rewritten a little weapon selection code

fixed bots do not chat when dead
some code cleanup
This commit is contained in:
jeefo 2016-09-11 21:01:06 +03:00
commit 3c5d056fec
32 changed files with 794 additions and 1214 deletions

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#pragma once
@ -17,7 +17,7 @@ protected:
unsigned long int m_textSize;
unsigned long int m_codeSize;
byte m_textBuffer[N + F - 1];
uint8 m_textBuffer[N + F - 1];
int m_matchPosition;
int m_matchLength;
@ -41,7 +41,7 @@ private:
int compare = 1;
byte *key = &m_textBuffer[node];
uint8 *key = &m_textBuffer[node];
int temp = N + 1 + key[0];
m_right[node] = m_left[node] = NIL;
@ -172,16 +172,18 @@ public:
memset (m_parent, 0, sizeof (m_parent));
}
int InternalEncode (const char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize)
int InternalEncode (const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize)
{
int i, bit, length, node, strPtr, lastMatchLength, codeBufferPtr, bufferPtr = 0;
byte codeBuffer[17], mask;
int i, length, node, strPtr, lastMatchLength, codeBufferPtr, bufferPtr = 0;
uint8 codeBuffer[17], mask;
File fp (fileName, "wb");
if (!fp.IsValid ())
return -1;
uint8 bit;
fp.Write (header, headerSize, 1);
InitTree ();
@ -219,8 +221,8 @@ public:
}
else
{
codeBuffer[codeBufferPtr++] = (unsigned char) m_matchPosition;
codeBuffer[codeBufferPtr++] = (unsigned char) (((m_matchPosition >> 4) & 0xf0) | (m_matchLength - (THRESHOLD + 1)));
codeBuffer[codeBufferPtr++] = (uint8) m_matchPosition;
codeBuffer[codeBufferPtr++] = (uint8) (((m_matchPosition >> 4) & 0xf0) | (m_matchLength - (THRESHOLD + 1)));
}
if ((mask <<= 1) == 0)
@ -273,12 +275,14 @@ public:
return m_codeSize;
}
int InternalDecode (const char *fileName, int headerSize, byte *buffer, int bufferSize)
int InternalDecode (const char *fileName, int headerSize, uint8 *buffer, int bufferSize)
{
int i, j, k, node, bit;
int i, j, k, node;
unsigned int flags;
int bufferPtr = 0;
uint8 bit;
File fp (fileName, "rb");
if (!fp.IsValid ())
@ -296,14 +300,14 @@ public:
{
if (((flags >>= 1) & 256) == 0)
{
if ((bit = fp.GetChar ()) == EOF)
if ((bit = static_cast <uint8> (fp.GetChar ())) == EOF)
break;
flags = bit | 0xff00;
}
if (flags & 1)
{
if ((bit = fp.GetChar ()) == EOF)
if ((bit = static_cast <uint8> (fp.GetChar ())) == EOF)
break;
buffer[bufferPtr++] = bit;
@ -343,14 +347,14 @@ public:
}
// external decoder
static int Uncompress (const char *fileName, int headerSize, byte *buffer, int bufferSize)
static int Uncompress (const char *fileName, int headerSize, uint8 *buffer, int bufferSize)
{
static Compressor compressor = Compressor ();
return compressor.InternalDecode (fileName, headerSize, buffer, bufferSize);
}
// external encoder
static int Compress(const char *fileName, byte *header, int headerSize, byte *buffer, int bufferSize)
static int Compress(const char *fileName, uint8 *header, int headerSize, uint8 *buffer, int bufferSize)
{
static Compressor compressor = Compressor ();
return compressor.InternalEncode (fileName, header, headerSize, buffer, bufferSize);

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#pragma once
@ -13,7 +13,6 @@
#include <stdio.h>
#include <memory.h>
#include <dllapi.h>
#include <meta_api.h>
using namespace Math;
@ -625,21 +624,21 @@ struct Client
// experience data hold in memory while playing
struct Experience
{
unsigned short team0Damage;
unsigned short team1Damage;
signed short team0DangerIndex;
signed short team1DangerIndex;
signed short team0Value;
signed short team1Value;
uint16 team0Damage;
uint16 team1Damage;
int16 team0DangerIndex;
int16 team1DangerIndex;
int16 team0Value;
int16 team1Value;
};
// experience data when saving/loading
struct ExperienceSave
{
unsigned char team0Damage;
unsigned char team1Damage;
signed char team0Value;
signed char team1Value;
uint8 team0Damage;
uint8 team1Damage;
int8 team0Value;
int8 team1Value;
};
// bot creation tab
@ -668,7 +667,7 @@ struct WeaponProperty
// define chatting collection structure
struct ChatCollection
{
char chatProbability;
int chatProbability;
float chatDelay;
float timeNextChat;
int entityIndex;
@ -775,7 +774,7 @@ private:
Path *m_currentPath; // pointer to the current path waypoint
SearchPathType m_pathType; // which pathfinder to use
unsigned char m_visibility; // visibility flags
uint8 m_visibility; // visibility flags
int m_currentWaypointIndex; // current waypoint index
int m_travelStartIndex; // travel start index to double jump action
@ -784,7 +783,7 @@ private:
int m_loosedBombWptIndex; // nearest to loosed bomb waypoint
int m_plantedBombWptIndex;// nearest to planted bomb waypoint
unsigned short m_currentTravelFlags; // connection flags like jumping
uint16 m_currentTravelFlags; // connection flags like jumping
bool m_jumpFinished; // has bot finished jumping
Vector m_desiredVelocity; // desired velocity for jump waypoints
float m_navTimeset; // time waypoint chosen by Bot
@ -941,7 +940,7 @@ private:
bool IsInViewCone (const Vector &origin);
void ReactOnSound (void);
bool CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart);
bool CheckVisibility (edict_t *target, Vector *origin, uint8 *bodyPart);
bool IsEnemyViewable (edict_t *player);
edict_t *FindNearestButton (const char *className);
@ -972,7 +971,7 @@ private:
float GetWalkSpeed (void);
bool ItemIsVisible (const Vector &dest, char *itemName);
bool ItemIsVisible (const Vector &dest, const char *itemName);
bool LastEnemyShootable (void);
bool IsBehindSmokeClouds (edict_t *ent);
void RunTask (void);
@ -993,7 +992,7 @@ private:
int GetBestSecondaryWeaponCarried (void);
void RunPlayerMovement (void);
byte ThrottledMsec (void);
uint8 ThrottledMsec (void);
void GetValidWaypoint (void);
int ChangeWptIndex (int waypointIndex);
bool IsDeadlyDrop (const Vector &to);
@ -1357,7 +1356,7 @@ private:
int m_lastJumpWaypoint;
int m_visibilityIndex;
Vector m_lastWaypoint;
unsigned char m_visLUT[MAX_WAYPOINTS][MAX_WAYPOINTS / 4];
uint8 m_visLUT[MAX_WAYPOINTS][MAX_WAYPOINTS / 4];
float m_pathDisplayTime;
float m_arrowDisplayTime;

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#pragma once
@ -27,6 +27,20 @@
#include <sys/stat.h>
#endif
//
// Basic Types
//
typedef signed char int8;
typedef signed short int16;
typedef signed long int32;
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; }
//
// Title: Utility Classes Header
//
@ -223,7 +237,7 @@ namespace Math
*sine = sinf (rad);
*cosine = cosf (rad);
#elif defined (__linux__) || defined (GCC) || defined (__APPLE__)
register double _cos, _sin;
double _cos, _sin;
__asm __volatile__ ("fsincos" : "=t" (_cos), "=u" (_sin) : "0" (rad));
*cosine = _cos;
@ -277,7 +291,7 @@ private:
public:
RandomSequenceOfUnique (void)
{
unsigned int seedBase = time (NULL);
unsigned int seedBase = static_cast <unsigned int> (time (NULL));
unsigned int seedOffset = seedBase + 1;
m_index = PermuteQPR (PermuteQPR (seedBase) + 0x682f0161);
@ -285,7 +299,7 @@ public:
m_divider = (static_cast <unsigned long long> (1)) << 32;
}
inline int Long (int low, int high)
inline int Int (int low, int high)
{
return static_cast <int> (Random () * (static_cast <double> (high) - static_cast <double> (low) + 1.0) / m_divider + static_cast <double> (low));
}
@ -1609,7 +1623,7 @@ public:
{
extern class RandomSequenceOfUnique Random;
return m_elements[Random.Long (0, m_itemCount - 1)];
return m_elements[Random.Int (0, m_itemCount - 1)];
}
Array <T> &operator = (const Array <T> &other)
@ -2028,7 +2042,7 @@ private:
int delta = 4;
if (m_allocatedSize > 64)
delta = m_allocatedSize * 0.5;
delta = static_cast <int> (m_allocatedSize * 0.5);
else if (m_allocatedSize > 8)
delta = 16;
@ -2667,7 +2681,7 @@ public:
String result;
for (int i = 0; i < GetLength (); i++)
result += toupper (m_bufferPtr[i]);
result += static_cast <char> (toupper (static_cast <int> (m_bufferPtr[i])));
return result;
}
@ -2684,7 +2698,7 @@ public:
String result;
for (int i = 0; i < GetLength (); i++)
result += tolower (m_bufferPtr[i]);
result += static_cast <char> (tolower (static_cast <int> (m_bufferPtr[i])));
return result;
}
@ -3663,8 +3677,8 @@ public:
class MemoryFile
{
public:
typedef unsigned char *(*MF_Loader) (const char *, int *);
typedef void (*MF_Unloader) (unsigned char *);
typedef uint8 *(*MF_Loader) (const char *, int *);
typedef void (*MF_Unloader) (uint8 *);
public:
static MF_Loader Loader;
@ -3673,7 +3687,7 @@ public:
protected:
int m_size;
int m_pos;
unsigned char *m_buffer;
uint8 *m_buffer;
//
// Group: (Con/De)structors
@ -3843,7 +3857,7 @@ public:
if (!m_buffer|| m_pos >= m_size || buffer == NULL || !size || !count)
return 0;
int blocksRead = min ((m_size - m_pos) / size, count) * size;
int blocksRead = A_min ((m_size - m_pos) / size, count) * size;
memcpy (buffer, &m_buffer[m_pos], blocksRead);
m_pos += blocksRead;

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
// Purpose: Engine & Game interfaces.
//
@ -92,7 +92,7 @@ struct MessageBlock
class Engine : public Singleton <Engine>
{
private:
short m_drawModels[DRAW_NUM];
int m_drawModels[DRAW_NUM];
// bot client command
bool m_isBotCommand;

View file

@ -1,231 +0,0 @@
/***
*
* Copyright (c) 1999-2005, Valve Corporation. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#ifndef ARCHTYPES_H
#define ARCHTYPES_H
#ifdef _WIN32
#pragma once
#endif
#include <string.h>
// detects the build platform
#if defined (__linux__) || defined (__debian__) || defined (__linux)
#define __linux__ 1
#endif
// for when we care about how many bits we use
typedef signed char int8;
typedef signed short int16;
typedef signed long int32;
#ifdef _WIN32
#ifdef _MSC_VER
typedef signed __int64 int64;
#endif
#elif defined __linux__
typedef long long int64;
#endif
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
#ifdef _WIN32
#ifdef _MSC_VER
typedef unsigned __int64 uint64;
#endif
#elif defined __linux__
typedef unsigned long long uint64;
#endif
typedef float float32;
typedef double float64;
// for when we don't care about how many bits we use
typedef unsigned int uint;
// This can be used to ensure the size of pointers to members when declaring
// a pointer type for a class that has only been forward declared
#ifdef _MSC_VER
#define SINGLE_INHERITANCE __single_inheritance
#define MULTIPLE_INHERITANCE __multiple_inheritance
#else
#define SINGLE_INHERITANCE
#define MULTIPLE_INHERITANCE
#endif
// need these for the limits
#include <limits.h>
#include <float.h>
// Maximum and minimum representable values
// fixing compiling againt maxosx10.10
#if 0
#define INT8_MAX SCHAR_MAX
#define INT16_MAX SHRT_MAX
#define INT32_MAX LONG_MAX
#define INT64_MAX (((int64)~0) >> 1)
#define INT8_MIN SCHAR_MIN
#define INT16_MIN SHRT_MIN
#define INT32_MIN LONG_MIN
#define INT64_MIN (((int64)1) << 63)
#define UINT8_MAX ((uint8)~0)
#define UINT16_MAX ((uint16)~0)
#define UINT32_MAX ((uint32)~0)
#define UINT64_MAX ((uint64)~0)
#define UINT8_MIN 0
#define UINT16_MIN 0
#define UINT32_MIN 0
#define UINT64_MIN 0
#ifndef UINT_MIN
#define UINT_MIN UINT32_MIN
#endif
#define FLOAT32_MAX FLT_MAX
#define FLOAT64_MAX DBL_MAX
#define FLOAT32_MIN FLT_MIN
#define FLOAT64_MIN DBL_MIN
#endif
// portability / compiler settings
#if defined(_WIN32) && !defined(WINDED)
#if defined(_M_IX86)
#define __i386__ 1
#endif
#elif __linux__
typedef unsigned int DWORD;
typedef unsigned short WORD;
typedef void *HINSTANCE;
#define _MAX_PATH PATH_MAX
#endif // defined(_WIN32) && !defined(WINDED)
// Defines MAX_PATH
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
// Used to step into the debugger
#define DebuggerBreak() __asm { int 3 }
// C functions for external declarations that call the appropriate C++ methods
#ifndef EXPORT
#ifdef _WIN32
#define EXPORT __declspec( dllexport )
#else
#define EXPORT /* */
#endif
#endif
#if defined __i386__ && !defined __linux__
#define id386 1
#else
#define id386 0
#endif // __i386__
#ifdef _WIN32
// Used for dll exporting and importing
#define DLL_EXPORT extern "C" __declspec( dllexport )
#define DLL_IMPORT extern "C" __declspec( dllimport )
// Can't use extern "C" when DLL exporting a class
#define DLL_CLASS_EXPORT __declspec( dllexport )
#define DLL_CLASS_IMPORT __declspec( dllimport )
// Can't use extern "C" when DLL exporting a global
#define DLL_GLOBAL_EXPORT extern __declspec( dllexport )
#define DLL_GLOBAL_IMPORT extern __declspec( dllimport )
#elif defined __linux__ || defined (__APPLE__)
// Used for dll exporting and importing
#define DLL_EXPORT extern "C"
#define DLL_IMPORT extern "C"
// Can't use extern "C" when DLL exporting a class
#define DLL_CLASS_EXPORT
#define DLL_CLASS_IMPORT
// Can't use extern "C" when DLL exporting a global
#define DLL_GLOBAL_EXPORT extern
#define DLL_GLOBAL_IMPORT extern
#else
#error "Unsupported Platform."
#endif
#ifndef _WIN32
#define FAKEFUNC (void *) 0
#else
#define FAKEFUNC __noop
#endif
// Used for standard calling conventions
#ifdef _WIN32
#define STDCALL __stdcall
#define FASTCALL __fastcall
#ifndef FORCEINLINE
#define FORCEINLINE __forceinline
#endif
#else
#define STDCALL
#define FASTCALL
#define FORCEINLINE inline
#endif
// Force a function call site -not- to inlined. (useful for profiling)
#define DONT_INLINE(a) (((int)(a)+1)?(a):(a))
// Pass hints to the compiler to prevent it from generating unnessecary / stupid code
// in certain situations. Several compilers other than MSVC also have an equivilent
// construct.
//
// Essentially the 'Hint' is that the condition specified is assumed to be true at
// that point in the compilation. If '0' is passed, then the compiler assumes that
// any subsequent code in the same 'basic block' is unreachable, and thus usually
// removed.
#ifdef _MSC_VER
#define HINT(THE_HINT) __assume((THE_HINT))
#else
#define HINT(THE_HINT) 0
#endif
// Marks the codepath from here until the next branch entry point as unreachable,
// and asserts if any attempt is made to execute it.
#define UNREACHABLE() { ASSERT(0); HINT(0); }
// In cases where no default is present or appropriate, this causes MSVC to generate
// as little code as possible, and throw an assertion in debug.
#define NO_DEFAULT default: UNREACHABLE();
#ifdef _WIN32
// Alloca defined for this platform
#define stackalloc( _size ) _alloca( _size )
#define stackfree( _p ) 0
#elif __linux__
// Alloca defined for this platform
#define stackalloc( _size ) alloca( _size )
#define stackfree( _p ) 0
#endif
#endif

View file

@ -602,10 +602,10 @@
#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END).
// attenuation values
#define ATTN_NONE 0
#define ATTN_NORM (float)0.8
#define ATTN_IDLE (float)2
#define ATTN_STATIC (float)1.25
#define ATTN_NONE 0.0f
#define ATTN_NORM 0.8f
#define ATTN_IDLE 2f
#define ATTN_STATIC 1.25f
// pitch values
#define PITCH_NORM 100 // non-pitch shifted
@ -710,42 +710,6 @@ enum
typedef int func_t;
typedef int string_t;
typedef unsigned char byte;
typedef unsigned short word;
#define _DEF_BYTE_
#undef true
#undef false
#ifndef __cplusplus
typedef enum
{ false, true } int;
#else
#endif
typedef struct
{
byte r, g, b;
} color24;
typedef struct
{
unsigned r, g, b, a;
} colorVec;
#ifdef _WIN32
#pragma pack(push,2)
#endif
typedef struct
{
unsigned short r, g, b, a;
} PackedColorVec;
#ifdef _WIN32
#pragma pack(pop)
#endif
typedef struct link_s
{
struct link_s *prev, *next;

View file

@ -1,47 +0,0 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
*
* This file is part of Metamod.
*
* Metamod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* Metamod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Metamod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
// Simplified version by Wei Mingzhi
#ifndef DLLAPI_H
#define DLLAPI_H
#undef DLLEXPORT
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#elif defined(linux) || defined (__APPLE__)
#define DLLEXPORT /* */
#define WINAPI /* */
#endif /* linux */
#define C_DLLEXPORT extern "C" DLLEXPORT
#endif /* DLLAPI_H */

View file

@ -18,7 +18,6 @@
#define INTERFACE_VERSION 140
#include <stdio.h>
#include "archtypes.h"
#define FCVAR_ARCHIVE (1 << 0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1 << 1) // changes the client's info string
@ -189,14 +188,14 @@ typedef struct enginefuncs_s
void (*pfnGetAttachment) (const edict_t *ent, int iAttachment, float *rgflOrigin, float *rgflAngles);
void (*pfnCRC32_Init) (CRC32_t *pulCRC);
void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len);
void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, unsigned char ch);
void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, uint8 ch);
CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC);
int32 (*pfnRandomLong) (int32 lLow, int32 lHigh);
float (*pfnRandomFloat) (float flLow, float flHigh);
void (*pfnSetView) (const edict_t *client, const edict_t *pViewent);
float (*pfnTime) (void);
void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw);
byte *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
uint8 *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
void (*pfnFreeFile) (void *buffer);
void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection
int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare);
@ -204,10 +203,10 @@ typedef struct enginefuncs_s
void (*pfnCvar_RegisterVariable) (cvar_t *variable);
void (*pfnFadeClientVolume) (const edict_t *ent, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
void (*pfnSetClientMaxspeed) (const edict_t *ent, float fNewMaxspeed);
edict_t *(*pfnCreateFakeClient) (const char *netname); // returns NULL if fake client can't be created
void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec);
edict_t *(*pfnCreateFakeClient) (const char *netname); // returns nullptr if fake client can't be created
void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, uint16 buttons, uint8 impulse, uint8 msec);
int (*pfnNumberOfEntities) (void);
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in nullptr gets the serverinfo
char *(*pfnInfoKeyValue) (char *infobuffer, char const *key);
void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value);
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value);
@ -224,14 +223,14 @@ typedef struct enginefuncs_s
const char *(*pfnGetPhysicsKeyValue) (const edict_t *client, const char *key);
void (*pfnSetPhysicsKeyValue) (const edict_t *client, const char *key, const char *value);
const char *(*pfnGetPhysicsInfoString) (const edict_t *client);
unsigned short (*pfnPrecacheEvent) (int type, const char *psz);
void (*pfnPlaybackEvent) (int flags, const edict_t *pInvoker, unsigned short evIndexOfEntity, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
unsigned char *(*pfnSetFatPVS) (float *org);
unsigned char *(*pfnSetFatPAS) (float *org);
int (*pfnCheckVisibility) (const edict_t *entity, unsigned char *pset);
uint16 (*pfnPrecacheEvent) (int type, const char *psz);
void (*pfnPlaybackEvent) (int flags, const edict_t *pInvoker, uint16 evIndexOfEntity, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
uint8 *(*pfnSetFatPVS) (float *org);
uint8 *(*pfnSetFatPAS) (float *org);
int (*pfnCheckVisibility) (const edict_t *entity, uint8 *pset);
void (*pfnDeltaSetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaUnsetField) (struct delta_s *pFields, const char *fieldname);
void (*pfnDeltaAddEncoder) (char *name, void (*conditionalencode) (struct delta_s *pFields, const unsigned char *from, const unsigned char *to));
void (*pfnDeltaAddEncoder) (char *name, void (*conditionalencode) (struct delta_s *pFields, const uint8 *from, const uint8 *to));
int (*pfnGetCurrentPlayer) (void);
int (*pfnCanSkipPlayer) (const edict_t *player);
int (*pfnDeltaFindField) (struct delta_s *pFields, const char *fieldname);
@ -338,9 +337,9 @@ typedef struct
void (*pfnPM_Move) (struct playermove_s *ppmove, int server);
void (*pfnPM_Init) (struct playermove_s *ppmove);
char (*pfnPM_FindTextureType) (char *name);
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, unsigned char **pvs, unsigned char **pas);
void (*pfnSetupVisibility) (struct edict_s *pViewEntity, struct edict_s *client, uint8 **pvs, uint8 **pas);
void (*pfnUpdateClientData) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
int (*pfnAddToFullPack) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
int (*pfnAddToFullPack) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, uint8 *pSet);
void (*pfnCreateBaseline) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, float* player_mins, float* player_maxs);
void (*pfnRegisterEncoders) (void);
int (*pfnGetWeaponData) (struct edict_s *player, struct weapon_data_s *info);

