First commit of the year in this repo.

Tweaked a little weapon recoil compensation code.
Some of the cosmetic code changes.
Rewrote chatter loading code, so it's works a bit faster now.
Optimized angle clamping in bot  vision code.
This commit is contained in:
jeefo 2017-01-03 02:11:16 +03:00
commit ac0a2e1a8f
10 changed files with 263 additions and 345 deletions

2
.gitignore vendored
View file

@ -35,6 +35,8 @@ Icon
.Spotlight-V100
.Trashes
/project/#Verone
/project/.vs
/.vs
*.pdb
*.asm

View file

@ -256,7 +256,6 @@ enum ChatterMessage
// counter-strike weapon id's
enum Weapon
{
#ifndef XASH_CSDM
WEAPON_P228 = 1,
WEAPON_SHIELD = 2,
WEAPON_SCOUT = 3,
@ -290,41 +289,6 @@ 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
};
// buy counts

View file

@ -43,11 +43,6 @@ typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
// Own min/max implementation
template <typename T> inline T A_min (T a, T b) { return a < b ? a : b; }
template <typename T> inline T A_max (T a, T b) { return a > b ? a : b; }
template <typename T> inline T A_clamp (T x, T a, T b) { return A_min (A_max (x, a), b); }
// Fast stricmp got somewhere from chromium
static inline int A_stricmp (const char *str1, const char *str2, int length = -1)
{
@ -202,6 +197,31 @@ namespace Math
#endif
}
// own min/max implementation
template <typename T> static inline T A_min (T a, T b)
{
return a < b ? a : b;
}
template <typename T> static inline T A_max (T a, T b)
{
return a > b ? a : b;
}
template <typename T> static inline T A_clamp (T x, T a, T b)
{
return A_min (A_max (x, a), b);
}
static inline float F_clamp (float x, float a, float b)
{
#ifdef ENABLE_SSE_INTRINSICS
return _mm_cvtss_f32 (_mm_min_ss (_mm_max_ss (_mm_set1_ps (x), _mm_set1_ps (a)), _mm_set1_ps (b)));
#else
return A_clamp <float> (x, a, b);
#endif
}
//
// Function: A_sinf
//
@ -422,7 +442,7 @@ private:
public:
RandomSequenceOfUnique (void)
{
unsigned int seedBase = static_cast <unsigned int> (time (NULL));
unsigned int seedBase = static_cast <unsigned int> (time (nullptr));
unsigned int seedOffset = seedBase + 1;
m_index = PermuteQPR (PermuteQPR (seedBase) + 0x682f0161);
@ -867,21 +887,21 @@ public:
Math::SineCosine (Math::DegreeToRadian (y), &sineYaw, &cosineYaw); // compute the sine and cosine of the yaw component
Math::SineCosine (Math::DegreeToRadian (z), &sineRoll, &cosineRoll); // compute the sine and cosine of the roll component
if (forward != NULL)
if (forward != nullptr)
{
forward->x = cosinePitch * cosineYaw;
forward->y = cosinePitch * sineYaw;
forward->z = -sinePitch;
}
if (right != NULL)
if (right != nullptr)
{
right->x = -sineRoll * sinePitch * cosineYaw + cosineRoll * sineYaw;
right->y = -sineRoll * sinePitch * sineYaw - cosineRoll * cosineYaw;
right->z = -sineRoll * cosinePitch;
}
if (upward != NULL)
if (upward != nullptr)
{
upward->x = cosineRoll * sinePitch * cosineYaw + sineRoll * sineYaw;
upward->y = cosineRoll * sinePitch * sineYaw - sineRoll * cosineYaw;
@ -907,9 +927,9 @@ public:
public:
Node (void)
{
m_next = NULL;
m_prev = NULL;
m_data = NULL;
m_next = nullptr;
m_prev = nullptr;
m_data = nullptr;
}
};
@ -939,8 +959,8 @@ public:
//
void Destory (void)
{
m_first = NULL;
m_last = NULL;
m_first = nullptr;
m_last = nullptr;
m_count = 0;
}
@ -958,32 +978,32 @@ public:
//
// Function: GetFirst
// Gets the first list entry. NULL in case list is empty.
// Gets the first list entry. nullptr in case list is empty.
//
// Returns:
// First list entry.
//
inline T *GetFirst (void) const
{
if (m_first != NULL)
if (m_first != nullptr)
return m_first->m_data;
return NULL;
return nullptr;
};
//
// Function: GetLast
// Gets the last list entry. NULL in case list is empty.
// Gets the last list entry. nullptr in case list is empty.
//
// Returns:
// Last list entry.
//
inline T *GetLast (void) const
{
if (m_last != NULL)
if (m_last != nullptr)
return m_last->m_data;
return NULL;
return nullptr;
};
//
@ -998,15 +1018,15 @@ public:
//
T *GetNext (T *current)
{
if (current == NULL)
if (current == nullptr)
return GetFirst ();
Node <T> *next = FindNode (current)->m_next;
if (next != NULL)
if (next != nullptr)
return next->m_data;
return NULL;
return nullptr;
}
//
@ -1021,15 +1041,15 @@ public:
//
T *GetPrev (T *current)
{
if (current == NULL)
if (current == nullptr)
return GetLast ();
Node <T> *prev = FindNode (current)->m_prev;
if (prev != NULL)
if (prev != nullptr)
return prev->m_prev;
return NULL;
return nullptr;
}
//
@ -1041,17 +1061,17 @@ public:
// next - Next node to be inserted into linked list.
//
// Returns:
// Item if operation success, NULL otherwise.
// Item if operation success, nullptr otherwise.
//
T *Link (T *entry, T *next = NULL)
T *Link (T *entry, T *next = nullptr)
{
Node <T> *prevNode = NULL;
Node <T> *prevNode = nullptr;
Node <T> *nextNode = FindNode (next);
Node <T> *newNode = new Node <T> ();
newNode->m_data = entry;
if (nextNode == NULL)
if (nextNode == nullptr)
{
prevNode = m_last;
m_last = newNode;
@ -1062,7 +1082,7 @@ public:
nextNode->m_prev = newNode;
}
if (prevNode == NULL)
if (prevNode == nullptr)
m_first = newNode;
else
prevNode->m_next = newNode;
@ -1084,9 +1104,9 @@ public:
// next - Next node to be inserted into linked list.
//
// Returns:
// Item if operation success, NULL otherwise.
// Item if operation success, nullptr otherwise.
//
T *Link (T &entry, T *next = NULL)
T *Link (T &entry, T *next = nullptr)
{
T *newEntry = new T ();
*newEntry = entry;
@ -1105,15 +1125,15 @@ public:
{
Node <T> *entryNode = FindNode (entry);
if (entryNode == NULL)
if (entryNode == nullptr)
return;
if (entryNode->m_prev == NULL)
if (entryNode->m_prev == nullptr)
m_first = entryNode->m_next;
else
entryNode->m_prev->m_next = entryNode->m_next;
if (entryNode->m_next == NULL)
if (entryNode->m_next == nullptr)
m_last = entryNode->m_prev;
else
entryNode->m_next->m_prev = entryNode->m_prev;
@ -1132,7 +1152,7 @@ public:
// Returns:
// Item that was inserted.
//
T *Allocate (T *next = NULL)
T *Allocate (T *next = nullptr)
{
T *entry = new T ();
@ -1158,9 +1178,9 @@ public:
//
void RemoveAll (void)
{
Node <T> *node = NULL;
Node <T> *node = nullptr;
while ((node = GetIterator (node)) != NULL)
while ((node = GetIterator (node)) != nullptr)
{
Node <T> *nodeToKill = node;
node = node->m_prev;
@ -1181,14 +1201,14 @@ public:
//
Node <T> *FindNode (T *entry)
{
Node <T> *iter = NULL;
Node <T> *iter = nullptr;
while ((iter = GetIterator (iter)) != NULL)
while ((iter = GetIterator (iter)) != nullptr)
{
if (iter->m_data == entry)
return iter;
}
return NULL;
return nullptr;
}
//
@ -1201,9 +1221,9 @@ public:
// Returns:
// Node pointer.
//
Node <T> *GetIterator (Node <T> *entry = NULL)
Node <T> *GetIterator (Node <T> *entry = nullptr)
{
if (entry == NULL)
if (entry == nullptr)
return m_first;
return entry->m_next;
@ -1237,7 +1257,7 @@ public:
//
Array (int resizeStep = 0)
{
m_elements = NULL;
m_elements = nullptr;
m_itemSize = 0;
m_itemCount = 0;
m_resizeStep = resizeStep;
@ -1252,7 +1272,7 @@ public:
//
Array (const Array <T> &other)
{
m_elements = NULL;
m_elements = nullptr;
m_itemSize = 0;
m_itemCount = 0;
m_resizeStep = 0;
@ -1282,7 +1302,7 @@ public:
{
delete [] m_elements;
m_elements = NULL;
m_elements = nullptr;
m_itemSize = 0;
m_itemCount = 0;
}
@ -1328,7 +1348,7 @@ public:
T *buffer = new T[checkSize];
if (keepData && m_elements != NULL)
if (keepData && m_elements != nullptr)
{
if (checkSize < m_itemCount)
m_itemCount = checkSize;
@ -1486,7 +1506,7 @@ public:
//
bool InsertAt (int index, T *objects, int count = 1, bool enlarge = true)
{
if (objects == NULL || count < 1)
if (objects == nullptr || count < 1)
return false;
int newSize = 0;
@ -1675,7 +1695,7 @@ public:
T *buffer = new T[m_itemCount];
if (m_elements != NULL)
if (m_elements != nullptr)
{
for (int i = 0; i < m_itemCount; i++)
buffer[i] = m_elements[i];
@ -1795,7 +1815,7 @@ protected:
public:
HashItem (void)
{
m_next = NULL;
m_next = nullptr;
m_index = 0;
}
@ -2024,7 +2044,7 @@ public:
int hashId = Hash <K> (keyName) % m_hashSize;
HashItem *hashItem = m_table[hashId], *nextHash = 0;
while (hashItem != NULL)
while (hashItem != nullptr)
{
if (m_mapTable[hashItem->m_index].key == keyName)
{
@ -2054,7 +2074,7 @@ public:
{
HashItem *ptr = m_table[i];
while (ptr != NULL)
while (ptr != nullptr)
{
HashItem *m_next = ptr->m_next;
@ -2081,7 +2101,7 @@ public:
{
int hashId = Hash <K> (keyName) % m_hashSize;
for (HashItem *ptr = m_table[hashId]; ptr != NULL; ptr = ptr->m_next)
for (HashItem *ptr = m_table[hashId]; ptr != nullptr; ptr = ptr->m_next)
{
if (m_mapTable[ptr->m_index].key == keyName)
return ptr->m_index;
@ -2132,7 +2152,7 @@ private:
m_allocatedSize = size + 16;
char *tempBuffer = new char[size + 1];
if (m_bufferPtr != NULL)
if (m_bufferPtr != nullptr)
{
strcpy (tempBuffer, m_bufferPtr);
tempBuffer[m_stringLength] = 0;
@ -2233,7 +2253,7 @@ private:
public:
String (void)
{
m_bufferPtr = NULL;
m_bufferPtr = nullptr;
m_allocatedSize = 0;
m_stringLength = 0;
}
@ -2245,7 +2265,7 @@ public:
String (const char *bufferPtr)
{
m_bufferPtr = NULL;
m_bufferPtr = nullptr;
m_allocatedSize = 0;
m_stringLength = 0;
@ -2254,7 +2274,7 @@ public:
String (char input)
{
m_bufferPtr = NULL;
m_bufferPtr = nullptr;
m_allocatedSize = 0;
m_stringLength = 0;
@ -2263,7 +2283,7 @@ public:
String (const String &inputString)
{
m_bufferPtr = NULL;
m_bufferPtr = nullptr;
m_allocatedSize = 0;
m_stringLength = 0;
@ -2284,7 +2304,7 @@ public:
//
const char *GetBuffer (void)
{
if (m_bufferPtr == NULL || *m_bufferPtr == 0x0)
if (m_bufferPtr == nullptr || *m_bufferPtr == 0x0)
return "";
return &m_bufferPtr[0];
@ -2299,7 +2319,7 @@ public:
//
const char *GetBuffer (void) const
{
if (m_bufferPtr == NULL || *m_bufferPtr == 0x0)
if (m_bufferPtr == nullptr || *m_bufferPtr == 0x0)
return "";
return &m_bufferPtr[0];
@ -2488,7 +2508,7 @@ public:
//
void Assign (const char *bufferPtr)
{
if (bufferPtr == NULL)
if (bufferPtr == nullptr)
{
UpdateBufferSize (1);
m_stringLength = 0;
@ -2497,7 +2517,7 @@ public:
}
UpdateBufferSize (strlen (bufferPtr));
if (m_bufferPtr != NULL)
if (m_bufferPtr != nullptr)
{
strcpy (m_bufferPtr, bufferPtr);
m_stringLength = strlen (m_bufferPtr);
@ -2531,7 +2551,7 @@ public:
//
void Empty (void)
{
if (m_bufferPtr != NULL)
if (m_bufferPtr != nullptr)
{
m_bufferPtr[0] = 0;
m_stringLength = 0;
@ -2547,7 +2567,7 @@ public:
//
bool IsEmpty (void) const
{
if (m_bufferPtr == NULL || m_stringLength == 0)
if (m_bufferPtr == nullptr || m_stringLength == 0)
return true;
return false;
@ -2562,7 +2582,7 @@ public:
//
int GetLength (void) const
{
if (m_bufferPtr == NULL)
if (m_bufferPtr == nullptr)
return 0;
return m_stringLength;
@ -3083,21 +3103,21 @@ public:
String &TrimRight (void)
{
char *str = m_bufferPtr;
char *last = NULL;
char *last = nullptr;
while (*str != 0)
{
if (IsTrimChar (*str))
{
if (last == NULL)
if (last == nullptr)
last = str;
}
else
last = NULL;
last = nullptr;
str++;
}
if (last != NULL)
if (last != nullptr)
Delete (last - m_bufferPtr);
return *this;
@ -3153,21 +3173,21 @@ public:
void TrimRight (char ch)
{
const char *str = m_bufferPtr;
const char *last = NULL;
const char *last = nullptr;
while (*str != 0)
{
if (*str == ch)
{
if (last == NULL)
if (last == nullptr)
last = str;
}
else
last = NULL;
last = nullptr;
str++;
}
if (last != NULL)
if (last != nullptr)
{
int i = last - m_bufferPtr;
Delete (i, m_stringLength - i);
@ -3369,7 +3389,7 @@ public:
//
bool Contains (const String &what)
{
return strstr (m_bufferPtr, what.m_bufferPtr) != NULL;
return strstr (m_bufferPtr, what.m_bufferPtr) != nullptr;
}
//
@ -3497,7 +3517,7 @@ public:
//
File (void)
{
m_handle = NULL;
m_handle = nullptr;
m_fileSize = 0;
}
@ -3532,7 +3552,7 @@ public:
//
bool Open (const String &fileName, const String &mode)
{
if ((m_handle = fopen (fileName.GetBuffer (), mode.GetBuffer ())) == NULL)
if ((m_handle = fopen (fileName.GetBuffer (), mode.GetBuffer ())) == nullptr)
return false;
fseek (m_handle, 0L, SEEK_END);
@ -3548,10 +3568,10 @@ public:
//
void Close (void)
{
if (m_handle != NULL)
if (m_handle != nullptr)
{
fclose (m_handle);
m_handle = NULL;
m_handle = nullptr;
}
m_fileSize = 0;
}
@ -3565,7 +3585,7 @@ public:
//
bool Eof (void)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return feof (m_handle) ? true : false;
}
@ -3578,7 +3598,7 @@ public:
//
bool Flush (void)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return fflush (m_handle) ? false : true;
}
@ -3591,7 +3611,7 @@ public:
//
int GetChar (void)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return fgetc (m_handle);
}
@ -3608,7 +3628,7 @@ public:
//
char *GetBuffer (char *buffer, int count)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return fgets (buffer, count, m_handle);
}
@ -3624,7 +3644,7 @@ public:
//
int Printf (const char *format, ...)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
va_list ap;
va_start (ap, format);
@ -3649,7 +3669,7 @@ public:
//
char PutChar (char ch)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return static_cast <char> (fputc (ch, m_handle));
}
@ -3665,7 +3685,7 @@ public:
//
bool PutString (String buffer)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
if (fputs (buffer.GetBuffer (), m_handle) < 0)
return false;
@ -3687,7 +3707,7 @@ public:
//
int Read (void *buffer, int size, int count = 1)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return fread (buffer, size, count, m_handle);
}
@ -3705,7 +3725,7 @@ public:
//
int Write (void *buffer, int size, int count = 1)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
return fwrite (buffer, size, count, m_handle);
}
@ -3722,7 +3742,7 @@ public:
//
bool Seek (long offset, int origin)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
if (fseek (m_handle, offset, origin) != 0)
return false;
@ -3736,7 +3756,7 @@ public:
//
void Rewind (void)
{
assert (m_handle != NULL);
assert (m_handle != nullptr);
rewind (m_handle);
}
@ -3761,7 +3781,7 @@ public:
//
bool IsValid (void)
{
return m_handle != NULL;
return m_handle != nullptr;
}
public:
@ -3826,7 +3846,7 @@ public:
m_size = 0;
m_pos = 0;
m_buffer = NULL;
m_buffer = nullptr;
}
//
@ -3838,7 +3858,7 @@ public:
m_size = 0;
m_pos = 0;
m_buffer = NULL;
m_buffer = nullptr;
Open (fileName);
}
@ -3872,7 +3892,7 @@ public:
m_buffer = Loader (fileName, &m_size);
if (m_buffer == NULL || m_size < 0)
if (m_buffer == nullptr || m_size < 0)
return false;
return true;
@ -3884,13 +3904,13 @@ public:
//
void Close (void)
{
if (Unloader != NULL)
if (Unloader != nullptr)
Unloader (m_buffer);
m_size = 0;
m_pos = 0;
m_buffer = NULL;
m_buffer = nullptr;
}
//
@ -3902,7 +3922,7 @@ public:
//
int GetChar (void)
{
if (m_buffer == NULL || m_pos >= m_size)
if (m_buffer == nullptr || m_pos >= m_size)
return -1;
int readCh = m_buffer[m_pos];
@ -3924,8 +3944,8 @@ public:
//
char *GetBuffer (char *buffer, int count)
{
if (m_buffer == NULL || m_pos >= m_size)
return NULL;
if (m_buffer == nullptr || m_pos >= m_size)
return nullptr;
int start = m_pos;
int end = m_size - 1;
@ -3942,7 +3962,7 @@ public:
}
if (m_pos == start)
return NULL;
return nullptr;
int pos = start;
@ -3977,10 +3997,10 @@ public:
//
int Read (void *buffer, int size, int count = 1)
{
if (!m_buffer|| m_pos >= m_size || buffer == NULL || !size || !count)
if (!m_buffer|| m_pos >= m_size || buffer == nullptr || !size || !count)
return 0;
int blocksRead = A_min ((m_size - m_pos) / size, count) * size;
int blocksRead = Math::A_min ((m_size - m_pos) / size, count) * size;
memcpy (buffer, &m_buffer[m_pos], blocksRead);
m_pos += blocksRead;
@ -4001,7 +4021,7 @@ public:
//
bool Seek (long offset, int origin)
{
if (m_buffer == NULL || m_pos >= m_size)
if (m_buffer == nullptr || m_pos >= m_size)
return false;
if (origin == SEEK_SET)
@ -4049,7 +4069,7 @@ public:
//
bool IsValid (void)
{
return m_buffer != NULL && m_size > 0;
return m_buffer != nullptr && m_size > 0;
}
};
@ -4119,18 +4139,6 @@ public:
return reference;
};
};
//
// Macro: ThrowException
// Throws debug exception.
//
// Parameters:
// text - Text of error.
//
#define ThrowException(text) \
throw Exception (text, __FILE__, __LINE__)
//
// Macro: IterateArray
// Utility macro for iterating arrays.
@ -4155,3 +4163,7 @@ public:
// Squared Length
//
#define GET_SQUARE(in) (in * in)
//
// Stringify a string
#define STRINGIFY(str) (#str)

View file

@ -249,12 +249,7 @@ public:
FORCEINLINE int GetTeam (edict_t *ent)
{
extern Client g_clients[MAX_ENGINE_PLAYERS];
#ifndef XASH_CSDM
return g_clients[IndexOfEntity (ent) - 1].team;
#else
return g_clients[IndexOfEntity (ent) - 1].team = ent->v.team == 1 ? TERRORIST : CT;
#endif
}
// adds translation pair from config

View file

@ -2934,11 +2934,6 @@ void Bot::ThinkFrame (void)
else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10.0f && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool () && !waypoints.HasChanged ())
botMovement = true;
#ifdef XASH_CSDM
if (m_notKilled)
botMovement = true;
#endif
CheckMessageQueue (); // check for pending messages
if (botMovement)

View file

@ -687,12 +687,12 @@ bool Bot::DoFirePause (float distance)
if ((m_aimFlags & AIM_ENEMY) && !m_enemyOrigin.IsZero ())
{
if (IsEnemyProtectedByShield (m_enemy) && GetShootingConeDeviation (GetEntity (), &m_enemyOrigin) > 0.92f)
if (GetShootingConeDeviation (GetEntity (), &m_enemyOrigin) > 0.92f && IsEnemyProtectedByShield (m_enemy))
return true;
}
float offset = 0.0f;
const float SprayDistance = 200.0f;
const float SprayDistance = 250.0f;
if (distance < SprayDistance)
return false;
@ -712,8 +712,11 @@ bool Bot::DoFirePause (float distance)
// check if we need to compensate recoil
if (tanf (A_sqrtf (fabsf (xPunch * xPunch) + fabsf (yPunch * yPunch))) * distance > offset + 30.0f + ((100 - (m_difficulty * 25)) / 100.f))
{
if (m_firePause < engine.Time () - interval)
m_firePause = engine.Time () + Random.Float (0.5f, 0.5f + 0.3f * ((100.0f - (m_difficulty * 25)) / 100.f));
if (m_firePause < engine.Time ())
m_firePause = Random.Float (0.5f, 0.5f + 0.3f * ((100.0f - (m_difficulty * 25)) / 100.f));
m_firePause -= interval;
m_firePause += engine.Time ();
return true;
}

View file

@ -1033,7 +1033,6 @@ void Engine::ProcessMessageCapture (void *ptr)
case 4:
if (playerIndex >= 0 && playerIndex <= MaxClients ())
{
#ifndef XASH_CSDM
Client &client = g_clients[playerIndex - 1];
if (intVal == 1)
@ -1047,7 +1046,6 @@ void Engine::ProcessMessageCapture (void *ptr)
client.team = playerIndex;
else
client.team = client.team2;
#endif
}
break;
}

View file

@ -442,30 +442,6 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
return 1; // command was handled by bot
}
void ParseVoiceEvent (const String &base, int type, float timeToRepeat)
{
// this function does common work of parsing single line of voice chatter
Array <String> temp = String (base).Split (',');
ChatterItem chatterItem;
FOR_EACH_AE (temp, i)
{
temp[i].Trim ().TrimQuotes ();
float duration = engine.GetWaveLength (temp[i]);
if (duration <= 0.0f)
continue;
chatterItem.name = temp[i];
chatterItem.repeat = timeToRepeat;
chatterItem.duration = duration;
g_chatterFactory[type].Push (chatterItem);
}
temp.RemoveAll ();
}
// forwards for MemoryFile
MemoryFile::MF_Loader MemoryFile::Loader = nullptr;
@ -644,7 +620,7 @@ void InitConfig (void)
{
SKIP_COMMENTS ();
Array <String> pair = String (line).Split ('=');
auto pair = String (line).Split ('=');
if (pair.GetElementNumber () != 2)
continue;
@ -652,7 +628,7 @@ void InitConfig (void)
pair[0].Trim ().Trim ();
pair[1].Trim ().Trim ();
Array <String> splitted = pair[1].Split (',');
auto splitted = pair[1].Split (',');
if (pair[0] == "MapStandard")
{
@ -717,108 +693,137 @@ void InitConfig (void)
// CHATTER SYSTEM INITIALIZATION
if ((g_gameFlags & GAME_SUPPORT_BOT_VOICE) && yb_communication_type.GetInt () == 2 && OpenConfig ("chatter.cfg", "Couldn't open chatter system configuration", &fp))
{
Array <String> array;
const float ChatterInfinity = 99999.0f;
extern ConVar yb_chatter_path;
// for faster loading
struct EventMap
{
const char *str;
int code;
float repeat;
} chatterEventMap[] = {
{ STRINGIFY (Radio_CoverMe), Radio_CoverMe, ChatterInfinity },
{ STRINGIFY (Radio_YouTakePoint), Radio_YouTakePoint, ChatterInfinity },
{ STRINGIFY (Radio_HoldPosition), Radio_HoldPosition, ChatterInfinity },
{ STRINGIFY (Radio_RegroupTeam), Radio_RegroupTeam, ChatterInfinity },
{ STRINGIFY (Radio_FollowMe), Radio_FollowMe, ChatterInfinity },
{ STRINGIFY (Radio_TakingFire), Radio_TakingFire, ChatterInfinity },
{ STRINGIFY (Radio_GoGoGo), Radio_GoGoGo, ChatterInfinity },
{ STRINGIFY (Radio_Fallback), Radio_Fallback, ChatterInfinity },
{ STRINGIFY (Radio_StickTogether), Radio_StickTogether, ChatterInfinity },
{ STRINGIFY (Radio_GetInPosition), Radio_GetInPosition, ChatterInfinity },
{ STRINGIFY (Radio_StormTheFront), Radio_StormTheFront, ChatterInfinity },
{ STRINGIFY (Radio_ReportTeam), Radio_ReportTeam, ChatterInfinity },
{ STRINGIFY (Radio_Affirmative), Radio_Affirmative, ChatterInfinity },
{ STRINGIFY (Radio_EnemySpotted), Radio_EnemySpotted, ChatterInfinity },
{ STRINGIFY (Radio_NeedBackup), Radio_NeedBackup, ChatterInfinity },
{ STRINGIFY (Radio_SectorClear), Radio_SectorClear, ChatterInfinity },
{ STRINGIFY (Radio_InPosition), Radio_InPosition, ChatterInfinity },
{ STRINGIFY (Radio_ReportingIn), Radio_ReportingIn, ChatterInfinity },
{ STRINGIFY (Radio_ShesGonnaBlow), Radio_ShesGonnaBlow, ChatterInfinity },
{ STRINGIFY (Radio_Negative), Radio_Negative, ChatterInfinity },
{ STRINGIFY (Radio_EnemyDown), Radio_EnemyDown, ChatterInfinity },
{ STRINGIFY (Chatter_DiePain), Chatter_DiePain, ChatterInfinity },
{ STRINGIFY (Chatter_GoingToPlantBomb), Chatter_GoingToPlantBomb, ChatterInfinity },
{ STRINGIFY (Chatter_GoingToGuardVIPSafety), Chatter_GoingToGuardVIPSafety, ChatterInfinity },
{ STRINGIFY (Chatter_RescuingHostages), Chatter_RescuingHostages, ChatterInfinity },
{ STRINGIFY (Chatter_TeamKill), Chatter_TeamKill, ChatterInfinity },
{ STRINGIFY (Chatter_GuardingVipSafety), Chatter_GuardingVipSafety, ChatterInfinity },
{ STRINGIFY (Chatter_PlantingC4), Chatter_PlantingC4, ChatterInfinity },
{ STRINGIFY (Chatter_InCombat), Chatter_InCombat, ChatterInfinity },
{ STRINGIFY (Chatter_SeeksEnemy), Chatter_SeeksEnemy, ChatterInfinity },
{ STRINGIFY (Chatter_Nothing), Chatter_Nothing, ChatterInfinity },
{ STRINGIFY (Chatter_EnemyDown), Chatter_EnemyDown, ChatterInfinity },
{ STRINGIFY (Chatter_UseHostage), Chatter_UseHostage, ChatterInfinity },
{ STRINGIFY (Chatter_WonTheRound), Chatter_WonTheRound, ChatterInfinity },
{ STRINGIFY (Chatter_QuicklyWonTheRound), Chatter_QuicklyWonTheRound, ChatterInfinity },
{ STRINGIFY (Chatter_NoEnemiesLeft), Chatter_NoEnemiesLeft, ChatterInfinity },
{ STRINGIFY (Chatter_FoundBombPlace), Chatter_FoundBombPlace, ChatterInfinity },
{ STRINGIFY (Chatter_WhereIsTheBomb), Chatter_WhereIsTheBomb, ChatterInfinity },
{ STRINGIFY (Chatter_DefendingBombSite), Chatter_DefendingBombSite, ChatterInfinity },
{ STRINGIFY (Chatter_BarelyDefused), Chatter_BarelyDefused, ChatterInfinity },
{ STRINGIFY (Chatter_NiceshotCommander), Chatter_NiceshotCommander, ChatterInfinity },
{ STRINGIFY (Chatter_ReportingIn), Chatter_ReportingIn, 10.0f },
{ STRINGIFY (Chatter_SpotTheBomber), Chatter_SpotTheBomber, 4.3f },
{ STRINGIFY (Chatter_VIPSpotted), Chatter_VIPSpotted, 5.3f },
{ STRINGIFY (Chatter_FriendlyFire), Chatter_FriendlyFire, 2.1f },
{ STRINGIFY (Chatter_GotBlinded), Chatter_GotBlinded, 5.0f },
{ STRINGIFY (Chatter_GuardDroppedC4), Chatter_GuardDroppedC4, 3.0f },
{ STRINGIFY (Chatter_DefusingC4), Chatter_DefusingC4, 3.0f },
{ STRINGIFY (Chatter_FoundC4), Chatter_FoundC4, 5.5f },
{ STRINGIFY (Chatter_ScaredEmotion), Chatter_ScaredEmotion, 6.1f },
{ STRINGIFY (Chatter_HeardEnemy), Chatter_ScaredEmotion, 12.8f },
{ STRINGIFY (Chatter_SniperWarning), Chatter_SniperWarning, 4.3f },
{ STRINGIFY (Chatter_SniperKilled), Chatter_SniperKilled, 2.1f },
{ STRINGIFY (Chatter_OneEnemyLeft), Chatter_OneEnemyLeft, 2.5f },
{ STRINGIFY (Chatter_TwoEnemiesLeft), Chatter_TwoEnemiesLeft, 2.5f },
{ STRINGIFY (Chatter_ThreeEnemiesLeft), Chatter_ThreeEnemiesLeft, 2.5f },
{ STRINGIFY (Chatter_NiceshotPall), Chatter_NiceshotPall, 2.0f },
{ STRINGIFY (Chatter_GoingToGuardHostages), Chatter_GoingToGuardHostages, 3.0f },
{ STRINGIFY (Chatter_GoingToGuardDoppedBomb), Chatter_GoingToGuardDoppedBomb, 3.0f },
{ STRINGIFY (Chatter_OnMyWay), Chatter_OnMyWay, 1.5f },
{ STRINGIFY (Chatter_LeadOnSir), Chatter_LeadOnSir, 5.0f },
{ STRINGIFY (Chatter_Pinned_Down), Chatter_Pinned_Down, 5.0f },
{ STRINGIFY (Chatter_GottaFindTheBomb), Chatter_GottaFindTheBomb, 3.0f },
{ STRINGIFY (Chatter_You_Heard_The_Man), Chatter_You_Heard_The_Man, 3.0f },
{ STRINGIFY (Chatter_Lost_The_Commander), Chatter_Lost_The_Commander, 4.5f },
{ STRINGIFY (Chatter_NewRound), Chatter_NewRound, 3.5f },
{ STRINGIFY (Chatter_CoverMe), Chatter_CoverMe, 3.5f },
{ STRINGIFY (Chatter_BehindSmoke), Chatter_BehindSmoke, 3.5f },
{ STRINGIFY (Chatter_BombSiteSecured), Chatter_BombSiteSecured, 3.5f },
{ STRINGIFY (Chatter_GoingToCamp), Chatter_GoingToCamp, 5.0f },
{ STRINGIFY (Chatter_Camp), Chatter_Camp, 5.0f },
};
while (fp.GetBuffer (line, 511))
{
SKIP_COMMENTS ();
if (strncmp (line, "RewritePath", 11) == 0)
{
extern ConVar yb_chatter_path;
yb_chatter_path.SetString (String (&line[12]).Trim ());
}
else if (strncmp (line, "Event", 5) == 0)
{
array = String (&line[6]).Split ('=');
auto items = String (&line[6]).Split ('=');
if (array.GetElementNumber () != 2)
AddLogEntry (true, LL_ERROR, "Error in chatter config file syntax... Please correct all Errors.");
if (items.GetElementNumber () != 2)
{
AddLogEntry (true, LL_ERROR, "Error in chatter config file syntax... Please correct all errors.");
continue;
}
FOR_EACH_AE (array, i)
array[i].Trim ().Trim (); // double trim
FOR_EACH_AE (items, i)
items[i].Trim ().Trim (); // double trim
// just to be more unique :)
array[1].TrimLeft ('(');
array[1].TrimRight (';');
array[1].TrimRight (')');
items[1].TrimLeft ('(');
items[1].TrimRight (';');
items[1].TrimRight (')');
#define PARSE_CHATTER_ITEM(type, timeToRepeatAgain) { if (strcmp (array[0], #type) == 0) ParseVoiceEvent (array[1], type, timeToRepeatAgain); }
#define PARSE_CHATTER_ITEM_NR(type) PARSE_CHATTER_ITEM(type, 99999.0f)
for (int i = 0; i < ARRAYSIZE_HLSDK (chatterEventMap); i++)
{
auto event = &chatterEventMap[i];
// radio system
PARSE_CHATTER_ITEM_NR (Radio_CoverMe);
PARSE_CHATTER_ITEM_NR (Radio_YouTakePoint);
PARSE_CHATTER_ITEM_NR (Radio_HoldPosition);
PARSE_CHATTER_ITEM_NR (Radio_RegroupTeam);
PARSE_CHATTER_ITEM_NR (Radio_FollowMe);
PARSE_CHATTER_ITEM_NR (Radio_TakingFire);
PARSE_CHATTER_ITEM_NR (Radio_GoGoGo);
PARSE_CHATTER_ITEM_NR (Radio_Fallback);
PARSE_CHATTER_ITEM_NR (Radio_StickTogether);
PARSE_CHATTER_ITEM_NR (Radio_GetInPosition);
PARSE_CHATTER_ITEM_NR (Radio_StormTheFront);
PARSE_CHATTER_ITEM_NR (Radio_ReportTeam);
PARSE_CHATTER_ITEM_NR (Radio_Affirmative);
PARSE_CHATTER_ITEM_NR (Radio_EnemySpotted);
PARSE_CHATTER_ITEM_NR (Radio_NeedBackup);
PARSE_CHATTER_ITEM_NR (Radio_SectorClear);
PARSE_CHATTER_ITEM_NR (Radio_InPosition);
PARSE_CHATTER_ITEM_NR (Radio_ReportingIn);
PARSE_CHATTER_ITEM_NR (Radio_ShesGonnaBlow);
PARSE_CHATTER_ITEM_NR (Radio_Negative);
PARSE_CHATTER_ITEM_NR (Radio_EnemyDown);
if (A_stricmp (event->str, items[0].GetBuffer ()) == 0)
{
// this does common work of parsing comma-separated chatter line
auto sounds = items[1].Split (',');
// voice system
PARSE_CHATTER_ITEM (Chatter_SpotTheBomber, 4.3f);
PARSE_CHATTER_ITEM (Chatter_VIPSpotted, 5.3f);
PARSE_CHATTER_ITEM (Chatter_FriendlyFire, 2.1f);
PARSE_CHATTER_ITEM_NR (Chatter_DiePain);
PARSE_CHATTER_ITEM (Chatter_GotBlinded, 5.0f);
PARSE_CHATTER_ITEM_NR (Chatter_GoingToPlantBomb);
PARSE_CHATTER_ITEM_NR (Chatter_GoingToGuardVIPSafety);
PARSE_CHATTER_ITEM_NR (Chatter_RescuingHostages);
PARSE_CHATTER_ITEM_NR (Chatter_GoingToCamp);
PARSE_CHATTER_ITEM_NR (Chatter_TeamKill);
PARSE_CHATTER_ITEM_NR (Chatter_ReportingIn);
PARSE_CHATTER_ITEM (Chatter_GuardDroppedC4, 3.0f);
PARSE_CHATTER_ITEM_NR (Chatter_Camp);
PARSE_CHATTER_ITEM_NR (Chatter_GuardingVipSafety);
PARSE_CHATTER_ITEM_NR (Chatter_PlantingC4);
PARSE_CHATTER_ITEM (Chatter_DefusingC4, 3.0f);
PARSE_CHATTER_ITEM_NR (Chatter_InCombat);
PARSE_CHATTER_ITEM_NR (Chatter_SeeksEnemy);
PARSE_CHATTER_ITEM_NR (Chatter_Nothing);
PARSE_CHATTER_ITEM_NR (Chatter_EnemyDown);
PARSE_CHATTER_ITEM_NR (Chatter_UseHostage);
PARSE_CHATTER_ITEM (Chatter_FoundC4, 5.5f);
PARSE_CHATTER_ITEM_NR (Chatter_WonTheRound);
PARSE_CHATTER_ITEM (Chatter_ScaredEmotion, 6.1f);
PARSE_CHATTER_ITEM (Chatter_HeardEnemy, 12.2f);
PARSE_CHATTER_ITEM (Chatter_SniperWarning, 4.3f);
PARSE_CHATTER_ITEM (Chatter_SniperKilled, 2.1f);
PARSE_CHATTER_ITEM_NR (Chatter_QuicklyWonTheRound);
PARSE_CHATTER_ITEM (Chatter_OneEnemyLeft, 2.5f);
PARSE_CHATTER_ITEM (Chatter_TwoEnemiesLeft, 2.5f);
PARSE_CHATTER_ITEM (Chatter_ThreeEnemiesLeft, 2.5f);
PARSE_CHATTER_ITEM_NR (Chatter_NoEnemiesLeft);
PARSE_CHATTER_ITEM_NR (Chatter_FoundBombPlace);
PARSE_CHATTER_ITEM_NR (Chatter_WhereIsTheBomb);
PARSE_CHATTER_ITEM_NR (Chatter_DefendingBombSite);
PARSE_CHATTER_ITEM_NR (Chatter_BarelyDefused);
PARSE_CHATTER_ITEM_NR (Chatter_NiceshotCommander);
PARSE_CHATTER_ITEM (Chatter_NiceshotPall, 2.0);
PARSE_CHATTER_ITEM (Chatter_GoingToGuardHostages, 3.0f);
PARSE_CHATTER_ITEM (Chatter_GoingToGuardDoppedBomb, 3.0f);
PARSE_CHATTER_ITEM (Chatter_OnMyWay, 1.5f);
PARSE_CHATTER_ITEM (Chatter_LeadOnSir, 5.0f);
PARSE_CHATTER_ITEM (Chatter_Pinned_Down, 5.0f);
PARSE_CHATTER_ITEM (Chatter_GottaFindTheBomb, 3.0f);
PARSE_CHATTER_ITEM (Chatter_You_Heard_The_Man, 3.0f);
PARSE_CHATTER_ITEM (Chatter_Lost_The_Commander, 4.5f);
PARSE_CHATTER_ITEM (Chatter_NewRound, 3.5f);
PARSE_CHATTER_ITEM (Chatter_CoverMe, 3.5f);
PARSE_CHATTER_ITEM (Chatter_BehindSmoke, 3.5f);
PARSE_CHATTER_ITEM (Chatter_BombSiteSecured, 3.5f);
FOR_EACH_AE (sounds, j)
{
sounds[j].Trim ().TrimQuotes ();
float duration = engine.GetWaveLength (sounds[j]);
if (duration > 0.0f)
g_chatterFactory[event->code].Push ({ sounds[j], event->repeat, duration }, true);
}
sounds.RemoveAll ();
}
}
}
}
fp.Close ();
@ -1003,7 +1008,6 @@ int Spawn (edict_t *ent)
return 0;
}
}
#ifndef XASH_CSDM
else if (strcmp (entityClassname, "info_player_start") == 0)
{
SET_MODEL (ent, ENGINE_STR ("models/player/urban/urban.mdl"));
@ -1029,7 +1033,6 @@ int Spawn (edict_t *ent)
ent->v.renderamt = 127; // set its transparency amount
ent->v.effects |= EF_NODRAW;
}
#endif
else if (strcmp (entityClassname, "func_vip_safetyzone") == 0 || strcmp (STRING (ent->v.classname), "info_vip_safetyzone") == 0)
g_mapType |= MAP_AS; // assassination map
@ -3436,43 +3439,3 @@ LINK_ENTITY (weapon_xm1014)
LINK_ENTITY (weaponbox)
LINK_ENTITY (world_items)
LINK_ENTITY (worldspawn)
#ifdef XASH_CSDM
LINK_ENTITY (aiscripted_sequence)
LINK_ENTITY (cine_blood)
LINK_ENTITY (deadplayer_entity)
LINK_ENTITY (func_headq)
LINK_ENTITY (info_node)
LINK_ENTITY (info_node_air)
LINK_ENTITY (info_player_csdm)
LINK_ENTITY (monster_c4)
LINK_ENTITY (monster_cine2_hvyweapons)
LINK_ENTITY (monster_cine2_scientist)
LINK_ENTITY (monster_cine2_slave)
LINK_ENTITY (monster_cine3_barney)
LINK_ENTITY (monster_cine3_scientist)
LINK_ENTITY (monster_cine_barney)
LINK_ENTITY (monster_cine_panther)
LINK_ENTITY (monster_cine_scientist)
LINK_ENTITY (monster_cockroach)
LINK_ENTITY (monster_furniture)
LINK_ENTITY (monster_osprey)
LINK_ENTITY (monster_rat)
LINK_ENTITY (monster_tentacle)
LINK_ENTITY (monster_tentaclemaw)
LINK_ENTITY (monstermaker)
LINK_ENTITY (node_viewer)
LINK_ENTITY (node_viewer_fly)
LINK_ENTITY (node_viewer_human)
LINK_ENTITY (node_viewer_large)
LINK_ENTITY (scripted_sequence)
LINK_ENTITY (testhull)
LINK_ENTITY (xen_hair)
LINK_ENTITY (xen_hull)
LINK_ENTITY (xen_plantlight)
LINK_ENTITY (xen_spore_large)
LINK_ENTITY (xen_spore_medium)
LINK_ENTITY (xen_spore_small)
LINK_ENTITY (xen_tree)
LINK_ENTITY (xen_ttrigger)
#endif

View file

@ -1356,20 +1356,6 @@ void Bot::StartGame (void)
{
// this function handles the selection of teams & class
#ifdef XASH_CSDM
m_wantedTeam = Random.Int (1, 2);
engine.IssueBotCommand (GetEntity (), "jointeam %d", m_wantedTeam);
SET_CLIENT_KEYVALUE (GetIndex (), GET_INFOKEYBUFFER (GetEntity ()), "model", m_wantedTeam == 2 ? "Counter-Terrorists" : "Terrorists");
if (Random.Int (0, 100) < 20)
ChatMessage (CHAT_WELCOME);
m_notStarted = false;
return;
#endif
// cs prior beta 7.0 uses hud-based motd, so press fire once
if (g_gameFlags & GAME_LEGACY)
pev->button |= IN_ATTACK;

View file

@ -3181,7 +3181,7 @@ void Bot::UpdateBodyAngles (void)
void Bot::UpdateLookAngles (void)
{
const float delta = A_clamp <float> (engine.Time () - m_lookUpdateTime, MATH_EQEPSILON, 0.05f);
const float delta = F_clamp (engine.Time () - m_lookUpdateTime, MATH_EQEPSILON, 0.05f);
m_lookUpdateTime = engine.Time ();
// adjust all body and view angles to face an absolute vector