Skip to content

Commit

Permalink
Use custom assert instead normal
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Dec 13, 2023
1 parent db5cbee commit abe648b
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 72 deletions.
2 changes: 1 addition & 1 deletion regamedll/dlls/bot/cs_bot_pathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
if (IsOnLadder())
Jump(MUST_JUMP);

assert(m_pathIndex < m_pathLength);
Assert(m_pathIndex < m_pathLength);

// Check if reached the end of the path
bool nearEndOfPath = false;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/bot/states/cs_bot_idle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void IdleState::OnUpdate(CCSBot *me)
}
}

assert((0, "A CT bot doesn't know what to do while the bomb is planted!\n"));
DbgAssert(!"A CT bot doesn't know what to do while the bomb is planted!\n");
}

// if we have a sniper rifle, we like to camp, whether rogue or not
Expand Down
10 changes: 5 additions & 5 deletions regamedll/dlls/buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ void CBaseButton::ButtonActivate()
PlayLockSounds(pev, &m_ls, FALSE, TRUE);
}

assert(m_toggle_state == TS_AT_BOTTOM);
DbgAssert(m_toggle_state == TS_AT_BOTTOM);
m_toggle_state = TS_GOING_UP;

SetMoveDone(&CBaseButton::TriggerAndWait);
Expand All @@ -688,7 +688,7 @@ void CBaseButton::ButtonActivate()
// Button has reached the "in/up" position. Activate its "targets", and pause before "popping out".
void CBaseButton::TriggerAndWait()
{
assert(m_toggle_state == TS_GOING_UP);
DbgAssert(m_toggle_state == TS_GOING_UP);

if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
return;
Expand Down Expand Up @@ -724,7 +724,7 @@ void CBaseButton::TriggerAndWait()
// Starts the button moving "out/down".
void CBaseButton::ButtonReturn()
{
//assert(m_toggle_state == TS_AT_TOP);
DbgAssert(m_toggle_state == TS_AT_TOP);
m_toggle_state = TS_GOING_DOWN;

SetMoveDone(&CBaseButton::ButtonBackHome);
Expand Down Expand Up @@ -763,7 +763,7 @@ void CBaseButton::Restart()
// Button has returned to start state. Quiesce it.
void CBaseButton::ButtonBackHome()
{
assert(m_toggle_state == TS_GOING_DOWN);
DbgAssert(m_toggle_state == TS_GOING_DOWN);
m_toggle_state = TS_AT_BOTTOM;

if (pev->spawnflags & SF_BUTTON_TOGGLE
Expand Down Expand Up @@ -884,7 +884,7 @@ void CRotButton::Spawn()
m_vecAngle1 = pev->angles;
m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance;

assert(("rotating button start/end positions are equal", m_vecAngle1 != m_vecAngle2));
DbgAssertMsg(m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal");

m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE);
m_fRotating = TRUE;
Expand Down
14 changes: 7 additions & 7 deletions regamedll/dlls/doors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void CBaseDoor::Spawn()
// 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(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));
DbgAssertMsg(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal");

if (pev->spawnflags & SF_DOOR_START_OPEN)
{
Expand Down Expand Up @@ -494,7 +494,7 @@ void CBaseDoor::DoorGoUp()
bool isReversing = (m_toggle_state == TS_GOING_DOWN);

// It could be going-down, if blocked.
assert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);
DbgAssert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);

// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
// filter them out and leave a client stuck with looping door sounds!
Expand Down Expand Up @@ -634,7 +634,7 @@ void CBaseDoor::DoorHitTop()
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseArrived), VOL_NORM, ATTN_NORM);
}

assert(m_toggle_state == TS_GOING_UP);
DbgAssert(m_toggle_state == TS_GOING_UP);
m_toggle_state = TS_AT_TOP;

// toggle-doors don't come down automatically, they wait for refire.
Expand Down Expand Up @@ -696,7 +696,7 @@ void CBaseDoor::DoorGoDown()
}

#ifdef DOOR_ASSERT
assert(m_toggle_state == TS_AT_TOP);
DbgAssert(m_toggle_state == TS_AT_TOP);
#endif

