removed useless things

merged changes for xash csdm into master
This commit is contained in:
jeefo 2015-12-26 17:19:20 +03:00
commit 4b8c18001d
11 changed files with 102 additions and 334 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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 K, class V> 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 <HashItem> *m_table;
Array <V> 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 <HashItem> [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 <HashItem> [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:
// <Array>
//
const Array <V> &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 <HashTable <K, V> *> (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 <HashTable <K, V> *> (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 <K> (keyName) % m_hashSize;
Array <HashItem> &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 <HashItem> &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 <K> (keyName) % m_hashSize;
Array <HashItem> &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 <int> (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.

View file

@ -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
}