This commit is contained in:
David Anderson 2010-07-02 18:17:16 -07:00
commit 651dfb796c
21 changed files with 236 additions and 33 deletions

View File

@ -42,7 +42,7 @@ using namespace SourceMod;
* Add 1 to the RHS of this expression to bump the intercom file * Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries * This is to prevent mismatching core/logic binaries
*/ */
#define SM_LOGIC_MAGIC (0x0F47C0DE - 14) #define SM_LOGIC_MAGIC (0x0F47C0DE - 15)
#if defined SM_LOGIC #if defined SM_LOGIC
class IVEngineServer class IVEngineServer

View File

@ -507,6 +507,22 @@ static cell_t FindFlagByChar(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
static cell_t FindFlagChar(IPluginContext *pContext, const cell_t *params)
{
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
char flagchar;
if (!adminsys->FindFlagChar((AdminFlag)params[1], &flagchar))
{
return 0;
}
*addr = (cell_t)flagchar;
return 1;
}
static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params) static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params)
{ {
char *flag; char *flag;
@ -563,6 +579,7 @@ REGISTER_NATIVES(adminNatives)
{"CreateAuthMethod", CreateAuthMethod}, {"CreateAuthMethod", CreateAuthMethod},
{"FindFlagByName", FindFlagByName}, {"FindFlagByName", FindFlagByName},
{"FindFlagByChar", FindFlagByChar}, {"FindFlagByChar", FindFlagByChar},
{"FindFlagChar", FindFlagChar},
{"ReadFlagString", ReadFlagString}, {"ReadFlagString", ReadFlagString},
{"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel}, {"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel},
{"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel}, {"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel},

View File

@ -16,6 +16,7 @@ binary.AddSourceFiles('extensions/tf2', [
'RegNatives.cpp', 'RegNatives.cpp',
'util.cpp', 'util.cpp',
'criticals.cpp', 'criticals.cpp',
'holiday.cpp',
'CDetour/detours.cpp', 'CDetour/detours.cpp',
'sdk/smsdk_ext.cpp', 'sdk/smsdk_ext.cpp',
'asm/asm.c' 'asm/asm.c'

View File

@ -19,7 +19,7 @@ PROJECT = game.tf2
USEMETA = true USEMETA = true
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp criticals.cpp \ OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp criticals.cpp \
util.cpp CDetour/detours.cpp asm/asm.c holiday.cpp util.cpp CDetour/detours.cpp asm/asm.c
############################################## ##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###

View File

@ -188,7 +188,7 @@ DETOUR_DECL_MEMBER0(CalcIsAttackCriticalHelperBow, bool)
} }
} }
void InitialiseDetours() void InitialiseCritDetours()
{ {
calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical"); calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical");
calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee"); calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee");
@ -222,7 +222,7 @@ void InitialiseDetours()
} }
void RemoveDetours() void RemoveCritDetours()
{ {
calcIsAttackCriticalDetour->Destroy(); calcIsAttackCriticalDetour->Destroy();
calcIsAttackCriticalMeleeDetour->Destroy(); calcIsAttackCriticalMeleeDetour->Destroy();

View File

@ -37,8 +37,8 @@
#include <jit/x86/x86_macros.h> #include <jit/x86/x86_macros.h>
#include "CDetour/detours.h" #include "CDetour/detours.h"
void InitialiseDetours(); void InitialiseCritDetours();
void RemoveDetours(); void RemoveCritDetours();
extern IForward *g_critForward; extern IForward *g_critForward;

View File

@ -36,6 +36,7 @@
#include "iplayerinfo.h" #include "iplayerinfo.h"
#include "sm_trie_tpl.h" #include "sm_trie_tpl.h"
#include "criticals.h" #include "criticals.h"
#include "holiday.h"
#include "CDetour/detours.h" #include "CDetour/detours.h"
/** /**
@ -108,10 +109,12 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
playerhelpers->RegisterCommandTargetProcessor(this); playerhelpers->RegisterCommandTargetProcessor(this);
g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef); g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef);
g_getHolidayForward = forwards->CreateForward("TF2_OnGetHoliday", ET_Event, 1, NULL, Param_CellByRef);
g_pCVar = icvar; g_pCVar = icvar;
m_DetoursEnabled = false; m_CritDetoursEnabled = false;
m_GetHolidayDetourEnabled = false;
return true; return true;
} }
@ -155,6 +158,7 @@ void TF2Tools::SDK_OnUnload()
plsys->RemovePluginsListener(this); plsys->RemovePluginsListener(this);
forwards->ReleaseForward(g_critForward); forwards->ReleaseForward(g_critForward);
forwards->ReleaseForward(g_getHolidayForward);
} }
void TF2Tools::SDK_OnAllLoaded() void TF2Tools::SDK_OnAllLoaded()
@ -297,19 +301,29 @@ bool TF2Tools::ProcessCommandTarget(cmd_target_info_t *info)
void TF2Tools::OnPluginLoaded(IPlugin *plugin) void TF2Tools::OnPluginLoaded(IPlugin *plugin)
{ {
if (!m_DetoursEnabled && g_critForward->GetFunctionCount()) if (!m_CritDetoursEnabled && g_critForward->GetFunctionCount())
{ {
InitialiseDetours(); InitialiseCritDetours();
m_DetoursEnabled = true; m_CritDetoursEnabled = true;
}
if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
{
InitialiseGetHolidayDetour();
m_GetHolidayDetourEnabled = true;
} }
} }
void TF2Tools::OnPluginUnloaded(IPlugin *plugin) void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
{ {
if (m_DetoursEnabled && !g_critForward->GetFunctionCount()) if (m_CritDetoursEnabled && !g_critForward->GetFunctionCount())
{ {
RemoveDetours(); RemoveCritDetours();
m_DetoursEnabled = false; m_CritDetoursEnabled = false;
}
if (m_GetHolidayDetourEnabled && !g_getHolidayForward->GetFunctionCount())
{
RemoveGetHolidayDetour();
m_GetHolidayDetourEnabled = false;
} }
} }
int FindResourceEntity() int FindResourceEntity()

View File

@ -112,7 +112,8 @@ public:
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late); virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
#endif #endif
private: private:
bool m_DetoursEnabled; bool m_CritDetoursEnabled;
bool m_GetHolidayDetourEnabled;
}; };
enum TFClassType enum TFClassType

View File

@ -0,0 +1,77 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "holiday.h"
CDetour *getHolidayDetour = NULL;
IForward *g_getHolidayForward = NULL;
DETOUR_DECL_MEMBER0(GetHoliday, int)
{
int actualres = DETOUR_MEMBER_CALL(GetHoliday)();
if (!g_getHolidayForward)
{
g_pSM->LogMessage(myself, "Invalid Forward");
return actualres;
}
cell_t result = 0;
int newres = actualres;
g_getHolidayForward->PushCellByRef(&newres);
g_getHolidayForward->Execute(&result);
if (result == Pl_Changed)
{
return newres;
}
return actualres;
}
void InitialiseGetHolidayDetour()
{
getHolidayDetour = DETOUR_CREATE_MEMBER(GetHoliday, "GetHoliday");
if (!getHolidayDetour)
{
g_pSM->LogError(myself, "GetHoliday detour failed");
return;
}
getHolidayDetour->EnableDetour();
}
void RemoveGetHolidayDetour()
{
getHolidayDetour->Destroy();
}

45
extensions/tf2/holiday.h Normal file
View File

@ -0,0 +1,45 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_HOLIDAY_H_
#define _INCLUDE_SOURCEMOD_HOLIDAY_H_
#include "extension.h"
#include <jit/jit_helpers.h>
#include <jit/x86/x86_macros.h>
#include "CDetour/detours.h"
void InitialiseGetHolidayDetour();
void RemoveGetHolidayDetour();
extern IForward *g_getHolidayForward;
#endif //_INCLUDE_SOURCEMOD_HOLIDAY_H_

View File

@ -194,6 +194,10 @@
RelativePath="..\extension.cpp" RelativePath="..\extension.cpp"
> >
</File> </File>
<File
RelativePath="..\holiday.cpp"
>
</File>
<File <File
RelativePath="..\natives.cpp" RelativePath="..\natives.cpp"
> >
@ -220,6 +224,10 @@
RelativePath="..\extension.h" RelativePath="..\extension.h"
> >
</File> </File>
<File
RelativePath="..\holiday.h"
>
</File>
<File <File
RelativePath="..\RegNatives.h" RelativePath="..\RegNatives.h"
> >

View File

@ -19,7 +19,6 @@
"game" "ageofchivalry" "game" "ageofchivalry"
"game" "zps" "game" "zps"
"game" "bg2" "game" "bg2"
"game" "garrysmod"
"game" "pvkii" "game" "pvkii"
"game" "gesource" "game" "gesource"
"game" "empires" "game" "empires"

View File

@ -19,6 +19,7 @@
"game" "dod" "game" "dod"
"game" "tf" "game" "tf"
"game" "cstrike" "game" "cstrike"
"game" "garrysmod"
} }
"Offsets" "Offsets"

View File

@ -21,7 +21,6 @@
"game" "empires" "game" "empires"
"game" "synergy" "game" "synergy"
"game" "bg2" "game" "bg2"
"game" "garrysmod"
"game" "pvkii" "game" "pvkii"
"game" "gesource" "game" "gesource"
} }
@ -124,7 +123,6 @@
"game" "empires" "game" "empires"
"game" "synergy" "game" "synergy"
"game" "bg2" "game" "bg2"
"game" "garrysmod"
"game" "pvkii" "game" "pvkii"
"game" "gesource" "game" "gesource"
"game" "RnLBeta" "game" "RnLBeta"

View File

@ -19,6 +19,7 @@
"game" "dod" "game" "dod"
"game" "tf" "game" "tf"
"game" "cstrike" "game" "cstrike"
"game" "garrysmod"
} }
"Offsets" "Offsets"
@ -124,6 +125,7 @@
"game" "dod" "game" "dod"
"game" "tf" "game" "tf"
"game" "cstrike" "game" "cstrike"
"game" "garrysmod"
} }
"Offsets" "Offsets"

View File

@ -11,48 +11,46 @@
"Games" "Games"
{ {
/* Garry's Mod 10 - Windows only /* Garry's Mod - Windows only */
* This mod is not officially supported
*/
"garrysmod" "garrysmod"
{ {
"Offsets" "Offsets"
{ {
"GiveNamedItem" "GiveNamedItem"
{ {
"windows" "391" "windows" "426"
} }
"RemovePlayerItem" "RemovePlayerItem"
{ {
"windows" "279" "windows" "300"
} }
"Weapon_GetSlot" "Weapon_GetSlot"
{ {
"windows" "277" "windows" "298"
} }
"Ignite" "Ignite"
{ {
"windows" "228" "windows" "237"
} }
"Extinguish" "Extinguish"
{ {
"windows" "232" "windows" "241"
} }
"Teleport" "Teleport"
{ {
"windows" "101" "windows" "106"
} }
"CommitSuicide" "CommitSuicide"
{ {
"windows" "429" "windows" "464"
} }
"GetVelocity" "GetVelocity"
{ {
"windows" "131" "windows" "138"
} }
"EyeAngles" "EyeAngles"
{ {
"windows" "123" "windows" "129"
} }
"AcceptInput" "AcceptInput"
{ {
@ -76,7 +74,7 @@
} }
"WeaponEquip" "WeaponEquip"
{ {
"windows" "270" "windows" "291"
} }
"Activate" "Activate"
{ {
@ -84,7 +82,7 @@
} }
"PlayerRunCmd" "PlayerRunCmd"
{ {
"windows" "409" "windows" "444"
} }
"FireOutputBackup" "FireOutputBackup"
{ {

View File

@ -92,6 +92,13 @@
"linux" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer" "linux" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer"
"mac" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer" "mac" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer"
} }
"GetHoliday"
{
"library" "server"
"windows" "\x81\xEC\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x83\x2A\x2A\x2A\x56\x8B\xF1\x89\x2A\x2A\x2A\x74\x2A\xB8"
"linux" "@_ZN12CTFGameRules10GetHolidayEv"
"mac" "@_ZN12CTFGameRules10GetHolidayEv"
}
} }
"Offsets" "Offsets"
{ {

View File

@ -516,6 +516,15 @@ native bool:FindFlagByName(const String:name[], &AdminFlag:flag);
*/ */
native bool:FindFlagByChar(c, &AdminFlag:flag); native bool:FindFlagByChar(c, &AdminFlag:flag);
/**
* Finds a flag char by a gived admin flag.
*
* @param flag Flag to look up.
* @param c Variable to store flag char.
* @return True on success, false if not found.
*/
native bool:FindFlagChar(AdminFlag:flag, &c);
/** /**
* Converts a string of flag characters to a bit string. * Converts a string of flag characters to a bit string.
* *

View File

@ -99,6 +99,13 @@ enum TFCond
TFCond_Jarated TFCond_Jarated
}; };
enum TFHoliday
{
TFHoliday_None = 1,
TFHoliday_Halloween,
TFHoliday_Birthday
};
/** /**
* Sets a client on fire for 10 seconds. * Sets a client on fire for 10 seconds.
* *
@ -224,6 +231,16 @@ native TFClassType:TF2_GetClass(const String:classname[]);
*/ */
forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result); forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result);
/**
* Called when the game checks to see if the current day is one of its tracked holidays
*
* @note Change the value of holiday and return Plugin_Changed to override.
* Return Plugin_Continue for no change.
*
* @param holiday Current Holiday
*/
forward Action:TF2_OnGetHoliday(&TFHoliday:holiday);
/** /**
* Do not edit below this line! * Do not edit below this line!
*/ */

View File

@ -35,7 +35,7 @@
#include <IShareSys.h> #include <IShareSys.h>
#define SMINTERFACE_ADMINSYS_NAME "IAdminSys" #define SMINTERFACE_ADMINSYS_NAME "IAdminSys"
#define SMINTERFACE_ADMINSYS_VERSION 5 #define SMINTERFACE_ADMINSYS_VERSION 6
/** /**
* @file IAdminSystem.h * @file IAdminSystem.h
@ -717,6 +717,15 @@ namespace SourceMod
const char *cmd, const char *cmd,
FlagBits flags, FlagBits flags,
bool override_only) =0; bool override_only) =0;
/**
* @brief Reads a flag as the corresponding character.
*
* @param flag Flag to look up.
* @param c Variable to store flag char.
* @return True on success, false if not found.
*/
virtual bool FindFlagChar(AdminFlag flag, char *c) =0;
}; };
} }

View File

@ -1,4 +1,4 @@
a billion and nanas a billion and nanas
joys of buildbot, part 2: buildbot and the very lonely square-shaped duck joys of buildbot, part 2: buildbot and the very lonely square-shaped duck
joys of buildbot, part 3: an accidental event proves troublesome for a psychic fish joys of buildbot, part 3: an accidental event proves troublesome for a psychic fish
joys of buildbot, part 4: a transient mummy is perplexed by a broken wand joys of buildbot, part 4: a transient mummy is perplexed by a broken wand