From 773e358596d8e69aa02d95f3de4b10a4e036e00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bergstr=C3=B6m?= Date: Wed, 31 Mar 2004 06:15:27 +0000 Subject: [PATCH] Fixed setting players online once again --- dlls/cstrike/cstrike.cpp | 20 ++++++++++++++++++-- dlls/cstrike/cstrike.h | 20 +------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/dlls/cstrike/cstrike.cpp b/dlls/cstrike/cstrike.cpp index e846db50..804c3aa6 100755 --- a/dlls/cstrike/cstrike.cpp +++ b/dlls/cstrike/cstrike.cpp @@ -1359,12 +1359,27 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi return(TRUE); } - /****GetEntityAPI2_Post**********************************************************/ void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) { int index = ENTINDEX(pEntity); - if (!g_players[index].GetOnline()) + // Only BOTs are set online here! Players must not, because then cs_user_* natives will crash in client_connect, possibly also other early forwards. + if (!g_players[index].GetOnline() && strcmp(GETPLAYERAUTHID(pEntity), "BOT") == 0) { g_players[index].SetOnline(true); + //LOG_CONSOLE(PLID, "CSTRIKE MODULE: ClientUserInfoChanged_Post: %d was set to be online! (Auth: %s)", index, GETPLAYERAUTHID(pEntity)); + } + + RETURN_META(MRES_IGNORED); +} + +void ClientPutInServer_Post( edict_t *pEntity ) { + int index = ENTINDEX(pEntity); + // At this place normal players will be set online. Bots (at least MM bots) don't normally ever get caught here so they can't be set online here. + // There might be other implementations of bots though that are caught by MM, so they will be set online here if they didn't already + // in ClientUserInfoChanged_Post above... + if (!g_players[index].GetOnline()) { + g_players[index].SetOnline(true); + //LOG_CONSOLE(PLID, "CSTRIKE MODULE: ClientPutInServer_Post: %d was set to be online! (Auth: %s)", index, GETPLAYERAUTHID(pEntity)); + } RETURN_META(MRES_IGNORED); } @@ -1372,6 +1387,7 @@ void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) { DLL_FUNCTIONS gFunctionTable_Post; C_DLLEXPORT int GetEntityAPI2_Post( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) { gFunctionTable_Post.pfnClientUserInfoChanged = ClientUserInfoChanged_Post; + gFunctionTable_Post.pfnClientPutInServer = ClientPutInServer_Post; if(*interfaceVersion!=INTERFACE_VERSION) { LOG_ERROR(PLID, "GetEntityAPI2_Post version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION); diff --git a/dlls/cstrike/cstrike.h b/dlls/cstrike/cstrike.h index 22ee16ec..61f1e6c7 100755 --- a/dlls/cstrike/cstrike.h +++ b/dlls/cstrike/cstrike.h @@ -1,4 +1,4 @@ -#define __cswonbuild__ // comment when compiling for STEAM +//#define __cswonbuild__ // comment when compiling for STEAM /* AMX Mod X * Counter-Strike Module @@ -151,24 +151,6 @@ pfnmodule_engine_g* g_engModuleFunc; #define OFFSET_HOSTAGEID 487 + EXTRAOFFSET #endif // defined __cswonbuild__ -// Offsets of ammo amount in player entities -/* -382 int awm -383 int scout, ak, g3 -384 int para -385 int famas, m4a1, aug, sg550, galil, sg552 -386 int m3, xm -387 int usp, ump, mac -388 int fiveseven, p90 -389 int deagle -390 int p228 -391 int glock, mp5, tmp, elites -392 int flash -393 int he -394 int smoke -395 int c4 -*/ - // Ids of weapons in CS #define CSW_P228 1 //#define CSW_SHIELD 2