View file

@ -72,7 +72,7 @@ extern enginefuncs_t g_engfuncs;
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL)
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin = nullptr, edict_t *ed = nullptr)
{
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ed);
}
@ -95,7 +95,7 @@ static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrig
#define ALERT (*g_engfuncs.pfnAlertMessage)
#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf)
#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData)
#define GET_PRIVATE(pent) (pent ? (pent->pvPrivateData) : NULL);
#define GET_PRIVATE(pent) (pent ? (pent->pvPrivateData) : nullptr);
#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData)
#define ALLOC_STRING (*g_engfuncs.pfnAllostring)
#define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString)

View file

@ -16,21 +16,7 @@
#ifndef EXTDLL_H
#define EXTDLL_H
#ifdef DLL_DEBUG
#define DEBUG 1
#endif
#ifdef _MSC_VER
#pragma warning (disable : 4244) // int or float down-conversion
#pragma warning (disable : 4305) // int or float data truncation
#pragma warning (disable : 4201) // nameless struct/union
#pragma warning (disable : 4514) // unreferenced inline function removed
#pragma warning (disable : 4100) // unreferenced formal parameter
#pragma warning (disable : 4715) // not all control paths return a value
#pragma warning (disable : 4996) // function was declared deprecated
#pragma warning (disable : 4702) // unreachable code
#pragma warning (disable : 4706) // assignment within conditional expression
/* disable deprecation warnings concerning unsafe CRT functions */
#if !defined _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
@ -49,7 +35,7 @@
#define FALSE 0
#define TRUE (!FALSE)
typedef unsigned long ULONG;
typedef unsigned char BYTE;
typedef uint8 BYTE;
typedef int BOOL;
#define MAX_PATH PATH_MAX
@ -68,8 +54,6 @@ typedef int BOOL;
#include "stdlib.h"
#include "math.h"
#include <archtypes.h>
typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h

View file