m_toggle_state = TS_GOING_DOWN;
Expand Down Expand Up @@ -724,7 +724,7 @@ void CBaseDoor::DoorHitBottom()
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseArrived), VOL_NORM, ATTN_NORM);
}

assert(m_toggle_state == TS_GOING_DOWN);
DbgAssert(m_toggle_state == TS_GOING_DOWN);
m_toggle_state = TS_AT_BOTTOM;

// Re-instate touch method, cycle is complete
Expand Down Expand Up @@ -927,7 +927,7 @@ void CRotDoor::Spawn()
m_vecAngle1 = pev->angles;
m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance;

assert(("rotating door start/end positions are equal", m_vecAngle1 != m_vecAngle2));
DbgAssertMsg(m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal");

if (pev->spawnflags & SF_DOOR_PASSABLE)
pev->solid = SOLID_NOT;
Expand Down Expand Up @@ -1011,7 +1011,7 @@ void CMomentaryDoor::Spawn()

// 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(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));
DbgAssertMsg(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal");

if (pev->spawnflags & SF_DOOR_START_OPEN)
{
Expand Down
6 changes: 3 additions & 3 deletions regamedll/dlls/ehandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ inline int EntityHandle<T>::GetSerialNumber() const
template <typename T>
inline bool EntityHandle<T>::operator==(T *pEntity) const
{
assert(("EntityHandle<T>::operator==: got a nullptr pointer!", pEntity != nullptr));
DbgAssertMsg(pEntity != nullptr, "EntityHandle<T>::operator==: got a nullptr pointer!");

if (m_serialnumber != pEntity->edict()->serialnumber)
{
Expand Down Expand Up @@ -221,10 +221,10 @@ template <typename T>
inline T *EntityHandle<T>::operator->()
{
edict_t *pEdict = Get();
assert(("EntityHandle<T>::operator->: pointer is nullptr!", pEdict != nullptr));
DbgAssertMsg(pEdict != nullptr, "EntityHandle<T>::operator->: pointer is nullptr!");

T *pEntity = GET_PRIVATE<T>(pEdict);
assert(("EntityHandle<T>::operator->: pvPrivateData is nullptr!", pEntity != nullptr));
DbgAssertMsg(pEntity != nullptr, "EntityHandle<T>::operator->: pvPrivateData is nullptr!");
return pEntity;
}

Expand Down
6 changes: 3 additions & 3 deletions regamedll/dlls/func_tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ void CFuncTank::StopControl()

void CFuncTank::ControllerPostFrame()
{
assert(m_pController != nullptr);

if (gpGlobals->time < m_flNextAttack)
return;

Assert(m_pController != nullptr);

if (m_pController->pev->button & IN_ATTACK)
{
Vector vecForward;
Expand Down Expand Up @@ -879,7 +879,7 @@ void CFuncTankControls::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
}

// if this fails, most likely means save/restore hasn't worked properly
assert(m_pTank != nullptr);
DbgAssert(m_pTank != nullptr);
}

void CFuncTankControls::Think()
Expand Down
6 changes: 3 additions & 3 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4878,7 +4878,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(ChangeLevel)()

// find the map to change to
char *mapcfile = (char *)CVAR_GET_STRING("mapcyclefile");
assert(mapcfile != nullptr);
Assert(mapcfile != nullptr);

szCommands[0] = '\0';
szRules[0] = '\0';
Expand Down Expand Up @@ -4914,7 +4914,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(ChangeLevel)()
{
keeplooking = false;

assert(item != nullptr);
Assert(item != nullptr);

if (item->minplayers != 0)
{
Expand Down Expand Up @@ -5276,7 +5276,7 @@ int CHalfLifeMultiplay::GetRarityOfKill(CBaseEntity *pKiller, CBasePlayer *pVict
// That is done so that the domination and revenge will be calculated prior
// to the death message being sent to the clients
int iAttackerEntityIndex = pKillerPlayer->entindex();
assert(iAttackerEntityIndex > 0 && iAttackerEntityIndex <= MAX_CLIENTS);
Assert(iAttackerEntityIndex > 0 && iAttackerEntityIndex <= MAX_CLIENTS);

int iKillsUnanswered = pVictim->CSPlayer()->m_iNumKilledByUnanswered[iAttackerEntityIndex - 1] + 1;
if (iKillsUnanswered == CS_KILLS_FOR_DOMINATION || pKillerPlayer->CSPlayer()->IsPlayerDominated(pVictim->entindex() - 1))
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/pathcorner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void CPathCorner::KeyValue(KeyValueData *pkvd)

void CPathCorner::Spawn()
{
assert(("path_corner without a targetname", !pev->targetname.IsNull()));
DbgAssertMsg(!pev->targetname.IsNull(), "path_corner without a targetname");
}

TYPEDESCRIPTION CPathTrack::m_SaveData[] =
Expand Down
10 changes: 5 additions & 5 deletions regamedll/dlls/plats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void CFuncPlat::GoDown()
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement), m_volume, ATTN_NORM);
}

assert(m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP);
DbgAssert(m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP);
m_toggle_state = TS_GOING_DOWN;
SetMoveDone(&CFuncPlat::CallHitBottom);
LinearMove(m_vecPosition2, pev->speed);
Expand All @@ -401,7 +401,7 @@ void CFuncPlat::HitBottom()
EMIT_SOUND(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM);
}

assert(m_toggle_state == TS_GOING_DOWN);
DbgAssert(m_toggle_state == TS_GOING_DOWN);
m_toggle_state = TS_AT_BOTTOM;
}

Expand All @@ -413,7 +413,7 @@ void CFuncPlat::GoUp()
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement), m_volume, ATTN_NORM);
}

