From 5ff6b9ecdeac877342d3588b2892192fb229b7d3 Mon Sep 17 00:00:00 2001 From: jeefo Date: Thu, 10 Mar 2016 00:37:33 +0300 Subject: [PATCH] added compile-time support for up to 64 maxplayers --- include/core.h | 3 ++- include/engine.h | 2 +- include/globals.h | 4 ++-- source/globals.cpp | 4 ++-- source/interface.cpp | 4 ++-- source/manager.cpp | 8 ++++---- source/navigate.cpp | 4 ++++ source/waypoint.cpp | 12 +++++++++++- 8 files changed, 28 insertions(+), 13 deletions(-) diff --git a/include/core.h b/include/core.h index d15c9f9..99ebe14 100644 --- a/include/core.h +++ b/include/core.h @@ -552,6 +552,7 @@ const int MAX_WAYPOINTS = 1024; const int MAX_WEAPONS = 32; const int NUM_WEAPONS = 26; const int MAX_COLLIDE_MOVES = 3; +const int MAX_ENGINE_PLAYERS = 32; // we can have 64 players with xash // weapon masks const int WEAPON_PRIMARY = ((1 << WEAPON_XM1014) | (1 < m_creationTab; // bot creation tab - Bot *m_bots[32]; // all available bots + Bot *m_bots[MAX_ENGINE_PLAYERS]; // all available bots float m_maintainTime; // time to maintain bot creation float m_quotaMaintainTime; // time to maintain bot quota diff --git a/include/engine.h b/include/engine.h index 24b56f0..d2af737 100644 --- a/include/engine.h +++ b/include/engine.h @@ -185,7 +185,7 @@ public: inline int GetTeam (edict_t *ent) { - extern Client g_clients[32]; + extern Client g_clients[MAX_ENGINE_PLAYERS]; #ifndef XASH_CSDM return g_clients[IndexOfEntity (ent) - 1].team; diff --git a/include/globals.h b/include/globals.h index e59f302..5f40d7f 100644 --- a/include/globals.h +++ b/include/globals.h @@ -48,7 +48,7 @@ extern int g_rusherWeaponPrefs[NUM_WEAPONS]; extern int g_carefulWeaponPrefs[NUM_WEAPONS]; extern int g_grenadeBuyPrecent[NUM_WEAPONS - 23]; extern int g_botBuyEconomyTable[NUM_WEAPONS - 15]; -extern int g_radioSelect[32]; +extern int g_radioSelect[MAX_ENGINE_PLAYERS]; extern int g_lastRadio[2]; extern int g_storeAddbotVars[4]; extern int *g_weaponPrefs[]; @@ -62,7 +62,7 @@ extern RandomSequenceOfUnique Random; extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1]; extern WeaponProperty g_weaponDefs[MAX_WEAPONS + 1]; -extern Client g_clients[32]; +extern Client g_clients[MAX_ENGINE_PLAYERS]; extern MenuText g_menus[21]; extern TaskItem g_taskFilters[]; diff --git a/source/globals.cpp b/source/globals.cpp index 4e379f8..0bfb0b3 100644 --- a/source/globals.cpp +++ b/source/globals.cpp @@ -37,7 +37,7 @@ float g_autoPathDistance = 250.0f; int g_lastRadio[2]; int g_storeAddbotVars[4]; -int g_radioSelect[32]; +int g_radioSelect[MAX_ENGINE_PLAYERS]; int g_gameFlags = 0; int g_numWaypoints = 0; int g_mapType = 0; @@ -65,7 +65,7 @@ BlendAPI_t g_serverBlendingAPI = NULL; FuncPointers_t g_funcPointers = NULL; enginefuncs_t g_engfuncs; -Client g_clients[32]; +Client g_clients[MAX_ENGINE_PLAYERS]; WeaponProperty g_weaponDefs[MAX_WEAPONS + 1]; edict_t *g_hostEntity = NULL; diff --git a/source/interface.cpp b/source/interface.cpp index 7ac643f..8256024 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -1,4 +1,4 @@ -// +// // Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd"). // Copyright (c) YaPB Development Team. // @@ -1164,7 +1164,7 @@ void ClientDisconnect (edict_t *ent) int i = engine.IndexOfEntity (ent) - 1; - InternalAssert (i >= 0 && i < 32); + InternalAssert (i >= 0 && i < MAX_ENGINE_PLAYERS); Bot *bot = bots.GetBot (i); diff --git a/source/manager.cpp b/source/manager.cpp index 5959458..bb5711f 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -202,7 +202,7 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality, } int index = engine.IndexOfEntity (bot) - 1; - InternalAssert (index >= 0 && index <= 32); // check index + InternalAssert (index >= 0 && index <= MAX_ENGINE_PLAYERS); // check index InternalAssert (m_bots[index] == NULL); // check bot slot m_bots[index] = new Bot (bot, difficulty, personality, team, member, steamId); @@ -223,7 +223,7 @@ int BotManager::GetIndex (edict_t *ent) int index = engine.IndexOfEntity (ent) - 1; - if (index < 0 || index >= 32) + if (index < 0 || index >= MAX_ENGINE_PLAYERS) return -1; if (m_bots[index] != NULL) @@ -236,7 +236,7 @@ Bot *BotManager::GetBot (int index) { // this function finds a bot specified by index, and then returns pointer to it (using own bot array) - if (index < 0 || index >= 32) + if (index < 0 || index >= MAX_ENGINE_PLAYERS) return NULL; if (m_bots[index] != NULL) @@ -830,7 +830,7 @@ void BotManager::Free (void) { // this function free all bots slots (used on server shutdown) - for (int i = 0; i < 32; i++) + for (int i = 0; i < MAX_ENGINE_PLAYERS; i++) Free (i); } diff --git a/source/navigate.cpp b/source/navigate.cpp index 9134114..df5257b 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -30,6 +30,10 @@ int Bot::FindGoal (void) break; } } + + // forcing terrorist bot to not move to another bombspot + if (m_inBombZone && !m_hasProgressBar && m_hasC4) + return waypoints.FindNearest (pev->origin, 400.0f, FLAG_GOAL); } int tactic = 0; diff --git a/source/waypoint.cpp b/source/waypoint.cpp index 4044763..a24a1ec 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -1052,7 +1052,7 @@ void Waypoint::InitTypes (void) bool Waypoint::Load (void) { - MemoryFile fp (CheckSubfolderFile ()); + File fp (CheckSubfolderFile (), "rb"); WaypointHeader header; memset (&header, 0, sizeof (header)); @@ -1118,6 +1118,16 @@ bool Waypoint::Load (void) fp.Close (); return false; } + + // more checks of waypoint quality + if (m_paths[i]->pathNumber < 0 || m_paths[i]->pathNumber > g_numWaypoints) + { + sprintf (m_infoBuffer, "%s.pwf - bad waypoint file (path #%d index is out of bounds)", map, i); + AddLogEntry (true, LL_ERROR, m_infoBuffer); + + fp.Close (); + return false; + } } m_waypointPaths = true; }