@ -8,6 +8,7 @@
#ifndef META_API_H
#define META_API_H
typedef int (*GameAPI_t) (gamefuncs_t *, int);
typedef int (*GameAPI2_t) (gamefuncs_t *, int *);
typedef int (*NewAPI2_t) (gamefuncs_t *, int *);
@ -18,9 +19,6 @@ typedef int (*GETENTITYAPI2_FN) (gamefuncs_t *pFunctionTable, int *interfaceVers
typedef int (*GETNEWDLLFUNCTIONS_FN) (newgamefuncs_t *pFunctionTable, int *interfaceVersion);
typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
C_DLLEXPORT int GetEntityAPI (gamefuncs_t *pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetEntityAPI2 (gamefuncs_t *pFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions (newgamefuncs_t *pNewFunctionTable, int *interfaceVersion);
#define META_INTERFACE_VERSION "5:13"
@ -159,26 +157,6 @@ extern mutil_funcs_t *gpMetaUtilFuncs;
extern meta_globals_t *gpMetaGlobals;
extern metamod_funcs_t gMetaFunctionTable;
C_DLLEXPORT void Meta_Init (void);
typedef void (*META_INIT_FN) (void);
C_DLLEXPORT int Meta_Query (char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);
typedef int (*META_QUERY_FN) (char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);
C_DLLEXPORT int Meta_Attach (PLUG_LOADTIME now, metamod_funcs_t *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, metamod_funcs_t *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
C_DLLEXPORT int Meta_Detach (PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
C_DLLEXPORT int GetEntityAPI_Post (gamefuncs_t *pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetEntityAPI2_Post (gamefuncs_t *pFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions_Post (newgamefuncs_t *pNewFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetEngineFunctions (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
C_DLLEXPORT int GetEngineFunctions_Post (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
#define MDLL_FUNC gpGamedllFuncs->dllapi_table

View file

@ -1,14 +0,0 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef MUTIL_H
#define MUTIL_H
#include "plinfo.h"
#include "sdk_util.h"
#endif /* MUTIL_H */

View file

@ -1,11 +0,0 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef PLINFO_H
#define PLINFO_H
#endif

View file

@ -116,8 +116,8 @@ typedef struct entvars_s
float frame; // % playback position in animation sequences (0..255)
float animtime; // world time when frame was set
float framerate; // animation playback rate (-8x to 8x)
byte controller[4]; // bone controller setting (0..255)
byte blending[2]; // blending amount between sub-sequences (0..255)
uint8 controller[4]; // bone controller setting (0..255)
uint8 blending[2]; // blending amount between sub-sequences (0..255)
float scale; // sprite rendering scale (0..255)

View file

@ -1,23 +0,0 @@
/*
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
* See the file "dllapi.h" in this folder for full information
*/
// Simplified version by Wei Mingzhi
#ifndef SDK_UTIL_H
#define SDK_UTIL_H
#ifdef DEBUG
#undef DEBUG
#endif
#include <util.h>
short FixedSigned16 (float value, float scale);
unsigned short FixedUnsigned16 (float value, float scale);
#endif

View file

@ -73,94 +73,14 @@ typedef int BOOL;
#define M_PI 3.1415926
#endif
//
// Conversion among the three types of "entity", including identity-conversions.
//
#if 0
static inline edict_t *ENT (const entvars_t *pev)
{
return pev->pContainingEntity;
}
static inline edict_t *ENT (edict_t *pent)
{
return pent;
}
static inline edict_t *ENT (EOFFSET eoffset)
{
return (*g_engfuncs.pfnPEntityOfEntOffset) (eoffset);
}
static inline EOFFSET OFFSET (EOFFSET eoffset)
{
return eoffset;
}
static inline EOFFSET OFFSET (const edict_t *pent)
{
#if _DEBUG
if (!pent)
ALERT (at_error, "Bad ent in OFFSET()\n");
#endif
return (*g_engfuncs.pfnEntOffsetOfPEntity) (pent);
}
static inline EOFFSET OFFSET (entvars_t *pev)
{
#if _DEBUG
if (!pev)
ALERT (at_error, "Bad pev in OFFSET()\n");
#endif
return OFFSET (ENT (pev));
}
static inline entvars_t *VARS (entvars_t *pev)
{
return pev;
}
static inline entvars_t *VARS (edict_t *pent)
{
if (!pent)
return NULL;
return &pent->v;
}
static inline entvars_t *VARS (EOFFSET eoffset)
{
return VARS (ENT (eoffset));
}
#endif
short FixedSigned16 (float value, float scale);
uint16 FixedUnsigned16 (float value, float scale);
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent)
{
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ent->pContainingEntity);
}
#if 0
// Testing the three types of "entity" for nullity
#define eoNullEntity 0
static inline BOOL FNullEnt (EOFFSET eoffset)
{
return eoffset == 0;
}
static inline BOOL FNullEnt (entvars_t *pev)
{
return pev == NULL || FNullEnt (OFFSET (pev));
}
static inline int FNullEnt (const edict_t *pent)
{
return !pent || !(*g_engfuncs.pfnEntOffsetOfPEntity) (pent);
}
// Testing strings for nullity
#define iStringNull 0
static inline BOOL FStringNull (int stingPtr)
{
return stingPtr == iStringNull;
}
#define cchMapNameMost 32
#define SAFE_FUNCTION_CALL(pfn,args) try { pfn args; } catch (...) { }
#endif
// Dot products for view cone checking
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks
@ -195,8 +115,8 @@ typedef struct hudtextparms_s
float x;
float y;
int effect;
byte r1, g1, b1, a1;
byte r2, g2, b2, a2;
uint8 r1, g1, b1, a1;
uint8 r2, g2, b2, a2;
float fadeinTime;
float fadeoutTime;
float holdTime;

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#pragma once
@ -69,7 +69,7 @@ extern gamefuncs_t g_functionTable;
static inline bool IsNullString (const char *input)
{
if (input == NULL)
if (input == nullptr)
return true;
return *input == '\0';

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#pragma once
@ -40,14 +40,14 @@
#include <direct.h>
#include <string.h>
#define DLL_ENTRYPOINT int STDCALL DllMain (HINSTANCE, DWORD dwReason, LPVOID)
#define DLL_ENTRYPOINT int __stdcall DllMain (HINSTANCE, DWORD dwReason, LPVOID)
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
#define DLL_RETENTRY return TRUE
#if defined (COMPILER_VISUALC)
#define DLL_GIVEFNPTRSTODLL extern "C" void STDCALL
#define DLL_GIVEFNPTRSTODLL extern "C" void __stdcall
#elif defined (COMPILER_MINGW32)
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STDCALL
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void __stdcall
#endif
// specify export parameter
@ -59,7 +59,7 @@
typedef int (FAR *EntityAPI_t) (gamefuncs_t *, int);
typedef int (FAR *NewEntityAPI_t) (newgamefuncs_t *, int *);
typedef int (FAR *BlendAPI_t) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (STDCALL *FuncPointers_t) (enginefuncs_t *, globalvars_t *);
typedef void (__stdcall *FuncPointers_t) (enginefuncs_t *, globalvars_t *);
typedef void (FAR *EntityPtr_t) (entvars_t *);
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
@ -105,9 +105,9 @@ public:
Library (const char *fileName)
{
m_ptr = NULL;
m_ptr = nullptr;
if (fileName == NULL)
if (fileName == nullptr)
return;
LoadLib (fileName);
@ -140,7 +140,7 @@ public:
template <typename R> R GetFuncAddr (const char *function)
{
if (!IsLoaded ())
return NULL;
return nullptr;
#ifdef PLATFORM_WIN32
return reinterpret_cast <R> (GetProcAddress (static_cast <HMODULE> (m_ptr), function));
@ -156,6 +156,6 @@ public:
inline bool IsLoaded (void) const
{
return m_ptr != NULL;
return m_ptr != nullptr;
}
};

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#pragma once

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <winver.h>

View file

@ -15,17 +15,12 @@
<ClInclude Include="..\include\core.h" />
<ClInclude Include="..\include\corelib.h" />
<ClInclude Include="..\include\engine.h" />
<ClInclude Include="..\include\engine\archtypes.h" />
<ClInclude Include="..\include\engine\const.h" />
<ClInclude Include="..\include\engine\dllapi.h" />
<ClInclude Include="..\include\engine\eiface.h" />
<ClInclude Include="..\include\engine\enginecallback.h" />
<ClInclude Include="..\include\engine\extdll.h" />
<ClInclude Include="..\include\engine\meta_api.h" />
<ClInclude Include="..\include\engine\mutil.h" />
<ClInclude Include="..\include\engine\plinfo.h" />
<ClInclude Include="..\include\engine\progdefs.h" />
<ClInclude Include="..\include\engine\sdk_util.h" />
<ClInclude Include="..\include\engine\util.h" />
<ClInclude Include="..\include\globals.h" />
<ClInclude Include="..\include\platform.h" />

View file

@ -33,9 +33,6 @@
<ClInclude Include="..\include\engine\const.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\dllapi.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\eiface.h">
<Filter>include\engine</Filter>
</ClInclude>
@ -45,24 +42,12 @@
<ClInclude Include="..\include\engine\meta_api.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\mutil.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\plinfo.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\progdefs.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\sdk_util.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\util.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\engine\archtypes.h">
<Filter>include\engine</Filter>
</ClInclude>
<ClInclude Include="..\include\platform.h">
<Filter>include</Filter>
</ClInclude>

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -92,17 +92,17 @@ char *HumanizeName (char *name)
strncpy (outputName, name, SIZEOF_CHAR (outputName)); // copy name to new buffer
// drop tag marks, 80 percent of time
if (Random.Long (1, 100) < 80)
if (Random.Int (1, 100) < 80)
StripTags (outputName);
else
String::TrimExternalBuffer (outputName);
// sometimes switch name to lower characters
// note: since we're using russian names written in english, we reduce this shit to 6 percent
if (Random.Long (1, 100) <= 6)
if (Random.Int (1, 100) <= 6)
{
for (int i = 0; i < static_cast <int> (strlen (outputName)); i++)
outputName[i] = tolower (outputName[i]); // to lower case
outputName[i] = static_cast <char> (tolower (static_cast <int> (outputName[i]))); // to lower case
}
return &outputName[0]; // return terminated string
}
@ -116,18 +116,18 @@ void HumanizeChat (char *buffer)
// sometimes switch text to lowercase
// note: since we're using russian chat written in english, we reduce this shit to 4 percent
if (Random.Long (1, 100) <= 4)
if (Random.Int (1, 100) <= 4)
{
for (i = 0; i < length; i++)
buffer[i] = tolower (buffer[i]); // switch to lowercase
buffer[i] = static_cast <char> (tolower (static_cast <int> (buffer[i])));; // switch to lowercase
}
if (length > 15)
{
// "length / 2" percent of time drop a character
if (Random.Long (1, 100) < (length / 2))
if (Random.Int (1, 100) < (length / 2))
{
int pos = Random.Long ((length / 8), length - (length / 8)); // chose random position in string
int pos = Random.Int ((length / 8), length - (length / 8)); // chose random position in string
for (i = pos; i < length - 1; i++)
buffer[i] = buffer[i + 1]; // overwrite the buffer with stripped string
@ -137,9 +137,9 @@ void HumanizeChat (char *buffer)
}
// "length" / 4 precent of time swap character
if (Random.Long (1, 100) < (length / 4))
if (Random.Int (1, 100) < (length / 4))
{
int pos = Random.Long ((length / 8), ((3 * length) / 8)); // choose random position in string
int pos = Random.Int ((length / 8), ((3 * length) / 8)); // choose random position in string
char ch = buffer[pos]; // swap characters
buffer[pos] = buffer[pos + 1];
@ -163,14 +163,14 @@ void Bot::PrepareChatMessage (char *text)
char *textStart = text;
char *pattern = text;
edict_t *talkEntity = NULL;
edict_t *talkEntity = nullptr;
while (pattern != NULL)
while (pattern != nullptr)
{
// all replacement placeholders start with a %
pattern = strstr (textStart, "%");
if (pattern != NULL)
if (pattern != nullptr)
{
int length = pattern - textStart;
@ -304,14 +304,14 @@ void Bot::PrepareChatMessage (char *text)
{
if (g_gameFlags & GAME_CZERO)
{
if (Random.Long (1, 100) < 30)
if (Random.Int (1, 100) < 30)
strcat (m_tempStrings, "CZ");
else
strcat (m_tempStrings, "Condition Zero");
}
else if ((g_gameFlags & GAME_CSTRIKE16) || (g_gameFlags & GAME_LEGACY))
{
if (Random.Long (1, 100) < 30)
if (Random.Int (1, 100) < 30)
strcat (m_tempStrings, "CS");
else
strcat (m_tempStrings, "Counter-Strike");
@ -327,7 +327,7 @@ void Bot::PrepareChatMessage (char *text)
}
}
if (textStart != NULL)
if (textStart != nullptr)
{
// let the bots make some mistakes...
char tempString[160];
@ -350,7 +350,7 @@ bool CheckKeywords (char *tempMessage, char *reply)
FOR_EACH_AE (g_replyFactory[i].keywords, j)
{
// check is keyword has occurred in message
if (strstr (tempMessage, g_replyFactory[i].keywords[j].GetBuffer ()) != NULL)
if (strstr (tempMessage, g_replyFactory[i].keywords[j].GetBuffer ()) != nullptr)
{
Array <String> &replies = g_replyFactory[i].usedReplies;
@ -363,7 +363,7 @@ bool CheckKeywords (char *tempMessage, char *reply)
// don't say this twice
FOR_EACH_AE (replies, k)
{
if (strstr (replies[k].GetBuffer (), generatedReply) != NULL)
if (strstr (replies[k].GetBuffer (), generatedReply) != nullptr)
replyUsed = true;
}
@ -380,7 +380,7 @@ bool CheckKeywords (char *tempMessage, char *reply)
}
// didn't find a keyword? 70% of the time use some universal reply
if (Random.Long (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ())
if (Random.Int (1, 100) < 70 && !g_chatFactory[CHAT_NOKW].IsEmpty ())
{
strcpy (reply, g_chatFactory[CHAT_NOKW].GetRandomElement ().GetBuffer ());
return true;
@ -397,7 +397,7 @@ bool Bot::ParseChat (char *reply)
// text to uppercase for keyword parsing
for (int i = 0; i < static_cast <int> (strlen (tempMessage)); i++)
tempMessage[i] = toupper (tempMessage[i]);
tempMessage[i] = static_cast <char> (tolower (static_cast <int> (tempMessage[i])));
return CheckKeywords (tempMessage, reply);
}
@ -413,7 +413,7 @@ bool Bot::RepliesToPlayer (void)
// check is time to chat is good
if (m_sayTextBuffer.timeNextChat < engine.Time ())
{
if (Random.Long (1, 100) < m_sayTextBuffer.chatProbability + Random.Long (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
if (Random.Int (1, 100) < m_sayTextBuffer.chatProbability + Random.Int (2, 10) && ParseChat (reinterpret_cast <char *> (&text)))
{
PrepareChatMessage (text);
PushMessageQueue (GSM_SAY);

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -14,7 +14,7 @@ ConVar yb_ignore_enemies ("yb_ignore_enemies", "0");
ConVar yb_csdm_mode ("yb_csdm_mode", "0");
ConVar yb_check_enemy_rendering ("yb_check_enemy_rendering", "0");
ConVar mp_friendlyfire ("mp_friendlyfire", NULL, VT_NOREGISTER);
ConVar mp_friendlyfire ("mp_friendlyfire", nullptr, VT_NOREGISTER);
int Bot::GetNearbyFriendsNearPosition(const Vector &origin, float radius)
{
@ -93,7 +93,7 @@ bool Bot::IsEnemyHiddenByRendering (edict_t *enemy)
return false;
}
bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
bool Bot::CheckVisibility (edict_t *target, Vector *origin, uint8 *bodyPart)
{
// this function checks visibility of a bot target.
@ -214,7 +214,7 @@ bool Bot::LookupEnemy (void)
if (m_enemyIgnoreTimer > engine.Time () || m_blindTime > engine.Time () || yb_ignore_enemies.GetBool ())
return false;
edict_t *player, *newEnemy = NULL;
edict_t *player, *newEnemy = nullptr;
float nearestDistance = m_viewDistance;
@ -237,7 +237,7 @@ bool Bot::LookupEnemy (void)
m_enemyUpdateTime = engine.Time () + 0.5f;
// ignore shielded enemies, while we have real one
edict_t *shieldEnemy = NULL;
edict_t *shieldEnemy = nullptr;
// setup potentially visible set for this bot
Vector potentialVisibility = EyePosition ();
@ -245,7 +245,7 @@ bool Bot::LookupEnemy (void)
if (pev->flags & FL_DUCKING)
potentialVisibility = potentialVisibility + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN);
byte *pvs = ENGINE_SET_PVS (reinterpret_cast <float *> (&potentialVisibility));
uint8 *pvs = ENGINE_SET_PVS (reinterpret_cast <float *> (&potentialVisibility));
// search the world for players...
for (int i = 0; i < engine.MaxClients (); i++)
@ -266,7 +266,7 @@ bool Bot::LookupEnemy (void)
{
m_blindRecognizeTime = engine.Time () + Random.Float (1.0f, 2.0f);
if (Random.Long (0, 100) < 50)
if (Random.Int (0, 100) < 50)
ChatterMessage (Chatter_BehindSmoke);
}
@ -323,9 +323,9 @@ bool Bot::LookupEnemy (void)
if (m_seeEnemyTime + 3.0 < engine.Time () && (m_hasC4 || HasHostage () || !engine.IsNullEntity (m_targetEntity)))
RadioMessage (Radio_EnemySpotted);
m_targetEntity = NULL; // stop following when we see an enemy...
m_targetEntity = nullptr; // stop following when we see an enemy...
if (Random.Long (0, 100) < m_difficulty * 25)
if (Random.Int (0, 100) < m_difficulty * 25)
m_enemySurpriseTime = engine.Time () + m_actualReactionTime * 0.5f;
else
m_enemySurpriseTime = engine.Time () + m_actualReactionTime;
@ -353,7 +353,7 @@ bool Bot::LookupEnemy (void)
Bot *other = bots.GetBot (client.ent);
if (other != NULL && other->m_seeEnemyTime + 2.0f < engine.Time () && engine.IsNullEntity (other->m_lastEnemy) && IsVisible (pev->origin, other->GetEntity ()) && other->IsInViewCone (pev->origin))
if (other != nullptr && other->m_seeEnemyTime + 2.0f < engine.Time () && engine.IsNullEntity (other->m_lastEnemy) && IsVisible (pev->origin, other->GetEntity ()) && other->IsInViewCone (pev->origin))
{
other->m_lastEnemy = newEnemy;
other->m_lastEnemyOrigin = m_lastEnemyOrigin;
@ -372,7 +372,7 @@ bool Bot::LookupEnemy (void)
if (!IsAlive (newEnemy))
{
m_enemy = NULL;
m_enemy = nullptr;
// shoot at dying players if no new enemy to give some more human-like illusion
if (m_seeEnemyTime + 0.1f > engine.Time ())
@ -459,7 +459,7 @@ const Vector &Bot::GetAimPosition (void)
int headshotFreq[5] = { 20, 40, 60, 80, 100 };
// now check is our skill match to aim at head, else aim at enemy body
if ((Random.Long (1, 100) < headshotFreq[m_difficulty]) || UsesPistol ())
if ((Random.Int (1, 100) < headshotFreq[m_difficulty]) || UsesPistol ())
targetOrigin = targetOrigin + m_enemy->v.view_ofs + Vector (0.0f, 0.0f, GetZOffset (distance));
else
targetOrigin = targetOrigin + Vector (0.0f, 0.0f, GetZOffset (distance));
@ -816,7 +816,7 @@ void Bot::FinishWeaponSelection (float distance, int index, int id, int choosen)
{
if (distance < 64.0f)
{
if (Random.Long (1, 100) < 30 || HasShield ())
if (Random.Int (1, 100) < 30 || HasShield ())
pev->button |= IN_ATTACK; // use primary attack
else
pev->button |= IN_ATTACK2; // use secondary attack
@ -1082,7 +1082,7 @@ void Bot::CombatFight (void)
{
if (m_lastFightStyleCheck + 3.0f < engine.Time ())
{
int rand = Random.Long (1, 100);
int rand = Random.Int (1, 100);
if (distance < 450.0f)
m_fightStyle = FIGHT_STRAFE;
@ -1107,7 +1107,7 @@ void Bot::CombatFight (void)
{
if (m_lastFightStyleCheck + 3.0f < engine.Time ())
{
if (Random.Long (0, 100) < 50)
if (Random.Int (0, 100) < 50)
m_fightStyle = FIGHT_STRAFE;
else
m_fightStyle = FIGHT_STAY;
@ -1131,7 +1131,7 @@ void Bot::CombatFight (void)
else
m_combatStrafeDir = STRAFE_DIR_RIGHT;
if (Random.Long (1, 100) < 30)
if (Random.Int (1, 100) < 30)
m_combatStrafeDir = (m_combatStrafeDir == STRAFE_DIR_LEFT ? STRAFE_DIR_RIGHT : STRAFE_DIR_LEFT);
m_strafeSetTime = engine.Time () + Random.Float (0.5f, 3.0f);
@ -1158,7 +1158,7 @@ void Bot::CombatFight (void)
}
}
if (m_difficulty >= 3 && (m_jumpTime + 5.0f < engine.Time () && IsOnFloor () && Random.Long (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0f) && !UsesSniper ())
if (m_difficulty >= 3 && (m_jumpTime + 5.0f < engine.Time () && IsOnFloor () && Random.Int (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.GetLength2D () > 150.0f) && !UsesSniper ())
pev->button |= IN_JUMP;
if (m_moveSpeed > 0.0f && distance > 100.0f && m_currentWeapon != WEAPON_KNIFE)

View file

@ -4,15 +4,15 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
Engine::Engine (void)
{
m_startEntity = NULL;
m_localEntity = NULL;
m_startEntity = nullptr;
m_localEntity = nullptr;
m_language.RemoveAll ();
ResetMessageCapture ();
@ -44,7 +44,7 @@ void Engine::Precache (edict_t *startEntity)
m_drawModels[DRAW_SIMPLE] = PRECACHE_MODEL (ENGINE_STR ("sprites/laserbeam.spr"));
m_drawModels[DRAW_ARROW] = PRECACHE_MODEL (ENGINE_STR ("sprites/arrow1.spr"));
m_localEntity = NULL;
m_localEntity = nullptr;
m_startEntity = startEntity;
}
@ -134,7 +134,7 @@ void Engine::DrawLine (edict_t * ent, const Vector &start, const Vector &end, in
if (!IsValidPlayer (ent))
return; // reliability check
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, ent);
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, nullptr, ent);
WRITE_BYTE (TE_BEAMPOINTS);
WRITE_COORD (end.x);
WRITE_COORD (end.y);
@ -207,7 +207,7 @@ float Engine::GetWaveLength (const char *fileName)
return 0.0f;
// check if we have engine function for this
if (g_engfuncs.pfnGetApproxWavePlayLen != NULL)
if (g_engfuncs.pfnGetApproxWavePlayLen != nullptr)
{
fp.Close ();
return g_engfuncs.pfnGetApproxWavePlayLen (filePath) / 1000.0f;
@ -221,12 +221,12 @@ float Engine::GetWaveLength (const char *fileName)
char chunkID[4];
char formatChunkId[4];
unsigned long formatChunkLength;
unsigned short dummy;
unsigned short channels;
uint16 dummy;
uint16 channels;
unsigned long sampleRate;
unsigned long bytesPerSecond;
unsigned short bytesPerSample;
unsigned short bitsPerSample;
uint16 bytesPerSample;
uint16 bitsPerSample;
char dataChunkId[4];
unsigned long dataChunkLength;
} waveHdr;
@ -326,7 +326,7 @@ void Engine::RegisterCmd (const char * command, void func (void))
void Engine::EmitSound (edict_t *ent, const char *sound)
{
g_engfuncs.pfnEmitSound (ent, CHAN_WEAPON, sound, 1.0f, ATTN_NORM, 0, 100.0f);
g_engfuncs.pfnEmitSound (ent, CHAN_WEAPON, sound, 1.0f, ATTN_NORM, 0, 100);
}
void Engine::IssueBotCommand (edict_t *ent, const char *fmt, ...)
@ -518,7 +518,7 @@ void Engine::PushRegisteredConVarsToEngine (bool gameVars)
{
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
if (ptr->self->m_eptr == NULL)
if (ptr->self->m_eptr == nullptr)
{
g_engfuncs.pfnCVarRegister (&ptr->reg);
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
@ -528,12 +528,12 @@ void Engine::PushRegisteredConVarsToEngine (bool gameVars)
{
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
if (ptr->regMissing && ptr->self->m_eptr == NULL)
if (ptr->regMissing && ptr->self->m_eptr == nullptr)
{
g_engfuncs.pfnCVarRegister (&ptr->reg);
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
}
InternalAssert (ptr->self->m_eptr != NULL); // ensure game var exists
InternalAssert (ptr->self->m_eptr != nullptr); // ensure game var exists
}
}
}
@ -590,8 +590,8 @@ void Engine::ProcessMessageCapture (void *ptr)
return;
// some needed variables
static byte r, g, b;
static byte enabled;
static uint8 r, g, b;
static uint8 enabled;
static int damageArmor, damageTaken, damageBits;
static int killerIndex, victimIndex, playerIndex;
@ -606,7 +606,7 @@ void Engine::ProcessMessageCapture (void *ptr)
char *strVal = reinterpret_cast <char *> (ptr);
int intVal = *reinterpret_cast <int *> (ptr);
unsigned char byteVal = *reinterpret_cast <unsigned char *> (ptr);
uint8 byteVal = *reinterpret_cast <uint8 *> (ptr);
// now starts of network message execution
switch (m_msgBlock.msg)
@ -770,7 +770,7 @@ void Engine::ProcessMessageCapture (void *ptr)
case 2:
damageBits = intVal;
if (bot != NULL && (damageArmor > 0 || damageTaken > 0))
if (bot != nullptr && (damageArmor > 0 || damageTaken > 0))
bot->TakeDamage (bot->pev->dmg_inflictor, damageTaken, damageArmor, damageBits);
break;
}
@ -838,7 +838,7 @@ void Engine::ProcessMessageCapture (void *ptr)
{
Bot *notify = bots.GetBot (i);
if (notify != NULL && notify->m_notKilled && killer != notify->GetEntity () && notify->EntityIsVisible (victim->v.origin) && GetTeam (killer) == notify->m_team && GetTeam (killer) != GetTeam (victim))
if (notify != nullptr && notify->m_notKilled && killer != notify->GetEntity () && notify->EntityIsVisible (victim->v.origin) && GetTeam (killer) == notify->m_team && GetTeam (killer) != GetTeam (victim))
{
if (killer == g_hostEntity)
notify->HandleChatterMessage ("#Bot_NiceShotCommander");
@ -855,7 +855,7 @@ void Engine::ProcessMessageCapture (void *ptr)
{
Bot *notify = bots.GetBot (i);
if (notify != NULL && notify->m_seeEnemyTime + 2.0f < Time () && notify->m_notKilled && notify->m_team == GetTeam (victim) && IsVisible (killer->v.origin, notify->GetEntity ()) && IsNullEntity (notify->m_enemy) && GetTeam (killer) != GetTeam (victim))
if (notify != nullptr && notify->m_seeEnemyTime + 2.0f < Time () && notify->m_notKilled && notify->m_team == GetTeam (victim) && IsVisible (killer->v.origin, notify->GetEntity ()) && IsNullEntity (notify->m_enemy) && GetTeam (killer) != GetTeam (victim))
{
notify->m_actualReactionTime = 0.0f;
notify->m_seeEnemyTime = Time ();
@ -868,14 +868,14 @@ void Engine::ProcessMessageCapture (void *ptr)
Bot *notify = bots.GetBot (killer);
// is this message about a bot who killed somebody?
if (notify != NULL)
if (notify != nullptr)
notify->m_lastVictim = victim;
else // did a human kill a bot on his team?
{
Bot *target = bots.GetBot (victim);
if (target != NULL)
if (target != nullptr)
{
if (GetTeam (killer) == GetTeam (victim))
target->m_voteKickIndex = killerIndex;
@ -958,7 +958,7 @@ void Engine::ProcessMessageCapture (void *ptr)
{
Bot *notify = bots.FindOneValidAliveBot ();
if (notify != NULL && notify->m_notKilled)
if (notify != nullptr && notify->m_notKilled)
notify->HandleChatterMessage (strVal);
}
}
@ -977,7 +977,7 @@ void Engine::ProcessMessageCapture (void *ptr)
{
Bot *notify = bots.FindOneValidAliveBot ();
if (notify != NULL && notify->m_notKilled)
if (notify != nullptr && notify->m_notKilled)
notify->HandleChatterMessage (strVal);
}
}
@ -992,20 +992,20 @@ void Engine::ProcessMessageCapture (void *ptr)
{
Bot *notify = bots.GetBot (i);
if (notify != NULL && notify->m_notKilled)
if (notify != nullptr && notify->m_notKilled)
{
notify->DeleteSearchNodes ();
notify->ResetTasks ();
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && notify->m_team == CT)
if (yb_communication_type.GetInt () == 2 && Random.Int (0, 100) < 75 && notify->m_team == CT)
notify->ChatterMessage (Chatter_WhereIsTheBomb);
}
}
waypoints.SetBombPosition ();
}
else if (bot != NULL && FStrEq (strVal, "#Switch_To_BurstFire"))
else if (bot != nullptr && FStrEq (strVal, "#Switch_To_BurstFire"))
bot->m_weaponBurstMode = BM_ON;
else if (bot != NULL && FStrEq (strVal, "#Switch_To_SemiAuto"))
else if (bot != nullptr && FStrEq (strVal, "#Switch_To_SemiAuto"))
bot->m_weaponBurstMode = BM_OFF;
}
break;
@ -1056,7 +1056,7 @@ void Engine::ProcessMessageCapture (void *ptr)
m_msgBlock.state++; // and finally update network message state
}
ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing) : m_eptr (NULL)
ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing) : m_eptr (nullptr)
{
engine.PushVariableToStack (name, initval, type, regMissing, this);
}

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -71,11 +71,11 @@ Array <Array <ChatterItem> > g_chatterFactory;
Array <BotName> g_botNames;
Array <KeywordFactory> g_replyFactory;
RandomSequenceOfUnique Random;
Library *g_gameLib = NULL;
Library *g_gameLib = nullptr;
meta_globals_t *gpMetaGlobals = NULL;
gamedll_funcs_t *gpGamedllFuncs = NULL;
mutil_funcs_t *gpMetaUtilFuncs = NULL;
meta_globals_t *gpMetaGlobals = nullptr;
gamedll_funcs_t *gpGamedllFuncs = nullptr;
mutil_funcs_t *gpMetaUtilFuncs = nullptr;
gamefuncs_t g_functionTable;
@ -83,9 +83,9 @@ enginefuncs_t g_engfuncs;
Client g_clients[MAX_ENGINE_PLAYERS];
WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
edict_t *g_hostEntity = NULL;
globalvars_t *g_pGlobals = NULL;
Experience *g_experienceData = NULL;
edict_t *g_hostEntity = nullptr;
globalvars_t *g_pGlobals = nullptr;
Experience *g_experienceData = nullptr;
// default tables for personality weapon preferences, overridden by weapons.cfg
int g_normalWeaponPrefs[NUM_WEAPONS] =
@ -110,19 +110,6 @@ int *g_weaponPrefs[] =
g_carefulWeaponPrefs
};
// metamod engine & dllapi function tables
metamod_funcs_t gMetaFunctionTable =
{
NULL, // pfnGetEntityAPI ()
NULL, // pfnGetEntityAPI_Post ()
GetEntityAPI2, // pfnGetEntityAPI2 ()
GetEntityAPI2_Post, // pfnGetEntityAPI2_Post ()
NULL, // pfnGetNewDLLFunctions ()
NULL, // pfnGetNewDLLFunctions_Post ()
GetEngineFunctions, // pfnGetEngineFunctions ()
GetEngineFunctions_Post, // pfnGetEngineFunctions_Post ()
};
// metamod plugin information
plugin_info_t Plugin_info =
{
@ -383,25 +370,25 @@ MenuText g_menus[21] =
// kickmenu #1
{
0x0,
NULL,
nullptr,
},
// kickmenu #2
{
0x0,
NULL,
nullptr,
},
// kickmenu #3
{
0x0,
NULL,
nullptr,
},
// kickmenu #4
{
0x0,
NULL,
nullptr,
},
// command menu

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -16,7 +16,7 @@ ConVar yb_password_key ("yb_password_key", "_ybpw");
ConVar yb_language ("yb_language", "en");
ConVar yb_version ("yb_version", PRODUCT_VERSION, VT_READONLY);
ConVar mp_startmoney ("mp_startmoney", NULL, VT_NOREGISTER);
ConVar mp_startmoney ("mp_startmoney", nullptr, VT_NOREGISTER);
int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *self)
{
@ -96,7 +96,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
{
Bot *bot = bots.GetBot (i);
if (bot != NULL)
if (bot != nullptr)
bot->m_voteMap = nominatedMap;
}
engine.ClientPrintf (ent, "All dead bots will vote for map #%d", nominatedMap);
@ -179,7 +179,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
{
Bot *bot = bots.GetBot (i);
if (bot != NULL)
if (bot != nullptr)
{
bot->pev->takedamage = isOn ? 0.0f : 1.0f;
}
@ -197,7 +197,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
DisplayMenuToClient (ent, &g_menus[18]);
else
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
engine.CenterPrintf ("You're dead, and have no access to this menu");
}
}
@ -246,7 +246,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
// toggles displaying player models on spawn spots
else if (stricmp (arg1, "mdl") == 0 || stricmp (arg1, "models") == 0)
{
edict_t *spawnEntity = NULL;
edict_t *spawnEntity = nullptr;
if (stricmp (arg2, "on") == 0)
{
@ -480,8 +480,8 @@ void ParseVoiceEvent (const String &base, int type, float timeToRepeat)
}
// forwards for MemoryFile
MemoryFile::MF_Loader MemoryFile::Loader = NULL;
MemoryFile::MF_Unloader MemoryFile::Unloader = NULL;
MemoryFile::MF_Loader MemoryFile::Loader = nullptr;
MemoryFile::MF_Unloader MemoryFile::Unloader = nullptr;
void InitConfig (void)
{
@ -605,7 +605,7 @@ void InitConfig (void)
break;
case 3:
if (strstr (line, "@KEY") != NULL)
if (strstr (line, "@KEY") != nullptr)
{
if (!replyKey.keywords.IsEmpty () && !replyKey.replies.IsEmpty ())
{
@ -936,7 +936,7 @@ void GameDLLInit (void)
engine.IssueCmd ("exec addons/yapb/conf/yapb.cfg");
// set correct version string
yb_version.SetString (FormatBuffer ("%d.%d.%d.%u", PRODUCT_VERSION_DWORD_INTERNAL, GenerateBuildNumber ()));
yb_version.SetString (FormatBuffer ("%d.%d.%d", PRODUCT_VERSION_DWORD_INTERNAL, GenerateBuildNumber ()));
// register fake metamod command handler if we not! under mm
if (!(g_gameFlags & GAME_METAMOD))
@ -970,7 +970,7 @@ void Touch (edict_t *pentTouched, edict_t *pentOther)
{
Bot *bot = bots.GetBot (pentOther);
if (bot != NULL)
if (bot != nullptr)
bot->VerifyBreakable (pentTouched);
}
if (g_gameFlags & GAME_METAMOD)
@ -1005,7 +1005,7 @@ int Spawn (edict_t *ent)
g_mapType = 0; // reset map type as worldspawn is the first entity spawned
// detect official csbots here, as they causing crash in linkent code when active for some reason
if (!(g_gameFlags & GAME_LEGACY) && g_engfuncs.pfnCVarGetPointer ("bot_stop") != NULL)
if (!(g_gameFlags & GAME_LEGACY) && g_engfuncs.pfnCVarGetPointer ("bot_stop") != nullptr)
g_gameFlags |= GAME_OFFICIAL_CSBOT;
}
else if (strcmp (entityClassname, "player_weaponstrip") == 0)
@ -1147,7 +1147,7 @@ void ClientDisconnect (edict_t *ent)
Bot *bot = bots.GetBot (i);
// check if its a bot
if (bot != NULL)
if (bot != nullptr)
{
if (bot->pev == &ent->v)
{
@ -1237,14 +1237,14 @@ void ClientCommand (edict_t *ent)
return;
}
else if (stricmp (command, "menuselect") == 0 && !IsNullString (arg1) && g_clients[issuerPlayerIndex].menu != NULL)
else if (stricmp (command, "menuselect") == 0 && !IsNullString (arg1) && g_clients[issuerPlayerIndex].menu != nullptr)
{
Client *client = &g_clients[issuerPlayerIndex];
int selection = atoi (arg1);
if (client->menu == &g_menus[12])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1267,7 +1267,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1277,7 +1277,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[13])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1308,7 +1308,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[9])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1359,7 +1359,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1369,7 +1369,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[10])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1465,7 +1465,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[11])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
g_waypointOn = true; // turn waypoints on in case
@ -1481,7 +1481,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[0])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1504,7 +1504,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
@ -1515,7 +1515,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[2])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1540,7 +1540,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1550,7 +1550,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[1])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1577,13 +1577,13 @@ void ClientCommand (edict_t *ent)
DisplayMenuToClient (ent, &g_menus[18]);
else
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
engine.CenterPrintf ("You're dead, and have no access to this menu");
}
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1593,8 +1593,8 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[18])
{
DisplayMenuToClient (ent, NULL); // reset menu display
Bot *bot = NULL;
DisplayMenuToClient (ent, nullptr); // reset menu display
Bot *bot = nullptr;
switch (selection)
{
@ -1628,7 +1628,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
@ -1639,17 +1639,17 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[19])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
const int autoDistanceValue[] = {0, 100, 130, 160, 190, 220, 250};
const float autoDistanceValue[] = {0.0f, 100.0f, 130.0f, 160.0f, 190.0f, 220.0f, 250.0f };
if (selection >= 1 && selection <= 7)
g_autoPathDistance = autoDistanceValue[selection - 1];
if (g_autoPathDistance == 0)
if (g_autoPathDistance == 0.0f)
engine.CenterPrintf ("AutoPath disabled");
else
engine.CenterPrintf ("AutoPath maximum distance set to %f", g_autoPathDistance);
engine.CenterPrintf ("AutoPath maximum distance set to %.2f", g_autoPathDistance);
if (g_gameFlags & GAME_METAMOD)
RETURN_META (MRES_SUPERCEDE);
@ -1658,7 +1658,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[20])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1675,7 +1675,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
@ -1686,7 +1686,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[5])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
client->menu = &g_menus[4];
@ -1713,7 +1713,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
@ -1727,7 +1727,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[6] && fillCommand)
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1743,7 +1743,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1753,7 +1753,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[4] && fillCommand)
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1764,7 +1764,7 @@ void ClientCommand (edict_t *ent)
bots.FillServer (fillServerTeam, selection - 2, g_storeAddbotVars[0]);
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1774,7 +1774,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[6])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1797,7 +1797,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1807,7 +1807,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[4])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1820,7 +1820,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1830,7 +1830,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[7] || client->menu == &g_menus[8])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1844,7 +1844,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1854,7 +1854,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[3])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1869,7 +1869,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, NULL);
DisplayMenuToClient (ent, nullptr);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1879,7 +1879,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[14])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1909,7 +1909,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[15])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1939,7 +1939,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[16])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1969,7 +1969,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == &g_menus[17])
{
DisplayMenuToClient (ent, NULL); // reset menu display
DisplayMenuToClient (ent, nullptr); // reset menu display
switch (selection)
{
@ -1998,7 +1998,7 @@ void ClientCommand (edict_t *ent)
if (!engine.IsBotCommand () && (stricmp (command, "say") == 0 || stricmp (command, "say_team") == 0))
{
Bot *bot = NULL;
Bot *bot = nullptr;
if (FStrEq (arg1, "dropme") || FStrEq (arg1, "dropc4"))
{
@ -2023,7 +2023,7 @@ void ClientCommand (edict_t *ent)
Bot *target = bots.GetBot (i);
if (target != NULL)
if (target != nullptr)
{
target->m_sayTextBuffer.entityIndex = engine.IndexOfEntity (ent);
@ -2056,7 +2056,7 @@ void ClientCommand (edict_t *ent)
Bot *bot = bots.GetBot (i);
// validate bot
if (bot != NULL && bot->m_team == radioTarget.team && ent != bot->GetEntity () && bot->m_radioOrder == 0)
if (bot != nullptr && bot->m_team == radioTarget.team && ent != bot->GetEntity () && bot->m_radioOrder == 0)
{
bot->m_radioOrder = radioCommand;
bot->m_radioEntity = ent;
@ -2182,7 +2182,7 @@ void StartFrame (void)
else
{
storeClient.flags &= ~(CF_USED | CF_ALIVE);
storeClient.ent = NULL;
storeClient.ent = nullptr;
}
}
@ -2237,14 +2237,14 @@ void StartFrame (void)
static cvar_t *csdm_active;
static cvar_t *mp_freeforall;
if (csdm_active == NULL)
if (csdm_active == nullptr)
csdm_active = CVAR_GET_POINTER ("csdm_active");
if (mp_freeforall == NULL)
if (mp_freeforall == nullptr)
mp_freeforall = CVAR_GET_POINTER ("mp_freeforall");
if (csdm_active != NULL && csdm_active->value > 0)
yb_csdm_mode.SetInt (mp_freeforall != NULL && mp_freeforall->value > 0 ? 2 : 1);
if (csdm_active != nullptr && csdm_active->value > 0)
yb_csdm_mode.SetInt (mp_freeforall != nullptr && mp_freeforall->value > 0 ? 2 : 1);
}
g_timePerSecondUpdate = engine.Time () + 1.0f;
}
@ -2408,26 +2408,26 @@ void pfnMessageBegin (int msgDest, int msgType, const float *origin, edict_t *ed
// store the message type in our own variables, since the GET_USER_MSG_ID () will just do a lot of strcmp()'s...
if ((g_gameFlags & GAME_METAMOD) && engine.FindMessageId (NETMSG_MONEY) == -1)
{
engine.AssignMessageId (NETMSG_VGUI, GET_USER_MSG_ID (PLID, "VGUIMenu", NULL));
engine.AssignMessageId (NETMSG_SHOWMENU, GET_USER_MSG_ID (PLID, "ShowMenu", NULL));
engine.AssignMessageId (NETMSG_WEAPONLIST, GET_USER_MSG_ID (PLID, "WeaponList", NULL));
engine.AssignMessageId (NETMSG_CURWEAPON, GET_USER_MSG_ID (PLID, "CurWeapon", NULL));
engine.AssignMessageId (NETMSG_AMMOX, GET_USER_MSG_ID (PLID, "AmmoX", NULL));
engine.AssignMessageId (NETMSG_AMMOPICKUP, GET_USER_MSG_ID (PLID, "AmmoPickup", NULL));
engine.AssignMessageId (NETMSG_DAMAGE, GET_USER_MSG_ID (PLID, "Damage", NULL));
engine.AssignMessageId (NETMSG_MONEY, GET_USER_MSG_ID (PLID, "Money", NULL));
engine.AssignMessageId (NETMSG_STATUSICON, GET_USER_MSG_ID (PLID, "StatusIcon", NULL));
engine.AssignMessageId (NETMSG_DEATH, GET_USER_MSG_ID (PLID, "DeathMsg", NULL));
engine.AssignMessageId (NETMSG_SCREENFADE, GET_USER_MSG_ID (PLID, "ScreenFade", NULL));
engine.AssignMessageId (NETMSG_HLTV, GET_USER_MSG_ID (PLID, "HLTV", NULL));
engine.AssignMessageId (NETMSG_TEXTMSG, GET_USER_MSG_ID (PLID, "TextMsg", NULL));
engine.AssignMessageId (NETMSG_SCOREINFO, GET_USER_MSG_ID (PLID, "ScoreInfo", NULL));
engine.AssignMessageId (NETMSG_BARTIME, GET_USER_MSG_ID (PLID, "BarTime", NULL));
engine.AssignMessageId (NETMSG_SENDAUDIO, GET_USER_MSG_ID (PLID, "SendAudio", NULL));
engine.AssignMessageId (NETMSG_SAYTEXT, GET_USER_MSG_ID (PLID, "SayText", NULL));
engine.AssignMessageId (NETMSG_VGUI, GET_USER_MSG_ID (PLID, "VGUIMenu", nullptr));
engine.AssignMessageId (NETMSG_SHOWMENU, GET_USER_MSG_ID (PLID, "ShowMenu", nullptr));
engine.AssignMessageId (NETMSG_WEAPONLIST, GET_USER_MSG_ID (PLID, "WeaponList", nullptr));
engine.AssignMessageId (NETMSG_CURWEAPON, GET_USER_MSG_ID (PLID, "CurWeapon", nullptr));
engine.AssignMessageId (NETMSG_AMMOX, GET_USER_MSG_ID (PLID, "AmmoX", nullptr));
engine.AssignMessageId (NETMSG_AMMOPICKUP, GET_USER_MSG_ID (PLID, "AmmoPickup", nullptr));
engine.AssignMessageId (NETMSG_DAMAGE, GET_USER_MSG_ID (PLID, "Damage", nullptr));
engine.AssignMessageId (NETMSG_MONEY, GET_USER_MSG_ID (PLID, "Money", nullptr));
engine.AssignMessageId (NETMSG_STATUSICON, GET_USER_MSG_ID (PLID, "StatusIcon", nullptr));
engine.AssignMessageId (NETMSG_DEATH, GET_USER_MSG_ID (PLID, "DeathMsg", nullptr));
engine.AssignMessageId (NETMSG_SCREENFADE, GET_USER_MSG_ID (PLID, "ScreenFade", nullptr));
engine.AssignMessageId (NETMSG_HLTV, GET_USER_MSG_ID (PLID, "HLTV", nullptr));
engine.AssignMessageId (NETMSG_TEXTMSG, GET_USER_MSG_ID (PLID, "TextMsg", nullptr));
engine.AssignMessageId (NETMSG_SCOREINFO, GET_USER_MSG_ID (PLID, "ScoreInfo", nullptr));
engine.AssignMessageId (NETMSG_BARTIME, GET_USER_MSG_ID (PLID, "BarTime", nullptr));
engine.AssignMessageId (NETMSG_SENDAUDIO, GET_USER_MSG_ID (PLID, "SendAudio", nullptr));
engine.AssignMessageId (NETMSG_SAYTEXT, GET_USER_MSG_ID (PLID, "SayText", nullptr));
if (!(g_gameFlags & GAME_LEGACY))
engine.AssignMessageId (NETMSG_BOTVOICE, GET_USER_MSG_ID (PLID, "BotVoice", NULL));
engine.AssignMessageId (NETMSG_BOTVOICE, GET_USER_MSG_ID (PLID, "BotVoice", nullptr));
}
engine.ResetMessageCapture ();
@ -2471,7 +2471,7 @@ void pfnMessageBegin (int msgDest, int msgType, const float *origin, edict_t *ed
{
Bot *bot = bots.GetBot (i);
if (bot != NULL)
if (bot != nullptr)
bot->m_notKilled = false;
}
}
@ -2635,7 +2635,7 @@ const char *pfnCmd_Args (void)
}
if (g_gameFlags & GAME_METAMOD)
RETURN_META_VALUE (MRES_IGNORED, NULL);
RETURN_META_VALUE (MRES_IGNORED, nullptr);
return CMD_ARGS (); // ask the client command string to the engine
}
@ -2658,7 +2658,7 @@ const char *pfnCmd_Argv (int argc)
return engine.GetOverrideArgv (argc); // if so, then return the wanted argument we know
}
if (g_gameFlags & GAME_METAMOD)
RETURN_META_VALUE (MRES_IGNORED, NULL);
RETURN_META_VALUE (MRES_IGNORED, nullptr);
return CMD_ARGV (argc); // ask the argument number "argc" to the engine
}
@ -2690,7 +2690,7 @@ void pfnSetClientMaxspeed (const edict_t *ent, float newMaxspeed)
Bot *bot = bots.GetBot (const_cast <edict_t *> (ent));
// check wether it's not a bot
if (bot != NULL)
if (bot != nullptr)
bot->pev->maxspeed = newMaxspeed;
if (g_gameFlags & GAME_METAMOD)
@ -2765,14 +2765,14 @@ void pfnAlertMessage (ALERT_TYPE alertType, char *format, ...)
vsnprintf (buffer, SIZEOF_CHAR (buffer), format, ap);
va_end (ap);
if ((g_mapType & MAP_DE) && g_bombPlanted && strstr (buffer, "_Defuse_") != NULL)
if ((g_mapType & MAP_DE) && g_bombPlanted && strstr (buffer, "_Defuse_") != nullptr)
{
// notify all terrorists that CT is starting bomb defusing
for (int i = 0; i < engine.MaxClients (); i++)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && bot->m_team == TERRORIST && bot->m_notKilled)
if (bot != nullptr && bot->m_team == TERRORIST && bot->m_notKilled)
{
bot->DeleteSearchNodes ();
@ -2867,7 +2867,7 @@ SHARED_LIBRARAY_EXPORT int GetNewDLLFunctions (newgamefuncs_t *functionTable, in
auto api_GetNewDLLFunctions = g_gameLib->GetFuncAddr <NewEntityAPI_t> ("GetNewDLLFunctions");
if (api_GetNewDLLFunctions == NULL)
if (api_GetNewDLLFunctions == nullptr)
return FALSE;
if (!api_GetNewDLLFunctions (functionTable, interfaceVersion))
@ -2927,7 +2927,7 @@ SHARED_LIBRARAY_EXPORT int Server_GetBlendingInterface (int version, void **ppin
auto api_GetBlendingInterface = g_gameLib->GetFuncAddr <BlendAPI_t> ("Server_GetBlendingInterface");
if (api_GetBlendingInterface == NULL)
if (api_GetBlendingInterface == nullptr)
return FALSE;
return api_GetBlendingInterface (version, ppinterface, pstudio, rotationmatrix, bonetransform);
@ -2951,9 +2951,23 @@ SHARED_LIBRARAY_EXPORT int Meta_Attach (PLUG_LOADTIME, metamod_funcs_t *function
// where we can tell if the plugin will be allowed to run or not, we wait until here to make
// our initialization stuff, like registering CVARs and dedicated server commands.
// metamod engine & dllapi function tables
static metamod_funcs_t metamodFunctionTable =
{
nullptr, // pfnGetEntityAPI ()
nullptr, // pfnGetEntityAPI_Post ()
GetEntityAPI2, // pfnGetEntityAPI2 ()
GetEntityAPI2_Post, // pfnGetEntityAPI2_Post ()
nullptr, // pfnGetNewDLLFunctions ()
nullptr, // pfnGetNewDLLFunctions_Post ()
GetEngineFunctions, // pfnGetEngineFunctions ()
GetEngineFunctions_Post, // pfnGetEngineFunctions_Post ()
};
// keep track of the pointers to engine function tables metamod gives us
gpMetaGlobals = pMGlobals;
memcpy (functionTable, &gMetaFunctionTable, sizeof (metamod_funcs_t));
memcpy (functionTable, &metamodFunctionTable, sizeof (metamod_funcs_t));
gpGamedllFuncs = pGamedllFuncs;
return TRUE; // returning true enables metamod to attach this plugin
@ -2983,7 +2997,7 @@ Library *LoadCSBinary (void)
const char *modname = engine.GetModName ();
if (!modname)
return NULL;
return nullptr;
#if defined (PLATFORM_WIN32)
const char *libs[] = { "mp.dll", "cs.dll" };
@ -3009,7 +3023,7 @@ Library *LoadCSBinary (void)
g_gameFlags |= GAME_CZERO;
if (g_gameFlags & GAME_METAMOD)
return NULL;
return nullptr;
return new Library (path);
}
@ -3021,18 +3035,18 @@ Library *LoadCSBinary (void)
if (!game->IsLoaded ())
{
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Unable to load gamedll \"%s\". Exiting... (gamedir: %s)", libs[i], modname);
return NULL;
return nullptr;
}
// detect xash engine
if (g_engfuncs.pfnCVarGetPointer ("build") != NULL)
if (g_engfuncs.pfnCVarGetPointer ("build") != nullptr)
{
g_gameFlags |= (GAME_LEGACY | GAME_XASH);
if (g_gameFlags & GAME_METAMOD)
{
delete game;
return NULL;
return nullptr;
}
return game;
}
@ -3040,7 +3054,7 @@ Library *LoadCSBinary (void)
// detect if we're running modern game
EntityPtr_t entity = game->GetFuncAddr <EntityPtr_t> ("weapon_famas");
if (entity != NULL)
if (entity != nullptr)
g_gameFlags |= GAME_CSTRIKE16;
else
g_gameFlags |= GAME_LEGACY;
@ -3048,12 +3062,12 @@ Library *LoadCSBinary (void)
if (g_gameFlags & GAME_METAMOD)
{
delete game;
return NULL;
return nullptr;
}
return game;
}
}
return NULL;
return nullptr;
}
DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t *pGlobals)
@ -3107,7 +3121,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
#else
g_gameLib = LoadCSBinary ();
{
if (g_gameLib == NULL && !(g_gameFlags & GAME_METAMOD))
if (g_gameLib == nullptr && !(g_gameFlags & GAME_METAMOD))
{
AddLogEntry (true, LL_FATAL | LL_IGNORE, "Mod that you has started, not supported by this bot (gamedir: %s)", engine.GetModName ());
return;
@ -3146,7 +3160,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
if (!api_GiveFnptrsToDll)
TerminateOnMalloc ();
GetEngineFunctions (functionTable, NULL);
GetEngineFunctions (functionTable, nullptr);
// give the engine functions to the other DLL...
api_GiveFnptrsToDll (functionTable, pGlobals);
@ -3169,10 +3183,10 @@ DLL_ENTRYPOINT
void LinkEntity_Helper (EntityPtr_t &addr, const char *name, entvars_t *pev)
{
if (addr == NULL)
if (addr == nullptr)
addr = g_gameLib->GetFuncAddr <EntityPtr_t > (name);
if (addr == NULL)
if (addr == nullptr)
return;
addr (pev);

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -41,7 +41,7 @@ BotManager::BotManager (void)
m_grenadeUpdateTime = 0.0f;
m_creationTab.RemoveAll ();
m_killerEntity = NULL;
m_killerEntity = nullptr;
m_balanceCount = 0;
}
@ -113,7 +113,7 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
// this function completely prepares bot entity (edict) for creation, creates team, difficulty, sets name etc, and
// then sends result to bot constructor
edict_t *bot = NULL;
edict_t *bot = nullptr;
char outputName[33];
if (g_numWaypoints < 1) // don't allow creating bots with no waypoints loaded
@ -132,17 +132,17 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
if (difficulty < 0 || difficulty > 4)
{
difficulty = Random.Long (3, 4);
difficulty = Random.Int (3, 4);
yb_difficulty.SetInt (difficulty);
}
if (personality < 0 || personality > 2)
{
if (Random.Long (0, 100) < 50)
if (Random.Int (0, 100) < 50)
personality = PERSONALITY_NORMAL;
else
{
if (Random.Long (0, 100) < 65)
if (Random.Int (0, 100) < 65)
personality = PERSONALITY_RUSHER;
else
personality = PERSONALITY_CAREFUL;
@ -165,7 +165,7 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
BotName *pickedName = &g_botNames.GetRandomElement ();
if (pickedName == NULL)
if (pickedName == nullptr)
continue;
if (pickedName->used)
@ -178,7 +178,7 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
}
}
else
sprintf (outputName, "bot%i", Random.Long (0, 100)); // just pick ugly random name
sprintf (outputName, "bot%i", Random.Int (0, 100)); // just pick ugly random name
}
else
strncpy (outputName, name, 21);
@ -204,11 +204,11 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
int index = engine.IndexOfEntity (bot) - 1;
InternalAssert (index >= 0 && index <= MAX_ENGINE_PLAYERS); // check index
InternalAssert (m_bots[index] == NULL); // check bot slot
InternalAssert (m_bots[index] == nullptr); // check bot slot
m_bots[index] = new Bot (bot, difficulty, personality, team, member, steamId);
if (m_bots[index] == NULL)
if (m_bots[index] == nullptr)
TerminateOnMalloc ();
engine.Printf ("Connecting Bot...");
@ -230,7 +230,7 @@ int BotManager::GetIndex (edict_t *ent)
if (index < 0 || index >= MAX_ENGINE_PLAYERS)
return -1;
if (m_bots[index] != NULL)
if (m_bots[index] != nullptr)
return index;
return -1; // if no edict, return -1;
@ -241,12 +241,12 @@ 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 >= MAX_ENGINE_PLAYERS)
return NULL;
return nullptr;
if (m_bots[index] != NULL)
if (m_bots[index] != nullptr)
return m_bots[index];
return NULL; // no bot
return nullptr; // no bot
}
Bot *BotManager::GetBot (edict_t *ent)
@ -267,14 +267,14 @@ Bot *BotManager::FindOneValidAliveBot (void)
if (result.GetSize () > 4)
break;
if (m_bots[i] != NULL && IsAlive (m_bots[i]->GetEntity ()))
if (m_bots[i] != nullptr && IsAlive (m_bots[i]->GetEntity ()))
result.Push (i);
}
if (!result.IsEmpty ())
return m_bots[result.GetRandomElement ()];
return NULL;
return nullptr;
}
void BotManager::Think (void)
@ -283,7 +283,7 @@ void BotManager::Think (void)
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL)
if (m_bots[i] != nullptr)
m_bots[i]->Think ();
}
}
@ -294,7 +294,7 @@ void BotManager::PeriodicThink (void)
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL)
if (m_bots[i] != nullptr)
m_bots[i]->PeriodicThink ();
}
}
@ -338,7 +338,7 @@ void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent)
{
// this function increases or decreases bot quota amount depending on auto vacate variables
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent) != NULL)
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent) != nullptr)
return;
if (isPlayerConnection)
@ -454,11 +454,11 @@ void BotManager::MaintainBotQuota (void)
char mode = yb_quota_mode.GetString ()[0];
if (mode == 'f') // fill
desiredCount = max (0, desiredCount - numHumans);
desiredCount = A_max (0, desiredCount - numHumans);
else if (mode == 'm') // match
desiredCount = max (0, yb_quota.GetInt () * numHumans);
desiredCount = A_max (0, yb_quota.GetInt () * numHumans);
desiredCount = min (desiredCount, engine.MaxClients () - (numHumans + (yb_autovacate.GetBool () ? 1 : 0)));
desiredCount = A_min (desiredCount, engine.MaxClients () - (numHumans + (yb_autovacate.GetBool () ? 1 : 0)));
if (yb_autovacate_smart_kick.GetBool () && numBots > 1 && desiredCount > 1)
VerifyPlayersHasJoinedTeam (desiredCount);
@ -532,7 +532,7 @@ void BotManager::RemoveFromTeam (Team team, bool removeAll)
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL && team == engine.GetTeam (m_bots[i]->GetEntity ()))
if (m_bots[i] != nullptr && team == engine.GetTeam (m_bots[i]->GetEntity ()))
{
m_bots[i]->Kick ();
@ -559,7 +559,7 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
for (int i = ((selection - 1) * 8); i < selection * 8; i++)
{
if ((m_bots[i] != NULL) && !engine.IsNullEntity (m_bots[i]->GetEntity ()))
if (m_bots[i] != nullptr && !engine.IsNullEntity (m_bots[i]->GetEntity ()))
{
validSlots |= 1 << (i - ((selection - 1) * 8));
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), engine.GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
@ -608,7 +608,7 @@ void BotManager::KillAll (int team)
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL)
if (m_bots[i] != nullptr)
{
if (team != -1 && team != m_bots[i]->m_team)
continue;
@ -628,7 +628,7 @@ void BotManager::RemoveRandom (bool keepQuota)
// first try to kick the bot that is currently dead
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL && !m_bots[i]->m_notKilled) // is this slot used?
if (m_bots[i] != nullptr && !m_bots[i]->m_notKilled) // is this slot used?
{
m_bots[i]->Kick (keepQuota);
deadBotFound = true;
@ -649,7 +649,7 @@ void BotManager::RemoveRandom (bool keepQuota)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && bot->pev->frags < score)
if (bot != nullptr && bot->pev->frags < score)
{
index = i;
score = bot->pev->frags;
@ -666,7 +666,7 @@ void BotManager::RemoveRandom (bool keepQuota)
// worst case, just kick some random bot
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL) // is this slot used?
if (m_bots[i] != nullptr) // is this slot used?
{
m_bots[i]->Kick (keepQuota);
break;
@ -737,7 +737,7 @@ void BotManager::ListBots (void)
Bot *bot = GetBot (i);
// is this player slot valid
if (bot != NULL)
if (bot != nullptr)
engine.Printf ("[%-3.1d] %-9.13s %-17.18s %-3.4s %-3.1d %-3.1d", i, STRING (bot->pev->netname), bot->m_personality == PERSONALITY_RUSHER ? "rusher" : bot->m_personality == PERSONALITY_NORMAL ? "normal" : "careful", bot->m_team == CT ? "CT" : "T", bot->m_difficulty, static_cast <int> (bot->pev->frags));
}
}
@ -750,7 +750,7 @@ int BotManager::GetBotsNum (void)
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL)
if (m_bots[i] != nullptr)
count++;
}
return count;
@ -766,7 +766,7 @@ Bot *BotManager::GetHighestFragsBot (int team)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && bot->m_notKilled && bot->m_team == team)
if (bot != nullptr && bot->m_notKilled && bot->m_team == team)
{
if (bot->pev->frags > bestScore)
{
@ -798,7 +798,7 @@ void BotManager::CheckTeamEconomics (int team, bool setTrue)
// start calculating
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL && engine.GetTeam (m_bots[i]->GetEntity ()) == team)
if (m_bots[i] != nullptr && engine.GetTeam (m_bots[i]->GetEntity ()) == team)
{
if (m_bots[i]->m_moneyAmount <= g_botBuyEconomyTable[0])
numPoorPlayers++;
@ -833,7 +833,7 @@ void BotManager::Free (int index)
// this function frees one bot selected by index (used on bot disconnect)
delete m_bots[index];
m_bots[index] = NULL;
m_bots[index] = nullptr;
}
Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, const String &steamId)
@ -848,10 +848,10 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
pev = &bot->v;
if (bot->pvPrivateData != NULL)
if (bot->pvPrivateData != nullptr)
FREE_PRIVATE (bot);
bot->pvPrivateData = NULL;
bot->pvPrivateData = nullptr;
bot->v.frags = 0;
// create the player entity by calling MOD's player function
@ -892,11 +892,11 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
m_startAction = GSM_IDLE;
m_moneyAmount = 0;
m_logotypeIndex = Random.Long (0, 9);
m_logotypeIndex = Random.Int (0, 9);
// assign how talkative this bot will be
m_sayTextBuffer.chatDelay = Random.Float (3.8f, 10.0f);
m_sayTextBuffer.chatProbability = Random.Long (1, 100);
m_sayTextBuffer.chatProbability = Random.Int (1, 100);
m_notKilled = false;
m_weaponBurstMode = BM_OFF;
@ -904,7 +904,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
if (difficulty < 0 || difficulty > 4)
{
difficulty = Random.Long (3, 4);
difficulty = Random.Int (3, 4);
yb_difficulty.SetInt (difficulty);
}
@ -937,7 +937,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
memset (&m_ammo, 0, sizeof (m_ammo));
m_currentWeapon = 0; // current weapon is not assigned at start
m_voicePitch = Random.Long (80, 115); // assign voice pitch
m_voicePitch = Random.Int (80, 115); // assign voice pitch
// copy them over to the temp level variables
m_agressionLevel = m_baseAgressionLevel;
@ -987,7 +987,7 @@ int BotManager::GetHumansNum (void)
{
const Client &client = g_clients[i];
if ((client.flags & CF_USED) && m_bots[i] == NULL && !(client.ent->v.flags & FL_FAKECLIENT))
if ((client.flags & CF_USED) && m_bots[i] == nullptr && !(client.ent->v.flags & FL_FAKECLIENT))
count++;
}
return count;
@ -1003,7 +1003,7 @@ int BotManager::GetHumansAliveNum (void)
{
const Client &client = g_clients[i];
if ((client.flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL && !(client.ent->v.flags & FL_FAKECLIENT))
if ((client.flags & (CF_USED | CF_ALIVE)) && m_bots[i] == nullptr && !(client.ent->v.flags & FL_FAKECLIENT))
count++;
}
return count;
@ -1019,7 +1019,7 @@ int BotManager::GetHumansJoinedTeam (void)
{
const Client &client = g_clients[i];
if ((client.flags & (CF_USED | CF_ALIVE)) && m_bots[i] == NULL && client.team != SPECTATOR && !(client.ent->v.flags & FL_FAKECLIENT) && client.ent->v.movetype != MOVETYPE_FLY)
if ((client.flags & (CF_USED | CF_ALIVE)) && m_bots[i] == nullptr && client.team != SPECTATOR && !(client.ent->v.flags & FL_FAKECLIENT) && client.ent->v.movetype != MOVETYPE_FLY)
count++;
}
return count;
@ -1037,7 +1037,7 @@ void Bot::NewRound (void)
m_waypointOrigin.Zero ();
m_destOrigin.Zero ();
m_currentWaypointIndex = -1;
m_currentPath = NULL;
m_currentPath = nullptr;
m_currentTravelFlags = 0;
m_goalFailed = 0;
m_desiredVelocity.Zero ();
@ -1061,7 +1061,7 @@ void Bot::NewRound (void)
switch (m_personality)
{
case PERSONALITY_NORMAL:
m_pathType = Random.Long (0, 100) > 50 ? SEARCH_PATH_SAFEST_FASTER : SEARCH_PATH_SAFEST;
m_pathType = Random.Int (0, 100) > 50 ? SEARCH_PATH_SAFEST_FASTER : SEARCH_PATH_SAFEST;
break;
case PERSONALITY_RUSHER:
@ -1097,23 +1097,23 @@ void Bot::NewRound (void)
m_viewDistance = 4096.0f;
m_maxViewDistance = 4096.0f;
m_liftEntity = NULL;
m_pickupItem = NULL;
m_itemIgnore = NULL;
m_liftEntity = nullptr;
m_pickupItem = nullptr;
m_itemIgnore = nullptr;
m_itemCheckTime = 0.0f;
m_breakableEntity = NULL;
m_breakableEntity = nullptr;
m_breakableOrigin.Zero ();
m_timeDoorOpen = 0.0f;
ResetCollideState ();
ResetDoubleJumpState ();
m_enemy = NULL;
m_lastVictim = NULL;
m_lastEnemy = NULL;
m_enemy = nullptr;
m_lastVictim = nullptr;
m_lastEnemy = nullptr;
m_lastEnemyOrigin.Zero ();
m_trackingEdict = NULL;
m_trackingEdict = nullptr;
m_timeNextTracking = 0.0f;
m_buttonPushTime = 0.0f;
@ -1124,7 +1124,7 @@ void Bot::NewRound (void)
m_oldCombatDesire = 0.0f;
m_liftUsageTime = 0.0f;
m_avoidGrenade = NULL;
m_avoidGrenade = nullptr;
m_needAvoidGrenade = 0;
m_lastDamageType = -1;
@ -1140,12 +1140,12 @@ void Bot::NewRound (void)
SetIdealReactionTimes (true);
m_targetEntity = NULL;
m_targetEntity = nullptr;
m_tasks.RemoveAll ();
m_followWaitTime = 0.0f;
for (i = 0; i < MAX_HOSTAGES; i++)
m_hostages[i] = NULL;
m_hostages[i] = nullptr;
for (i = 0; i < Chatter_Total; i++)
m_chatterTimes[i] = -1.0f;
@ -1202,7 +1202,7 @@ void Bot::NewRound (void)
m_checkKnifeSwitch = true;
m_buyingFinished = false;
m_radioEntity = NULL;
m_radioEntity = nullptr;
m_radioOrder = 0;
m_defendedBomb = false;
m_defendHostage = false;
@ -1231,7 +1231,7 @@ void Bot::NewRound (void)
PushMessageQueue (GSM_BUY_STUFF);
PushTask (TASK_NORMAL, TASKPRI_NORMAL, -1, 0.0f, true);
if (Random.Long (0, 100) < 50)
if (Random.Int (0, 100) < 50)
ChatterMessage (Chatter_NewRound);
m_thinkInterval = (g_gameFlags & GAME_LEGACY) ? 0.0f : (1.0f / 30.0f) * Random.Float (0.95f, 1.05f);
@ -1262,13 +1262,13 @@ void Bot::StartGame (void)
// this function handles the selection of teams & class
#ifdef XASH_CSDM
m_wantedTeam = Random.Long (1, 2);
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.Long (0, 100) < 20)
if (Random.Int (0, 100) < 20)
ChatMessage (CHAT_WELCOME);
m_notStarted = false;
@ -1300,12 +1300,12 @@ void Bot::StartGame (void)
if (g_gameFlags & GAME_CZERO) // czero has spetsnaz and militia skins
{
if (m_wantedClass < 1 || m_wantedClass > 5)
m_wantedClass = Random.Long (1, 5); // use random if invalid
m_wantedClass = Random.Int (1, 5); // use random if invalid
}
else
{
if (m_wantedClass < 1 || m_wantedClass > 4)
m_wantedClass = Random.Long (1, 4); // use random if invalid
m_wantedClass = Random.Int (1, 4); // use random if invalid
}
// select the class the bot wishes to use...
@ -1315,7 +1315,7 @@ void Bot::StartGame (void)
m_notStarted = false;
// check for greeting other players, since we connected
if (Random.Long (0, 100) < 20)
if (Random.Int (0, 100) < 20)
ChatMessage (CHAT_WELCOME);
}
}
@ -1341,7 +1341,7 @@ void BotManager::CalculatePingOffsets (void)
PLAYER_CNX_STATS (ent, &ping, &loss);
if (ping < 0 || ping > 100)
ping = Random.Long (3, 15);
ping = Random.Int (3, 15);
averagePing += ping;
}
@ -1349,21 +1349,22 @@ void BotManager::CalculatePingOffsets (void)
if (numHumans > 0)
averagePing /= numHumans;
else
averagePing = Random.Long (30, 40);
averagePing = Random.Int (30, 40);
for (int i = 0; i < engine.MaxClients (); i++)
{
Bot *bot = GetBot (i);
if (bot == NULL)
if (bot == nullptr)
continue;
int botPing = Random.Long (averagePing - averagePing * 0.2f, averagePing + averagePing * 0.2f) + Random.Long (bot->m_difficulty + 3, bot->m_difficulty + 6) + 10;
int part = static_cast <int> (averagePing * 0.2f);
int botPing = Random.Int (averagePing - part, averagePing + part) + Random.Int (bot->m_difficulty + 3, bot->m_difficulty + 6) + 10;
if (botPing <= 5)
botPing = Random.Long (10, 23);
botPing = Random.Int (10, 23);
else if (botPing > 100)
botPing = Random.Long (30, 40);
botPing = Random.Int (30, 40);
for (int j = 0; j < 2; j++)
{
@ -1398,7 +1399,7 @@ void BotManager::SendPingDataOffsets (edict_t *to)
{
Bot *bot = m_bots[i];
if (bot == NULL)
if (bot == nullptr)
continue;
switch (sending)
@ -1406,7 +1407,7 @@ void BotManager::SendPingDataOffsets (edict_t *to)
case 0:
{
// start a new message
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_PINGS, NULL, to);
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_PINGS, nullptr, to);
WRITE_BYTE ((bot->m_pingOffset[sending] * 64) + (1 + 2 * i));
WRITE_SHORT (bot->m_ping[sending]);
@ -1457,7 +1458,7 @@ void BotManager::UpdateActiveGrenades (void)
if (m_grenadeUpdateTime > engine.Time ())
return;
edict_t *grenade = NULL;
edict_t *grenade = nullptr;
// clear previously stored grenades
m_activeGrenades.RemoveAll ();
@ -1495,12 +1496,12 @@ void BotManager::SelectLeaderEachTeam (int team, bool reset)
{
auto bot = m_bots[i];
if (bot != NULL && bot->m_isVIP)
if (bot != nullptr && bot->m_isVIP)
{
// vip bot is the leader
bot->m_isLeader = true;
if (Random.Long (1, 100) < 50)
if (Random.Int (1, 100) < 50)
{
bot->RadioMessage (Radio_FollowMe);
bot->m_campButtons = 0;
@ -1513,11 +1514,11 @@ void BotManager::SelectLeaderEachTeam (int team, bool reset)
{
auto bot = bots.GetHighestFragsBot (team);
if (bot != NULL && bot->m_notKilled)
if (bot != nullptr && bot->m_notKilled)
{
bot->m_isLeader = true;
if (Random.Long (1, 100) < 45)
if (Random.Int (1, 100) < 45)
bot->RadioMessage (Radio_FollowMe);
}
m_leaderChoosen[TERRORIST] = true;
@ -1531,13 +1532,13 @@ void BotManager::SelectLeaderEachTeam (int team, bool reset)
{
auto bot = m_bots[i];
if (bot != NULL && bot->m_hasC4)
if (bot != nullptr && bot->m_hasC4)
{
// bot carrying the bomb is the leader
bot->m_isLeader = true;
// terrorist carrying a bomb needs to have some company
if (Random.Long (1, 100) < 80)
if (Random.Int (1, 100) < 80)
{
if (yb_communication_type.GetInt () == 2)
bot->ChatterMessage (Chatter_GoingToPlantBomb);
@ -1556,7 +1557,7 @@ void BotManager::SelectLeaderEachTeam (int team, bool reset)
{
bot->m_isLeader = true;
if (Random.Long (1, 100) < 30)
if (Random.Int (1, 100) < 30)
bot->RadioMessage (Radio_FollowMe);
}
m_leaderChoosen[CT] = true;
@ -1568,7 +1569,7 @@ void BotManager::SelectLeaderEachTeam (int team, bool reset)
{
bot->m_isLeader = true;
if (Random.Long (1, 100) < 30)
if (Random.Int (1, 100) < 30)
bot->RadioMessage (Radio_FollowMe);
}
}
@ -1578,7 +1579,7 @@ void BotManager::SelectLeaderEachTeam (int team, bool reset)
{
bot->m_isLeader = true;
if (Random.Long (1, 100) < (team == TERRORIST ? 30 : 40))
if (Random.Int (1, 100) < (team == TERRORIST ? 30 : 40))
bot->RadioMessage (Radio_FollowMe);
}
}

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -16,7 +16,7 @@ int Bot::FindGoal (void)
// chooses a destination (goal) waypoint for a bot
if (!g_bombPlanted && m_team == TERRORIST && (g_mapType & MAP_DE))
{
edict_t *pent = NULL;
edict_t *pent = nullptr;
while (!engine.IsNullEntity (pent = FIND_ENTITY_BY_STRING (pent, "classname", "weaponbox")))
{
@ -47,8 +47,8 @@ int Bot::FindGoal (void)
float backoffDesire = 0.0f;
float tacticChoice = 0.0f;
Array <int> *offensiveWpts = NULL;
Array <int> *defensiveWpts = NULL;
Array <int> *offensiveWpts = nullptr;
Array <int> *defensiveWpts = nullptr;
switch (m_team)
{
@ -217,7 +217,7 @@ int Bot::FinishFindGoal (int tactic, Array <int> *defensive, Array <int> *offsen
m_currentWaypointIndex = ChangeWptIndex (waypoints.FindNearest (pev->origin));
if (goalChoices[0] == -1)
return m_chosenGoalIndex = Random.Long (0, g_numWaypoints - 1);
return m_chosenGoalIndex = Random.Int (0, g_numWaypoints - 1);
bool isSorting = false;
@ -278,13 +278,13 @@ bool Bot::GoalIsValid (void)
return false;
else if (goal == m_currentWaypointIndex) // no nodes needed
return true;
else if (m_navNode == NULL) // no path calculated
else if (m_navNode == nullptr) // no path calculated
return false;
// got path - check if still valid
PathNode *node = m_navNode;
while (node->next != NULL)
while (node->next != nullptr)
node = node->next;
if (node->index == goal)
@ -320,7 +320,7 @@ void Bot::CheckCloseAvoidance (const Vector &dirNormal)
if (m_seeEnemyTime + 1.5f < engine.Time ())
return;
edict_t *nearest = NULL;
edict_t *nearest = nullptr;
float nearestDist = 99999.0f;
int playerCount = 0;
@ -438,7 +438,7 @@ 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 + 1];
int state[MAX_COLLIDE_MOVES * 2 + 1];
int i = 0;
// first 4 entries hold the possible collision states
@ -733,7 +733,7 @@ bool Bot::DoWaypointNav (void)
if (m_liftState == LIFT_NO_NEARBY)
{
m_liftState = LIFT_LOOKING_BUTTON_OUTSIDE;
m_liftUsageTime = engine.Time () + 7.0;
m_liftUsageTime = engine.Time () + 7.0f;
}
liftClosedDoorExists = true;
}
@ -742,7 +742,7 @@ bool Bot::DoWaypointNav (void)
engine.TestLine (m_currentPath->origin, m_currentPath->origin + Vector (0.0f, 0.0f, -50.0f), TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
// if trace result shows us that it is a lift
if (!engine.IsNullEntity (tr.pHit) && m_navNode != NULL && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists)
if (!engine.IsNullEntity (tr.pHit) && m_navNode != nullptr && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists)
{
if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && tr.pHit->v.velocity.z == 0.0f)
{
@ -760,9 +760,9 @@ bool Bot::DoWaypointNav (void)
m_liftUsageTime = engine.Time () + 7.0f;
}
}
else if (m_navNode != NULL) // no lift found at waypoint
else if (m_navNode != nullptr) // no lift found at waypoint
{
if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR) && m_navNode->next != NULL)
if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR) && m_navNode->next != nullptr)
{
if (m_navNode->next->index >= 0 && m_navNode->next->index < g_numWaypoints && (waypoints.GetPath (m_navNode->next->index)->flags & FLAG_LIFT))
{
@ -800,7 +800,7 @@ bool Bot::DoWaypointNav (void)
{
Bot *bot = bots.GetBot (i);
if (bot == NULL || bot == this)
if (bot == nullptr || bot == this)
continue;
if (!bot->m_notKilled || bot->m_team != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER)
@ -839,7 +839,7 @@ bool Bot::DoWaypointNav (void)
{
Bot *bot = bots.GetBot (i);
if (bot == NULL)
if (bot == nullptr)
continue; // skip invalid bots
if (!bot->m_notKilled || bot->m_team != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER || bot->m_liftEntity != m_liftEntity)
@ -873,7 +873,7 @@ bool Bot::DoWaypointNav (void)
if (!needWaitForTeammate || m_liftUsageTime < engine.Time ())
{
m_liftState = LIFT_LOOKING_BUTTON_INSIDE;
m_liftUsageTime = engine.Time () + 10.0;
m_liftUsageTime = engine.Time () + 10.0f;
}
}
@ -1042,7 +1042,7 @@ bool Bot::DoWaypointNav (void)
if ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) && (m_currentPath->origin.z - pev->origin.z) > 50.0f && (waypoints.GetPath (m_prevWptIndex[0])->origin.z - pev->origin.z) > 50.0f)
{
m_liftState = LIFT_NO_NEARBY;
m_liftEntity = NULL;
m_liftEntity = nullptr;
m_liftUsageTime = 0.0f;
DeleteSearchNodes ();
@ -1069,13 +1069,13 @@ bool Bot::DoWaypointNav (void)
m_liftState = LIFT_NO_NEARBY;
m_liftUsageTime = 0.0f;
m_liftEntity = NULL;
m_liftEntity = nullptr;
}
}
if (m_liftUsageTime < engine.Time () && m_liftUsageTime != 0.0f)
{
m_liftEntity = NULL;
m_liftEntity = nullptr;
m_liftState = LIFT_NO_NEARBY;
m_liftUsageTime = 0.0f;
@ -1104,7 +1104,7 @@ bool Bot::DoWaypointNav (void)
{
IgnoreCollisionShortly (); // don't consider being stuck
if (Random.Long (1, 100) < 50)
if (Random.Int (1, 100) < 50)
MDLL_Use (tr.pHit, GetEntity ()); // also 'use' the door randomly
}
@ -1130,7 +1130,7 @@ bool Bot::DoWaypointNav (void)
m_doorOpenAttempt++;
m_timeDoorOpen = engine.Time () + 1.0f; // retry in 1 sec until door is open
edict_t *ent = NULL;
edict_t *ent = nullptr;
if (m_doorOpenAttempt > 2 && !engine.IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, 512.0f)))
{
@ -1193,15 +1193,16 @@ bool Bot::DoWaypointNav (void)
// add goal values
if (m_chosenGoalIndex != -1)
{
int waypointValue;
int16 waypointValue;
int startIndex = m_chosenGoalIndex;
int goalIndex = m_currentWaypointIndex;
if (m_team == TERRORIST)
{
waypointValue = (g_experienceData + (startIndex * g_numWaypoints) + goalIndex)->team0Value;
waypointValue += static_cast <int> (pev->health * 0.5f);
waypointValue += static_cast <int> (m_goalValue * 0.5f);
waypointValue += static_cast <int16> (pev->health * 0.5f);
waypointValue += static_cast <int16> (m_goalValue * 0.5f);
if (waypointValue < -MAX_GOAL_VALUE)
waypointValue = -MAX_GOAL_VALUE;
@ -1213,8 +1214,8 @@ bool Bot::DoWaypointNav (void)
else
{
waypointValue = (g_experienceData + (startIndex * g_numWaypoints) + goalIndex)->team1Value;
waypointValue += static_cast <int> (pev->health * 0.5f);
waypointValue += static_cast <int> (m_goalValue * 0.5f);
waypointValue += static_cast <int16> (pev->health * 0.5f);
waypointValue += static_cast <int16> (m_goalValue * 0.5f);
if (waypointValue < -MAX_GOAL_VALUE)
waypointValue = -MAX_GOAL_VALUE;
@ -1226,7 +1227,7 @@ bool Bot::DoWaypointNav (void)
}
return true;
}
else if (m_navNode == NULL)
else if (m_navNode == nullptr)
return false;
int taskTarget = GetTask ()->data;
@ -1242,7 +1243,7 @@ bool Bot::DoWaypointNav (void)
if (distance > 512.0)
{
if (Random.Long (0, 100) < 50 && !waypoints.IsGoalVisited (taskTarget))
if (Random.Int (0, 100) < 50 && !waypoints.IsGoalVisited (taskTarget))
RadioMessage (Radio_SectorClear);
waypoints.SetGoalVisited (taskTarget); // doesn't hear so not a good goal
@ -1250,7 +1251,7 @@ bool Bot::DoWaypointNav (void)
}
else
{
if (Random.Long (0, 100) < 50 && !waypoints.IsGoalVisited (taskTarget))
if (Random.Int (0, 100) < 50 && !waypoints.IsGoalVisited (taskTarget))
RadioMessage (Radio_SectorClear);
waypoints.SetGoalVisited (taskTarget); // doesn't hear so not a good goal
@ -1286,7 +1287,7 @@ void Bot::FindShortestPath (int srcIndex, int destIndex)
PathNode *node = new PathNode;
node->index = srcIndex;
node->next = NULL;
node->next = nullptr;
m_navNodeStart = node;
m_navNode = m_navNodeStart;
@ -1306,11 +1307,11 @@ void Bot::FindShortestPath (int srcIndex, int destIndex)
node->next = new PathNode;
node = node->next;
if (node == NULL)
if (node == nullptr)
TerminateOnMalloc ();
node->index = srcIndex;
node->next = NULL;
node->next = nullptr;
}
}
@ -1348,7 +1349,7 @@ public:
inline ~PriorityQueue (void)
{
free (m_heap);
m_heap = NULL;
m_heap = nullptr;
}
// inserts a value into the priority queue
@ -1360,7 +1361,7 @@ public:
return;
}
if (m_heap == NULL)
if (m_heap == nullptr)
return;
if (m_size >= m_heapSize)
@ -1370,7 +1371,7 @@ public:
Node *newHeap = static_cast <Node *> (realloc (m_heap, sizeof (Node) * m_heapSize));
if (newHeap != NULL)
if (newHeap != nullptr)
m_heap = newHeap;
}
@ -1381,7 +1382,7 @@ public:
while (child)
{
int parent = (child - 1) * 0.5f;
int parent = static_cast <int> ((child - 1) * 0.5f);
if (m_heap[parent].pri <= m_heap[child].pri)
break;
@ -1435,7 +1436,7 @@ float gfunctionKillsDistT (int currentIndex, int parentIndex)
if (parentIndex == -1)
return 0.0f;
float cost = (g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team0Damage + g_highestDamageT;
float cost = static_cast <float> ((g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team0Damage + g_highestDamageT);
Path *current = waypoints.GetPath (currentIndex);
@ -1461,7 +1462,7 @@ float gfunctionKillsDistCT (int currentIndex, int parentIndex)
if (parentIndex == -1)
return 0.0f;
float cost = (g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team1Damage + g_highestDamageCT;
float cost = static_cast <float> ((g_experienceData + (currentIndex * g_numWaypoints) + currentIndex)->team1Damage + g_highestDamageCT);
Path *current = waypoints.GetPath (currentIndex);
@ -1575,7 +1576,7 @@ float gfunctionPathDist (int currentIndex, int parentIndex)
if (current->flags & (FLAG_CROUCH | FLAG_LADDER))
return parent->distances[i] * 1.5f;
return parent->distances[i];
return static_cast <float> (parent->distances[i]);
}
}
return 65355.0f;
@ -1658,7 +1659,7 @@ void Bot::FindPath(int srcIndex, int destIndex, SearchPathType pathType /*= SEAR
{
float g;
float f;
short parentIndex;
int parentIndex;
AStarState state;
} astar[MAX_WAYPOINTS];
@ -1672,8 +1673,8 @@ void Bot::FindPath(int srcIndex, int destIndex, SearchPathType pathType /*= SEAR
astar[i].state = NEW;
}
float (*gcalc) (int, int) = NULL;
float (*hcalc) (int, int, int) = NULL;
float (*gcalc) (int, int) = nullptr;
float (*hcalc) (int, int, int) = nullptr;
switch (pathType)
{
@ -1750,7 +1751,7 @@ void Bot::FindPath(int srcIndex, int destIndex, SearchPathType pathType /*= SEAR
if (currentIndex == destIndex)
{
// build the complete path
m_navNode = NULL;
m_navNode = nullptr;
do
{
@ -1805,18 +1806,18 @@ void Bot::FindPath(int srcIndex, int destIndex, SearchPathType pathType /*= SEAR
void Bot::DeleteSearchNodes (void)
{
PathNode *deletingNode = NULL;
PathNode *deletingNode = nullptr;
PathNode *node = m_navNodeStart;
while (node != NULL)
while (node != nullptr)
{
deletingNode = node->next;
delete node;
node = deletingNode;
}
m_navNodeStart = NULL;
m_navNode = NULL;
m_navNodeStart = nullptr;
m_navNode = nullptr;
m_chosenGoalIndex = -1;
}
@ -1899,13 +1900,13 @@ bool Bot::FindWaypoint (void)
// now pick random one from choosen
if (waypointIndeces[2] != -1)
i = Random.Long (0, 2);
i = Random.Int (0, 2);
else if (waypointIndeces[1] != -1)
i = Random.Long (0, 1);
i = Random.Int (0, 1);
else if (waypointIndeces[0] != -1)
i = Random.Long (0, 0);
i = Random.Int (0, 0);
else if (coveredWaypoint != -1)
{
@ -1941,7 +1942,7 @@ bool Bot::FindWaypoint (void)
waypointIndeces[i] = random;
}
else
waypointIndeces[i] = Random.Long (0, g_numWaypoints - 1);
waypointIndeces[i] = Random.Int (0, g_numWaypoints - 1);
}
m_collideTime = engine.Time ();
@ -1974,7 +1975,7 @@ void Bot::GetValidWaypoint (void)
if (value > MAX_DAMAGE_VALUE)
value = MAX_DAMAGE_VALUE;
(g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + m_currentWaypointIndex)->team0Damage = static_cast <unsigned short> (value);
(g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + m_currentWaypointIndex)->team0Damage = static_cast <uint16> (value);
// affect nearby connected with victim waypoints
for (int i = 0; i < MAX_PATH_INDEX; i++)
@ -1987,7 +1988,7 @@ void Bot::GetValidWaypoint (void)
if (value > MAX_DAMAGE_VALUE)
value = MAX_DAMAGE_VALUE;
(g_experienceData + (m_currentPath->index[i] * g_numWaypoints) + m_currentPath->index[i])->team0Damage = static_cast <unsigned short> (value);
(g_experienceData + (m_currentPath->index[i] * g_numWaypoints) + m_currentPath->index[i])->team0Damage = static_cast <uint16> (value);
}
}
}
@ -1999,7 +2000,7 @@ void Bot::GetValidWaypoint (void)
if (value > MAX_DAMAGE_VALUE)
value = MAX_DAMAGE_VALUE;
(g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + m_currentWaypointIndex)->team1Damage = static_cast <unsigned short> (value);
(g_experienceData + (m_currentWaypointIndex * g_numWaypoints) + m_currentWaypointIndex)->team1Damage = static_cast <uint16> (value);
// affect nearby connected with victim waypoints
for (int i = 0; i < MAX_PATH_INDEX; i++)
@ -2012,7 +2013,7 @@ void Bot::GetValidWaypoint (void)
if (value > MAX_DAMAGE_VALUE)
value = MAX_DAMAGE_VALUE;
(g_experienceData + (m_currentPath->index[i] * g_numWaypoints) + m_currentPath->index[i])->team1Damage = static_cast <unsigned short> (value);
(g_experienceData + (m_currentPath->index[i] * g_numWaypoints) + m_currentPath->index[i])->team1Damage = static_cast <uint16> (value);
}
}
}
@ -2070,7 +2071,7 @@ int Bot::ChooseBombWaypoint (void)
Array <int> goals = waypoints.m_goalPoints;
if (goals.IsEmpty ())
return Random.Long (0, g_numWaypoints - 1); // reliability check
return Random.Int (0, g_numWaypoints - 1); // reliability check
Vector bombOrigin = CheckBombAudible ();
@ -2125,7 +2126,7 @@ int Bot::FindDefendWaypoint (const Vector &origin)
// some of points not found, return random one
if (srcIndex == -1 || posIndex == -1)
return Random.Long (0, g_numWaypoints - 1);
return Random.Int (0, g_numWaypoints - 1);
for (int i = 0; i < g_numWaypoints; i++) // find the best waypoint now
{
@ -2212,7 +2213,7 @@ int Bot::FindDefendWaypoint (const Vector &origin)
}
if (found.IsEmpty ())
return Random.Long (0, g_numWaypoints - 1); // most worst case, since there a evil error in waypoints
return Random.Int (0, g_numWaypoints - 1); // most worst case, since there a evil error in waypoints
return found.GetRandomElement ();
}
@ -2224,7 +2225,7 @@ int Bot::FindDefendWaypoint (const Vector &origin)
if (waypointIndex[index] == -1)
break;
}
return waypointIndex[Random.Long (0, (index - 1) * 0.5f)];
return waypointIndex[Random.Int (0, static_cast <int> ((index - 1) * 0.5f))];
}
int Bot::FindCoverWaypoint (float maxDistance)
@ -2371,8 +2372,8 @@ bool Bot::GetBestNextWaypoint (void)
// this function does a realtime post processing of waypoints return from the
// pathfinder, to vary paths and find the best waypoint on our way
InternalAssert (m_navNode != NULL);
InternalAssert (m_navNode->next != NULL);
InternalAssert (m_navNode != nullptr);
InternalAssert (m_navNode->next != nullptr);
if (!IsPointOccupied (m_navNode->index))
return false;
@ -2403,7 +2404,7 @@ bool Bot::HeadTowardWaypoint (void)
GetValidWaypoint (); // check if old waypoints is still reliable
// no waypoints from pathfinding?
if (m_navNode == NULL)
if (m_navNode == nullptr)
return false;
TraceResult tr;
@ -2412,10 +2413,10 @@ bool Bot::HeadTowardWaypoint (void)
m_currentTravelFlags = 0; // reset travel flags (jumping etc)
// we're not at the end of the list?
if (m_navNode != NULL)
if (m_navNode != nullptr)
{
// if in between a route, postprocess the waypoint (find better alternatives)...
if (m_navNode != m_navNodeStart && m_navNode->next != NULL)
if (m_navNode != m_navNodeStart && m_navNode->next != nullptr)
{
GetBestNextWaypoint ();
m_minSpeed = pev->maxspeed;
@ -2449,7 +2450,7 @@ bool Bot::HeadTowardWaypoint (void)
if (m_baseAgressionLevel < kills && HasPrimaryWeapon ())
{
PushTask (TASK_CAMP, TASKPRI_CAMP, -1, engine.Time () + Random.Float (m_difficulty * 0.5f, m_difficulty) * 5.0f, true);
PushTask (TASK_CAMP, TASKPRI_CAMP, -1, engine.Time () + Random.Float (m_difficulty * 0.5f, static_cast <float> (m_difficulty)) * 5.0f, true);
PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, FindDefendWaypoint (waypoints.GetPath (nextIndex)->origin), engine.Time () + Random.Float (3.0f, 10.0f), true);
}
}
@ -2457,13 +2458,13 @@ bool Bot::HeadTowardWaypoint (void)
{
if (static_cast <float> (kills) == m_baseAgressionLevel)
m_campButtons |= IN_DUCK;
else if (Random.Long (1, 100) > m_difficulty * 25)
else if (Random.Int (1, 100) > m_difficulty * 25)
m_minSpeed = GetWalkSpeed ();
}
}
}
if (m_navNode != NULL)
if (m_navNode != nullptr)
{
int destIndex = m_navNode->index;
@ -2490,7 +2491,7 @@ bool Bot::HeadTowardWaypoint (void)
Vector dst;
// try to find out about future connection flags
if (m_navNode->next != NULL)
if (m_navNode->next != nullptr)
{
for (int i = 0; i < MAX_PATH_INDEX; i++)
{
@ -2523,7 +2524,7 @@ bool Bot::HeadTowardWaypoint (void)
Bot *otherBot = bots.GetBot (c);
// if another bot uses this ladder, wait 3 secs
if (otherBot != NULL && otherBot != this && IsAlive (otherBot->GetEntity ()) && otherBot->m_currentWaypointIndex == m_navNode->index)
if (otherBot != nullptr && otherBot != this && IsAlive (otherBot->GetEntity ()) && otherBot->m_currentWaypointIndex == m_navNode->index)
{
PushTask (TASK_PAUSE, TASKPRI_PAUSE, -1, engine.Time () + 3.0f, false);
return true;
@ -3099,7 +3100,7 @@ int Bot::GetAimingWaypoint (void)
int currentWaypoint = m_currentWaypointIndex;
if (currentWaypoint == -1)
return Random.Long (0, g_numWaypoints - 1);
return Random.Int (0, g_numWaypoints - 1);
for (int i = 0; i < g_numWaypoints; i++)
{
@ -3139,9 +3140,9 @@ int Bot::GetAimingWaypoint (void)
count--;
if (count >= 0)
return indices[Random.Long (0, count)];
return indices[Random.Int (0, count)];
return Random.Long (0, g_numWaypoints - 1);
return Random.Int (0, g_numWaypoints - 1);
}
void Bot::UpdateBodyAngles (void)
@ -3330,7 +3331,7 @@ int Bot::FindPlantedBomb (void)
if (m_team != TERRORIST || !(g_mapType & MAP_DE))
return -1; // don't search for bomb if the player is CT, or it's not defusing bomb
edict_t *bombEntity = NULL; // temporaly pointer to bomb
edict_t *bombEntity = nullptr; // temporaly pointer to bomb
// search the bomb on the map
while (!engine.IsNullEntity (bombEntity = FIND_ENTITY_BY_CLASSNAME (bombEntity, "grenade")))
@ -3358,7 +3359,7 @@ bool Bot::IsPointOccupied (int index)
{
Bot *bot = bots.GetBot (i);
if (bot == NULL || bot == this)
if (bot == nullptr || bot == this)
continue;
// check if this waypoint is already used
@ -3384,10 +3385,10 @@ edict_t *Bot::FindNearestButton (const char *targetName)
// it's entity, also here must be specified the target, that button must open.
if (IsNullString (targetName))
return NULL;
return nullptr;
float nearestDistance = 99999.0f;
edict_t *searchEntity = NULL, *foundEntity = NULL;
edict_t *searchEntity = nullptr, *foundEntity = nullptr;
// find the nearest button which can open our target
while (!engine.IsNullEntity(searchEntity = FIND_ENTITY_BY_TARGET (searchEntity, targetName)))

View file

@ -4,15 +4,15 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
ConVar yb_display_menu_text ("yb_display_menu_text", "1");
ConVar mp_roundtime ("mp_roundtime", NULL, VT_NOREGISTER);
ConVar mp_freezetime ("mp_freezetime", NULL, VT_NOREGISTER, true);
ConVar mp_roundtime ("mp_roundtime", nullptr, VT_NOREGISTER);
ConVar mp_freezetime ("mp_freezetime", nullptr, VT_NOREGISTER, true);
uint16 FixedUnsigned16 (float value, float scale)
{
@ -45,7 +45,7 @@ const char *FormatBuffer (const char *format, ...)
static char strBuffer[2][MAX_PRINT_BUFFER];
static int rotator = 0;
if (format == NULL)
if (format == nullptr)
return strBuffer[rotator];
static char *ptr = strBuffer[rotator ^= 1];
@ -106,7 +106,7 @@ void DisplayMenuToClient (edict_t *ent, MenuText *menu)
int clientIndex = engine.IndexOfEntity (ent) - 1;
if (menu != NULL)
if (menu != nullptr)
{
String tempText = String (menu->menuText);
tempText.Replace ("\v", "\n");
@ -125,7 +125,7 @@ void DisplayMenuToClient (edict_t *ent, MenuText *menu)
while (strlen (text) >= 64)
{
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), NULL, ent);
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), nullptr, ent);
WRITE_SHORT (menu->validSlots);
WRITE_CHAR (-1);
WRITE_BYTE (1);
@ -138,7 +138,7 @@ void DisplayMenuToClient (edict_t *ent, MenuText *menu)
text += 64;
}
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), NULL, ent);
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), nullptr, ent);
WRITE_SHORT (menu->validSlots);
WRITE_CHAR (-1);
WRITE_BYTE (0);
@ -149,14 +149,14 @@ void DisplayMenuToClient (edict_t *ent, MenuText *menu)
}
else
{
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), NULL, ent);
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), nullptr, ent);
WRITE_SHORT (0);
WRITE_CHAR (0);
WRITE_BYTE (0);
WRITE_STRING ("");
MESSAGE_END();
g_clients[clientIndex].menu = NULL;
g_clients[clientIndex].menu = nullptr;
}
CLIENT_COMMAND (ent, "speak \"player/geiger1\"\n"); // Stops others from hearing menu sounds..
}
@ -242,7 +242,7 @@ void FreeLibraryMemory (void)
waypoints.Init (); // frees waypoint data
delete [] g_experienceData;
g_experienceData = NULL;
g_experienceData = nullptr;
}
void UpdateGlobalExperienceData (void)
@ -253,8 +253,8 @@ void UpdateGlobalExperienceData (void)
if (g_numWaypoints < 1 || waypoints.HasChanged ())
return; // no action
unsigned short maxDamage; // maximum damage
unsigned short actDamage; // actual damage
uint16 maxDamage; // maximum damage
uint16 actDamage; // actual damage
int bestIndex; // best index to store
bool recalcKills = false;
@ -327,7 +327,7 @@ void UpdateGlobalExperienceData (void)
if (clip < 0)
clip = 0;
(g_experienceData + (i * g_numWaypoints) + j)->team0Damage = static_cast <unsigned short> (clip);
(g_experienceData + (i * g_numWaypoints) + j)->team0Damage = static_cast <uint16> (clip);
clip = (g_experienceData + (i * g_numWaypoints) + j)->team1Damage;
clip -= static_cast <int> (MAX_DAMAGE_VALUE * 0.5);
@ -335,7 +335,7 @@ void UpdateGlobalExperienceData (void)
if (clip < 0)
clip = 0;
(g_experienceData + (i * g_numWaypoints) + j)->team1Damage = static_cast <unsigned short> (clip);
(g_experienceData + (i * g_numWaypoints) + j)->team1Damage = static_cast <uint16> (clip);
}
}
}
@ -359,8 +359,8 @@ void UpdateGlobalExperienceData (void)
{
for (int i = 0; i < g_numWaypoints; i++)
{
(g_experienceData + (i * g_numWaypoints) + i)->team0Damage /= static_cast <unsigned short> (engine.MaxClients () * 0.5);
(g_experienceData + (i * g_numWaypoints) + i)->team1Damage /= static_cast <unsigned short> (engine.MaxClients () * 0.5);
(g_experienceData + (i * g_numWaypoints) + i)->team0Damage /= static_cast <uint16> (engine.MaxClients () * 0.5);
(g_experienceData + (i * g_numWaypoints) + i)->team1Damage /= static_cast <uint16> (engine.MaxClients () * 0.5);
}
g_highestKills = 1;
}
@ -433,7 +433,7 @@ bool IsValidPlayer (edict_t *ent)
if (ent->v.flags & FL_PROXY)
return false;
if ((ent->v.flags & (FL_CLIENT | FL_FAKECLIENT)) || bots.GetBot (ent) != NULL)
if ((ent->v.flags & (FL_CLIENT | FL_FAKECLIENT)) || bots.GetBot (ent) != nullptr)
return !IsNullString (STRING (ent->v.netname));
return false;
@ -452,7 +452,7 @@ bool IsPlayerVIP (edict_t *ent)
bool IsValidBot (edict_t *ent)
{
if (bots.GetBot (ent) != NULL || (!engine.IsNullEntity (ent) && (ent->v.flags & FL_FAKECLIENT)))
if (bots.GetBot (ent) != nullptr || (!engine.IsNullEntity (ent) && (ent->v.flags & FL_FAKECLIENT)))
return true;
return false;
@ -477,10 +477,10 @@ bool OpenConfig (const char *fileName, const char *errorIfNotExists, MemoryFile
// check file existence
int size = 0;
unsigned char *buffer = NULL;
uint8 *buffer = nullptr;
// check is file is exists for this language
if ((buffer = MemoryFile::Loader (langConfig, &size)) != NULL)
if ((buffer = MemoryFile::Loader (langConfig, &size)) != nullptr)
{
MemoryFile::Unloader (buffer);
@ -544,19 +544,19 @@ void CheckWelcomeMessage (void)
engine.ChatPrintf ("----- %s v%s (Build: %u), {%s}, (c) 2016, by %s (%s)-----", PRODUCT_NAME, PRODUCT_VERSION, GenerateBuildNumber (), PRODUCT_DATE, PRODUCT_AUTHOR, PRODUCT_URL);
MESSAGE_BEGIN (MSG_ONE, SVC_TEMPENTITY, NULL, g_hostEntity);
MESSAGE_BEGIN (MSG_ONE, SVC_TEMPENTITY, nullptr, g_hostEntity);
WRITE_BYTE (TE_TEXTMESSAGE);
WRITE_BYTE (1);
WRITE_SHORT (FixedSigned16 (-1, 1 << 13));
WRITE_SHORT (FixedSigned16 (-1, 1 << 13));
WRITE_BYTE (2);
WRITE_BYTE (Random.Long (33, 255));
WRITE_BYTE (Random.Long (33, 255));
WRITE_BYTE (Random.Long (33, 255));
WRITE_BYTE (Random.Int (33, 255));
WRITE_BYTE (Random.Int (33, 255));
WRITE_BYTE (Random.Int (33, 255));
WRITE_BYTE (0);
WRITE_BYTE (Random.Long (230, 255));
WRITE_BYTE (Random.Long (230, 255));
WRITE_BYTE (Random.Long (230, 255));
WRITE_BYTE (Random.Int (230, 255));
WRITE_BYTE (Random.Int (230, 255));
WRITE_BYTE (Random.Int (230, 255));
WRITE_BYTE (200);
WRITE_SHORT (FixedUnsigned16 (0.0078125f, 1 << 8));
WRITE_SHORT (FixedUnsigned16 (2.0f, 1 << 8));
@ -660,7 +660,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
// team, live status, search distance etc. if needBot is true, then pvHolder, will
// be filled with bot pointer, else with edict pointer(!).
edict_t *survive = NULL; // pointer to temporally & survive entity
edict_t *survive = nullptr; // pointer to temporally & survive entity
float nearestPlayer = 4096.0f; // nearest player
int toTeam = engine.GetTeam (to);
@ -874,7 +874,7 @@ int GenerateBuildNumber (void)
const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
// array of the month days
byte monthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8 monthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int day = 0; // day of the year
int year = 0; // year

View file

@ -4,7 +4,7 @@
//
// This software is licensed under the BSD-style license.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// http://yapb.jeefo.net/license
// https://yapb.jeefo.net/license
//
#include <core.h>
@ -32,10 +32,10 @@ void Waypoint::Init (void)
void Waypoint::CleanupPathMemory (void)
{
for (int i = 0; i < g_numWaypoints && m_paths[i] != NULL; i++)
for (int i = 0; i < g_numWaypoints && m_paths[i] != nullptr; i++)
{
delete m_paths[i];
m_paths[i] = NULL;
m_paths[i] = nullptr;
}
}
@ -57,11 +57,11 @@ void Waypoint::AddPath (int addIndex, int pathIndex, float distance)
}
// check for free space in the connection indices
for (int i = 0; i < MAX_PATH_INDEX; i++)
for (int16 i = 0; i < MAX_PATH_INDEX; i++)
{
if (path->index[i] == -1)
{
path->index[i] = pathIndex;
path->index[i] = static_cast <int16> (pathIndex);
path->distances[i] = abs (static_cast <int> (distance));
AddLogEntry (true, LL_DEFAULT, "Path added from %d to %d", addIndex, pathIndex);
@ -86,7 +86,7 @@ void Waypoint::AddPath (int addIndex, int pathIndex, float distance)
{
AddLogEntry (true, LL_DEFAULT, "Path added from %d to %d", addIndex, pathIndex);
path->index[slotID] = pathIndex;
path->index[slotID] = static_cast <int16> (pathIndex);
path->distances[slotID] = abs (static_cast <int> (distance));
}
}
@ -155,7 +155,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
float distance;
Vector forward;
Path *path = NULL;
Path *path = nullptr;
bool placeNew = true;
Vector newOrigin = waypointOrigin;
@ -217,7 +217,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
case 10:
index = FindNearest (g_hostEntity->v.origin, 50.0f);
if (index != -1 && m_paths[index] != NULL)
if (index != -1 && m_paths[index] != nullptr)
{
distance = (m_paths[index]->origin - g_hostEntity->v.origin).GetLength ();
@ -247,7 +247,7 @@ void Waypoint::Add (int flags, const Vector &waypointOrigin)
m_paths[index] = new Path;
if (m_paths[index] == NULL)
if (m_paths[index] == nullptr)
TerminateOnMalloc ();
path = m_paths[index];
@ -456,8 +456,8 @@ void Waypoint::Delete (void)
if (index < 0)
return;
Path *path = NULL;
InternalAssert (m_paths[index] != NULL);
Path *path = nullptr;
InternalAssert (m_paths[index] != nullptr);
int i, j;
@ -493,7 +493,7 @@ void Waypoint::Delete (void)
// free deleted node
delete m_paths[index];
m_paths[index] = NULL;
m_paths[index] = nullptr;
// rotate path array down
for (i = index; i < g_numWaypoints - 1; i++)
@ -742,7 +742,7 @@ void Waypoint::CalculateWayzone (int index)
}
}
for (int scanDistance = 16; scanDistance < 128; scanDistance += 16)
for (float scanDistance = 16.0f; scanDistance < 128.0f; scanDistance += 16.0f)
{
start = path->origin;
MakeVectors (Vector::GetZero ());
@ -759,11 +759,11 @@ void Waypoint::CalculateWayzone (int index)
Vector radiusStart = start - g_pGlobals->v_forward * scanDistance;
Vector radiusEnd = start + g_pGlobals->v_forward * scanDistance;
engine.TestHull (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
engine.TestHull (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, head_hull, nullptr, &tr);
if (tr.flFraction < 1.0f)
{
engine.TestLine (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, NULL, &tr);
engine.TestLine (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, nullptr, &tr);
if (FClassnameIs (tr.pHit, "func_door") || FClassnameIs (tr.pHit, "func_door_rotating"))
{
@ -782,7 +782,7 @@ void Waypoint::CalculateWayzone (int index)
Vector dropStart = start + g_pGlobals->v_forward * scanDistance;
Vector dropEnd = dropStart - Vector (0.0f, 0.0f, scanDistance + 60.0f);
engine.TestHull (dropStart, dropEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
engine.TestHull (dropStart, dropEnd, TRACE_IGNORE_MONSTERS, head_hull, nullptr, &tr);
if (tr.flFraction >= 1.0f)
{
@ -794,7 +794,7 @@ void Waypoint::CalculateWayzone (int index)
dropStart = start - g_pGlobals->v_forward * scanDistance;
dropEnd = dropStart - Vector (0.0f, 0.0f, scanDistance + 60.0f);
engine.TestHull (dropStart, dropEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
engine.TestHull (dropStart, dropEnd, TRACE_IGNORE_MONSTERS, head_hull, nullptr, &tr);
if (tr.flFraction >= 1.0f)
{
@ -804,7 +804,7 @@ void Waypoint::CalculateWayzone (int index)
}
radiusEnd.z += 34.0f;
engine.TestHull (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, head_hull, NULL, &tr);
engine.TestHull (radiusStart, radiusEnd, TRACE_IGNORE_MONSTERS, head_hull, nullptr, &tr);
if (tr.flFraction < 1.0f)
{
@ -843,14 +843,14 @@ void Waypoint::SaveExperienceTab (void)
{
for (int j = 0; j < g_numWaypoints; j++)
{
(experienceSave + (i * g_numWaypoints) + j)->team0Damage = (g_experienceData + (i * g_numWaypoints) + j)->team0Damage >> 3;
(experienceSave + (i * g_numWaypoints) + j)->team1Damage = (g_experienceData + (i * g_numWaypoints) + j)->team1Damage >> 3;
(experienceSave + (i * g_numWaypoints) + j)->team0Value = (g_experienceData + (i * g_numWaypoints) + j)->team0Value / 8;
(experienceSave + (i * g_numWaypoints) + j)->team1Value = (g_experienceData + (i * g_numWaypoints) + j)->team1Value / 8;
(experienceSave + (i * g_numWaypoints) + j)->team0Damage = static_cast <uint8> ((g_experienceData + (i * g_numWaypoints) + j)->team0Damage >> 3);
(experienceSave + (i * g_numWaypoints) + j)->team1Damage = static_cast <uint8> ((g_experienceData + (i * g_numWaypoints) + j)->team1Damage >> 3);
(experienceSave + (i * g_numWaypoints) + j)->team0Value = static_cast <int8> ((g_experienceData + (i * g_numWaypoints) + j)->team0Value / 8);
(experienceSave + (i * g_numWaypoints) + j)->team1Value = static_cast <int8> ((g_experienceData + (i * g_numWaypoints) + j)->team1Value / 8);
}
}
int result = Compressor::Compress (FormatBuffer ("%slearned/%s.exp", GetDataDir (), engine.GetMapName ()), (unsigned char *)&header, sizeof (ExtensionHeader), (unsigned char *)experienceSave, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
int result = Compressor::Compress (FormatBuffer ("%slearned/%s.exp", GetDataDir (), engine.GetMapName ()), (uint8 *)&header, sizeof (ExtensionHeader), (uint8 *)experienceSave, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
delete [] experienceSave;
@ -866,7 +866,7 @@ void Waypoint::InitExperienceTab (void)
int i, j;
delete [] g_experienceData;
g_experienceData = NULL;
g_experienceData = nullptr;
if (g_numWaypoints < 1)
return;
@ -912,7 +912,7 @@ void Waypoint::InitExperienceTab (void)
{
ExperienceSave *experienceLoad = new ExperienceSave[g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave)];
Compressor::Uncompress (FormatBuffer ("%slearned/%s.exp", GetDataDir (), engine.GetMapName ()), sizeof (ExtensionHeader), (unsigned char *)experienceLoad, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
Compressor::Uncompress (FormatBuffer ("%slearned/%s.exp", GetDataDir (), engine.GetMapName ()), sizeof (ExtensionHeader), (uint8 *)experienceLoad, g_numWaypoints * g_numWaypoints * sizeof (ExperienceSave));
for (i = 0; i < g_numWaypoints; i++)
{
@ -920,8 +920,8 @@ void Waypoint::InitExperienceTab (void)
{
if (i == j)
{
(g_experienceData + (i * g_numWaypoints) + j)->team0Damage = (unsigned short) ((experienceLoad + (i * g_numWaypoints) + j)->team0Damage);
(g_experienceData + (i * g_numWaypoints) + j)->team1Damage = (unsigned short) ((experienceLoad + (i * g_numWaypoints) + j)->team1Damage);
(g_experienceData + (i * g_numWaypoints) + j)->team0Damage = (uint16) ((experienceLoad + (i * g_numWaypoints) + j)->team0Damage);
(g_experienceData + (i * g_numWaypoints) + j)->team1Damage = (uint16) ((experienceLoad + (i * g_numWaypoints) + j)->team1Damage);
if ((g_experienceData + (i * g_numWaypoints) + j)->team0Damage > g_highestDamageT)
g_highestDamageT = (g_experienceData + (i * g_numWaypoints) + j)->team0Damage;
@ -931,12 +931,12 @@ void Waypoint::InitExperienceTab (void)
}
else
{
(g_experienceData + (i * g_numWaypoints) + j)->team0Damage = (unsigned short) ((experienceLoad + (i * g_numWaypoints) + j)->team0Damage) << 3;
(g_experienceData + (i * g_numWaypoints) + j)->team1Damage = (unsigned short) ((experienceLoad + (i * g_numWaypoints) + j)->team1Damage) << 3;
(g_experienceData + (i * g_numWaypoints) + j)->team0Damage = (uint16) ((experienceLoad + (i * g_numWaypoints) + j)->team0Damage) << 3;
(g_experienceData + (i * g_numWaypoints) + j)->team1Damage = (uint16) ((experienceLoad + (i * g_numWaypoints) + j)->team1Damage) << 3;
}
(g_experienceData + (i * g_numWaypoints) + j)->team0Value = (signed short) ((experienceLoad + i * (g_numWaypoints) + j)->team0Value) * 8;
(g_experienceData + (i * g_numWaypoints) + j)->team1Value = (signed short) ((experienceLoad + i * (g_numWaypoints) + j)->team1Value) * 8;
(g_experienceData + (i * g_numWaypoints) + j)->team0Value = (int16) ((experienceLoad + i * (g_numWaypoints) + j)->team0Value) * 8;
(g_experienceData + (i * g_numWaypoints) + j)->team1Value = (int16) ((experienceLoad + i * (g_numWaypoints) + j)->team1Value) * 8;
}
}
delete [] experienceLoad;
@ -971,7 +971,7 @@ void Waypoint::SaveVisibilityTab (void)
}
fp.Close ();
Compressor::Compress (FormatBuffer ("%slearned/%s.vis", GetDataDir (), engine.GetMapName ()), (unsigned char *) &header, sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (unsigned char));
Compressor::Compress (FormatBuffer ("%slearned/%s.vis", GetDataDir (), engine.GetMapName ()), (uint8 *) &header, sizeof (ExtensionHeader), (uint8 *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (uint8));
}
void Waypoint::InitVisibilityTab (void)
@ -1012,7 +1012,7 @@ void Waypoint::InitVisibilityTab (void)
return;
}
int result = Compressor::Uncompress (FormatBuffer ("%slearned/%s.vis", GetDataDir (), engine.GetMapName ()), sizeof (ExtensionHeader), (unsigned char *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (unsigned char));
int result = Compressor::Uncompress (FormatBuffer ("%slearned/%s.vis", GetDataDir (), engine.GetMapName ()), sizeof (ExtensionHeader), (uint8 *) m_visLUT, MAX_WAYPOINTS * (MAX_WAYPOINTS / 4) * sizeof (uint8));
if (result == -1)
{
@ -1118,7 +1118,7 @@ bool Waypoint::Load (void)
{
m_paths[i] = new Path;
if (m_paths[i] == NULL)
if (m_paths[i] == nullptr)
TerminateOnMalloc ();
if (fp.Read (m_paths[i], sizeof (Path)) == 0)
@ -1285,7 +1285,7 @@ bool Waypoint::Reachable (Bot *bot, int index)
{
// this function return wether bot able to reach index waypoint or not, depending on several factors.
if (bot == NULL || index < 0 || index >= g_numWaypoints)
if (bot == nullptr || index < 0 || index >= g_numWaypoints)
return false;
Vector src = bot->pev->origin;
@ -1407,7 +1407,7 @@ void Waypoint::InitializeVisibility (void)
return;
TraceResult tr;
byte res, shift;
uint8 res, shift;
for (m_visibilityIndex = 0; m_visibilityIndex < g_numWaypoints; m_visibilityIndex++)
{
@ -1431,7 +1431,7 @@ void Waypoint::InitializeVisibility (void)
// first check ducked visibility
Vector dest = m_paths[i]->origin;
engine.TestLine (sourceDuck, dest, TRACE_IGNORE_MONSTERS, NULL, &tr);
engine.TestLine (sourceDuck, dest, TRACE_IGNORE_MONSTERS, nullptr, &tr);
// check if line of sight to object is not blocked (i.e. visible)
if (tr.flFraction != 1.0f || tr.fStartSolid)
@ -1441,7 +1441,7 @@ void Waypoint::InitializeVisibility (void)
res <<= 1;
engine.TestLine (sourceStand, dest, TRACE_IGNORE_MONSTERS, NULL, &tr);
engine.TestLine (sourceStand, dest, TRACE_IGNORE_MONSTERS, nullptr, &tr);
// check if line of sight to object is not blocked (i.e. visible)
if (tr.flFraction != 1.0f || tr.fStartSolid)
@ -1465,7 +1465,7 @@ void Waypoint::InitializeVisibility (void)
bool Waypoint::IsVisible (int srcIndex, int destIndex)
{
unsigned char res = m_visLUT[srcIndex][destIndex >> 2];
uint8 res = m_visLUT[srcIndex][destIndex >> 2];
res >>= (destIndex % 4) << 1;
return !((res & 3) == 3);
@ -1473,7 +1473,7 @@ bool Waypoint::IsVisible (int srcIndex, int destIndex)
bool Waypoint::IsDuckVisible (int srcIndex, int destIndex)
{
unsigned char res = m_visLUT[srcIndex][destIndex >> 2];
uint8 res = m_visLUT[srcIndex][destIndex >> 2];
res >>= (destIndex % 4) << 1;
return !((res & 2) == 2);
@ -1481,7 +1481,7 @@ bool Waypoint::IsDuckVisible (int srcIndex, int destIndex)
bool Waypoint::IsStandVisible (int srcIndex, int destIndex)
{
unsigned char res = m_visLUT[srcIndex][destIndex >> 2];
uint8 res = m_visLUT[srcIndex][destIndex >> 2];
res >>= (destIndex % 4) << 1;
return !((res & 1) == 1);
@ -1494,7 +1494,7 @@ const char *Waypoint::GetWaypointInfo(int id)
Path *path = m_paths[id];
// if this path is null, return
if (path == NULL)
if (path == nullptr)
return "\0";
bool jumpPoint = false;
@ -1641,8 +1641,8 @@ void Waypoint::Think (void)
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 15, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10);
else // draw node with flags
{
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75), 14, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10); // draw basic path
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 14, 0, static_cast <int> (nodeFlagColor.x), static_cast <int> (nodeFlagColor.y), static_cast <int> (nodeFlagColor.z), 250, 0, 10); // draw additional path
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight), m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75f), 14, 0, static_cast <int> (nodeColor.x), static_cast <int> (nodeColor.y), static_cast <int> (nodeColor.z), 250, 0, 10); // draw basic path
engine.DrawLine (g_hostEntity, m_paths[i]->origin - Vector (0, 0, nodeHalfHeight - nodeHeight * 0.75f), m_paths[i]->origin + Vector (0, 0, nodeHalfHeight), 14, 0, static_cast <int> (nodeFlagColor.x), static_cast <int> (nodeFlagColor.y), static_cast <int> (nodeFlagColor.z), 250, 0, 10); // draw additional path
}
m_waypointDisplayTime[i] = engine.Time ();
}
@ -1797,7 +1797,7 @@ void Waypoint::Think (void)
}
// draw entire message
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, g_hostEntity);
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, nullptr, g_hostEntity);
WRITE_BYTE (TE_TEXTMESSAGE);
WRITE_BYTE (4); // channel
WRITE_SHORT (FixedSigned16 (0, 1 << 13)); // x
@ -1813,7 +1813,7 @@ void Waypoint::Think (void)
WRITE_BYTE (255); // a2
WRITE_SHORT (0); // fadeintime
WRITE_SHORT (0); // fadeouttime
WRITE_SHORT (FixedUnsigned16 (1.1, 1 << 8)); // holdtime
WRITE_SHORT (FixedUnsigned16 (1.1f, 1 << 8)); // holdtime
WRITE_STRING (tempMessage);
MESSAGE_END ();
}
@ -1949,7 +1949,7 @@ bool Waypoint::NodesValid (void)
}
// perform DFS instead of floyd-warshall, this shit speedup this process in a bit
PathNode *stack = NULL;
PathNode *stack = nullptr;
bool visited[MAX_WAYPOINTS];
// first check incoming connectivity, initialize the "visited" table
@ -1958,10 +1958,10 @@ bool Waypoint::NodesValid (void)
// check from waypoint nr. 0
stack = new PathNode;
stack->next = NULL;
stack->next = nullptr;
stack->index = 0;
while (stack != NULL)
while (stack != nullptr)
{
// pop a node from the stack
PathNode *current = stack;
@ -2023,10 +2023,10 @@ bool Waypoint::NodesValid (void)
// check from Waypoint nr. 0
stack = new PathNode;
stack->next = NULL;
stack->next = nullptr;
stack->index = 0;
while (stack != NULL)
while (stack != nullptr)
{
// pop a node from the stack
PathNode *current = stack;
@ -2075,8 +2075,8 @@ void Waypoint::InitPathMatrix (void)
delete [] m_distMatrix;
delete [] m_pathMatrix;
m_distMatrix = NULL;
m_pathMatrix = NULL;
m_distMatrix = nullptr;
m_pathMatrix = nullptr;
m_distMatrix = new int [g_numWaypoints * g_numWaypoints];
m_pathMatrix = new int [g_numWaypoints * g_numWaypoints];
@ -2227,7 +2227,7 @@ void Waypoint::CreateBasic (void)
{
// this function creates basic waypoint types on map
edict_t *ent = NULL;
edict_t *ent = nullptr;
// first of all, if map contains ladder points, create it
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_ladder")))
@ -2248,7 +2248,7 @@ void Waypoint::CreateBasic (void)
up = down = front;
down.z = ent->v.absmax.z;
engine.TestHull (down, up, TRACE_IGNORE_MONSTERS, point_hull, NULL, &tr);
engine.TestHull (down, up, TRACE_IGNORE_MONSTERS, point_hull, nullptr, &tr);
if (POINT_CONTENTS (up) == CONTENTS_SOLID || tr.flFraction != 1.0f)
{
@ -2256,7 +2256,7 @@ void Waypoint::CreateBasic (void)
down.z = ent->v.absmax.z;
}
engine.TestHull (down, up - Vector (0.0f, 0.0f, 1000.0f), TRACE_IGNORE_MONSTERS, point_hull, NULL, &tr);
engine.TestHull (down, up - Vector (0.0f, 0.0f, 1000.0f), TRACE_IGNORE_MONSTERS, point_hull, nullptr, &tr);
up = tr.vecEndPos;
Vector pointOrigin = up + Vector (0.0f, 0.0f, 39.0f);
@ -2386,8 +2386,8 @@ Path *Waypoint::GetPath (int id)
{
Path *path = m_paths[id];
if (path == NULL)
return NULL;
if (path == nullptr)
return nullptr;
return path;
}
@ -2442,7 +2442,7 @@ void Waypoint::SetBombPosition (bool shouldReset)
return;
}
edict_t *ent = NULL;
edict_t *ent = nullptr;
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
{
@ -2499,8 +2499,8 @@ Waypoint::Waypoint (void)
m_rescuePoints.RemoveAll ();
m_sniperPoints.RemoveAll ();
m_distMatrix = NULL;
m_pathMatrix = NULL;
m_distMatrix = nullptr;
m_pathMatrix = nullptr;
}
Waypoint::~Waypoint (void)
@ -2510,8 +2510,8 @@ Waypoint::~Waypoint (void)
delete [] m_distMatrix;
delete [] m_pathMatrix;
m_distMatrix = NULL;
m_pathMatrix = NULL;
m_distMatrix = nullptr;
m_pathMatrix = nullptr;
}
void Waypoint::CloseSocketHandle (int sock)
@ -2542,7 +2542,7 @@ WaypointDownloadError Waypoint::RequestWaypoint (void)
hostent *host = gethostbyname (yb_waypoint_autodl_host.GetString ());
if (host == NULL)
if (host == nullptr)
return WDE_SOCKET_ERROR;
int socketHandle = socket (AF_INET, SOCK_STREAM, 0);