assert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);
DbgAssert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);
m_toggle_state = TS_GOING_UP;
SetMoveDone(&CFuncPlat::CallHitTop);
LinearMove(m_vecPosition1, pev->speed);
Expand All @@ -432,7 +432,7 @@ void CFuncPlat::HitTop()
EMIT_SOUND(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM);
}

assert(m_toggle_state == TS_GOING_UP);
DbgAssert(m_toggle_state == TS_GOING_UP);
m_toggle_state = TS_AT_TOP;

if (!IsTogglePlat())
Expand All @@ -456,7 +456,7 @@ void CFuncPlat::Blocked(CBaseEntity *pOther)
}

// Send the platform back where it came from
assert(m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN);
DbgAssert(m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN);

if (m_toggle_state == TS_GOING_UP)
{
Expand Down
9 changes: 0 additions & 9 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6504,8 +6504,6 @@ void EXT_FUNC CBasePlayer::__API_HOOK(ImpulseCommands)()
else
iOn = 0;

assert(gmsgLogo > 0);

MESSAGE_BEGIN(MSG_ONE, gmsgLogo, nullptr, pev);
WRITE_BYTE(iOn);
MESSAGE_END();
Expand Down Expand Up @@ -7143,9 +7141,6 @@ void CBasePlayer::SendAmmoUpdate()
{
m_rgAmmoLast[i] = m_rgAmmo[i];

assert(m_rgAmmo[i] >= 0);
assert(m_rgAmmo[i] <= 255);

// send "Ammo" update message
MESSAGE_BEGIN(MSG_ONE, gmsgAmmoX, nullptr, pev);
WRITE_BYTE(i);
Expand Down Expand Up @@ -7427,8 +7422,6 @@ void EXT_FUNC CBasePlayer::__API_HOOK(UpdateClientData)()
{
m_iClientBattery = int(pev->armorvalue);

assert(gmsgBattery > 0);

// send "armor" update message
MESSAGE_BEGIN(MSG_ONE, gmsgBattery, nullptr, pev);
WRITE_SHORT(int(pev->armorvalue));
Expand Down Expand Up @@ -7510,8 +7503,6 @@ void EXT_FUNC CBasePlayer::__API_HOOK(UpdateClientData)()

if (m_iTrain & TRAIN_NEW)
{
assert(gmsgTrain > 0);

// send "train hud" update message
MESSAGE_BEGIN(MSG_ONE, gmsgTrain, nullptr, pev);
WRITE_BYTE(m_iTrain & 0xF);
Expand Down
4 changes: 2 additions & 2 deletions regamedll/dlls/saverestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,10 @@ void CGlobalState::DumpGlobals()

void CGlobalState::EntityAdd(string_t globalname, string_t mapName, GLOBALESTATE state)
{
assert(!Find(globalname));
DbgAssert(!Find(globalname));

globalentity_t *pNewEntity = (globalentity_t *)calloc(sizeof(globalentity_t), 1);
assert(pNewEntity != nullptr);
DbgAssert(pNewEntity != nullptr);

pNewEntity->pNext = m_pList;
m_pList = pNewEntity;
Expand Down
8 changes: 4 additions & 4 deletions regamedll/dlls/subs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ void CBaseToggle::KeyValue(KeyValueData *pkvd)
// pev->origin traveling at flSpeed
void CBaseToggle::LinearMove(Vector vecDest, float flSpeed)
{
assert(("LinearMove: no speed is defined!", flSpeed != 0));
//assert(("LinearMove: no post-move function defined", m_pfnCallWhenMoveDone != nullptr));
DbgAssertMsg(flSpeed != 0, "LinearMove: no speed is defined!");
//DbgAssertMsg(m_pfnCallWhenMoveDone != nullptr, "LinearMove: no post-move function defined");

m_vecFinalDest = vecDest;

Expand Down Expand Up @@ -382,8 +382,8 @@ NOXREF BOOL CBaseToggle::IsLockedByMaster()
// Just like LinearMove, but rotational.
void CBaseToggle::AngularMove(Vector vecDestAngle, float flSpeed)
{
assert(("AngularMove: no speed is defined!", flSpeed != 0));
//assert(("AngularMove: no post-move function defined", m_pfnCallWhenMoveDone != nullptr));
DbgAssertMsg(flSpeed != 0, "AngularMove: no speed is defined!");
//DbgAssertMsg(m_pfnCallWhenMoveDone != nullptr, "AngularMove: no post-move function defined");

m_vecFinalAngle = vecDestAngle;

Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ void CTriggerMultiple::Spawn()

InitTrigger();

assert(("trigger_multiple with health", pev->health == 0));
DbgAssertMsg(pev->health == 0, "trigger_multiple with health");

//UTIL_SetOrigin(pev, pev->origin);
//SET_MODEL(ENT(pev), STRING(pev->model));
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname)
}

giAmmoIndex++;
assert(giAmmoIndex < MAX_AMMO_SLOTS);
DbgAssert(giAmmoIndex < MAX_AMMO_SLOTS);

if (giAmmoIndex >= MAX_AMMO_SLOTS)
giAmmoIndex = 1;
Expand Down
6 changes: 3 additions & 3 deletions regamedll/game_shared/bitvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ inline CBitVec<NUM_BITS> &CBitVec<NUM_BITS>::operator=(CBitVec<NUM_BITS> const &
template<int NUM_BITS>
inline CBitVecAccessor CBitVec<NUM_BITS>::operator[](int i)
{
assert(i >= 0 && i < GetNumBits());
DbgAssert(i >= 0 && i < GetNumBits());
return CBitVecAccessor(m_DWords, i);
}

Expand All @@ -152,13 +152,13 @@ inline bool CBitVec<NUM_BITS>::operator!=(CBitVec<NUM_BITS> const &other)
template<int NUM_BITS>
inline uint32 CBitVec<NUM_BITS>::GetDWord(int i)
{
assert(i >= 0 && i < NUM_DWORDS);
DbgAssert(i >= 0 && i < NUM_DWORDS);
return m_DWords[i];
}

template<int NUM_BITS>
inline void CBitVec<NUM_BITS>::SetDWord(int i, uint32 val)
{
assert(i >= 0 && i < NUM_DWORDS);
DbgAssert(i >= 0 && i < NUM_DWORDS);
m_DWords[i] = val;
}
Loading

0 comments on commit abe648b

Please sign in to comment.