fixed amb1252, GetPlayerInfo wouldnt work for the last player index
fixed iserver crashing on linux --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401779
This commit is contained in:
parent
6151b89b94
commit
1ad8e34181
@ -83,18 +83,28 @@ void InitializeValveGlobals()
|
||||
}
|
||||
#endif
|
||||
|
||||
bool vcmp(const void *_addr1, const void *_addr2, size_t len)
|
||||
{
|
||||
unsigned char *addr1 = (unsigned char *)_addr1;
|
||||
unsigned char *addr2 = (unsigned char *)_addr2;
|
||||
|
||||
for (size_t i=0; i<len; i++)
|
||||
{
|
||||
if (addr2[i] == '*')
|
||||
continue;
|
||||
if (addr1[i] != addr2[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
/* Thanks to DS for the sigs */
|
||||
#define ISERVER_WIN_SIG "\x8B\x44\x24\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8"
|
||||
#define ISERVER_WIN_SIG_LEN 11
|
||||
void GetIServer()
|
||||
{
|
||||
/* First check that the IVEngineServer::CreateFakeClient exists */
|
||||
if (!memutils->FindPattern(engine, ISERVER_WIN_SIG, ISERVER_WIN_SIG_LEN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int offset;
|
||||
void *vfunc = NULL;
|
||||
|
||||
@ -110,6 +120,12 @@ void GetIServer()
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if we're on the expected function */
|
||||
if (!vcmp(vfunc, ISERVER_WIN_SIG, ISERVER_WIN_SIG_LEN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Finally we have the interface we were looking for */
|
||||
iserver = *reinterpret_cast<IServer **>(reinterpret_cast<unsigned char *>(vfunc) + offset);
|
||||
#else
|
||||
@ -123,6 +139,11 @@ void GetIServer()
|
||||
void **vtable = *reinterpret_cast<void ***>(enginePatch->GetThisPtr() + info.thisptroffs + info.vtbloffs);
|
||||
vfunc = vtable[info.vtblindex];
|
||||
}
|
||||
/* Check if we're on the expected function */
|
||||
if (!vcmp(vfunc, ISERVER_WIN_SIG, ISERVER_WIN_SIG_LEN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iserver = *reinterpret_cast<IServer **>(reinterpret_cast<unsigned char *>(vfunc) + offset);
|
||||
#endif
|
||||
@ -136,6 +157,6 @@ void GetIServer()
|
||||
return;
|
||||
}
|
||||
|
||||
iserver = *reinterpret_cast<IServer **>(addr);
|
||||
iserver = reinterpret_cast<IServer *>(addr);
|
||||
}
|
||||
#endif
|
||||
|
@ -272,7 +272,7 @@ bool GetPlayerInfo(int client, player_info_t *info)
|
||||
#if defined ORANGEBOX_BUILD
|
||||
return engine->GetPlayerInfo(client, info);
|
||||
#else
|
||||
return iserver->GetPlayerInfo(client, info);
|
||||
return (iserver) ? iserver->GetPlayerInfo(client-1, info) : false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -853,6 +853,11 @@ static cell_t GetPlayerDecalFile(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
static cell_t GetServerNetStats(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (iserver == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("IServer interface not supported, file a bug report.");
|
||||
}
|
||||
|
||||
float in, out;
|
||||
cell_t *pIn, *pOut;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user