mirror of
https://github.com/accelerator74/l4dtoolz.git
synced 2026-10-10 04:03:16 +08:00
2.2.0
New method for changing the MaxClients limit. Thanks to @A1mDev
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#define _INCLUDE_GAME_OFFSETS_
|
||||
|
||||
#if SH_SYS == SH_SYS_WIN32
|
||||
const int maxplayers_offs = 0x228; // m_nMaxClientsLimit (in CGameServer::SetMaxClients)
|
||||
#if SOURCE_ENGINE == SE_LEFT4DEAD
|
||||
const int sv_offs = 6; // IServer pointer (in IVEngineServer::CreateFakeClient)
|
||||
const int maxhuman_idx = 131; // CTerrorGameRules::GetMaxHumanPlayers vtable
|
||||
@@ -11,7 +10,6 @@
|
||||
const int maxhuman_idx = 136; // CTerrorGameRules::GetMaxHumanPlayers vtable
|
||||
#endif
|
||||
#else
|
||||
const int maxplayers_offs = 0x220; // m_nMaxClientsLimit (in CGameServer::SetMaxClients)
|
||||
#if SOURCE_ENGINE == SE_LEFT4DEAD
|
||||
const char* engine_dll = "engine.so";
|
||||
const int maxhuman_idx = 132; // CTerrorGameRules::GetMaxHumanPlayers vtable
|
||||
|
||||
+4
-33
@@ -117,23 +117,11 @@ bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
|
||||
g_pGameIServer = (CBaseServer *)g_MemUtils.ResolveSymbol(handle, "sv");
|
||||
dlclose(handle);
|
||||
#endif
|
||||
int* m_nMaxClientsLimit = reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(g_pGameIServer)+maxplayers_offs);
|
||||
if (*m_nMaxClientsLimit != 18) {
|
||||
Warning("Couldn't patch maxplayers\n");
|
||||
if (!late) {
|
||||
g_pGameIServer = NULL;
|
||||
}
|
||||
} else {
|
||||
*m_nMaxClientsLimit = 32;
|
||||
const char *pszCmdLineMax;
|
||||
if(CommandLine()->CheckParm("-maxplayers", &pszCmdLineMax) || CommandLine()->CheckParm("+maxplayers", &pszCmdLineMax)) {
|
||||
char command[32];
|
||||
UTIL_Format(command, sizeof(command), "maxplayers %d\n", clamp(atoi(pszCmdLineMax), 1, 32));
|
||||
engine->ServerCommand(command);
|
||||
if (CommandLine()->CheckParm("-maxplayers", &pszCmdLineMax)) {
|
||||
g_pGameIServer->m_nMaxclients = clamp(atoi(pszCmdLineMax), 1, 32);
|
||||
} else {
|
||||
engine->ServerCommand("maxplayers 31\n");
|
||||
}
|
||||
engine->ServerExecute();
|
||||
g_pGameIServer->m_nMaxclients = 31;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,23 +191,6 @@ void l4dtoolz::LevelShutdown()
|
||||
}
|
||||
}
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
len = maxlength - 1;
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
ServerClass *UTIL_FindServerClass(const char *classname)
|
||||
{
|
||||
ServerClass *sc = gamedll->GetAllServerClasses();
|
||||
@@ -242,7 +213,7 @@ const char *l4dtoolz::GetLicense()
|
||||
|
||||
const char *l4dtoolz::GetVersion()
|
||||
{
|
||||
return "2.1.0";
|
||||
return "2.2.0";
|
||||
}
|
||||
|
||||
const char *l4dtoolz::GetDate()
|
||||
|
||||
@@ -26,7 +26,6 @@ public:
|
||||
static void OnChangeUnreserved ( IConVar *var, const char *pOldValue, float flOldValue );
|
||||
};
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
ServerClass *UTIL_FindServerClass(const char *classname);
|
||||
|
||||
extern l4dtoolz g_l4dtoolz;
|
||||
|
||||
Reference in New Issue
Block a user