Refactoring

This commit is contained in:
s1lent 2017-11-23 00:27:55 +07:00
parent a4fa8c6bc4
commit 7f9cf53c49
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
116 changed files with 2144 additions and 2182 deletions

View File

@ -15,7 +15,7 @@ void Assertions::StringEquals(std::string message, std::string expected, std::st
} }
void Assertions::StringEquals(std::string message, const char *expected, const char *actual, const char *fileName, long lineNumber) { void Assertions::StringEquals(std::string message, const char *expected, const char *actual, const char *fileName, long lineNumber) {
if (actual == NULL) { if (actual == nullptr) {
std::stringstream ss; std::stringstream ss;
ss << message << " (expected '" << expected << "', got NULL"; ss << message << " (expected '" << expected << "', got NULL";
throw TestFailException(ss.str(), std::string(fileName), lineNumber); throw TestFailException(ss.str(), std::string(fileName), lineNumber);

View File

@ -8,16 +8,15 @@
int GradleAdapter::writeAllTestsInfoToFile(const char *fname) { int GradleAdapter::writeAllTestsInfoToFile(const char *fname) {
FILE *outFile = fopen(fname, "w"); FILE *outFile = fopen(fname, "w");
if (outFile == NULL) { if (!outFile) {
return 1; return 1;
} }
fprintf(outFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fprintf(outFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fprintf(outFile, "<tests>\n"); fprintf(outFile, "<tests>\n");
Test *curTest = TestRegistry::getFirstTest(); Test *curTest = TestRegistry::getFirstTest();
while (curTest != NULL) { while (curTest) {
fprintf(outFile, "<test "); fprintf(outFile, "<test ");
fprintf(outFile, " name=\"%s\" ", curTest->getName()); fprintf(outFile, " name=\"%s\" ", curTest->getName());
@ -35,14 +34,14 @@ int GradleAdapter::writeAllTestsInfoToFile(const char* fname) {
int GradleAdapter::runTest(const char *groupName, const char *testName) { int GradleAdapter::runTest(const char *groupName, const char *testName) {
Test *curTest = TestRegistry::getFirstTest(); Test *curTest = TestRegistry::getFirstTest();
while (curTest != NULL) { while (curTest) {
if (!strcmp(groupName, curTest->getGroup()) && !strcmp(testName, curTest->getName())) { if (!strcmp(groupName, curTest->getGroup()) && !strcmp(testName, curTest->getName())) {
break; break;
} }
curTest = curTest->getNext(); curTest = curTest->getNext();
} }
if (curTest == NULL) { if (!curTest) {
printf("Test group='%s' name='%s' not found\n", groupName, testName); printf("Test group='%s' name='%s' not found\n", groupName, testName);
return 2; return 2;
} }
@ -61,7 +60,7 @@ int GradleAdapter::runTest(const char* groupName, const char* testName) {
int GradleAdapter::runGroup(const char *groupName) { int GradleAdapter::runGroup(const char *groupName) {
Test *curTest = TestRegistry::getFirstTest(); Test *curTest = TestRegistry::getFirstTest();
int ranTests = 0; int ranTests = 0;
while (curTest != NULL) { while (curTest) {
if (strcmp(groupName, curTest->getGroup())) { if (strcmp(groupName, curTest->getGroup())) {
curTest = curTest->getNext(); curTest = curTest->getNext();
continue; continue;
@ -90,7 +89,7 @@ int GradleAdapter::runGroup(const char* groupName) {
int GradleAdapter::runAllTests() { int GradleAdapter::runAllTests() {
Test *curTest = TestRegistry::getFirstTest(); Test *curTest = TestRegistry::getFirstTest();
int ranTests = 0; int ranTests = 0;
while (curTest != NULL) { while (curTest) {
TestResult result; TestResult result;
curTest->run(result); curTest->run(result);
ranTests++; ranTests++;

View File

@ -1,5 +1,3 @@
#include "cppunitlite/Test.h" #include "cppunitlite/Test.h"
#include "cppunitlite/TestRegistry.h" #include "cppunitlite/TestRegistry.h"
#include "cppunitlite/Failure.h" #include "cppunitlite/Failure.h"
@ -7,21 +5,18 @@
#include <exception> #include <exception>
#include <sstream> #include <sstream>
Test::Test (const char* testName, const char* testGroup, int timeout) Test::Test (const char* testName, const char* testGroup, int timeout)
: name_ (testName), group_ (testGroup), timeout_(timeout) : name_ (testName), group_ (testGroup), timeout_(timeout)
{ {
next_ = NULL; next_ = nullptr;
TestRegistry::addTest(this); TestRegistry::addTest(this);
} }
Test *Test::getNext() const Test *Test::getNext() const
{ {
return next_; return next_;
} }
void Test::setNext(Test *test) void Test::setNext(Test *test)
{ {
next_ = test; next_ = test;

View File

@ -29,17 +29,12 @@
#pragma once #pragma once
#ifdef PLAY_GAMEDLL #ifdef PLAY_GAMEDLL
// NOTE: In some cases we need high precision of floating-point,
// probably gamedll compiled with flag /fpmath:fasted, // so use double instead of float, otherwise unittest will fail
// so we need to use type double, otherwise will be the test failed typedef double real_t;
typedef double float_precision;
#else #else
typedef float real_t;
typedef float float_precision; #endif
#endif // PLAY_GAMEDLL
typedef float vec_t; typedef float vec_t;
typedef vec_t vec3_t[3]; typedef vec_t vec3_t[3];

View File

@ -49,7 +49,7 @@ EXT_FUNC bool CCSPlayer::JoinTeam(TeamName team)
pPlayer->m_iTeam = SPECTATOR; pPlayer->m_iTeam = SPECTATOR;
pPlayer->m_iJoiningState = JOINED; pPlayer->m_iJoiningState = JOINED;
pPlayer->m_pIntroCamera = NULL; pPlayer->m_pIntroCamera = nullptr;
pPlayer->m_bTeamChanged = true; pPlayer->m_bTeamChanged = true;
pPlayer->TeamChangeUpdate(); pPlayer->TeamChangeUpdate();
@ -154,7 +154,7 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItem(const char *pszItemName)
pPlayer->m_bHasDefuser = false; pPlayer->m_bHasDefuser = false;
pPlayer->pev->body = 0; pPlayer->pev->body = 0;
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_HIDE); WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser"); WRITE_STRING("defuser");
MESSAGE_END(); MESSAGE_END();
@ -181,7 +181,7 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItem(const char *pszItemName)
pPlayer->m_iKevlar = ARMOR_NONE; pPlayer->m_iKevlar = ARMOR_NONE;
pPlayer->pev->armorvalue = 0; pPlayer->pev->armorvalue = 0;
MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev); MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, nullptr, pPlayer->pev);
WRITE_BYTE(0); WRITE_BYTE(0);
MESSAGE_END(); MESSAGE_END();
} }

View File

@ -209,7 +209,7 @@ void CBaseAnimating::SetSequenceBox()
Vector rmax(-9999, -9999, -9999); Vector rmax(-9999, -9999, -9999);
Vector base, transformed; Vector base, transformed;
for (int i = 0; i <= 1; ++i) for (int i = 0; i <= 1; i++)
{ {
base.x = bounds[i].x; base.x = bounds[i].x;
for (int j = 0; j <= 1; j++) for (int j = 0; j <= 1; j++)

View File

@ -55,12 +55,12 @@ int LookupActivity(void *pmodel, entvars_t *pev, int activity)
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex);
for (i = 0; i < pstudiohdr->numseq; ++i) for (i = 0; i < pstudiohdr->numseq; i++)
{ {
if (pseqdesc[i].activity == activity) if (pseqdesc[i].activity == activity)
{ {
weightTotal += pseqdesc[i].actweight; weightTotal += pseqdesc[i].actweight;
++activitySequenceCount; activitySequenceCount++;
} }
} }
@ -70,7 +70,7 @@ int LookupActivity(void *pmodel, entvars_t *pev, int activity)
{ {
int which = RANDOM_LONG(0, weightTotal - 1); int which = RANDOM_LONG(0, weightTotal - 1);
for (i = 0; i < pstudiohdr->numseq; ++i) for (i = 0; i < pstudiohdr->numseq; i++)
{ {
if (pseqdesc[i].activity == activity) if (pseqdesc[i].activity == activity)
{ {
@ -87,7 +87,7 @@ int LookupActivity(void *pmodel, entvars_t *pev, int activity)
{ {
select = RANDOM_LONG(0, activitySequenceCount - 1); select = RANDOM_LONG(0, activitySequenceCount - 1);
for (i = 0; i < pstudiohdr->numseq; ++i) for (i = 0; i < pstudiohdr->numseq; i++)
{ {
if (pseqdesc[i].activity == activity) if (pseqdesc[i].activity == activity)
{ {
@ -96,7 +96,7 @@ int LookupActivity(void *pmodel, entvars_t *pev, int activity)
return i; return i;
} }
--select; select--;
} }
} }
} }
@ -118,7 +118,7 @@ int LookupActivityHeaviest(void *pmodel, entvars_t *pev, int activity)
int weight = 0; int weight = 0;
int seq = ACT_INVALID; int seq = ACT_INVALID;
for (int i = 0; i < pstudiohdr->numseq; ++i) for (int i = 0; i < pstudiohdr->numseq; i++)
{ {
if (pseqdesc[i].activity == activity) if (pseqdesc[i].activity == activity)
{ {
@ -161,7 +161,7 @@ int LookupSequence(void *pmodel, const char *label)
// Look up by sequence name. // Look up by sequence name.
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex);
for (int i = 0; i < pstudiohdr->numseq; ++i) for (int i = 0; i < pstudiohdr->numseq; i++)
{ {
if (!Q_stricmp(pseqdesc[i].label, label)) if (!Q_stricmp(pseqdesc[i].label, label))
return i; return i;
@ -196,7 +196,7 @@ NOXREF void SequencePrecache(void *pmodel, const char *pSequenceName)
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index; mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index;
mstudioevent_t *pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); mstudioevent_t *pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex);
for (int i = 0; i < pseqdesc->numevents; ++i) for (int i = 0; i < pseqdesc->numevents; i++)
{ {
// Don't send client-side events to the server AI // Don't send client-side events to the server AI
if (pevent[i].event >= EVENT_CLIENT) if (pevent[i].event >= EVENT_CLIENT)
@ -446,7 +446,7 @@ int FindTransition(void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir)
} }
// look for someone going // look for someone going
for (int i = 0; i < pstudiohdr->numseq; ++i) for (int i = 0; i < pstudiohdr->numseq; i++)
{ {
if (pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode) if (pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode)
{ {
@ -562,8 +562,8 @@ void AngleQuaternion(vec_t *angles, vec_t *quaternion)
#else // REGAMEDLL_FIXES #else // REGAMEDLL_FIXES
void AngleQuaternion(vec_t *angles, vec_t *quaternion) void AngleQuaternion(vec_t *angles, vec_t *quaternion)
{ {
float_precision sy, cy, sp_, cp; real_t sy, cy, sp_, cp;
float_precision angle; real_t angle;
float sr, cr; float sr, cr;
float ftmp0; float ftmp0;
@ -597,10 +597,10 @@ void AngleQuaternion(vec_t *angles, vec_t *quaternion)
void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt) void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt)
{ {
int i; int i;
float_precision a = 0; real_t a = 0;
float_precision b = 0; real_t b = 0;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; i++)
{ {
a += (p[i] - q[i]) * (p[i] - q[i]); a += (p[i] - q[i]) * (p[i] - q[i]);
b += (p[i] + q[i]) * (p[i] + q[i]); b += (p[i] + q[i]) * (p[i] + q[i]);
@ -608,7 +608,7 @@ void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt)
if (a > b) if (a > b)
{ {
for (i = 0; i < 4; ++i) for (i = 0; i < 4; i++)
q[i] = -q[i]; q[i] = -q[i];
} }
@ -619,13 +619,13 @@ void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt)
{ {
if ((1.0 - cosom) > 0.00000001) if ((1.0 - cosom) > 0.00000001)
{ {
float_precision cosomega = Q_acos(float_precision(cosom)); real_t cosomega = Q_acos(real_t(cosom));
float omega = cosomega; float omega = cosomega;
float sinom = Q_sin(cosomega); float sinom = Q_sin(cosomega);
sclp = Q_sin((1.0 - t) * omega) / sinom; sclp = Q_sin((1.0 - t) * omega) / sinom;
sclq = Q_sin(float_precision(omega * t)) / sinom; sclq = Q_sin(real_t(omega * t)) / sinom;
} }
else else
{ {
@ -633,7 +633,7 @@ void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt)
sclp = 1.0 - t; sclp = 1.0 - t;
} }
for (i = 0; i < 4; ++i) for (i = 0; i < 4; i++)
qt[i] = sclp * p[i] + sclq * q[i]; qt[i] = sclp * p[i] + sclq * q[i];
} }
else else
@ -646,7 +646,7 @@ void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt)
sclp = Q_sin((1.0 - t) * 0.5 * M_PI); sclp = Q_sin((1.0 - t) * 0.5 * M_PI);
sclq = Q_sin(t * 0.5 * M_PI); sclq = Q_sin(t * 0.5 * M_PI);
for (i = 0; i < 3; ++i) for (i = 0; i < 3; i++)
qt[i] = sclp * p[i] + sclq * qt[i]; qt[i] = sclp * p[i] + sclq * qt[i];
} }
} }
@ -908,7 +908,7 @@ void StudioSlerpBones(vec4_t *q1, float pos1[][3], vec4_t *q2, float pos2[][3],
s = Q_clamp(s, 0.0f, 1.0f); s = Q_clamp(s, 0.0f, 1.0f);
s1 = 1.0f - s; s1 = 1.0f - s;
for (i = 0; i < g_pstudiohdr->numbones; ++i) for (i = 0; i < g_pstudiohdr->numbones; i++)
{ {
QuaternionSlerp(q1[i], q2[i], s, q3); QuaternionSlerp(q1[i], q2[i], s, q3);
@ -955,12 +955,12 @@ void ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4])
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3]; out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3];
} }
float_precision StudioEstimateFrame(float frame, mstudioseqdesc_t *pseqdesc) real_t StudioEstimateFrame(float frame, mstudioseqdesc_t *pseqdesc)
{ {
if (pseqdesc->numframes <= 1) if (pseqdesc->numframes <= 1)
return 0; return 0;
return float_precision(pseqdesc->numframes - 1) * frame / 256; return real_t(pseqdesc->numframes - 1) * frame / 256;
} }
void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict) void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict)
@ -997,7 +997,7 @@ void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t
{ {
chainlength = g_pstudiohdr->numbones; chainlength = g_pstudiohdr->numbones;
for (i = 0; i < chainlength; ++i) for (i = 0; i < chainlength; i++)
chain[(chainlength - i) - 1] = i; chain[(chainlength - i) - 1] = i;
} }
else else
@ -1018,7 +1018,7 @@ void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t
{ {
if (pseqdesc->numblends > 1) if (pseqdesc->numblends > 1)
{ {
float b = float_precision(pblending[0]) / 255.0f; float b = real_t(pblending[0]) / 255.0f;
panim = StudioGetAnim(pModel, pseqdesc); panim = StudioGetAnim(pModel, pseqdesc);
panim += g_pstudiohdr->numbones; panim += g_pstudiohdr->numbones;
@ -1033,7 +1033,7 @@ void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t
/*static */float pos3[MAXSTUDIOBONES][3], pos4[MAXSTUDIOBONES][3]; /*static */float pos3[MAXSTUDIOBONES][3], pos4[MAXSTUDIOBONES][3];
/*static */float q3[MAXSTUDIOBONES][4], q4[MAXSTUDIOBONES][4]; /*static */float q3[MAXSTUDIOBONES][4], q4[MAXSTUDIOBONES][4];
float_precision s, t; real_t s, t;
s = GetPlayerYaw(pEdict); s = GetPlayerYaw(pEdict);
t = GetPlayerPitch(pEdict); t = GetPlayerPitch(pEdict);
@ -1136,7 +1136,7 @@ void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t
panim = StudioGetAnim(pModel, pseqdesc); panim = StudioGetAnim(pModel, pseqdesc);
StudioCalcRotations(pbones, chain, chainlength, adj, pos2, q2, pseqdesc, panim, 0, 0); StudioCalcRotations(pbones, chain, chainlength, adj, pos2, q2, pseqdesc, panim, 0, 0);
for (i = 0; i < g_pstudiohdr->numbones; ++i) for (i = 0; i < g_pstudiohdr->numbones; i++)
{ {
if (!Q_strcmp(pbones[i].name, "Bip01 Spine")) if (!Q_strcmp(pbones[i].name, "Bip01 Spine"))
{ {

View File

@ -18,6 +18,7 @@ void CBaseMonster::GibMonster()
// throw some human gibs. // throw some human gibs.
CGib::SpawnRandomGibs(pev, 4, 1); CGib::SpawnRandomGibs(pev, 4, 1);
} }
gibbed = true; gibbed = true;
} }
else if (HasAlienGibs()) else if (HasAlienGibs())
@ -28,6 +29,7 @@ void CBaseMonster::GibMonster()
// Throw alien gibs // Throw alien gibs
CGib::SpawnRandomGibs(pev, 4, 0); CGib::SpawnRandomGibs(pev, 4, 0);
} }
gibbed = true; gibbed = true;
} }
@ -40,9 +42,11 @@ void CBaseMonster::GibMonster()
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
else else
{
FadeMonster(); FadeMonster();
} }
} }
}
BOOL CBaseMonster::HasHumanGibs() BOOL CBaseMonster::HasHumanGibs()
{ {
@ -350,7 +354,7 @@ void CBaseMonster::Killed(entvars_t *pevAttacker, int iGib)
} }
else if (pev->flags & FL_MONSTER) else if (pev->flags & FL_MONSTER)
{ {
SetTouch(NULL); SetTouch(nullptr);
BecomeDead(); BecomeDead();
} }
@ -444,9 +448,7 @@ BOOL CBaseMonster::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, f
vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize();
#else #else
// TODO: fix test demo // TODO: fix test demo
vecDir = NormalizeSubtract< vecDir = NormalizeSubtract<real_t, float, real_t, real_t>(Center(), pInflictor->Center() - Vector(0, 0, 10));
float_precision, float, float_precision, float_precision
>(Center(), pInflictor->Center() - Vector(0, 0, 10));
#endif #endif
vecDir = g_vecAttackDir = vecDir.Normalize(); vecDir = g_vecAttackDir = vecDir.Normalize();
} }
@ -568,12 +570,12 @@ BOOL CBaseMonster::DeadTakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacke
float CBaseMonster::DamageForce(float damage) float CBaseMonster::DamageForce(float damage)
{ {
float_precision force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; real_t force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5;
if (force > 1000.0) if (force > 1000.0)
{ {
force = 1000.0; force = 1000.0;
} }
return force; return force;
} }
@ -736,7 +738,7 @@ NOXREF void CBaseMonster::CorpseFallThink()
{ {
if (pev->flags & FL_ONGROUND) if (pev->flags & FL_ONGROUND)
{ {
SetThink(NULL); SetThink(nullptr);
SetSequenceBox(); SetSequenceBox();
// link into world. // link into world.
@ -830,10 +832,10 @@ void CBaseMonster::Look(int iDistance)
// DON'T let visibility information from last frame sit around! // DON'T let visibility information from last frame sit around!
ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT); ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT);
m_pLink = NULL; m_pLink = nullptr;
// the current visible entity that we're dealing with // the current visible entity that we're dealing with
CBaseEntity *pSightEnt = NULL; CBaseEntity *pSightEnt = nullptr;
CBaseEntity *pList[100]; CBaseEntity *pList[100];
Vector delta(iDistance, iDistance, iDistance); Vector delta(iDistance, iDistance, iDistance);
@ -909,10 +911,10 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy()
// so first visible entity will become the closest. // so first visible entity will become the closest.
iNearest = 8192; iNearest = 8192;
pNextEnt = m_pLink; pNextEnt = m_pLink;
pReturn = NULL; pReturn = nullptr;
iBestRelationship = R_NO; iBestRelationship = R_NO;
while (pNextEnt != NULL) while (pNextEnt)
{ {
if (pNextEnt->IsAlive()) if (pNextEnt->IsAlive())
{ {
@ -968,7 +970,7 @@ NOXREF void CBaseMonster::MakeDamageBloodDecal(int cCount, float flNoise, TraceR
} }
} }
for (i = 0; i < cCount; ++i) for (i = 0; i < cCount; i++)
{ {
vecTraceDir = vecDir; vecTraceDir = vecDir;

View File

@ -132,7 +132,7 @@ void CFuncConveyor::Spawn()
void CFuncConveyor::UpdateSpeed(float speed) void CFuncConveyor::UpdateSpeed(float speed)
{ {
// Encode it as an integer with 4 fractional bits // Encode it as an integer with 4 fractional bits
int speedCode = int(Q_fabs(float_precision(speed)) * 16.0); int speedCode = int(Q_fabs(real_t(speed)) * 16.0);
if (speed < 0) if (speed < 0)
pev->rendercolor.x = 1; pev->rendercolor.x = 1;
@ -499,9 +499,9 @@ void CFuncRotating::HurtTouch(CBaseEntity *pOther)
void CFuncRotating::RampPitchVol(BOOL fUp) void CFuncRotating::RampPitchVol(BOOL fUp)
{ {
Vector vecAVel = pev->avelocity; Vector vecAVel = pev->avelocity;
float_precision vecCur; real_t vecCur;
float_precision vecFinal; real_t vecFinal;
float_precision fpct; real_t fpct;
float fvol; float fvol;
float fpitch; float fpitch;
int pitch; int pitch;
@ -733,7 +733,7 @@ void CPendulum::Spawn()
pev->speed = 100; pev->speed = 100;
// Calculate constant acceleration from speed and distance // Calculate constant acceleration from speed and distance
m_accel = (pev->speed * pev->speed) / (2 * Q_fabs(float_precision(m_distance))); m_accel = (pev->speed * pev->speed) / (2 * Q_fabs(real_t(m_distance)));
m_maxSpeed = pev->speed; m_maxSpeed = pev->speed;
m_start = pev->angles; m_start = pev->angles;
m_center = pev->angles + (m_distance * 0.5) * pev->movedir; m_center = pev->angles + (m_distance * 0.5) * pev->movedir;
@ -764,7 +764,7 @@ void CPendulum::PendulumUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
{ {
if (pev->spawnflags & SF_PENDULUM_AUTO_RETURN) if (pev->spawnflags & SF_PENDULUM_AUTO_RETURN)
{ {
float_precision delta; real_t delta;
delta = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start); delta = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start);
@ -776,7 +776,7 @@ void CPendulum::PendulumUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
{ {
// Dead stop // Dead stop
pev->speed = 0; pev->speed = 0;
SetThink(NULL); SetThink(nullptr);
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
} }
} }
@ -796,7 +796,7 @@ void CPendulum::Stop()
{ {
pev->angles = m_start; pev->angles = m_start;
pev->speed = 0; pev->speed = 0;
SetThink(NULL); SetThink(nullptr);
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
} }
@ -845,7 +845,7 @@ void CPendulum::Swing()
{ {
pev->angles = m_center; pev->angles = m_center;
pev->speed = 0; pev->speed = 0;
SetThink(NULL); SetThink(nullptr);
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
} }
else if (pev->speed > m_dampSpeed) else if (pev->speed > m_dampSpeed)

View File

@ -36,30 +36,30 @@ LINK_ENTITY_TO_CLASS(bot, CCSBot, CAPI_CSBot)
#endif #endif
// Return the number of bots following the given player // Return the number of bots following the given player
int GetBotFollowCount(CBasePlayer *leader) int GetBotFollowCount(CBasePlayer *pLeader)
{ {
int count = 0; int count = 0;
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
if (!player->IsBot()) if (!pPlayer->IsBot())
continue; continue;
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
CCSBot *bot = reinterpret_cast<CCSBot *>(player); CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
if (bot->IsBot() && bot->GetFollowLeader() == leader) if (pBot->IsBot() && pBot->GetFollowLeader() == pLeader)
count++; count++;
} }
@ -246,20 +246,20 @@ bool IsIntersectingBox(const Vector &start, const Vector &end, const Vector &box
} }
// When bot is touched by another entity. // When bot is touched by another entity.
void CCSBot::BotTouch(CBaseEntity *other) void CCSBot::BotTouch(CBaseEntity *pOther)
{ {
// if we have touched a higher-priority player, make way // if we have touched a higher-priority player, make way
// TODO: Need to account for reaction time, etc. // TODO: Need to account for reaction time, etc.
if (other->IsPlayer()) if (pOther->IsPlayer())
{ {
// if we are defusing a bomb, don't move // if we are defusing a bomb, don't move
if (IsDefusingBomb()) if (IsDefusingBomb())
return; return;
CBasePlayer *player = static_cast<CBasePlayer *>(other); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pOther);
// get priority of other player // get priority of other player
unsigned int otherPri = TheCSBots()->GetPlayerPriority(player); unsigned int otherPri = TheCSBots()->GetPlayerPriority(pPlayer);
// get our priority // get our priority
unsigned int myPri = TheCSBots()->GetPlayerPriority(this); unsigned int myPri = TheCSBots()->GetPlayerPriority(this);
@ -274,34 +274,34 @@ void CCSBot::BotTouch(CBaseEntity *other)
unsigned int avoidPri = TheCSBots()->GetPlayerPriority(m_avoid); unsigned int avoidPri = TheCSBots()->GetPlayerPriority(m_avoid);
if (avoidPri < otherPri) if (avoidPri < otherPri)
{ {
// ignore 'other' because we're already avoiding someone better // ignore 'pOther' because we're already avoiding someone better
return; return;
} }
} }
m_avoid = static_cast<CBasePlayer *>(other); m_avoid = static_cast<CBasePlayer *>(pOther);
m_avoidTimestamp = gpGlobals->time; m_avoidTimestamp = gpGlobals->time;
return; return;
} }
// If we won't be able to break it, don't try // If we won't be able to break it, don't try
if (other->pev->takedamage != DAMAGE_YES) if (pOther->pev->takedamage != DAMAGE_YES)
return; return;
if (IsAttacking()) if (IsAttacking())
return; return;
// See if it's breakable // See if it's breakable
if (FClassnameIs(other->pev, "func_breakable")) if (FClassnameIs(pOther->pev, "func_breakable"))
{ {
Vector center = (other->pev->absmax + other->pev->absmin) / 2.0f; Vector center = (pOther->pev->absmax + pOther->pev->absmin) / 2.0f;
bool breakIt = true; bool breakIt = true;
if (m_pathLength) if (m_pathLength)
{ {
Vector goal = m_goalPosition + Vector(0, 0, HalfHumanHeight); Vector goal = m_goalPosition + Vector(0, 0, HalfHumanHeight);
breakIt = IsIntersectingBox(pev->origin, goal, other->pev->absmin, other->pev->absmax); breakIt = IsIntersectingBox(pev->origin, goal, pOther->pev->absmin, pOther->pev->absmax);
} }
if (breakIt) if (breakIt)
@ -361,11 +361,11 @@ CBasePlayer *CCSBot::FindNearbyPlayer()
} }
// Assign given player as our current enemy to attack // Assign given player as our current enemy to attack
void CCSBot::SetEnemy(CBasePlayer *enemy) void CCSBot::SetEnemy(CBasePlayer *pEnemy)
{ {
if (m_enemy != enemy) if (m_enemy != pEnemy)
{ {
m_enemy = enemy; m_enemy = pEnemy;
m_currentEnemyAcquireTimestamp = gpGlobals->time; m_currentEnemyAcquireTimestamp = gpGlobals->time;
} }
} }
@ -420,7 +420,7 @@ bool CCSBot::StayOnNavMesh()
return false; return false;
} }
void CCSBot::Panic(CBasePlayer *enemy) void CCSBot::Panic(CBasePlayer *pEnemy)
{ {
if (IsSurprised()) if (IsSurprised())
return; return;
@ -431,7 +431,7 @@ void CCSBot::Panic(CBasePlayer *enemy)
if (GetProfile()->GetSkill() >= 0.5f) if (GetProfile()->GetSkill() >= 0.5f)
{ {
Vector2D toEnemy = (enemy->pev->origin - pev->origin).Make2D(); Vector2D toEnemy = (pEnemy->pev->origin - pev->origin).Make2D();
toEnemy.NormalizeInPlace(); toEnemy.NormalizeInPlace();
float along = DotProduct(toEnemy, dir); float along = DotProduct(toEnemy, dir);
@ -439,7 +439,7 @@ void CCSBot::Panic(CBasePlayer *enemy)
float c45 = 0.7071f; float c45 = 0.7071f;
float size = 100.0f; float size = 100.0f;
float_precision shift = RANDOM_FLOAT(-75.0, 75.0); real_t shift = RANDOM_FLOAT(-75.0, 75.0);
if (along > c45) if (along > c45)
{ {
@ -465,7 +465,7 @@ void CCSBot::Panic(CBasePlayer *enemy)
else else
{ {
const float offset = 200.0f; const float offset = 200.0f;
float_precision side = RANDOM_FLOAT(-offset, offset) * 2.0f; real_t side = RANDOM_FLOAT(-offset, offset) * 2.0f;
spot.x = pev->origin.x - dir.x * offset + perp.x * side; spot.x = pev->origin.x - dir.x * offset + perp.x * side;
spot.y = pev->origin.y - dir.y * offset + perp.y * side; spot.y = pev->origin.y - dir.y * offset + perp.y * side;
@ -619,18 +619,18 @@ void CCSBot::UpdateHostageEscortCount()
// recount the hostages in case we lost some // recount the hostages in case we lost some
m_hostageEscortCount = 0; m_hostageEscortCount = 0;
CHostage *hostage = nullptr; CHostage *pHostage = nullptr;
while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (FNullEnt(hostage->edict())) if (FNullEnt(pHostage->edict()))
break; break;
// skip dead or rescued hostages // skip dead or rescued hostages
if (!hostage->IsAlive()) if (!pHostage->IsAlive())
continue; continue;
// check if hostage has targeted us, and is following // check if hostage has targeted us, and is following
if (hostage->IsFollowing(this)) if (pHostage->IsFollowing(this))
m_hostageEscortCount++; m_hostageEscortCount++;
} }
} }
@ -660,43 +660,43 @@ CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) const
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
// is it a player? // is it a player?
if (!player->IsPlayer()) if (!pPlayer->IsPlayer())
continue; continue;
// is it alive? // is it alive?
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
// skip friends // skip friends
if (BotRelationship(player) == BOT_TEAMMATE) if (BotRelationship(pPlayer) == BOT_TEAMMATE)
continue; continue;
// is it "important" // is it "important"
if (!TheCSBots()->IsImportantPlayer(player)) if (!TheCSBots()->IsImportantPlayer(pPlayer))
continue; continue;
// is it closest? // is it closest?
Vector d = pev->origin - player->pev->origin; Vector d = pev->origin - pPlayer->pev->origin;
float distSq = d.x * d.x + d.y * d.y + d.z * d.z; float distSq = d.x * d.x + d.y * d.y + d.z * d.z;
if (distSq < nearDist) if (distSq < nearDist)
{ {
if (checkVisibility && !IsVisible(player, CHECK_FOV)) if (checkVisibility && !IsVisible(pPlayer, CHECK_FOV))
continue; continue;
nearEnemy = player; nearEnemy = pPlayer;
nearDist = distSq; nearDist = distSq;
} }
} }

View File

@ -247,7 +247,7 @@ public:
virtual void OnExit(CCSBot *me); virtual void OnExit(CCSBot *me);
virtual const char *GetName() const { return "Follow"; } virtual const char *GetName() const { return "Follow"; }
void SetLeader(CBasePlayer *leader) { m_leader = leader; } void SetLeader(CBasePlayer *pLeader) { m_leader = pLeader; }
private: private:
void ComputeLeaderMotionState(float leaderSpeed); void ComputeLeaderMotionState(float leaderSpeed);
@ -287,7 +287,7 @@ public:
virtual void OnExit(CCSBot *me); virtual void OnExit(CCSBot *me);
virtual const char *GetName() const { return "UseEntity"; } virtual const char *GetName() const { return "UseEntity"; }
void SetEntity(CBaseEntity *entity) { m_entity = entity; } void SetEntity(CBaseEntity *pEntity) { m_entity = pEntity; }
private: private:
EntityHandle<CBaseEntity> m_entity; EntityHandle<CBaseEntity> m_entity;
@ -313,11 +313,11 @@ public:
virtual void Walk(); virtual void Walk();
virtual bool Jump(bool mustJump = false); // returns true if jump was started virtual bool Jump(bool mustJump = false); // returns true if jump was started
virtual void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); // invoked when event occurs in the game (some events have NULL entity) virtual void OnEvent(GameEventType event, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr); // invoked when event occurs in the game (some events have NULL entity)
#define CHECK_FOV true #define CHECK_FOV true
virtual bool IsVisible(const Vector *pos, bool testFOV = false) const; // return true if we can see the point virtual bool IsVisible(const Vector *pos, bool testFOV = false) const; // return true if we can see the point
virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = nullptr) const; // return true if we can see any part of the player virtual bool IsVisible(CBasePlayer *pPlayer, bool testFOV = false, unsigned char *visParts = nullptr) const; // return true if we can see any part of the player
virtual bool IsEnemyPartVisible(VisiblePartType part) const; // if enemy is visible, return the part we see for our current enemy virtual bool IsEnemyPartVisible(VisiblePartType part) const; // if enemy is visible, return the part we see for our current enemy
@ -374,12 +374,12 @@ public:
bool IsEscapingFromBomb() const; // return true if we are escaping from the bomb bool IsEscapingFromBomb() const; // return true if we are escaping from the bomb
void RescueHostages(); void RescueHostages();
void UseEntity(CBaseEntity *entity); // use the entity void UseEntity(CBaseEntity *pEntity); // use the entity
bool IsBuying() const; bool IsBuying() const;
void Panic(CBasePlayer *enemy); // look around in panic void Panic(CBasePlayer *pEnemy); // look around in panic
void Follow(CBasePlayer *player); // begin following given Player void Follow(CBasePlayer *pPlayer); // begin following given Player
void ContinueFollowing(); // continue following our leader after finishing what we were doing void ContinueFollowing(); // continue following our leader after finishing what we were doing
void StopFollowing(); // stop following void StopFollowing(); // stop following
bool IsFollowing() const; // return true if we are following someone (not necessarily in the follow state) bool IsFollowing() const; // return true if we are following someone (not necessarily in the follow state)
@ -437,7 +437,7 @@ public:
NUM_TASKS NUM_TASKS
}; };
void SetTask(TaskType task, CBaseEntity *entity = nullptr); // set our current "task" void SetTask(TaskType task, CBaseEntity *pEntity = nullptr); // set our current "task"
TaskType GetTask() const; TaskType GetTask() const;
CBaseEntity *GetTaskEntity(); CBaseEntity *GetTaskEntity();
@ -495,7 +495,7 @@ public:
// enemies // enemies
// BOTPORT: GetEnemy() collides with GetEnemy() in CBaseEntity - need to use different nomenclature // BOTPORT: GetEnemy() collides with GetEnemy() in CBaseEntity - need to use different nomenclature
void SetEnemy(CBasePlayer *enemy); // set given player as our current enemy void SetEnemy(CBasePlayer *pEnemy); // set given player as our current enemy
CBasePlayer *GetEnemy(); CBasePlayer *GetEnemy();
int GetNearbyEnemyCount() const; // return max number of nearby enemies we've seen recently int GetNearbyEnemyCount() const; // return max number of nearby enemies we've seen recently
unsigned int GetEnemyPlace() const; // return location where we see the majority of our enemies unsigned int GetEnemyPlace() const; // return location where we see the majority of our enemies
@ -563,7 +563,7 @@ public:
bool IsUsingLadder() const; // returns true if we are in the process of negotiating a ladder bool IsUsingLadder() const; // returns true if we are in the process of negotiating a ladder
void GetOffLadder(); void GetOffLadder();
void SetGoalEntity(CBaseEntity *entity); void SetGoalEntity(CBaseEntity *pEntity);
template <typename T = CBaseEntity> template <typename T = CBaseEntity>
T *GetGoalEntity(); T *GetGoalEntity();
@ -654,7 +654,7 @@ public:
void BotDeathThink(); void BotDeathThink();
CBasePlayer *FindNearbyPlayer(); CBasePlayer *FindNearbyPlayer();
void AdjustSafeTime(); // called when enemy seen to adjust safe time for this round void AdjustSafeTime(); // called when enemy seen to adjust safe time for this round
void EXPORT BotTouch(CBaseEntity *other); void EXPORT BotTouch(CBaseEntity *pOther);
bool HasAnyAmmo(CBasePlayerWeapon *weapon) const; bool HasAnyAmmo(CBasePlayerWeapon *weapon) const;
private: private:
@ -1000,7 +1000,7 @@ private:
void StartNormalProcess(); void StartNormalProcess();
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
bool IsNoticable(const CBasePlayer *player, unsigned char visibleParts) const; // return true if we "notice" given player bool IsNoticable(const CBasePlayer *pPlayer, unsigned char visibleParts) const; // return true if we "notice" given player
#endif #endif
}; };
@ -1124,10 +1124,10 @@ inline bool CCSBot::IsNoiseHeard() const
return false; return false;
} }
inline void CCSBot::SetTask(TaskType task, CBaseEntity *entity) inline void CCSBot::SetTask(TaskType task, CBaseEntity *pEntity)
{ {
m_task = task; m_task = task;
m_taskEntity = entity; m_taskEntity = pEntity;
} }
inline CCSBot::TaskType CCSBot::GetTask() const inline CCSBot::TaskType CCSBot::GetTask() const
@ -1281,9 +1281,9 @@ inline bool CCSBot::IsUsingLadder() const
return m_pathLadder != nullptr; return m_pathLadder != nullptr;
} }
inline void CCSBot::SetGoalEntity(CBaseEntity *entity) inline void CCSBot::SetGoalEntity(CBaseEntity *pEntity)
{ {
m_goalEntity = entity; m_goalEntity = pEntity;
} }
template <typename T> template <typename T>
@ -1393,7 +1393,7 @@ inline int CCSBot::GetHostageEscortCount() const
inline void CCSBot::IncreaseHostageEscortCount() inline void CCSBot::IncreaseHostageEscortCount()
{ {
++m_hostageEscortCount; m_hostageEscortCount++;
} }
inline void CCSBot::ResetWaitForHostagePatience() inline void CCSBot::ResetWaitForHostagePatience()
@ -1464,12 +1464,8 @@ public:
bool operator()(CNavArea *area) bool operator()(CNavArea *area)
{ {
// collect all the hiding spots in this area // collect all the hiding spots in this area
const HidingSpotList *list = area->GetHidingSpotList(); for (auto const spot : *area->GetHidingSpotList())
for (HidingSpotList::const_iterator iter = list->begin(); iter != list->end(); ++iter)
{ {
const HidingSpot *spot = (*iter);
if (m_count >= MAX_SPOTS) if (m_count >= MAX_SPOTS)
break; break;
@ -1545,9 +1541,9 @@ public:
class PathCost class PathCost
{ {
public: public:
PathCost(CCSBot *bot, RouteType route = SAFEST_ROUTE) PathCost(CCSBot *pBot, RouteType route = SAFEST_ROUTE)
{ {
m_bot = bot; m_bot = pBot;
m_route = route; m_route = route;
} }
float operator()(CNavArea *area, CNavArea *fromArea, const CNavLadder *ladder) float operator()(CNavArea *area, CNavArea *fromArea, const CNavLadder *ladder)
@ -1632,7 +1628,7 @@ public:
if (area->GetAttributes() & NAV_CROUCH) if (area->GetAttributes() & NAV_CROUCH)
{ {
// these areas are very slow to move through // these areas are very slow to move through
float_precision crouchPenalty = (m_route == FASTEST_ROUTE) ? 20.0f : 5.0f; real_t crouchPenalty = (m_route == FASTEST_ROUTE) ? 20.0f : 5.0f;
// avoid crouch areas if we are rescuing hostages // avoid crouch areas if we are rescuing hostages
if (m_bot->GetHostageEscortCount()) if (m_bot->GetHostageEscortCount())
@ -1643,15 +1639,6 @@ public:
cost += crouchPenalty * dist; cost += crouchPenalty * dist;
} }
// if this is a "walk" area, add penalty
if (area->GetAttributes() & NAV_WALK)
{
// these areas are kinda slow to move through
float_precision walkPenalty = (m_route == FASTEST_ROUTE) ? 2.5f : 1.5f;
cost += walkPenalty * dist;
}
// if this is a "jump" area, add penalty // if this is a "jump" area, add penalty
if (area->GetAttributes() & NAV_JUMP) if (area->GetAttributes() & NAV_JUMP)
{ {
@ -1696,19 +1683,19 @@ private:
class FollowTargetCollector class FollowTargetCollector
{ {
public: public:
FollowTargetCollector(CBasePlayer *player) FollowTargetCollector(CBasePlayer *pPlayer)
{ {
m_player = player; m_player = pPlayer;
m_forward.x = player->pev->velocity.x; m_forward.x = pPlayer->pev->velocity.x;
m_forward.y = player->pev->velocity.y; m_forward.y = pPlayer->pev->velocity.y;
float speed = m_forward.NormalizeInPlace(); float speed = m_forward.NormalizeInPlace();
const float walkSpeed = 100.0f; const float walkSpeed = 100.0f;
if (speed < walkSpeed) if (speed < walkSpeed)
{ {
m_cutoff.x = player->pev->origin.x; m_cutoff.x = pPlayer->pev->origin.x;
m_cutoff.y = player->pev->origin.y; m_cutoff.y = pPlayer->pev->origin.y;
m_forward.x = 0.0f; m_forward.x = 0.0f;
m_forward.y = 0.0f; m_forward.y = 0.0f;
@ -1716,10 +1703,10 @@ public:
else else
{ {
const float k = 1.5f; const float k = 1.5f;
float_precision trimSpeed = (speed < 200.0f) ? speed : 200.0f; real_t trimSpeed = (speed < 200.0f) ? speed : 200.0f;
m_cutoff.x = player->pev->origin.x + k * trimSpeed * m_forward.x; m_cutoff.x = pPlayer->pev->origin.x + k * trimSpeed * m_forward.x;
m_cutoff.y = player->pev->origin.y + k * trimSpeed * m_forward.y; m_cutoff.y = pPlayer->pev->origin.y + k * trimSpeed * m_forward.y;
} }
m_targetAreaCount = 0; m_targetAreaCount = 0;
@ -1744,11 +1731,12 @@ public:
Vector2D to(((*area->GetCenter()).x - m_cutoff.x), (*area->GetCenter()).y - m_cutoff.y); Vector2D to(((*area->GetCenter()).x - m_cutoff.x), (*area->GetCenter()).y - m_cutoff.y);
to.NormalizeInPlace(); to.NormalizeInPlace();
//if (DotProduct(to, m_forward) > 0.7071f) if (DotProduct(to, m_forward) > 0.7071f)
if ((to.x * m_forward.x + to.y * m_forward.y) > 0.7071f) {
m_targetArea[m_targetAreaCount++] = area; m_targetArea[m_targetAreaCount++] = area;
} }
} }
}
return (m_targetAreaCount < MAX_TARGET_AREAS); return (m_targetAreaCount < MAX_TARGET_AREAS);
} }
@ -1763,7 +1751,7 @@ public:
void InstallBotControl(); void InstallBotControl();
void Bot_ServerCommand(); void Bot_ServerCommand();
void Bot_RegisterCVars(); void Bot_RegisterCVars();
int GetBotFollowCount(CBasePlayer *leader); int GetBotFollowCount(CBasePlayer *pLeader);
const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange); const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange);
void drawProgressMeter(float progress, char *title); void drawProgressMeter(float progress, char *title);

View File

@ -59,93 +59,93 @@ const Vector *GetRandomSpotAtPlace(Place place)
} }
// Transmit meme to other bots // Transmit meme to other bots
void BotMeme::Transmit(CCSBot *sender) const void BotMeme::Transmit(CCSBot *pSender) const
{ {
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
// skip self // skip self
if (sender == player) if (pSender == pPlayer)
continue; continue;
// ignore dead humans // ignore dead humans
if (!player->IsBot() && !player->IsAlive()) if (!pPlayer->IsBot() && !pPlayer->IsAlive())
continue; continue;
// ignore enemies, since we can't hear them talk // ignore enemies, since we can't hear them talk
if (sender->BotRelationship(player) == CCSBot::BOT_ENEMY) if (pSender->BotRelationship(pPlayer) == CCSBot::BOT_ENEMY)
continue; continue;
// if not a bot, fail the test // if not a bot, fail the test
if (!player->IsBot()) if (!pPlayer->IsBot())
continue; continue;
// allow bot to interpret our meme // allow bot to interpret our meme
Interpret(sender, (CCSBot *)player); Interpret(pSender, (CCSBot *)pPlayer);
} }
} }
// A teammate called for help - respond // A teammate called for help - respond
void BotHelpMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotHelpMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
const float maxHelpRange = 3000.0f; // 2000 const float maxHelpRange = 3000.0f; // 2000
receiver->RespondToHelpRequest(sender, m_place, maxHelpRange); pReceiver->RespondToHelpRequest(pSender, m_place, maxHelpRange);
} }
// A teammate reported information about a bombsite // A teammate reported information about a bombsite
void BotBombsiteStatusMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotBombsiteStatusMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
// remember this bombsite's status // remember this bombsite's status
if (m_status == CLEAR) if (m_status == CLEAR)
receiver->GetGameState()->ClearBombsite(m_zoneIndex); pReceiver->GetGameState()->ClearBombsite(m_zoneIndex);
else else
receiver->GetGameState()->MarkBombsiteAsPlanted(m_zoneIndex); pReceiver->GetGameState()->MarkBombsiteAsPlanted(m_zoneIndex);
// if we were heading to the just-cleared bombsite, pick another one to search // if we were heading to the just-cleared bombsite, pick another one to search
// if our target bombsite wasn't cleared, will will continue going to it, // if our target bombsite wasn't cleared, will will continue going to it,
// because GetNextBombsiteToSearch() will return the same zone (since its not cleared) // because GetNextBombsiteToSearch() will return the same zone (since its not cleared)
// if the bomb was planted, we will head to that bombsite // if the bomb was planted, we will head to that bombsite
if (receiver->GetTask() == CCSBot::FIND_TICKING_BOMB) if (pReceiver->GetTask() == CCSBot::FIND_TICKING_BOMB)
{ {
receiver->Idle(); pReceiver->Idle();
receiver->GetChatter()->Affirmative(); pReceiver->GetChatter()->Affirmative();
} }
} }
// A teammate reported information about the bomb // A teammate reported information about the bomb
void BotBombStatusMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotBombStatusMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
// update our gamestate based on teammate's report // update our gamestate based on teammate's report
switch (m_state) switch (m_state)
{ {
case CSGameState::MOVING: case CSGameState::MOVING:
{ {
receiver->GetGameState()->UpdateBomber(&m_pos); pReceiver->GetGameState()->UpdateBomber(&m_pos);
// if we are hunting and see no enemies, respond // if we are hunting and see no enemies, respond
if (!receiver->IsRogue() && receiver->IsHunting() && receiver->GetNearbyEnemyCount() == 0) if (!pReceiver->IsRogue() && pReceiver->IsHunting() && pReceiver->GetNearbyEnemyCount() == 0)
receiver->RespondToHelpRequest(sender, TheNavAreaGrid.GetPlace(&m_pos)); pReceiver->RespondToHelpRequest(pSender, TheNavAreaGrid.GetPlace(&m_pos));
break; break;
} }
case CSGameState::LOOSE: case CSGameState::LOOSE:
{ {
receiver->GetGameState()->UpdateLooseBomb(&m_pos); pReceiver->GetGameState()->UpdateLooseBomb(&m_pos);
if (receiver->GetTask() == CCSBot::GUARD_BOMB_ZONE) if (pReceiver->GetTask() == CCSBot::GUARD_BOMB_ZONE)
{ {
receiver->Idle(); pReceiver->Idle();
receiver->GetChatter()->Affirmative(); pReceiver->GetChatter()->Affirmative();
} }
break; break;
} }
@ -153,17 +153,17 @@ void BotBombStatusMeme::Interpret(CCSBot *sender, CCSBot *receiver) const
} }
// A teammate has asked that we follow him // A teammate has asked that we follow him
void BotFollowMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotFollowMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
if (receiver->IsRogue()) if (pReceiver->IsRogue())
return; return;
// if we're busy, ignore // if we're busy, ignore
if (receiver->IsBusy()) if (pReceiver->IsBusy())
return; return;
PathCost pathCost(receiver); PathCost pathCost(pReceiver);
float travelDistance = NavAreaTravelDistance(receiver->GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&sender->pev->origin), pathCost); float travelDistance = NavAreaTravelDistance(pReceiver->GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&pSender->pev->origin), pathCost);
if (travelDistance < 0.0f) if (travelDistance < 0.0f)
return; return;
@ -172,80 +172,81 @@ void BotFollowMeme::Interpret(CCSBot *sender, CCSBot *receiver) const
return; return;
// begin following // begin following
receiver->Follow(sender); pReceiver->Follow(pSender);
// acknowledge // acknowledge
receiver->GetChatter()->Say("CoveringFriend"); pReceiver->GetChatter()->Say("CoveringFriend");
} }
// A teammate has asked us to defend a place // A teammate has asked us to defend a place
void BotDefendHereMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotDefendHereMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
if (receiver->IsRogue()) if (pReceiver->IsRogue())
return; return;
// if we're busy, ignore // if we're busy, ignore
if (receiver->IsBusy()) if (pReceiver->IsBusy())
return; return;
Place place = TheNavAreaGrid.GetPlace(&m_pos); Place place = TheNavAreaGrid.GetPlace(&m_pos);
if (place != UNDEFINED_PLACE) if (place != UNDEFINED_PLACE)
{ {
// pick a random hiding spot in this place // pick a random hiding spot in this place
const Vector *spot = FindRandomHidingSpot(receiver, place, receiver->IsSniper()); const Vector *spot = FindRandomHidingSpot(pReceiver, place, pReceiver->IsSniper());
if (spot) if (spot)
{ {
receiver->SetTask(CCSBot::HOLD_POSITION); pReceiver->SetTask(CCSBot::HOLD_POSITION);
receiver->Hide(spot); pReceiver->Hide(spot);
return; return;
} }
} }
// hide nearby // hide nearby
receiver->SetTask(CCSBot::HOLD_POSITION); pReceiver->SetTask(CCSBot::HOLD_POSITION);
receiver->Hide(TheNavAreaGrid.GetNearestNavArea(&m_pos)); pReceiver->Hide(TheNavAreaGrid.GetNearestNavArea(&m_pos));
// acknowledge // acknowledge
receiver->GetChatter()->Say("Affirmative"); pReceiver->GetChatter()->Say("Affirmative");
} }
// A teammate has asked where the bomb is planted // A teammate has asked where the bomb is planted
void BotWhereBombMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotWhereBombMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
int zone = receiver->GetGameState()->GetPlantedBombsite(); int zone = pReceiver->GetGameState()->GetPlantedBombsite();
if (zone != CSGameState::UNKNOWN) if (zone != CSGameState::UNKNOWN)
receiver->GetChatter()->FoundPlantedBomb(zone); {
pReceiver->GetChatter()->FoundPlantedBomb(zone);
}
} }
// A teammate has asked us to report in // A teammate has asked us to report in
void BotRequestReportMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotRequestReportMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
receiver->GetChatter()->ReportingIn(); pReceiver->GetChatter()->ReportingIn();
} }
// A teammate told us all the hostages are gone // A teammate told us all the hostages are gone
void BotAllHostagesGoneMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotAllHostagesGoneMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
receiver->GetGameState()->AllHostagesGone(); pReceiver->GetGameState()->AllHostagesGone();
// acknowledge // acknowledge
receiver->GetChatter()->Say("Affirmative"); pReceiver->GetChatter()->Say("Affirmative");
} }
// A teammate told us a CT is talking to a hostage // A teammate told us a CT is talking to a hostage
void BotHostageBeingTakenMeme::Interpret(CCSBot *sender, CCSBot *receiver) const void BotHostageBeingTakenMeme::Interpret(CCSBot *pSender, CCSBot *pReceiver) const
{ {
receiver->GetGameState()->HostageWasTaken(); pReceiver->GetGameState()->HostageWasTaken();
// if we're busy, ignore // if we're busy, ignore
if (receiver->IsBusy()) if (pReceiver->IsBusy())
return; return;
receiver->Idle(); pReceiver->Idle();
// acknowledge // acknowledge
receiver->GetChatter()->Say("Affirmative"); pReceiver->GetChatter()->Say("Affirmative");
} }
BotSpeakable::BotSpeakable() BotSpeakable::BotSpeakable()
@ -1405,7 +1406,7 @@ void BotChatterInterface::ReportEnemies()
} }
} }
void BotChatterInterface::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void BotChatterInterface::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
; ;
} }
@ -1521,32 +1522,32 @@ BotStatement *BotChatterInterface::GetActiveStatement()
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
// ignore dead humans // ignore dead humans
if (!player->IsBot() && !player->IsAlive()) if (!pPlayer->IsBot() && !pPlayer->IsAlive())
continue; continue;
// ignore enemies, since we can't hear them talk // ignore enemies, since we can't hear them talk
if (m_me->BotRelationship(player) == CCSBot::BOT_ENEMY) if (m_me->BotRelationship(pPlayer) == CCSBot::BOT_ENEMY)
continue; continue;
// if not a bot, fail the test // if not a bot, fail the test
// TODO: Check if human is currently talking // TODO: Check if human is currently talking
if (!player->IsBot()) if (!pPlayer->IsBot())
continue; continue;
CCSBot *bot = reinterpret_cast<CCSBot *>(player); CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
auto say = bot->GetChatter()->m_statementList; auto say = pBot->GetChatter()->m_statementList;
while (say) while (say)
{ {
// if this statement is currently being spoken, return it // if this statement is currently being spoken, return it

View File

@ -44,22 +44,22 @@ typedef unsigned int CountCriteria;
class BotMeme class BotMeme
{ {
public: public:
void Transmit(CCSBot *sender) const; // transmit meme to other bots void Transmit(CCSBot *pSender) const; // transmit meme to other bots
virtual ~BotMeme(){} virtual ~BotMeme(){}
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const = 0; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const = 0; // cause the given bot to act on this meme
}; };
class BotAllHostagesGoneMeme: public BotMeme class BotAllHostagesGoneMeme: public BotMeme
{ {
public: public:
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
}; };
class BotHostageBeingTakenMeme: public BotMeme class BotHostageBeingTakenMeme: public BotMeme
{ {
public: public:
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
}; };
class BotHelpMeme: public BotMeme class BotHelpMeme: public BotMeme
@ -69,7 +69,7 @@ public:
{ {
m_place = place; m_place = place;
} }
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
private: private:
Place m_place; Place m_place;
@ -85,7 +85,7 @@ public:
m_zoneIndex = zoneIndex; m_zoneIndex = zoneIndex;
m_status = status; m_status = status;
} }
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
private: private:
int m_zoneIndex; // the bombsite int m_zoneIndex; // the bombsite
@ -102,7 +102,7 @@ public:
} }
public: public:
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
private: private:
CSGameState::BombState m_state; CSGameState::BombState m_state;
@ -112,7 +112,7 @@ private:
class BotFollowMeme: public BotMeme class BotFollowMeme: public BotMeme
{ {
public: public:
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
}; };
class BotDefendHereMeme: public BotMeme class BotDefendHereMeme: public BotMeme
@ -122,7 +122,7 @@ public:
{ {
m_pos = pos; m_pos = pos;
} }
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
private: private:
Vector m_pos; Vector m_pos;
@ -131,13 +131,13 @@ private:
class BotWhereBombMeme: public BotMeme class BotWhereBombMeme: public BotMeme
{ {
public: public:
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
}; };
class BotRequestReportMeme: public BotMeme class BotRequestReportMeme: public BotMeme
{ {
public: public:
virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme virtual void Interpret(CCSBot *pSender, CCSBot *pReceiver) const; // cause the given bot to act on this meme
}; };
enum BotStatementType enum BotStatementType
@ -296,7 +296,7 @@ private:
inline int BotPhraseManager::FindPlaceIndex(Place where) const inline int BotPhraseManager::FindPlaceIndex(Place where) const
{ {
for (int i = 0; i < m_placeCount; ++i) for (int i = 0; i < m_placeCount; i++)
{ {
if (m_placeStatementHistory[i].placeID == where) if (m_placeStatementHistory[i].placeID == where)
return i; return i;
@ -449,7 +449,7 @@ public:
void Reset(); // reset to initial state void Reset(); // reset to initial state
void Update(); // process ongoing chatter void Update(); // process ongoing chatter
void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); // invoked when event occurs in the game (some events have NULL entities) void OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther); // invoked when event occurs in the game (some events have NULL entities)
void OnDeath(); // invoked when we die void OnDeath(); // invoked when we die
enum VerbosityType enum VerbosityType

View File

@ -28,10 +28,10 @@
#include "precompiled.h" #include "precompiled.h"
void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CCSBot::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
GetGameState()->OnEvent(event, entity, other); GetGameState()->OnEvent(event, pEntity, pOther);
GetChatter()->OnEvent(event, entity, other); GetChatter()->OnEvent(event, pEntity, pOther);
// Morale adjustments happen even for dead players // Morale adjustments happen even for dead players
switch (event) switch (event)
@ -61,7 +61,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
if (!IsAlive()) if (!IsAlive())
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
// If we just saw a nearby friend die, and we haven't yet acquired an enemy // If we just saw a nearby friend die, and we haven't yet acquired an enemy
// automatically acquire our dead friend's killer // automatically acquire our dead friend's killer
@ -71,7 +71,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
{ {
if (BotRelationship(pPlayer) == BOT_TEAMMATE) if (BotRelationship(pPlayer) == BOT_TEAMMATE)
{ {
CBasePlayer *pKiller = static_cast<CBasePlayer *>(other); CBasePlayer *pKiller = static_cast<CBasePlayer *>(pOther);
// check that attacker is an enemy (for friendly fire, etc) // check that attacker is an enemy (for friendly fire, etc)
if (pKiller && pKiller->IsPlayer()) if (pKiller && pKiller->IsPlayer())
@ -102,7 +102,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
case EVENT_PLAYER_DIED: case EVENT_PLAYER_DIED:
{ {
CBasePlayer *pVictim = pPlayer; CBasePlayer *pVictim = pPlayer;
CBasePlayer *pKiller = (other && other->IsPlayer()) ? static_cast<CBasePlayer *>(other) : nullptr; CBasePlayer *pKiller = (pOther && pOther->IsPlayer()) ? static_cast<CBasePlayer *>(pOther) : nullptr;
// if the human player died in the single player game, tell the team // if the human player died in the single player game, tell the team
if (CSGameRules()->IsCareer() && !pVictim->IsBot() && BotRelationship(pVictim) == BOT_TEAMMATE) if (CSGameRules()->IsCareer() && !pVictim->IsBot() && BotRelationship(pVictim) == BOT_TEAMMATE)
@ -218,12 +218,12 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
{ {
// check if we're close enough to hear it // check if we're close enough to hear it
const float bombBeepHearRangeSq = 1000.0f * 1000.0f; const float bombBeepHearRangeSq = 1000.0f * 1000.0f;
if ((pev->origin - entity->pev->origin).LengthSquared() < bombBeepHearRangeSq) if ((pev->origin - pEntity->pev->origin).LengthSquared() < bombBeepHearRangeSq)
{ {
// radio the news to our team // radio the news to our team
if (m_iTeam == CT && GetGameState()->GetPlantedBombsite() == CSGameState::UNKNOWN) if (m_iTeam == CT && GetGameState()->GetPlantedBombsite() == CSGameState::UNKNOWN)
{ {
const CCSBotManager::Zone *zone = TheCSBots()->GetZone(&entity->pev->origin); const CCSBotManager::Zone *zone = TheCSBots()->GetZone(&pEntity->pev->origin);
if (zone) if (zone)
{ {
GetChatter()->FoundPlantedBomb(zone->m_index); GetChatter()->FoundPlantedBomb(zone->m_index);
@ -231,7 +231,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
} }
// remember where the bomb is // remember where the bomb is
GetGameState()->UpdatePlantedBomb(&entity->pev->origin); GetGameState()->UpdatePlantedBomb(&pEntity->pev->origin);
} }
} }
return; return;
@ -251,7 +251,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
Idle(); Idle();
} }
OnEvent(EVENT_BOMB_BEEP, other); OnEvent(EVENT_BOMB_BEEP, pOther);
return; return;
} }
case EVENT_BOMB_DEFUSE_ABORTED: case EVENT_BOMB_DEFUSE_ABORTED:
@ -261,7 +261,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
case EVENT_WEAPON_FIRED_ON_EMPTY: case EVENT_WEAPON_FIRED_ON_EMPTY:
case EVENT_WEAPON_RELOADED: case EVENT_WEAPON_RELOADED:
{ {
if (m_enemy == entity && IsUsingKnife()) if (m_enemy == pEntity && IsUsingKnife())
ForceRun(5.0f); ForceRun(5.0f);
break; break;
} }
@ -288,18 +288,18 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
if (!IsRogue() && event == EVENT_HOSTAGE_CALLED_FOR_HELP && m_iTeam == CT && IsHunting()) if (!IsRogue() && event == EVENT_HOSTAGE_CALLED_FOR_HELP && m_iTeam == CT && IsHunting())
{ {
if ((entity->pev->origin - pev->origin).IsLengthGreaterThan(1000.0f)) if ((pEntity->pev->origin - pev->origin).IsLengthGreaterThan(1000.0f))
return; return;
if (IsVisible(&entity->Center())) if (IsVisible(&pEntity->Center()))
{ {
m_task = COLLECT_HOSTAGES; m_task = COLLECT_HOSTAGES;
m_taskEntity = nullptr; m_taskEntity = nullptr;
Run(); Run();
m_goalEntity = entity; m_goalEntity = pEntity;
MoveTo(&entity->pev->origin, m_hostageEscortCount == 0 ? SAFEST_ROUTE : FASTEST_ROUTE); MoveTo(&pEntity->pev->origin, m_hostageEscortCount == 0 ? SAFEST_ROUTE : FASTEST_ROUTE);
PrintIfWatched("I'm fetching a hostage that called out to me\n"); PrintIfWatched("I'm fetching a hostage that called out to me\n");
return; return;
@ -314,7 +314,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
PriorityType priority; PriorityType priority;
bool isHostile; bool isHostile;
if (IsGameEventAudible(event, entity, other, &range, &priority, &isHostile) == false) if (IsGameEventAudible(event, pEntity, pOther, &range, &priority, &isHostile) == false)
return; return;
if (event == EVENT_HOSTAGE_USED) if (event == EVENT_HOSTAGE_USED)
@ -322,7 +322,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe
if (m_iTeam == CT) if (m_iTeam == CT)
return; return;
if ((entity->pev->origin - pev->origin).IsLengthGreaterThan(range)) if ((pEntity->pev->origin - pev->origin).IsLengthGreaterThan(range))
return; return;
GetChatter()->HostagesBeingTaken(); GetChatter()->HostagesBeingTaken();

View File

@ -33,20 +33,20 @@ const float updateTimesliceDuration = 0.5f;
int _navAreaCount = 0; int _navAreaCount = 0;
int _currentIndex = 0; int _currentIndex = 0;
inline CNavNode *LadderEndSearch(CBaseEntity *entity, const Vector *pos, NavDirType mountDir) inline CNavNode *LadderEndSearch(CBaseEntity *pEntity, const Vector *pos, NavDirType mountDir)
{ {
Vector center = *pos; Vector center = *pos;
AddDirectionVector(&center, mountDir, HalfHumanWidth); AddDirectionVector(&center, mountDir, HalfHumanWidth);
// Test the ladder dismount point first, then each cardinal direction one and two steps away // Test the ladder dismount point first, then each cardinal direction one and two steps away
for (int d = (-1); d < 2 * NUM_DIRECTIONS; ++d) for (int dir = (-1); dir < 2 * NUM_DIRECTIONS; dir++)
{ {
Vector tryPos = center; Vector tryPos = center;
if (d >= NUM_DIRECTIONS) if (dir >= NUM_DIRECTIONS)
AddDirectionVector(&tryPos, (NavDirType)(d - NUM_DIRECTIONS), GenerationStepSize * 2.0f); AddDirectionVector(&tryPos, (NavDirType)(dir - NUM_DIRECTIONS), GenerationStepSize * 2.0f);
else if (d >= 0) else if (dir >= 0)
AddDirectionVector(&tryPos, (NavDirType)d, GenerationStepSize); AddDirectionVector(&tryPos, (NavDirType)dir, GenerationStepSize);
// step up a rung, to ensure adjacent floors are below us // step up a rung, to ensure adjacent floors are below us
tryPos.z += GenerationStepSize; tryPos.z += GenerationStepSize;
@ -60,7 +60,7 @@ inline CNavNode *LadderEndSearch(CBaseEntity *entity, const Vector *pos, NavDirT
// make sure this point is not on the other side of a wall // make sure this point is not on the other side of a wall
const float fudge = 2.0f; const float fudge = 2.0f;
TraceResult result; TraceResult result;
UTIL_TraceLine(center + Vector(0, 0, fudge), tryPos + Vector(0, 0, fudge), ignore_monsters, dont_ignore_glass, ENT(entity->pev), &result); UTIL_TraceLine(center + Vector(0, 0, fudge), tryPos + Vector(0, 0, fudge), ignore_monsters, dont_ignore_glass, ENT(pEntity->pev), &result);
if (result.flFraction != 1.0f if (result.flFraction != 1.0f
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES

View File

@ -104,6 +104,10 @@ CCSBotManager::CCSBotManager()
{ {
TheBotPhrases->Initialize((*pVoiceBanks)[i], i); TheBotPhrases->Initialize((*pVoiceBanks)[i], i);
} }
#ifdef REGAMEDLL_FIXES
AddServerCommands();
#endif
} }
// Invoked when a new round begins // Invoked when a new round begins
@ -182,27 +186,27 @@ bool CCSBotManager::IsWeaponUseable(CBasePlayerItem *item) const
} }
// Return true if this player is on "defense" // Return true if this player is on "defense"
bool CCSBotManager::IsOnDefense(CBasePlayer *player) const bool CCSBotManager::IsOnDefense(CBasePlayer *pPlayer) const
{ {
switch (GetScenario()) switch (GetScenario())
{ {
case SCENARIO_DEFUSE_BOMB: case SCENARIO_DEFUSE_BOMB:
return (player->m_iTeam == CT); return (pPlayer->m_iTeam == CT);
case SCENARIO_RESCUE_HOSTAGES: case SCENARIO_RESCUE_HOSTAGES:
return (player->m_iTeam == TERRORIST); return (pPlayer->m_iTeam == TERRORIST);
case SCENARIO_ESCORT_VIP: case SCENARIO_ESCORT_VIP:
return (player->m_iTeam == TERRORIST); return (pPlayer->m_iTeam == TERRORIST);
} }
return false; return false;
} }
// Return true if this player is on "offense" // Return true if this player is on "offense"
bool CCSBotManager::IsOnOffense(CBasePlayer *player) const bool CCSBotManager::IsOnOffense(CBasePlayer *pPlayer) const
{ {
return !IsOnDefense(player); return !IsOnDefense(pPlayer);
} }
// Invoked when a map has just been loaded // Invoked when a map has just been loaded
@ -221,7 +225,10 @@ void CCSBotManager::ServerActivate()
m_isAnalysisRequested = false; m_isAnalysisRequested = false;
m_bServerActive = true; m_bServerActive = true;
#ifndef REGAMEDLL_FIXES
AddServerCommands(); AddServerCommands();
#endif
TheBotPhrases->OnMapChange(); TheBotPhrases->OnMapChange();
} }
@ -266,7 +273,6 @@ void CCSBotManager::AddServerCommands()
AddServerCommand("bot_nav_crouch"); AddServerCommand("bot_nav_crouch");
AddServerCommand("bot_nav_jump"); AddServerCommand("bot_nav_jump");
AddServerCommand("bot_nav_precise"); AddServerCommand("bot_nav_precise");
AddServerCommand("bot_nav_walk");
AddServerCommand("bot_nav_no_jump"); AddServerCommand("bot_nav_no_jump");
AddServerCommand("bot_nav_analyze"); AddServerCommand("bot_nav_analyze");
AddServerCommand("bot_nav_strip"); AddServerCommand("bot_nav_strip");
@ -299,8 +305,8 @@ void CCSBotManager::ClientDisconnect(CBasePlayer *pPlayer)
auto pevTemp = VARS(pPlayer->edict()); auto pevTemp = VARS(pPlayer->edict());
CCSBot *bot = reinterpret_cast<CCSBot *>(pPlayer); CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
bot->Disconnect(); pBot->Disconnect();
if (!FStringNull(pPlayer->pev->classname)) if (!FStringNull(pPlayer->pev->classname))
{ {
@ -309,9 +315,9 @@ void CCSBotManager::ClientDisconnect(CBasePlayer *pPlayer)
FREE_PRIVATE(pPlayer->edict()); FREE_PRIVATE(pPlayer->edict());
auto player = GetClassPtr<CCSPlayer>((CBasePlayer *)pevTemp); pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pevTemp);
AddEntityHashValue(player->pev, STRING(player->pev->classname), CLASSNAME); AddEntityHashValue(pPlayer->pev, STRING(pPlayer->pev->classname), CLASSNAME);
player->pev->flags = FL_DORMANT; pPlayer->pev->flags = FL_DORMANT;
} }
void PrintAllEntities() void PrintAllEntities()
@ -337,7 +343,14 @@ void CCSBotManager::ServerCommand(const char *pcmd)
if (FStrEq(pcmd, "bot_about")) if (FStrEq(pcmd, "bot_about"))
{ {
Q_sprintf(buffer, "\n--------------------------------------------------------------------------\nThe Official Counter-Strike Bot V%d.%02d\nCreated by Michael S. Booth\nWeb: www.turtlerockstudios.com\\csbot\nE-mail: csbot@turtlerockstudios.com\n--------------------------------------------------------------------------\n\n", BOT_VERSION_MAJOR, BOT_VERSION_MINOR); Q_snprintf(buffer, sizeof(buffer),
"\n--------------------------------------------------------------------------\n"
"The Official Counter-Strike Bot V%d.%02d\n"
"Created by Michael S. Booth\n"
"Web: www.turtlerockstudios.com\\csbot\n"
"E-mail: csbot@turtlerockstudios.com\n"
"--------------------------------------------------------------------------\n\n", BOT_VERSION_MAJOR, BOT_VERSION_MINOR);
CONSOLE_ECHO(buffer); CONSOLE_ECHO(buffer);
HintMessageToAllPlayers(buffer); HintMessageToAllPlayers(buffer);
} }
@ -522,10 +535,6 @@ void CCSBotManager::ServerCommand(const char *pcmd)
{ {
m_editCmd = EDIT_ATTRIB_PRECISE; m_editCmd = EDIT_ATTRIB_PRECISE;
} }
else if (FStrEq(pcmd, "bot_nav_walk"))
{
m_editCmd = EDIT_ATTRIB_WALK;
}
else if (FStrEq(pcmd, "bot_nav_no_jump")) else if (FStrEq(pcmd, "bot_nav_no_jump"))
{ {
m_editCmd = EDIT_ATTRIB_NO_JUMP; m_editCmd = EDIT_ATTRIB_NO_JUMP;
@ -641,17 +650,17 @@ void CCSBotManager::ServerCommand(const char *pcmd)
if (!pEntity->IsPlayer()) if (!pEntity->IsPlayer())
continue; continue;
if ((pEntity->pev->flags & FL_DORMANT) == FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
CBasePlayer *playerOrBot = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev); CBasePlayer *playerOrBot = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (playerOrBot->IsBot()) if (playerOrBot->IsBot())
{ {
CCSBot *bot = static_cast<CCSBot *>(playerOrBot); CCSBot *pBot = static_cast<CCSBot *>(playerOrBot);
if (bot) if (pBot)
{ {
bot->MoveTo(&area->m_center, FASTEST_ROUTE); pBot->MoveTo(&area->m_center, FASTEST_ROUTE);
} }
break; break;
@ -1271,7 +1280,7 @@ CNavArea *CCSBotManager::GetRandomAreaInZone(const Zone *zone) const
return zone->m_area[RANDOM_LONG(0, zone->m_areaCount - 1)]; return zone->m_area[RANDOM_LONG(0, zone->m_areaCount - 1)];
} }
void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
switch (event) switch (event)
{ {
@ -1281,7 +1290,7 @@ void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntit
break; break;
case EVENT_BOMB_DEFUSING: case EVENT_BOMB_DEFUSING:
m_bombDefuser = (CBasePlayer *)entity; m_bombDefuser = static_cast<CBasePlayer *>(pEntity);
break; break;
case EVENT_BOMB_DEFUSE_ABORTED: case EVENT_BOMB_DEFUSE_ABORTED:
@ -1308,7 +1317,7 @@ void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntit
break; break;
} }
CBotManager::OnEvent(event, entity, other); CBotManager::OnEvent(event, pEntity, pOther);
} }
// Get the time remaining before the planted bomb explodes // Get the time remaining before the planted bomb explodes
@ -1332,13 +1341,13 @@ void CCSBotManager::SetLooseBomb(CBaseEntity *bomb)
} }
// Return true if player is important to scenario (VIP, bomb carrier, etc) // Return true if player is important to scenario (VIP, bomb carrier, etc)
bool CCSBotManager::IsImportantPlayer(CBasePlayer *player) const bool CCSBotManager::IsImportantPlayer(CBasePlayer *pPlayer) const
{ {
switch (GetScenario()) switch (GetScenario())
{ {
case SCENARIO_DEFUSE_BOMB: case SCENARIO_DEFUSE_BOMB:
{ {
if (player->m_iTeam == TERRORIST && player->IsBombGuy()) if (pPlayer->m_iTeam == TERRORIST && pPlayer->IsBombGuy())
return true; return true;
// TODO: TEAM_CT's defusing the bomb are important // TODO: TEAM_CT's defusing the bomb are important
@ -1346,7 +1355,7 @@ bool CCSBotManager::IsImportantPlayer(CBasePlayer *player) const
} }
case SCENARIO_ESCORT_VIP: case SCENARIO_ESCORT_VIP:
{ {
if (player->m_iTeam == CT && player->m_bIsVIP) if (pPlayer->m_iTeam == CT && pPlayer->m_bIsVIP)
return true; return true;
return false; return false;
@ -1363,18 +1372,18 @@ bool CCSBotManager::IsImportantPlayer(CBasePlayer *player) const
} }
// Return priority of player (0 = max pri) // Return priority of player (0 = max pri)
unsigned int CCSBotManager::GetPlayerPriority(CBasePlayer *player) const unsigned int CCSBotManager::GetPlayerPriority(CBasePlayer *pPlayer) const
{ {
const unsigned int lowestPriority = 0xFFFFFFFF; const unsigned int lowestPriority = 0xFFFFFFFF;
if (!player->IsPlayer()) if (!pPlayer->IsPlayer())
return lowestPriority; return lowestPriority;
// human players have highest priority // human players have highest priority
if (!player->IsBot()) if (!pPlayer->IsBot())
return 0; return 0;
CCSBot *bot = reinterpret_cast<CCSBot *>(player); CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
// bots doing something important for the current scenario have high priority // bots doing something important for the current scenario have high priority
switch (GetScenario()) switch (GetScenario())
@ -1382,7 +1391,7 @@ unsigned int CCSBotManager::GetPlayerPriority(CBasePlayer *player) const
case SCENARIO_DEFUSE_BOMB: case SCENARIO_DEFUSE_BOMB:
{ {
// the bomb carrier has high priority // the bomb carrier has high priority
if (bot->m_iTeam == TERRORIST && bot->m_bHasC4) if (pBot->m_iTeam == TERRORIST && pBot->m_bHasC4)
return 1; return 1;
break; break;
@ -1390,7 +1399,7 @@ unsigned int CCSBotManager::GetPlayerPriority(CBasePlayer *player) const
case SCENARIO_ESCORT_VIP: case SCENARIO_ESCORT_VIP:
{ {
// the VIP has high priority // the VIP has high priority
if (bot->m_iTeam == CT && bot->m_bIsVIP) if (pBot->m_iTeam == CT && pBot->m_bIsVIP)
return 1; return 1;
break; break;
@ -1398,7 +1407,7 @@ unsigned int CCSBotManager::GetPlayerPriority(CBasePlayer *player) const
case SCENARIO_RESCUE_HOSTAGES: case SCENARIO_RESCUE_HOSTAGES:
{ {
// TEAM_CT's rescuing hostages have high priority // TEAM_CT's rescuing hostages have high priority
if (bot->m_iTeam == CT && bot->GetHostageEscortCount()) if (pBot->m_iTeam == CT && pBot->GetHostageEscortCount())
return 1; return 1;
break; break;
@ -1406,7 +1415,7 @@ unsigned int CCSBotManager::GetPlayerPriority(CBasePlayer *player) const
} }
// everyone else is ranked by their unique ID (which cannot be zero) // everyone else is ranked by their unique ID (which cannot be zero)
return 1 + bot->GetID(); return 1 + pBot->GetID();
} }
// Return the last time the given radio message was sent for given team // Return the last time the given radio message was sent for given team

View File

@ -51,9 +51,9 @@ public:
virtual void RestartRound(); // (EXTEND) invoked when a new round begins virtual void RestartRound(); // (EXTEND) invoked when a new round begins
virtual void StartFrame(); // (EXTEND) called each frame virtual void StartFrame(); // (EXTEND) called each frame
virtual void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); virtual void OnEvent(GameEventType event, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr);
virtual unsigned int GetPlayerPriority(CBasePlayer *player) const; // return priority of player (0 = max pri) virtual unsigned int GetPlayerPriority(CBasePlayer *pPlayer) const; // return priority of pPlayer (0 = max pri)
virtual bool IsImportantPlayer(CBasePlayer *player) const; // return true if player is important to scenario (VIP, bomb carrier, etc) virtual bool IsImportantPlayer(CBasePlayer *pPlayer) const; // return true if pPlayer is important to scenario (VIP, bomb carrier, etc)
public: public:
void ValidateMapData(); void ValidateMapData();
@ -117,7 +117,7 @@ public:
const Zone *GetZone(int i) const { return &m_zone[i]; } const Zone *GetZone(int i) const { return &m_zone[i]; }
const Zone *GetZone(const Vector *pos) const; // return the zone that contains the given position const Zone *GetZone(const Vector *pos) const; // return the zone that contains the given position
const Zone *GetClosestZone(const Vector *pos) const; // return the closest zone to the given position const Zone *GetClosestZone(const Vector *pos) const; // return the closest zone to the given position
const Zone *GetClosestZone(const CBaseEntity *entity) const { return GetClosestZone(&entity->pev->origin); } // return the closest zone to the given entity const Zone *GetClosestZone(const CBaseEntity *pEntity) const { return GetClosestZone(&pEntity->pev->origin); } // return the closest zone to the given entity
int GetZoneCount() const { return m_zoneCount; } int GetZoneCount() const { return m_zoneCount; }
const Vector *GetRandomPositionInZone(const Zone *zone) const; const Vector *GetRandomPositionInZone(const Zone *zone) const;
@ -139,9 +139,9 @@ public:
continue; continue;
// just use the first overlapping nav area as a reasonable approximation // just use the first overlapping nav area as a reasonable approximation
float_precision dist = NavAreaTravelDistance(startArea, m_zone[i].m_area[0], costFunc); real_t dist = NavAreaTravelDistance(startArea, m_zone[i].m_area[0], costFunc);
if (/*dist >= 0.0f && */dist < closeDist) if (dist >= 0.0f && dist < closeDist)
{ {
closeZone = &m_zone[i]; closeZone = &m_zone[i];
closeDist = dist; closeDist = dist;
@ -197,8 +197,8 @@ public:
bool IsWeaponUseable(CBasePlayerItem *item) const; // return true if the bot can use this weapon bool IsWeaponUseable(CBasePlayerItem *item) const; // return true if the bot can use this weapon
bool IsDefenseRushing() const { return m_isDefenseRushing; } // returns true if defense team has "decided" to rush this round bool IsDefenseRushing() const { return m_isDefenseRushing; } // returns true if defense team has "decided" to rush this round
bool IsOnDefense(CBasePlayer *player) const; // return true if this player is on "defense" bool IsOnDefense(CBasePlayer *pPlayer) const; // return true if this player is on "defense"
bool IsOnOffense(CBasePlayer *player) const; // return true if this player is on "offense" bool IsOnOffense(CBasePlayer *pPlayer) const; // return true if this player is on "offense"
bool IsRoundOver() const { return m_isRoundOver; } // return true if the round has ended bool IsRoundOver() const { return m_isRoundOver; } // return true if the round has ended

View File

@ -129,7 +129,7 @@ bool CCSBot::DiscontinuityJump(float ground, bool onlyJumpDown, bool mustJump)
if (m_isJumpCrouching) if (m_isJumpCrouching)
return false; return false;
float_precision dz = ground - GetFeetZ(); real_t dz = ground - GetFeetZ();
if (dz > StepHeight && !onlyJumpDown) if (dz > StepHeight && !onlyJumpDown)
{ {

View File

@ -669,11 +669,11 @@ int CCSBot::FindOurPositionOnPath(Vector *close, bool local) const
Vector eyes = feet + Vector(0, 0, HalfHumanHeight); // in case we're crouching Vector eyes = feet + Vector(0, 0, HalfHumanHeight); // in case we're crouching
Vector pos; Vector pos;
const Vector *from, *to; const Vector *from, *to;
float_precision length; real_t length;
float closeLength; float closeLength;
float closeDistSq = 9999999999.9; float closeDistSq = 9999999999.9;
int closeIndex = -1; int closeIndex = -1;
float_precision distSq; real_t distSq;
int start, end; int start, end;
@ -1085,7 +1085,7 @@ float CCSBot::GetApproximateFallDamage(float height) const
const float slope = 0.2178f; const float slope = 0.2178f;
const float intercept = 26.0f; const float intercept = 26.0f;
float_precision damage = slope * height - intercept; real_t damage = slope * height - intercept;
if (damage < 0.0f) if (damage < 0.0f)
return 0.0f; return 0.0f;
@ -1116,26 +1116,26 @@ bool CCSBot::IsFriendInTheWay(const Vector *goalPos) const
// check if any friends are overlapping this linear path // check if any friends are overlapping this linear path
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
// ignore enemies // ignore enemies
if (BotRelationship(player) == BOT_ENEMY) if (BotRelationship(pPlayer) == BOT_ENEMY)
continue; continue;
if (player == this) if (pPlayer == this)
continue; continue;
// compute vector from us to our friend // compute vector from us to our friend
Vector toFriend = player->pev->origin - pev->origin; Vector toFriend = pPlayer->pev->origin - pev->origin;
// check if friend is in our "personal space" // check if friend is in our "personal space"
const float personalSpace = 100.0f; const float personalSpace = 100.0f;
@ -1158,7 +1158,7 @@ bool CCSBot::IsFriendInTheWay(const Vector *goalPos) const
// check if friend overlaps our intended line of movement // check if friend overlaps our intended line of movement
const float friendRadius = 30.0f; const float friendRadius = 30.0f;
if ((pos - player->pev->origin).IsLengthLessThan(friendRadius)) if ((pos - pPlayer->pev->origin).IsLengthLessThan(friendRadius))
{ {
// friend is in our personal space and overlaps our intended line of movement // friend is in our personal space and overlaps our intended line of movement
m_isFriendInTheWay = true; m_isFriendInTheWay = true;
@ -1393,29 +1393,6 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
StandUp(); StandUp();
} }
// end crouching logic // end crouching logic
// Walking
bool didWalk = false;
for (int i = prevIndex; i < m_pathLength; ++i)
{
const CNavArea *to = m_path[i].area;
Vector close;
to->GetClosestPointOnArea(&pev->origin, &close);
if ((close - pev->origin).Make2D().IsLengthGreaterThan(crouchRange))
break;
if (to->GetAttributes() & NAV_WALK)
{
Walk();
didWalk = true;
break;
}
}
if (!didWalk)
Run();
} }
// compute our forward facing angle // compute our forward facing angle

View File

@ -260,7 +260,7 @@ bool CCSBot::RespondToHelpRequest(CBasePlayer *them, Place place, float maxRange
{ {
// compute actual travel distance // compute actual travel distance
PathCost pc(this); PathCost pc(this);
float_precision travelDistance = NavAreaTravelDistance(m_lastKnownArea, TheNavAreaGrid.GetNearestNavArea(&them->pev->origin), pc); real_t travelDistance = NavAreaTravelDistance(m_lastKnownArea, TheNavAreaGrid.GetNearestNavArea(&them->pev->origin), pc);
if (travelDistance < 0.0f) if (travelDistance < 0.0f)
return false; return false;

View File

@ -58,20 +58,20 @@ void CCSBot::EscapeFromBomb()
SetState(&m_escapeFromBombState); SetState(&m_escapeFromBombState);
} }
void CCSBot::Follow(CBasePlayer *player) void CCSBot::Follow(CBasePlayer *pPlayer)
{ {
if (!player) if (!pPlayer)
return; return;
// note when we began following // note when we began following
if (!m_isFollowing || m_leader != player) if (!m_isFollowing || m_leader != pPlayer)
m_followTimestamp = gpGlobals->time; m_followTimestamp = gpGlobals->time;
m_isFollowing = true; m_isFollowing = true;
m_leader = player; m_leader = pPlayer;
SetTask(FOLLOW); SetTask(FOLLOW);
m_followState.SetLeader(player); m_followState.SetLeader(pPlayer);
SetState(&m_followState); SetState(&m_followState);
} }
@ -98,9 +98,9 @@ void CCSBot::RescueHostages()
} }
// Use the entity // Use the entity
void CCSBot::UseEntity(CBaseEntity *entity) void CCSBot::UseEntity(CBaseEntity *pEntity)
{ {
m_useEntityState.SetEntity(entity); m_useEntityState.SetEntity(pEntity);
SetState(&m_useEntityState); SetState(&m_useEntityState);
} }
@ -322,9 +322,9 @@ void CCSBot::Attack(CBasePlayer *victim)
Vector idealAngle = UTIL_VecToAngles(toEnemy); Vector idealAngle = UTIL_VecToAngles(toEnemy);
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
float_precision deltaYaw = float_precision(Q_abs(m_lookYaw - idealAngle.y)); real_t deltaYaw = real_t(Q_abs(m_lookYaw - idealAngle.y));
#else #else
float_precision deltaYaw = float_precision(Q_abs(int64(m_lookYaw - idealAngle.y))); real_t deltaYaw = real_t(Q_abs(int64(m_lookYaw - idealAngle.y)));
#endif #endif
while (deltaYaw > 180.0f) while (deltaYaw > 180.0f)

View File

@ -659,17 +659,17 @@ void CCSBot::Update()
// chance of following is proportional to teamwork attribute // chance of following is proportional to teamwork attribute
if (GetProfile()->GetTeamwork() > RANDOM_FLOAT(0.0f, 1.0f)) if (GetProfile()->GetTeamwork() > RANDOM_FLOAT(0.0f, 1.0f))
{ {
CBasePlayer *leader = GetClosestVisibleHumanFriend(); CBasePlayer *pLeader = GetClosestVisibleHumanFriend();
if (leader && leader->IsAutoFollowAllowed()) if (pLeader && pLeader->IsAutoFollowAllowed())
{ {
// count how many bots are already following this player // count how many bots are already following this player
const float maxFollowCount = 2; const float maxFollowCount = 2;
if (GetBotFollowCount(leader) < maxFollowCount) if (GetBotFollowCount(pLeader) < maxFollowCount)
{ {
const float autoFollowRange = 300.0f; const float autoFollowRange = 300.0f;
if ((leader->pev->origin - pev->origin).IsLengthLessThan(autoFollowRange)) if ((pLeader->pev->origin - pev->origin).IsLengthLessThan(autoFollowRange))
{ {
CNavArea *leaderArea = TheNavAreaGrid.GetNavArea(&leader->pev->origin); CNavArea *leaderArea = TheNavAreaGrid.GetNavArea(&pLeader->pev->origin);
if (leaderArea) if (leaderArea)
{ {
PathCost cost(this, FASTEST_ROUTE); PathCost cost(this, FASTEST_ROUTE);
@ -677,8 +677,8 @@ void CCSBot::Update()
if (/*travelRange >= 0.0f &&*/ travelRange < autoFollowRange) if (/*travelRange >= 0.0f &&*/ travelRange < autoFollowRange)
{ {
// follow this human // follow this human
Follow(leader); Follow(pLeader);
PrintIfWatched("Auto-Following %s\n", STRING(leader->pev->netname)); PrintIfWatched("Auto-Following %s\n", STRING(pLeader->pev->netname));
if (CSGameRules()->IsCareer()) if (CSGameRules()->IsCareer())
{ {

View File

@ -247,9 +247,9 @@ bool CCSBot::IsVisible(const Vector *pos, bool testFOV) const
// Return true if we can see any part of the player // Return true if we can see any part of the player
// Check parts in order of importance. Return the first part seen in "visParts" if it is non-NULL. // Check parts in order of importance. Return the first part seen in "visParts" if it is non-NULL.
bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visParts) const bool CCSBot::IsVisible(CBasePlayer *pPlayer, bool testFOV, unsigned char *visParts) const
{ {
Vector spot = player->pev->origin; Vector spot = pPlayer->pev->origin;
unsigned char testVisParts = NONE; unsigned char testVisParts = NONE;
// finish chest check // finish chest check
@ -266,10 +266,10 @@ bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visPart
const float standFeet = 34.0f; const float standFeet = 34.0f;
const float crouchFeet = 14.0f; const float crouchFeet = 14.0f;
if (player->pev->flags & FL_DUCKING) if (pPlayer->pev->flags & FL_DUCKING)
spot.z = player->pev->origin.z - crouchFeet; spot.z = pPlayer->pev->origin.z - crouchFeet;
else else
spot.z = player->pev->origin.z - standFeet; spot.z = pPlayer->pev->origin.z - standFeet;
// check feet // check feet
if (IsVisible(&spot, testFOV)) if (IsVisible(&spot, testFOV))
@ -277,17 +277,17 @@ bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visPart
// check "edges" // check "edges"
const float edgeOffset = 13.0f; const float edgeOffset = 13.0f;
Vector2D dir = (player->pev->origin - pev->origin).Make2D(); Vector2D dir = (pPlayer->pev->origin - pev->origin).Make2D();
dir.NormalizeInPlace(); dir.NormalizeInPlace();
Vector2D perp(-dir.y, dir.x); Vector2D perp(-dir.y, dir.x);
spot = player->pev->origin + Vector(perp.x * edgeOffset, perp.y * edgeOffset, 0); spot = pPlayer->pev->origin + Vector(perp.x * edgeOffset, perp.y * edgeOffset, 0);
if (IsVisible(&spot, testFOV)) if (IsVisible(&spot, testFOV))
testVisParts |= LEFT_SIDE; testVisParts |= LEFT_SIDE;
spot = player->pev->origin - Vector(perp.x * edgeOffset, perp.y * edgeOffset, 0); spot = pPlayer->pev->origin - Vector(perp.x * edgeOffset, perp.y * edgeOffset, 0);
if (IsVisible(&spot, testFOV)) if (IsVisible(&spot, testFOV))
testVisParts |= RIGHT_SIDE; testVisParts |= RIGHT_SIDE;
@ -497,7 +497,7 @@ void CCSBot::UpdateLookAround(bool updateNow)
// TODO: Use skill parameter instead of accuracy // TODO: Use skill parameter instead of accuracy
// lower skills have exponentially longer delays // lower skills have exponentially longer delays
float_precision asleep = (1.0f - GetProfile()->GetSkill()); real_t asleep = (1.0f - GetProfile()->GetSkill());
asleep *= asleep; asleep *= asleep;
asleep *= asleep; asleep *= asleep;
@ -505,7 +505,8 @@ void CCSBot::UpdateLookAround(bool updateNow)
// figure out how far along the path segment we are // figure out how far along the path segment we are
Vector delta = m_spotEncounter->path.to - m_spotEncounter->path.from; Vector delta = m_spotEncounter->path.to - m_spotEncounter->path.from;
float_precision length = delta.Length(); real_t length = delta.Length();
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
float adx = Q_abs(delta.x); float adx = Q_abs(delta.x);
float ady = Q_abs(delta.y); float ady = Q_abs(delta.y);
@ -513,7 +514,7 @@ void CCSBot::UpdateLookAround(bool updateNow)
float adx = float(Q_abs(int64(delta.x))); float adx = float(Q_abs(int64(delta.x)));
float ady = float(Q_abs(int64(delta.y))); float ady = float(Q_abs(int64(delta.y)));
#endif #endif
float_precision t; real_t t;
if (adx > ady) if (adx > ady)
t = (pev->origin.x - m_spotEncounter->path.from.x) / delta.x; t = (pev->origin.x - m_spotEncounter->path.from.x) / delta.x;
@ -693,51 +694,51 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
{ {
for (i = 1; i <= gpGlobals->maxClients; i++) for (i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
// is it a player? // is it a player?
if (!player->IsPlayer()) if (!pPlayer->IsPlayer())
continue; continue;
// ignore self // ignore self
if (player->entindex() == entindex()) if (pPlayer->entindex() == entindex())
continue; continue;
// is it alive? // is it alive?
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
// is it an enemy? // is it an enemy?
if (BotRelationship(player) == BOT_TEAMMATE) if (BotRelationship(pPlayer) == BOT_TEAMMATE)
{ {
TraceResult result; TraceResult result;
UTIL_TraceLine(GetEyePosition(), player->pev->origin, ignore_monsters, ignore_glass, edict(), &result); UTIL_TraceLine(GetEyePosition(), pPlayer->pev->origin, ignore_monsters, ignore_glass, edict(), &result);
if (result.flFraction == 1.0f) if (result.flFraction == 1.0f)
{ {
// update watch timestamp // update watch timestamp
int idx = player->entindex() - 1; int idx = pPlayer->entindex() - 1;
m_watchInfo[idx].timestamp = gpGlobals->time; m_watchInfo[idx].timestamp = gpGlobals->time;
m_watchInfo[idx].isEnemy = false; m_watchInfo[idx].isEnemy = false;
// keep track of our closest friend // keep track of our closest friend
Vector to = pev->origin - player->pev->origin; Vector to = pev->origin - pPlayer->pev->origin;
float rangeSq = to.LengthSquared(); float rangeSq = to.LengthSquared();
if (rangeSq < closeFriendRange) if (rangeSq < closeFriendRange)
{ {
m_closestVisibleFriend = player; m_closestVisibleFriend = pPlayer;
closeFriendRange = rangeSq; closeFriendRange = rangeSq;
} }
// keep track of our closest human friend // keep track of our closest human friend
if (!player->IsBot() && rangeSq < closeHumanFriendRange) if (!pPlayer->IsBot() && rangeSq < closeHumanFriendRange)
{ {
m_closestVisibleHumanFriend = player; m_closestVisibleHumanFriend = pPlayer;
closeHumanFriendRange = rangeSq; closeHumanFriendRange = rangeSq;
} }
} }
@ -747,14 +748,14 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
// check if this enemy is fully // check if this enemy is fully
unsigned char visParts; unsigned char visParts;
if (!IsVisible(player, CHECK_FOV, &visParts)) if (!IsVisible(pPlayer, CHECK_FOV, &visParts))
continue; continue;
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
// do we notice this enemy? (always notice current enemy) // do we notice this enemy? (always notice current enemy)
if (player != currentThreat) if (pPlayer != currentThreat)
{ {
if (!IsNoticable(player, visParts)) if (!IsNoticable(pPlayer, visParts))
{ {
continue; continue;
} }
@ -762,24 +763,24 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
#endif #endif
// update watch timestamp // update watch timestamp
int idx = player->entindex() - 1; int idx = pPlayer->entindex() - 1;
m_watchInfo[idx].timestamp = gpGlobals->time; m_watchInfo[idx].timestamp = gpGlobals->time;
m_watchInfo[idx].isEnemy = true; m_watchInfo[idx].isEnemy = true;
// note if we see the bomber // note if we see the bomber
if (player->IsBombGuy()) if (pPlayer->IsBombGuy())
{ {
m_bomber = player; m_bomber = pPlayer;
} }
// keep track of all visible threats // keep track of all visible threats
Vector d = pev->origin - player->pev->origin; Vector d = pev->origin - pPlayer->pev->origin;
float distSq = d.LengthSquared(); float distSq = d.LengthSquared();
// maintain set of visible threats, sorted by increasing distance // maintain set of visible threats, sorted by increasing distance
if (threatCount == 0) if (threatCount == 0)
{ {
threat[0].enemy = player; threat[0].enemy = pPlayer;
threat[0].range = distSq; threat[0].range = distSq;
threatCount = 1; threatCount = 1;
} }
@ -794,11 +795,11 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
} }
// shift lower half down a notch // shift lower half down a notch
for (int k = threatCount - 1; k >= j; --k) for (int k = threatCount - 1; k >= j; k--)
threat[k + 1] = threat[k]; threat[k + 1] = threat[k];
// insert threat into sorted list // insert threat into sorted list
threat[j].enemy = player; threat[j].enemy = pPlayer;
threat[j].range = distSq; threat[j].range = distSq;
if (threatCount < MAX_THREATS) if (threatCount < MAX_THREATS)
@ -857,11 +858,11 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
{ {
// find the area the player/bot is standing on // find the area the player/bot is standing on
CNavArea *area; CNavArea *area;
CCSBot *bot = reinterpret_cast<CCSBot *>(threat[i].enemy); CCSBot *pBot = static_cast<CCSBot *>(threat[i].enemy);
if (bot->IsBot()) if (pBot->IsBot())
{ {
area = bot->GetLastKnownArea(); area = pBot->GetLastKnownArea();
} }
else else
{ {
@ -1071,7 +1072,7 @@ void CCSBot::Blind(float duration, float holdTime, float fadeTime, int alpha)
} }
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
bool CCSBot::IsNoticable(const CBasePlayer *player, unsigned char visibleParts) const bool CCSBot::IsNoticable(const CBasePlayer *pPlayer, unsigned char visibleParts) const
{ {
float deltaT = m_attentionInterval.GetElapsedTime(); float deltaT = m_attentionInterval.GetElapsedTime();
@ -1113,7 +1114,7 @@ bool CCSBot::IsNoticable(const CBasePlayer *player, unsigned char visibleParts)
} }
// compute range modifier - farther away players are harder to notice, depeding on what they are doing // compute range modifier - farther away players are harder to notice, depeding on what they are doing
float range = (player->pev->origin - pev->origin).Length(); float range = (pPlayer->pev->origin - pev->origin).Length();
const float closeRange = 300.0f; const float closeRange = 300.0f;
const float farRange = 1000.0f; const float farRange = 1000.0f;
@ -1132,9 +1133,9 @@ bool CCSBot::IsNoticable(const CBasePlayer *player, unsigned char visibleParts)
} }
// harder to notice when crouched // harder to notice when crouched
bool isCrouching = (player->pev->flags & FL_DUCKING) == FL_DUCKING; bool isCrouching = (pPlayer->pev->flags & FL_DUCKING) == FL_DUCKING;
// moving players are easier to spot // moving players are easier to spot
float playerSpeedSq = player->pev->velocity.LengthSquared(); float playerSpeedSq = pPlayer->pev->velocity.LengthSquared();
const float runSpeed = 200.0f; const float runSpeed = 200.0f;
const float walkSpeed = 30.0f; const float walkSpeed = 30.0f;
float farChance, closeChance; float farChance, closeChance;

View File

@ -61,18 +61,18 @@ void CCSBot::FireWeaponAtEnemy()
Vector2D toAimSpot = (m_aimSpot - pev->origin).Make2D(); Vector2D toAimSpot = (m_aimSpot - pev->origin).Make2D();
float rangeToEnemy = toAimSpot.NormalizeInPlace(); float rangeToEnemy = toAimSpot.NormalizeInPlace();
const float_precision halfPI = (M_PI / 180.0f); const real_t halfPI = (M_PI / 180.0f);
float_precision yaw = pev->v_angle[YAW] * halfPI; real_t yaw = pev->v_angle[YAW] * halfPI;
Vector2D dir(Q_cos(yaw), Q_sin(yaw)); Vector2D dir(Q_cos(yaw), Q_sin(yaw));
float_precision onTarget = DotProduct(toAimSpot, dir); real_t onTarget = DotProduct(toAimSpot, dir);
// aim more precisely with a sniper rifle // aim more precisely with a sniper rifle
// because rifles' bullets spray, dont have to be very precise // because rifles' bullets spray, dont have to be very precise
const float_precision halfSize = (IsUsingSniperRifle()) ? HalfHumanWidth : 2.0f * HalfHumanWidth; const real_t halfSize = (IsUsingSniperRifle()) ? HalfHumanWidth : 2.0f * HalfHumanWidth;
// aiming tolerance depends on how close the target is - closer targets subtend larger angles // aiming tolerance depends on how close the target is - closer targets subtend larger angles
float_precision aimTolerance = Q_cos(Q_atan(halfSize / rangeToEnemy)); real_t aimTolerance = Q_cos(Q_atan(halfSize / rangeToEnemy));
if (onTarget > aimTolerance) if (onTarget > aimTolerance)
{ {
@ -205,7 +205,7 @@ void CCSBot::SetAimOffset(float accuracy)
PrintIfWatched("Accuracy = %4.3f\n", accuracy); PrintIfWatched("Accuracy = %4.3f\n", accuracy);
float range = (m_lastEnemyPosition - pev->origin).Length(); float range = (m_lastEnemyPosition - pev->origin).Length();
const float_precision maxOffset = range * (float_precision(m_iFOV) / DEFAULT_FOV) * 0.1; const real_t maxOffset = range * (real_t(m_iFOV) / DEFAULT_FOV) * 0.1;
float error = maxOffset * (1 - accuracy); float error = maxOffset * (1 - accuracy);
m_aimOffsetGoal[0] = RANDOM_FLOAT(-error, error); m_aimOffsetGoal[0] = RANDOM_FLOAT(-error, error);
@ -443,10 +443,6 @@ void CCSBot::EquipBestWeapon(bool mustEquip)
if ((TheCSBots()->AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) if ((TheCSBots()->AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN)
|| (TheCSBots()->AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN) || (TheCSBots()->AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN)
|| (TheCSBots()->AllowRifles() && weaponClass == WEAPONCLASS_RIFLE) || (TheCSBots()->AllowRifles() && weaponClass == WEAPONCLASS_RIFLE)
#ifndef REGAMEDLL_FIXES
// TODO: already is checked shotguns!
|| (TheCSBots()->AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN)
#endif
|| (TheCSBots()->AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE) || (TheCSBots()->AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE)
|| (TheCSBots()->AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN) || (TheCSBots()->AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN)
|| (TheCSBots()->AllowTacticalShield() && pPrimary->m_iId == WEAPON_SHIELDGUN)) || (TheCSBots()->AllowTacticalShield() && pPrimary->m_iId == WEAPON_SHIELDGUN))

View File

@ -93,7 +93,7 @@ void CSGameState::Reset()
} }
// Update game state based on events we have received // Update game state based on events we have received
void CSGameState::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CSGameState::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
switch (event) switch (event)
{ {
@ -103,9 +103,9 @@ void CSGameState::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity
SetBombState(PLANTED); SetBombState(PLANTED);
// Terrorists always know where the bomb is // Terrorists always know where the bomb is
if (m_owner->m_iTeam == TERRORIST && other) if (m_owner->m_iTeam == TERRORIST && pOther)
{ {
UpdatePlantedBomb(&other->pev->origin); UpdatePlantedBomb(&pOther->pev->origin);
} }
break; break;
} }

View File

@ -38,7 +38,7 @@ public:
CSGameState(CCSBot *owner); CSGameState(CCSBot *owner);
void Reset(); void Reset();
void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); // Event handling void OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther); // Event handling
bool IsRoundOver() const; // true if round has been won or lost (but not yet reset) bool IsRoundOver() const; // true if round has been won or lost (but not yet reset)
// bomb defuse scenario // bomb defuse scenario
@ -79,7 +79,7 @@ public:
const Vector *GetBombPosition() const; // return where we think the bomb is, or NULL if we don't know const Vector *GetBombPosition() const; // return where we think the bomb is, or NULL if we don't know
// hostage rescue scenario // hostage rescue scenario
CHostage *GetNearestFreeHostage(Vector *knowPos = NULL) const; // return the closest free hostage, and where we think it is (knowPos) CHostage *GetNearestFreeHostage(Vector *knowPos = nullptr) const; // return the closest free hostage, and where we think it is (knowPos)
const Vector *GetRandomFreeHostagePosition(); const Vector *GetRandomFreeHostagePosition();
bool AreAllHostagesBeingRescued() const; // return true if there are no free hostages bool AreAllHostagesBeingRescued() const; // return true if there are no free hostages
bool AreAllHostagesGone() const; // all hostages have been rescued or are dead bool AreAllHostagesGone() const; // all hostages have been rescued or are dead

View File

@ -397,11 +397,11 @@ void BuyState::OnUpdate(CCSBot *me)
for (int i = 0; i < MAX_BUY_WEAPON_PRIMARY; i++) for (int i = 0; i < MAX_BUY_WEAPON_PRIMARY; i++)
{ {
if ((masterPrimary[i].type == SHOTGUN && TheCSBots()->AllowShotguns()) || if ((masterPrimary[i].type == SHOTGUN && TheCSBots()->AllowShotguns())
(masterPrimary[i].type == SUB_MACHINE_GUN && TheCSBots()->AllowSubMachineGuns()) || || (masterPrimary[i].type == SUB_MACHINE_GUN && TheCSBots()->AllowSubMachineGuns())
(masterPrimary[i].type == RIFLE && TheCSBots()->AllowRifles()) || || (masterPrimary[i].type == RIFLE && TheCSBots()->AllowRifles())
(masterPrimary[i].type == SNIPER_RIFLE && TheCSBots()->AllowSnipers() && wantSniper) || || (masterPrimary[i].type == SNIPER_RIFLE && TheCSBots()->AllowSnipers() && wantSniper)
(masterPrimary[i].type == MACHINE_GUN && TheCSBots()->AllowMachineGuns())) || (masterPrimary[i].type == MACHINE_GUN && TheCSBots()->AllowMachineGuns()))
{ {
stockPrimary[stockPrimaryCount++] = &masterPrimary[i]; stockPrimary[stockPrimaryCount++] = &masterPrimary[i];
} }

View File

@ -262,7 +262,7 @@ void FollowState::OnUpdate(CCSBot *me)
area = collector.m_targetArea[a]; area = collector.m_targetArea[a];
area->GetClosestPointOnArea(&me->pev->origin, &close); area->GetClosestPointOnArea(&me->pev->origin, &close);
float_precision rangeSq = (me->pev->origin - close).LengthSquared(); real_t rangeSq = (me->pev->origin - close).LengthSquared();
if (rangeSq < closeRangeSq) if (rangeSq < closeRangeSq)
{ {
target = area; target = area;

View File

@ -115,22 +115,22 @@ void HideState::OnUpdate(CCSBot *me)
// if we are momentarily hiding while following someone, check to see if he has moved on // if we are momentarily hiding while following someone, check to see if he has moved on
if (me->IsFollowing()) if (me->IsFollowing())
{ {
CBasePlayer *leader = me->GetFollowLeader(); CBasePlayer *pLeader = me->GetFollowLeader();
// BOTPORT: Determine walk/run velocity thresholds // BOTPORT: Determine walk/run velocity thresholds
float runThreshold = 200.0f; float runThreshold = 200.0f;
if (leader->pev->velocity.IsLengthGreaterThan(runThreshold)) if (pLeader->pev->velocity.IsLengthGreaterThan(runThreshold))
{ {
// leader is running, stay with him // leader is running, stay with him
me->Follow(leader); me->Follow(pLeader);
return; return;
} }
// if leader has moved, stay with him // if leader has moved, stay with him
const float followRange = 250.0f; const float followRange = 250.0f;
if ((m_leaderAnchorPos - leader->pev->origin).IsLengthGreaterThan(followRange)) if ((m_leaderAnchorPos - pLeader->pev->origin).IsLengthGreaterThan(followRange))
{ {
me->Follow(leader); me->Follow(pLeader);
return; return;
} }
} }

View File

@ -180,7 +180,7 @@ void HuntState::OnUpdate(CCSBot *me)
continue; continue;
// keep track of the least recently cleared area // keep track of the least recently cleared area
float_precision age = gpGlobals->time - area->GetClearedTimestamp(me->m_iTeam - 1); real_t age = gpGlobals->time - area->GetClearedTimestamp(me->m_iTeam - 1);
if (age > oldest) if (age > oldest)
{ {
oldest = age; oldest = age;

View File

@ -310,7 +310,7 @@ void IdleState::OnUpdate(CCSBot *me)
// just use the first overlapping nav area as a reasonable approximation // just use the first overlapping nav area as a reasonable approximation
ShortestPathCost pathCost = ShortestPathCost(); ShortestPathCost pathCost = ShortestPathCost();
float_precision dist = NavAreaTravelDistance(me->GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&TheCSBots()->GetZone(z)->m_center), pathCost); real_t dist = NavAreaTravelDistance(me->GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&TheCSBots()->GetZone(z)->m_center), pathCost);
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (dist < 0.0f) if (dist < 0.0f)

View File

@ -178,7 +178,7 @@ void CMultiSource::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u
useType = USE_ON; useType = USE_ON;
} }
SUB_UseTargets(NULL, useType, 0); SUB_UseTargets(nullptr, useType, 0);
} }
} }
@ -385,7 +385,7 @@ BOOL CBaseButton::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, fl
} }
// Temporarily disable the touch function, until movement is finished. // Temporarily disable the touch function, until movement is finished.
SetTouch(NULL); SetTouch(nullptr);
m_hActivator = CBaseEntity::Instance(pevAttacker); m_hActivator = CBaseEntity::Instance(pevAttacker);
if (!m_hActivator) if (!m_hActivator)
@ -482,7 +482,7 @@ void CBaseButton::Spawn()
m_vecPosition1 = pev->origin; m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (Q_fabs(float_precision(pev->movedir.x * (pev->size.x - 2))) + Q_fabs(float_precision(pev->movedir.y * (pev->size.y - 2))) + Q_fabs(float_precision(pev->movedir.z * (pev->size.z - 2))) - m_flLip)); m_vecPosition2 = m_vecPosition1 + (pev->movedir * (Q_fabs(real_t(pev->movedir.x * (pev->size.x - 2))) + Q_fabs(real_t(pev->movedir.y * (pev->size.y - 2))) + Q_fabs(real_t(pev->movedir.z * (pev->size.z - 2))) - m_flLip));
// Is this a non-moving button? // Is this a non-moving button?
if (((m_vecPosition2 - m_vecPosition1).Length() < 1) || (pev->spawnflags & SF_BUTTON_DONTMOVE)) if (((m_vecPosition2 - m_vecPosition1).Length() < 1) || (pev->spawnflags & SF_BUTTON_DONTMOVE))
@ -501,7 +501,7 @@ void CBaseButton::Spawn()
} }
else else
{ {
SetTouch(NULL); SetTouch(nullptr);
SetUse(&CBaseButton::ButtonUse); SetUse(&CBaseButton::ButtonUse);
} }
} }
@ -640,7 +640,7 @@ void CBaseButton::ButtonTouch(CBaseEntity *pOther)
} }
// Temporarily disable the touch function, until movement is finished. // Temporarily disable the touch function, until movement is finished.
SetTouch(NULL); SetTouch(nullptr);
if (code == BUTTON_RETURN) if (code == BUTTON_RETURN)
{ {
@ -703,11 +703,13 @@ void CBaseButton::TriggerAndWait()
if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY)) if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY))
{ {
// ALL buttons are now use only // ALL buttons are now use only
SetTouch(NULL); SetTouch(nullptr);
} }
else else
{
SetTouch(&CBaseButton::ButtonTouch); SetTouch(&CBaseButton::ButtonTouch);
} }
}
else else
{ {
pev->nextthink = pev->ltime + m_flWait; pev->nextthink = pev->ltime + m_flWait;
@ -752,7 +754,7 @@ void CBaseButton::Restart()
} }
else else
{ {
SetTouch(NULL); SetTouch(nullptr);
SetUse(&CBaseButton::ButtonUse); SetUse(&CBaseButton::ButtonUse);
} }
} }
@ -799,10 +801,12 @@ void CBaseButton::ButtonBackHome()
if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY)) if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY))
{ {
// All buttons are now use only // All buttons are now use only
SetTouch(NULL); SetTouch(nullptr);
} }
else else
{
SetTouch(&CBaseButton::ButtonTouch); SetTouch(&CBaseButton::ButtonTouch);
}
// reset think for a sparking button // reset think for a sparking button
if (pev->spawnflags & SF_BUTTON_SPARK_IF_OFF) if (pev->spawnflags & SF_BUTTON_SPARK_IF_OFF)
@ -884,12 +888,15 @@ void CRotButton::Spawn()
// if the button is flagged for USE button activation only, take away it's touch function and add a use function // if the button is flagged for USE button activation only, take away it's touch function and add a use function
if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY)) if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY))
{ {
SetTouch(NULL); SetTouch(nullptr);
SetUse(&CRotButton::ButtonUse); SetUse(&CRotButton::ButtonUse);
} }
else // touchable button // touchable button
else
{
SetTouch(&CRotButton::ButtonTouch); SetTouch(&CRotButton::ButtonTouch);
} }
}
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
void CRotButton::Restart() void CRotButton::Restart()
@ -1092,7 +1099,9 @@ void CMomentaryRotButton::Off()
m_direction = -1; m_direction = -1;
} }
else else
SetThink(NULL); {
SetThink(nullptr);
}
} }
void CMomentaryRotButton::Return() void CMomentaryRotButton::Return()
@ -1115,7 +1124,7 @@ void CMomentaryRotButton::UpdateSelfReturn(float value)
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
pev->angles = m_start; pev->angles = m_start;
pev->nextthink = -1; pev->nextthink = -1;
SetThink(NULL); SetThink(nullptr);
} }
else else
{ {
@ -1135,8 +1144,8 @@ LINK_ENTITY_TO_CLASS(env_debris, CEnvSpark, CCSEnvSpark)
void CEnvSpark::Spawn() void CEnvSpark::Spawn()
{ {
SetThink(NULL); SetThink(nullptr);
SetUse(NULL); SetUse(nullptr);
// Use for on/off // Use for on/off
if (pev->spawnflags & SF_SPARK_TOOGLE) if (pev->spawnflags & SF_SPARK_TOOGLE)
@ -1212,7 +1221,7 @@ void CEnvSpark::SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
void CEnvSpark::SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) void CEnvSpark::SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{ {
SetUse(&CEnvSpark::SparkStart); SetUse(&CEnvSpark::SparkStart);
SetThink(NULL); SetThink(nullptr);
} }
LINK_ENTITY_TO_CLASS(button_target, CButtonTarget, CCSButtonTarget) LINK_ENTITY_TO_CLASS(button_target, CButtonTarget, CCSButtonTarget)
@ -1243,16 +1252,19 @@ void CButtonTarget::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
SUB_UseTargets(pActivator, USE_ON, 0); SUB_UseTargets(pActivator, USE_ON, 0);
} }
else else
{
SUB_UseTargets(pActivator, USE_OFF, 0); SUB_UseTargets(pActivator, USE_OFF, 0);
} }
}
int CButtonTarget::ObjectCaps() int CButtonTarget::ObjectCaps()
{ {
int caps = (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); int caps = (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION);
if (pev->spawnflags & SF_BTARGET_USE) if (pev->spawnflags & SF_BTARGET_USE)
return caps | FCAP_IMPULSE_USE; {
else caps |= FCAP_IMPULSE_USE;
}
return caps; return caps;
} }

View File

@ -129,22 +129,22 @@ void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, b
if (m_rescuer) if (m_rescuer)
{ {
int hostages_ = 0; int hostagesCount = 0;
CHostage *hostageEntity = nullptr; CHostage *pHostage = nullptr;
while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (!hostageEntity->IsAlive()) if (!pHostage->IsAlive())
continue; continue;
if (!hostageEntity->IsFollowingSomeone()) if (!pHostage->IsFollowingSomeone())
continue; continue;
if (hostageEntity->m_target == pVictim) if (pHostage->m_target == pVictim)
++hostages_; hostagesCount++;
} }
if (!hostages_) if (!hostagesCount)
return; return;
} }
@ -164,7 +164,7 @@ void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, b
return; return;
} }
++m_eventsSeen; m_eventsSeen++;
SendPartialNotification(); SendPartialNotification();
} }
@ -189,7 +189,7 @@ void CCareerTask::OnWeaponInjury(int weaponId, int weaponClassId, bool attackerH
return; return;
} }
++m_eventsSeen; m_eventsSeen++;
SendPartialNotification(); SendPartialNotification();
} }
@ -205,26 +205,24 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
if (m_rescuer) if (m_rescuer)
{ {
int hostages_ = 0; int hostagesCount = 0;
CHostage *hostageEntity = nullptr; CHostage *pHostage = nullptr;
while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (!hostageEntity->IsAlive()) if (!pHostage->IsAlive())
continue; continue;
if (!hostageEntity->IsFollowingSomeone()) if (!pHostage->IsFollowingSomeone())
continue; continue;
if (hostageEntity->m_target == pAttacker) if (pHostage->m_target == pAttacker)
++hostages_; hostagesCount++;
} }
if (!hostages_) if (!hostagesCount)
{
return; return;
} }
}
if ((m_event != EVENT_KILL || (!m_weaponId && !m_weaponClassId)) if ((m_event != EVENT_KILL || (!m_weaponId && !m_weaponClassId))
&& (m_event != EVENT_HEADSHOT || (!m_weaponId && !m_weaponClassId)) && (m_event != EVENT_HEADSHOT || (!m_weaponId && !m_weaponClassId))
@ -234,35 +232,35 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
{ {
if (!Q_strcmp(m_name, "defendhostages")) if (!Q_strcmp(m_name, "defendhostages"))
{ {
int hostages_ = 0; int hostagesCount = 0;
CHostage *hostageEntity = nullptr; CHostage *pHostage = nullptr;
while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (hostageEntity->pev->takedamage != DAMAGE_YES && hostageEntity->pev->deadflag != DEAD_DEAD) if (pHostage->pev->takedamage != DAMAGE_YES && pHostage->pev->deadflag != DEAD_DEAD)
++hostages_; hostagesCount++;
} }
if (!hostages_) if (!hostagesCount)
{ {
++m_eventsSeen; m_eventsSeen++;
SendPartialNotification(); SendPartialNotification();
} }
} }
else if (!Q_strcmp(m_name, "hostagessurvive")) else if (!Q_strcmp(m_name, "hostagessurvive"))
{ {
int hostages_ = 0; int hostagesCount = 0;
CHostage *hostageEntity = nullptr; CHostage *pHostage = nullptr;
while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (hostageEntity && hostageEntity->IsDead()) if (pHostage && pHostage->IsDead())
++hostages_; hostagesCount++;
} }
if (!hostages_) if (!hostagesCount)
{ {
++m_eventsSeen; m_eventsSeen++;
SendPartialNotification(); SendPartialNotification();
} }
} }
@ -276,22 +274,22 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
} }
else if (IsTaskCompletableThisRound()) else if (IsTaskCompletableThisRound())
{ {
++m_eventsSeen; m_eventsSeen++;
SendPartialNotification(); SendPartialNotification();
} }
} }
else else
{ {
++m_eventsSeen; m_eventsSeen++;
SendPartialNotification(); SendPartialNotification();
} }
} }
} }
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (event == m_event && !m_mustLive && m_eventsSeen >= m_eventsNeeded && IsTaskCompletableThisRound()) if (event == m_event && !m_mustLive && m_eventsSeen >= m_eventsNeeded && IsTaskCompletableThisRound())
{ {
CBasePlayer *player = UTIL_GetLocalPlayer(); EMIT_SOUND(ENT(pLocalPlayer->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);
EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);
m_isComplete = true; m_isComplete = true;
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
@ -309,7 +307,7 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast")) if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast"))
{ {
TheCareerTasks->SetFinishedTaskTime(int(TheCareerTasks->GetRoundElapsedTime())); TheCareerTasks->SetFinishedTaskTime(int(TheCareerTasks->GetRoundElapsedTime()));
UTIL_GetLocalPlayer()->SyncRoundTimer(); pLocalPlayer->SyncRoundTimer();
} }
} }
else if (event >= EVENT_ROUND_DRAW) else if (event >= EVENT_ROUND_DRAW)
@ -327,8 +325,7 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
{ {
if (m_eventsSeen >= m_eventsNeeded && !m_diedThisRound && IsTaskCompletableThisRound()) if (m_eventsSeen >= m_eventsNeeded && !m_diedThisRound && IsTaskCompletableThisRound())
{ {
CBasePlayer *player = UTIL_GetLocalPlayer(); EMIT_SOUND(ENT(pLocalPlayer->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);
EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM);
m_isComplete = true; m_isComplete = true;
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
@ -341,7 +338,7 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast")) if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast"))
{ {
TheCareerTasks->SetFinishedTaskTime(int(TheCareerTasks->GetRoundElapsedTime())); TheCareerTasks->SetFinishedTaskTime(int(TheCareerTasks->GetRoundElapsedTime()));
UTIL_GetLocalPlayer()->SyncRoundTimer(); pLocalPlayer->SyncRoundTimer();
} }
if (TheTutor) if (TheTutor)
@ -539,11 +536,11 @@ void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker)
if (enemyTeam != team) if (enemyTeam != team)
return; return;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive()) if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive())
++numEnemies; numEnemies++;
} }
if (!numEnemies) if (!numEnemies)
@ -564,13 +561,13 @@ bool CCareerTaskManager::AreAllTasksComplete()
int CCareerTaskManager::GetNumRemainingTasks() int CCareerTaskManager::GetNumRemainingTasks()
{ {
int nCount = 0; int nTasksCount = 0;
for (auto task : m_tasks) { for (auto task : m_tasks) {
if (task->IsComplete()) if (task->IsComplete())
++nCount; nTasksCount++;
} }
return nCount; return nTasksCount;
} }
float CCareerTaskManager::GetRoundElapsedTime() float CCareerTaskManager::GetRoundElapsedTime()

View File

@ -114,10 +114,10 @@ public:
void Reset(bool deleteTasks = true); void Reset(bool deleteTasks = true);
void AddTask(const char *taskName, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, bool isComplete); void AddTask(const char *taskName, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, bool isComplete);
void HandleEvent(GameEventType event, CBasePlayer *pAttacker = NULL, CBasePlayer *pVictim = NULL); void HandleEvent(GameEventType event, CBasePlayer *pAttacker = nullptr, CBasePlayer *pVictim = nullptr);
void HandleEnemyKill(bool wasBlind, const char *weaponName, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim); void HandleEnemyKill(bool wasBlind, const char *weaponName, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim);
void HandleWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim); void HandleWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim);
void HandleDeath(int team, CBasePlayer *pAttacker = NULL); void HandleDeath(int team, CBasePlayer *pAttacker = nullptr);
void HandleWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker); void HandleWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker);
void HandleEnemyInjury(const char *weaponName, bool attackerHasShield, CBasePlayer *pAttacker); void HandleEnemyInjury(const char *weaponName, bool attackerHasShield, CBasePlayer *pAttacker);

View File

@ -412,7 +412,7 @@ void DispatchThink(edict_t *pent)
if (pEntity) if (pEntity)
{ {
if (pEntity->pev->flags & FL_DORMANT) if (pEntity->IsDormant())
{ {
ALERT(at_error, "Dormant entity %s is thinking!!\n", STRING(pEntity->pev->classname)); ALERT(at_error, "Dormant entity %s is thinking!!\n", STRING(pEntity->pev->classname));
} }
@ -451,7 +451,7 @@ void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData)
// These don't use ltime & nextthink as times really, but we'll fudge around it. // These don't use ltime & nextthink as times really, but we'll fudge around it.
if (pEntity->pev->movetype == MOVETYPE_PUSH) if (pEntity->pev->movetype == MOVETYPE_PUSH)
{ {
float_precision delta = pEntity->pev->nextthink - pEntity->pev->ltime; real_t delta = pEntity->pev->nextthink - pEntity->pev->ltime;
pEntity->pev->ltime = gpGlobals->time; pEntity->pev->ltime = gpGlobals->time;
pEntity->pev->nextthink = pEntity->pev->ltime + delta; pEntity->pev->nextthink = pEntity->pev->ltime + delta;
} }
@ -677,7 +677,7 @@ BOOL CBaseEntity::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, fl
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
float_precision flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; real_t flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5;
if (flForce > 1000.0) if (flForce > 1000.0)
flForce = 1000.0; flForce = 1000.0;
@ -769,19 +769,19 @@ void SetObjectCollisionBox(entvars_t *pev)
if (pev->solid == SOLID_BSP && (pev->angles.x || pev->angles.y || pev->angles.z)) if (pev->solid == SOLID_BSP && (pev->angles.x || pev->angles.y || pev->angles.z))
{ {
// expand for rotation // expand for rotation
float_precision max, v; real_t max, v;
int i; int i;
max = 0; max = 0;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
v = Q_fabs(float_precision(((float *)pev->mins)[i])); v = Q_fabs(real_t(((float *)pev->mins)[i]));
if (v > max) if (v > max)
{ {
max = v; max = v;
} }
v = Q_fabs(float_precision(((float *)pev->maxs)[i])); v = Q_fabs(real_t(((float *)pev->maxs)[i]));
if (v > max) if (v > max)
{ {
max = v; max = v;
@ -845,11 +845,6 @@ void CBaseEntity::MakeDormant()
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
} }
int CBaseEntity::IsDormant()
{
return (pev->flags & FL_DORMANT) == FL_DORMANT;
}
BOOL CBaseEntity::IsInWorld() BOOL CBaseEntity::IsInWorld()
{ {
// position // position

View File

@ -151,7 +151,11 @@ public:
bool Intersects(CBaseEntity *pOther); bool Intersects(CBaseEntity *pOther);
bool Intersects(const Vector &mins, const Vector &maxs); bool Intersects(const Vector &mins, const Vector &maxs);
void MakeDormant(); void MakeDormant();
int IsDormant();
// This entity's classname.
const char *GetClassname() const { return pev->classname.str(); }
bool IsDormant() const { return (pev->flags & FL_DORMANT) == FL_DORMANT; }
BOOL IsLockedByMaster() { return FALSE; } BOOL IsLockedByMaster() { return FALSE; }
public: public:
@ -266,7 +270,7 @@ public:
}; };
// Inlines // Inlines
inline BOOL FNullEnt(CBaseEntity *ent) { return (ent == NULL || FNullEnt(ent->edict())); } inline BOOL FNullEnt(CBaseEntity *pEntity) { return (pEntity == nullptr || FNullEnt(pEntity->edict())); }
template <typename T> template <typename T>
inline void CBaseEntity::SetThink(void (T::*pfn)()) inline void CBaseEntity::SetThink(void (T::*pfn)())

View File

@ -446,7 +446,7 @@ NOXREF int CountTeams()
if (pPlayer->m_iTeam == UNASSIGNED) if (pPlayer->m_iTeam == UNASSIGNED)
continue; continue;
if (pPlayer->pev->flags & FL_DORMANT) if (pPlayer->IsDormant())
continue; continue;
if (pPlayer->m_iTeam == SPECTATOR) if (pPlayer->m_iTeam == SPECTATOR)
@ -472,7 +472,7 @@ void ListPlayers(CBasePlayer *current)
if (FNullEnt(pEntity->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (pEntity->pev->flags & FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
@ -499,7 +499,7 @@ int CountTeamPlayers(int iTeam)
if (FNullEnt(pEntity->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (pEntity->pev->flags & FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
if (GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev)->m_iTeam == iTeam) if (GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev)->m_iTeam == iTeam)
@ -655,7 +655,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
SET_CLIENT_MAXSPEED(ENT(pPlayer->pev), 1); SET_CLIENT_MAXSPEED(ENT(pPlayer->pev), 1);
SET_MODEL(ENT(pPlayer->pev), "models/player.mdl"); SET_MODEL(ENT(pPlayer->pev), "models/player.mdl");
pPlayer->SetThink(NULL); pPlayer->SetThink(nullptr);
CBaseEntity *pTarget = nullptr; CBaseEntity *pTarget = nullptr;
pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera"); pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera");
@ -721,7 +721,6 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
void Host_Say(edict_t *pEntity, BOOL teamonly) void Host_Say(edict_t *pEntity, BOOL teamonly)
{ {
CBasePlayer *client;
int j; int j;
char *p; char *p;
char text[128]; char text[128];
@ -919,39 +918,39 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
// This may return the world in single player if the client types something between levels or during spawn // This may return the world in single player if the client types something between levels or during spawn
// so check it, or it will infinite loop // so check it, or it will infinite loop
client = nullptr; CBasePlayer *pReceiver = nullptr;
while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player"))) while ((pReceiver = UTIL_FindEntityByClassname(pReceiver, "player")))
{ {
if (FNullEnt(client->edict())) if (FNullEnt(pReceiver->edict()))
break; break;
if (!client->pev) if (!pReceiver->pev)
continue; continue;
if (client->edict() == pEntity) if (pReceiver->edict() == pEntity)
continue; continue;
// Not a client ? (should never be true) // Not a client ? (should never be true)
if (!client->IsNetClient()) if (!pReceiver->IsNetClient())
continue; continue;
// can the receiver hear the sender? or has he muted him? // can the receiver hear the sender? or has he muted him?
if (gpGlobals->deathmatch != 0.0f && CSGameRules()->m_VoiceGameMgr.PlayerHasBlockedPlayer(client, pPlayer)) if (gpGlobals->deathmatch != 0.0f && CSGameRules()->m_VoiceGameMgr.PlayerHasBlockedPlayer(pReceiver, pPlayer))
continue; continue;
if (teamonly && client->m_iTeam != pPlayer->m_iTeam) if (teamonly && pReceiver->m_iTeam != pPlayer->m_iTeam)
continue; continue;
if ((client->pev->deadflag != DEAD_NO && !bSenderDead) || (client->pev->deadflag == DEAD_NO && bSenderDead)) if ((pReceiver->pev->deadflag != DEAD_NO && !bSenderDead) || (pReceiver->pev->deadflag == DEAD_NO && bSenderDead))
{ {
if (!(pPlayer->pev->flags & FL_PROXY)) if (!(pPlayer->pev->flags & FL_PROXY))
continue; continue;
} }
if ((client->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY && client->m_iTeam == pPlayer->m_iTeam) if ((pReceiver->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY && pReceiver->m_iTeam == pPlayer->m_iTeam)
|| client->m_iIgnoreGlobalChat == IGNOREMSG_NONE) || pReceiver->m_iIgnoreGlobalChat == IGNOREMSG_NONE)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, client->pev); MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, pReceiver->pev);
WRITE_BYTE(ENTINDEX(pEntity)); WRITE_BYTE(ENTINDEX(pEntity));
WRITE_STRING(pszFormat); WRITE_STRING(pszFormat);
WRITE_STRING(""); WRITE_STRING("");
@ -966,8 +965,6 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
} }
} }
char *fullText = p;
// print to the sending client // print to the sending client
MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, &pEntity->v); MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, &pEntity->v);
WRITE_BYTE(ENTINDEX(pEntity)); WRITE_BYTE(ENTINDEX(pEntity));
@ -991,7 +988,9 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), text)); SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(pPlayer->pev->netname), text));
} }
else else
{
SERVER_PRINT(text); SERVER_PRINT(text);
}
if (logmessages.value) if (logmessages.value)
{ {
@ -1001,7 +1000,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
char *szTeam = GetTeam(pPlayer->m_iTeam); char *szTeam = GetTeam(pPlayer->m_iTeam);
UTIL_LogPrintf("\"%s<%i><%s><%s>\" %s \"%s\"%s\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()), UTIL_LogPrintf("\"%s<%i><%s><%s>\" %s \"%s\"%s\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()),
szTeam, temp, fullText, deadText); szTeam, temp, p, deadText);
} }
} }
@ -3363,7 +3362,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
{ {
pPlayer->ClearAutoBuyData(); pPlayer->ClearAutoBuyData();
for (int i = 1; i < CMD_ARGC_(); ++i) for (int i = 1; i < CMD_ARGC_(); i++)
{ {
pPlayer->AddAutoBuyData(CMD_ARGV_(i)); pPlayer->AddAutoBuyData(CMD_ARGV_(i));
} }
@ -3534,7 +3533,7 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
EmptyEntityHashTable(); EmptyEntityHashTable();
// Clients have not been initialized yet // Clients have not been initialized yet
for (i = 0; i < edictCount; ++i) for (i = 0; i < edictCount; i++)
{ {
edict_t *pEdict = &pEdictList[i]; edict_t *pEdict = &pEdictList[i];
@ -3548,14 +3547,16 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
pClass = CBaseEntity::Instance(pEdict); pClass = CBaseEntity::Instance(pEdict);
// Activate this entity if it's got a class & isn't dormant // Activate this entity if it's got a class & isn't dormant
if (pClass && !(pClass->pev->flags & FL_DORMANT)) if (pClass && !pClass->IsDormant())
{ {
AddEntityHashValue(&pEdict->v, STRING(pEdict->v.classname), CLASSNAME); AddEntityHashValue(&pEdict->v, STRING(pEdict->v.classname), CLASSNAME);
pClass->Activate(); pClass->Activate();
} }
else else
{
ALERT(at_console, "Can't instance %s\n", STRING(pEdict->v.classname)); ALERT(at_console, "Can't instance %s\n", STRING(pEdict->v.classname));
} }
}
// Link user messages here to make sure first client can get them... // Link user messages here to make sure first client can get them...
LinkUserMessages(); LinkUserMessages();
@ -3771,12 +3772,12 @@ void ClientPrecache()
else else
numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2; numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2;
for (i = 0; i < numPlayerModels; ++i) for (i = 0; i < numPlayerModels; i++)
PRECACHE_MODEL(sPlayerModelFiles[i]); PRECACHE_MODEL(sPlayerModelFiles[i]);
if (AreRunningCZero()) if (AreRunningCZero())
{ {
for (i = FirstCustomSkin; i <= LastCustomSkin; ++i) for (i = FirstCustomSkin; i <= LastCustomSkin; i++)
{ {
const char *fname = TheBotProfiles->GetCustomSkinFname(i); const char *fname = TheBotProfiles->GetCustomSkinFname(i);
@ -3836,12 +3837,12 @@ void ClientPrecache()
Vector vMin(-38, -24, -41); Vector vMin(-38, -24, -41);
Vector vMax(38, 24, 41); Vector vMax(38, 24, 41);
for (i = 0; i < numPlayerModels; ++i) for (i = 0; i < numPlayerModels; i++)
ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]); ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]);
if (AreRunningCZero()) if (AreRunningCZero())
{ {
for (i = FirstCustomSkin; i <= LastCustomSkin; ++i) for (i = FirstCustomSkin; i <= LastCustomSkin; i++)
{ {
const char *fname = TheBotProfiles->GetCustomSkinFname(i); const char *fname = TheBotProfiles->GetCustomSkinFname(i);
if (!fname) if (!fname)
@ -4198,11 +4199,12 @@ bool CheckPlayerPVSLeafChanged(edict_t *client, int clientnum)
if (pvs->headnode != client->headnode || pvs->num_leafs != client->num_leafs) if (pvs->headnode != client->headnode || pvs->num_leafs != client->num_leafs)
return true; return true;
for (int i = 0; i < pvs->num_leafs; ++i) for (int i = 0; i < pvs->num_leafs; i++)
{ {
if (client->leafnums[i] != pvs->leafnums[i]) if (client->leafnums[i] != pvs->leafnums[i])
return true; return true;
} }
return false; return false;
} }
@ -4325,10 +4327,10 @@ BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, e
state->framerate = ent->v.framerate; state->framerate = ent->v.framerate;
state->body = ent->v.body; state->body = ent->v.body;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; i++)
state->controller[i] = ent->v.controller[i]; state->controller[i] = ent->v.controller[i];
for (i = 0; i < 2; ++i) for (i = 0; i < 2; i++)
state->blending[i] = ent->v.blending[i]; state->blending[i] = ent->v.blending[i];
state->rendermode = ent->v.rendermode; state->rendermode = ent->v.rendermode;

View File

@ -94,14 +94,14 @@ void SV_Career_EndRound_f()
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->pev)) if (!pPlayer || FNullEnt(pPlayer->pev))
continue; continue;
if (player->IsBot() && player->m_iTeam == pLocalPlayer->m_iTeam) if (pPlayer->IsBot() && pPlayer->m_iTeam == pLocalPlayer->m_iTeam)
{ {
SERVER_COMMAND(UTIL_VarArgs("bot_kill \"%s\"\n", STRING(player->pev->netname))); SERVER_COMMAND(UTIL_VarArgs("bot_kill \"%s\"\n", STRING(pPlayer->pev->netname)));
} }
} }
} }

View File

@ -6,7 +6,7 @@ void PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAt
if (!fadetoblack.value) if (!fadetoblack.value)
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *pObserver = UTIL_PlayerByIndex(i); CBasePlayer *pObserver = UTIL_PlayerByIndex(i);
if (pObserver && pObserver->IsObservingPlayer(pPlayer)) if (pObserver && pObserver->IsObservingPlayer(pPlayer))
@ -132,7 +132,7 @@ void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker,
} }
} }
float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity) float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *pEntity)
{ {
float retval = 0.0f; float retval = 0.0f;
TraceResult tr; TraceResult tr;
@ -148,10 +148,10 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity)
const float damagePercentageRightSide = 0.10f; const float damagePercentageRightSide = 0.10f;
const float damagePercentageLeftSide = 0.10f; const float damagePercentageLeftSide = 0.10f;
if (!entity->IsPlayer()) if (!pEntity->IsPlayer())
{ {
// the entity is not a player, so the damage is all or nothing. // the entity is not a player, so the damage is all or nothing.
UTIL_TraceLine(vecSrc, entity->pev->origin, ignore_monsters, nullptr, &tr); UTIL_TraceLine(vecSrc, pEntity->pev->origin, ignore_monsters, nullptr, &tr);
if (tr.flFraction == 1.0f) if (tr.flFraction == 1.0f)
retval = 1.0f; retval = 1.0f;
@ -160,34 +160,34 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity)
} }
// check chest // check chest
Vector vecChest = entity->pev->origin; Vector vecChest = pEntity->pev->origin;
UTIL_TraceLine(vecSrc, vecChest, ignore_monsters, nullptr, &tr); UTIL_TraceLine(vecSrc, vecChest, ignore_monsters, nullptr, &tr);
if (tr.flFraction == 1.0f) if (tr.flFraction == 1.0f)
retval += damagePercentageChest; retval += damagePercentageChest;
// check top of head // check top of head
Vector vecHead = entity->pev->origin + Vector(0, 0, topOfHead); Vector vecHead = pEntity->pev->origin + Vector(0, 0, topOfHead);
UTIL_TraceLine(vecSrc, vecHead, ignore_monsters, nullptr, &tr); UTIL_TraceLine(vecSrc, vecHead, ignore_monsters, nullptr, &tr);
if (tr.flFraction == 1.0f) if (tr.flFraction == 1.0f)
retval += damagePercentageHead; retval += damagePercentageHead;
// check feet // check feet
Vector vecFeet = entity->pev->origin; Vector vecFeet = pEntity->pev->origin;
vecFeet.z -= (entity->pev->flags & FL_DUCKING) ? crouchFeet : standFeet; vecFeet.z -= (pEntity->pev->flags & FL_DUCKING) ? crouchFeet : standFeet;
UTIL_TraceLine(vecSrc, vecFeet, ignore_monsters, nullptr, &tr); UTIL_TraceLine(vecSrc, vecFeet, ignore_monsters, nullptr, &tr);
if (tr.flFraction == 1.0f) if (tr.flFraction == 1.0f)
retval += damagePercentageFeet; retval += damagePercentageFeet;
Vector2D dir = (entity->pev->origin - vecSrc).Make2D(); Vector2D dir = (pEntity->pev->origin - vecSrc).Make2D();
dir.NormalizeInPlace(); dir.NormalizeInPlace();
Vector2D perp(-dir.y * edgeOffset, dir.x * edgeOffset); Vector2D perp(-dir.y * edgeOffset, dir.x * edgeOffset);
Vector vecRightSide = entity->pev->origin + Vector(perp.x, perp.y, 0); Vector vecRightSide = pEntity->pev->origin + Vector(perp.x, perp.y, 0);
Vector vecLeftSide = entity->pev->origin - Vector(perp.x, perp.y, 0); Vector vecLeftSide = pEntity->pev->origin - Vector(perp.x, perp.y, 0);
// check right "edge" // check right "edge"
UTIL_TraceLine(vecSrc, vecRightSide, ignore_monsters, nullptr, &tr); UTIL_TraceLine(vecSrc, vecRightSide, ignore_monsters, nullptr, &tr);

View File

@ -213,7 +213,7 @@ void CBaseDoor::Spawn()
m_vecPosition1 = pev->origin; m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (Q_fabs(float_precision(pev->movedir.x * (pev->size.x - 2))) + Q_fabs(float_precision(pev->movedir.y * (pev->size.y - 2))) + Q_fabs(float_precision(pev->movedir.z * (pev->size.z - 2))) - m_flLip)); m_vecPosition2 = m_vecPosition1 + (pev->movedir * (Q_fabs(real_t(pev->movedir.x * (pev->size.x - 2))) + Q_fabs(real_t(pev->movedir.y * (pev->size.y - 2))) + Q_fabs(real_t(pev->movedir.z * (pev->size.z - 2))) - m_flLip));
assert(("door start/end positions are equal", m_vecPosition1 != m_vecPosition2)); assert(("door start/end positions are equal", m_vecPosition1 != m_vecPosition2));
@ -230,7 +230,7 @@ void CBaseDoor::Spawn()
// if the door is flagged for USE button activation only, use NULL touch function // if the door is flagged for USE button activation only, use NULL touch function
if (pev->spawnflags & SF_DOOR_USE_ONLY) if (pev->spawnflags & SF_DOOR_USE_ONLY)
{ {
SetTouch(NULL); SetTouch(nullptr);
} }
else else
{ {
@ -248,7 +248,7 @@ void CBaseDoor::Restart()
DoorGoDown(); DoorGoDown();
if (pev->spawnflags & SF_DOOR_USE_ONLY) if (pev->spawnflags & SF_DOOR_USE_ONLY)
SetTouch(NULL); SetTouch(nullptr);
else else
SetTouch(&CBaseDoor::DoorTouch); SetTouch(&CBaseDoor::DoorTouch);
} }
@ -442,7 +442,7 @@ void CBaseDoor::DoorTouch(CBaseEntity *pOther)
if (DoorActivate()) if (DoorActivate())
{ {
// Temporarily disable the touch function, until movement is finished. // Temporarily disable the touch function, until movement is finished.
SetTouch(NULL); SetTouch(nullptr);
} }
} }
@ -717,7 +717,7 @@ void CBaseDoor::DoorHitBottom()
if (pev->spawnflags & SF_DOOR_USE_ONLY) if (pev->spawnflags & SF_DOOR_USE_ONLY)
{ {
// use only door // use only door
SetTouch(NULL); SetTouch(nullptr);
} }
else else
{ {
@ -942,7 +942,7 @@ void CRotDoor::Spawn()
if (pev->spawnflags & SF_DOOR_USE_ONLY) if (pev->spawnflags & SF_DOOR_USE_ONLY)
{ {
SetTouch(NULL); SetTouch(nullptr);
} }
else else
{ {
@ -988,7 +988,7 @@ void CMomentaryDoor::Spawn()
m_vecPosition1 = pev->origin; m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (Q_fabs(float_precision(pev->movedir.x * (pev->size.x - 2))) + Q_fabs(float_precision(pev->movedir.y * (pev->size.y - 2))) + Q_fabs(float_precision(pev->movedir.z * (pev->size.z - 2))) - m_flLip)); m_vecPosition2 = m_vecPosition1 + (pev->movedir * (Q_fabs(real_t(pev->movedir.x * (pev->size.x - 2))) + Q_fabs(real_t(pev->movedir.y * (pev->size.y - 2))) + Q_fabs(real_t(pev->movedir.z * (pev->size.z - 2))) - m_flLip));
assert(("door start/end positions are equal", m_vecPosition1 != m_vecPosition2)); assert(("door start/end positions are equal", m_vecPosition1 != m_vecPosition2));
if (pev->spawnflags & SF_DOOR_START_OPEN) if (pev->spawnflags & SF_DOOR_START_OPEN)
@ -1000,7 +1000,7 @@ void CMomentaryDoor::Spawn()
m_vecPosition1 = pev->origin; m_vecPosition1 = pev->origin;
} }
SetTouch(NULL); SetTouch(nullptr);
Precache(); Precache();
} }

View File

@ -58,7 +58,7 @@ void CBubbling::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT
} }
else else
{ {
SetThink(NULL); SetThink(nullptr);
pev->nextthink = 0; pev->nextthink = 0;
} }
} }
@ -334,7 +334,7 @@ void CLightning::Spawn()
if (ServerSide()) if (ServerSide())
{ {
SetThink(NULL); SetThink(nullptr);
if (pev->dmg > 0) if (pev->dmg > 0)
{ {
SetThink(&CLightning::DamageThink); SetThink(&CLightning::DamageThink);
@ -477,7 +477,7 @@ void CLightning::StrikeUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
if (m_active) if (m_active)
{ {
m_active = 0; m_active = 0;
SetThink(NULL); SetThink(nullptr);
} }
else else
{ {
@ -486,7 +486,7 @@ void CLightning::StrikeUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
} }
if (!(pev->spawnflags & SF_BEAM_TOGGLE)) if (!(pev->spawnflags & SF_BEAM_TOGGLE))
SetUse(NULL); SetUse(nullptr);
} }
int IsPointEntity(CBaseEntity *pEnt) int IsPointEntity(CBaseEntity *pEnt)
@ -1021,7 +1021,7 @@ void CGlow::Animate(float frames)
{ {
if (m_maxFrame > 0) if (m_maxFrame > 0)
{ {
pev->frame = Q_fmod(float_precision(pev->frame + frames), float_precision(m_maxFrame)); pev->frame = Q_fmod(real_t(pev->frame + frames), real_t(m_maxFrame));
} }
} }
@ -1222,7 +1222,7 @@ void CSprite::Animate(float frames)
TurnOff(); TurnOff();
else if (m_maxFrame > 0) else if (m_maxFrame > 0)
pev->frame = Q_fmod(float_precision(pev->frame), float_precision(m_maxFrame)); pev->frame = Q_fmod(real_t(pev->frame), real_t(m_maxFrame));
} }
} }
@ -1414,7 +1414,7 @@ void CGibShooter::ShootThink()
if (pev->spawnflags & SF_GIBSHOOTER_REPEATABLE) if (pev->spawnflags & SF_GIBSHOOTER_REPEATABLE)
{ {
m_iGibs = m_iGibCapacity; m_iGibs = m_iGibCapacity;
SetThink(NULL); SetThink(nullptr);
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
else else
@ -1544,7 +1544,7 @@ void CTestEffect::TestThink()
if (t < 3.0) if (t < 3.0)
{ {
for (i = 0; i < m_iBeam; ++i) for (i = 0; i < m_iBeam; i++)
{ {
t = (gpGlobals->time - m_flBeamTime[i]) / (3.0f + m_flStartTime - m_flBeamTime[i]); t = (gpGlobals->time - m_flBeamTime[i]) / (3.0f + m_flStartTime - m_flBeamTime[i]);
m_pBeam[i]->SetBrightness(int(255.0f * t)); m_pBeam[i]->SetBrightness(int(255.0f * t));
@ -1554,14 +1554,14 @@ void CTestEffect::TestThink()
} }
else else
{ {
for (i = 0; i < m_iBeam; ++i) for (i = 0; i < m_iBeam; i++)
{ {
UTIL_Remove(m_pBeam[i]); UTIL_Remove(m_pBeam[i]);
} }
m_flStartTime = gpGlobals->time; m_flStartTime = gpGlobals->time;
m_iBeam = 0; m_iBeam = 0;
SetThink(NULL); SetThink(nullptr);
} }
} }
@ -1965,7 +1965,7 @@ void CItemSoda::CanThink()
pev->solid = SOLID_TRIGGER; pev->solid = SOLID_TRIGGER;
UTIL_SetSize(pev, Vector(-8, -8, 0), Vector(8, 8, 8)); UTIL_SetSize(pev, Vector(-8, -8, 0), Vector(8, 8, 8));
SetThink(NULL); SetThink(nullptr);
SetTouch(&CItemSoda::CanTouch); SetTouch(&CItemSoda::CanTouch);
} }
@ -2002,7 +2002,7 @@ void CItemSoda::CanTouch(CBaseEntity *pOther)
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
pev->effects = EF_NODRAW; pev->effects = EF_NODRAW;
SetTouch(NULL); SetTouch(nullptr);
SetThink(&CItemSoda::SUB_Remove); SetThink(&CItemSoda::SUB_Remove);
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }

View File

@ -88,7 +88,7 @@ public:
void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
void SetBrightness(int brightness) { pev->renderamt = brightness; } void SetBrightness(int brightness) { pev->renderamt = brightness; }
void AnimateAndDie(float_precision framerate) void AnimateAndDie(real_t framerate)
{ {
SetThink(&CSprite::AnimateUntilDead); SetThink(&CSprite::AnimateUntilDead);
pev->framerate = framerate; pev->framerate = framerate;

View File

@ -165,8 +165,7 @@ void CEnvExplosion::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
if (!(pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS)) if (!(pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS))
{ {
int sparkCount = RANDOM_LONG(0, 3); int sparkCount = RANDOM_LONG(0, 3);
for (int i = 0; i < sparkCount; i++)
for (int i = 0; i < sparkCount; ++i)
{ {
Create("spark_shower", pev->origin, tr.vecPlaneNormal, nullptr); Create("spark_shower", pev->origin, tr.vecPlaneNormal, nullptr);
} }
@ -194,7 +193,7 @@ void CEnvExplosion::Smoke()
} }
} }
// HACKHACK -- create one of these and fake a keyvalue to get the right explosion setup // HACKHACK: create one of these and fake a keyvalue to get the right explosion setup
void ExplosionCreate(const Vector &center, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage) void ExplosionCreate(const Vector &center, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage)
{ {
KeyValueData kvd; KeyValueData kvd;

View File

@ -119,7 +119,7 @@ void CBreakable::Spawn()
// Only break on trigger // Only break on trigger
if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY) if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY)
{ {
SetTouch(NULL); SetTouch(nullptr);
} }
// Flag unbreakable glass as "worldbrush" so it will block ALL tracelines // Flag unbreakable glass as "worldbrush" so it will block ALL tracelines
@ -150,7 +150,7 @@ void CBreakable::Restart()
if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY) if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY)
{ {
SetTouch(NULL); SetTouch(nullptr);
} }
if (!IsBreakable() && pev->rendermode != kRenderNormal) if (!IsBreakable() && pev->rendermode != kRenderNormal)
@ -282,7 +282,7 @@ void CBreakable::MaterialSoundPrecache(Materials precacheMaterial)
pSoundList = MaterialSoundList(precacheMaterial, soundCount); pSoundList = MaterialSoundList(precacheMaterial, soundCount);
for (i = 0; i < soundCount; ++i) for (i = 0; i < soundCount; i++)
{ {
PRECACHE_SOUND((char *)pSoundList[i]); PRECACHE_SOUND((char *)pSoundList[i]);
} }
@ -487,7 +487,7 @@ void CBreakable::BreakTouch(CBaseEntity *pOther)
if (flDamage >= pev->health) if (flDamage >= pev->health)
{ {
SetTouch(NULL); SetTouch(nullptr);
TakeDamage(pevToucher, pevToucher, flDamage, DMG_CRUSH); TakeDamage(pevToucher, pevToucher, flDamage, DMG_CRUSH);
// do a little damage to player if we broke glass or computer // do a little damage to player if we broke glass or computer
@ -502,7 +502,7 @@ void CBreakable::BreakTouch(CBaseEntity *pOther)
DamageSound(); DamageSound();
SetThink(&CBreakable::Die); SetThink(&CBreakable::Die);
SetTouch(NULL); SetTouch(nullptr);
// BUGBUG: why doesn't zero delay work? // BUGBUG: why doesn't zero delay work?
if (m_flDelay == 0.0f) if (m_flDelay == 0.0f)
@ -803,15 +803,15 @@ void CBreakable::Die()
CBaseEntity *pList[256]; CBaseEntity *pList[256];
int count = UTIL_EntitiesInBox(pList, ARRAYSIZE(pList), mins, maxs, FL_ONGROUND); int count = UTIL_EntitiesInBox(pList, ARRAYSIZE(pList), mins, maxs, FL_ONGROUND);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; i++)
{ {
pList[i]->pev->flags &= ~FL_ONGROUND; pList[i]->pev->flags &= ~FL_ONGROUND;
pList[i]->pev->groundentity = nullptr; pList[i]->pev->groundentity = nullptr;
} }
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
SUB_UseTargets(NULL, USE_TOGGLE, 0); SUB_UseTargets(nullptr, USE_TOGGLE, 0);
SetThink(NULL); SetThink(nullptr);
pev->nextthink = pev->ltime + 0.1f; pev->nextthink = pev->ltime + 0.1f;
@ -1023,7 +1023,7 @@ void CPushable::Move(CBaseEntity *pOther, int push)
bPlayerTouch = true; bPlayerTouch = true;
} }
float_precision factor; real_t factor;
if (bPlayerTouch) if (bPlayerTouch)
{ {
@ -1039,12 +1039,14 @@ void CPushable::Move(CBaseEntity *pOther, int push)
factor = 1.0f; factor = 1.0f;
} }
else else
{
factor = 0.25f; factor = 0.25f;
}
pev->velocity.x += pevToucher->velocity.x * factor; pev->velocity.x += pevToucher->velocity.x * factor;
pev->velocity.y += pevToucher->velocity.y * factor; pev->velocity.y += pevToucher->velocity.y * factor;
float_precision length = Q_sqrt(pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y); real_t length = Q_sqrt(pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y);
if (push && (length > MaxSpeed())) if (push && (length > MaxSpeed()))
{ {

View File

@ -361,7 +361,7 @@ void CFuncTank::Think()
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
TrackTarget(); TrackTarget();
if (fabs(float_precision(pev->avelocity.x)) > 1 || fabs(float_precision(pev->avelocity.y)) > 1) if (Q_fabs(real_t(pev->avelocity.x)) > 1 || Q_fabs(real_t(pev->avelocity.y)) > 1)
StartRotSound(); StartRotSound();
else else
StopRotSound(); StopRotSound();
@ -468,7 +468,7 @@ void CFuncTank::TrackTarget()
} }
// Move toward target at rate or less // Move toward target at rate or less
float_precision distY = UTIL_AngleDistance(angles.y, pev->angles.y); real_t distY = UTIL_AngleDistance(angles.y, pev->angles.y);
pev->avelocity.y = distY * 10.0f; pev->avelocity.y = distY * 10.0f;
if (pev->avelocity.y > m_yawRate) if (pev->avelocity.y > m_yawRate)
@ -491,7 +491,7 @@ void CFuncTank::TrackTarget()
} }
// Move toward target at rate or less // Move toward target at rate or less
float_precision distX = UTIL_AngleDistance(angles.x, pev->angles.x); real_t distX = UTIL_AngleDistance(angles.x, pev->angles.x);
pev->avelocity.x = distX * 10.0f; pev->avelocity.x = distX * 10.0f;
if (pev->avelocity.x > m_pitchRate) if (pev->avelocity.x > m_pitchRate)
@ -508,7 +508,7 @@ void CFuncTank::TrackTarget()
return; return;
} }
if (CanFire() && ((fabs(distX) < m_pitchTolerance && fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT))) if (CanFire() && ((Q_fabs(distX) < m_pitchTolerance && Q_fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT)))
{ {
bool fire = false; bool fire = false;
Vector forward; Vector forward;
@ -541,7 +541,7 @@ void CFuncTank::TrackTarget()
// If barrel is offset, add in additional rotation // If barrel is offset, add in additional rotation
void CFuncTank::AdjustAnglesForBarrel(Vector &angles, float distance) void CFuncTank::AdjustAnglesForBarrel(Vector &angles, float distance)
{ {
float_precision r2, d2; real_t r2, d2;
if (m_barrelPos.y != 0.0f || m_barrelPos.z != 0.0f) if (m_barrelPos.y != 0.0f || m_barrelPos.z != 0.0f)
{ {
@ -599,7 +599,7 @@ void CFuncTank::TankTrace(const Vector &vecStart, const Vector &vecForward, cons
{ {
// get circular gaussian spread // get circular gaussian spread
float x, z; float x, z;
float_precision y; real_t y;
do do
{ {

View File

@ -651,9 +651,9 @@ public:
VFUNC void SetAccountRules(RewardRules rules, int amount) { m_rgRewardAccountRules[rules] = static_cast<RewardAccount>(amount); } VFUNC void SetAccountRules(RewardRules rules, int amount) { m_rgRewardAccountRules[rules] = static_cast<RewardAccount>(amount); }
VFUNC RewardAccount GetAccountRules(RewardRules rules) const { return m_rgRewardAccountRules[rules]; } VFUNC RewardAccount GetAccountRules(RewardRules rules) const { return m_rgRewardAccountRules[rules]; }
void DisplayMaps(CBasePlayer *player, int iVote); void DisplayMaps(CBasePlayer *pPlayer, int iVote);
void ResetAllMapVotes(); void ResetAllMapVotes();
void ProcessMapVote(CBasePlayer *player, int iVote); void ProcessMapVote(CBasePlayer *pPlayer, int iVote);
// BOMB MAP FUNCTIONS // BOMB MAP FUNCTIONS
VFUNC BOOL IsThereABomber(); VFUNC BOOL IsThereABomber();

View File

@ -79,6 +79,7 @@ void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType)
pev->velocity = g_vecZero; pev->velocity = g_vecZero;
pev->nextthink = gpGlobals->time + 0.3f; pev->nextthink = gpGlobals->time + 0.3f;
// draw sparks
if (iContents != CONTENTS_WATER) if (iContents != CONTENTS_WATER)
{ {
int sparkCount = RANDOM_LONG(0, 3); int sparkCount = RANDOM_LONG(0, 3);
@ -469,7 +470,7 @@ void CGrenade::SG_Smoke()
else else
{ {
Vector origin, angle; Vector origin, angle;
float_precision x_old, y_old, R_angle; real_t x_old, y_old, R_angle;
UTIL_MakeVectors(pev->angles); UTIL_MakeVectors(pev->angles);
@ -479,8 +480,8 @@ void CGrenade::SG_Smoke()
R_angle = m_angle / (180.00433335 / M_PI); R_angle = m_angle / (180.00433335 / M_PI);
x_old = Q_cos(float_precision(R_angle)); x_old = Q_cos(real_t(R_angle));
y_old = Q_sin(float_precision(R_angle)); y_old = Q_sin(real_t(R_angle));
angle.x = origin.x * x_old - origin.y * y_old; angle.x = origin.x * x_old - origin.y * y_old;
angle.y = origin.x * y_old + origin.y * x_old; angle.y = origin.x * y_old + origin.y * x_old;
@ -949,18 +950,18 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
return; return;
// TODO: We must be sure that the activator is a player. // TODO: We must be sure that the activator is a player.
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pActivator->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pActivator->pev);
// For CTs to defuse the c4 // For CTs to defuse the c4
if (player->m_iTeam != CT) if (pPlayer->m_iTeam != CT)
{ {
return; return;
} }
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if((player->pev->flags & FL_ONGROUND) != FL_ONGROUND) // Defuse should start only on ground if((pPlayer->pev->flags & FL_ONGROUND) != FL_ONGROUND) // Defuse should start only on ground
{ {
ClientPrint(player->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground"); ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground");
return; return;
} }
#endif #endif
@ -972,7 +973,7 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
} }
// freeze the player in place while defusing // freeze the player in place while defusing
SET_CLIENT_MAXSPEED(player->edict(), 1); SET_CLIENT_MAXSPEED(pPlayer->edict(), 1);
if (TheBots) if (TheBots)
{ {
@ -984,38 +985,38 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
TheCareerTasks->HandleEvent(EVENT_BOMB_DEFUSING); TheCareerTasks->HandleEvent(EVENT_BOMB_DEFUSING);
} }
if (player->m_bHasDefuser) if (pPlayer->m_bHasDefuser)
{ {
UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n", UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n",
STRING(player->pev->netname), STRING(pPlayer->pev->netname),
GETPLAYERUSERID(player->edict()), GETPLAYERUSERID(pPlayer->edict()),
GETPLAYERAUTHID(player->edict())); GETPLAYERAUTHID(pPlayer->edict()));
// TODO show messages on clients on event // TODO show messages on clients on event
ClientPrint(player->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit"); ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit");
m_flDefuseCountDown = gpGlobals->time + 5.0f; m_flDefuseCountDown = gpGlobals->time + 5.0f;
// start the progress bar // start the progress bar
player->SetProgressBarTime(5); pPlayer->SetProgressBarTime(5);
} }
else else
{ {
UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_Without_Kit\"\n", UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Begin_Bomb_Defuse_Without_Kit\"\n",
STRING(player->pev->netname), STRING(pPlayer->pev->netname),
GETPLAYERUSERID(player->edict()), GETPLAYERUSERID(pPlayer->edict()),
GETPLAYERAUTHID(player->edict())); GETPLAYERAUTHID(pPlayer->edict()));
// TODO: show messages on clients on event // TODO: show messages on clients on event
ClientPrint(player->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit"); ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit");
m_flDefuseCountDown = gpGlobals->time + 10.0f; m_flDefuseCountDown = gpGlobals->time + 10.0f;
// start the progress bar // start the progress bar
player->SetProgressBarTime(10); pPlayer->SetProgressBarTime(10);
} }
player->m_bIsDefusing = true; pPlayer->m_bIsDefusing = true;
m_pBombDefuser = static_cast<CBasePlayer *>(pActivator); m_pBombDefuser = static_cast<CBasePlayer *>(pActivator);
m_bStartDefuse = true; m_bStartDefuse = true;
m_fNextDefuse = gpGlobals->time + NEXT_DEFUSE_TIME; m_fNextDefuse = gpGlobals->time + NEXT_DEFUSE_TIME;
@ -1023,7 +1024,7 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
EMIT_SOUND(edict(), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); // Emit sound using bomb. EMIT_SOUND(edict(), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); // Emit sound using bomb.
#else #else
EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM);
#endif #endif
} }

View File

@ -21,7 +21,7 @@ NOXREF void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cG
return; return;
} }
for (int i = 0; i < cGibs; ++i) for (int i = 0; i < cGibs; i++)
{ {
CGib *pGib = GetClassPtr<CCSGib>((CGib *)nullptr); CGib *pGib = GetClassPtr<CCSGib>((CGib *)nullptr);
@ -67,7 +67,7 @@ NOXREF void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cG
pGib->pev->solid = SOLID_BBOX; pGib->pev->solid = SOLID_BBOX;
UTIL_SetSize(pGib->pev, Vector(0, 0,0), Vector(0, 0, 0)); UTIL_SetSize(pGib->pev, Vector(0, 0,0), Vector(0, 0, 0));
pGib->SetTouch(&CGib::StickyGibTouch); pGib->SetTouch(&CGib::StickyGibTouch);
pGib->SetThink(NULL); pGib->SetThink(nullptr);
} }
pGib->LimitVelocity(); pGib->LimitVelocity();
@ -136,8 +136,7 @@ void CGib::SpawnHeadGib(entvars_t *pevVictim)
void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human) void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human)
{ {
int cSplat; for (int cSplat = 0; cSplat < cGibs; cSplat++)
for (cSplat = 0; cSplat < cGibs; ++cSplat)
{ {
CGib *pGib = GetClassPtr<CCSGib>((CGib *)nullptr); CGib *pGib = GetClassPtr<CCSGib>((CGib *)nullptr);

View File

@ -226,7 +226,7 @@ void CCyclerSprite::Animate(float frames)
if (m_maxFrame > 0) if (m_maxFrame > 0)
{ {
pev->frame = Q_fmod(float_precision(pev->frame), float_precision(m_maxFrame)); pev->frame = Q_fmod(real_t(pev->frame), real_t(m_maxFrame));
} }
} }

View File

@ -398,7 +398,9 @@ void CHostage::IdleThink()
pPlayer = m_improv->GetFollowLeader(); pPlayer = m_improv->GetFollowLeader();
} }
else else
{
pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)m_hTargetEnt->pev); pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)m_hTargetEnt->pev);
}
if (!pPlayer || pPlayer->m_iTeam == CT) if (!pPlayer || pPlayer->m_iTeam == CT)
{ {
@ -1002,7 +1004,7 @@ void CHostage::Touch(CBaseEntity *pOther)
pev->velocity.y += vPush.y; pev->velocity.y += vPush.y;
#else #else
// TODO: fix test demo // TODO: fix test demo
pev->velocity = pev->velocity + NormalizeMulScalar<float_precision, float_precision, float>(vPush, pushForce); pev->velocity = pev->velocity + NormalizeMulScalar<real_t, real_t, float>(vPush, pushForce);
#endif #endif
} }
@ -1114,7 +1116,7 @@ void CHostage::MoveToward(const Vector &vecLoc)
Vector vecbigDest; Vector vecbigDest;
Vector vecMove; Vector vecMove;
CBaseEntity *pFollowing; CBaseEntity *pFollowing;
float_precision flDist; real_t flDist;
pFollowing = GetClassPtr<CCSEntity>((CBaseEntity *)m_hTargetEnt->pev); pFollowing = GetClassPtr<CCSEntity>((CBaseEntity *)m_hTargetEnt->pev);
vecMove = vecLoc - pev->origin; vecMove = vecLoc - pev->origin;
@ -1132,7 +1134,7 @@ void CHostage::MoveToward(const Vector &vecLoc)
auto nFwdMove = m_LocalNav->PathTraversable(pev->origin, vecbigDest, FALSE); auto nFwdMove = m_LocalNav->PathTraversable(pev->origin, vecbigDest, FALSE);
if (nFwdMove != PTRAVELS_EMPTY) if (nFwdMove != PTRAVELS_EMPTY)
{ {
float_precision flSpeed = 250; real_t flSpeed = 250;
vecbigDest = pFollowing->pev->origin; vecbigDest = pFollowing->pev->origin;
vecbigDest.z += pFollowing->pev->mins.z; vecbigDest.z += pFollowing->pev->mins.z;
@ -1480,15 +1482,15 @@ bool CHostageManager::IsNearbyHostageTalking(CHostageImprov *improv)
for (int i = 0; i < m_hostageCount; i++) for (int i = 0; i < m_hostageCount; i++)
{ {
const float closeRange = 500.0f; const float closeRange = 500.0f;
const CHostageImprov *other = m_hostage[i]->m_improv; const CHostageImprov *pHostage = m_hostage[i]->m_improv;
if (!other) if (!pHostage)
continue; continue;
if (!other->IsAlive() || other == improv) if (!pHostage->IsAlive() || pHostage == improv)
continue; continue;
if (!(improv->GetCentroid() - other->GetCentroid()).IsLengthGreaterThan(closeRange) && !other->IsTalking()) if (!(improv->GetCentroid() - pHostage->GetCentroid()).IsLengthGreaterThan(closeRange) && !pHostage->IsTalking())
{ {
return true; return true;
} }
@ -1501,16 +1503,16 @@ bool CHostageManager::IsNearbyHostageJumping(CHostageImprov *improv)
{ {
for (int i = 0; i < m_hostageCount; i++) for (int i = 0; i < m_hostageCount; i++)
{ {
const CHostageImprov *other = m_hostage[i]->m_improv; const CHostageImprov *pHostage = m_hostage[i]->m_improv;
if (!other) if (!pHostage)
continue; continue;
if (!other->IsAlive() || other == improv) if (!pHostage->IsAlive() || pHostage == improv)
continue; continue;
const float closeRange = 500.0f; const float closeRange = 500.0f;
if (!(improv->GetCentroid() - other->GetCentroid()).IsLengthGreaterThan(closeRange) && other->IsJumping()) if (!(improv->GetCentroid() - pHostage->GetCentroid()).IsLengthGreaterThan(closeRange) && pHostage->IsJumping())
{ {
return true; return true;
} }
@ -1519,14 +1521,14 @@ bool CHostageManager::IsNearbyHostageJumping(CHostageImprov *improv)
return false; return false;
} }
void CHostageManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CHostageManager::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
for (int i = 0; i < m_hostageCount; i++) for (int i = 0; i < m_hostageCount; i++)
{ {
CHostageImprov *improv = m_hostage[i]->m_improv; CHostageImprov *improv = m_hostage[i]->m_improv;
if (improv) if (improv)
{ {
improv->OnGameEvent(event, entity, other); improv->OnGameEvent(event, pEntity, pOther);
} }
} }
} }
@ -1611,23 +1613,21 @@ char *SimpleChatter::GetSound(HostageChatterType type, float *duration)
return sound; return sound;
} }
float SimpleChatter::PlaySound(CBaseEntity *entity, HostageChatterType type) float SimpleChatter::PlaySound(CBaseEntity *pEntity, HostageChatterType type)
{ {
CHostage *hostage;
float duration; float duration;
char *sound; char *pszSoundName = GetSound(type, &duration);
int pitch; CHostage *pHostage = static_cast<CHostage *>(pEntity);
int attenuation = 1;
sound = GetSound(type, &duration); if (!pszSoundName)
hostage = static_cast<CHostage *>(entity);
if (!sound)
{ {
return 0; return 0;
} }
switch (hostage->m_whichModel) int pitch;
int attenuation = 1;
switch (pHostage->m_whichModel)
{ {
case CHostage::REGULAR_GUY: case CHostage::REGULAR_GUY:
pitch = 92; pitch = 92;
@ -1644,13 +1644,13 @@ float SimpleChatter::PlaySound(CBaseEntity *entity, HostageChatterType type)
break; break;
} }
EMIT_SOUND_DYN(ENT(hostage->pev), CHAN_VOICE, sound, VOL_NORM, attenuation, 0, pitch); EMIT_SOUND_DYN(ENT(pHostage->pev), CHAN_VOICE, pszSoundName, VOL_NORM, attenuation, 0, pitch);
if (type == HOSTAGE_CHATTER_CALL_TO_RESCUER) if (type == HOSTAGE_CHATTER_CALL_TO_RESCUER)
{ {
if (TheBots) if (TheBots)
{ {
TheBots->OnEvent(EVENT_HOSTAGE_CALLED_FOR_HELP, hostage); TheBots->OnEvent(EVENT_HOSTAGE_CALLED_FOR_HELP, pHostage);
} }
} }

View File

@ -134,13 +134,13 @@ public:
return m_hTargetEnt; return m_hTargetEnt;
} }
bool IsFollowing(const CBaseEntity *entity = nullptr) bool IsFollowing(const CBaseEntity *pEntity = nullptr)
{ {
if (m_improv) { if (m_improv) {
return m_improv->IsFollowing(); return m_improv->IsFollowing(pEntity);
} }
if ((!entity && !m_hTargetEnt) || (entity && m_hTargetEnt != entity)) if ((!pEntity && !m_hTargetEnt) || (pEntity && m_hTargetEnt != pEntity))
return false; return false;
if (m_State != FOLLOW) if (m_State != FOLLOW)
@ -211,7 +211,7 @@ public:
}; };
void AddSound(HostageChatterType type, char *filename); void AddSound(HostageChatterType type, char *filename);
float PlaySound(CBaseEntity *entity, HostageChatterType type); float PlaySound(CBaseEntity *pEntity, HostageChatterType type);
char *GetSound(HostageChatterType type, float *duration); char *GetSound(HostageChatterType type, float *duration);
void Shuffle(ChatterSet *chatter); void Shuffle(ChatterSet *chatter);
@ -235,7 +235,7 @@ public:
} }
bool IsNearbyHostageTalking(CHostageImprov *improv); bool IsNearbyHostageTalking(CHostageImprov *improv);
bool IsNearbyHostageJumping(CHostageImprov *improv); bool IsNearbyHostageJumping(CHostageImprov *improv);
void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); void OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
// Iterate over all active hostages in the game, invoking functor on each. // Iterate over all active hostages in the game, invoking functor on each.
// If functor returns false, stop iteration and return false. // If functor returns false, stop iteration and return false.

View File

@ -40,10 +40,10 @@ inline void DrawAxes(const Vector &origin, int red, int green, int blue)
UTIL_DrawBeamPoints(origin + Vector(0, 0, size), origin - Vector(0, 0, size), 2, red, green, blue); UTIL_DrawBeamPoints(origin + Vector(0, 0, size), origin - Vector(0, 0, size), 2, red, green, blue);
} }
CHostageImprov::CHostageImprov(CBaseEntity *entity) CHostageImprov::CHostageImprov(CBaseEntity *pEntity)
{ {
m_animateState.Reset(); m_animateState.Reset();
m_hostage = static_cast<CHostage *>(entity); m_hostage = static_cast<CHostage *>(pEntity);
OnReset(); OnReset();
} }
@ -127,7 +127,7 @@ void CHostageImprov::ClearFaceTo()
void CHostageImprov::MoveTowards(const Vector &pos, float deltaT) void CHostageImprov::MoveTowards(const Vector &pos, float deltaT)
{ {
Vector move; Vector move;
float_precision accelRate; real_t accelRate;
const float crouchWalkRate = 250.0f; const float crouchWalkRate = 250.0f;
// Jump up on ledges // Jump up on ledges
@ -230,9 +230,9 @@ bool CHostageImprov::FaceTowards(const Vector &target, float deltaT)
to.NormalizeInPlace(); to.NormalizeInPlace();
#else #else
// TODO: fix test demo // TODO: fix test demo
float_precision float_x = target.x - GetFeet().x; real_t float_x = target.x - GetFeet().x;
float_precision float_y = target.y - GetFeet().y; real_t float_y = target.y - GetFeet().y;
float_precision flLen = to.Length(); real_t flLen = to.Length();
if (flLen <= 0) if (flLen <= 0)
{ {
@ -251,7 +251,7 @@ bool CHostageImprov::FaceTowards(const Vector &target, float deltaT)
Vector2D lat(BotCOS(moveAngle), BotSIN(moveAngle)); Vector2D lat(BotCOS(moveAngle), BotSIN(moveAngle));
Vector2D dir(-lat.y, lat.x); Vector2D dir(-lat.y, lat.x);
float_precision dot = DotProduct(to, dir); real_t dot = DotProduct(to, dir);
if (DotProduct(to, lat) < 0.0f) if (DotProduct(to, lat) < 0.0f)
{ {
@ -299,13 +299,13 @@ void CHostageImprov::FaceOutwards()
const int cornerCount = ARRAYSIZE(corner); const int cornerCount = ARRAYSIZE(corner);
for (int i = 0; i < cornerCount; ++i) for (int i = 0; i < cornerCount; i++)
{ {
to = GetCentroid() + corner[i]; to = GetCentroid() + corner[i];
UTIL_TraceLine(GetCentroid(), to, ignore_monsters, ignore_glass, m_hostage->edict(), &result); UTIL_TraceLine(GetCentroid(), to, ignore_monsters, ignore_glass, m_hostage->edict(), &result);
float_precision range = (result.vecEndPos - GetCentroid()).LengthSquared(); real_t range = (result.vecEndPos - GetCentroid()).LengthSquared();
if (range > farthestRange) if (range > farthestRange)
{ {
@ -353,20 +353,20 @@ bool CHostageImprov::IsFriendInTheWay(const Vector &goalPos) const
} }
// check if any CT are overlapping this linear path // check if any CT are overlapping this linear path
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (!player->IsAlive() || player->m_iTeam == TERRORIST) if (!pPlayer->IsAlive() || pPlayer->m_iTeam == TERRORIST)
continue; continue;
if (IsFriendInTheWay(player, goalPos)) if (IsFriendInTheWay(pPlayer, goalPos))
{ {
m_isFriendInTheWay = true; m_isFriendInTheWay = true;
break; break;
@ -529,19 +529,19 @@ bool CHostageImprov::IsVisible(const Vector &pos, bool testFOV) const
return result.flFraction == 1.0f; return result.flFraction == 1.0f;
} }
bool CHostageImprov::IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance) const bool CHostageImprov::IsPlayerLookingAtMe(CBasePlayer *pOther, float cosTolerance) const
{ {
Vector2D toOther = (other->pev->origin - GetCentroid()).Make2D(); Vector2D toOther = (pOther->pev->origin - GetCentroid()).Make2D();
toOther.NormalizeInPlace(); toOther.NormalizeInPlace();
UTIL_MakeVectors(other->pev->punchangle + other->pev->v_angle); UTIL_MakeVectors(pOther->pev->punchangle + pOther->pev->v_angle);
Vector2D otherDir = gpGlobals->v_forward.Make2D(); Vector2D otherDir = gpGlobals->v_forward.Make2D();
otherDir.NormalizeInPlace(); otherDir.NormalizeInPlace();
if (-cosTolerance > DotProduct(toOther, otherDir)) if (-cosTolerance > DotProduct(toOther, otherDir))
{ {
if (IsVisible(other->EyePosition())) if (IsVisible(pOther->EyePosition()))
{ {
return true; return true;
} }
@ -552,18 +552,18 @@ bool CHostageImprov::IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance)
CBasePlayer *CHostageImprov::IsAnyPlayerLookingAtMe(int team, float cosTolerance) const CBasePlayer *CHostageImprov::IsAnyPlayerLookingAtMe(int team, float cosTolerance) const
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(pPlayer))
continue; continue;
if (player->IsAlive() && (team == UNASSIGNED || player->m_iTeam == team)) if (pPlayer->IsAlive() && (team == UNASSIGNED || pPlayer->m_iTeam == team))
{ {
if (IsPlayerLookingAtMe(player, cosTolerance)) if (IsPlayerLookingAtMe(pPlayer, cosTolerance))
{ {
return player; return pPlayer;
} }
} }
} }
@ -579,24 +579,24 @@ CBasePlayer *CHostageImprov::GetClosestPlayerByTravelDistance(int team, float *r
if (!GetLastKnownArea()) if (!GetLastKnownArea())
return nullptr; return nullptr;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(pPlayer))
continue; continue;
if (player->IsAlive() && (team == UNASSIGNED || player->m_iTeam == team)) if (pPlayer->IsAlive() && (team == UNASSIGNED || pPlayer->m_iTeam == team))
{ {
ShortestPathCost cost; ShortestPathCost cost;
Vector vecCenter = player->Center(); Vector vecCenter = pPlayer->Center();
float_precision range = NavAreaTravelDistance(GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&vecCenter), cost); real_t range = NavAreaTravelDistance(GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&vecCenter), cost);
if (range > 0 && range < closeRange) if (range > 0 && range < closeRange)
{ {
closeRange = range; closeRange = range;
close = player; close = pPlayer;
} }
} }
} }
@ -670,24 +670,24 @@ void CHostageImprov::UpdateVision()
m_visiblePlayerCount = 0; m_visiblePlayerCount = 0;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
if (player->IsAlive() && IsVisible(player->pev->origin, true)) if (pPlayer->IsAlive() && IsVisible(pPlayer->pev->origin, true))
{ {
m_visiblePlayer[m_visiblePlayerCount] = player; m_visiblePlayer[m_visiblePlayerCount] = pPlayer;
if (player->m_iTeam == TERRORIST) if (pPlayer->m_iTeam == TERRORIST)
m_lastSawT.Start(); m_lastSawT.Start();
else else
m_lastSawCT.Start(); m_lastSawCT.Start();
@ -904,7 +904,7 @@ void CHostageImprov::UpdatePosition(float deltaT)
m_hostage->pev->velocity.x = dir.x * pushSpeed; m_hostage->pev->velocity.x = dir.x * pushSpeed;
m_hostage->pev->velocity.y = dir.y * pushSpeed; m_hostage->pev->velocity.y = dir.y * pushSpeed;
#else #else
Vector vecRet = NormalizeMulScalar<float_precision, float_precision, float_precision, float>(dir, pushSpeed); Vector vecRet = NormalizeMulScalar<real_t, real_t, real_t, float>(dir, pushSpeed);
m_hostage->pev->velocity.x = vecRet.x; m_hostage->pev->velocity.x = vecRet.x;
m_hostage->pev->velocity.y = vecRet.y; m_hostage->pev->velocity.y = vecRet.y;
#endif #endif
@ -919,8 +919,8 @@ void CHostageImprov::UpdatePosition(float deltaT)
if (m_isLookingAt) if (m_isLookingAt)
{ {
Vector angles = UTIL_VecToAngles(m_viewGoal - GetEyes()); Vector angles = UTIL_VecToAngles(m_viewGoal - GetEyes());
float_precision pitch = angles.x - m_hostage->pev->angles.x; real_t pitch = angles.x - m_hostage->pev->angles.x;
float_precision yaw = angles.y - m_hostage->pev->angles.y; real_t yaw = angles.y - m_hostage->pev->angles.y;
while (yaw > 180.0f) while (yaw > 180.0f)
yaw -= 360.0f; yaw -= 360.0f;
@ -987,7 +987,7 @@ void CHostageImprov::UpdatePosition(float deltaT)
m_vel.x += m_vel.x * -friction * deltaT; m_vel.x += m_vel.x * -friction * deltaT;
m_vel.y += m_vel.y * -friction * deltaT; m_vel.y += m_vel.y * -friction * deltaT;
float_precision speed = m_vel.NormalizeInPlace(); real_t speed = m_vel.NormalizeInPlace();
const float maxSpeed = 285.0f; const float maxSpeed = 285.0f;
if (speed > maxSpeed) if (speed > maxSpeed)
@ -1120,7 +1120,7 @@ void CHostageImprov::OnUpdate(float deltaT)
if (m_blinkCounter) if (m_blinkCounter)
{ {
m_hostage->pev->body = 1; m_hostage->pev->body = 1;
--m_blinkCounter; m_blinkCounter--;
} }
else else
{ {
@ -1253,13 +1253,13 @@ void CHostageImprov::OnUpdate(float deltaT)
m_animateState.OnUpdate(this); m_animateState.OnUpdate(this);
} }
void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
switch (event) switch (event)
{ {
case EVENT_BULLET_IMPACT: case EVENT_BULLET_IMPACT:
{ {
Vector *impactPos = (Vector *)other; Vector *impactPos = (Vector *)pOther;
const float nearRange = 100.0f; const float nearRange = 100.0f;
if ((GetCentroid() - *impactPos).IsLengthLessThan(nearRange)) if ((GetCentroid() - *impactPos).IsLengthLessThan(nearRange))
@ -1270,24 +1270,24 @@ void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBase
} }
case EVENT_PLAYER_DIED: case EVENT_PLAYER_DIED:
case EVENT_HOSTAGE_KILLED: case EVENT_HOSTAGE_KILLED:
if (IsVisible(entity->pev->origin, true)) if (IsVisible(pEntity->pev->origin, true))
{ {
Frighten(TERRIFIED); Frighten(TERRIFIED);
if (!entity->IsPlayer() || (entity->IsPlayer() && ((CBasePlayer *)entity)->m_iTeam != TERRORIST)) if (!pEntity->IsPlayer() || (pEntity->IsPlayer() && ((CBasePlayer *)pEntity)->m_iTeam != TERRORIST))
{ {
DelayedChatter(RANDOM_FLOAT(0.5f, 0.7f), HOSTAGE_CHATTER_SCARED_OF_MURDER, true); DelayedChatter(RANDOM_FLOAT(0.5f, 0.7f), HOSTAGE_CHATTER_SCARED_OF_MURDER, true);
} }
if (!entity->IsPlayer()) if (!pEntity->IsPlayer())
{ {
m_idleState.OnInjury(); m_idleState.OnInjury();
} }
} }
break; break;
case EVENT_HOSTAGE_RESCUED: case EVENT_HOSTAGE_RESCUED:
if (m_hostage == other) if (m_hostage == pOther)
{ {
if (!entity) if (!pEntity)
return; return;
Chatter(HOSTAGE_CHATTER_RESCUED, false); Chatter(HOSTAGE_CHATTER_RESCUED, false);
@ -1309,11 +1309,11 @@ void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBase
PriorityType priority; PriorityType priority;
bool isHostile; bool isHostile;
if (entity && IsGameEventAudible(event, entity, other, &range, &priority, &isHostile)) if (pEntity && IsGameEventAudible(event, pEntity, pOther, &range, &priority, &isHostile))
{ {
const float fudge = 0.4f; const float fudge = 0.4f;
if ((m_hostage->pev->origin - entity->pev->origin).IsLengthLessThan(range * fudge)) if ((m_hostage->pev->origin - pEntity->pev->origin).IsLengthLessThan(range * fudge))
{ {
m_lastNoiseTimer.Start(); m_lastNoiseTimer.Start();
@ -1347,7 +1347,7 @@ void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBase
if (event == EVENT_FLASHBANG_GRENADE_EXPLODED) if (event == EVENT_FLASHBANG_GRENADE_EXPLODED)
{ {
Vector *impactPos = (Vector *)other; Vector *impactPos = (Vector *)pOther;
const float flashRange = 1000.0f; const float flashRange = 1000.0f;
if ((GetEyes() - *impactPos).IsLengthLessThan(flashRange) && IsVisible(*impactPos)) if ((GetEyes() - *impactPos).IsLengthLessThan(flashRange) && IsVisible(*impactPos))
@ -1358,22 +1358,19 @@ void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBase
} }
} }
void CHostageImprov::OnTouch(CBaseEntity *other) void CHostageImprov::OnTouch(CBaseEntity *pOther)
{ {
const char *classname;
Vector2D to; Vector2D to;
const float pushForce = 20.0f; const float pushForce = 20.0f;
classname = STRING(other->pev->classname);
if (cv_hostage_debug.value != 0.0) if (cv_hostage_debug.value != 0.0)
{ {
CONSOLE_ECHO("%5.1f: Hostage hit '%s'\n", gpGlobals->time, classname); CONSOLE_ECHO("%5.1f: Hostage hit '%s'\n", gpGlobals->time, pOther->GetClassname());
} }
m_collisionTimer.Start(); m_collisionTimer.Start();
if (FStrEq(classname, "worldspawn")) if (FStrEq(pOther->pev->classname, "worldspawn"))
{ {
const float lookAheadRange = 30.0f; const float lookAheadRange = 30.0f;
float ground; float ground;
@ -1396,7 +1393,7 @@ void CHostageImprov::OnTouch(CBaseEntity *other)
Vector pos = alongFloor * lookAheadRange; Vector pos = alongFloor * lookAheadRange;
for (float_precision offset = 1.0f; offset <= 18.0f; offset += 3.0f) for (real_t offset = 1.0f; offset <= 18.0f; offset += 3.0f)
{ {
Vector vecStart = GetFeet(); Vector vecStart = GetFeet();
vecStart.z += offset; vecStart.z += offset;
@ -1468,13 +1465,13 @@ void CHostageImprov::OnTouch(CBaseEntity *other)
} }
} }
} }
else if (FStrEq(classname, "func_breakable")) else if (FStrEq(pOther->pev->classname, "func_breakable"))
{ {
other->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET); pOther->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET);
} }
else if (other->IsPlayer() || FClassnameIs(other->pev, "hostage_entity")) else if (pOther->IsPlayer() || FClassnameIs(pOther->pev, "hostage_entity"))
{ {
to = (m_hostage->pev->origin - other->pev->origin).Make2D(); to = (m_hostage->pev->origin - pOther->pev->origin).Make2D();
to.NormalizeInPlace(); to.NormalizeInPlace();
m_vel.x += to.x * pushForce; m_vel.x += to.x * pushForce;
@ -1511,14 +1508,14 @@ CBasePlayer *CHostageImprov::GetClosestVisiblePlayer(int team)
CBasePlayer *close = nullptr; CBasePlayer *close = nullptr;
float closeRangeSq = 1e8f; float closeRangeSq = 1e8f;
for (int i = 0; i < m_visiblePlayerCount; ++i) for (int i = 0; i < m_visiblePlayerCount; i++)
{ {
CBasePlayer *pPlayer = m_visiblePlayer[i]; CBasePlayer *pPlayer = m_visiblePlayer[i];
if (!pPlayer || (team > 0 && pPlayer->m_iTeam != team)) if (!pPlayer || (team > 0 && pPlayer->m_iTeam != team))
continue; continue;
float_precision rangeSq = (GetCentroid() - pPlayer->pev->origin).LengthSquared(); real_t rangeSq = (GetCentroid() - pPlayer->pev->origin).LengthSquared();
if (rangeSq < closeRangeSq) if (rangeSq < closeRangeSq)
{ {
@ -1822,18 +1819,18 @@ void CHostageImprov::ClearPath()
if (result.pHit) if (result.pHit)
{ {
entvars_t *entity = VARS(result.pHit); edict_t *pEntity = result.pHit;
if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) if (FClassnameIs(pEntity, "func_door") || FClassnameIs(pEntity, "func_door_rotating"))
{ {
CBaseEntity *pObject = CBaseEntity::Instance(entity); CBaseEntity *pObject = CBaseEntity::Instance(pEntity);
if (pObject) if (pObject)
{ {
pObject->Touch(m_hostage); pObject->Touch(m_hostage);
} }
} }
else if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) else if (FClassnameIs(pEntity, "func_breakable") && pEntity->v.takedamage == DAMAGE_YES)
{ {
CBaseEntity *pObject = CBaseEntity::Instance(entity); CBaseEntity *pObject = CBaseEntity::Instance(pEntity);
if (pObject) if (pObject)
{ {
pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET); pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET);

View File

@ -38,7 +38,7 @@ enum HostageChatterType;
class CHostageImprov: public CImprov class CHostageImprov: public CImprov
{ {
public: public:
CHostageImprov(CBaseEntity *entity = nullptr); CHostageImprov(CBaseEntity *pEntity = nullptr);
~CHostageImprov() {}; ~CHostageImprov() {};
// invoked when an improv reaches its MoveTo goal // invoked when an improv reaches its MoveTo goal
@ -98,18 +98,18 @@ public:
virtual bool CanCrouch() const { return true; } virtual bool CanCrouch() const { return true; }
virtual bool CanJump() const { return true; } virtual bool CanJump() const { return true; }
virtual bool IsVisible(const Vector &pos, bool testFOV = false) const; // return true if hostage can see position virtual bool IsVisible(const Vector &pos, bool testFOV = false) const; // return true if hostage can see position
virtual bool IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance = 0.95f) const; virtual bool IsPlayerLookingAtMe(CBasePlayer *pOther, float cosTolerance = 0.95f) const;
virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const; virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const;
virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = nullptr) const; virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = nullptr) const;
virtual CNavArea *GetLastKnownArea() const { return m_lastKnownArea; } virtual CNavArea *GetLastKnownArea() const { return m_lastKnownArea; }
virtual void OnUpdate(float deltaT); virtual void OnUpdate(float deltaT);
virtual void OnUpkeep(float deltaT); virtual void OnUpkeep(float deltaT);
virtual void OnReset(); virtual void OnReset();
virtual void OnGameEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); virtual void OnGameEvent(GameEventType event, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr);
virtual void OnTouch(CBaseEntity *other); // in contact with "other" virtual void OnTouch(CBaseEntity *pOther); // in contact with "other"
#ifdef PLAY_GAMEDLL #ifdef PLAY_GAMEDLL
void ApplyForce2(float_precision x, float_precision y); void ApplyForce2(real_t x, real_t y);
#endif #endif
public: public:
@ -353,19 +353,19 @@ public:
m_velDir = improv->GetActualVelocity(); m_velDir = improv->GetActualVelocity();
m_speed = m_velDir.NormalizeInPlace(); m_speed = m_velDir.NormalizeInPlace();
} }
bool operator()(CBaseEntity *entity) bool operator()(CBaseEntity *pEntity)
{ {
const float space = 1.0f; const float space = 1.0f;
Vector to; Vector to;
float range; float range;
if (entity == reinterpret_cast<CBaseEntity *>(m_improv->GetEntity())) if (pEntity == reinterpret_cast<CBaseEntity *>(m_improv->GetEntity()))
return true; return true;
if (entity->IsPlayer() && !entity->IsAlive()) if (pEntity->IsPlayer() && !pEntity->IsAlive())
return true; return true;
to = entity->pev->origin - m_improv->GetCentroid(); to = pEntity->pev->origin - m_improv->GetCentroid();
#ifdef PLAY_GAMEDLL #ifdef PLAY_GAMEDLL
// TODO: fix test demo // TODO: fix test demo
@ -374,7 +374,7 @@ public:
range = to.NormalizeInPlace(); range = to.NormalizeInPlace();
#endif #endif
CBasePlayer *player = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
const float spring = 50.0f; const float spring = 50.0f;
const float damper = 1.0f; const float damper = 1.0f;
@ -383,11 +383,11 @@ public:
return true; return true;
const float cosTolerance = 0.8f; const float cosTolerance = 0.8f;
if (entity->IsPlayer() && player->m_iTeam == CT && !m_improv->IsFollowing() && m_improv->IsPlayerLookingAtMe(player, cosTolerance)) if (pEntity->IsPlayer() && pPlayer->m_iTeam == CT && !m_improv->IsFollowing() && m_improv->IsPlayerLookingAtMe(pPlayer, cosTolerance))
return true; return true;
const float minSpace = (spring - range); const float minSpace = (spring - range);
float_precision ds = -minSpace; real_t ds = -minSpace;
#ifndef PLAY_GAMEDLL #ifndef PLAY_GAMEDLL
m_improv->ApplyForce(to * ds); m_improv->ApplyForce(to * ds);
@ -417,16 +417,16 @@ public:
m_dir = Vector(BotCOS(me->GetMoveAngle()), BotSIN(me->GetMoveAngle()), 0.0f); m_dir = Vector(BotCOS(me->GetMoveAngle()), BotSIN(me->GetMoveAngle()), 0.0f);
m_isBlocked = false; m_isBlocked = false;
} }
bool operator()(CBaseEntity *entity) bool operator()(CBaseEntity *pEntity)
{ {
Vector to; Vector to;
float_precision range; real_t range;
const float closeRange = 60.0f; const float closeRange = 60.0f;
const float aheadTolerance = 0.95f; const float aheadTolerance = 0.95f;
if (entity != reinterpret_cast<CBaseEntity *>(m_me->GetEntity())) if (pEntity != reinterpret_cast<CBaseEntity *>(m_me->GetEntity()))
{ {
to = (entity->Center() - m_me->GetCentroid()); to = (pEntity->Center() - m_me->GetCentroid());
range = to.NormalizeInPlace(); range = to.NormalizeInPlace();
if (range <= closeRange && DotProduct(to, m_dir) >= aheadTolerance) if (range <= closeRange && DotProduct(to, m_dir) >= aheadTolerance)
@ -444,7 +444,7 @@ private:
}; };
#ifdef PLAY_GAMEDLL #ifdef PLAY_GAMEDLL
inline void CHostageImprov::ApplyForce2(float_precision x, float_precision y) inline void CHostageImprov::ApplyForce2(real_t x, real_t y)
{ {
m_vel.x += x; m_vel.x += x;
m_vel.y += y; m_vel.y += y;

View File

@ -129,7 +129,7 @@ void CLocalNav::AddPathNode(node_index_t nindexSource, int offsetX, int offsetY,
offsetYAbs = offsetY; offsetYAbs = offsetY;
vecSource = m_vecStartingLoc; vecSource = m_vecStartingLoc;
vecDest = vecSource + Vector(float_precision(offsetX) * HOSTAGE_STEPSIZE, float_precision(offsetY) * HOSTAGE_STEPSIZE, 0); vecDest = vecSource + Vector(real_t(offsetX) * HOSTAGE_STEPSIZE, real_t(offsetY) * HOSTAGE_STEPSIZE, 0);
} }
else else
{ {
@ -149,7 +149,7 @@ void CLocalNav::AddPathNode(node_index_t nindexSource, int offsetX, int offsetY,
} }
vecSource = nodeCurrent->vecLoc; vecSource = nodeCurrent->vecLoc;
vecDest = vecSource + Vector((float_precision(offsetX) * HOSTAGE_STEPSIZE), (float_precision(offsetY) * HOSTAGE_STEPSIZE), 0); vecDest = vecSource + Vector((real_t(offsetX) * HOSTAGE_STEPSIZE), (real_t(offsetY) * HOSTAGE_STEPSIZE), 0);
if (m_nindexAvailableNode) if (m_nindexAvailableNode)
{ {
@ -230,15 +230,13 @@ node_index_t CLocalNav::GetBestNode(Vector &vecOrigin, Vector &vecDest)
if (!nodeCurrent->fSearched) if (!nodeCurrent->fSearched)
{ {
float_precision flCurrentVal; real_t flCurrentVal;
float_precision flDistFromStart; real_t flDistFromStart;
float flDistToDest; float flDistToDest;
float_precision flZDiff = -1.0; real_t flZDiff = -1.0;
flDistFromStart = LengthSubtract flDistFromStart = LengthSubtract<real_t, real_t, real_t, real_t>(vecDest, nodeCurrent->vecLoc);
<float_precision, float_precision,
float_precision, float_precision>(vecDest, nodeCurrent->vecLoc);
flDistToDest = nodeCurrent->vecLoc.z - vecDest.z; flDistToDest = nodeCurrent->vecLoc.z - vecDest.z;
if (flDistToDest >= 0.0) if (flDistToDest >= 0.0)
@ -251,7 +249,7 @@ node_index_t CLocalNav::GetBestNode(Vector &vecOrigin, Vector &vecDest)
else else
flZDiff = 1.25; flZDiff = 1.25;
flCurrentVal = flZDiff * (float_precision(nodeCurrent->bDepth) * HOSTAGE_STEPSIZE + flDistFromStart); flCurrentVal = flZDiff * (real_t(nodeCurrent->bDepth) * HOSTAGE_STEPSIZE + flDistFromStart);
if (flCurrentVal < flBestVal) if (flCurrentVal < flBestVal)
{ {
flBestVal = flCurrentVal; flBestVal = flCurrentVal;
@ -307,7 +305,7 @@ node_index_t CLocalNav::FindPath(Vector &vecStart, Vector &vecDest, float flTarg
localnode_t *node; localnode_t *node;
Vector vecNodeLoc; Vector vecNodeLoc;
float_precision flDistToDest; real_t flDistToDest;
m_vecStartingLoc = vecStart; m_vecStartingLoc = vecStart;
m_nindexAvailableNode = 0; m_nindexAvailableNode = 0;
@ -400,7 +398,7 @@ node_index_t CLocalNav::FindDirectPath(Vector &vecStart, Vector &vecDest, float
Vector vecNodeLoc; Vector vecNodeLoc;
node_index_t nIndexLast; node_index_t nIndexLast;
vecPathDir = NormalizeSubtract<float_precision, float, float, float_precision>(vecStart, vecDest); vecPathDir = NormalizeSubtract<real_t, float, float, real_t>(vecStart, vecDest);
vecActualDest = vecDest - (vecPathDir * flTargetRadius); vecActualDest = vecDest - (vecPathDir * flTargetRadius);
if (PathTraversable(vecStart, vecActualDest, fNoMonsters) == PTRAVELS_EMPTY) if (PathTraversable(vecStart, vecActualDest, fNoMonsters) == PTRAVELS_EMPTY)
@ -457,7 +455,7 @@ PathTraversAble CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, B
Vector vecSrcTmp; Vector vecSrcTmp;
Vector vecDestTmp; Vector vecDestTmp;
Vector vecDir; Vector vecDir;
float_precision flTotal; real_t flTotal;
auto retval = PTRAVELS_EMPTY; auto retval = PTRAVELS_EMPTY;
vecSrcTmp = vecSource; vecSrcTmp = vecSource;
@ -585,7 +583,7 @@ BOOL CLocalNav::SlopeTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMon
vecDown = vecDest - vecSource; vecDown = vecDest - vecSource;
vecAngles = UTIL_VecToAngles(tr.vecPlaneNormal); vecAngles = UTIL_VecToAngles(tr.vecPlaneNormal);
vecSlopeEnd.z = vecDown.Length2D() * Q_tan(float_precision((90.0 - vecAngles.x) * (M_PI / 180))) + vecSource.z; vecSlopeEnd.z = vecDown.Length2D() * Q_tan(real_t((90.0 - vecAngles.x) * (M_PI / 180))) + vecSource.z;
if (!PathClear(vecSource, vecSlopeEnd, fNoMonsters, tr)) if (!PathClear(vecSource, vecSlopeEnd, fNoMonsters, tr))
{ {
@ -773,15 +771,11 @@ BOOL CLocalNav::LadderHit(Vector &vecSource, Vector &vecDest, TraceResult &tr)
void CLocalNav::Think() void CLocalNav::Think()
{ {
static cvar_t *sv_stepsize = NULL;
if (gpGlobals->time >= m_flNextCvarCheck) if (gpGlobals->time >= m_flNextCvarCheck)
{ {
if (sv_stepsize != NULL) if (g_psv_stepsize)
m_flStepSize = sv_stepsize->value;
else
{ {
sv_stepsize = CVAR_GET_POINTER("sv_stepsize"); m_flStepSize = g_psv_stepsize->value;
m_flStepSize = sv_stepsize ? sv_stepsize->value : 18;
} }
m_flNextCvarCheck = gpGlobals->time + 1.0f; m_flNextCvarCheck = gpGlobals->time + 1.0f;

View File

@ -181,7 +181,7 @@ public:
virtual void UpdateStationaryAnimation(CHostageImprov *improv); virtual void UpdateStationaryAnimation(CHostageImprov *improv);
public: public:
void SetLeader(CBasePlayer *leader) { m_leader = leader; } void SetLeader(CBasePlayer *pLeader) { m_leader = pLeader; }
CBasePlayer *GetLeader() const { return m_leader; } CBasePlayer *GetLeader() const { return m_leader; }
private: private:

View File

@ -159,10 +159,10 @@ void HostageEscapeState::OnUpdate(CHostageImprov *improv)
else else
improv->Run(); improv->Run();
CBasePlayer *player = improv->GetClosestVisiblePlayer(UNASSIGNED); CBasePlayer *pPlayer = improv->GetClosestVisiblePlayer(UNASSIGNED);
if (player) if (pPlayer)
{ {
if (player->m_iTeam != TERRORIST) if (pPlayer->m_iTeam != TERRORIST)
{ {
improv->Stop(); improv->Stop();
improv->Idle(); improv->Idle();
@ -170,7 +170,7 @@ void HostageEscapeState::OnUpdate(CHostageImprov *improv)
} }
const float farRange = 750.0f; const float farRange = 750.0f;
if ((player->pev->origin - improv->GetCentroid()).IsLengthGreaterThan(farRange)) if ((pPlayer->pev->origin - improv->GetCentroid()).IsLengthGreaterThan(farRange))
{ {
improv->Frighten(CHostageImprov::NERVOUS); improv->Frighten(CHostageImprov::NERVOUS);

View File

@ -65,7 +65,7 @@ void HostageFollowState::OnUpdate(CHostageImprov *improv)
return; return;
} }
float_precision range = (m_leader->pev->origin - improv->GetCentroid()).Length(); real_t range = (m_leader->pev->origin - improv->GetCentroid()).Length();
const float maxPathLength = 3000.0f; const float maxPathLength = 3000.0f;
const float giveUpRange = 1000.0f; const float giveUpRange = 1000.0f;

View File

@ -122,7 +122,7 @@ void CItem::ItemTouch(CBaseEntity *pOther)
if (MyTouch(pPlayer)) if (MyTouch(pPlayer))
{ {
SUB_UseTargets(pOther, USE_TOGGLE, 0); SUB_UseTargets(pOther, USE_TOGGLE, 0);
SetTouch(NULL); SetTouch(nullptr);
g_pGameRules->PlayerGotItem(pPlayer, this); g_pGameRules->PlayerGotItem(pPlayer, this);
if (g_pGameRules->ItemShouldRespawn(this) == GR_ITEM_RESPAWN_YES) if (g_pGameRules->ItemShouldRespawn(this) == GR_ITEM_RESPAWN_YES)
@ -138,7 +138,7 @@ void CItem::ItemTouch(CBaseEntity *pOther)
CBaseEntity *CItem::Respawn() CBaseEntity *CItem::Respawn()
{ {
SetTouch(NULL); SetTouch(nullptr);
pev->effects |= EF_NODRAW; pev->effects |= EF_NODRAW;

View File

@ -144,26 +144,16 @@ void CEnvLight::KeyValue(KeyValueData *pkvd)
void CEnvLight::Spawn() void CEnvLight::Spawn()
{ {
#ifdef HOOK_GAMEDLL
// NOTE: fix negative the values for function sprintf from STD C++:
// expected - sv_skyvec_y "0.000000"
// with using sprintf from STD C++, got - sv_skyvec_y "-0.000000"
// If we not doing it then the test will be failed!
#define SPRINTF_OLD_STD_FIX + 0
#else
#define SPRINTF_OLD_STD_FIX
#endif
char szVector[64]; char szVector[64];
UTIL_MakeAimVectors(pev->angles); UTIL_MakeAimVectors(pev->angles);
Q_sprintf(szVector, "%f", gpGlobals->v_forward.x SPRINTF_OLD_STD_FIX); Q_sprintf(szVector, "%f", gpGlobals->v_forward.x);
CVAR_SET_STRING("sv_skyvec_x", szVector); CVAR_SET_STRING("sv_skyvec_x", szVector);
Q_sprintf(szVector, "%f", gpGlobals->v_forward.y SPRINTF_OLD_STD_FIX); Q_sprintf(szVector, "%f", gpGlobals->v_forward.y);
CVAR_SET_STRING("sv_skyvec_y", szVector); CVAR_SET_STRING("sv_skyvec_y", szVector);
Q_sprintf(szVector, "%f", gpGlobals->v_forward.z SPRINTF_OLD_STD_FIX); Q_sprintf(szVector, "%f", gpGlobals->v_forward.z);
CVAR_SET_STRING("sv_skyvec_z", szVector); CVAR_SET_STRING("sv_skyvec_z", szVector);
CLight::Spawn(); CLight::Spawn();

View File

@ -470,7 +470,11 @@ CHalfLifeMultiplay::CHalfLifeMultiplay()
m_iCareerMatchWins = 0; m_iCareerMatchWins = 0;
m_iRoundWinDifference = int(CVAR_GET_FLOAT("mp_windifference")); m_iRoundWinDifference = int(CVAR_GET_FLOAT("mp_windifference"));
if (IsCareer())
{
CCareerTaskManager::Create(); CCareerTaskManager::Create();
}
if (m_iRoundWinDifference < 1) if (m_iRoundWinDifference < 1)
{ {
@ -620,15 +624,15 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)()
{ {
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->edict())) if (!pPlayer || FNullEnt(pPlayer->edict()))
continue; continue;
if (player->pev->deadflag != DEAD_NO || player->m_iTeam != TERRORIST) if (pPlayer->pev->deadflag != DEAD_NO || pPlayer->m_iTeam != TERRORIST)
continue; continue;
if (!player->IsBot()) if (!pPlayer->IsBot())
humansPresent++; humansPresent++;
} }
@ -645,25 +649,25 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)()
} }
// Give the C4 to the specified T player.. // Give the C4 to the specified T player..
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (!pPlayer->IsPlayer()) if (!pEntity->IsPlayer())
continue; continue;
if (pPlayer->pev->flags == FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (player->pev->deadflag != DEAD_NO || player->m_iTeam != TERRORIST || (giveToHumans && player->IsBot())) if (pPlayer->pev->deadflag != DEAD_NO || pPlayer->m_iTeam != TERRORIST || (giveToHumans && pPlayer->IsBot()))
continue; continue;
if (++iTemp == m_iC4Guy) if (++iTemp == m_iC4Guy)
{ {
if (player->MakeBomber()) if (pPlayer->MakeBomber())
{ {
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
// we already have bomber // we already have bomber
@ -677,25 +681,25 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)()
if (!IsThereABomber()) if (!IsThereABomber())
{ {
m_iC4Guy = 0; m_iC4Guy = 0;
pPlayer = nullptr; pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (!pPlayer->IsPlayer()) if (!pEntity->IsPlayer())
continue; continue;
if (pPlayer->pev->flags == FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (player->pev->deadflag != DEAD_NO || player->m_iTeam != TERRORIST) if (pPlayer->pev->deadflag != DEAD_NO || pPlayer->m_iTeam != TERRORIST)
continue; continue;
player->MakeBomber(); pPlayer->MakeBomber();
return; return;
} }
} }
@ -862,44 +866,28 @@ void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &Num
// initialize count dead/alive players // initialize count dead/alive players
// Count how many dead players there are on each team. // Count how many dead players there are on each team.
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{
if (FNullEnt(pPlayer->edict()))
{ {
if (FNullEnt(pEntity->edict()))
break; break;
}
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); if (pEntity->IsDormant())
if (pPlayer->pev->flags == FL_DORMANT)
{
continue; continue;
}
// TODO: check it out, for what here used player->IsBot() ? CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
// maybe body this conditions is located under the wrapper #ifdef 0 switch (pPlayer->m_iTeam)
// if (player->IsBot())
// {
// #ifdef 0
// ....
// #endif
// }
switch (player->m_iTeam)
{ {
case CT: case CT:
{ {
m_iNumCT++; m_iNumCT++;
if (player->m_iMenu != Menu_ChooseAppearance) if (pPlayer->m_iMenu != Menu_ChooseAppearance)
{ {
m_iNumSpawnableCT++; m_iNumSpawnableCT++;
//player->IsBot();
} }
//player->IsBot(); if (pPlayer->pev->deadflag != DEAD_NO)
if (player->pev->deadflag != DEAD_NO)
NumDeadCT++; NumDeadCT++;
else else
NumAliveCT++; NumAliveCT++;
@ -910,20 +898,18 @@ void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &Num
{ {
m_iNumTerrorist++; m_iNumTerrorist++;
if (player->m_iMenu != Menu_ChooseAppearance) if (pPlayer->m_iMenu != Menu_ChooseAppearance)
{ {
m_iNumSpawnableTerrorist++; m_iNumSpawnableTerrorist++;
//player->IsBot();
} }
//player->IsBot();
if (player->pev->deadflag != DEAD_NO) if (pPlayer->pev->deadflag != DEAD_NO)
NumDeadTerrorist++; NumDeadTerrorist++;
else else
NumAliveTerrorist++; NumAliveTerrorist++;
// Check to see if this guy escaped. // Check to see if this guy escaped.
if (player->m_bEscaped) if (pPlayer->m_bEscaped)
m_iHaveEscaped++; m_iHaveEscaped++;
break; break;
@ -1006,8 +992,8 @@ bool EXT_FUNC CHalfLifeMultiplay::NeededPlayersCheck()
{ {
if (IsCareer()) if (IsCareer())
{ {
CBasePlayer *player = UTIL_PlayerByIndex(gpGlobals->maxClients); CBasePlayer *pPlayer = UTIL_PlayerByIndex(gpGlobals->maxClients);
if (!player || !player->IsBot()) if (!pPlayer || !pPlayer->IsBot())
{ {
return true; return true;
} }
@ -1180,7 +1166,7 @@ bool EXT_FUNC CHalfLifeMultiplay::PrisonRoundEndCheck(int NumAliveTerrorist, int
// checks to scenario Escaped Terrorist's // checks to scenario Escaped Terrorist's
if (m_bMapHasEscapeZone) if (m_bMapHasEscapeZone)
{ {
m_flEscapeRatio = float_precision(m_iHaveEscaped) / float_precision(m_iNumEscapers); m_flEscapeRatio = real_t(m_iHaveEscaped) / real_t(m_iNumEscapers);
if (m_flEscapeRatio >= m_flRequiredEscapeRatio) if (m_flEscapeRatio >= m_flRequiredEscapeRatio)
{ {
@ -1330,7 +1316,7 @@ bool CHalfLifeMultiplay::TeamExterminationCheck(int NumAliveTerrorist, int NumAl
CGrenade *pBomb = nullptr; CGrenade *pBomb = nullptr;
bool nowin = false; bool nowin = false;
while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{ {
if (pBomb->m_bIsC4 && !pBomb->m_bJustBlew) if (pBomb->m_bIsC4 && !pBomb->m_bJustBlew)
{ {
@ -1368,7 +1354,7 @@ bool CHalfLifeMultiplay::Hostage_Rescue(float tmDelay)
if (!m_bNeededPlayers) if (!m_bNeededPlayers)
{ {
++m_iNumCTWins; m_iNumCTWins++;
// Update the clients team score // Update the clients team score
UpdateTeamScores(); UpdateTeamScores();
} }
@ -1401,27 +1387,27 @@ bool CHalfLifeMultiplay::Hostage_Rescue(float tmDelay)
bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() bool CHalfLifeMultiplay::HostageRescueRoundEndCheck()
{ {
// Check to see if 50% of the hostages have been rescued. // Check to see if 50% of the hostages have been rescued.
CBaseEntity *hostage = nullptr; CBaseEntity *pHostage = nullptr;
int iHostages = 0; int hostagesCount = 0;
// Assume that all hostages are either rescued or dead.. // Assume that all hostages are either rescued or dead..
bool bHostageAlive = false; bool bHostageAlive = false;
while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
iHostages++; hostagesCount++;
// We've found a live hostage. don't end the round // We've found a live hostage. don't end the round
if (hostage->IsAlive()) if (pHostage->IsAlive())
{ {
bHostageAlive = true; bHostageAlive = true;
} }
} }
// There are no hostages alive.. check to see if the CTs have rescued atleast 50% of them. // There are no hostages alive.. check to see if the CTs have rescued atleast 50% of them.
if (!bHostageAlive && iHostages > 0) if (!bHostageAlive && hostagesCount > 0)
{ {
if (m_iHostagesRescued >= (iHostages * 0.5f)) if (m_iHostagesRescued >= (hostagesCount * 0.5f))
{ {
return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_ALL_HOSTAGES_RESCUED, GetRoundRestartDelay()); return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_ALL_HOSTAGES_RESCUED, GetRoundRestartDelay());
} }
@ -1432,18 +1418,18 @@ bool CHalfLifeMultiplay::HostageRescueRoundEndCheck()
void CHalfLifeMultiplay::SwapAllPlayers() void CHalfLifeMultiplay::SwapAllPlayers()
{ {
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (pPlayer->pev->flags == FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
player->SwitchTeam(); pPlayer->SwitchTeam();
} }
// Swap Team victories // Swap Team victories
@ -1520,23 +1506,23 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(BalanceTeams)()
iHighestUserID = 0; iHighestUserID = 0;
toSwap = nullptr; toSwap = nullptr;
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
// search for player with highest UserID = most recently joined to switch over // search for player with highest UserID = most recently joined to switch over
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (pPlayer->pev->flags == FL_DORMANT) if (pEntity->IsDormant())
continue; continue;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (player->m_iTeam == iTeamToSwap && GETPLAYERUSERID(player->edict()) > iHighestUserID && m_pVIP != player) if (pPlayer->m_iTeam == iTeamToSwap && GETPLAYERUSERID(pPlayer->edict()) > iHighestUserID && m_pVIP != pPlayer)
{ {
iHighestUserID = GETPLAYERUSERID(player->edict()); iHighestUserID = GETPLAYERUSERID(pPlayer->edict());
toSwap = player; toSwap = pPlayer;
} }
} }
@ -1600,7 +1586,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
if (!m_bCompleteReset) if (!m_bCompleteReset)
#endif #endif
{ {
++m_iTotalRoundsPlayed; m_iTotalRoundsPlayed++;
} }
ClearBodyQue(); ClearBodyQue();
@ -1659,10 +1645,12 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
if ((m_iNumCT - m_iNumTerrorist) >= 2 || (m_iNumTerrorist - m_iNumCT) >= 2) if ((m_iNumCT - m_iNumTerrorist) >= 2 || (m_iNumTerrorist - m_iNumCT) >= 2)
{ {
++m_iUnBalancedRounds; m_iUnBalancedRounds++;
} }
else else
{
m_iUnBalancedRounds = 0; m_iUnBalancedRounds = 0;
}
// Warn the players of an impending auto-balance next round... // Warn the players of an impending auto-balance next round...
if (shouldBalancedOnNextRound() && m_iUnBalancedRounds == 1) if (shouldBalancedOnNextRound() && m_iUnBalancedRounds == 1)
@ -1720,10 +1708,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
// Reset the player stats // Reset the player stats
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *plr = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer && !FNullEnt(pPlayer->pev))
if (plr && !FNullEnt(plr->pev)) {
plr->Reset(); pPlayer->Reset();
}
} }
if (TheBots) if (TheBots)
@ -1885,68 +1874,68 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
#endif #endif
// tell bots that the round is restarting // tell bots that the round is restarting
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
if (pPlayer->pev->flags == FL_DORMANT) if (pEntity->pev->flags == FL_DORMANT)
continue; continue;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
player->m_iNumSpawns = 0; pPlayer->m_iNumSpawns = 0;
player->m_bTeamChanged = false; pPlayer->m_bTeamChanged = false;
#ifndef REGAMEDLL_FIXES #ifndef REGAMEDLL_FIXES
// NOTE: unreachable code // NOTE: unreachable code
if (!player->IsPlayer()) if (!pPlayer->IsPlayer())
{ {
player->SyncRoundTimer(); pPlayer->SyncRoundTimer();
} }
#endif #endif
if (player->m_iTeam == CT) if (pPlayer->m_iTeam == CT)
{ {
if (!player->m_bReceivesNoMoneyNextRound) if (!pPlayer->m_bReceivesNoMoneyNextRound)
{ {
player->AddAccount(m_iAccountCT, RT_ROUND_BONUS); pPlayer->AddAccount(m_iAccountCT, RT_ROUND_BONUS);
} }
} }
else if (player->m_iTeam == TERRORIST) else if (pPlayer->m_iTeam == TERRORIST)
{ {
// Add another potential escaper to the mix! // Add another potential escaper to the mix!
m_iNumEscapers++; m_iNumEscapers++;
if (!player->m_bReceivesNoMoneyNextRound) if (!pPlayer->m_bReceivesNoMoneyNextRound)
{ {
player->AddAccount(m_iAccountTerrorist, RT_ROUND_BONUS); pPlayer->AddAccount(m_iAccountTerrorist, RT_ROUND_BONUS);
} }
// If it's a prison scenario then remove the Ts guns // If it's a prison scenario then remove the Ts guns
if (m_bMapHasEscapeZone) if (m_bMapHasEscapeZone)
{ {
// this will cause them to be reset with default weapons, armor, and items // this will cause them to be reset with default weapons, armor, and items
player->m_bNotKilled = false; pPlayer->m_bNotKilled = false;
} }
} }
if (player->m_iTeam != UNASSIGNED && player->m_iTeam != SPECTATOR) if (pPlayer->m_iTeam != UNASSIGNED && pPlayer->m_iTeam != SPECTATOR)
{ {
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
// remove the c4 if the player is carrying it // remove the c4 if the player is carrying it
if (player->m_bHasC4) { if (pPlayer->m_bHasC4) {
player->RemoveBomb(); pPlayer->RemoveBomb();
} }
#else #else
// drop the c4 if the player is carrying it // drop the c4 if the player is carrying it
if (player->m_bHasC4) { if (pPlayer->m_bHasC4) {
player->DropPlayerItem("weapon_c4"); pPlayer->DropPlayerItem("weapon_c4");
} }
#endif #endif
player->RoundRespawn(); pPlayer->RoundRespawn();
} }
// Gooseman : The following code fixes the HUD icon bug // Gooseman : The following code fixes the HUD icon bug
@ -1986,8 +1975,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)()
BOOL CHalfLifeMultiplay::IsThereABomber() BOOL CHalfLifeMultiplay::IsThereABomber()
{ {
CBasePlayer *pPlayer = nullptr; CBasePlayer *pPlayer = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")))
while ((pPlayer = (CBasePlayer *)UTIL_FindEntityByClassname(pPlayer, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pPlayer->edict()))
break; break;
@ -2066,7 +2054,7 @@ BOOL CHalfLifeMultiplay::TeamStacked(int newTeam_id, int curTeam_id)
void CHalfLifeMultiplay::StackVIPQueue() void CHalfLifeMultiplay::StackVIPQueue()
{ {
for (int i = MAX_VIP_QUEUES - 2; i > 0; --i) for (int i = MAX_VIP_QUEUES - 2; i > 0; i--)
{ {
if (m_pVIPQueue[i - 1]) if (m_pVIPQueue[i - 1])
{ {
@ -2211,22 +2199,22 @@ void CHalfLifeMultiplay::PickNextVIP()
int iCount = 1; int iCount = 1;
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
CBasePlayer *player = nullptr;
CBasePlayer *pLastPlayer = nullptr; CBasePlayer *pLastPlayer = nullptr;
pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{
if (!FNullEnt(pEntity->edict()))
break;
while (pPlayer && !FNullEnt(pPlayer->edict())) if (pEntity->IsDormant())
{ continue;
if (!(pPlayer->pev->flags & FL_DORMANT))
{
player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev);
if (player->m_iTeam == CT && iCount == m_iLastPick) CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (pPlayer->m_iTeam == CT && iCount == m_iLastPick)
{ {
if (player == m_pVIP && pLastPlayer) if (pPlayer == m_pVIP && pLastPlayer)
player = pLastPlayer; pPlayer = pLastPlayer;
// Remove the current VIP from his VIP status and make him a regular CT. // Remove the current VIP from his VIP status and make him a regular CT.
if (m_pVIP) if (m_pVIP)
@ -2234,44 +2222,40 @@ void CHalfLifeMultiplay::PickNextVIP()
ResetCurrentVIP(); ResetCurrentVIP();
} }
player->MakeVIP(); pPlayer->MakeVIP();
m_iConsecutiveVIP = 0; m_iConsecutiveVIP = 0;
return; break;
} }
else if (player->m_iTeam == CT)
if (pPlayer->m_iTeam == CT)
iCount++; iCount++;
if (player->m_iTeam != SPECTATOR) if (pPlayer->m_iTeam != SPECTATOR)
pLastPlayer = player; pLastPlayer = pPlayer;
}
pPlayer = UTIL_FindEntityByClassname(pPlayer, "player");
} }
} }
// There is no VIP and there is no one waiting to be the VIP.. therefore just pick the first CT player we can find. // There is no VIP and there is no one waiting to be the VIP.. therefore just pick the first CT player we can find.
else if (m_pVIP == nullptr) else if (m_pVIP == nullptr)
{ {
CBaseEntity *pPlayer = nullptr; CBaseEntity *pEntity = nullptr;
CBasePlayer *player = nullptr;
pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
while (pPlayer && !FNullEnt(pPlayer->edict()))
{ {
if (pPlayer->pev->flags != FL_DORMANT) if (!FNullEnt(pEntity->edict()))
{ break;
player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev);
if (player->m_iTeam == CT) if (pEntity->IsDormant())
continue;
CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (pPlayer->m_iTeam == CT)
{ {
player->MakeVIP(); pPlayer->MakeVIP();
m_iConsecutiveVIP = 0; m_iConsecutiveVIP = 0;
return; return;
} }
} }
pPlayer = UTIL_FindEntityByClassname(pPlayer, "player");
}
} }
} }
@ -3041,7 +3025,7 @@ bool CHalfLifeMultiplay::IsBombPlanted()
if (m_bMapHasBombTarget) if (m_bMapHasBombTarget)
{ {
CGrenade *bomb = nullptr; CGrenade *bomb = nullptr;
while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade"))) while ((bomb = UTIL_FindEntityByClassname(bomb, "grenade")))
{ {
if (bomb->m_bIsC4) if (bomb->m_bIsC4)
{ {
@ -3053,22 +3037,21 @@ bool CHalfLifeMultiplay::IsBombPlanted()
return false; return false;
} }
// living players on the given team need to be marked as not receiving any money // Living players on the given team need to be marked as not receiving any money next round.
// next round.
void CHalfLifeMultiplay::MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int iTeam) void CHalfLifeMultiplay::MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int iTeam)
{ {
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->pev)) if (!pPlayer || FNullEnt(pPlayer->pev))
continue; continue;
if (player->m_iTeam == iTeam) if (pPlayer->m_iTeam == iTeam)
{ {
if (player->pev->health > 0 && player->pev->deadflag == DEAD_NO) if (pPlayer->pev->health > 0 && pPlayer->pev->deadflag == DEAD_NO)
{ {
player->m_bReceivesNoMoneyNextRound = true; pPlayer->m_bReceivesNoMoneyNextRound = true;
} }
} }
} }
@ -3097,14 +3080,14 @@ void CHalfLifeMultiplay::CareerRestart()
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player || FNullEnt(player->pev)) if (!pPlayer || FNullEnt(pPlayer->pev))
continue; continue;
if (!player->IsBot()) if (!pPlayer->IsBot())
{ {
player->ForceClientDllUpdate(); pPlayer->ForceClientDllUpdate();
} }
} }
} }
@ -3379,7 +3362,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl)
else else
{ {
CGrenade *bomb = nullptr; CGrenade *bomb = nullptr;
while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade"))) while ((bomb = UTIL_FindEntityByClassname(bomb, "grenade")))
{ {
if (bomb->m_bIsC4) if (bomb->m_bIsC4)
{ {
@ -3477,22 +3460,22 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient)
pPlayer->m_pObserver->SUB_Remove(); pPlayer->m_pObserver->SUB_Remove();
} }
CBasePlayer *pClient = nullptr; CBasePlayer *pObserver = nullptr;
while ((pClient = UTIL_FindEntityByClassname(pClient, "player"))) while ((pObserver = UTIL_FindEntityByClassname(pObserver, "player")))
{ {
if (FNullEnt(pClient->edict())) if (FNullEnt(pObserver->edict()))
break; break;
if (!pClient->pev || pClient == pPlayer) if (!pObserver->pev || pObserver == pPlayer)
continue; continue;
// If a spectator was chasing this player, move him/her onto the next player // If a spectator was chasing this player, move him/her onto the next player
if (pClient->m_hObserverTarget == pPlayer) if (pObserver->m_hObserverTarget == pPlayer)
{ {
int iMode = pClient->pev->iuser1; int iMode = pObserver->pev->iuser1;
pClient->pev->iuser1 = OBS_NONE; pObserver->pev->iuser1 = OBS_NONE;
pClient->Observer_SetMode(iMode); pObserver->Observer_SetMode(iMode);
} }
} }
} }
@ -4170,10 +4153,7 @@ int CHalfLifeMultiplay::PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pT
return GR_NOTTEAMMATE; return GR_NOTTEAMMATE;
} }
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); if (pPlayer->m_iTeam != static_cast<CBasePlayer *>(pTarget)->m_iTeam)
CBasePlayer *target = GetClassPtr<CCSPlayer>((CBasePlayer *)pTarget->pev);
if (player->m_iTeam != target->m_iTeam)
{ {
return GR_NOTTEAMMATE; return GR_NOTTEAMMATE;
} }
@ -4428,40 +4408,67 @@ void ExtractCommandString(char *s, char *szCommand)
char value[512]; // use two buffers so compares char value[512]; // use two buffers so compares
// work without stomping on each other // work without stomping on each other
char *o; char *c;
int nCount;
if (*s == '\\') while (*s)
s++;
while (true)
{ {
o = pkey; if (*s == '\\')
{
// skip the slash
s++;
}
// Copy a key
c = pkey;
nCount = 0;
while (*s != '\\') while (*s != '\\')
{ {
if (!*s) if (!*s)
{ {
return; // allow value to be ended with NULL
break;
} }
*o++ = *s++; if (nCount >= sizeof(pkey))
} {
*o = '\0';
s++; s++;
// skip oversized key chars till the slash or EOL
continue;
}
o = value; *c++ = *s++;
nCount++;
}
while (*s != '\\' && *s) *c = '\0';
s++; // skip the slash
// Copy a value
c = value;
nCount = 0;
while (*s != '\\')
{ {
if (!*s) if (!*s)
{ {
return; // allow value to be ended with NULL
break;
} }
*o++ = *s++; if (nCount >= sizeof(value))
{
s++;
// skip oversized value chars till the slash or EOL
continue;
} }
*o = '\0'; *c++ = *s++;
nCount++;
}
*c = '\0';
Q_strcat(szCommand, pkey); Q_strcat(szCommand, pkey);
if (Q_strlen(value) > 0) if (Q_strlen(value) > 0)
@ -4471,29 +4478,28 @@ void ExtractCommandString(char *s, char *szCommand)
} }
Q_strcat(szCommand, "\n"); Q_strcat(szCommand, "\n");
if (!*s) /*if (!*s)
{ {
return; return;
} }
s++; s++;*/
} }
} }
void CHalfLifeMultiplay::ResetAllMapVotes() void CHalfLifeMultiplay::ResetAllMapVotes()
{ {
CBaseEntity *pTempEntity = nullptr; CBaseEntity *pEntity = nullptr;
while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pTempEntity->edict())) if (FNullEnt(pEntity->edict()))
break; break;
CBasePlayer *pTempPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pTempEntity->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (pPlayer->m_iTeam != UNASSIGNED)
if (pTempPlayer->m_iTeam != UNASSIGNED)
{ {
pTempPlayer->m_iMapVote = 0; pPlayer->m_iMapVote = 0;
} }
} }
@ -4517,14 +4523,14 @@ int GetMapCount()
if (!item) if (!item)
break; break;
++nCount; nCount++;
item = item->next; item = item->next;
} while (item != mapcycle.next_item); } while (item != mapcycle.next_item);
return nCount; return nCount;
} }
void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote) void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *pPlayer, int iVote)
{ {
static mapcycle_t mapcycle2; static mapcycle_t mapcycle2;
char *mapcfile = (char *)CVAR_GET_STRING("mapcyclefile"); char *mapcfile = (char *)CVAR_GET_STRING("mapcyclefile");
@ -4541,16 +4547,18 @@ void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote)
if (item->next == mapcycle2.next_item) if (item->next == mapcycle2.next_item)
done = 1; done = 1;
++iCount; iCount++;
if (player) if (pPlayer)
{ {
if (m_iMapVotes[iCount] == 1) if (m_iMapVotes[iCount] == 1)
{ {
ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Vote", UTIL_dtos1(iCount), item->mapname, UTIL_dtos2(1)); ClientPrint(pPlayer->pev, HUD_PRINTCONSOLE, "#Vote", UTIL_dtos1(iCount), item->mapname, UTIL_dtos2(1));
} }
else else
ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Votes", UTIL_dtos1(iCount), item->mapname, UTIL_dtos2(m_iMapVotes[iCount])); {
ClientPrint(pPlayer->pev, HUD_PRINTCONSOLE, "#Votes", UTIL_dtos1(iCount), item->mapname, UTIL_dtos2(m_iMapVotes[iCount]));
}
} }
if (iCount == iVote) if (iCount == iVote)
@ -4581,24 +4589,24 @@ void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote)
ResetAllMapVotes(); ResetAllMapVotes();
} }
void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *player, int iVote) void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *pPlayer, int iVote)
{ {
CBaseEntity *pTempEntity = nullptr; CBaseEntity *pEntity = nullptr;
int iValidVotes = 0, iNumPlayers = 0; int iValidVotes = 0, iNumPlayers = 0;
while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pTempEntity->edict())) if (FNullEnt(pEntity->edict()))
break; break;
CBasePlayer *pTempPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pTempEntity->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (pTempPlayer->m_iTeam != UNASSIGNED) if (pPlayer->m_iTeam != UNASSIGNED)
{ {
++iNumPlayers; iNumPlayers++;
if (pTempPlayer->m_iMapVote == iVote) if (pPlayer->m_iMapVote == iVote)
++iValidVotes; iValidVotes++;
} }
} }
@ -4624,12 +4632,14 @@ void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *player, int iVote)
if (iValidVotes < iRequiredVotes) if (iValidVotes < iRequiredVotes)
{ {
DisplayMaps(player, 0); DisplayMaps(pPlayer, 0);
ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_required_votes", UTIL_dtos1(iRequiredVotes)); ClientPrint(pPlayer->pev, HUD_PRINTCONSOLE, "#Game_required_votes", UTIL_dtos1(iRequiredVotes));
} }
else else
{
DisplayMaps(nullptr, iVote); DisplayMaps(nullptr, iVote);
} }
}
LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, ChangeLevel); LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, ChangeLevel);

View File

@ -201,7 +201,7 @@ CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move)
while (dist > 0) while (dist > 0)
{ {
Vector dir = pcurrent->pev->origin - currentPos; Vector dir = pcurrent->pev->origin - currentPos;
float_precision length = dir.Length(); real_t length = dir.Length();
if (!length) if (!length)
{ {
@ -260,7 +260,7 @@ CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move)
} }
Vector dir = pcurrent->GetNext()->pev->origin - currentPos; Vector dir = pcurrent->GetNext()->pev->origin - currentPos;
float_precision length = dir.Length(); real_t length = dir.Length();
if (!length && !ValidPath(pcurrent->GetNext()->GetNext(), move)) if (!length && !ValidPath(pcurrent->GetNext()->GetNext(), move))
{ {

View File

@ -356,7 +356,7 @@ void CFuncPlat::PlatUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
} }
else else
{ {
SetUse(NULL); SetUse(nullptr);
if (m_toggle_state == TS_AT_TOP) if (m_toggle_state == TS_AT_TOP)
{ {
@ -829,7 +829,7 @@ void CFuncTrain::Restart()
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
SetThink(NULL); SetThink(nullptr);
pev->velocity = g_vecZero; pev->velocity = g_vecZero;
// restore of first target // restore of first target
@ -958,7 +958,7 @@ void CFuncTrackTrain::Blocked(CBaseEntity *pOther)
// Blocker is on-ground on the train // Blocker is on-ground on the train
if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev) if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev)
{ {
float_precision deltaSpeed = Q_fabs(float_precision(pev->speed)); real_t deltaSpeed = Q_fabs(real_t(pev->speed));
if (deltaSpeed > 50) if (deltaSpeed > 50)
{ {
@ -1004,12 +1004,12 @@ void CFuncTrackTrain::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP
pev->velocity = g_vecZero; pev->velocity = g_vecZero;
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
StopSound(); StopSound();
SetThink(NULL); SetThink(nullptr);
} }
} }
else else
{ {
float_precision delta = (int(pev->speed * 4.0f) / int(m_speed)) * 0.25 + 0.25 * value; real_t delta = (int(pev->speed * 4.0f) / int(m_speed)) * 0.25 + 0.25 * value;
if (delta > 1) if (delta > 1)
delta = 1; delta = 1;
@ -1115,8 +1115,8 @@ void CFuncTrackTrain::Next()
pev->velocity = (nextPos - pev->origin) * 10; pev->velocity = (nextPos - pev->origin) * 10;
#else #else
// TODO: fix test demo // TODO: fix test demo
pev->velocity.x = (float_precision(nextPos.x - pev->origin.x) * 10.0f); pev->velocity.x = (real_t(nextPos.x - pev->origin.x) * 10.0f);
pev->velocity.y = (float_precision(nextPos.y - pev->origin.y) * 10.0f); pev->velocity.y = (real_t(nextPos.y - pev->origin.y) * 10.0f);
pev->velocity.z = ((nextPos.z - pev->origin.z) * 10.0f); pev->velocity.z = ((nextPos.z - pev->origin.z) * 10.0f);
#endif #endif
@ -1140,7 +1140,7 @@ void CFuncTrackTrain::Next()
// TODO: All of this crap has to be done to make the angles not wrap around, revisit this. // TODO: All of this crap has to be done to make the angles not wrap around, revisit this.
UTIL_FixupAngles(angles); UTIL_FixupAngles(angles);
#else #else
float_precision fixAngleY = angles.y + 180.0f; real_t fixAngleY = angles.y + 180.0f;
angles.x = UTIL_FixupAngle(angles.x); angles.x = UTIL_FixupAngle(angles.x);
angles.y = UTIL_FixupAngle(fixAngleY); // TODO: fix test demo angles.y = UTIL_FixupAngle(fixAngleY); // TODO: fix test demo
@ -1388,7 +1388,7 @@ void CFuncTrackTrain::NearestPath()
{ {
CPathTrack *pTrack = nullptr; CPathTrack *pTrack = nullptr;
CPathTrack *pNearest = nullptr; CPathTrack *pNearest = nullptr;
float_precision dist; real_t dist;
float closest = 1024.0f; float closest = 1024.0f;
while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024.0f))) while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024.0f)))
@ -1409,7 +1409,7 @@ void CFuncTrackTrain::NearestPath()
if (!pNearest) if (!pNearest)
{ {
ALERT(at_console, "Can't find a nearby track !!!\n"); ALERT(at_console, "Can't find a nearby track !!!\n");
SetThink(NULL); SetThink(nullptr);
return; return;
} }
@ -1732,7 +1732,7 @@ TRAIN_CODE CFuncTrackChange::EvaluateTrain(CPathTrack *pcurrent)
return TRAIN_BLOCKING; return TRAIN_BLOCKING;
Vector dist = pev->origin - m_train->pev->origin; Vector dist = pev->origin - m_train->pev->origin;
float_precision length = dist.Length2D(); real_t length = dist.Length2D();
// Empirically determined close distance // Empirically determined close distance
if (length < m_train->m_length) if (length < m_train->m_length)
@ -1750,7 +1750,7 @@ TRAIN_CODE CFuncTrackChange::EvaluateTrain(CPathTrack *pcurrent)
void CFuncTrackChange::UpdateTrain(Vector &dest) void CFuncTrackChange::UpdateTrain(Vector &dest)
{ {
float_precision time = (pev->nextthink - pev->ltime); real_t time = (pev->nextthink - pev->ltime);
m_train->pev->velocity = pev->velocity; m_train->pev->velocity = pev->velocity;
m_train->pev->avelocity = pev->avelocity; m_train->pev->avelocity = pev->avelocity;
@ -1904,7 +1904,7 @@ void CFuncTrackChange::HitBottom()
//UpdateTrain(); //UpdateTrain();
m_train->SetTrack(m_trackBottom); m_train->SetTrack(m_trackBottom);
} }
SetThink(NULL); SetThink(nullptr);
pev->nextthink = -1; pev->nextthink = -1;
UpdateAutoTargets(m_toggle_state); UpdateAutoTargets(m_toggle_state);
@ -1922,7 +1922,7 @@ void CFuncTrackChange::HitTop()
} }
// Don't let the plat go back down // Don't let the plat go back down
SetThink(NULL); SetThink(nullptr);
pev->nextthink = -1; pev->nextthink = -1;
UpdateAutoTargets(m_toggle_state); UpdateAutoTargets(m_toggle_state);
@ -2076,7 +2076,7 @@ void CGunTarget::Start()
void CGunTarget::Next() void CGunTarget::Next()
{ {
SetThink(NULL); SetThink(nullptr);
m_hTargetEnt = GetNextTarget(); m_hTargetEnt = GetNextTarget();
CBaseEntity *pTarget = m_hTargetEnt; CBaseEntity *pTarget = m_hTargetEnt;

View File

@ -318,7 +318,6 @@ CBasePlayer *CBasePlayer::GetNextRadioRecipient(CBasePlayer *pStartPlayer)
else if (pPlayer) else if (pPlayer)
{ {
int iSpecMode = IsObserver(); int iSpecMode = IsObserver();
if (iSpecMode != OBS_CHASE_LOCKED && iSpecMode != OBS_CHASE_FREE && iSpecMode != OBS_IN_EYE) if (iSpecMode != OBS_CHASE_LOCKED && iSpecMode != OBS_CHASE_FREE && iSpecMode != OBS_IN_EYE)
continue; continue;
@ -386,9 +385,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
if (!FNullEnt(pPlayer->m_hObserverTarget)) if (!FNullEnt(pPlayer->m_hObserverTarget))
continue; continue;
CBasePlayer *pTarget = static_cast<CBasePlayer *>(CBaseEntity::Instance(pPlayer->m_hObserverTarget->pev)); if (m_hObserverTarget && m_hObserverTarget->m_iTeam == m_iTeam)
if (pTarget && pTarget->m_iTeam == m_iTeam)
{ {
bSend = true; bSend = true;
} }
@ -814,7 +811,6 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
BOOL bTeamAttack = FALSE; BOOL bTeamAttack = FALSE;
int armorHit = 0; int armorHit = 0;
CBasePlayer *pAttack = nullptr; CBasePlayer *pAttack = nullptr;
CBaseEntity *pAttacker = nullptr;
if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL)) if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL))
m_LastHitGroup = HITGROUP_GENERIC; m_LastHitGroup = HITGROUP_GENERIC;
@ -865,8 +861,8 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
if (pev->armorvalue != 0.0f && IsArmored(m_LastHitGroup)) if (pev->armorvalue != 0.0f && IsArmored(m_LastHitGroup))
{ {
float_precision flNew = flRatio * flDamage; real_t flNew = flRatio * flDamage;
float_precision flArmor = (flDamage - flNew) * flBonus; real_t flArmor = (flDamage - flNew) * flBonus;
// Does this use more armor than we have? // Does this use more armor than we have?
if (flArmor > pev->armorvalue) if (flArmor > pev->armorvalue)
@ -894,7 +890,9 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
Pain(m_LastHitGroup, true); Pain(m_LastHitGroup, true);
} }
else else
{
Pain(m_LastHitGroup, false); Pain(m_LastHitGroup, false);
}
m_lastDamageAmount = flDamage; m_lastDamageAmount = flDamage;
@ -922,23 +920,12 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack);
} }
if (CSGameRules()->IsCareer())
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer)
continue;
bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam);
if (killedByHumanPlayer)
{
if (TheCareerTasks) if (TheCareerTasks)
{ {
TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); CBasePlayer *pPlayerAttacker = CBasePlayer::Instance(pevAttacker);
} if (pPlayerAttacker && !pPlayerAttacker->IsBot() && pPlayerAttacker->m_iTeam != m_iTeam)
} {
TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayerAttacker->HasShield(), pPlayerAttacker);
} }
} }
} }
@ -981,7 +968,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
return bTookDamage; return bTookDamage;
} }
pAttacker = CBaseEntity::Instance(pevAttacker); CBaseEntity *pAttacker = CBaseEntity::Instance(pevAttacker);
if (!g_pGameRules->FPlayerCanTakeDamage(this, pAttacker) && !FClassnameIs(pevInflictor, "grenade")) if (!g_pGameRules->FPlayerCanTakeDamage(this, pAttacker) && !FClassnameIs(pevInflictor, "grenade"))
{ {
@ -1028,17 +1015,17 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
bTeamAttack = TRUE; bTeamAttack = TRUE;
if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f) if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6f)
{ {
CBaseEntity *pBasePlayer = nullptr; CBaseEntity *pEntity = nullptr;
while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pBasePlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
CBasePlayer *basePlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pBasePlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (basePlayer->m_iTeam == m_iTeam) if (pPlayer->m_iTeam == m_iTeam)
{ {
ClientPrint(basePlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname)); ClientPrint(pPlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname));
} }
} }
@ -1113,6 +1100,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
m_flVelocityModifier = 0.65f; m_flVelocityModifier = 0.65f;
} }
SetAnimation(PLAYER_LARGE_FLINCH); SetAnimation(PLAYER_LARGE_FLINCH);
} }
} }
@ -1124,8 +1112,8 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
// armor doesn't protect against fall or drown damage! // armor doesn't protect against fall or drown damage!
if (pev->armorvalue != 0.0f && !(bitsDamageType & (DMG_DROWN | DMG_FALL)) && IsArmored(m_LastHitGroup)) if (pev->armorvalue != 0.0f && !(bitsDamageType & (DMG_DROWN | DMG_FALL)) && IsArmored(m_LastHitGroup))
{ {
float_precision flNew = flRatio * flDamage; real_t flNew = flRatio * flDamage;
float_precision flArmor = (flDamage - flNew) * flBonus; real_t flArmor = (flDamage - flNew) * flBonus;
// Does this use more armor than we have? // Does this use more armor than we have?
if (flArmor > pev->armorvalue) if (flArmor > pev->armorvalue)
@ -1155,7 +1143,9 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
Pain(m_LastHitGroup, true); Pain(m_LastHitGroup, true);
} }
else else
{
Pain(m_LastHitGroup, false); Pain(m_LastHitGroup, false);
}
LogAttack(pAttack, this, bTeamAttack, flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); LogAttack(pAttack, this, bTeamAttack, flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker));
@ -1170,23 +1160,12 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack);
} }
if (CSGameRules()->IsCareer())
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer)
continue;
bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam);
if (killedByHumanPlayer)
{
if (TheCareerTasks) if (TheCareerTasks)
{ {
TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); CBasePlayer *pPlayerAttacker = CBasePlayer::Instance(pevAttacker);
} if (pPlayerAttacker && !pPlayerAttacker->IsBot() && pPlayerAttacker->m_iTeam != m_iTeam)
} {
TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayerAttacker->HasShield(), pPlayerAttacker);
} }
} }
} }
@ -1598,19 +1577,19 @@ void CBasePlayer::SetProgressBarTime(int time)
WRITE_SHORT(time); WRITE_SHORT(time);
MESSAGE_END(); MESSAGE_END();
CBaseEntity *pPlayer = nullptr; int playerIndex = entindex();
int myIndex = entindex(); CBaseEntity *pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (player->IsObserver() == OBS_IN_EYE && player->pev->iuser2 == myIndex) if (pPlayer->IsObserver() == OBS_IN_EYE && pPlayer->pev->iuser2 == playerIndex)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, nullptr, pPlayer->pev);
WRITE_SHORT(time); WRITE_SHORT(time);
MESSAGE_END(); MESSAGE_END();
} }
@ -1638,19 +1617,19 @@ void CBasePlayer::SetProgressBarTime2(int time, float timeElapsed)
WRITE_SHORT(iTimeElapsed); WRITE_SHORT(iTimeElapsed);
MESSAGE_END(); MESSAGE_END();
CBaseEntity *pPlayer = nullptr; int playerIndex = entindex();
int myIndex = entindex(); CBaseEntity *pEntity = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")))
{ {
if (FNullEnt(pPlayer->edict())) if (FNullEnt(pEntity->edict()))
break; break;
CBasePlayer *player = GetClassPtr<CCSPlayer>((CBasePlayer *)pPlayer->pev); CBasePlayer *pPlayer = GetClassPtr<CCSPlayer>((CBasePlayer *)pEntity->pev);
if (player->IsObserver() == OBS_IN_EYE && player->pev->iuser2 == myIndex) if (pPlayer->IsObserver() == OBS_IN_EYE && pPlayer->pev->iuser2 == playerIndex)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBarTime2, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgBarTime2, nullptr, pPlayer->pev);
WRITE_SHORT(time); WRITE_SHORT(time);
WRITE_SHORT(iTimeElapsed); WRITE_SHORT(iTimeElapsed);
MESSAGE_END(); MESSAGE_END();
@ -1658,9 +1637,9 @@ void CBasePlayer::SetProgressBarTime2(int time, float timeElapsed)
} }
} }
void BuyZoneIcon_Set(CBasePlayer *player) void BuyZoneIcon_Set(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_SHOW); WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("buyzone"); WRITE_STRING("buyzone");
WRITE_BYTE(0); WRITE_BYTE(0);
@ -1669,45 +1648,46 @@ void BuyZoneIcon_Set(CBasePlayer *player)
MESSAGE_END(); MESSAGE_END();
} }
void BuyZoneIcon_Clear(CBasePlayer *player) void BuyZoneIcon_Clear(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_HIDE); WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("buyzone"); WRITE_STRING("buyzone");
MESSAGE_END(); MESSAGE_END();
if (player->m_iMenu >= Menu_Buy) if (pPlayer->m_iMenu >= Menu_Buy)
{ {
if (player->m_iMenu <= Menu_BuyItem) if (pPlayer->m_iMenu <= Menu_BuyItem)
{ {
CLIENT_COMMAND(ENT(player->pev), "slot10\n"); CLIENT_COMMAND(ENT(pPlayer->pev), "slot10\n");
} }
else if (player->m_iMenu == Menu_ClientBuy) else if (pPlayer->m_iMenu == Menu_ClientBuy)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, pPlayer->pev);
MESSAGE_END(); MESSAGE_END();
} }
} }
} }
void BombTargetFlash_Set(CBasePlayer *player) void BombTargetFlash_Set(CBasePlayer *pPlayer)
{ {
if (player->m_bHasC4 && !(player->m_flDisplayHistory & DHF_IN_TARGET_ZONE)) if (pPlayer->m_bHasC4 && !(pPlayer->m_flDisplayHistory & DHF_IN_TARGET_ZONE))
{ {
player->m_flDisplayHistory |= DHF_IN_TARGET_ZONE; pPlayer->m_flDisplayHistory |= DHF_IN_TARGET_ZONE;
player->HintMessage("#Hint_you_are_in_targetzone"); pPlayer->HintMessage("#Hint_you_are_in_targetzone");
}
player->SetBombIcon(TRUE);
} }
void BombTargetFlash_Clear(CBasePlayer *player) pPlayer->SetBombIcon(TRUE);
{
player->SetBombIcon(FALSE);
} }
void RescueZoneIcon_Set(CBasePlayer *player) void BombTargetFlash_Clear(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); pPlayer->SetBombIcon(FALSE);
}
void RescueZoneIcon_Set(CBasePlayer *pPlayer)
{
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_SHOW); WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("rescue"); WRITE_STRING("rescue");
WRITE_BYTE(0); WRITE_BYTE(0);
@ -1715,37 +1695,37 @@ void RescueZoneIcon_Set(CBasePlayer *player)
WRITE_BYTE(0); WRITE_BYTE(0);
MESSAGE_END(); MESSAGE_END();
if (player->m_iTeam == CT && !(player->m_flDisplayHistory & DHF_IN_RESCUE_ZONE)) if (pPlayer->m_iTeam == CT && !(pPlayer->m_flDisplayHistory & DHF_IN_RESCUE_ZONE))
{ {
player->m_flDisplayHistory |= DHF_IN_RESCUE_ZONE; pPlayer->m_flDisplayHistory |= DHF_IN_RESCUE_ZONE;
player->HintMessage("#Hint_hostage_rescue_zone"); pPlayer->HintMessage("#Hint_hostage_rescue_zone");
} }
} }
void RescueZoneIcon_Clear(CBasePlayer *player) void RescueZoneIcon_Clear(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_HIDE); WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("rescue"); WRITE_STRING("rescue");
MESSAGE_END(); MESSAGE_END();
if (player->m_iMenu >= Menu_Buy) if (pPlayer->m_iMenu >= Menu_Buy)
{ {
if (player->m_iMenu <= Menu_BuyItem) if (pPlayer->m_iMenu <= Menu_BuyItem)
{ {
CLIENT_COMMAND(ENT(player->pev), "slot10\n"); CLIENT_COMMAND(ENT(pPlayer->pev), "slot10\n");
} }
else if (player->m_iMenu == Menu_ClientBuy) else if (pPlayer->m_iMenu == Menu_ClientBuy)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, pPlayer->pev);
MESSAGE_END(); MESSAGE_END();
} }
} }
} }
void EscapeZoneIcon_Set(CBasePlayer *player) void EscapeZoneIcon_Set(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_SHOW); WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("escape"); WRITE_STRING("escape");
WRITE_BYTE(0); WRITE_BYTE(0);
@ -1753,40 +1733,40 @@ void EscapeZoneIcon_Set(CBasePlayer *player)
WRITE_BYTE(0); WRITE_BYTE(0);
MESSAGE_END(); MESSAGE_END();
if (player->m_iTeam == CT) if (pPlayer->m_iTeam == CT)
{ {
if (!(player->m_flDisplayHistory & DHF_IN_ESCAPE_ZONE)) if (!(pPlayer->m_flDisplayHistory & DHF_IN_ESCAPE_ZONE))
{ {
player->m_flDisplayHistory |= DHF_IN_ESCAPE_ZONE; pPlayer->m_flDisplayHistory |= DHF_IN_ESCAPE_ZONE;
player->HintMessage("#Hint_terrorist_escape_zone"); pPlayer->HintMessage("#Hint_terrorist_escape_zone");
} }
} }
} }
void EscapeZoneIcon_Clear(CBasePlayer *player) void EscapeZoneIcon_Clear(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_HIDE); WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("escape"); WRITE_STRING("escape");
MESSAGE_END(); MESSAGE_END();
if (player->m_iMenu >= Menu_Buy) if (pPlayer->m_iMenu >= Menu_Buy)
{ {
if (player->m_iMenu <= Menu_BuyItem) if (pPlayer->m_iMenu <= Menu_BuyItem)
{ {
CLIENT_COMMAND(player->edict(), "slot10\n"); CLIENT_COMMAND(pPlayer->edict(), "slot10\n");
} }
else if (player->m_iMenu == Menu_ClientBuy) else if (pPlayer->m_iMenu == Menu_ClientBuy)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, pPlayer->pev);
MESSAGE_END(); MESSAGE_END();
} }
} }
} }
void VIP_SafetyZoneIcon_Set(CBasePlayer *player) void VIP_SafetyZoneIcon_Set(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_SHOW); WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("vipsafety"); WRITE_STRING("vipsafety");
WRITE_BYTE(0); WRITE_BYTE(0);
@ -1794,37 +1774,37 @@ void VIP_SafetyZoneIcon_Set(CBasePlayer *player)
WRITE_BYTE(0); WRITE_BYTE(0);
MESSAGE_END(); MESSAGE_END();
if (!(player->m_flDisplayHistory & DHF_IN_VIPSAFETY_ZONE)) if (!(pPlayer->m_flDisplayHistory & DHF_IN_VIPSAFETY_ZONE))
{ {
if (player->m_iTeam == CT) if (pPlayer->m_iTeam == CT)
{ {
player->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE; pPlayer->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE;
player->HintMessage("#Hint_ct_vip_zone", TRUE); pPlayer->HintMessage("#Hint_ct_vip_zone", TRUE);
} }
else if (player->m_iTeam == TERRORIST) else if (pPlayer->m_iTeam == TERRORIST)
{ {
player->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE; pPlayer->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE;
player->HintMessage("#Hint_terrorist_vip_zone", TRUE); pPlayer->HintMessage("#Hint_terrorist_vip_zone", TRUE);
} }
} }
} }
void VIP_SafetyZoneIcon_Clear(CBasePlayer *player) void VIP_SafetyZoneIcon_Clear(CBasePlayer *pPlayer)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_HIDE); WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("vipsafety"); WRITE_STRING("vipsafety");
MESSAGE_END(); MESSAGE_END();
if (player->m_iMenu >= Menu_Buy) if (pPlayer->m_iMenu >= Menu_Buy)
{ {
if (player->m_iMenu <= Menu_BuyItem) if (pPlayer->m_iMenu <= Menu_BuyItem)
{ {
CLIENT_COMMAND(player->edict(), "slot10\n"); CLIENT_COMMAND(pPlayer->edict(), "slot10\n");
} }
else if (player->m_iMenu == Menu_ClientBuy) else if (pPlayer->m_iMenu == Menu_ClientBuy)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, pPlayer->pev);
MESSAGE_END(); MESSAGE_END();
} }
} }
@ -1832,7 +1812,7 @@ void VIP_SafetyZoneIcon_Clear(CBasePlayer *player)
void CBasePlayer::SendFOV(int fov) void CBasePlayer::SendFOV(int fov)
{ {
pev->fov = float_precision(fov); pev->fov = real_t(fov);
m_iClientFOV = fov; m_iClientFOV = fov;
m_iFOV = fov; m_iFOV = fov;
@ -3704,24 +3684,24 @@ void EXT_FUNC CBasePlayer::__API_HOOK(StartObserver)(Vector &vecPosition, Vector
MESSAGE_END(); MESSAGE_END();
} }
bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity) bool CanSeeUseable(CBasePlayer *me, CBaseEntity *pEntity)
{ {
TraceResult result; TraceResult result;
Vector eye = me->pev->origin + me->pev->view_ofs; Vector eye = me->pev->origin + me->pev->view_ofs;
if (FClassnameIs(entity->pev, "hostage_entity")) if (FClassnameIs(pEntity->pev, "hostage_entity"))
{ {
Vector chest = entity->pev->origin + Vector(0, 0, HalfHumanHeight); Vector chest = pEntity->pev->origin + Vector(0, 0, HalfHumanHeight);
Vector head = entity->pev->origin + Vector(0, 0, HumanHeight * 0.9); Vector head = pEntity->pev->origin + Vector(0, 0, HumanHeight * 0.9);
Vector knees = entity->pev->origin + Vector(0, 0, StepHeight); Vector knees = pEntity->pev->origin + Vector(0, 0, StepHeight);
UTIL_TraceLine(eye, chest, ignore_monsters, ignore_glass, me->edict(), &result); UTIL_TraceLine(eye, chest, ignore_monsters, ignore_glass, me->edict(), &result);
if (result.flFraction < 1.0f) if (result.flFraction < 1.0f)
{ {
UTIL_TraceLine(eye, head, ignore_monsters, ignore_glass, entity->edict(), &result); UTIL_TraceLine(eye, head, ignore_monsters, ignore_glass, pEntity->edict(), &result);
if (result.flFraction < 1.0f) if (result.flFraction < 1.0f)
{ {
UTIL_TraceLine(eye, knees, ignore_monsters, ignore_glass, entity->edict(), &result); UTIL_TraceLine(eye, knees, ignore_monsters, ignore_glass, pEntity->edict(), &result);
if (result.flFraction < 1.0f) if (result.flFraction < 1.0f)
{ {
return false; return false;
@ -4184,7 +4164,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
// Slow down the player based on the velocity modifier // Slow down the player based on the velocity modifier
if (m_flVelocityModifier < 1.0f) if (m_flVelocityModifier < 1.0f)
{ {
float_precision modvel = m_flVelocityModifier + 0.01; real_t modvel = m_flVelocityModifier + 0.01;
m_flVelocityModifier = modvel; m_flVelocityModifier = modvel;
pev->velocity = pev->velocity * modvel; pev->velocity = pev->velocity * modvel;
@ -4199,7 +4179,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
// check every 5 seconds // check every 5 seconds
m_flIdleCheckTime = gpGlobals->time + 5.0; m_flIdleCheckTime = gpGlobals->time + 5.0;
float_precision flLastMove = gpGlobals->time - m_fLastMovement; real_t flLastMove = gpGlobals->time - m_fLastMovement;
//check if this player has been inactive for 2 rounds straight //check if this player has been inactive for 2 rounds straight
if (flLastMove > CSGameRules()->m_fMaxIdlePeriod) if (flLastMove > CSGameRules()->m_fMaxIdlePeriod)
@ -5455,10 +5435,10 @@ void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination)
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (player && !FNullEnt(player->edict())) if (pPlayer && !FNullEnt(pPlayer->edict()))
SetScoreboardAttributes(player); SetScoreboardAttributes(pPlayer);
} }
} }
@ -6157,22 +6137,22 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse)
} }
} }
void OLD_CheckBuyZone(CBasePlayer *player) void OLD_CheckBuyZone(CBasePlayer *pPlayer)
{ {
const char *pszSpawnClass = nullptr; const char *pszSpawnClass = nullptr;
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (!CSGameRules()->CanPlayerBuy(player)) if (!CSGameRules()->CanPlayerBuy(pPlayer))
{ {
return; return;
} }
#endif #endif
if (player->m_iTeam == TERRORIST) if (pPlayer->m_iTeam == TERRORIST)
{ {
pszSpawnClass = "info_player_deathmatch"; pszSpawnClass = "info_player_deathmatch";
} }
else if (player->m_iTeam == CT) else if (pPlayer->m_iTeam == CT)
{ {
pszSpawnClass = "info_player_start"; pszSpawnClass = "info_player_start";
} }
@ -6182,9 +6162,9 @@ void OLD_CheckBuyZone(CBasePlayer *player)
CBaseEntity *pSpot = nullptr; CBaseEntity *pSpot = nullptr;
while ((pSpot = UTIL_FindEntityByClassname(pSpot, pszSpawnClass))) while ((pSpot = UTIL_FindEntityByClassname(pSpot, pszSpawnClass)))
{ {
if ((pSpot->pev->origin - player->pev->origin).Length() < 200.0f) if ((pSpot->pev->origin - pPlayer->pev->origin).Length() < 200.0f)
{ {
player->m_signals.Signal(SIGNAL_BUY); pPlayer->m_signals.Signal(SIGNAL_BUY);
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
break; break;
#endif #endif
@ -6193,14 +6173,14 @@ void OLD_CheckBuyZone(CBasePlayer *player)
} }
} }
void OLD_CheckBombTarget(CBasePlayer *player) void OLD_CheckBombTarget(CBasePlayer *pPlayer)
{ {
CBaseEntity *pSpot = nullptr; CBaseEntity *pSpot = nullptr;
while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_bomb_target"))) while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_bomb_target")))
{ {
if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) if ((pSpot->pev->origin - pPlayer->pev->origin).Length() <= 256.0f)
{ {
player->m_signals.Signal(SIGNAL_BOMB); pPlayer->m_signals.Signal(SIGNAL_BOMB);
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
break; break;
#endif #endif
@ -6208,14 +6188,14 @@ void OLD_CheckBombTarget(CBasePlayer *player)
} }
} }
void OLD_CheckRescueZone(CBasePlayer *player) void OLD_CheckRescueZone(CBasePlayer *pPlayer)
{ {
CBaseEntity *pSpot = nullptr; CBaseEntity *pSpot = nullptr;
while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue"))) while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue")))
{ {
if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) if ((pSpot->pev->origin - pPlayer->pev->origin).Length() <= 256.0f)
{ {
player->m_signals.Signal(SIGNAL_RESCUE); pPlayer->m_signals.Signal(SIGNAL_RESCUE);
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
break; break;
#endif #endif
@ -6552,25 +6532,25 @@ void CBasePlayer::SendHostagePos()
void CBasePlayer::SendHostageIcons() void CBasePlayer::SendHostageIcons()
{ {
CBaseEntity *pHostage = nullptr;
int numHostages = 0;
char buf[16];
if (!AreRunningCZero()) if (!AreRunningCZero())
return; return;
int hostagesCount = 0;
CBaseEntity *pHostage = nullptr;
while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (pHostage->IsAlive()) if (pHostage->IsAlive())
numHostages++; hostagesCount++;
} }
if (numHostages > MAX_HOSTAGE_ICON) if (hostagesCount > MAX_HOSTAGE_ICON)
numHostages = MAX_HOSTAGE_ICON; hostagesCount = MAX_HOSTAGE_ICON;
Q_snprintf(buf, ARRAYSIZE(buf), "hostage%d", numHostages); char buf[16];
Q_snprintf(buf, ARRAYSIZE(buf), "hostage%d", hostagesCount);
if (numHostages) if (hostagesCount)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgScenarioIcon, nullptr, pev); MESSAGE_BEGIN(MSG_ONE, gmsgScenarioIcon, nullptr, pev);
WRITE_BYTE(1); // active WRITE_BYTE(1); // active
@ -7778,7 +7758,7 @@ void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
void CBasePlayer::StudioEstimateGait() void CBasePlayer::StudioEstimateGait()
{ {
float_precision dt; real_t dt;
Vector est_velocity; Vector est_velocity;
dt = gpGlobals->frametime; dt = gpGlobals->frametime;
@ -7810,8 +7790,8 @@ void CBasePlayer::StudioEstimateGait()
if (!est_velocity.x && !est_velocity.y) if (!est_velocity.x && !est_velocity.y)
{ {
float_precision flYawDiff = pev->angles.y - m_flGaityaw; real_t flYawDiff = pev->angles.y - m_flGaityaw;
float_precision flYaw = Q_fmod(flYawDiff, 360); real_t flYaw = Q_fmod(flYawDiff, 360);
flYawDiff = flYawDiff - int64(flYawDiff / 360) * 360; flYawDiff = flYawDiff - int64(flYawDiff / 360) * 360;
@ -7839,9 +7819,9 @@ void CBasePlayer::StudioEstimateGait()
flYawDiff *= dt; flYawDiff *= dt;
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (float_precision(Q_abs(flYawDiff)) < 0.1f) if (real_t(Q_abs(flYawDiff)) < 0.1f)
#else #else
if (float_precision(Q_abs(int64(flYawDiff))) < 0.1f) if (real_t(Q_abs(int64(flYawDiff))) < 0.1f)
#endif #endif
flYawDiff = 0; flYawDiff = 0;
@ -7851,7 +7831,7 @@ void CBasePlayer::StudioEstimateGait()
} }
else else
{ {
m_flGaityaw = (Q_atan2(float_precision(est_velocity.y), float_precision(est_velocity.x)) * 180 / M_PI); m_flGaityaw = (Q_atan2(real_t(est_velocity.y), real_t(est_velocity.x)) * 180 / M_PI);
if (m_flGaityaw > 180) if (m_flGaityaw > 180)
m_flGaityaw = 180; m_flGaityaw = 180;
@ -7901,8 +7881,8 @@ void CBasePlayer::CalculateYawBlend()
float dt; float dt;
float maxyaw = 255.0f; float maxyaw = 255.0f;
float_precision flYaw; // view direction relative to movement real_t flYaw; // view direction relative to movement
float_precision blend_yaw; real_t blend_yaw;
dt = gpGlobals->frametime; dt = gpGlobals->frametime;
@ -7915,7 +7895,7 @@ void CBasePlayer::CalculateYawBlend()
StudioEstimateGait(); StudioEstimateGait();
// calc side to side turning // calc side to side turning
flYaw = Q_fmod(float_precision(pev->angles.y - m_flGaityaw), 360); flYaw = Q_fmod(real_t(pev->angles.y - m_flGaityaw), 360);
if (flYaw < -180) if (flYaw < -180)
flYaw += 360; flYaw += 360;
@ -7956,7 +7936,7 @@ void CBasePlayer::CalculateYawBlend()
void CBasePlayer::StudioProcessGait() void CBasePlayer::StudioProcessGait()
{ {
mstudioseqdesc_t *pseqdesc; mstudioseqdesc_t *pseqdesc;
float_precision dt = gpGlobals->frametime; real_t dt = gpGlobals->frametime;
if (dt < 0.0) if (dt < 0.0)
dt = 0; dt = 0;
@ -7994,7 +7974,7 @@ void CBasePlayer::ResetStamina()
pev->fuser2 = 0; pev->fuser2 = 0;
} }
float_precision GetPlayerPitch(const edict_t *pEdict) real_t GetPlayerPitch(const edict_t *pEdict)
{ {
if (!pEdict) if (!pEdict)
return 0.0f; return 0.0f;
@ -8008,7 +7988,7 @@ float_precision GetPlayerPitch(const edict_t *pEdict)
return pPlayer->m_flPitch; return pPlayer->m_flPitch;
} }
float_precision GetPlayerYaw(const edict_t *pEdict) real_t GetPlayerYaw(const edict_t *pEdict)
{ {
if (!pEdict) if (!pEdict)
return 0.0f; return 0.0f;
@ -8806,6 +8786,7 @@ void CBasePlayer::ParseAutoBuyString(const char *string, bool &boughtPrimary, bo
command[i] = '\0'; command[i] = '\0';
break; break;
} }
i++; i++;
} }
@ -9165,21 +9146,21 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (player->m_iTeam == m_iTeam || player->m_iTeam == SPECTATOR) if (pPlayer->m_iTeam == m_iTeam || pPlayer->m_iTeam == SPECTATOR)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgLocation, nullptr, player->edict()); MESSAGE_BEGIN(MSG_ONE, gmsgLocation, nullptr, pPlayer->edict());
WRITE_BYTE(entindex()); WRITE_BYTE(entindex());
WRITE_STRING(m_lastLocation); WRITE_STRING(m_lastLocation);
MESSAGE_END(); MESSAGE_END();
} }
else if (forceUpdate) else if (forceUpdate)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgLocation, nullptr, player->edict()); MESSAGE_BEGIN(MSG_ONE, gmsgLocation, nullptr, pPlayer->edict());
WRITE_BYTE(entindex()); WRITE_BYTE(entindex());
WRITE_STRING(""); WRITE_STRING("");
MESSAGE_END(); MESSAGE_END();

View File

@ -664,7 +664,7 @@ public:
int random_seed; int random_seed;
unsigned short m_usPlayerBleed; unsigned short m_usPlayerBleed;
EHANDLE m_hObserverTarget; EntityHandle<CBasePlayer> m_hObserverTarget;
float m_flNextObserverInput; float m_flNextObserverInput;
int m_iObserverWeapon; int m_iObserverWeapon;
int m_iObserverC4State; int m_iObserverC4State;
@ -877,9 +877,11 @@ public:
inline bool CBasePlayer::IsReloading() const inline bool CBasePlayer::IsReloading() const
{ {
CBasePlayerWeapon *weapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem); CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(m_pActiveItem);
if (weapon && weapon->m_fInReload) if (pCurrentWeapon && pCurrentWeapon->m_fInReload)
{
return true; return true;
}
return false; return false;
} }
@ -896,18 +898,18 @@ inline CCSPlayer *CBasePlayer::CSPlayer() const {
// Index is 1 based // Index is 1 based
inline CBasePlayer *UTIL_PlayerByIndex(int playerIndex) inline CBasePlayer *UTIL_PlayerByIndex(int playerIndex)
{ {
return (CBasePlayer *)GET_PRIVATE(INDEXENT(playerIndex)); return GET_PRIVATE<CBasePlayer>(INDEXENT(playerIndex));
} }
#endif #endif
inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex) inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex)
{ {
CBasePlayer *player = nullptr; CBasePlayer *pPlayer = nullptr;
if (likely(playerIndex > 0 && playerIndex <= gpGlobals->maxClients)) if (likely(playerIndex > 0 && playerIndex <= gpGlobals->maxClients))
player = UTIL_PlayerByIndex(playerIndex); pPlayer = UTIL_PlayerByIndex(playerIndex);
return player; return pPlayer;
} }
extern int gEvilImpulse101; extern int gEvilImpulse101;
@ -918,22 +920,22 @@ extern CBaseEntity *g_pLastTerroristSpawn;
extern BOOL gInitHUD; extern BOOL gInitHUD;
extern cvar_t *sv_aim; extern cvar_t *sv_aim;
void OLD_CheckBuyZone(CBasePlayer *player); void OLD_CheckBuyZone(CBasePlayer *pPlayer);
void OLD_CheckBombTarget(CBasePlayer *player); void OLD_CheckBombTarget(CBasePlayer *pPlayer);
void OLD_CheckRescueZone(CBasePlayer *player); void OLD_CheckRescueZone(CBasePlayer *pPlayer);
void BuyZoneIcon_Set(CBasePlayer *player); void BuyZoneIcon_Set(CBasePlayer *pPlayer);
void BuyZoneIcon_Clear(CBasePlayer *player); void BuyZoneIcon_Clear(CBasePlayer *pPlayer);
void BombTargetFlash_Set(CBasePlayer *player); void BombTargetFlash_Set(CBasePlayer *pPlayer);
void BombTargetFlash_Clear(CBasePlayer *player); void BombTargetFlash_Clear(CBasePlayer *pPlayer);
void RescueZoneIcon_Set(CBasePlayer *player); void RescueZoneIcon_Set(CBasePlayer *pPlayer);
void RescueZoneIcon_Clear(CBasePlayer *player); void RescueZoneIcon_Clear(CBasePlayer *pPlayer);
void EscapeZoneIcon_Set(CBasePlayer *player); void EscapeZoneIcon_Set(CBasePlayer *pPlayer);
void EscapeZoneIcon_Clear(CBasePlayer *player); void EscapeZoneIcon_Clear(CBasePlayer *pPlayer);
void EscapeZoneIcon_Set(CBasePlayer *player); void EscapeZoneIcon_Set(CBasePlayer *pPlayer);
void EscapeZoneIcon_Clear(CBasePlayer *player); void EscapeZoneIcon_Clear(CBasePlayer *pPlayer);
void VIP_SafetyZoneIcon_Set(CBasePlayer *player); void VIP_SafetyZoneIcon_Set(CBasePlayer *pPlayer);
void VIP_SafetyZoneIcon_Clear(CBasePlayer *player); void VIP_SafetyZoneIcon_Clear(CBasePlayer *pPlayer);
void SendItemStatus(CBasePlayer *pPlayer); void SendItemStatus(CBasePlayer *pPlayer);
const char *GetCSModelName(int item_id); const char *GetCSModelName(int item_id);
@ -941,12 +943,12 @@ Vector VecVelocityForDamage(float flDamage);
int TrainSpeed(int iSpeed, int iMax); int TrainSpeed(int iSpeed, int iMax);
const char *GetWeaponName(entvars_t *pevInflictor, entvars_t *pKiller); const char *GetWeaponName(entvars_t *pevInflictor, entvars_t *pKiller);
void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name); void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name);
bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity); bool CanSeeUseable(CBasePlayer *me, CBaseEntity *pEntity);
void FixPlayerCrouchStuck(edict_t *pPlayer); void FixPlayerCrouchStuck(edict_t *pPlayer);
BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot); BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot);
CBaseEntity *FindEntityForward(CBaseEntity *pMe); CBaseEntity *FindEntityForward(CBaseEntity *pMe);
float_precision GetPlayerPitch(const edict_t *pEdict); real_t GetPlayerPitch(const edict_t *pEdict);
float_precision GetPlayerYaw(const edict_t *pEdict); real_t GetPlayerYaw(const edict_t *pEdict);
int GetPlayerGaitsequence(const edict_t *pEdict); int GetPlayerGaitsequence(const edict_t *pEdict);
const char *GetBuyStringForWeaponClass(int weaponClass); const char *GetBuyStringForWeaponClass(int weaponClass);
bool IsPrimaryWeaponClass(int classId); bool IsPrimaryWeaponClass(int classId);

View File

@ -872,7 +872,7 @@ BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange)
Vector vecSpot1 = pev->origin + pev->view_ofs; Vector vecSpot1 = pev->origin + pev->view_ofs;
Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs; Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs;
Vector vecRange; Vector vecRange;
float_precision flRange; real_t flRange;
TraceResult tr; TraceResult tr;
UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr);
@ -1017,11 +1017,11 @@ void USENTENCEG_InitLRU(unsigned char *plru, int count)
if (count > MAX_SENTENCE_LRU) if (count > MAX_SENTENCE_LRU)
count = MAX_SENTENCE_LRU; count = MAX_SENTENCE_LRU;
for (i = 0; i < count; ++i) for (i = 0; i < count; i++)
plru[i] = (unsigned char)i; plru[i] = (unsigned char)i;
// randomize array // randomize array
for (i = 0; i < (count * 4); ++i) for (i = 0; i < (count * 4); i++)
{ {
j = RANDOM_LONG(0, count - 1); j = RANDOM_LONG(0, count - 1);
k = RANDOM_LONG(0, count - 1); k = RANDOM_LONG(0, count - 1);
@ -1103,7 +1103,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound)
while (!ffound) while (!ffound)
{ {
for (i = 0; i < count; ++i) for (i = 0; i < count; i++)
{ {
if (plru[i] != 0xFF) if (plru[i] != 0xFF)
{ {
@ -1594,7 +1594,7 @@ char TEXTURETYPE_Find(char *name)
{ {
// CONSIDER: pre-sort texture names and perform faster binary search here // CONSIDER: pre-sort texture names and perform faster binary search here
for (int i = 0; i < gcTextures; ++i) for (int i = 0; i < gcTextures; i++)
{ {
if (!Q_strnicmp(name, &(grgszTextureName[i][0]), MAX_TEXTURENAME_LENGHT - 1)) if (!Q_strnicmp(name, &(grgszTextureName[i][0]), MAX_TEXTURENAME_LENGHT - 1))
return (grgchTextureType[i]); return (grgchTextureType[i]);

View File

@ -200,7 +200,7 @@ void CSoundEnt::Initialize()
m_iActiveSound = SOUNDLIST_EMPTY; m_iActiveSound = SOUNDLIST_EMPTY;
// clear all sounds, and link them into the free sound list. // clear all sounds, and link them into the free sound list.
for (i = 0; i < MAX_WORLD_SOUNDS; ++i) for (i = 0; i < MAX_WORLD_SOUNDS; i++)
{ {
m_SoundPool[i].Clear(); m_SoundPool[i].Clear();
m_SoundPool[i].m_iNext = i + 1; m_SoundPool[i].m_iNext = i + 1;
@ -210,7 +210,7 @@ void CSoundEnt::Initialize()
m_SoundPool[i - 1].m_iNext = SOUNDLIST_EMPTY; m_SoundPool[i - 1].m_iNext = SOUNDLIST_EMPTY;
// now reserve enough sounds for each client // now reserve enough sounds for each client
for (i = 0; i < gpGlobals->maxClients; ++i) for (i = 0; i < gpGlobals->maxClients; i++)
{ {
iSound = pSoundEnt->IAllocSound(); iSound = pSoundEnt->IAllocSound();

View File

@ -325,7 +325,7 @@ void CBaseToggle::LinearMove(Vector vecDest, float flSpeed)
Vector vecDestDelta = vecDest - pev->origin; Vector vecDestDelta = vecDest - pev->origin;
// divide vector length by speed to get time to reach dest // divide vector length by speed to get time to reach dest
float_precision flTravelTime = vecDestDelta.Length() / flSpeed; real_t flTravelTime = vecDestDelta.Length() / flSpeed;
// set nextthink to trigger a call to LinearMoveDone when dest is reached // set nextthink to trigger a call to LinearMoveDone when dest is reached
pev->nextthink = pev->ltime + flTravelTime; pev->nextthink = pev->ltime + flTravelTime;
@ -377,7 +377,7 @@ void CBaseToggle::AngularMove(Vector vecDestAngle, float flSpeed)
Vector vecDestDelta = vecDestAngle - pev->angles; Vector vecDestDelta = vecDestAngle - pev->angles;
// divide by speed to get time to reach dest // divide by speed to get time to reach dest
float_precision flTravelTime = vecDestDelta.Length() / flSpeed; real_t flTravelTime = vecDestDelta.Length() / flSpeed;
// set nextthink to trigger a call to AngularMoveDone when dest is reached // set nextthink to trigger a call to AngularMoveDone when dest is reached
pev->nextthink = pev->ltime + flTravelTime; pev->nextthink = pev->ltime + flTravelTime;

View File

@ -108,7 +108,7 @@ void CHalfLifeTraining::PlayerThink(CBasePlayer *pPlayer)
} }
CGrenade *pBomb = nullptr; CGrenade *pBomb = nullptr;
while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{ {
if (pBomb->m_pentCurBombTarget) if (pBomb->m_pentCurBombTarget)
pBomb->m_bStartDefuse = true; pBomb->m_bStartDefuse = true;
@ -231,7 +231,7 @@ void CHalfLifeTraining::CheckWinConditions()
{ {
CGrenade *pBomb = nullptr; CGrenade *pBomb = nullptr;
while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{ {
if (!pBomb->m_bIsC4 || !pBomb->m_bJustBlew) if (!pBomb->m_bIsC4 || !pBomb->m_bJustBlew)
continue; continue;
@ -246,7 +246,7 @@ void CHalfLifeTraining::CheckWinConditions()
{ {
CGrenade *pBomb = nullptr; CGrenade *pBomb = nullptr;
while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{ {
if (!pBomb->m_bIsC4 || !pBomb->m_bJustBlew) if (!pBomb->m_bIsC4 || !pBomb->m_bJustBlew)
continue; continue;

View File

@ -216,7 +216,7 @@ void CMultiManager::Spawn()
while (bSwapped) while (bSwapped)
{ {
bSwapped = false; bSwapped = false;
for (int i = 1; i < m_cTargets; ++i) for (int i = 1; i < m_cTargets; i++)
{ {
if (m_flTargetDelay[i] < m_flTargetDelay[i - 1]) if (m_flTargetDelay[i] < m_flTargetDelay[i - 1])
{ {
@ -239,7 +239,7 @@ void CMultiManager::Restart()
#ifndef REGAMEDLL_FIXES #ifndef REGAMEDLL_FIXES
edict_t *pentTarget = nullptr; edict_t *pentTarget = nullptr;
for (int i = 0; i < m_cTargets; ++i) for (int i = 0; i < m_cTargets; i++)
{ {
const char *name = STRING(m_iTargetName[i]); const char *name = STRING(m_iTargetName[i]);
@ -259,7 +259,7 @@ void CMultiManager::Restart()
} }
#endif #endif
SetThink(NULL); SetThink(nullptr);
if (IsClone()) if (IsClone())
{ {
@ -273,7 +273,7 @@ void CMultiManager::Restart()
BOOL CMultiManager::HasTarget(string_t targetname) BOOL CMultiManager::HasTarget(string_t targetname)
{ {
for (int i = 0; i < m_cTargets; ++i) for (int i = 0; i < m_cTargets; i++)
{ {
if (FStrEq(STRING(targetname), STRING(m_iTargetName[i]))) if (FStrEq(STRING(targetname), STRING(m_iTargetName[i])))
{ {
@ -300,7 +300,7 @@ void CMultiManager::ManagerThink()
// have we fired all targets? // have we fired all targets?
if (m_index >= m_cTargets) if (m_index >= m_cTargets)
{ {
SetThink(NULL); SetThink(nullptr);
if (IsClone()) if (IsClone())
{ {
UTIL_Remove(this); UTIL_Remove(this);
@ -311,8 +311,10 @@ void CMultiManager::ManagerThink()
SetUse(&CMultiManager::ManagerUse); SetUse(&CMultiManager::ManagerUse);
} }
else else
{
pev->nextthink = m_startTime + m_flTargetDelay[m_index]; pev->nextthink = m_startTime + m_flTargetDelay[m_index];
} }
}
CMultiManager *CMultiManager::Clone() CMultiManager *CMultiManager::Clone()
{ {
@ -354,7 +356,7 @@ void CMultiManager::ManagerUse(CBaseEntity *pActivator, CBaseEntity *pCaller, US
m_startTime = gpGlobals->time; m_startTime = gpGlobals->time;
// disable use until all targets have fired // disable use until all targets have fired
SetUse(NULL); SetUse(nullptr);
SetThink(&CMultiManager::ManagerThink); SetThink(&CMultiManager::ManagerThink);
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
@ -528,7 +530,7 @@ void CTriggerMonsterJump::Think()
// Unlink from trigger list // Unlink from trigger list
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
SetThink(NULL); SetThink(nullptr);
} }
void CTriggerMonsterJump::Touch(CBaseEntity *pOther) void CTriggerMonsterJump::Touch(CBaseEntity *pOther)
@ -651,7 +653,7 @@ void CTriggerCDAudio::PlayTrack(edict_t *pEdict)
{ {
PlayCDTrack(pEdict, int(pev->health)); PlayCDTrack(pEdict, int(pev->health));
SetTouch(NULL); SetTouch(nullptr);
UTIL_Remove(this); UTIL_Remove(this);
} }
@ -723,7 +725,7 @@ void CTriggerHurt::Spawn()
} }
else else
{ {
SetUse(NULL); SetUse(nullptr);
} }
if (m_bitsDamageInflict & DMG_RADIATION) if (m_bitsDamageInflict & DMG_RADIATION)
@ -764,7 +766,7 @@ void CTriggerHurt::RadiationThink()
{ {
edict_t *pentPlayer; edict_t *pentPlayer;
CBasePlayer *pPlayer = nullptr; CBasePlayer *pPlayer = nullptr;
float_precision flRange; real_t flRange;
entvars_t *pevTarget; entvars_t *pevTarget;
Vector vecSpot1; Vector vecSpot1;
Vector vecSpot2; Vector vecSpot2;
@ -855,7 +857,7 @@ void CBaseTrigger::HurtTouch(CBaseEntity *pOther)
return; return;
} }
// HACKHACK -- In multiplayer, players touch this based on packet receipt. // HACKHACK: In multiplayer, players touch this based on packet receipt.
// So the players who send packets later aren't always hurt. Keep track of // So the players who send packets later aren't always hurt. Keep track of
// how much time has passed and whether or not you've touched that player // how much time has passed and whether or not you've touched that player
if (g_pGameRules->IsMultiplayer()) if (g_pGameRules->IsMultiplayer())
@ -901,7 +903,7 @@ void CBaseTrigger::HurtTouch(CBaseEntity *pOther)
} }
else else
{ {
// Original code -- single player // Original code: single player
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (pev->dmgtime > gpGlobals->time && gpGlobals->time >= pev->pain_finished) if (pev->dmgtime > gpGlobals->time && gpGlobals->time >= pev->pain_finished)
#else #else
@ -1073,12 +1075,12 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator)
{ {
// we can't just remove (self) here, because this is a touch function // we can't just remove (self) here, because this is a touch function
// called while C code is looping through area links... // called while C code is looping through area links...
SetTouch(NULL); SetTouch(nullptr);
pev->nextthink = gpGlobals->time + 0.1f; pev->nextthink = gpGlobals->time + 0.1f;
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (!(pev->spawnflags & SF_TRIGGER_NORESET) && m_flWait == -2) if (!(pev->spawnflags & SF_TRIGGER_NORESET) && m_flWait == -2)
SetThink(NULL); SetThink(nullptr);
else else
#endif #endif
SetThink(&CBaseTrigger::SUB_Remove); SetThink(&CBaseTrigger::SUB_Remove);
@ -1088,7 +1090,7 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator)
// the wait time has passed, so set back up for another activation // the wait time has passed, so set back up for another activation
void CBaseTrigger::MultiWaitOver() void CBaseTrigger::MultiWaitOver()
{ {
SetThink(NULL); SetThink(nullptr);
} }
void CBaseTrigger::CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) void CBaseTrigger::CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
@ -1394,7 +1396,7 @@ int CChangeLevel::AddTransitionToList(LEVELLIST *pLevelList, int listCount, cons
return 0; return 0;
} }
for (i = 0; i < listCount; ++i) for (i = 0; i < listCount; i++)
{ {
if (pLevelList[i].pentLandmark == pentLandmark && Q_strcmp(pLevelList[i].mapName, pMapName) == 0) if (pLevelList[i].pentLandmark == pentLandmark && Q_strcmp(pLevelList[i].mapName, pMapName) == 0)
{ {
@ -1808,16 +1810,16 @@ void CBuyZone::BuyTouch(CBaseEntity *pOther)
if (!pOther->IsPlayer()) if (!pOther->IsPlayer())
return; return;
CBasePlayer *p = static_cast<CBasePlayer *>(pOther); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pOther);
if (pev->team == UNASSIGNED || pev->team == p->m_iTeam) if (pev->team == UNASSIGNED || pev->team == pPlayer->m_iTeam)
{ {
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (!CSGameRules()->CanPlayerBuy(p)) if (!CSGameRules()->CanPlayerBuy(pPlayer))
return; return;
#endif #endif
p->m_signals.Signal(SIGNAL_BUY); pPlayer->m_signals.Signal(SIGNAL_BUY);
} }
} }
@ -1836,12 +1838,12 @@ void CBombTarget::BombTargetTouch(CBaseEntity *pOther)
if (!pOther->IsPlayer()) if (!pOther->IsPlayer())
return; return;
CBasePlayer *p = static_cast<CBasePlayer *>(pOther); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pOther);
if (p->m_bHasC4) if (pPlayer->m_bHasC4)
{ {
p->m_signals.Signal(SIGNAL_BOMB); pPlayer->m_signals.Signal(SIGNAL_BOMB);
p->m_pentCurBombTarget = ENT(pev); pPlayer->m_pentCurBombTarget = ENT(pev);
} }
} }
@ -1884,26 +1886,27 @@ void CEscapeZone::EscapeTouch(CBaseEntity *pOther)
if (!pOther->IsPlayer()) if (!pOther->IsPlayer())
return; return;
CBasePlayer *p = static_cast<CBasePlayer *>(pOther); CBasePlayer *pEscapee = static_cast<CBasePlayer *>(pOther);
switch (p->m_iTeam) switch (pEscapee->m_iTeam)
{ {
case TERRORIST: case TERRORIST:
if (!p->m_bEscaped) if (!pEscapee->m_bEscaped)
{ {
p->m_bEscaped = true; pEscapee->m_bEscaped = true;
CSGameRules()->CheckWinConditions(); CSGameRules()->CheckWinConditions();
UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Terrorist_Escaped\"\n", STRING(p->pev->netname), GETPLAYERUSERID(p->edict()), GETPLAYERAUTHID(p->edict())); UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Terrorist_Escaped\"\n",
STRING(pEscapee->pev->netname), GETPLAYERUSERID(pEscapee->edict()), GETPLAYERAUTHID(pEscapee->edict()));
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer || FNullEnt(pPlayer->pev)) if (!pPlayer || FNullEnt(pPlayer->pev))
continue; continue;
if (pPlayer->m_iTeam == p->m_iTeam) if (pPlayer->m_iTeam == pEscapee->m_iTeam)
{ {
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Terrorist_Escaped"); ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Terrorist_Escaped");
} }
@ -1911,7 +1914,7 @@ void CEscapeZone::EscapeTouch(CBaseEntity *pOther)
} }
break; break;
case CT: case CT:
p->m_signals.Signal(SIGNAL_ESCAPE); pEscapee->m_signals.Signal(SIGNAL_ESCAPE);
break; break;
} }
} }
@ -1929,18 +1932,18 @@ void CVIP_SafetyZone::VIP_SafetyTouch(CBaseEntity *pOther)
if (!pOther->IsPlayer()) if (!pOther->IsPlayer())
return; return;
CBasePlayer *p = static_cast<CBasePlayer *>(pOther); CBasePlayer *pEscapee = static_cast<CBasePlayer *>(pOther);
p->m_signals.Signal(SIGNAL_VIPSAFETY); pEscapee->m_signals.Signal(SIGNAL_VIPSAFETY);
if (p->m_bIsVIP) if (pEscapee->m_bIsVIP)
{ {
UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Escaped_As_VIP\"\n", UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Escaped_As_VIP\"\n",
STRING(p->pev->netname), GETPLAYERUSERID(p->edict()), GETPLAYERAUTHID(p->edict())); STRING(pEscapee->pev->netname), GETPLAYERUSERID(pEscapee->edict()), GETPLAYERAUTHID(pEscapee->edict()));
p->m_bEscaped = true; pEscapee->m_bEscaped = true;
p->Disappear(); pEscapee->Disappear();
p->AddAccount(REWARD_VIP_HAVE_SELF_RESCUED, RT_VIP_RESCUED_MYSELF); pEscapee->AddAccount(REWARD_VIP_HAVE_SELF_RESCUED, RT_VIP_RESCUED_MYSELF);
} }
} }
@ -1967,7 +1970,7 @@ void CTriggerSave::SaveTouch(CBaseEntity *pOther)
if (!pOther->IsPlayer()) if (!pOther->IsPlayer())
return; return;
SetTouch(NULL); SetTouch(nullptr);
UTIL_Remove(this); UTIL_Remove(this);
SERVER_COMMAND("autosave\n"); SERVER_COMMAND("autosave\n");
} }
@ -1980,7 +1983,7 @@ void CTriggerEndSection::EndSectionUse(CBaseEntity *pActivator, CBaseEntity *pCa
if (pActivator && !pActivator->IsNetClient()) if (pActivator && !pActivator->IsNetClient())
return; return;
SetUse(NULL); SetUse(nullptr);
if (!FStringNull(pev->message)) if (!FStringNull(pev->message))
{ {
END_SECTION(STRING(pev->message)); END_SECTION(STRING(pev->message));
@ -2013,7 +2016,7 @@ void CTriggerEndSection::EndSectionTouch(CBaseEntity *pOther)
if (!pOther->IsNetClient()) if (!pOther->IsNetClient())
return; return;
SetTouch(NULL); SetTouch(nullptr);
if (!FStringNull(pev->message)) if (!FStringNull(pev->message))
{ {
END_SECTION(STRING(pev->message)); END_SECTION(STRING(pev->message));
@ -2295,8 +2298,8 @@ void CTriggerCamera::FollowTarget()
if (pev->angles.y < 0) if (pev->angles.y < 0)
pev->angles.y += 360; pev->angles.y += 360;
float_precision dx = vecGoal.x - pev->angles.x; real_t dx = vecGoal.x - pev->angles.x;
float_precision dy = vecGoal.y - pev->angles.y; real_t dy = vecGoal.y - pev->angles.y;
if (dx < -180) if (dx < -180)
dx += 360; dx += 360;
@ -2379,7 +2382,7 @@ void CTriggerCamera::Move()
pev->speed = UTIL_Approach(m_targetSpeed, pev->speed, m_acceleration * gpGlobals->frametime); pev->speed = UTIL_Approach(m_targetSpeed, pev->speed, m_acceleration * gpGlobals->frametime);
} }
float_precision fraction = 2 * gpGlobals->frametime; real_t fraction = 2 * gpGlobals->frametime;
pev->velocity = ((pev->movedir * pev->speed) * fraction) + (pev->velocity * (1 - fraction)); pev->velocity = ((pev->movedir * pev->speed) * fraction) + (pev->velocity * (1 - fraction));
} }

View File

@ -59,7 +59,7 @@ public:
CBaseTutorState(); CBaseTutorState();
virtual ~CBaseTutorState(); virtual ~CBaseTutorState();
virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther) = 0;
virtual const char *GetStateString() = 0; virtual const char *GetStateString() = 0;
public: public:
@ -76,7 +76,7 @@ public:
CBaseTutorStateSystem(); CBaseTutorStateSystem();
virtual ~CBaseTutorStateSystem(); virtual ~CBaseTutorStateSystem();
virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; virtual bool UpdateState(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther) = 0;
virtual const char *GetCurrentStateString() = 0; virtual const char *GetCurrentStateString() = 0;
virtual CBaseTutorState *ConstructNewState(TutorStateType stateType) = 0; virtual CBaseTutorState *ConstructNewState(TutorStateType stateType) = 0;

View File

@ -135,10 +135,10 @@ CBaseTutor::~CBaseTutor()
} }
} }
void CBaseTutor::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CBaseTutor::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CallEventHandler(event, entity, other); CallEventHandler(event, pEntity, pOther);
CheckForStateTransition(event, entity, other); CheckForStateTransition(event, pEntity, pOther);
} }
void CBaseTutor::ShotFired(Vector source, Vector target) void CBaseTutor::ShotFired(Vector source, Vector target)
@ -146,9 +146,9 @@ void CBaseTutor::ShotFired(Vector source, Vector target)
HandleShotFired(source, target); HandleShotFired(source, target);
} }
void CBaseTutor::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CBaseTutor::CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (m_stateSystem->UpdateState(event, entity, other)) if (m_stateSystem->UpdateState(event, pEntity, pOther))
{ {
DisplayNewStateDescriptionToPlayer(); DisplayNewStateDescriptionToPlayer();
} }
@ -159,7 +159,7 @@ void CBaseTutor::StartFrame(float time)
TutorThink(time); TutorThink(time);
} }
void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char *szMessage, TutorMessageEvent *event) void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *pPlayer, int id, const char *szMessage, TutorMessageEvent *event)
{ {
TutorMessage *definition; TutorMessage *definition;
int numArgs; int numArgs;
@ -168,7 +168,7 @@ void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char
numArgs = event->GetNumParameters(); numArgs = event->GetNumParameters();
definition = GetTutorMessageDefinition(event->GetID()); definition = GetTutorMessageDefinition(event->GetID());
MESSAGE_BEGIN(MSG_ONE, gmsgTutorText, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgTutorText, nullptr, pPlayer->pev);
WRITE_STRING(szMessage); WRITE_STRING(szMessage);
WRITE_BYTE(numArgs); WRITE_BYTE(numArgs);
@ -182,7 +182,7 @@ void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char
} }
WRITE_SHORT(id); WRITE_SHORT(id);
WRITE_SHORT(player->IsAlive() == FALSE); WRITE_SHORT(pPlayer->IsAlive() == FALSE);
if (definition) if (definition)
WRITE_SHORT(definition->m_type); WRITE_SHORT(definition->m_type);
@ -199,13 +199,13 @@ void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char
switch (definition->m_type) switch (definition->m_type)
{ {
case TUTORMESSAGETYPE_FRIEND_DEATH: case TUTORMESSAGETYPE_FRIEND_DEATH:
EMIT_SOUND_DYN(ENT(player->pev), CHAN_ITEM, "events/friend_died.wav", VOL_NORM, ATTN_NORM, 0, 120); EMIT_SOUND_DYN(ENT(pPlayer->pev), CHAN_ITEM, "events/friend_died.wav", VOL_NORM, ATTN_NORM, 0, 120);
break; break;
case TUTORMESSAGETYPE_ENEMY_DEATH: case TUTORMESSAGETYPE_ENEMY_DEATH:
EMIT_SOUND_DYN(ENT(player->pev), CHAN_ITEM, "events/enemy_died.wav", VOL_NORM, ATTN_NORM, 0, 85); EMIT_SOUND_DYN(ENT(pPlayer->pev), CHAN_ITEM, "events/enemy_died.wav", VOL_NORM, ATTN_NORM, 0, 85);
break; break;
default: default:
EMIT_SOUND_DYN(ENT(player->pev), CHAN_ITEM, "events/tutor_msg.wav", VOL_NORM, ATTN_NORM, 0, 100); EMIT_SOUND_DYN(ENT(pPlayer->pev), CHAN_ITEM, "events/tutor_msg.wav", VOL_NORM, ATTN_NORM, 0, 100);
break; break;
} }
} }
@ -217,9 +217,9 @@ void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char
} }
} }
NOXREF void CBaseTutor::DrawLineToEntity(CBasePlayer *player, int entindex, int id) NOXREF void CBaseTutor::DrawLineToEntity(CBasePlayer *pPlayer, int entindex, int id)
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgTutorLine, nullptr, player->pev); MESSAGE_BEGIN(MSG_ONE, gmsgTutorLine, nullptr, pPlayer->pev);
WRITE_SHORT(entindex); WRITE_SHORT(entindex);
WRITE_SHORT(id); WRITE_SHORT(id);
MESSAGE_END(); MESSAGE_END();
@ -254,25 +254,25 @@ void CBaseTutor::CloseCurrentWindow()
} }
} }
void CBaseTutor::CalculatePathForObjective(CBaseEntity *player) void CBaseTutor::CalculatePathForObjective(CBaseEntity *pPlayer)
{ {
; ;
} }
bool CBaseTutor::IsEntityInViewOfPlayer(CBaseEntity *entity, CBasePlayer *player) bool CBaseTutor::IsEntityInViewOfPlayer(CBaseEntity *pEntity, CBasePlayer *pPlayer)
{ {
if (!entity || !player) if (!pEntity || !pPlayer)
return false; return false;
if (cv_tutor_view_distance.value < (entity->pev->origin - player->pev->origin).Length()) if (cv_tutor_view_distance.value < (pEntity->pev->origin - pPlayer->pev->origin).Length())
return false; return false;
if (player->FInViewCone(entity)) if (pPlayer->FInViewCone(pEntity))
{ {
TraceResult result; TraceResult result;
Vector eye = player->pev->view_ofs + player->pev->origin; Vector eye = pPlayer->pev->view_ofs + pPlayer->pev->origin;
UTIL_TraceLine(eye, entity->pev->origin, ignore_monsters, ignore_glass, player->pev->pContainingEntity, &result); UTIL_TraceLine(eye, pEntity->pev->origin, ignore_monsters, ignore_glass, pPlayer->pev->pContainingEntity, &result);
if (result.flFraction == 1.0f) if (result.flFraction == 1.0f)
{ {
@ -283,20 +283,20 @@ bool CBaseTutor::IsEntityInViewOfPlayer(CBaseEntity *entity, CBasePlayer *player
return false; return false;
} }
bool CBaseTutor::IsPlayerLookingAtPosition(Vector *origin, CBasePlayer *player) bool CBaseTutor::IsPlayerLookingAtPosition(Vector *origin, CBasePlayer *pPlayer)
{ {
if (!origin || !player) if (!origin || !pPlayer)
return false; return false;
if (cv_tutor_look_distance.value < (*origin - player->pev->origin).Length()) if (cv_tutor_look_distance.value < (*origin - pPlayer->pev->origin).Length())
return false; return false;
if (player->IsLookingAtPosition(origin, cv_tutor_look_angle.value)) if (pPlayer->IsLookingAtPosition(origin, cv_tutor_look_angle.value))
{ {
TraceResult result; TraceResult result;
Vector eye = player->pev->origin + player->pev->view_ofs; Vector eye = pPlayer->pev->origin + pPlayer->pev->view_ofs;
UTIL_TraceLine(eye, *origin, ignore_monsters, ignore_glass, ENT(player->pev), &result); UTIL_TraceLine(eye, *origin, ignore_monsters, ignore_glass, ENT(pPlayer->pev), &result);
if (result.flFraction == 1.0f) if (result.flFraction == 1.0f)
return true; return true;
@ -305,22 +305,22 @@ bool CBaseTutor::IsPlayerLookingAtPosition(Vector *origin, CBasePlayer *player)
return false; return false;
} }
bool CBaseTutor::IsPlayerLookingAtEntity(CBaseEntity *entity, CBasePlayer *player) bool CBaseTutor::IsPlayerLookingAtEntity(CBaseEntity *pEntity, CBasePlayer *pPlayer)
{ {
if (!entity || !player) if (!pEntity || !pPlayer)
return false; return false;
UTIL_MakeVectors(player->pev->v_angle); UTIL_MakeVectors(pPlayer->pev->v_angle);
Vector srcVec = player->pev->view_ofs + player->pev->origin; Vector srcVec = pPlayer->pev->view_ofs + pPlayer->pev->origin;
Vector destVec = gpGlobals->v_forward * cv_tutor_look_distance.value + srcVec; Vector destVec = gpGlobals->v_forward * cv_tutor_look_distance.value + srcVec;
TraceResult result; TraceResult result;
UTIL_TraceLine(srcVec, destVec, dont_ignore_monsters, ignore_glass, ENT(player->pev), &result); UTIL_TraceLine(srcVec, destVec, dont_ignore_monsters, ignore_glass, ENT(pPlayer->pev), &result);
if (result.pHit) if (result.pHit)
{ {
if (!FNullEnt(result.pHit) && CBaseEntity::Instance(result.pHit) == entity) if (!FNullEnt(result.pHit) && CBaseEntity::Instance(result.pHit) == pEntity)
{ {
return true; return true;
} }
@ -329,22 +329,21 @@ bool CBaseTutor::IsPlayerLookingAtEntity(CBaseEntity *entity, CBasePlayer *playe
return false; return false;
} }
bool CBaseTutor::IsBombsiteInViewOfPlayer(CBaseEntity *entity, CBasePlayer *player) bool CBaseTutor::IsBombsiteInViewOfPlayer(CBaseEntity *pEntity, CBasePlayer *pPlayer)
{ {
if (!entity || !player) if (!pEntity || !pPlayer)
return false; return false;
Vector bombSiteCenter = (entity->pev->absmax + entity->pev->absmin) * 0.5f; Vector bombSiteCenter = pEntity->Center();
if (cv_tutor_view_distance.value < (bombSiteCenter - pPlayer->pev->origin).Length())
if (cv_tutor_view_distance.value < (bombSiteCenter - player->pev->origin).Length())
return false; return false;
if (player->FInViewCone(entity)) if (pPlayer->FInViewCone(pEntity))
{ {
TraceResult result; TraceResult result;
Vector eye = player->pev->origin + player->pev->view_ofs; Vector eye = pPlayer->pev->origin + pPlayer->pev->view_ofs;
UTIL_TraceLine(eye, bombSiteCenter, ignore_monsters, ignore_glass, ENT(player->pev), &result); UTIL_TraceLine(eye, bombSiteCenter, ignore_monsters, ignore_glass, ENT(pPlayer->pev), &result);
if (result.flFraction == 1.0f) if (result.flFraction == 1.0f)
{ {
@ -355,12 +354,12 @@ bool CBaseTutor::IsBombsiteInViewOfPlayer(CBaseEntity *entity, CBasePlayer *play
return false; return false;
} }
bool CBaseTutor::IsEntityInBombsite(CBaseEntity *bombsite, CBaseEntity *entity) bool CBaseTutor::IsEntityInBombsite(CBaseEntity *bombsite, CBaseEntity *pEntity)
{ {
if (!bombsite || !entity) if (!bombsite || !pEntity)
return false; return false;
return bombsite->Intersects(entity); return bombsite->Intersects(pEntity);
} }
bool CBaseTutor::DoMessagesHaveSameID(int id1, int id2) bool CBaseTutor::DoMessagesHaveSameID(int id1, int id2)

View File

@ -65,29 +65,29 @@ public:
virtual ~CBaseTutor(); virtual ~CBaseTutor();
virtual void TutorThink(float time) = 0; virtual void TutorThink(float time) = 0;
virtual void PurgeMessages() = 0; virtual void PurgeMessages() = 0;
virtual void CallEventHandler(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; virtual void CallEventHandler(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther) = 0;
virtual void ShowTutorMessage(TutorMessageEvent *event) = 0; virtual void ShowTutorMessage(TutorMessageEvent *event) = 0;
virtual bool IsEntityInViewOfPlayer(CBaseEntity *entity, CBasePlayer *player); virtual bool IsEntityInViewOfPlayer(CBaseEntity *pEntity, CBasePlayer *pPlayer);
virtual bool IsBombsiteInViewOfPlayer(CBaseEntity *entity, CBasePlayer *player); virtual bool IsBombsiteInViewOfPlayer(CBaseEntity *pEntity, CBasePlayer *pPlayer);
virtual bool IsEntityInBombsite(CBaseEntity *bombsite, CBaseEntity *entity); virtual bool IsEntityInBombsite(CBaseEntity *bombsite, CBaseEntity *pEntity);
virtual bool IsPlayerLookingAtPosition(Vector *origin, CBasePlayer *player); virtual bool IsPlayerLookingAtPosition(Vector *origin, CBasePlayer *pPlayer);
virtual bool IsPlayerLookingAtEntity(CBaseEntity *entity, CBasePlayer *player); virtual bool IsPlayerLookingAtEntity(CBaseEntity *pEntity, CBasePlayer *pPlayer);
virtual void HandleShotFired(Vector source, Vector target) = 0; virtual void HandleShotFired(Vector source, Vector target) = 0;
virtual struct TutorMessage *GetTutorMessageDefinition(int messageID) = 0; virtual struct TutorMessage *GetTutorMessageDefinition(int messageID) = 0;
public: public:
void StartFrame(float time); void StartFrame(float time);
void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); void OnEvent(GameEventType event, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr);
void ShotFired(Vector source, Vector target); void ShotFired(Vector source, Vector target);
void DisplayMessageToPlayer(CBasePlayer *player, int id, const char *szMessage, TutorMessageEvent *event); void DisplayMessageToPlayer(CBasePlayer *pPlayer, int id, const char *szMessage, TutorMessageEvent *event);
void DrawLineToEntity(CBasePlayer *player, int entindex, int id); void DrawLineToEntity(CBasePlayer *pPlayer, int entindex, int id);
void DisplayNewStateDescriptionToPlayer(); void DisplayNewStateDescriptionToPlayer();
void CloseCurrentWindow(); void CloseCurrentWindow();
void CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); void CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
void CalculatePathForObjective(CBaseEntity *player); void CalculatePathForObjective(CBaseEntity *pPlayer);
bool DoMessagesHaveSameID(int id1, int id2); bool DoMessagesHaveSameID(int id1, int id2);
protected: protected:

View File

@ -14,7 +14,7 @@ CCSTutorStateSystem::~CCSTutorStateSystem()
} }
} }
bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (!m_currentState) if (!m_currentState)
{ {
@ -23,7 +23,7 @@ bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *entity,
if (m_currentState) if (m_currentState)
{ {
TutorStateType nextStateType = m_currentState->CheckForStateTransition(event, entity, other); TutorStateType nextStateType = m_currentState->CheckForStateTransition(event, pEntity, pOther);
if (nextStateType != TUTORSTATE_UNDEFINED) if (nextStateType != TUTORSTATE_UNDEFINED)
{ {
delete m_currentState; delete m_currentState;
@ -67,22 +67,22 @@ CCSTutorUndefinedState::~CCSTutorUndefinedState()
; ;
} }
TutorStateType CCSTutorUndefinedState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorUndefinedState::CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (event == EVENT_PLAYER_SPAWNED) if (event == EVENT_PLAYER_SPAWNED)
{ {
return HandlePlayerSpawned(entity, other); return HandlePlayerSpawned(pEntity, pOther);
} }
return TUTORSTATE_UNDEFINED; return TUTORSTATE_UNDEFINED;
} }
TutorStateType CCSTutorUndefinedState::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorUndefinedState::HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer) if (pLocalPlayer)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{ {
return TUTORSTATE_WAITING_FOR_START; return TUTORSTATE_WAITING_FOR_START;
@ -107,14 +107,14 @@ CCSTutorWaitingForStartState::~CCSTutorWaitingForStartState()
; ;
} }
TutorStateType CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
switch (event) switch (event)
{ {
case EVENT_PLAYER_SPAWNED: case EVENT_PLAYER_SPAWNED:
return HandlePlayerSpawned(entity, other); return HandlePlayerSpawned(pEntity, pOther);
case EVENT_BUY_TIME_START: case EVENT_BUY_TIME_START:
return HandleBuyTimeStart(entity, other); return HandleBuyTimeStart(pEntity, pOther);
} }
return TUTORSTATE_UNDEFINED; return TUTORSTATE_UNDEFINED;
@ -132,12 +132,12 @@ const char *CCSTutorWaitingForStartState::GetStateString()
return m_TutorStateStrings[m_type]; return m_TutorStateStrings[m_type];
} }
TutorStateType CCSTutorWaitingForStartState::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorWaitingForStartState::HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer) if (pLocalPlayer)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{ {
return TUTORSTATE_WAITING_FOR_START; return TUTORSTATE_WAITING_FOR_START;
@ -147,7 +147,7 @@ TutorStateType CCSTutorWaitingForStartState::HandlePlayerSpawned(CBaseEntity *en
return TUTORSTATE_UNDEFINED; return TUTORSTATE_UNDEFINED;
} }
TutorStateType CCSTutorWaitingForStartState::HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorWaitingForStartState::HandleBuyTimeStart(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
return TUTORSTATE_BUYTIME; return TUTORSTATE_BUYTIME;
} }
@ -162,11 +162,11 @@ CCSTutorBuyMenuState::~CCSTutorBuyMenuState()
; ;
} }
TutorStateType CCSTutorBuyMenuState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorBuyMenuState::CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (event == EVENT_ROUND_START) if (event == EVENT_ROUND_START)
{ {
return HandleRoundStart(entity, other); return HandleRoundStart(pEntity, pOther);
} }
return TUTORSTATE_UNDEFINED; return TUTORSTATE_UNDEFINED;
@ -184,7 +184,7 @@ const char *CCSTutorBuyMenuState::GetStateString()
return m_TutorStateStrings[m_type]; return m_TutorStateStrings[m_type];
} }
TutorStateType CCSTutorBuyMenuState::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) TutorStateType CCSTutorBuyMenuState::HandleRoundStart(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
return TUTORSTATE_WAITING_FOR_START; return TUTORSTATE_WAITING_FOR_START;
} }

View File

@ -34,7 +34,7 @@ public:
CCSTutorStateSystem(); CCSTutorStateSystem();
virtual ~CCSTutorStateSystem(); virtual ~CCSTutorStateSystem();
virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other); virtual bool UpdateState(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
virtual const char *GetCurrentStateString(); virtual const char *GetCurrentStateString();
protected: protected:
@ -47,11 +47,11 @@ public:
CCSTutorUndefinedState(); CCSTutorUndefinedState();
virtual ~CCSTutorUndefinedState(); virtual ~CCSTutorUndefinedState();
virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
virtual const char *GetStateString(); virtual const char *GetStateString();
protected: protected:
TutorStateType HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); TutorStateType HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther);
}; };
class CCSTutorWaitingForStartState: public CBaseTutorState class CCSTutorWaitingForStartState: public CBaseTutorState
@ -60,12 +60,12 @@ public:
CCSTutorWaitingForStartState(); CCSTutorWaitingForStartState();
virtual ~CCSTutorWaitingForStartState(); virtual ~CCSTutorWaitingForStartState();
virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
virtual const char *GetStateString(); virtual const char *GetStateString();
protected: protected:
TutorStateType HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); TutorStateType HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther);
TutorStateType HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other); TutorStateType HandleBuyTimeStart(CBaseEntity *pEntity, CBaseEntity *pOther);
}; };
class CCSTutorBuyMenuState: public CBaseTutorState class CCSTutorBuyMenuState: public CBaseTutorState
@ -74,9 +74,9 @@ public:
CCSTutorBuyMenuState(); CCSTutorBuyMenuState();
virtual ~CCSTutorBuyMenuState(); virtual ~CCSTutorBuyMenuState();
virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
virtual const char *GetStateString(); virtual const char *GetStateString();
protected: protected:
TutorStateType HandleRoundStart(CBaseEntity *entity, CBaseEntity *other); TutorStateType HandleRoundStart(CBaseEntity *pEntity, CBaseEntity *pOther);
}; };

View File

@ -752,7 +752,7 @@ NOXREF void CCSTutor::LookupHotKey(TutorMessageID mid, int paramNum, wchar_t *bu
#endif #endif
} }
TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEntity *entity, CBaseEntity *other) TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
char enemyList[2048]; char enemyList[2048];
char teammateList[2048]; char teammateList[2048];
@ -892,9 +892,9 @@ void CCSTutor::AddToEventList(TutorMessageEvent *event)
} }
} }
void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *entity, CBaseEntity *other) void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
auto event = CreateTutorMessageEvent(mid, entity, other); auto event = CreateTutorMessageEvent(mid, pEntity, pOther);
if (event) if (event)
{ {
auto message = GetTutorMessageDefinition(mid); auto message = GetTutorMessageDefinition(mid);
@ -906,7 +906,7 @@ void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *entity,
m_lastScenarioEvent = nullptr; m_lastScenarioEvent = nullptr;
} }
m_lastScenarioEvent = CreateTutorMessageEvent(mid, entity, other); m_lastScenarioEvent = CreateTutorMessageEvent(mid, pEntity, pOther);
} }
AddToEventList(event); AddToEventList(event);
@ -1093,197 +1093,197 @@ void CCSTutor::ConstructMessageAndDisplay()
} }
} }
void CCSTutor::CallEventHandler(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CCSTutor::CallEventHandler(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
switch (event) switch (event)
{ {
case EVENT_WEAPON_FIRED: case EVENT_WEAPON_FIRED:
HandleWeaponFired(entity, other); HandleWeaponFired(pEntity, pOther);
break; break;
case EVENT_WEAPON_FIRED_ON_EMPTY: case EVENT_WEAPON_FIRED_ON_EMPTY:
HandleWeaponFiredOnEmpty(entity, other); HandleWeaponFiredOnEmpty(pEntity, pOther);
break; break;
case EVENT_WEAPON_RELOADED: case EVENT_WEAPON_RELOADED:
HandleWeaponReloaded(entity, other); HandleWeaponReloaded(pEntity, pOther);
break; break;
case EVENT_BEING_SHOT_AT: case EVENT_BEING_SHOT_AT:
HandleBeingShotAt(entity, other); HandleBeingShotAt(pEntity, pOther);
break; break;
case EVENT_PLAYER_BLINDED_BY_FLASHBANG: case EVENT_PLAYER_BLINDED_BY_FLASHBANG:
HandlePlayerBlindedByFlashbang(entity, other); HandlePlayerBlindedByFlashbang(pEntity, pOther);
break; break;
case EVENT_PLAYER_DIED: case EVENT_PLAYER_DIED:
HandlePlayerDied(entity, other); HandlePlayerDied(pEntity, pOther);
break; break;
case EVENT_PLAYER_TOOK_DAMAGE: case EVENT_PLAYER_TOOK_DAMAGE:
HandlePlayerTookDamage(entity, other); HandlePlayerTookDamage(pEntity, pOther);
break; break;
case EVENT_HOSTAGE_DAMAGED: case EVENT_HOSTAGE_DAMAGED:
HandleHostageDamaged(entity, other); HandleHostageDamaged(pEntity, pOther);
break; break;
case EVENT_HOSTAGE_KILLED: case EVENT_HOSTAGE_KILLED:
HandleHostageKilled(entity, other); HandleHostageKilled(pEntity, pOther);
break; break;
case EVENT_BOMB_PLANTED: case EVENT_BOMB_PLANTED:
HandleBombPlanted(entity, other); HandleBombPlanted(pEntity, pOther);
break; break;
case EVENT_BOMB_DEFUSING: case EVENT_BOMB_DEFUSING:
HandleBombDefusing(entity, other); HandleBombDefusing(pEntity, pOther);
break; break;
case EVENT_BOMB_DEFUSED: case EVENT_BOMB_DEFUSED:
HandleBombDefused(entity, other); HandleBombDefused(pEntity, pOther);
break; break;
case EVENT_BOMB_EXPLODED: case EVENT_BOMB_EXPLODED:
HandleBombExploded(entity, other); HandleBombExploded(pEntity, pOther);
break; break;
case EVENT_HOSTAGE_USED: case EVENT_HOSTAGE_USED:
HandleHostageUsed(entity, other); HandleHostageUsed(pEntity, pOther);
break; break;
case EVENT_HOSTAGE_RESCUED: case EVENT_HOSTAGE_RESCUED:
HandleHostageRescued(entity, other); HandleHostageRescued(pEntity, pOther);
break; break;
case EVENT_ALL_HOSTAGES_RESCUED: case EVENT_ALL_HOSTAGES_RESCUED:
HandleAllHostagesRescued(entity, other); HandleAllHostagesRescued(pEntity, pOther);
break; break;
case EVENT_TERRORISTS_WIN: case EVENT_TERRORISTS_WIN:
HandleTWin(entity, other); HandleTWin(pEntity, pOther);
break; break;
case EVENT_CTS_WIN: case EVENT_CTS_WIN:
HandleCTWin(entity, other); HandleCTWin(pEntity, pOther);
break; break;
case EVENT_ROUND_DRAW: case EVENT_ROUND_DRAW:
HandleRoundDraw(entity, other); HandleRoundDraw(pEntity, pOther);
break; break;
case EVENT_ROUND_START: case EVENT_ROUND_START:
HandleRoundStart(entity, other); HandleRoundStart(pEntity, pOther);
break; break;
case EVENT_PLAYER_SPAWNED: case EVENT_PLAYER_SPAWNED:
HandlePlayerSpawned(entity, other); HandlePlayerSpawned(pEntity, pOther);
break; break;
case EVENT_PLAYER_LEFT_BUY_ZONE: case EVENT_PLAYER_LEFT_BUY_ZONE:
HandlePlayerLeftBuyZone(entity, other); HandlePlayerLeftBuyZone(pEntity, pOther);
break; break;
case EVENT_DEATH_CAMERA_START: case EVENT_DEATH_CAMERA_START:
HandleDeathCameraStart(entity, other); HandleDeathCameraStart(pEntity, pOther);
break; break;
case EVENT_TUTOR_BUY_MENU_OPENNED: case EVENT_TUTOR_BUY_MENU_OPENNED:
HandleBuyMenuOpenned(entity, other); HandleBuyMenuOpenned(pEntity, pOther);
break; break;
case EVENT_TUTOR_AUTOBUY: case EVENT_TUTOR_AUTOBUY:
HandleAutoBuy(entity, other); HandleAutoBuy(pEntity, pOther);
break; break;
case EVENT_TUTOR_NOT_BUYING_ANYTHING: case EVENT_TUTOR_NOT_BUYING_ANYTHING:
HandleNotBuyingAnything(entity, other); HandleNotBuyingAnything(pEntity, pOther);
break; break;
case EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON: case EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON:
HandleNeedToBuyPrimaryWeapon(entity, other); HandleNeedToBuyPrimaryWeapon(pEntity, pOther);
break; break;
case EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO: case EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO:
HandleNeedToBuyPrimaryAmmo(entity, other); HandleNeedToBuyPrimaryAmmo(pEntity, pOther);
break; break;
case EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO: case EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO:
HandleNeedToBuySecondaryAmmo(entity, other); HandleNeedToBuySecondaryAmmo(pEntity, pOther);
break; break;
case EVENT_TUTOR_NEED_TO_BUY_ARMOR: case EVENT_TUTOR_NEED_TO_BUY_ARMOR:
HandleNeedToBuyArmor(entity, other); HandleNeedToBuyArmor(pEntity, pOther);
break; break;
case EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT: case EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT:
HandleNeedToBuyDefuseKit(entity, other); HandleNeedToBuyDefuseKit(pEntity, pOther);
break; break;
case EVENT_TUTOR_NEED_TO_BUY_GRENADE: case EVENT_TUTOR_NEED_TO_BUY_GRENADE:
HandleNeedToBuyGrenade(entity, other); HandleNeedToBuyGrenade(pEntity, pOther);
break; break;
case EVENT_CAREER_TASK_DONE: case EVENT_CAREER_TASK_DONE:
HandleCareerTaskDone(entity, other); HandleCareerTaskDone(pEntity, pOther);
break; break;
case EVENT_RADIO_COVER_ME: case EVENT_RADIO_COVER_ME:
HandleRadioCoverMe(entity, other); HandleRadioCoverMe(pEntity, pOther);
break; break;
case EVENT_RADIO_YOU_TAKE_THE_POINT: case EVENT_RADIO_YOU_TAKE_THE_POINT:
HandleRadioYouTakeThePoint(entity, other); HandleRadioYouTakeThePoint(pEntity, pOther);
break; break;
case EVENT_RADIO_HOLD_THIS_POSITION: case EVENT_RADIO_HOLD_THIS_POSITION:
HandleRadioHoldThisPosition(entity, other); HandleRadioHoldThisPosition(pEntity, pOther);
break; break;
case EVENT_RADIO_REGROUP_TEAM: case EVENT_RADIO_REGROUP_TEAM:
HandleRadioRegroupTeam(entity, other); HandleRadioRegroupTeam(pEntity, pOther);
break; break;
case EVENT_RADIO_FOLLOW_ME: case EVENT_RADIO_FOLLOW_ME:
HandleRadioFollowMe(entity, other); HandleRadioFollowMe(pEntity, pOther);
break; break;
case EVENT_RADIO_TAKING_FIRE: case EVENT_RADIO_TAKING_FIRE:
HandleRadioTakingFire(entity, other); HandleRadioTakingFire(pEntity, pOther);
break; break;
case EVENT_RADIO_GO_GO_GO: case EVENT_RADIO_GO_GO_GO:
HandleRadioGoGoGo(entity, other); HandleRadioGoGoGo(pEntity, pOther);
break; break;
case EVENT_RADIO_TEAM_FALL_BACK: case EVENT_RADIO_TEAM_FALL_BACK:
HandleRadioTeamFallBack(entity, other); HandleRadioTeamFallBack(pEntity, pOther);
break; break;
case EVENT_RADIO_STICK_TOGETHER_TEAM: case EVENT_RADIO_STICK_TOGETHER_TEAM:
HandleRadioStickTogetherTeam(entity, other); HandleRadioStickTogetherTeam(pEntity, pOther);
break; break;
case EVENT_RADIO_GET_IN_POSITION_AND_WAIT: case EVENT_RADIO_GET_IN_POSITION_AND_WAIT:
HandleRadioGetInPositionAndWait(entity, other); HandleRadioGetInPositionAndWait(pEntity, pOther);
break; break;
case EVENT_RADIO_STORM_THE_FRONT: case EVENT_RADIO_STORM_THE_FRONT:
HandleRadioStormTheFront(entity, other); HandleRadioStormTheFront(pEntity, pOther);
break; break;
case EVENT_RADIO_REPORT_IN_TEAM: case EVENT_RADIO_REPORT_IN_TEAM:
HandleRadioReportInTeam(entity, other); HandleRadioReportInTeam(pEntity, pOther);
break; break;
case EVENT_RADIO_AFFIRMATIVE: case EVENT_RADIO_AFFIRMATIVE:
HandleRadioAffirmative(entity, other); HandleRadioAffirmative(pEntity, pOther);
break; break;
case EVENT_RADIO_ENEMY_SPOTTED: case EVENT_RADIO_ENEMY_SPOTTED:
HandleRadioEnemySpotted(entity, other); HandleRadioEnemySpotted(pEntity, pOther);
break; break;
case EVENT_RADIO_NEED_BACKUP: case EVENT_RADIO_NEED_BACKUP:
HandleRadioNeedBackup(entity, other); HandleRadioNeedBackup(pEntity, pOther);
break; break;
case EVENT_RADIO_SECTOR_CLEAR: case EVENT_RADIO_SECTOR_CLEAR:
HandleRadioSectorClear(entity, other); HandleRadioSectorClear(pEntity, pOther);
break; break;
case EVENT_RADIO_IN_POSITION: case EVENT_RADIO_IN_POSITION:
HandleRadioInPosition(entity, other); HandleRadioInPosition(pEntity, pOther);
break; break;
case EVENT_RADIO_REPORTING_IN: case EVENT_RADIO_REPORTING_IN:
HandleRadioReportingIn(entity, other); HandleRadioReportingIn(pEntity, pOther);
break; break;
case EVENT_RADIO_GET_OUT_OF_THERE: case EVENT_RADIO_GET_OUT_OF_THERE:
HandleRadioGetOutOfThere(entity, other); HandleRadioGetOutOfThere(pEntity, pOther);
break; break;
case EVENT_RADIO_NEGATIVE: case EVENT_RADIO_NEGATIVE:
HandleRadioNegative(entity, other); HandleRadioNegative(pEntity, pOther);
break; break;
case EVENT_RADIO_ENEMY_DOWN: case EVENT_RADIO_ENEMY_DOWN:
HandleRadioEnemyDown(entity, other); HandleRadioEnemyDown(pEntity, pOther);
break; break;
default: default:
break; break;
} }
} }
void CCSTutor::HandleWeaponFired(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleWeaponFired(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer || !pLocalPlayer->IsAlive()) if (!pLocalPlayer || !pLocalPlayer->IsAlive())
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer == pLocalPlayer) if (pPlayer && pPlayer == pLocalPlayer)
{ {
CheckForNeedToReload(); CheckForNeedToReload();
} }
} }
void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{ {
CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(pPlayer->m_pActiveItem); CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(pPlayer->m_pActiveItem);
@ -1300,23 +1300,23 @@ void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleWeaponReloaded(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleWeaponReloaded(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == UTIL_GetLocalPlayer()) if (pPlayer && pPlayer->IsPlayer() && pPlayer == UTIL_GetLocalPlayer())
{ {
CancelEvent(YOU_SHOULD_RELOAD); CancelEvent(YOU_SHOULD_RELOAD);
} }
} }
void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerDied(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pVictim = static_cast<CBasePlayer *>(entity); CBasePlayer *pVictim = static_cast<CBasePlayer *>(pEntity);
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(other); CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (pVictim && !pVictim->IsPlayer()) if (pVictim && !pVictim->IsPlayer())
{ {
@ -1332,7 +1332,7 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
if (pLocalPlayer->m_bKilledByBomb) if (pLocalPlayer->m_bKilledByBomb)
{ {
CreateAndAddEventToList(YOU_DIED, entity, other); CreateAndAddEventToList(YOU_DIED, pEntity, pOther);
} }
else else
{ {
@ -1345,7 +1345,7 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
if (pVictim == pAttacker && pVictim == pLocalPlayer) if (pVictim == pAttacker && pVictim == pLocalPlayer)
{ {
CreateAndAddEventToList(YOU_DIED, entity, other); CreateAndAddEventToList(YOU_DIED, pEntity, pOther);
return; return;
} }
@ -1356,7 +1356,7 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
if (pVictim->m_iTeam == pAttacker->m_iTeam) if (pVictim->m_iTeam == pAttacker->m_iTeam)
{ {
CreateAndAddEventToList(YOU_KILLED_A_TEAMMATE, entity, other); CreateAndAddEventToList(YOU_KILLED_A_TEAMMATE, pEntity, pOther);
return; return;
} }
@ -1368,9 +1368,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
switch (numT) switch (numT)
{ {
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, pEntity, pOther); break;
} }
break; break;
} }
@ -1378,9 +1378,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
switch (numCT) switch (numCT)
{ {
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, pEntity, pOther); break;
} }
break; break;
} }
@ -1394,9 +1394,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
switch (numT) switch (numT)
{ {
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; default: CreateAndAddEventToList(YOU_KILLED_PLAYER, pEntity, pOther); break;
} }
break; break;
} }
@ -1404,9 +1404,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
switch (numCT) switch (numCT)
{ {
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; default: CreateAndAddEventToList(YOU_KILLED_PLAYER, pEntity, pOther); break;
} }
break; break;
} }
@ -1415,7 +1415,7 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
} }
else if (pVictim == pLocalPlayer) else if (pVictim == pLocalPlayer)
{ {
CreateAndAddEventToList(pVictim->m_bHeadshotKilled ? YOU_DIED_HEADSHOT : YOU_DIED, entity, other); CreateAndAddEventToList(pVictim->m_bHeadshotKilled ? YOU_DIED_HEADSHOT : YOU_DIED, pEntity, pOther);
} }
else if (pVictim->m_iTeam == pLocalPlayer->m_iTeam) else if (pVictim->m_iTeam == pLocalPlayer->m_iTeam)
{ {
@ -1427,26 +1427,26 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
if (numCT == 1) if (numCT == 1)
{ {
CreateAndAddEventToList(LAST_TEAMMATE_KILLED, entity, other); CreateAndAddEventToList(LAST_TEAMMATE_KILLED, pEntity, pOther);
} }
else if (numCT == 2) else if (numCT == 2)
{ {
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
} }
else else
{ {
CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
} }
} }
else else
{ {
if (numCT == 1) if (numCT == 1)
{ {
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
} }
else if (numCT > 1) else if (numCT > 1)
{ {
CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
} }
} }
break; break;
@ -1457,26 +1457,26 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
if (numT == 1) if (numT == 1)
{ {
CreateAndAddEventToList(LAST_TEAMMATE_KILLED, entity, other); CreateAndAddEventToList(LAST_TEAMMATE_KILLED, pEntity, pOther);
} }
else if (numT == 2) else if (numT == 2)
{ {
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
} }
else else
{ {
CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
} }
} }
else else
{ {
if (numT == 1) if (numT == 1)
{ {
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
} }
else if (numT > 1) else if (numT > 1)
{ {
CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
} }
} }
break; break;
@ -1491,9 +1491,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
switch (numT) switch (numT)
{ {
case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, pEntity, pOther); break;
case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; default: CreateAndAddEventToList(ENEMY_KILLED, pEntity, pOther); break;
} }
break; break;
} }
@ -1501,9 +1501,9 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
{ {
switch (numCT) switch (numCT)
{ {
case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, pEntity, pOther); break;
case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; default: CreateAndAddEventToList(ENEMY_KILLED, pEntity, pOther); break;
} }
break; break;
} }
@ -1511,14 +1511,14 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandlePlayerTookDamage(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerTookDamage(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pVictim = static_cast<CBasePlayer *>(entity); CBasePlayer *pVictim = static_cast<CBasePlayer *>(pEntity);
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(other); CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (pVictim && !pVictim->IsPlayer()) if (pVictim && !pVictim->IsPlayer())
{ {
@ -1540,33 +1540,33 @@ void CCSTutor::HandlePlayerTookDamage(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandlePlayerBlindedByFlashbang(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerBlindedByFlashbang(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{ {
CreateAndAddEventToList(YOU_ARE_BLIND_FROM_FLASHBANG); CreateAndAddEventToList(YOU_ARE_BLIND_FROM_FLASHBANG);
} }
} }
void CCSTutor::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (!pPlayer || !pPlayer->IsPlayer() || pPlayer != UTIL_GetLocalPlayer()) if (!pPlayer || !pPlayer->IsPlayer() || pPlayer != UTIL_GetLocalPlayer())
return; return;
m_haveSpawned = true; m_haveSpawned = true;
m_lastInGameHintShown = INGAME_HINT_BEGIN; m_lastInGameHintShown = INGAME_HINT_BEGIN;
CreateAndAddEventToList(YOU_SPAWNED, entity, other); CreateAndAddEventToList(YOU_SPAWNED, pEntity, pOther);
} }
NOXREF void CCSTutor::HandleClientCorpseSpawned(CBaseEntity *entity, CBaseEntity *other) NOXREF void CCSTutor::HandleClientCorpseSpawned(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (!pPlayer || !pPlayer->IsPlayer()) if (!pPlayer || !pPlayer->IsPlayer())
return; return;
@ -1578,7 +1578,7 @@ NOXREF void CCSTutor::HandleClientCorpseSpawned(CBaseEntity *entity, CBaseEntity
m_clientCorpseList.push_back(corpse); m_clientCorpseList.push_back(corpse);
} }
void CCSTutor::HandleBuyMenuOpenned(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBuyMenuOpenned(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (m_currentlyShownMessageID == BUY_TIME_BEGIN) if (m_currentlyShownMessageID == BUY_TIME_BEGIN)
{ {
@ -1587,7 +1587,7 @@ void CCSTutor::HandleBuyMenuOpenned(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleAutoBuy(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleAutoBuy(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (m_currentlyShownMessageID == BUY_TIME_BEGIN) if (m_currentlyShownMessageID == BUY_TIME_BEGIN)
{ {
@ -1595,12 +1595,12 @@ void CCSTutor::HandleAutoBuy(CBaseEntity *entity, CBaseEntity *other)
} }
} }
NOXREF void CCSTutor::HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other) NOXREF void CCSTutor::HandleBuyTimeStart(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
; ;
} }
void CCSTutor::HandlePlayerLeftBuyZone(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerLeftBuyZone(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
m_messageTypeMask = (TUTORMESSAGETYPE_DEFAULT | TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_SCENARIO | TUTORMESSAGETYPE_CAREER | TUTORMESSAGETYPE_INGAME_HINT | TUTORMESSAGETYPE_END_GAME); m_messageTypeMask = (TUTORMESSAGETYPE_DEFAULT | TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_SCENARIO | TUTORMESSAGETYPE_CAREER | TUTORMESSAGETYPE_INGAME_HINT | TUTORMESSAGETYPE_END_GAME);
@ -1615,7 +1615,7 @@ void CCSTutor::HandlePlayerLeftBuyZone(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleBombPlanted(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBombPlanted(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
@ -1623,21 +1623,21 @@ void CCSTutor::HandleBombPlanted(CBaseEntity *entity, CBaseEntity *other)
if (pLocalPlayer->IsAlive() && pLocalPlayer->m_iTeam == CT) if (pLocalPlayer->IsAlive() && pLocalPlayer->m_iTeam == CT)
{ {
CreateAndAddEventToList(BOMB_PLANTED_CT, entity, other); CreateAndAddEventToList(BOMB_PLANTED_CT, pEntity, pOther);
} }
else else
{ {
CreateAndAddEventToList(BOMB_PLANTED_T, entity, other); CreateAndAddEventToList(BOMB_PLANTED_T, pEntity, pOther);
} }
} }
void CCSTutor::HandleBombDefused(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBombDefused(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pDefuser = static_cast<CBasePlayer *>(entity); CBasePlayer *pDefuser = static_cast<CBasePlayer *>(pEntity);
if (pDefuser && pDefuser->IsPlayer() && pDefuser == pLocalPlayer) if (pDefuser && pDefuser->IsPlayer() && pDefuser == pLocalPlayer)
{ {
CreateAndAddEventToList(YOU_DEFUSED_BOMB); CreateAndAddEventToList(YOU_DEFUSED_BOMB);
@ -1652,20 +1652,20 @@ void CCSTutor::HandleBombDefused(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleBombDefusing(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBombDefusing(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && !pPlayer->m_bHasDefuser) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && !pPlayer->m_bHasDefuser)
{ {
CreateAndAddEventToList(DEFUSING_WITHOUT_KIT); CreateAndAddEventToList(DEFUSING_WITHOUT_KIT);
} }
} }
void CCSTutor::HandleBombExploded(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBombExploded(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
@ -1679,7 +1679,7 @@ void CCSTutor::HandleBombExploded(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRoundStart(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
@ -1697,7 +1697,7 @@ void CCSTutor::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other)
case TERRORIST: case TERRORIST:
{ {
if (pLocalPlayer->m_bHasC4) if (pLocalPlayer->m_bHasC4)
CreateAndAddEventToList(YOU_ARE_BOMB_CARRIER, entity, other); CreateAndAddEventToList(YOU_ARE_BOMB_CARRIER, pEntity, pOther);
else else
CreateAndAddEventToList(ROUND_START_DE_T); CreateAndAddEventToList(ROUND_START_DE_T);
break; break;
@ -1714,26 +1714,26 @@ void CCSTutor::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleBeingShotAt(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBeingShotAt(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && pLocalPlayer->IsAlive()) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && pLocalPlayer->IsAlive())
{ {
CreateAndAddEventToList(YOU_HAVE_BEEN_SHOT_AT, entity, other); CreateAndAddEventToList(YOU_HAVE_BEEN_SHOT_AT, pEntity, pOther);
} }
} }
void CCSTutor::HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageUsed(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pActivator = static_cast<CBasePlayer *>(entity); CBasePlayer *pActivator = static_cast<CBasePlayer *>(pEntity);
if (pActivator && pActivator->IsPlayer()) if (pActivator && pActivator->IsPlayer())
{ {
bool unusedHostages = !CheckForAllHostagesFollowingSomeone(); bool unusedHostages = !CheckForAllHostagesFollowingSomeone();
@ -1752,13 +1752,13 @@ void CCSTutor::HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleHostageRescued(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageRescued(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pRescuer = static_cast<CBasePlayer *>(entity); CBasePlayer *pRescuer = static_cast<CBasePlayer *>(pEntity);
if (pRescuer && pRescuer->IsPlayer()) if (pRescuer && pRescuer->IsPlayer())
{ {
switch (pLocalPlayer->m_iTeam) switch (pLocalPlayer->m_iTeam)
@ -1769,7 +1769,7 @@ void CCSTutor::HandleHostageRescued(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleAllHostagesRescued(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleAllHostagesRescued(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
@ -1782,20 +1782,20 @@ void CCSTutor::HandleAllHostagesRescued(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleHostageDamaged(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageDamaged(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(other); CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (entity && pAttacker && pAttacker->IsPlayer() && pLocalPlayer == pAttacker) if (pEntity && pAttacker && pAttacker->IsPlayer() && pLocalPlayer == pAttacker)
{ {
CreateAndAddEventToList(YOU_DAMAGED_HOSTAGE); CreateAndAddEventToList(YOU_DAMAGED_HOSTAGE);
} }
} }
void CCSTutor::HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageKilled(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
@ -1803,8 +1803,8 @@ void CCSTutor::HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other)
CheckForAllHostagesDead(); CheckForAllHostagesDead();
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(other); CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (entity && pAttacker && pAttacker->IsPlayer()) if (pEntity && pAttacker && pAttacker->IsPlayer())
{ {
bool unusedHostages = CheckForAllHostagesFollowingSomeone(); bool unusedHostages = CheckForAllHostagesFollowingSomeone();
if (pLocalPlayer == pAttacker) if (pLocalPlayer == pAttacker)
@ -1823,7 +1823,7 @@ void CCSTutor::HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleRoundDraw(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRoundDraw(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
if (CSGameRules()->m_iTotalRoundsPlayed) if (CSGameRules()->m_iTotalRoundsPlayed)
{ {
@ -1833,25 +1833,25 @@ void CCSTutor::HandleRoundDraw(CBaseEntity *entity, CBaseEntity *other)
ResetPlayerDeathInfo(); ResetPlayerDeathInfo();
} }
void CCSTutor::HandleCTWin(CBaseEntity *entith, CBaseEntity *other) void CCSTutor::HandleCTWin(CBaseEntity *entith, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(CT_WIN); CreateAndAddEventToList(CT_WIN);
ResetPlayerDeathInfo(); ResetPlayerDeathInfo();
} }
void CCSTutor::HandleTWin(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleTWin(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(T_WIN); CreateAndAddEventToList(T_WIN);
ResetPlayerDeathInfo(); ResetPlayerDeathInfo();
} }
void CCSTutor::HandleDeathCameraStart(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleDeathCameraStart(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer) if (!pLocalPlayer)
return; return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{ {
m_messageTypeMask = (TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_HINT | TUTORMESSAGETYPE_END_GAME); m_messageTypeMask = (TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_HINT | TUTORMESSAGETYPE_END_GAME);
@ -1859,147 +1859,147 @@ void CCSTutor::HandleDeathCameraStart(CBaseEntity *entity, CBaseEntity *other)
} }
} }
void CCSTutor::HandleRadioCoverMe(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioCoverMe(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_COVER_ME, entity, other); CreateAndAddEventToList(RADIO_COVER_ME, pEntity, pOther);
} }
void CCSTutor::HandleRadioYouTakeThePoint(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioYouTakeThePoint(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_YOU_TAKE_THE_POINT, entity, other); CreateAndAddEventToList(RADIO_YOU_TAKE_THE_POINT, pEntity, pOther);
} }
void CCSTutor::HandleRadioHoldThisPosition(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioHoldThisPosition(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_HOLD_THIS_POSITION, entity, other); CreateAndAddEventToList(RADIO_HOLD_THIS_POSITION, pEntity, pOther);
} }
void CCSTutor::HandleRadioRegroupTeam(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioRegroupTeam(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_REGROUP_TEAM, entity, other); CreateAndAddEventToList(RADIO_REGROUP_TEAM, pEntity, pOther);
} }
void CCSTutor::HandleRadioFollowMe(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioFollowMe(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_FOLLOW_ME, entity, other); CreateAndAddEventToList(RADIO_FOLLOW_ME, pEntity, pOther);
} }
void CCSTutor::HandleRadioTakingFire(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioTakingFire(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_TAKING_FIRE, entity, other); CreateAndAddEventToList(RADIO_TAKING_FIRE, pEntity, pOther);
} }
void CCSTutor::HandleRadioGoGoGo(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioGoGoGo(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_GO_GO_GO, entity, other); CreateAndAddEventToList(RADIO_GO_GO_GO, pEntity, pOther);
} }
void CCSTutor::HandleRadioTeamFallBack(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioTeamFallBack(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_TEAM_FALL_BACK, entity, other); CreateAndAddEventToList(RADIO_TEAM_FALL_BACK, pEntity, pOther);
} }
void CCSTutor::HandleRadioStickTogetherTeam(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioStickTogetherTeam(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_STICK_TOGETHER_TEAM, entity, other); CreateAndAddEventToList(RADIO_STICK_TOGETHER_TEAM, pEntity, pOther);
} }
void CCSTutor::HandleRadioGetInPositionAndWait(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioGetInPositionAndWait(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_GET_IN_POSITION_AND_WAIT, entity, other); CreateAndAddEventToList(RADIO_GET_IN_POSITION_AND_WAIT, pEntity, pOther);
} }
void CCSTutor::HandleRadioStormTheFront(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioStormTheFront(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_STORM_THE_FRONT, entity, other); CreateAndAddEventToList(RADIO_STORM_THE_FRONT, pEntity, pOther);
} }
void CCSTutor::HandleRadioReportInTeam(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioReportInTeam(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_REPORT_IN_TEAM, entity, other); CreateAndAddEventToList(RADIO_REPORT_IN_TEAM, pEntity, pOther);
} }
void CCSTutor::HandleRadioAffirmative(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioAffirmative(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_AFFIRMATIVE, entity, other); CreateAndAddEventToList(RADIO_AFFIRMATIVE, pEntity, pOther);
} }
void CCSTutor::HandleRadioEnemySpotted(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioEnemySpotted(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_ENEMY_SPOTTED, entity, other); CreateAndAddEventToList(RADIO_ENEMY_SPOTTED, pEntity, pOther);
} }
void CCSTutor::HandleRadioNeedBackup(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioNeedBackup(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_NEED_BACKUP, entity, other); CreateAndAddEventToList(RADIO_NEED_BACKUP, pEntity, pOther);
} }
void CCSTutor::HandleRadioSectorClear(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioSectorClear(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_SECTOR_CLEAR, entity, other); CreateAndAddEventToList(RADIO_SECTOR_CLEAR, pEntity, pOther);
} }
void CCSTutor::HandleRadioInPosition(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioInPosition(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_IN_POSITION, entity, other); CreateAndAddEventToList(RADIO_IN_POSITION, pEntity, pOther);
} }
void CCSTutor::HandleRadioReportingIn(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioReportingIn(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_REPORTING_IN, entity, other); CreateAndAddEventToList(RADIO_REPORTING_IN, pEntity, pOther);
} }
void CCSTutor::HandleRadioGetOutOfThere(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioGetOutOfThere(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_GET_OUT_OF_THERE, entity, other); CreateAndAddEventToList(RADIO_GET_OUT_OF_THERE, pEntity, pOther);
} }
void CCSTutor::HandleRadioNegative(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioNegative(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_NEGATIVE, entity, other); CreateAndAddEventToList(RADIO_NEGATIVE, pEntity, pOther);
} }
void CCSTutor::HandleRadioEnemyDown(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleRadioEnemyDown(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(RADIO_ENEMY_DOWN, entity, other); CreateAndAddEventToList(RADIO_ENEMY_DOWN, pEntity, pOther);
} }
void CCSTutor::HandleNotBuyingAnything(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNotBuyingAnything(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_TIME_BEGIN, entity, other); CreateAndAddEventToList(BUY_TIME_BEGIN, pEntity, pOther);
} }
void CCSTutor::HandleNeedToBuyPrimaryWeapon(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNeedToBuyPrimaryWeapon(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_NEED_PRIMARY, entity, other); CreateAndAddEventToList(BUY_NEED_PRIMARY, pEntity, pOther);
} }
void CCSTutor::HandleNeedToBuyPrimaryAmmo(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNeedToBuyPrimaryAmmo(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_NEED_PRIMARY_AMMO, entity, other); CreateAndAddEventToList(BUY_NEED_PRIMARY_AMMO, pEntity, pOther);
} }
void CCSTutor::HandleNeedToBuySecondaryAmmo(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNeedToBuySecondaryAmmo(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_NEED_SECONDARY_AMMO, entity, other); CreateAndAddEventToList(BUY_NEED_SECONDARY_AMMO, pEntity, pOther);
} }
void CCSTutor::HandleNeedToBuyArmor(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNeedToBuyArmor(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_NEED_ARMOR, entity, other); CreateAndAddEventToList(BUY_NEED_ARMOR, pEntity, pOther);
} }
void CCSTutor::HandleNeedToBuyDefuseKit(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNeedToBuyDefuseKit(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_NEED_DEFUSE_KIT, entity, other); CreateAndAddEventToList(BUY_NEED_DEFUSE_KIT, pEntity, pOther);
} }
void CCSTutor::HandleNeedToBuyGrenade(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleNeedToBuyGrenade(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
CreateAndAddEventToList(BUY_NEED_GRENADE, entity, other); CreateAndAddEventToList(BUY_NEED_GRENADE, pEntity, pOther);
} }
void CCSTutor::HandleCareerTaskDone(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleCareerTaskDone(CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
int numTasksRemaining = 0; int numTasksRemaining = 0;
@ -2263,7 +2263,7 @@ TutorMessageID CCSTutor::CheckForInBombZone()
bool CCSTutor::IsBombPlantedInBombsite(CBaseEntity *bombTarget) bool CCSTutor::IsBombPlantedInBombsite(CBaseEntity *bombTarget)
{ {
CGrenade *pBomb = nullptr; CGrenade *pBomb = nullptr;
while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
{ {
if (pBomb->m_bIsC4 && IsEntityInBombsite(pBomb, bombTarget)) if (pBomb->m_bIsC4 && IsEntityInBombsite(pBomb, bombTarget))
{ {
@ -2376,7 +2376,7 @@ void CCSTutor::CheckForAllHostagesDead()
bool foundLiveOne = false; bool foundLiveOne = false;
CHostage *pHostage = nullptr; CHostage *pHostage = nullptr;
while ((pHostage = (CHostage *)UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (pHostage->IsAlive()) if (pHostage->IsAlive())
{ {
@ -2396,7 +2396,7 @@ bool CCSTutor::CheckForAllHostagesFollowingSomeone()
bool foundUnusedOne = false; bool foundUnusedOne = false;
CHostage *pHostage = nullptr; CHostage *pHostage = nullptr;
while ((pHostage = (CHostage *)UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
if (pHostage->IsAlive()) if (pHostage->IsAlive())
{ {

View File

@ -275,13 +275,13 @@ public:
virtual ~CCSTutor(); virtual ~CCSTutor();
virtual void TutorThink(float time); virtual void TutorThink(float time);
virtual void PurgeMessages(); virtual void PurgeMessages();
virtual void CallEventHandler(GameEventType event, CBaseEntity *entity, CBaseEntity *other); virtual void CallEventHandler(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther);
virtual void ShowTutorMessage(TutorMessageEvent *event); virtual void ShowTutorMessage(TutorMessageEvent *event);
virtual void HandleShotFired(Vector source, Vector target); virtual void HandleShotFired(Vector source, Vector target);
virtual TutorMessage *GetTutorMessageDefinition(int messageID); virtual TutorMessage *GetTutorMessageDefinition(int messageID);
void CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *entity = NULL, CBaseEntity *other = NULL); void CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr);
TutorMessageEvent *CreateTutorMessageEvent(TutorMessageID mid, CBaseEntity *entity = NULL, CBaseEntity *other = NULL); TutorMessageEvent *CreateTutorMessageEvent(TutorMessageID mid, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr);
void AddToEventList(TutorMessageEvent *event); void AddToEventList(TutorMessageEvent *event);
void DeleteEventFromEventList(TutorMessageEvent *event); void DeleteEventFromEventList(TutorMessageEvent *event);
void ClearEventList(); void ClearEventList();
@ -307,62 +307,62 @@ public:
bool IsHostageMap(); bool IsHostageMap();
public: public:
void HandleWeaponFired(CBaseEntity *entity, CBaseEntity *other); void HandleWeaponFired(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other); void HandleWeaponFiredOnEmpty(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleWeaponReloaded(CBaseEntity *entity, CBaseEntity *other); void HandleWeaponReloaded(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other); void HandlePlayerDied(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); void HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleClientCorpseSpawned(CBaseEntity *entity, CBaseEntity *other); void HandleClientCorpseSpawned(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandlePlayerTookDamage(CBaseEntity *entity, CBaseEntity *other); void HandlePlayerTookDamage(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandlePlayerBlindedByFlashbang(CBaseEntity *entity, CBaseEntity *other); void HandlePlayerBlindedByFlashbang(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other); void HandleBuyTimeStart(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandlePlayerLeftBuyZone(CBaseEntity *entity, CBaseEntity *other); void HandlePlayerLeftBuyZone(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBombPlanted(CBaseEntity *entity, CBaseEntity *other); void HandleBombPlanted(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRoundStart(CBaseEntity *entity, CBaseEntity *other); void HandleRoundStart(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBombDefused(CBaseEntity *entity, CBaseEntity *other); void HandleBombDefused(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBombExploded(CBaseEntity *entity, CBaseEntity *other); void HandleBombExploded(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other); void HandleHostageUsed(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleHostageRescued(CBaseEntity *entity, CBaseEntity *other); void HandleHostageRescued(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleHostageDamaged(CBaseEntity *entity, CBaseEntity *other); void HandleHostageDamaged(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other); void HandleHostageKilled(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleAllHostagesRescued(CBaseEntity *entity, CBaseEntity *other); void HandleAllHostagesRescued(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBeingShotAt(CBaseEntity *entity, CBaseEntity *other); void HandleBeingShotAt(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRoundDraw(CBaseEntity *entity, CBaseEntity *other); void HandleRoundDraw(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleCTWin(CBaseEntity *entity, CBaseEntity *other); void HandleCTWin(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleTWin(CBaseEntity *entity, CBaseEntity *other); void HandleTWin(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleDeathCameraStart(CBaseEntity *entity, CBaseEntity *other); void HandleDeathCameraStart(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBombDefusing(CBaseEntity *entity, CBaseEntity *other); void HandleBombDefusing(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioCoverMe(CBaseEntity *entity, CBaseEntity *other); void HandleRadioCoverMe(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioYouTakeThePoint(CBaseEntity *entity, CBaseEntity *other); void HandleRadioYouTakeThePoint(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioHoldThisPosition(CBaseEntity *entity, CBaseEntity *other); void HandleRadioHoldThisPosition(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioRegroupTeam(CBaseEntity *entity, CBaseEntity *other); void HandleRadioRegroupTeam(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioFollowMe(CBaseEntity *entity, CBaseEntity *other); void HandleRadioFollowMe(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioTakingFire(CBaseEntity *entity, CBaseEntity *other); void HandleRadioTakingFire(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioGoGoGo(CBaseEntity *entity, CBaseEntity *other); void HandleRadioGoGoGo(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioTeamFallBack(CBaseEntity *entity, CBaseEntity *other); void HandleRadioTeamFallBack(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioStickTogetherTeam(CBaseEntity *entity, CBaseEntity *other); void HandleRadioStickTogetherTeam(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioGetInPositionAndWait(CBaseEntity *entity, CBaseEntity *other); void HandleRadioGetInPositionAndWait(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioStormTheFront(CBaseEntity *entity, CBaseEntity *other); void HandleRadioStormTheFront(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioReportInTeam(CBaseEntity *entity, CBaseEntity *other); void HandleRadioReportInTeam(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioAffirmative(CBaseEntity *entity, CBaseEntity *other); void HandleRadioAffirmative(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioEnemySpotted(CBaseEntity *entity, CBaseEntity *other); void HandleRadioEnemySpotted(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioNeedBackup(CBaseEntity *entity, CBaseEntity *other); void HandleRadioNeedBackup(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioSectorClear(CBaseEntity *entity, CBaseEntity *other); void HandleRadioSectorClear(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioInPosition(CBaseEntity *entity, CBaseEntity *other); void HandleRadioInPosition(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioReportingIn(CBaseEntity *entity, CBaseEntity *other); void HandleRadioReportingIn(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioGetOutOfThere(CBaseEntity *entity, CBaseEntity *other); void HandleRadioGetOutOfThere(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioNegative(CBaseEntity *entity, CBaseEntity *other); void HandleRadioNegative(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleRadioEnemyDown(CBaseEntity *entity, CBaseEntity *other); void HandleRadioEnemyDown(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleBuyMenuOpenned(CBaseEntity *entity, CBaseEntity *other); void HandleBuyMenuOpenned(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleAutoBuy(CBaseEntity *entity, CBaseEntity *other); void HandleAutoBuy(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNotBuyingAnything(CBaseEntity *entity, CBaseEntity *other); void HandleNotBuyingAnything(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNeedToBuyPrimaryWeapon(CBaseEntity *entity, CBaseEntity *other); void HandleNeedToBuyPrimaryWeapon(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNeedToBuyPrimaryAmmo(CBaseEntity *entity, CBaseEntity *other); void HandleNeedToBuyPrimaryAmmo(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNeedToBuySecondaryAmmo(CBaseEntity *entity, CBaseEntity *other); void HandleNeedToBuySecondaryAmmo(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNeedToBuyArmor(CBaseEntity *entity, CBaseEntity *other); void HandleNeedToBuyArmor(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNeedToBuyDefuseKit(CBaseEntity *entity, CBaseEntity *other); void HandleNeedToBuyDefuseKit(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleNeedToBuyGrenade(CBaseEntity *entity, CBaseEntity *other); void HandleNeedToBuyGrenade(CBaseEntity *pEntity, CBaseEntity *pOther);
void HandleCareerTaskDone(CBaseEntity *entity, CBaseEntity *other); void HandleCareerTaskDone(CBaseEntity *pEntity, CBaseEntity *pOther);
void GetNumPlayersAliveOnTeams(int &numT, int &numCT); void GetNumPlayersAliveOnTeams(int &numT, int &numCT);
void CheckForBombViewable(); void CheckForBombViewable();
@ -384,7 +384,7 @@ public:
bool IsBombPlantedInBombZone(const char *pszBombZone); bool IsBombPlantedInBombZone(const char *pszBombZone);
void ReadTutorMessageFile(); void ReadTutorMessageFile();
void ApplyPersistentDecay(); void ApplyPersistentDecay();
CBaseEntity *GetEntityForMessageID(int messageID, CBaseEntity *last = NULL); CBaseEntity *GetEntityForMessageID(int messageID, CBaseEntity *last = nullptr);
void ResetPlayerDeathInfo(); void ResetPlayerDeathInfo();
void ConstructRecentDeathsList(TeamName team, char *buf, int buflen, TutorMessageEvent *event); void ConstructRecentDeathsList(TeamName team, char *buf, int buflen, TutorMessageEvent *event);

View File

@ -919,7 +919,7 @@ float UTIL_Approach(float target, float value, float speed)
return value; return value;
} }
float_precision UTIL_ApproachAngle(float target, float value, float speed) real_t UTIL_ApproachAngle(float target, float value, float speed)
{ {
target = UTIL_AngleMod(target); target = UTIL_AngleMod(target);
@ -948,9 +948,9 @@ float_precision UTIL_ApproachAngle(float target, float value, float speed)
return value; return value;
} }
float_precision UTIL_AngleDistance(float next, float cur) real_t UTIL_AngleDistance(float next, float cur)
{ {
float_precision delta; real_t delta;
delta = next - cur; delta = next - cur;
@ -1617,7 +1617,7 @@ bool UTIL_IsGame(const char *pszGameName)
return false; return false;
} }
float_precision UTIL_GetPlayerGaitYaw(int playerIndex) real_t UTIL_GetPlayerGaitYaw(int playerIndex)
{ {
CBasePlayer *pPlayer = UTIL_PlayerByIndex(playerIndex); CBasePlayer *pPlayer = UTIL_PlayerByIndex(playerIndex);
if (pPlayer) if (pPlayer)

View File

@ -88,7 +88,7 @@
#define VEC_DUCK_VIEW Vector(0, 0, 12) #define VEC_DUCK_VIEW Vector(0, 0, 12)
#define PRECACHE_SOUND_ARRAY(a) \ #define PRECACHE_SOUND_ARRAY(a) \
{ for (int i = 0; i < ARRAYSIZE(a); ++i) PRECACHE_SOUND((char *)a[i]); } { for (int i = 0; i < ARRAYSIZE(a); i++) PRECACHE_SOUND((char *)a[i]); }
#define PLAYBACK_EVENT(flags, who, index)\ #define PLAYBACK_EVENT(flags, who, index)\
PLAYBACK_EVENT_FULL(flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0) PLAYBACK_EVENT_FULL(flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0)
@ -251,8 +251,8 @@ float UTIL_VecToYaw(const Vector &vec);
void UTIL_SetOrigin(entvars_t *pev, const Vector &vecOrigin); void UTIL_SetOrigin(entvars_t *pev, const Vector &vecOrigin);
void UTIL_ParticleEffect(const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount); void UTIL_ParticleEffect(const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount);
float UTIL_Approach(float target, float value, float speed); float UTIL_Approach(float target, float value, float speed);
float_precision UTIL_ApproachAngle(float target, float value, float speed); real_t UTIL_ApproachAngle(float target, float value, float speed);
float_precision UTIL_AngleDistance(float next, float cur); real_t UTIL_AngleDistance(float next, float cur);
float UTIL_SplineFraction(float value, float scale); float UTIL_SplineFraction(float value, float scale);
char *UTIL_VarArgs(char *format, ...); char *UTIL_VarArgs(char *format, ...);
Vector UTIL_GetAimVector(edict_t *pent, float flSpeed); Vector UTIL_GetAimVector(edict_t *pent, float flSpeed);
@ -289,7 +289,7 @@ void EntvarsKeyvalue(entvars_t *pev, KeyValueData *pkvd);
char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd); char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd);
int GetPlayerTeam(int index); int GetPlayerTeam(int index);
bool UTIL_IsGame(const char *pszGameName); bool UTIL_IsGame(const char *pszGameName);
float_precision UTIL_GetPlayerGaitYaw(int playerIndex); real_t UTIL_GetPlayerGaitYaw(int playerIndex);
int UTIL_ReadFlags(const char *c); int UTIL_ReadFlags(const char *c);
bool UTIL_AreBotsAllowed(); bool UTIL_AreBotsAllowed();
bool UTIL_AreHostagesImprov(); bool UTIL_AreHostagesImprov();
@ -351,9 +351,9 @@ public:
int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter = nullptr); int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter = nullptr);
inline float_precision UTIL_FixupAngle(float_precision v) inline real_t UTIL_FixupAngle(real_t v)
{ {
float_precision angle = v; real_t angle = v;
while (angle < 0) while (angle < 0)
angle += 360; angle += 360;

View File

@ -71,7 +71,7 @@ public:
// Methods // Methods
inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; } inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; }
inline float_precision Length() const { return Q_sqrt(float_precision(x * x + y * y)); } // Get the vector's magnitude inline real_t Length() const { return Q_sqrt(real_t(x * x + y * y)); } // Get the vector's magnitude
inline float LengthSquared() const { return (x * x + y * y); } // Get the vector's magnitude squared inline float LengthSquared() const { return (x * x + y * y); } // Get the vector's magnitude squared
operator float*() { return &x; } // Vectors will now automatically convert to float * when needed operator float*() { return &x; } // Vectors will now automatically convert to float * when needed
@ -79,7 +79,7 @@ public:
Vector2D Normalize() const Vector2D Normalize() const
{ {
float_precision flLen = Length(); real_t flLen = Length();
if (!flLen) if (!flLen)
return Vector2D(0, 0); return Vector2D(0, 0);
@ -93,9 +93,9 @@ public:
} }
inline bool IsLengthLessThan (float length) const { return (LengthSquared() < length * length); } inline bool IsLengthLessThan (float length) const { return (LengthSquared() < length * length); }
inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); } inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); }
float_precision NormalizeInPlace() real_t NormalizeInPlace()
{ {
float_precision flLen = Length(); real_t flLen = Length();
if (flLen > 0.0) if (flLen > 0.0)
{ {
x = vec_t(1 / flLen * x); x = vec_t(1 / flLen * x);
@ -118,7 +118,7 @@ public:
vec_t x, y; vec_t x, y;
}; };
inline float_precision DotProduct(const Vector2D &a, const Vector2D &b) inline real_t DotProduct(const Vector2D &a, const Vector2D &b)
{ {
return (a.x * b.x + a.y * b.y); return (a.x * b.x + a.y * b.y);
} }
@ -179,17 +179,17 @@ public:
} }
// Get the vector's magnitude // Get the vector's magnitude
float_precision Length() const real_t Length() const
{ {
float_precision x1 = float_precision(x); real_t x1 = real_t(x);
float_precision y1 = float_precision(y); real_t y1 = real_t(y);
float_precision z1 = float_precision(z); real_t z1 = real_t(z);
return Q_sqrt(x1 * x1 + y1 * y1 + z1 * z1); return Q_sqrt(x1 * x1 + y1 * y1 + z1 * z1);
} }
// Get the vector's magnitude squared // Get the vector's magnitude squared
float_precision LengthSquared() const { return (x * x + y * y + z * z); } real_t LengthSquared() const { return (x * x + y * y + z * z); }
operator float*() { return &x; } // Vectors will now automatically convert to float * when needed operator float*() { return &x; } // Vectors will now automatically convert to float * when needed
operator const float*() const { return &x; } // Vectors will now automatically convert to float * when needed operator const float*() const { return &x; } // Vectors will now automatically convert to float * when needed
@ -207,7 +207,7 @@ public:
#else #else
Vector Normalize() Vector Normalize()
{ {
float_precision flLen = Length(); real_t flLen = Length();
if (flLen == 0) if (flLen == 0)
return Vector(0, 0, 1); return Vector(0, 0, 1);
@ -221,7 +221,7 @@ public:
#ifndef PLAY_GAMEDLL #ifndef PLAY_GAMEDLL
return Normalize(); return Normalize();
#else #else
float_precision flLen = Length(); real_t flLen = Length();
if (flLen == 0) if (flLen == 0)
return Vector(0, 0, 1); return Vector(0, 0, 1);
@ -237,14 +237,14 @@ public:
return Vec2; return Vec2;
} }
float_precision Length2D() const { return Q_sqrt(float_precision(x * x + y * y)); } real_t Length2D() const { return Q_sqrt(real_t(x * x + y * y)); }
inline bool IsLengthLessThan (float length) const { return (LengthSquared() < length * length); } inline bool IsLengthLessThan (float length) const { return (LengthSquared() < length * length); }
inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); } inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); }
#ifdef PLAY_GAMEDLL #ifdef PLAY_GAMEDLL
template<typename T = float_precision> template<typename T = real_t>
float_precision NormalizeInPlace() real_t NormalizeInPlace()
{ {
T flLen = Length(); T flLen = Length();
@ -298,12 +298,12 @@ inline Vector operator*(float fl, const Vector &v)
return v * fl; return v * fl;
} }
inline float_precision DotProduct(const Vector &a, const Vector &b) inline real_t DotProduct(const Vector &a, const Vector &b)
{ {
return (a.x * b.x + a.y * b.y + a.z * b.z); return (a.x * b.x + a.y * b.y + a.z * b.z);
} }
inline float_precision DotProduct2D(const Vector &a, const Vector &b) inline real_t DotProduct2D(const Vector &a, const Vector &b)
{ {
return (a.x * b.x + a.y * b.y); return (a.x * b.x + a.y * b.y);
} }
@ -325,7 +325,7 @@ inline LenType LengthSubtract(Vector vecStart, Vector vecDest)
Y floatY = (vecDest.y - vecStart.y); Y floatY = (vecDest.y - vecStart.y);
Z floatZ = (vecDest.z - vecStart.z); Z floatZ = (vecDest.z - vecStart.z);
return Q_sqrt(float_precision(floatX * floatX + floatY * floatY + floatZ * floatZ)); return Q_sqrt(real_t(floatX * floatX + floatY * floatY + floatZ * floatZ));
} }
template< template<
@ -344,7 +344,7 @@ inline Vector NormalizeSubtract(Vector vecStart, Vector vecDest)
Y floatY = (vecDest.y - vecStart.y); Y floatY = (vecDest.y - vecStart.y);
Z floatZ = (vecDest.z - vecStart.z); Z floatZ = (vecDest.z - vecStart.z);
LenType flLen = Q_sqrt(float_precision(floatX * floatX + floatY * floatY + floatZ * floatZ)); LenType flLen = Q_sqrt(real_t(floatX * floatX + floatY * floatY + floatZ * floatZ));
if (flLen == 0.0) if (flLen == 0.0)
{ {

View File

@ -154,7 +154,7 @@ void CFuncVehicle::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
StopSound(); StopSound();
SetThink(NULL); SetThink(nullptr);
} }
} }
@ -171,7 +171,7 @@ void CFuncVehicle::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u
} }
} }
float_precision flSpeedRatio = delta; real_t flSpeedRatio = delta;
if (delta > 0) if (delta > 0)
{ {
@ -297,7 +297,7 @@ void CFuncVehicle::UpdateSound()
void CFuncVehicle::CheckTurning() void CFuncVehicle::CheckTurning()
{ {
float_precision maxspeed; real_t maxspeed;
TraceResult tr; TraceResult tr;
bool bTurnIntoWall = false; bool bTurnIntoWall = false;
@ -566,7 +566,7 @@ void CFuncVehicle::Next()
Vector vTargetAngle, vAngle; Vector vTargetAngle, vAngle;
float vx; float vx;
float_precision vy; real_t vy;
m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, gpGlobals->v_forward); m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, gpGlobals->v_forward);
m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, m_vVehicleDirection); m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, m_vVehicleDirection);
@ -766,7 +766,7 @@ void CFuncVehicle::NearestPath()
{ {
CPathTrack *pTrack = nullptr; CPathTrack *pTrack = nullptr;
CPathTrack *pNearest = nullptr; CPathTrack *pNearest = nullptr;
float_precision dist; real_t dist;
float closest = 1024.0f; float closest = 1024.0f;
while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024.0f))) while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024.0f)))
@ -787,7 +787,7 @@ void CFuncVehicle::NearestPath()
if (!pNearest) if (!pNearest)
{ {
ALERT(at_console, "Can't find a nearby track !!!\n"); ALERT(at_console, "Can't find a nearby track !!!\n");
SetThink(NULL); SetThink(nullptr);
return; return;
} }

View File

@ -677,7 +677,7 @@ bool CBasePlayerWeapon::ShieldSecondaryFire(int iUpAnim, int iDownAnim)
void CBasePlayerWeapon::KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change) void CBasePlayerWeapon::KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change)
{ {
float_precision flKickUp; real_t flKickUp;
float flKickLateral; float flKickLateral;
if (m_iShotsFired == 1) if (m_iShotsFired == 1)
@ -2083,7 +2083,7 @@ void CArmoury::Restart()
return; return;
} }
float flRatio = float_precision(m_iInitialCount / CSGameRules()->m_iTotalGrenadeCount) * float_precision(CSGameRules()->m_iNumTerrorist) * 1.75; float flRatio = real_t(m_iInitialCount / CSGameRules()->m_iTotalGrenadeCount) * real_t(CSGameRules()->m_iNumTerrorist) * 1.75;
m_iCount = int(flRatio); m_iCount = int(flRatio);
} }
else if (m_iItem == ARMOURY_KEVLAR || m_iItem == ARMOURY_ASSAULT) else if (m_iItem == ARMOURY_KEVLAR || m_iItem == ARMOURY_ASSAULT)
@ -2097,7 +2097,7 @@ void CArmoury::Restart()
return; return;
} }
float flRatio = float_precision(m_iInitialCount / CSGameRules()->m_iTotalArmourCount) * float_precision(CSGameRules()->m_iNumTerrorist); float flRatio = real_t(m_iInitialCount / CSGameRules()->m_iTotalArmourCount) * real_t(CSGameRules()->m_iNumTerrorist);
m_iCount = int(flRatio); m_iCount = int(flRatio);
} }
else else
@ -2111,7 +2111,7 @@ void CArmoury::Restart()
return; return;
} }
float flRatio = float_precision(m_iInitialCount / CSGameRules()->m_iTotalGunCount) * float_precision(CSGameRules()->m_iNumTerrorist) * 0.85; float flRatio = real_t(m_iInitialCount / CSGameRules()->m_iTotalGunCount) * real_t(CSGameRules()->m_iNumTerrorist) * 0.85;
m_iCount = int(flRatio); m_iCount = int(flRatio);
} }
} }
@ -2206,13 +2206,13 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther)
if (!pOther->IsPlayer()) if (!pOther->IsPlayer())
return; return;
CBasePlayer *p = static_cast<CBasePlayer *>(pOther); CBasePlayer *pToucher = static_cast<CBasePlayer *>(pOther);
if (p->m_bIsVIP) if (pToucher->m_bIsVIP)
return; return;
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
if (p->HasRestrictItem(GetItemIdByArmoury(m_iItem), ITEM_TYPE_TOUCHED)) if (pToucher->HasRestrictItem(GetItemIdByArmoury(m_iItem), ITEM_TYPE_TOUCHED))
return; return;
#endif #endif
@ -2223,32 +2223,32 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther)
#endif #endif
)) ))
{ {
if (p->m_bHasPrimary) if (pToucher->m_bHasPrimary)
return; return;
m_iCount--; m_iCount--;
auto item = &armouryItemInfo[m_iItem]; auto item = &armouryItemInfo[m_iItem];
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
p->GiveNamedItemEx(item->entityName); pToucher->GiveNamedItemEx(item->entityName);
#else #else
p->GiveNamedItem(item->entityName); pToucher->GiveNamedItem(item->entityName);
#endif #endif
p->GiveAmmo(item->giveAmount, item->ammoName, item->maxRounds); pToucher->GiveAmmo(item->giveAmount, item->ammoName, item->maxRounds);
} }
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
// secondary weapons (pistols) // secondary weapons (pistols)
else if (m_iCount > 0 && m_iItem >= ARMOURY_GLOCK18) else if (m_iCount > 0 && m_iItem >= ARMOURY_GLOCK18)
{ {
if (p->m_rgpPlayerItems[PISTOL_SLOT]) if (pToucher->m_rgpPlayerItems[PISTOL_SLOT])
return; return;
m_iCount--; m_iCount--;
auto item = &armouryItemInfo[m_iItem]; auto item = &armouryItemInfo[m_iItem];
p->GiveNamedItemEx(item->entityName); pToucher->GiveNamedItemEx(item->entityName);
p->GiveAmmo(item->giveAmount, item->ammoName, item->maxRounds); pToucher->GiveAmmo(item->giveAmount, item->ammoName, item->maxRounds);
} }
#endif #endif
// items & grenades // items & grenades
@ -2258,56 +2258,56 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther)
{ {
case ARMOURY_FLASHBANG: case ARMOURY_FLASHBANG:
{ {
if (p->AmmoInventory(AMMO_FLASHBANG) >= MaxAmmoCarry(WEAPON_FLASHBANG)) if (pToucher->AmmoInventory(AMMO_FLASHBANG) >= MaxAmmoCarry(WEAPON_FLASHBANG))
return; return;
p->GiveNamedItem("weapon_flashbang"); pToucher->GiveNamedItem("weapon_flashbang");
m_iCount--; m_iCount--;
break; break;
} }
case ARMOURY_HEGRENADE: case ARMOURY_HEGRENADE:
{ {
if (p->AmmoInventory(AMMO_HEGRENADE) >= MaxAmmoCarry(WEAPON_HEGRENADE)) if (pToucher->AmmoInventory(AMMO_HEGRENADE) >= MaxAmmoCarry(WEAPON_HEGRENADE))
return; return;
p->GiveNamedItem("weapon_hegrenade"); pToucher->GiveNamedItem("weapon_hegrenade");
m_iCount--; m_iCount--;
break; break;
} }
case ARMOURY_KEVLAR: case ARMOURY_KEVLAR:
{ {
if (p->m_iKevlar == ARMOR_KEVLAR) if (pToucher->m_iKevlar == ARMOR_KEVLAR)
return; return;
p->GiveNamedItem("item_kevlar"); pToucher->GiveNamedItem("item_kevlar");
m_iCount--; m_iCount--;
break; break;
} }
case ARMOURY_ASSAULT: case ARMOURY_ASSAULT:
{ {
if (p->m_iKevlar == ARMOR_VESTHELM) if (pToucher->m_iKevlar == ARMOR_VESTHELM)
return; return;
p->GiveNamedItem("item_assaultsuit"); pToucher->GiveNamedItem("item_assaultsuit");
m_iCount--; m_iCount--;
break; break;
} }
case ARMOURY_SMOKEGRENADE: case ARMOURY_SMOKEGRENADE:
{ {
if (p->AmmoInventory(AMMO_SMOKEGRENADE) >= MaxAmmoCarry(WEAPON_SMOKEGRENADE)) if (pToucher->AmmoInventory(AMMO_SMOKEGRENADE) >= MaxAmmoCarry(WEAPON_SMOKEGRENADE))
return; return;
p->GiveNamedItem("weapon_smokegrenade"); pToucher->GiveNamedItem("weapon_smokegrenade");
m_iCount--; m_iCount--;
break; break;
} }
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
case ARMOURY_SHIELD: case ARMOURY_SHIELD:
{ {
if (p->m_bHasPrimary || (p->m_rgpPlayerItems[PISTOL_SLOT] && p->GetItemById(WEAPON_ELITE))) if (pToucher->m_bHasPrimary || (pToucher->m_rgpPlayerItems[PISTOL_SLOT] && pToucher->GetItemById(WEAPON_ELITE)))
return; return;
p->GiveNamedItemEx("weapon_shield"); pToucher->GiveNamedItemEx("weapon_shield");
m_iCount--; m_iCount--;
break; break;
} }

View File

@ -272,7 +272,7 @@ public:
virtual int PrimaryAmmoIndex() { return -1; } virtual int PrimaryAmmoIndex() { return -1; }
virtual int SecondaryAmmoIndex() { return -1; } virtual int SecondaryAmmoIndex() { return -1; }
virtual int UpdateClientData(CBasePlayer *pPlayer) { return 0; } virtual int UpdateClientData(CBasePlayer *pPlayer) { return 0; }
virtual CBasePlayerItem *GetWeaponPtr() { return NULL; } virtual CBasePlayerItem *GetWeaponPtr() { return nullptr; }
virtual float GetMaxSpeed() { return 260.0f; } virtual float GetMaxSpeed() { return 260.0f; }
virtual int iItemSlot() { return 0; } // return 0 to MAX_ITEMS_SLOTS, used in hud virtual int iItemSlot() { return 0; } // return 0 to MAX_ITEMS_SLOTS, used in hud
@ -443,7 +443,7 @@ public:
public: public:
BOOL IsEmpty(); BOOL IsEmpty();
int GiveAmmo(int iCount, char *szName, int iMax, int *pIndex = NULL); int GiveAmmo(int iCount, char *szName, int iMax, int *pIndex = nullptr);
void EXPORT Kill(); void EXPORT Kill();
void EXPORT BombThink(); void EXPORT BombThink();

View File

@ -183,7 +183,7 @@ void CFlashbang::WeaponIdle()
else else
angThrow.x = -10 + angThrow.x * ((90 + 10) / 90.0); angThrow.x = -10 + angThrow.x * ((90 + 10) / 90.0);
float_precision flVel = (90.0f - angThrow.x) * 6.0f; real_t flVel = (90.0f - angThrow.x) * 6.0f;
if (flVel > 750.0f) if (flVel > 750.0f)
flVel = 750.0f; flVel = 750.0f;

View File

@ -39,7 +39,7 @@ int CG3SG1::GetItemInfo(ItemInfo *p)
p->pszName = STRING(pev->classname); p->pszName = STRING(pev->classname);
p->pszAmmo1 = "762Nato"; p->pszAmmo1 = "762Nato";
p->iMaxAmmo1 = MAX_AMMO_762NATO; p->iMaxAmmo1 = MAX_AMMO_762NATO;
p->pszAmmo2 = NULL; p->pszAmmo2 = nullptr;
p->iMaxAmmo2 = -1; p->iMaxAmmo2 = -1;
p->iMaxClip = G3SG1_MAX_CLIP; p->iMaxClip = G3SG1_MAX_CLIP;
p->iSlot = 0; p->iSlot = 0;
@ -73,7 +73,7 @@ void CG3SG1::SecondaryAttack()
m_pPlayer->ResetMaxSpeed(); m_pPlayer->ResetMaxSpeed();
if (TheBots != NULL) if (TheBots)
{ {
TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer); TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer);
} }
@ -136,7 +136,7 @@ void CG3SG1::G3SG1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
m_flNextPrimaryAttack = GetNextAttackDelay(0.2); m_flNextPrimaryAttack = GetNextAttackDelay(0.2);
} }
if (TheBots != NULL) if (TheBots)
{ {
TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer);
} }

View File

@ -129,7 +129,7 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl
if (tmpTrace.flFraction < 1.0f) if (tmpTrace.flFraction < 1.0f)
{ {
float_precision thisDistance = (tmpTrace.vecEndPos - vecSrc).Length(); real_t thisDistance = (tmpTrace.vecEndPos - vecSrc).Length();
if (thisDistance < distance) if (thisDistance < distance)
{ {

View File

@ -185,7 +185,7 @@ void CSmokeGrenade::WeaponIdle()
else else
angThrow.x = -10 + angThrow.x * ((90 + 10) / 90.0); angThrow.x = -10 + angThrow.x * ((90 + 10) / 90.0);
float_precision flVel = (90.0f - angThrow.x) * 6.0f; real_t flVel = (90.0f - angThrow.x) * 6.0f;
if (flVel > 750.0f) if (flVel > 750.0f)
flVel = 750.0f; flVel = 750.0f;

View File

@ -37,7 +37,7 @@ int CXM1014::GetItemInfo(ItemInfo *p)
p->pszName = STRING(pev->classname); p->pszName = STRING(pev->classname);
p->pszAmmo1 = "buckshot"; p->pszAmmo1 = "buckshot";
p->iMaxAmmo1 = MAX_AMMO_BUCKSHOT; p->iMaxAmmo1 = MAX_AMMO_BUCKSHOT;
p->pszAmmo2 = NULL; p->pszAmmo2 = nullptr;
p->iMaxAmmo2 = -1; p->iMaxAmmo2 = -1;
p->iMaxClip = XM1014_MAX_CLIP; p->iMaxClip = XM1014_MAX_CLIP;
p->iSlot = 0; p->iSlot = 0;
@ -76,7 +76,7 @@ void CXM1014::PrimaryAttack()
PlayEmptySound(); PlayEmptySound();
} }
if (TheBots != NULL) if (TheBots)
{ {
TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer);
} }

View File

@ -104,14 +104,14 @@ inline int CBitVec<NUM_BITS>::GetNumBits()
template<int NUM_BITS> template<int NUM_BITS>
inline CBitVec<NUM_BITS>::CBitVec() inline CBitVec<NUM_BITS>::CBitVec()
{ {
for (int i = 0; i < NUM_DWORDS; ++i) for (int i = 0; i < NUM_DWORDS; i++)
m_DWords[i] = 0; m_DWords[i] = 0;
} }
template<int NUM_BITS> template<int NUM_BITS>
inline void CBitVec<NUM_BITS>::Init(int val) inline void CBitVec<NUM_BITS>::Init(int val)
{ {
for (int i = 0; i < GetNumBits(); ++i) for (int i = 0; i < GetNumBits(); i++)
{ {
(*this)[i] = val; (*this)[i] = val;
} }
@ -134,7 +134,7 @@ inline CBitVecAccessor CBitVec<NUM_BITS>::operator[](int i)
template<int NUM_BITS> template<int NUM_BITS>
inline bool CBitVec<NUM_BITS>::operator==(CBitVec<NUM_BITS> const &other) inline bool CBitVec<NUM_BITS>::operator==(CBitVec<NUM_BITS> const &other)
{ {
for (int i = 0; i < NUM_DWORDS; ++i) for (int i = 0; i < NUM_DWORDS; i++)
{ {
if (m_DWords[i] != other.m_DWords[i]) if (m_DWords[i] != other.m_DWords[i])
return false; return false;

View File

@ -316,20 +316,20 @@ void CBot::ClientCommand(const char *cmd, const char *arg1, const char *arg2, co
#endif #endif
// Returns TRUE if given entity is our enemy // Returns TRUE if given entity is our enemy
bool CBot::IsEnemy(CBaseEntity *ent) const bool CBot::IsEnemy(CBaseEntity *pEntity) const
{ {
// only Players (real and AI) can be enemies // only Players (real and AI) can be enemies
if (!ent->IsPlayer()) if (!pEntity->IsPlayer())
return false; return false;
// corpses are no threat // corpses are no threat
if (!ent->IsAlive()) if (!pEntity->IsAlive())
return false; return false;
CBasePlayer *player = static_cast<CBasePlayer *>(ent); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
// if they are on our team, they are our friends // if they are on our team, they are our friends
if (BotRelationship(player) == BOT_TEAMMATE) if (BotRelationship(pPlayer) == BOT_TEAMMATE)
return false; return false;
// yep, we hate 'em // yep, we hate 'em
@ -340,25 +340,25 @@ bool CBot::IsEnemy(CBaseEntity *ent) const
int CBot::GetEnemiesRemaining() const int CBot::GetEnemiesRemaining() const
{ {
int count = 0; int count = 0;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBaseEntity *player = UTIL_PlayerByIndex(i); CBaseEntity *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
if (!IsEnemy(player)) if (!IsEnemy(pPlayer))
continue; continue;
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
++count; count++;
} }
return count; return count;
@ -368,28 +368,28 @@ int CBot::GetEnemiesRemaining() const
int CBot::GetFriendsRemaining() const int CBot::GetFriendsRemaining() const
{ {
int count = 0; int count = 0;
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBaseEntity *player = UTIL_PlayerByIndex(i); CBaseEntity *pPlayer = UTIL_PlayerByIndex(i);
if (!player) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
if (IsEnemy(player)) if (IsEnemy(pPlayer))
continue; continue;
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
if (player == static_cast<CBaseEntity *>(const_cast<CBot *>(this))) if (pPlayer == static_cast<CBaseEntity *>(const_cast<CBot *>(this)))
continue; continue;
++count; count++;
} }
return count; return count;
@ -403,13 +403,13 @@ bool CBot::IsLocalPlayerWatchingMe() const
int myIndex = const_cast<CBot *>(this)->entindex(); int myIndex = const_cast<CBot *>(this)->entindex();
CBasePlayer *player = UTIL_GetLocalPlayer(); CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
if (!player) if (!pPlayer)
return false; return false;
if (((player->pev->flags & FL_SPECTATOR) || player->m_iTeam == SPECTATOR) && player->pev->iuser2 == myIndex) if (((pPlayer->pev->flags & FL_SPECTATOR) || pPlayer->m_iTeam == SPECTATOR) && pPlayer->pev->iuser2 == myIndex)
{ {
switch (player->pev->iuser1) switch (pPlayer->pev->iuser1)
{ {
case OBS_CHASE_LOCKED: case OBS_CHASE_LOCKED:
case OBS_CHASE_FREE: case OBS_CHASE_FREE:

View File

@ -45,7 +45,7 @@ T *CreateBot(const BotProfile *profile)
if (UTIL_ClientsInGame() >= gpGlobals->maxClients) if (UTIL_ClientsInGame() >= gpGlobals->maxClients)
{ {
CONSOLE_ECHO("Unable to create bot: Server is full (%d/%d clients).\n", UTIL_ClientsInGame(), gpGlobals->maxClients); CONSOLE_ECHO("Unable to create bot: Server is full (%d/%d clients).\n", UTIL_ClientsInGame(), gpGlobals->maxClients);
return NULL; return nullptr;
} }
char netname[64]; char netname[64];
@ -55,11 +55,11 @@ T *CreateBot(const BotProfile *profile)
if (FNullEnt(pentBot)) if (FNullEnt(pentBot))
{ {
CONSOLE_ECHO("Unable to create bot: pfnCreateFakeClient() returned null.\n"); CONSOLE_ECHO("Unable to create bot: pfnCreateFakeClient() returned null.\n");
return NULL; return nullptr;
} }
else else
{ {
T *pBot = NULL; T *pBot = nullptr;
FREE_PRIVATE(pentBot); FREE_PRIVATE(pentBot);
pBot = GetClassPtr<TWrap>((T *)VARS(pentBot)); pBot = GetClassPtr<TWrap>((T *)VARS(pentBot));
pBot->Initialize(profile); pBot->Initialize(profile);
@ -131,13 +131,13 @@ public:
virtual void Reload(); virtual void Reload();
// invoked when event occurs in the game (some events have NULL entities) // invoked when event occurs in the game (some events have NULL entities)
virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) {}; virtual void OnEvent(GameEventType event, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr) {};
// return true if we can see the point // return true if we can see the point
virtual bool IsVisible(const Vector *pos, bool testFOV = false) const = 0; virtual bool IsVisible(const Vector *pos, bool testFOV = false) const = 0;
// return true if we can see any part of the player // return true if we can see any part of the player
virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = NULL) const = 0; virtual bool IsVisible(CBasePlayer *pPlayer, bool testFOV = false, unsigned char *visParts = nullptr) const = 0;
enum VisiblePartType : uint8 enum VisiblePartType : uint8
{ {
@ -153,10 +153,10 @@ public:
virtual bool IsEnemyPartVisible(VisiblePartType part) const = 0; virtual bool IsEnemyPartVisible(VisiblePartType part) const = 0;
// return true if player is facing towards us // return true if player is facing towards us
virtual bool IsPlayerFacingMe(CBasePlayer *other) const; virtual bool IsPlayerFacingMe(CBasePlayer *pOther) const;
// returns true if other player is pointing right at us // returns true if other player is pointing right at us
virtual bool IsPlayerLookingAtMe(CBasePlayer *other) const; virtual bool IsPlayerLookingAtMe(CBasePlayer *pOther) const;
virtual void ExecuteCommand(); virtual void ExecuteCommand();
virtual void SetModel(const char *modelName); virtual void SetModel(const char *modelName);
@ -197,7 +197,7 @@ public:
bool IsUsingScope() const; bool IsUsingScope() const;
// returns TRUE if given entity is our enemy // returns TRUE if given entity is our enemy
bool IsEnemy(CBaseEntity *ent) const; bool IsEnemy(CBaseEntity *pEntity) const;
// return number of enemies left alive // return number of enemies left alive
int GetEnemiesRemaining() const; int GetEnemiesRemaining() const;
@ -238,7 +238,7 @@ public:
protected: protected:
#ifndef REGAMEDLL_FIXES #ifndef REGAMEDLL_FIXES
// Do a "client command" - useful for invoking menu choices, etc. // Do a "client command" - useful for invoking menu choices, etc.
void ClientCommand(const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL, const char *arg3 = NULL); void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr);
#endif #endif
// the "personality" profile of this bot // the "personality" profile of this bot
@ -320,20 +320,20 @@ inline CBasePlayerWeapon *CBot::GetActiveWeapon() const
inline bool CBot::IsActiveWeaponReloading() const inline bool CBot::IsActiveWeaponReloading() const
{ {
CBasePlayerWeapon *weapon = GetActiveWeapon(); CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon();
if (weapon == NULL) if (!pCurrentWeapon)
return false; return false;
return (weapon->m_fInReload || weapon->m_fInSpecialReload) != 0; return (pCurrentWeapon->m_fInReload || pCurrentWeapon->m_fInSpecialReload) != 0;
} }
inline bool CBot::IsActiveWeaponRecoilHigh() const inline bool CBot::IsActiveWeaponRecoilHigh() const
{ {
CBasePlayerWeapon *weapon = GetActiveWeapon(); CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon();
if (weapon != NULL) if (pCurrentWeapon)
{ {
const float highRecoil = 0.4f; const float highRecoil = 0.4f;
return (weapon->m_flAccuracy > highRecoil) != 0; return (pCurrentWeapon->m_flAccuracy > highRecoil) != 0;
} }
return false; return false;
@ -343,40 +343,42 @@ inline void CBot::PushPostureContext()
{ {
if (m_postureStackIndex == MAX_POSTURE_STACK) if (m_postureStackIndex == MAX_POSTURE_STACK)
{ {
if (pev != NULL) if (pev)
{ {
PrintIfWatched("PushPostureContext() overflow error!\n"); PrintIfWatched("PushPostureContext() overflow error!\n");
} }
return; return;
} }
m_postureStack[m_postureStackIndex].isRunning = m_isRunning; m_postureStack[m_postureStackIndex].isRunning = m_isRunning;
m_postureStack[m_postureStackIndex].isCrouching = m_isCrouching; m_postureStack[m_postureStackIndex].isCrouching = m_isCrouching;
++m_postureStackIndex; m_postureStackIndex++;
} }
inline void CBot::PopPostureContext() inline void CBot::PopPostureContext()
{ {
if (m_postureStackIndex == 0) if (m_postureStackIndex == 0)
{ {
if (pev != NULL) if (pev)
{ {
PrintIfWatched("PopPostureContext() underflow error!\n"); PrintIfWatched("PopPostureContext() underflow error!\n");
} }
m_isRunning = true; m_isRunning = true;
m_isCrouching = false; m_isCrouching = false;
return; return;
} }
--m_postureStackIndex; m_postureStackIndex--;
m_isRunning = m_postureStack[m_postureStackIndex].isRunning; m_isRunning = m_postureStack[m_postureStackIndex].isRunning;
m_isCrouching = m_postureStack[m_postureStackIndex].isCrouching; m_isCrouching = m_postureStack[m_postureStackIndex].isCrouching;
} }
inline bool CBot::IsPlayerFacingMe(CBasePlayer *other) const inline bool CBot::IsPlayerFacingMe(CBasePlayer *pOther) const
{ {
Vector toOther = other->pev->origin - pev->origin; Vector toOther = pOther->pev->origin - pev->origin;
UTIL_MakeVectors(other->pev->v_angle + other->pev->punchangle); UTIL_MakeVectors(pOther->pev->v_angle + pOther->pev->punchangle);
Vector otherDir = gpGlobals->v_forward; Vector otherDir = gpGlobals->v_forward;
if (otherDir.x * toOther.x + otherDir.y * toOther.y < 0.0f) if (otherDir.x * toOther.x + otherDir.y * toOther.y < 0.0f)
@ -385,18 +387,18 @@ inline bool CBot::IsPlayerFacingMe(CBasePlayer *other) const
return false; return false;
} }
inline bool CBot::IsPlayerLookingAtMe(CBasePlayer *other) const inline bool CBot::IsPlayerLookingAtMe(CBasePlayer *pOther) const
{ {
Vector toOther = other->pev->origin - pev->origin; Vector toOther = pOther->pev->origin - pev->origin;
toOther.NormalizeInPlace(); toOther.NormalizeInPlace();
UTIL_MakeVectors(other->pev->v_angle + other->pev->punchangle); UTIL_MakeVectors(pOther->pev->v_angle + pOther->pev->punchangle);
Vector otherDir = gpGlobals->v_forward; Vector otherDir = gpGlobals->v_forward;
const float lookAtCos = 0.9f; const float lookAtCos = 0.9f;
if (otherDir.x * toOther.x + otherDir.y * toOther.y < -lookAtCos) if (otherDir.x * toOther.x + otherDir.y * toOther.y < -lookAtCos)
{ {
Vector vec(other->EyePosition()); Vector vec(pOther->EyePosition());
if (IsVisible(&vec)) if (IsVisible(&vec))
return true; return true;
} }

View File

@ -216,41 +216,41 @@ const char *CBotManager::GetNavMapFilename() const
// Invoked when given player does given event (some events have NULL player). // Invoked when given player does given event (some events have NULL player).
// Events are propogated to all bots. // Events are propogated to all bots.
// TODO: This has become the game-wide event dispatcher. We should restructure this. // TODO: This has become the game-wide event dispatcher. We should restructure this.
void CBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CBotManager::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{ {
// propogate event to all bots // propogate event to all bots
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (player == NULL) if (!pPlayer)
continue; continue;
if (FNullEnt(player->pev)) if (FNullEnt(pPlayer->pev))
continue; continue;
if (FStrEq(STRING(player->pev->netname), "")) if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue; continue;
if (!player->IsBot()) if (!pPlayer->IsBot())
continue; continue;
// do not send self-generated event // do not send self-generated event
if (entity == player) if (pEntity == pPlayer)
continue; continue;
CBot *bot = static_cast<CBot *>(player); CBot *bot = static_cast<CBot *>(pPlayer);
bot->OnEvent(event, entity, other); bot->OnEvent(event, pEntity, pOther);
} }
if (TheTutor != NULL) if (TheTutor)
{ {
TheTutor->OnEvent(event, entity, other); TheTutor->OnEvent(event, pEntity, pOther);
} }
if (g_pHostages != NULL) if (g_pHostages)
{ {
g_pHostages->OnEvent(event, entity, other); g_pHostages->OnEvent(event, pEntity, pOther);
} }
} }
@ -265,14 +265,12 @@ void CBotManager::AddGrenade(int type, CGrenade *grenade)
// The grenade entity in the world is going away // The grenade entity in the world is going away
void CBotManager::RemoveGrenade(CGrenade *grenade) void CBotManager::RemoveGrenade(CGrenade *grenade)
{ {
for (auto iter = m_activeGrenadeList.begin(); iter != m_activeGrenadeList.end(); iter++) for (auto ag : m_activeGrenadeList)
{ {
ActiveGrenade *ag = (*iter);
if (ag->IsEntity(grenade)) if (ag->IsEntity(grenade))
{ {
ag->OnEntityGone(); ag->OnEntityGone();
return; break;
} }
} }
} }

View File

@ -78,8 +78,8 @@ public:
virtual void StartFrame(); virtual void StartFrame();
// Events are propogated to all bots. // Events are propogated to all bots.
virtual void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); // Invoked when event occurs in the game (some events have NULL entity). virtual void OnEvent(GameEventType event, CBaseEntity *pEntity = nullptr, CBaseEntity *pOther = nullptr); // Invoked when event occurs in the game (some events have NULL entity).
virtual unsigned int GetPlayerPriority(CBasePlayer *player) const = 0; // return priority of player (0 = max pri) virtual unsigned int GetPlayerPriority(CBasePlayer *pPlayer) const = 0; // return priority of player (0 = max pri)
public: public:
const char *GetNavMapFilename() const; // return the filename for this map's "nav" file const char *GetNavMapFilename() const; // return the filename for this map's "nav" file

View File

@ -393,14 +393,46 @@ bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange)
return false; return false;
} }
// Return the local player
CBasePlayer *UTIL_GetLocalPlayer() CBasePlayer *UTIL_GetLocalPlayer()
{ {
if (!IS_DEDICATED_SERVER()) // no "local player" if this is a dedicated server or a single player game
return UTIL_PlayerByIndex(1); if (IS_DEDICATED_SERVER())
{
#ifdef _DEBUG
// just try to find any player
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex);
if (!pPlayer)
continue;
if (FNullEnt(pPlayer->pev))
continue;
if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue;
if (pPlayer->IsBot())
continue;
if (pPlayer->m_iTeam != TERRORIST && pPlayer->m_iTeam != CT)
continue;
if (pPlayer->m_iJoiningState != JOINED)
continue;
return pPlayer;
}
#endif
return nullptr; return nullptr;
} }
return UTIL_PlayerByIndex(1);
}
NOXREF Vector UTIL_ComputeOrigin(entvars_t *pevVars) NOXREF Vector UTIL_ComputeOrigin(entvars_t *pevVars)
{ {
if (pevVars->origin.x == 0.0f && pevVars->origin.y == 0.0f && pevVars->origin.z == 0.0f) if (pevVars->origin.x == 0.0f && pevVars->origin.y == 0.0f && pevVars->origin.z == 0.0f)
@ -563,7 +595,7 @@ void InitBotTrig()
{ {
for (int i = 0; i < COS_TABLE_SIZE; i++) for (int i = 0; i < COS_TABLE_SIZE; i++)
{ {
float_precision angle = 2.0f * M_PI * float(i) / float(COS_TABLE_SIZE - 1); real_t angle = 2.0f * M_PI * float(i) / float(COS_TABLE_SIZE - 1);
cosTable[i] = Q_cos(angle); cosTable[i] = Q_cos(angle);
} }
} }
@ -583,11 +615,11 @@ float BotSIN(float angle)
} }
// Determine if this event is audible, and if so, return its audible range and priority // Determine if this event is audible, and if so, return its audible range and priority
bool IsGameEventAudible(GameEventType event, CBaseEntity *entity, CBaseEntity *other, float *range, PriorityType *priority, bool *isHostile) bool IsGameEventAudible(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther, float *range, PriorityType *priority, bool *isHostile)
{ {
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(entity); CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (!entity || !pPlayer->IsPlayer()) if (!pEntity || !pPlayer->IsPlayer())
pPlayer = nullptr; pPlayer = nullptr;
const float ShortRange = 1000.0f; const float ShortRange = 1000.0f;

View File

@ -89,7 +89,7 @@ inline bool IsEntityValid(CBaseEntity *pEntity)
if (FStrEq(STRING(pEntity->pev->netname), "")) if (FStrEq(STRING(pEntity->pev->netname), ""))
return false; return false;
if (pEntity->pev->flags & FL_DORMANT) if (pEntity->IsDormant())
return false; return false;
return true; return true;
@ -143,7 +143,7 @@ inline bool IsIntersecting2D(const Vector &startA, const Vector &endA, const Vec
template <typename Functor> template <typename Functor>
bool ForEachPlayer(Functor &func) bool ForEachPlayer(Functor &func)
{ {
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!IsEntityValid(pPlayer)) if (!IsEntityValid(pPlayer))
@ -193,5 +193,5 @@ void BotPrecache();
void InitBotTrig(); void InitBotTrig();
float BotCOS(float angle); float BotCOS(float angle);
float BotSIN(float angle); float BotSIN(float angle);
bool IsGameEventAudible(enum GameEventType event, CBaseEntity *entity, CBaseEntity *other, float *range, PriorityType *priority, bool *isHostile); bool IsGameEventAudible(enum GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther, float *range, PriorityType *priority, bool *isHostile);
void HintMessageToAllPlayers(const char *message); void HintMessageToAllPlayers(const char *message);

View File

@ -83,7 +83,7 @@ public:
virtual void StartLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos) = 0; // invoked when a ladder is encountered while following a path virtual void StartLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos) = 0; // invoked when a ladder is encountered while following a path
virtual bool TraverseLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) = 0; // traverse given ladder virtual bool TraverseLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) = 0; // traverse given ladder
virtual bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = NULL) = 0; // find "simple" ground height, treating current nav area as part of the floor virtual bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = nullptr) = 0; // find "simple" ground height, treating current nav area as part of the floor
virtual void Run() = 0; virtual void Run() = 0;
virtual void Walk() = 0; virtual void Walk() = 0;
@ -110,15 +110,15 @@ public:
virtual bool CanCrouch() const = 0; virtual bool CanCrouch() const = 0;
virtual bool CanJump() const = 0; virtual bool CanJump() const = 0;
virtual bool IsVisible(const Vector &pos, bool testFOV = false) const = 0; // return true if improv can see position virtual bool IsVisible(const Vector &pos, bool testFOV = false) const = 0; // return true if improv can see position
virtual bool IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance = 0.95f) const = 0; // return true if 'other' is looking right at me virtual bool IsPlayerLookingAtMe(CBasePlayer *pOther, float cosTolerance = 0.95f) const = 0; // return true if 'other' is looking right at me
virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const = 0; // return player on given team that is looking right at me (team == 0 means any team), NULL otherwise virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const = 0; // return player on given team that is looking right at me (team == 0 means any team), NULL otherwise
virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = NULL) const = 0; // return actual travel distance to closest player on given team (team == 0 means any team) virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = nullptr) const = 0; // return actual travel distance to closest player on given team (team == 0 means any team)
virtual CNavArea *GetLastKnownArea() const = 0; virtual CNavArea *GetLastKnownArea() const = 0;
virtual void OnUpdate(float deltaT) = 0; // a less frequent, full update 'tick' virtual void OnUpdate(float deltaT) = 0; // a less frequent, full update 'tick'
virtual void OnUpkeep(float deltaT) = 0; // a frequent, lightweight update 'tick' virtual void OnUpkeep(float deltaT) = 0; // a frequent, lightweight update 'tick'
virtual void OnReset() = 0; // reset improv to initial state virtual void OnReset() = 0; // reset improv to initial state
virtual void OnGameEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; // invoked when an event occurs in the game virtual void OnGameEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther) = 0; // invoked when an event occurs in the game
virtual void OnTouch(CBaseEntity *other) = 0; // "other" has touched us virtual void OnTouch(CBaseEntity *pOther) = 0; // "other" has touched us
}; };

View File

@ -69,7 +69,6 @@ enum NavAttributeType
NAV_JUMP = 0x02, // must jump to traverse this area NAV_JUMP = 0x02, // must jump to traverse this area
NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area
NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping
NAV_WALK = 0x10, // must not run through this area
}; };
enum NavDirType enum NavDirType
@ -251,7 +250,7 @@ inline float DirectionToAngle(NavDirType dir)
return 0.0f; return 0.0f;
} }
inline NavDirType AngleToDirection(float_precision angle) inline NavDirType AngleToDirection(real_t angle)
{ {
while (angle < 0.0f) while (angle < 0.0f)
angle += 360.0f; angle += 360.0f;
@ -314,7 +313,7 @@ inline float SnapToGrid(float value)
return c * GenerationStepSize; return c * GenerationStepSize;
} }
inline float_precision NormalizeAngle(float_precision angle) inline real_t NormalizeAngle(real_t angle)
{ {
while (angle < -180.0f) while (angle < -180.0f)
angle += 360.0f; angle += 360.0f;
@ -371,14 +370,14 @@ inline bool VectorsAreEqual(const Vector *a, const Vector *b, float tolerance =
return false; return false;
} }
inline bool IsEntityWalkable(entvars_t *entity, unsigned int flags) inline bool IsEntityWalkable(entvars_t *pev, unsigned int flags)
{ {
// if we hit a door, assume its walkable because it will open when we touch it // if we hit a door, assume its walkable because it will open when we touch it
if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) if (FClassnameIs(pev, "func_door") || FClassnameIs(pev, "func_door_rotating"))
return (flags & WALK_THRU_DOORS) ? true : false; return (flags & WALK_THRU_DOORS) ? true : false;
// if we hit a breakable object, assume its walkable because we will shoot it when we touch it // if we hit a breakable object, assume its walkable because we will shoot it when we touch it
if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) else if (FClassnameIs(pev, "func_breakable") && pev->takedamage == DAMAGE_YES)
return (flags & WALK_THRU_BREAKABLES) ? true : false; return (flags & WALK_THRU_BREAKABLES) ? true : false;
return false; return false;
@ -395,17 +394,21 @@ inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flag
{ {
UTIL_TraceLine(useFrom, to, ignore_monsters, pEntIgnore, &result); UTIL_TraceLine(useFrom, to, ignore_monsters, pEntIgnore, &result);
if (result.flFraction != 1.0f && IsEntityWalkable(VARS(result.pHit), flags)) // if we hit a walkable entity, try again
if (result.flFraction != 1.0f && (result.pHit && IsEntityWalkable(VARS(result.pHit), flags)))
{ {
pEntIgnore = result.pHit; pEntIgnore = result.pHit;
// start from just beyond where we hit to avoid infinite loops
Vector dir = to - from; Vector dir = to - from;
dir.NormalizeInPlace(); dir.NormalizeInPlace();
useFrom = result.vecEndPos + 5.0f * dir; useFrom = result.vecEndPos + 5.0f * dir;
} }
else else
{
break; break;
} }
}
if (result.flFraction == 1.0f) if (result.flFraction == 1.0f)
return true; return true;

View File

@ -827,11 +827,12 @@ bool CNavArea::MergeEdit(CNavArea *adj)
// check that these areas can be merged // check that these areas can be merged
const float tolerance = 1.0f; const float tolerance = 1.0f;
bool merge = false; bool merge = false;
if (abs(m_extent.lo.x - adj->m_extent.lo.x) < tolerance && abs(m_extent.hi.x - adj->m_extent.hi.x) < tolerance) if (Q_abs(m_extent.lo.x - adj->m_extent.lo.x) < tolerance &&
Q_abs(m_extent.hi.x - adj->m_extent.hi.x) < tolerance)
merge = true; merge = true;
if (abs(m_extent.lo.y - adj->m_extent.lo.y) < tolerance && if (Q_abs(m_extent.lo.y - adj->m_extent.lo.y) < tolerance &&
abs(m_extent.hi.y - adj->m_extent.hi.y) < tolerance) Q_abs(m_extent.hi.y - adj->m_extent.hi.y) < tolerance)
merge = true; merge = true;
if (merge == false) if (merge == false)
@ -2363,19 +2364,6 @@ void CNavArea::Draw(byte red, byte green, byte blue, int duration)
UTIL_DrawBeamPoints(down, left, duration, red, green, blue); UTIL_DrawBeamPoints(down, left, duration, red, green, blue);
UTIL_DrawBeamPoints(left, up, duration, red, green, blue); UTIL_DrawBeamPoints(left, up, duration, red, green, blue);
} }
if (GetAttributes() & NAV_WALK)
{
float size = 8.0f;
Vector up(m_center.x - size, m_center.y - size, m_center.z + cv_bot_nav_zdraw.value);
Vector down(m_center.x + size, m_center.y + size, m_center.z + cv_bot_nav_zdraw.value);
Vector left(m_center.x - size, m_center.y + size, m_center.z + cv_bot_nav_zdraw.value);
Vector right(m_center.x + size, m_center.y - size, m_center.z + cv_bot_nav_zdraw.value);
UTIL_DrawBeamPoints(up, right, duration, red, green, blue);
UTIL_DrawBeamPoints(right, down, duration, red, green, blue);
UTIL_DrawBeamPoints(down, left, duration, red, green, blue);
UTIL_DrawBeamPoints(left, up, duration, red, green, blue);
}
} }
// Draw selected corner for debugging // Draw selected corner for debugging
@ -3085,25 +3073,25 @@ void DrawDanger()
} }
// If a player is at the given spot, return true // If a player is at the given spot, return true
bool IsSpotOccupied(CBaseEntity *me, const Vector *pos) bool IsSpotOccupied(CBaseEntity *pEntity, const Vector *pos)
{ {
const float closeRange = 75.0f; const float closeRange = 75.0f;
// is there a player in this spot // is there a player in this spot
float range; float range;
CBasePlayer *player = UTIL_GetClosestPlayer(pos, &range); CBasePlayer *pClosest = UTIL_GetClosestPlayer(pos, &range);
if (player != me) if (pEntity != pClosest)
{ {
if (player && range < closeRange) if (pClosest && range < closeRange)
return true; return true;
} }
// is there is a hostage in this spot // is there is a hostage in this spot
if (g_pHostages) if (g_pHostages)
{ {
CHostage *hostage = g_pHostages->GetClosestHostage(*pos, &range); CHostage *pHostage = g_pHostages->GetClosestHostage(*pos, &range);
if (hostage && hostage != me && range < closeRange) if (pHostage && pEntity != pHostage && range < closeRange)
return true; return true;
} }
@ -3264,31 +3252,31 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea
// Return true if moving from "start" to "finish" will cross a player's line of fire // Return true if moving from "start" to "finish" will cross a player's line of fire
// The path from "start" to "finish" is assumed to be a straight line // The path from "start" to "finish" is assumed to be a straight line
// "start" and "finish" are assumed to be points on the ground // "start" and "finish" are assumed to be points on the ground
bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity *ignore, int ignoreTeam) bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity *pEntIgnore, int ignoreTeam)
{ {
for (int p = 1; p <= gpGlobals->maxClients; p++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(p); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!IsEntityValid(player)) if (!IsEntityValid(pPlayer))
continue; continue;
if (player == ignore) if (pPlayer == pEntIgnore)
continue; continue;
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
if (ignoreTeam && player->m_iTeam == ignoreTeam) if (ignoreTeam && pPlayer->m_iTeam == ignoreTeam)
continue; continue;
UTIL_MakeVectors(player->pev->v_angle + player->pev->punchangle); UTIL_MakeVectors(pPlayer->pev->v_angle + pPlayer->pev->punchangle);
const float longRange = 5000.0f; const float longRange = 5000.0f;
Vector playerTarget = player->pev->origin + longRange * gpGlobals->v_forward; Vector playerTarget = pPlayer->pev->origin + longRange * gpGlobals->v_forward;
Vector result; Vector result;
if (IsIntersecting2D(start, finish, player->pev->origin, playerTarget, &result)) if (IsIntersecting2D(start, finish, pPlayer->pev->origin, playerTarget, &result))
{ {
float loZ, hiZ; float loZ, hiZ;
if (start.z < finish.z) if (start.z < finish.z)
@ -3409,28 +3397,28 @@ const Vector *FindNearbyRetreatSpot(CBaseEntity *me, const Vector *start, CNavAr
// Return number of players with given teamID in this area (teamID == 0 means any/all) // Return number of players with given teamID in this area (teamID == 0 means any/all)
// TODO: Keep pointers to contained Players to make this a zero-time query // TODO: Keep pointers to contained Players to make this a zero-time query
int CNavArea::GetPlayerCount(int teamID, CBasePlayer *ignore) const int CNavArea::GetPlayerCount(int teamID, CBasePlayer *pEntIgnore) const
{ {
int nCount = 0; int nCount = 0;
for (int i = 1; i <= gpGlobals->maxClients; i++) for (int i = 1; i <= gpGlobals->maxClients; i++)
{ {
CBasePlayer *player = UTIL_PlayerByIndex(i); CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (player == ignore) if (pPlayer == pEntIgnore)
continue; continue;
if (!IsEntityValid(player)) if (!IsEntityValid(pPlayer))
continue; continue;
if (!player->IsPlayer()) if (!pPlayer->IsPlayer())
continue; continue;
if (!player->IsAlive()) if (!pPlayer->IsAlive())
continue; continue;
if (teamID == UNASSIGNED || player->m_iTeam == teamID) if (teamID == UNASSIGNED || pPlayer->m_iTeam == teamID)
{ {
if (Contains(&player->pev->origin)) if (Contains(&pPlayer->pev->origin))
nCount++; nCount++;
} }
} }
@ -3841,12 +3829,11 @@ void EditNavAreas(NavEditCmdType cmd)
} }
else else
{ {
Q_sprintf(attrib, "%s%s%s%s%s", Q_sprintf(attrib, "%s%s%s%s",
(area->GetAttributes() & NAV_CROUCH) ? "CROUCH " : "", (area->GetAttributes() & NAV_CROUCH) ? "CROUCH " : "",
(area->GetAttributes() & NAV_JUMP) ? "JUMP " : "", (area->GetAttributes() & NAV_JUMP) ? "JUMP " : "",
(area->GetAttributes() & NAV_PRECISE) ? "PRECISE " : "", (area->GetAttributes() & NAV_PRECISE) ? "PRECISE " : "",
(area->GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP " : "", (area->GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP " : "");
(area->GetAttributes() & NAV_WALK) ? "WALK " : "");
} }
Q_sprintf(buffer, "Area #%d %s %s\n", area->GetID(), locName, attrib); Q_sprintf(buffer, "Area #%d %s %s\n", area->GetID(), locName, attrib);
@ -3990,10 +3977,6 @@ void EditNavAreas(NavEditCmdType cmd)
EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100);
area->SetAttributes(area->GetAttributes() ^ NAV_PRECISE); area->SetAttributes(area->GetAttributes() ^ NAV_PRECISE);
break; break;
case EDIT_ATTRIB_WALK:
EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100);
area->SetAttributes(area->GetAttributes() ^ NAV_WALK);
break;
case EDIT_ATTRIB_NO_JUMP: case EDIT_ATTRIB_NO_JUMP:
EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100);
area->SetAttributes(area->GetAttributes() ^ NAV_NO_JUMP); area->SetAttributes(area->GetAttributes() ^ NAV_NO_JUMP);
@ -4314,11 +4297,10 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal)
UTIL_TraceLine(from, to, ignore_monsters, dont_ignore_glass, ignore, &result); UTIL_TraceLine(from, to, ignore_monsters, dont_ignore_glass, ignore, &result);
if (result.pHit) if (result.flFraction != 1.0f && result.pHit)
{ {
if (FClassnameIs(VARS(result.pHit), "func_door") // ignoring any entities that we can walk through
|| FClassnameIs(VARS(result.pHit), "func_door_rotating") if (IsEntityWalkable(VARS(result.pHit), WALK_THRU_DOORS | WALK_THRU_BREAKABLES))
|| (FClassnameIs(VARS(result.pHit), "func_breakable") && VARS(result.pHit)->takedamage == DAMAGE_YES))
{ {
ignore = result.pHit; ignore = result.pHit;
continue; continue;

View File

@ -50,7 +50,6 @@ enum NavEditCmdType
EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area
EDIT_ATTRIB_JUMP, // toggle jump attribute on current area EDIT_ATTRIB_JUMP, // toggle jump attribute on current area
EDIT_ATTRIB_PRECISE, // toggle precise attribute on current area EDIT_ATTRIB_PRECISE, // toggle precise attribute on current area
EDIT_ATTRIB_WALK, // toggle walk attribute on current area
EDIT_ATTRIB_NO_JUMP, // toggle inhibiting discontinuity jumping in current area EDIT_ATTRIB_NO_JUMP, // toggle inhibiting discontinuity jumping in current area
EDIT_BEGIN_AREA, // begin creating a new nav area EDIT_BEGIN_AREA, // begin creating a new nav area
EDIT_END_AREA, // end creation of the new nav area EDIT_END_AREA, // end creation of the new nav area
@ -635,7 +634,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa
// TODO: Cost might work as "manhattan distance" // TODO: Cost might work as "manhattan distance"
startArea->SetTotalCost((*startArea->GetCenter() - actualGoalPos).Length()); startArea->SetTotalCost((*startArea->GetCenter() - actualGoalPos).Length());
float_precision initCost = costFunc(startArea, nullptr, nullptr); real_t initCost = costFunc(startArea, nullptr, nullptr);
if (initCost < 0.0f) if (initCost < 0.0f)
return false; return false;
@ -781,7 +780,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa
if (newArea == area) if (newArea == area)
continue; continue;
float_precision newCostSoFar = costFunc(newArea, area, ladder); real_t newCostSoFar = costFunc(newArea, area, ladder);
// check if cost functor says this area is a dead-end // check if cost functor says this area is a dead-end
if (newCostSoFar < 0.0f) if (newCostSoFar < 0.0f)
@ -795,7 +794,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa
else else
{ {
// compute estimate of distance left to go // compute estimate of distance left to go
float_precision newCostRemaining = (*newArea->GetCenter() - actualGoalPos).Length(); real_t newCostRemaining = (*newArea->GetCenter() - actualGoalPos).Length();
// track closest area to goal in case path fails // track closest area to goal in case path fails
if (closestArea && newCostRemaining < closestAreaDist) if (closestArea && newCostRemaining < closestAreaDist)
@ -830,7 +829,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa
// Compute distance between two areas. Return -1 if can't reach 'endArea' from 'startArea'. // Compute distance between two areas. Return -1 if can't reach 'endArea' from 'startArea'.
template <typename CostFunctor> template <typename CostFunctor>
float_precision NavAreaTravelDistance(CNavArea *startArea, CNavArea *endArea, CostFunctor &costFunc) real_t NavAreaTravelDistance(CNavArea *startArea, CNavArea *endArea, CostFunctor &costFunc)
{ {
if (!startArea) if (!startArea)
return -1.0f; return -1.0f;
@ -846,7 +845,7 @@ float_precision NavAreaTravelDistance(CNavArea *startArea, CNavArea *endArea, Co
return -1.0f; return -1.0f;
// compute distance along path // compute distance along path
float_precision distance = 0.0f; real_t distance = 0.0f;
for (CNavArea *area = endArea; area->GetParent(); area = area->GetParent()) for (CNavArea *area = endArea; area->GetParent(); area = area->GetParent())
{ {
distance += (*area->GetCenter() - *area->GetParent()->GetCenter()).Length(); distance += (*area->GetCenter() - *area->GetParent()->GetCenter()).Length();
@ -863,7 +862,7 @@ float NavAreaTravelDistance(const Vector *startPos, CNavArea *startArea, const V
return -1.0f; return -1.0f;
// compute path between areas using given cost heuristic // compute path between areas using given cost heuristic
CNavArea *goalArea = NULL; CNavArea *goalArea = nullptr;
if (NavAreaBuildPath(startArea, TheNavAreaGrid.GetNearestNavArea(goalPos), goalPos, costFunc, &goalArea) == false) if (NavAreaBuildPath(startArea, TheNavAreaGrid.GetNearestNavArea(goalPos), goalPos, costFunc, &goalArea) == false)
return -1.0f; return -1.0f;

View File

@ -130,13 +130,12 @@ void CNavArea::Save(FILE *fp) const
fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.hi.y, m_swZ); fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.hi.y, m_swZ);
static int base = 1; static int base = 1;
fprintf(fp, "\n\ng %04dArea%s%s%s%s%s\n", m_id, fprintf(fp, "\n\ng %04dArea%s%s%s%s\n", m_id,
(GetAttributes() & NAV_CROUCH) ? "CROUCH" : "", (GetAttributes() & NAV_JUMP) ? "JUMP" : "", (GetAttributes() & NAV_CROUCH) ? "CROUCH" : "", (GetAttributes() & NAV_JUMP) ? "JUMP" : "",
(GetAttributes() & NAV_PRECISE) ? "PRECISE" : "", (GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP" : "", (GetAttributes() & NAV_PRECISE) ? "PRECISE" : "", (GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP" : "");
(GetAttributes() & NAV_WALK) ? "NAV_WALK" : "");
fprintf(fp, "f %d %d %d %d %d\n\n", base, base + 1, base + 2, base + 3, base + 4); fprintf(fp, "f %d %d %d %d\n\n", base, base + 1, base + 2, base + 3);
base += 5; base += 4;
} }
void CNavArea::Save(int fd, unsigned int version) void CNavArea::Save(int fd, unsigned int version)

View File

@ -42,9 +42,9 @@ const CNavNode *CNavNode::GetNode(const Vector *pos)
const float tolerance = 0.45f * GenerationStepSize; const float tolerance = 0.45f * GenerationStepSize;
for (const CNavNode *node = m_list; node; node = node->m_next) for (const CNavNode *node = m_list; node; node = node->m_next)
{ {
float dx = abs(node->m_pos.x - pos->x); float dx = Q_abs(node->m_pos.x - pos->x);
float dy = abs(node->m_pos.y - pos->y); float dy = Q_abs(node->m_pos.y - pos->y);
float dz = abs(node->m_pos.z - pos->z); float dz = Q_abs(node->m_pos.z - pos->z);
if (dx < tolerance && dy < tolerance && dz < tolerance) if (dx < tolerance && dy < tolerance && dz < tolerance)
return node; return node;

Some files were not shown because too many files have changed in this diff Show More