From 4b8c18001ddcde003d8df147095d1832b1addf8d Mon Sep 17 00:00:00 2001 From: jeefo Date: Sat, 26 Dec 2015 17:19:20 +0300 Subject: [PATCH] removed useless things merged changes for xash csdm into master --- include/compress.h | 10 ++ include/core.h | 39 +++++- include/corelib.h | 288 +------------------------------------------ include/globals.h | 4 + source/basecode.cpp | 7 +- source/interface.cpp | 5 +- source/manager.cpp | 24 ++++ source/navigate.cpp | 4 +- source/netmsg.cpp | 14 ++- source/support.cpp | 6 +- source/waypoint.cpp | 35 ------ 11 files changed, 102 insertions(+), 334 deletions(-) diff --git a/include/compress.h b/include/compress.h index 9151f77..b64f3f3 100644 --- a/include/compress.h +++ b/include/compress.h @@ -151,6 +151,11 @@ public: m_matchPosition = 0; m_matchLength = 0; + + memset (m_textBuffer, 0, sizeof (m_textBuffer)); + memset (m_right, 0, sizeof (m_right)); + memset (m_left, 0, sizeof (m_right)); + memset (m_parent, 0, sizeof (m_parent)); } ~Compressor (void) @@ -160,6 +165,11 @@ public: m_matchPosition = 0; m_matchLength = 0; + + memset (m_textBuffer, 0, sizeof (m_textBuffer)); + memset (m_right, 0, sizeof (m_right)); + memset (m_left, 0, sizeof (m_left)); + memset (m_parent, 0, sizeof (m_parent)); } int InternalEncode (const char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize) diff --git a/include/core.h b/include/core.h index 01840b9..ee2b6b6 100644 --- a/include/core.h +++ b/include/core.h @@ -358,6 +358,7 @@ enum ChatterMessage // counter-strike weapon id's enum Weapon { +#ifndef XASH_CSDM WEAPON_P228 = 1, WEAPON_SHIELD = 2, WEAPON_SCOUT = 3, @@ -391,6 +392,41 @@ enum Weapon WEAPON_ARMOR = 31, WEAPON_ARMORHELM = 32, WEAPON_DEFUSER = 33 +#else + WEAPON_KNIFE = 1, + WEAPON_USP = 2, + WEAPON_GLOCK = 3, + WEAPON_EXPLOSIVE = 4, + WEAPON_FLASHBANG = 5, + WEAPON_SMOKE = 6, + WEAPON_M4A1 = 7, + WEAPON_AK47 = 8, + WEAPON_AWP = 9, + WEAPON_GALIL = 10, + WEAPON_FAMAS = 11, + WEAPON_DEAGLE = 12, + WEAPON_AUG = 13, + WEAPON_SG552 = 14, + WEAPON_MP5 = 15, + WEAPON_M3 = 16, + WEAPON_C4 = 17, + WEAPON_SCOUT = 18, + WEAPON_MAC10 = 19, + WEAPON_M249 = 20, + WEAPON_FIVESEVEN = 21, + WEAPON_UMP45 = 22, + WEAPON_TMP = 23, + WEAPON_G3SG1 = 24, + WEAPON_SG550 = 25, + WEAPON_ELITE = 26, + WEAPON_P228 = 27, + WEAPON_SHIELD = 28, + WEAPON_XM1014 = 29, + WEAPON_P90 = 30, + WEAPON_ARMOR = 31, + WEAPON_ARMORHELM = 32, + WEAPON_DEFUSER = 33 +#endif }; // defines for pickup items @@ -1473,7 +1509,6 @@ private: float m_pathDisplayTime; float m_arrowDisplayTime; float m_waypointDisplayTime[MAX_WAYPOINTS]; - float m_goalsScore[MAX_WAYPOINTS]; int m_findWPIndex; int m_facingAtIndex; char m_infoBuffer[256]; @@ -1545,10 +1580,8 @@ public: const char *GetWaypointInfo (int id); char *GetInfo (void) { return m_infoBuffer; } - int AddGoalScore (int index, int other[4]); void SetFindIndex (int index); void SetLearnJumpWaypoint (void); - void ClearGoalScore (void); bool IsGoalVisited (int index); void SetGoalVisited (int index); diff --git a/include/corelib.h b/include/corelib.h index 5b5ba5b..9666868 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -1643,7 +1643,8 @@ protected: public: HashItem (void) { - m_next = NULL; + m_next = NULL; + m_index = 0; } HashItem (int index, HashItem *next) @@ -1948,291 +1949,6 @@ public: } }; -// -// Class: HashTable -// Represents Hash Table container. -// -template class HashTable -{ -protected: - struct HashItem - { - public: - K m_key; - int m_index; - - public: - HashItem (void) { m_index = 0; } - HashItem (const K &key, int index) { m_key = key; m_index = index; } - }; - - int m_hashSize; - Array *m_table; - Array m_symTable; - - V *InternalGet (const K &keyName, bool create) - { - int index = GetIndex (keyName, create); - - if (index < 0) - return 0; - - return &m_symTable[index]; - } - -// Group: (Con/De)structors -public: - - // - // Function: HashTable - // Default hash table container constructor. - // - // Parameters: - // hashSize - Initial hash size. - // - HashTable (int hashSize = 36) - { - m_hashSize = hashSize; - m_table = new Array [hashSize]; - } - - // - // Function: ~HashTable - // Default hash table container destructor. - // - virtual ~HashTable (void) - { - RemoveAll (); - delete [] m_table; - } - - // - // Function: IsEmpty - // Checks whether container is empty. - // - // Returns: - // True if no elements in container, false otherwise. - // - bool IsEmpty (void) - { - return m_symTable.GetSize () == 0; - } - - // - // Function: SetupHashTable - // Setups the hash table. - // - // Parameters: - // hashSize - Initial hash size. - // - void SetupHashTable (int hashSize) - { - m_hashSize = hashSize; - m_table = new Array [hashSize]; - } - - // - // Function: IsExists - // Checks whether element exists in container. - // - // Parameters: - // keyName - Key name of element, that should be checked. - // - // Returns: - // True if element exists, false otherwise. - // - bool IsExists (const K &keyName) - { - return InternalGet (keyName, false) != 0; - } - - // - // Function: GetSize - // Gets the size of container. - // - // Returns: - // Number of elements in container. - // - int GetSize (void) - { - return m_symTable.GetSize (); - } - - V &operator [] (const K &keyName) - { - return *InternalGet (keyName, true); - } - - // - // Function: Get - // Gets the value, by it's index. - // - // Parameters: - // index - Index of element. - // - // Returns: - // Reference to element. - // - V &Get (int index) - { - return m_symTable[index]; - } - - // - // Function: GetElements - // Gets the all elements of container. - // - // Returns: - // Array of elements, containing inside container. - // - // See Also: - // - // - const Array &GetElements (void) const - { - return m_symTable; - } - - // - // Function: Find - // Finds element by his key name. - // - // Parameters: - // keyName - Key name to be searched. - // element - Holder for element object. - // - // Returns: - // True if element found, false otherwise. - // - bool Find (const K &keyName, V &element) const - { - V *hashPtr = const_cast *> (this)->InternalGet (keyName, false); - - if (hashPtr != NULL) - { - element = *hashPtr; - return true; - } - return false; - } - - // - // Function: Find - // Finds element by his key name. - // - // Parameters: - // keyName - Key name to be searched. - // elementPtr - Holder for element pointer. - // - // Returns: - // True if element found, false otherwise. - // - bool Find (const K &keyName, V *&elementPtr) const - { - V *hashPtr = const_cast *> (this)->InternalGet (keyName, false); - - if (hashPtr != NULL) - { - elementPtr = hashPtr; - return true; - } - return false; - } - - // - // Function: Remove - // Removes element from container. - // - // Parameters: - // keyName - Key name of element, that should be removed. - // - // Returns: - // Removed element. - // - V Remove (const K &keyName) - { - V removeResult; - - int hashId = Hash (keyName) % m_hashSize; - Array &bucket = m_table[hashId]; - - for (int i = 0; i < bucket.GetSize (); i++) - { - const HashItem &item = bucket[i]; - - if (item.m_key == keyName) - { - int index = item.m_index; - - removeResult = m_symTable.RemoveAt (index); - bucket.RemoveAt (i); - - for (hashId = 0; hashId < m_hashSize; hashId++) - { - Array &bucket = m_table[hashId]; - - for (int j = 0; j < bucket.GetSize (); j++) - { - const HashItem &item = bucket[j]; - - if (item.m_index > index) - item.m_index--; - } - } - return removeResult; - } - } - return removeResult; - } - - // - // Function: GetIndex - // Gets index of element. - // - // Parameters: - // keyName - Key of element. - // create - If true and no element found by a keyName, create new element. - // - // Returns: - // Either found index, created index, or -1 in case of error. - // - int GetIndex (const K &keyName, bool create) - { - int hashId = Hash (keyName) % m_hashSize; - Array &bucket = m_table[hashId]; - - for (int i = 0; i < bucket.GetSize (); i++) - { - const HashItem &item = bucket[i]; - - if (item.m_key == keyName) - return item.m_index; - } - - if (create) - { - int symSize = m_symTable.GetSize (); - m_symTable.SetSize (static_cast (symSize + 1)); - - bucket.Push (HashItem (keyName, symSize)); - return symSize; - } - return -1; - } - - // - // Function: RemoveAll - // Removes all elements from container. - // - void RemoveAll (void) - { - for (int i = 0; i < m_hashSize; ++i) - m_table[i].RemoveAll (); - - m_symTable.RemoveAll (); - } -}; - // // Class: String // Reference counted string class. diff --git a/include/globals.h b/include/globals.h index 6e7ce41..233ee23 100644 --- a/include/globals.h +++ b/include/globals.h @@ -124,5 +124,9 @@ static inline bool IsEntityNull (const edict_t *ent) static inline int GetTeam (edict_t *ent) { +#ifndef XASH_CSDM return g_clients[IndexOfEntity (ent) - 1].team; +#else + return g_clients[IndexOfEntity (ent) - 1].team = ent->v.team == 1 ? TEAM_TF : TEAM_CF; +#endif } \ No newline at end of file diff --git a/source/basecode.cpp b/source/basecode.cpp index f7c58e9..353ea55 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -1240,7 +1240,7 @@ void Bot::CheckMessageQueue (void) } } - if (m_radioSelect != Radio_ReportingIn && g_radioInsteadVoice || yb_communication_type.GetInt () != 2 || g_chatterFactory[m_radioSelect].IsEmpty () || g_gameVersion == CSV_OLD) + if (m_radioSelect != Radio_ReportingIn || g_radioInsteadVoice || yb_communication_type.GetInt () != 2 || g_chatterFactory[m_radioSelect].IsEmpty () || g_gameVersion == CSV_OLD) { if (m_radioSelect < Radio_GoGoGo) FakeClientCommand (GetEntity (), "radio1"); @@ -2964,6 +2964,11 @@ void Bot::ThinkDelayed (void) else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10.0f && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool ()) botMovement = true; +#ifdef XASH_CSDM + if (m_notKilled) + botMovement = true; +#endif + CheckMessageQueue (); // check for pending messages // remove voice icon diff --git a/source/interface.cpp b/source/interface.cpp index bb190dc..c58eb6f 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -980,6 +980,7 @@ int Spawn (edict_t *ent) } else if (strcmp (STRING (ent->v.classname), "player_weaponstrip") == 0 && (STRING (ent->v.target))[0] == '0') ent->v.target = ent->v.targetname = ALLOC_STRING ("fake"); +#ifndef XASH_CSDM else if (strcmp (STRING (ent->v.classname), "info_player_start") == 0) { SET_MODEL (ent, ENGINE_STR ("models/player/urban/urban.mdl")); @@ -1005,6 +1006,7 @@ int Spawn (edict_t *ent) ent->v.renderamt = 127; // set its transparency amount ent->v.effects |= EF_NODRAW; } +#endif else if (strcmp (STRING (ent->v.classname), "func_vip_safetyzone") == 0 || strcmp (STRING (ent->v.classname), "info_vip_safetyzone") == 0) g_mapType |= MAP_AS; // assassination map @@ -3029,7 +3031,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t #endif char gameDLLName[256]; - snprintf (gameDLLName, sizeof (gameDLLName), "%s/%s", getenv ("XASH3D_GAMELIBDIR"), GAME_SERVER_DLL); + snprintf (gameDLLName, SIZEOF_CHAR (gameDLLName), "%s/%s", getenv ("XASH3D_GAMELIBDIR"), GAME_SERVER_DLL); g_gameLib = new Library (gameDLLName); @@ -3051,6 +3053,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t { "czero", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero", CSV_CZERO }, { "czero", "cs.so", "cs.dylib", "mp.dll", "Counter-Strike: Condition Zero (Newer)", CSV_CZERO }, { "csv15", "cs_i386.so", "cs.dylib", "mp.dll", "CS 1.5 for Steam", CSV_OLD }, + { "csdm", "cs_i386.so", "cs.dylib", "mp.dll", "CSDM for Windows", CSV_OLD }, { "cs13", "cs_i386.so", "cs.dylib", "mp.dll", "Counter-Strike v1.3", CSV_OLD }, // assume cs13 = cs15 }; diff --git a/source/manager.cpp b/source/manager.cpp index e49b9e3..e65333a 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -38,6 +38,7 @@ BotManager::BotManager (void) m_maintainTime = 0.0f; m_creationTab.RemoveAll (); + m_killerEntity = NULL; } BotManager::~BotManager (void) @@ -1181,6 +1182,29 @@ void Bot::StartGame (void) { // this function handles the selection of teams & class +#ifdef XASH_CSDM + m_wantedTeam = Random.Long (1, 2); + + FakeClientCommand (GetEntity (), "jointeam %d", m_wantedTeam); + + if (m_wantedTeam == 2) + { + SET_MODEL (GetEntity (), ENGINE_STR ("models/player/Counter-Terrorists/Counter-Terrorists.mdl")); + SET_CLIENT_KEYVALUE (GetIndex (), GET_INFOKEYBUFFER (GetEntity ()), "model", "Counter-Terrorists"); + } + else + { + SET_MODEL (GetEntity (), ENGINE_STR ("models/player/Terrorists/Terrorists.mdl")); + SET_CLIENT_KEYVALUE (GetIndex (), GET_INFOKEYBUFFER (GetEntity ()), "model", "Terrorists"); + } + + if (Random.Long (0, 100) < 20) + ChatMessage (CHAT_WELCOME); + + m_notStarted = false; + return; +#endif + // handle counter-strike stuff here... if (m_startAction == GSM_TEAM_SELECT) { diff --git a/source/navigate.cpp b/source/navigate.cpp index 5cb5288..23a64ad 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -431,14 +431,14 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dirNormal) // collision check allowed if not flying through the air if (IsOnFloor () || IsOnLadder () || IsInWater ()) { - char state[MAX_COLLIDE_MOVES * 2]; + char state[MAX_COLLIDE_MOVES * 2 + 1]; int i = 0; // first 4 entries hold the possible collision states state[i++] = COLLISION_STRAFELEFT; state[i++] = COLLISION_STRAFERIGHT; state[i++] = COLLISION_JUMP; - // state[i++] = COLLISION_DUCK; + // state[i++] = COLLISION_DUCK; if (bits & PROBE_STRAFE) { diff --git a/source/netmsg.cpp b/source/netmsg.cpp index 5605827..22ad597 100644 --- a/source/netmsg.cpp +++ b/source/netmsg.cpp @@ -461,17 +461,21 @@ void NetworkMsg::Execute (void *p) case 4: if (playerIndex >= 0 && playerIndex <= GetMaxClients ()) { +#ifndef XASH_CSDM + Client &cl = g_clients[playerIndex - 1]; + if (PTR_TO_INT (p) == 1) - g_clients[playerIndex - 1].realTeam = TEAM_TF; + cl.realTeam = TEAM_TF; else if (PTR_TO_INT (p) == 2) - g_clients[playerIndex - 1].realTeam = TEAM_CF; + cl.realTeam = TEAM_CF; else - g_clients[playerIndex - 1].realTeam = TEAM_SPEC; + cl.realTeam = TEAM_SPEC; if (yb_csdm_mode.GetInt () == 2) - g_clients[playerIndex - 1].team = playerIndex; + cl.team = playerIndex; else - g_clients[playerIndex - 1].team = g_clients[playerIndex - 1].realTeam; + cl.team = g_clients[playerIndex - 1].realTeam; +#endif } break; } diff --git a/source/support.cpp b/source/support.cpp index fbdbea1..999cb20 100644 --- a/source/support.cpp +++ b/source/support.cpp @@ -12,7 +12,12 @@ ConVar yb_listenserver_welcome ("yb_listenserver_welcome", "1", VT_NOSERVER); ConVar mp_roundtime ("mp_roundtime", NULL, VT_NOREGISTER); + +#ifndef XASH_CSDM ConVar mp_freezetime ("mp_freezetime", NULL, VT_NOREGISTER); +#else +ConVar mp_freezetime ("mp_freezetime", "0", VT_NOSERVER); +#endif void TraceLine (const Vector &start, const Vector &end, bool ignoreMonsters, bool ignoreGlass, edict_t *ignoreEntity, TraceResult *ptr) { @@ -742,7 +747,6 @@ void RoundInit (void) g_radioSelect[i] = 0; } waypoints.SetBombPosition (true); - waypoints.ClearGoalScore (); g_bombSayString = false; g_timeBombPlanted = 0.0f; diff --git a/source/waypoint.cpp b/source/waypoint.cpp index 640affd..a7c97b7 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -2446,41 +2446,6 @@ void Waypoint::SetFindIndex (int index) m_findWPIndex = -1; } -int Waypoint::AddGoalScore (int index, int other[4]) -{ - Array left; - - if (m_goalsScore[index] < 1024.0f) - left.Push (index); - - for (int i = 0; i < 3; i++) - { - if (m_goalsScore[other[i]] < 1024.0f) - left.Push (other[i]); - } - - if (left.IsEmpty ()) - index = other[Random.Long (0, 3)]; - else - index = left.GetRandomElement (); - - if (m_paths[index]->flags & FLAG_GOAL) - m_goalsScore[index] += 384.0f; - else if (m_paths[index]->flags & (FLAG_CF_ONLY | FLAG_TF_ONLY)) - m_goalsScore[index] += 768.0f; - else if (m_paths[index]->flags & FLAG_CAMP) - m_goalsScore[index] += 1024.0f; - - return index; -} - -void Waypoint::ClearGoalScore (void) -{ - // iterate though all waypoints - for (int i = 0; i < MAX_WAYPOINTS; i++) - m_goalsScore[i] = 0.0f; -} - Waypoint::Waypoint (void) { m_waypointPaths = false;