Add hack-fix for CS:S reverting name changes done with SetClientName.

This commit is contained in:
Nicholas Hastings 2015-03-22 18:29:11 -04:00
parent d12d7625aa
commit 885117fb66
2 changed files with 34 additions and 1 deletions

View File

@ -50,6 +50,9 @@
*/ */
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool); SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
#if SOURCE_ENGINE == SE_CSS
SH_DECL_HOOK1_void_vafmt(IVEngineServer, ClientCommand, SH_NOATTRIB, 0, edict_t *);
#endif
SDKTools g_SdkTools; /**< Global singleton for extension's main interface */ SDKTools g_SdkTools; /**< Global singleton for extension's main interface */
IServerGameEnts *gameents = NULL; IServerGameEnts *gameents = NULL;
@ -261,6 +264,10 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
#endif #endif
GET_V_IFACE_ANY(GetEngineFactory, soundemitterbase, ISoundEmitterSystemBase, SOUNDEMITTERSYSTEM_INTERFACE_VERSION); GET_V_IFACE_ANY(GetEngineFactory, soundemitterbase, ISoundEmitterSystemBase, SOUNDEMITTERSYSTEM_INTERFACE_VERSION);
#if SOURCE_ENGINE == SE_CSS
SH_ADD_HOOK(IVEngineServer, ClientCommand, engine, SH_MEMBER(this, &SDKTools::OnSendClientCommand), false);
#endif
gpGlobals = ismm->GetCGlobals(); gpGlobals = ismm->GetCGlobals();
enginePatch = SH_GET_CALLCLASS(engine); enginePatch = SH_GET_CALLCLASS(engine);
enginesoundPatch = SH_GET_CALLCLASS(engsound); enginesoundPatch = SH_GET_CALLCLASS(engsound);
@ -268,6 +275,14 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
return true; return true;
} }
bool SDKTools::SDK_OnMetamodUnload(char *error, size_t maxlen)
{
#if SOURCE_ENGINE == SE_CSS
SH_REMOVE_HOOK(IVEngineServer, ClientCommand, engine, SH_MEMBER(this, &SDKTools::OnSendClientCommand), false);
#endif
return true;
}
void SDKTools::SDK_OnAllLoaded() void SDKTools::SDK_OnAllLoaded()
{ {
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools); SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
@ -456,6 +471,21 @@ void SDKTools::OnClientPutInServer(int client)
g_Hooks.OnClientPutInServer(client); g_Hooks.OnClientPutInServer(client);
} }
#if SOURCE_ENGINE == SE_CSS
void SDKTools::OnSendClientCommand(edict_t *pPlayer, const char *szFormat)
{
// Due to legacy code, CS:S still sends "name \"newname\"" to the client after a
// name change. The engine has a change hook on name causing it to reset to the
// player's Steam name. This quashes that to make SetClientName work properly.
if (!strncmp(szFormat, "name ", 5))
{
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
}
#endif
class SDKTools_API : public ISDKTools class SDKTools_API : public ISDKTools
{ {
public: public:

View File

@ -83,7 +83,7 @@ public: //public SDKExtension
public: public:
#if defined SMEXT_CONF_METAMOD #if defined SMEXT_CONF_METAMOD
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late); virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen); virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen);
//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen); //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen);
#endif #endif
public: //IConCommandBaseAccessor public: //IConCommandBaseAccessor
@ -101,6 +101,9 @@ public: // IVoiceServer
#else #else
void OnClientCommand(edict_t *pEntity); void OnClientCommand(edict_t *pEntity);
#endif #endif
#if SOURCE_ENGINE == SE_CSS
void OnSendClientCommand(edict_t *pPlayer, const char *szFormat);
#endif
public: //ICommandTargetProcessor public: //ICommandTargetProcessor
bool ProcessCommandTarget(cmd_target_info_t *info); bool ProcessCommandTarget(cmd_target_info_t *info);