diff --git a/.travis.yml b/.travis.yml
index e76699699..0a4166894 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,10 @@ branches:
- master
before_install: sudo apt-get update -qq
-install: sudo apt-get install -qq build-essential libsdl1.2debian libsdl-image1.2 libopenal1 libsdl1.2-dev libsdl-image1.2-dev libopenal-dev libvorbis-dev
+install:
+ - sudo apt-get install -qq build-essential libsdl1.2debian libsdl-image1.2 libopenal1 libsdl1.2-dev libsdl-image1.2-dev libopenal-dev libvorbis-dev
+ - sudo apt-get install -qq g++-4.8
+ - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
script: cd ./source/src; make all
notifications:
diff --git a/source/codeblocks/AssaultCube.cbp b/source/codeblocks/AssaultCube.cbp
index d6e996952..a277d7abb 100644
--- a/source/codeblocks/AssaultCube.cbp
+++ b/source/codeblocks/AssaultCube.cbp
@@ -25,6 +25,7 @@
+
diff --git a/source/src/Makefile b/source/src/Makefile
index e127f5ccb..eb447a4d6 100644
--- a/source/src/Makefile
+++ b/source/src/Makefile
@@ -1,6 +1,6 @@
DEBUG ?= 0
WARNINGS ?= 1
-override CXXFLAGS += -fsigned-char
+override CXXFLAGS += -fsigned-char --std=c++11
ifeq ($(DEBUG), 1)
override CXXFLAGS += -ggdb3 -D_DEBUG -Wextra
override WARNINGS = 1
diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp
index ca9b7ddfd..af396c8ea 100644
--- a/source/src/audiomanager.cpp
+++ b/source/src/audiomanager.cpp
@@ -6,14 +6,14 @@
VARF(audio, 0, 1, 1, initwarning("sound configuration", INIT_RESET, CHANGE_SOUND));
VARP(audiodebug, 0, 0, 1);
-char *musicdonecmd = NULL;
+char *musicdonecmd = nullptr;
VARFP(musicvol, 0, 128, 255, audiomgr.setmusicvol(musicvol));
// audio manager
audiomanager::audiomanager()
-: nosound(true), currentpitch(1.0f), device(NULL), context(NULL), gamemusic(NULL) {}
+: nosound(true), currentpitch(1.0f), device(nullptr), context(nullptr), gamemusic(nullptr) {}
void audiomanager::initsound()
{
@@ -24,19 +24,19 @@ void audiomanager::initsound()
}
nosound = true;
- device = NULL;
- context = NULL;
+ device = nullptr;
+ context = nullptr;
// list available devices
- if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
+ if(alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
{
- const ALCchar *devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
+ const ALCchar *devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
if(devices)
{
string d;
copystring(d, "Audio devices: ");
- // null separated device string
+ // nullptr separated device string
for(const ALchar *c = devices; c[strlen(c)+1]; c += strlen(c)+1)
{
if(c!=devices) concatstring(d, ", ");
@@ -48,11 +48,11 @@ void audiomanager::initsound()
// open device
const char *devicename = getalias("openaldevice");
- device = alcOpenDevice(devicename && devicename[0] ? devicename : NULL);
+ device = alcOpenDevice(devicename && devicename[0] ? devicename : nullptr);
if(device)
{
- context = alcCreateContext(device, NULL);
+ context = alcCreateContext(device, nullptr);
if(context)
{
alcMakeContextCurrent(context);
@@ -188,7 +188,7 @@ void audiomanager::registermusic(char *name)
musics.add(newstring(name));
}
-int audiomanager::findsound(char *name, int vol, vector &sounds)
+int audiomanager::findsound(char *name, int vol, vect &sounds)
{
loopv(sounds)
{
@@ -197,7 +197,7 @@ int audiomanager::findsound(char *name, int vol, vector &sounds)
return -1;
}
-int audiomanager::addsound(char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius)
+int audiomanager::addsound(char *name, int vol, int maxuses, bool loop, vect &sounds, bool load, int audibleradius)
{
if(nosound) return -1;
if(!soundvol) return -1;
@@ -271,7 +271,7 @@ void audiomanager::soundcleanup()
sourcescheduler::instance().reset();
// shutdown openal
- alcMakeContextCurrent(NULL);
+ alcMakeContextCurrent(nullptr);
if(context) alcDestroyContext(context);
if(device) alcCloseDevice(device);
}
@@ -363,7 +363,7 @@ void audiomanager::updateplayerfootsteps(playerent *p)
// manage looping sounds
location *audiomanager::updateloopsound(int sound, bool active, float vol)
{
- location *l = locations.find(sound, NULL, gamesounds);
+ location *l = locations.find(sound, nullptr, gamesounds);
if(!l && active) l = _playsound(sound, camerareference(), SP_HIGH, 0.0f, true);
else if(l && !active) l->drop();
if(l && vol != 1.0f) l->src->gain(vol);
@@ -430,7 +430,7 @@ COMMAND(soundtest, "");
// sound configuration
-soundconfig::soundconfig(sbuffer *b, int vol, int maxuses, bool loop, int audibleradius)
+soundconfig::soundconfig(sbuffer *b=nullptr, int vol=0, int maxuses=0, bool loop=false, int audibleradius=0)
{
buf = b;
this->vol = vol > 0 ? vol : 100;
@@ -452,7 +452,7 @@ void soundconfig::ondetach()
uses--;
}
-vector gamesounds, mapsounds;
+vect gamesounds, mapsounds;
void audiomanager::detachsounds(playerent *owner)
{
@@ -466,8 +466,8 @@ VARP(maxsoundsatonce, 0, 32, 100);
location *audiomanager::_playsound(int n, const worldobjreference &r, int priority, float offset, bool loop)
{
- if(nosound || !soundvol) return NULL;
- if(soundmuted(n)) return NULL;
+ if(nosound || !soundvol) return nullptr;
+ if(soundmuted(n)) return nullptr;
DEBUGVAR(n);
DEBUGVAR(priority);
@@ -480,7 +480,7 @@ location *audiomanager::_playsound(int n, const worldobjreference &r, int priori
if(maxsoundsatonce && soundsatonce>maxsoundsatonce)
{
DEBUGVAR(soundsatonce);
- return NULL;
+ return nullptr;
}
}
@@ -617,7 +617,7 @@ void audiomanager::updateaudio()
if(musicdonecmd)
{
char *cmd = musicdonecmd;
- musicdonecmd = NULL;
+ musicdonecmd = nullptr;
execute(cmd);
delete[] cmd;
}
diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp
index a2e6bd8c9..68f643eb9 100644
--- a/source/src/bot/ac_bot.cpp
+++ b/source/src/bot/ac_bot.cpp
@@ -37,7 +37,7 @@ void CACBot::Spawn()
m_iStrafeTime = m_iStrafeCheckDelay = 0;
m_iMoveDir = DIR_NONE;
- m_pPrevEnemy = NULL;
+ m_pPrevEnemy = nullptr;
m_iCombatNavTime = 0;
m_iSPMoveTime = 0;
m_iEnemySearchDelay = 0;
@@ -46,13 +46,13 @@ void CACBot::Spawn()
m_bShootAtFeet = (RandomLong(1, 100) <= m_pBotSkill->sShootAtFeetWithRLPercent);
m_iHuntDelay = 0;
m_vHuntLocation = m_vPrevHuntLocation = g_vecZero;
- m_pHuntTarget = NULL;
+ m_pHuntTarget = nullptr;
m_fPrevHuntDist = 0.0f;
m_iHuntLastTurnLessTime = m_iHuntPlayerUpdateTime = m_iHuntPauseTime = 0;
m_iLastJumpPad = 0;
- m_pTargetEnt = NULL;
- m_pTargetFlag = NULL;
+ m_pTargetEnt = nullptr;
+ m_pTargetFlag = nullptr;
m_iCheckTeleporterDelay = m_iCheckJumppadsDelay = 0;
m_iCheckEntsDelay = 0;
m_iCheckFlagsDelay = 0;
diff --git a/source/src/bot/ac_bot_ai.cpp b/source/src/bot/ac_bot_ai.cpp
index 56ef8f20f..647b6e2a1 100644
--- a/source/src/bot/ac_bot_ai.cpp
+++ b/source/src/bot/ac_bot_ai.cpp
@@ -144,8 +144,8 @@ entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight)
*/
float flDist;
- entity *pNewTargetEnt = NULL;
- waypoint_s *pWptNearBot = NULL, *pBestWpt = NULL;
+ entity *pNewTargetEnt = nullptr;
+ waypoint_s *pWptNearBot = nullptr, *pBestWpt = nullptr;
short sScore, sHighestScore = 0;
if ((WaypointClass.m_iWaypointCount >= 1) && bUseWPs)
@@ -228,7 +228,7 @@ entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight)
if (f > 100.0f) f = 100.0f;
sScore += ((100 - short(f)) / 2);
- waypoint_s *pWptNearEnt = NULL;
+ waypoint_s *pWptNearEnt = nullptr;
// If this entity isn't visible check if there is a nearby waypoint
if (!IsReachable(o, flMaxHeight))//(!IsVisible(o))
{
@@ -245,7 +245,7 @@ entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight)
}
// Score on visibility
- if (pWptNearEnt == NULL) // Ent is visible
+ if (pWptNearEnt == nullptr) // Ent is visible
sScore += 30;
else
sScore += 15;
@@ -256,7 +256,7 @@ entity *CACBot::SearchForEnts(bool bUseWPs, float flRange, float flMaxHeight)
if (pWptNearEnt)
pBestWpt = pWptNearEnt;
else
- pBestWpt = NULL; // Best ent so far doesn't need any waypoints
+ pBestWpt = nullptr; // Best ent so far doesn't need any waypoints
sHighestScore = sScore;
pNewTargetEnt = &ents[i];
@@ -288,8 +288,8 @@ entity *CACBot::SearchForFlags(bool bUseWPs, float flRange, float flMaxHeight)
- Distance
*/
float flDist;
- entity *pNewTargetFlag = NULL;
- waypoint_s *pWptNearBot = NULL, *pBestWpt = NULL;
+ entity *pNewTargetFlag = nullptr;
+ waypoint_s *pWptNearBot = nullptr, *pBestWpt = nullptr;
short sScore, sHighestScore = 0;
vec vNewGoal = g_vecZero;
@@ -327,7 +327,7 @@ entity *CACBot::SearchForFlags(bool bUseWPs, float flRange, float flMaxHeight)
if (ff > 100.0f) ff = 100.0f;
sScore += ((100 - short(ff)) / 2);
- waypoint_s *pWptNearEnt = NULL;
+ waypoint_s *pWptNearEnt = nullptr;
// If this flag entity isn't visible check if there is a nearby waypoint
if (!IsReachable(o, flMaxHeight))//(!IsVisible(o))
{
@@ -344,7 +344,7 @@ entity *CACBot::SearchForFlags(bool bUseWPs, float flRange, float flMaxHeight)
}
// Score on visibility
- if (pWptNearEnt == NULL) // Ent is visible
+ if (pWptNearEnt == nullptr) // Ent is visible
sScore += 6;
else
sScore += 3;
@@ -352,7 +352,7 @@ entity *CACBot::SearchForFlags(bool bUseWPs, float flRange, float flMaxHeight)
if(sScore > sHighestScore)
{
if (pWptNearEnt) pBestWpt = pWptNearEnt;
- else pBestWpt = NULL; // best flag doesn't need any waypoints
+ else pBestWpt = nullptr; // best flag doesn't need any waypoints
vNewGoal = o;
pNewTargetFlag = &e;
diff --git a/source/src/bot/bot.cpp b/source/src/bot/bot.cpp
index 5066c02c0..0c9228e11 100644
--- a/source/src/bot/bot.cpp
+++ b/source/src/bot/bot.cpp
@@ -71,7 +71,7 @@ void CBot::Spawn()
// Init all bot variables
m_pMyEnt->targetyaw = m_pMyEnt->targetpitch = 0.0f;
- m_pMyEnt->enemy = NULL;
+ m_pMyEnt->enemy = nullptr;
m_pMyEnt->maxspeed = 22.0f;
m_pMyEnt->pBot = this;
@@ -85,7 +85,7 @@ void CBot::Spawn()
m_iStrafeTime = m_iStrafeCheckDelay = 0;
m_iMoveDir = DIR_NONE;
- m_pPrevEnemy = NULL;
+ m_pPrevEnemy = nullptr;
m_iCombatNavTime = 0;
m_iSPMoveTime = 0;
m_iEnemySearchDelay = 0;
@@ -95,7 +95,7 @@ void CBot::Spawn()
m_bShootAtFeet = (RandomLong(1, 100) <= m_pBotSkill->sShootAtFeetWithRLPercent);
m_iHuntDelay = 0;
m_vHuntLocation = m_vPrevHuntLocation = g_vecZero;
- m_pHuntTarget = NULL;
+ m_pHuntTarget = nullptr;
m_fPrevHuntDist = 0.0f;
m_iHuntLastTurnLessTime = m_iHuntPlayerUpdateTime = m_iHuntPauseTime = 0;
m_iLookAroundDelay = m_iLookAroundTime = m_iLookAroundUpdateTime = 0;
@@ -103,8 +103,8 @@ void CBot::Spawn()
m_bLookLeft = false;
m_iLastJumpPad = 0;
- m_pTargetEnt = NULL;
- m_pTargetFlag = NULL;
+ m_pTargetEnt = nullptr;
+ m_pTargetFlag = nullptr;
while(!m_UnreachableEnts.Empty()) delete m_UnreachableEnts.Pop();
m_iCheckTeleporterDelay = m_iCheckJumppadsDelay = 0;
m_iCheckEntsDelay = 0;
@@ -309,7 +309,7 @@ bool CBot::SelectGun(int Gun)
bool CBot::IsVisible(entity *e, bool CheckPlayers)
{
vec v(e->x, e->y, e->z);
- return ::IsVisible(m_pMyEnt->o, v, (CheckPlayers) ? m_pMyEnt : NULL);
+ return ::IsVisible(m_pMyEnt->o, v, (CheckPlayers) ? m_pMyEnt : nullptr);
}
bool CBot::IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist)
@@ -394,23 +394,23 @@ void CBot::ResetCurrentTask()
switch (m_eCurrentBotState)
{
case STATE_ENEMY:
- m_pMyEnt->enemy = NULL;
- m_pTargetEnt = NULL;
+ m_pMyEnt->enemy = nullptr;
+ m_pTargetEnt = nullptr;
m_iCombatNavTime = m_iMoveDir = 0;
m_bCombatJump = false;
m_vGoal = g_vecZero;
break;
case STATE_FLAG:
- m_pTargetFlag = NULL;
+ m_pTargetFlag = nullptr;
m_vGoal = g_vecZero;
break;
case STATE_ENT:
- m_pTargetEnt = NULL;
+ m_pTargetEnt = nullptr;
m_vGoal = g_vecZero;
break;
case STATE_SP:
m_iSPMoveTime = m_iMoveDir = 0;
- m_pTargetEnt = NULL;
+ m_pTargetEnt = nullptr;
m_vGoal = g_vecZero;
break;
case STATE_NORMAL:
diff --git a/source/src/bot/bot.h b/source/src/bot/bot.h
index 26f35a6a7..5cd3886fb 100644
--- a/source/src/bot/bot.h
+++ b/source/src/bot/bot.h
@@ -258,12 +258,12 @@ class CBot
void CheckFOV(void);
bool IsVisible(const vec &o, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, o,
(CheckPlayers) ? m_pMyEnt :
- NULL); };
+ nullptr); };
bool IsVisible(playerent *d, bool CheckPlayers = false) { return ::IsVisible(m_pMyEnt->o, d->o,
(CheckPlayers) ?
- m_pMyEnt : NULL); };
+ m_pMyEnt : nullptr); };
bool IsVisible(entity *e, bool CheckPlayers = false);
- bool IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist = NULL);
+ bool IsVisible(vec o, int Dir, float flDist, bool CheckPlayers, float *pEndDist = nullptr);
bool IsVisible(int Dir, float flDist, bool CheckPlayers)
{ return IsVisible(m_pMyEnt->o, Dir, flDist, CheckPlayers); };
bool IsInFOV(const vec &o);
diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp
index 3acb19421..1b9e4ba3b 100644
--- a/source/src/bot/bot_ai.cpp
+++ b/source/src/bot/bot_ai.cpp
@@ -30,7 +30,7 @@ vec CBot::GetEnemyPos(playerent *d)
vec end = o;
end.z -= 900.0f;
traceresult_s tr;
- TraceLine(o, end, NULL, false, &tr);
+ TraceLine(o, end, nullptr, false, &tr);
if ((o.z - tr.end.z) < 8.0f)
{
end = o;
@@ -122,13 +122,13 @@ bool CBot::FindEnemy(void)
// UNDONE: Enemies are now only scored on their distance
if(BotsAgainstHumans())
{
- m_pMyEnt->enemy = NULL;
+ m_pMyEnt->enemy = nullptr;
if(player1->state == CS_ALIVE)
{
m_pMyEnt->enemy = player1;
}
- return m_pMyEnt->enemy != NULL;
+ return m_pMyEnt->enemy != nullptr;
}
if (m_pMyEnt->enemy) // Bot already has an enemy
@@ -145,19 +145,19 @@ bool CBot::FindEnemy(void)
m_pPrevEnemy = m_pMyEnt->enemy;
}
else
- m_pMyEnt->enemy = NULL;
+ m_pMyEnt->enemy = nullptr;
}
- if (m_iEnemySearchDelay > lastmillis) return (m_pMyEnt->enemy!=NULL);
+ if (m_iEnemySearchDelay > lastmillis) return (m_pMyEnt->enemy!=nullptr);
- m_pMyEnt->enemy = NULL;
+ m_pMyEnt->enemy = nullptr;
// Add enemy searchy delay
float MinDelay = m_pBotSkill->flMinEnemySearchDelay;
float MaxDelay = m_pBotSkill->flMaxEnemySearchDelay;
m_iEnemySearchDelay = lastmillis + int(RandomFloat(MinDelay, MaxDelay) * 1000.0f);
- playerent *pNewEnemy = NULL, *d = NULL;
+ playerent *pNewEnemy = nullptr, *d = nullptr;
float flDist, flNearestDist = 99999.9f;
short EnemyVal, BestEnemyVal = -100;
@@ -251,21 +251,21 @@ bool CBot::CheckHunt(void)
return true;
}
else
- m_pHuntTarget = NULL;
+ m_pHuntTarget = nullptr;
}
- if (m_iHuntDelay > lastmillis) return (m_pHuntTarget!=NULL);
+ if (m_iHuntDelay > lastmillis) return (m_pHuntTarget!=nullptr);
if (m_vHuntLocation!=g_vecZero)
m_vPrevHuntLocation = m_vHuntLocation;
- m_pHuntTarget = NULL;
+ m_pHuntTarget = nullptr;
m_vHuntLocation = g_vecZero;
// Add enemy hunt search delay
m_iHuntDelay = lastmillis + 1500;
- playerent *pNewEnemy = NULL, *d = NULL;
+ playerent *pNewEnemy = nullptr, *d = nullptr;
float flDist, flNearestDist = 99999.9f, flNearestOldPosDistToEnemy = 99999.9f;
float flNearestOldPosDistToBot = 99999.9f;
short EnemyVal, BestEnemyVal = -100;
@@ -526,7 +526,7 @@ bool CBot::HuntEnemy(void)
{
if (bDone || !IsReachable(m_vHuntLocation))
{
- m_pHuntTarget = NULL;
+ m_pHuntTarget = nullptr;
m_vPrevHuntLocation = m_vHuntLocation;
m_vHuntLocation = g_vecZero;
m_fPrevHuntDist = 0.0f;
@@ -625,7 +625,7 @@ bool CBot::HuntEnemy(void)
if (bToHigh)
{
- m_pHuntTarget = NULL;
+ m_pHuntTarget = nullptr;
m_vPrevHuntLocation = m_vHuntLocation;
m_vHuntLocation = g_vecZero;
m_fPrevHuntDist = 0.0f;
@@ -640,7 +640,7 @@ bool CBot::HuntEnemy(void)
void CBot::CheckWeaponSwitch()
{
- if(m_pMyEnt->nextweaponsel == NULL) m_pMyEnt->weaponchanging = 0;
+ if(m_pMyEnt->nextweaponsel == nullptr) m_pMyEnt->weaponchanging = 0;
if(!m_pMyEnt->weaponchanging) return;
int timeprogress = lastmillis-m_pMyEnt->weaponchanging;
@@ -813,7 +813,7 @@ void CBot::MainAI()
else m_pMyEnt->trycrouch = false;
if (!BotManager.BotsShoot() && m_pMyEnt->enemy)
- m_pMyEnt->enemy = NULL; // Clear enemy when bots may not shoot
+ m_pMyEnt->enemy = nullptr; // Clear enemy when bots may not shoot
if (m_bGoToDebugGoal) // For debugging the waypoint navigation
{
@@ -1025,7 +1025,7 @@ void CBot::DoCombatNav()
vec v(m_pTargetEnt->x, m_pTargetEnt->y,
S(m_pTargetEnt->x, m_pTargetEnt->y)->floor+m_pMyEnt->eyeheight);
if ((GetDistance(v) > 25.0f) || !IsVisible(m_pTargetEnt))
- m_pTargetEnt = NULL;
+ m_pTargetEnt = nullptr;
}
if (!m_pTargetEnt && (m_iCheckEntsDelay <= lastmillis))
@@ -1831,7 +1831,7 @@ bool CBot::WaterNav()
}
traceresult_s tr;
- TraceLine(v, v2, NULL, false, &tr);
+ TraceLine(v, v2, nullptr, false, &tr);
if (tr.collided)
{
small_=true;
@@ -1886,7 +1886,7 @@ bool CBot::CheckItems()
}
if (m_vGoal==g_vecZero)
- m_pTargetEnt = NULL;
+ m_pTargetEnt = nullptr;
if (!m_pTargetEnt)
{
@@ -1909,7 +1909,7 @@ bool CBot::CheckItems()
{
ResetWaypointVars();
m_vGoal = g_vecZero;
- m_pTargetEnt = NULL;
+ m_pTargetEnt = nullptr;
}
return false;
@@ -1927,7 +1927,7 @@ bool CBot::CheckFlags()
}
if (m_vGoal==g_vecZero)
- m_pTargetFlag = NULL;
+ m_pTargetFlag = nullptr;
if (!m_pTargetFlag || m_iCheckFlagsDelay <= lastmillis)
{
@@ -1950,7 +1950,7 @@ bool CBot::CheckFlags()
{
ResetWaypointVars();
m_vGoal = g_vecZero;
- m_pTargetFlag = NULL;
+ m_pTargetFlag = nullptr;
}
return false;
@@ -2008,7 +2008,7 @@ bool CBot::IsReachable(vec to, float flMaxHeight)
v_new_dest.z = v_new_dest.z - (JUMP_HEIGHT + 1.0f);
// check if we didn't hit anything, if so then it's in mid-air
- if (::IsVisible(v_new_src, v_new_dest, NULL))
+ if (::IsVisible(v_new_src, v_new_dest, nullptr))
{
condebug("to is in midair");
debugbeam(from, to);
@@ -2028,7 +2028,7 @@ bool CBot::IsReachable(vec to, float flMaxHeight)
v_down.z = v_down.z - 100.0f; // straight down
- TraceLine(v_check, v_down, NULL, false, &tr);
+ TraceLine(v_check, v_down, nullptr, false, &tr);
// height from ground
last_height = GetDistance(v_check, tr.end);
@@ -2045,7 +2045,7 @@ bool CBot::IsReachable(vec to, float flMaxHeight)
v_down = v_check;
v_down.z = v_down.z - 100.0f;
- TraceLine(v_check, v_down, NULL, false, &tr);
+ TraceLine(v_check, v_down, nullptr, false, &tr);
curr_height = GetDistance(v_check, tr.end);
@@ -2088,7 +2088,7 @@ void CBot::HearSound(int n, const vec *o)
// Look who made the sound(check for the nearest enemy)
float flDist, flNearestDist = 3.0f; // Range of 3 units
- playerent *pNearest = NULL;
+ playerent *pNearest = nullptr;
// Check all players first
loopv(players)
diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp
index 4c7749c2e..03e5252d5 100644
--- a/source/src/bot/bot_util.cpp
+++ b/source/src/bot/bot_util.cpp
@@ -324,7 +324,7 @@ float Get2DDistance(vec v1, vec v2)
bool IsVisible(vec v1, vec v2, dynent *tracer, bool SkipTags)
{
traceresult_s tr;
- TraceLine(v1, v2, tracer, (tracer!=NULL), &tr, SkipTags);
+ TraceLine(v1, v2, tracer, (tracer!=nullptr), &tr, SkipTags);
return !tr.collided;
}
@@ -459,7 +459,7 @@ const char *SkillNrToSkillName(short skillnr)
else if (skillnr == 3) return "worse";
else if (skillnr == 4) return "bad";
- return NULL;
+ return nullptr;
}
bool IsInGame(dynent *d)
diff --git a/source/src/bot/bot_util.h b/source/src/bot/bot_util.h
index 2a50f5637..e0991873e 100644
--- a/source/src/bot/bot_util.h
+++ b/source/src/bot/bot_util.h
@@ -11,7 +11,7 @@ float WrapYZAngle(float angle);
float GetDistance(vec v1, vec v2);
float Get2DDistance(vec v1, vec v2);
-bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false);
+bool IsVisible(vec v1, vec v2, dynent *tracer = nullptr, bool SkipTags=false);
bool IsValidFile(const char *szFileName);
bool FileIsOlder(const char *szFileName1, const char *szFileName2);
vec PredictPos(vec pos, vec vel, float Time);
@@ -40,7 +40,7 @@ template class TLinkedList
node_s *next;
node_s *prev;
- node_s(void) : next(NULL), prev(NULL)
+ node_s(void) : next(nullptr), prev(nullptr)
{
//memset(&Entry, 0, sizeof(Entry));
};
@@ -54,8 +54,8 @@ template class TLinkedList
{
pNodeList = new node_s;
pNodeList->Entry = entry;
- pNodeList->next = NULL;
- pNodeList->prev = NULL;
+ pNodeList->next = nullptr;
+ pNodeList->prev = nullptr;
pLastNode = pNodeList;
iNodeCount = 1;
}
@@ -65,7 +65,7 @@ template class TLinkedList
pLastNode->next->prev = pLastNode;
pLastNode = pLastNode->next;
pLastNode->Entry = entry;
- pLastNode->next = NULL;
+ pLastNode->next = nullptr;
iNodeCount++;
}
}
@@ -76,8 +76,8 @@ template class TLinkedList
{
pNodeList = new node_s;
pNodeList->Entry = Entry;
- pNodeList->next = NULL;
- pNodeList->prev = NULL;
+ pNodeList->next = nullptr;
+ pNodeList->prev = nullptr;
pLastNode = pNodeList;
iNodeCount = 1;
}
@@ -85,7 +85,7 @@ template class TLinkedList
{
node_s *pNew = new node_s;
pNew->Entry = Entry;
- pNew->prev = NULL;
+ pNew->prev = nullptr;
pNew->next = pNodeList;
pNodeList->prev = pNew;
pNodeList = pNew;
@@ -102,14 +102,14 @@ template class TLinkedList
if (pNode->Entry == Entry) // first node
{
if (pNodeList == pLastNode)
- pLastNode = NULL;
+ pLastNode = nullptr;
pNodeList = pNodeList->next;
if (pNodeList)
- pNodeList->prev = NULL;
- pNode->next = NULL;
+ pNodeList->prev = nullptr;
+ pNode->next = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
return;
}
@@ -118,12 +118,12 @@ template class TLinkedList
{
pNode = pLastNode;
pLastNode = pLastNode->prev;
- pLastNode->next = NULL;
+ pLastNode->next = nullptr;
- pNode->next = NULL;
- pNode->prev = NULL;
+ pNode->next = nullptr;
+ pNode->prev = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
return;
}
@@ -143,10 +143,10 @@ template class TLinkedList
pNode->next->prev = pPrevNode;
pPrevNode->next = pNode->next;
- pNode->next = NULL;
- pNode->prev = NULL;
+ pNode->next = nullptr;
+ pNode->prev = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
}
@@ -162,10 +162,10 @@ template class TLinkedList
pNodeList = pNodeList->next;
if (pNodeList)
- pNodeList->prev = NULL;
- pNode->next = NULL;
+ pNodeList->prev = nullptr;
+ pNode->next = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
return;
}
@@ -174,12 +174,12 @@ template class TLinkedList
{
pNode = pLastNode;
pLastNode = pLastNode->prev;
- pLastNode->next = NULL;
+ pLastNode->next = nullptr;
- pNode->next = NULL;
- pNode->prev = NULL;
+ pNode->next = nullptr;
+ pNode->prev = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
return;
}
@@ -195,10 +195,10 @@ template class TLinkedList
pNode->next->prev = pPrevNode;
pPrevNode->next = pNode->next;
- pNode->next = NULL;
- pNode->prev = NULL;
+ pNode->next = nullptr;
+ pNode->prev = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
}
@@ -206,21 +206,21 @@ template class TLinkedList
{
node_s *pNode = pNodeList;
node_s *pTemp;
- while (pNode != NULL)
+ while (pNode != nullptr)
{
pTemp = pNode;
pNode = pNode->next;
- pTemp->next = NULL;
- pTemp->prev = NULL;
+ pTemp->next = nullptr;
+ pTemp->prev = nullptr;
delete pTemp;
}
- pNodeList = pLastNode = NULL;
+ pNodeList = pLastNode = nullptr;
iNodeCount = 0;
}
void Reset(void) // Special case, doesn't delete existing nodes
{
- pNodeList = pLastNode = NULL;
+ pNodeList = pLastNode = nullptr;
iNodeCount = 0;
}
@@ -233,13 +233,13 @@ template class TLinkedList
return pNode;
pNode = pNode->next;
}
- return NULL;
+ return nullptr;
}
C Pop(void)
{
if (!pNodeList)
- return static_cast(NULL);
+ return static_cast(nullptr);
C Entry = pNodeList->Entry;
DeleteNode(pNodeList);
@@ -261,18 +261,18 @@ template class TLinkedList
bool IsInList(C Entry)
{
- return (SearchNode(Entry) != NULL);
+ return (SearchNode(Entry) != nullptr);
}
- bool Empty(void) { return (pNodeList == NULL); };
+ bool Empty(void) { return (pNodeList == nullptr); };
int NodeCount(void) { return iNodeCount; };
// construction/destruction
TLinkedList(void)
{
- pNodeList = NULL;
- pLastNode = NULL;
+ pNodeList = nullptr;
+ pLastNode = nullptr;
iNodeCount = 0;
};
@@ -305,10 +305,10 @@ template class TPriorList
D Priority;
node_s *next;
- node_s(C Ent, D Prior) : Entry(Ent), Priority(Prior), next(NULL) {};
+ node_s(C Ent, D Prior) : Entry(Ent), Priority(Prior), next(nullptr) {};
};
- TPriorList(void) : pHeadNode(NULL), pLastNode(NULL) {};
+ TPriorList(void) : pHeadNode(nullptr), pLastNode(nullptr) {};
~TPriorList(void) { Clear(); };
void AddEntry(C Entry, D Prior)
@@ -324,7 +324,7 @@ template class TPriorList
iNodeCount++;
node_s *pNew = new node_s(Entry, Prior);
node_s *pNode = pHeadNode;
- node_s *pPrev = NULL;
+ node_s *pPrev = nullptr;
while(pNode)
{
@@ -358,7 +358,7 @@ template class TPriorList
C Pop(void)
{
if (!pHeadNode)
- return static_cast(NULL);
+ return static_cast(nullptr);
C Entry = pHeadNode->Entry;
DeleteNode(pHeadNode);
@@ -375,7 +375,7 @@ template class TPriorList
delete pTemp;
}
- pHeadNode = pLastNode = NULL;
+ pHeadNode = pLastNode = nullptr;
}
bool IsInList(C Entry, D Prior)
@@ -395,7 +395,7 @@ template class TPriorList
return false;
}
- bool Empty(void) { return (pHeadNode == NULL); }
+ bool Empty(void) { return (pHeadNode == nullptr); }
node_s *GetFirst(void) { return pHeadNode; }
private:
node_s *pHeadNode;
@@ -412,7 +412,7 @@ template class TPriorList
pTemp = pTemp->next;
}
- return NULL;
+ return nullptr;
}
void DeleteNode(node_s *pNode)
@@ -426,9 +426,9 @@ template class TPriorList
pLastNode = pHeadNode->next;
pHeadNode = pHeadNode->next;
- pNode->next = NULL;
+ pNode->next = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
return;
}
@@ -436,11 +436,11 @@ template class TPriorList
if (pNode == pLastNode) // last node
{
pNode = pLastNode;
- pLastNode->next = NULL;
+ pLastNode->next = nullptr;
- pNode->next = NULL;
+ pNode->next = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
return;
}
@@ -453,9 +453,9 @@ template class TPriorList
// unlink pNode
pPrevNode->next = pNode->next;
- pNode->next = NULL;
+ pNode->next = nullptr;
delete pNode;
- pNode = NULL;
+ pNode = nullptr;
iNodeCount--;
}
};
@@ -499,7 +499,7 @@ template class TMultiChoice
break;
}
delete pChoiceList;
- pChoiceList = NULL;
+ pChoiceList = nullptr;
}
void Insert(C Choice, short Percent = 50)
diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp
index 8cdb5f77b..52b4cc4d2 100644
--- a/source/src/bot/bot_waypoint.cpp
+++ b/source/src/bot/bot_waypoint.cpp
@@ -21,7 +21,7 @@ CCubeWaypointClass WaypointClass;
VAR(xhairwpsel, 0, 1, 1);
// FIXME: multiple selections support ?
// well, TBH I haven't groked this myself yet, but the following curselection segfaults the client, so I'm just putting in a sane-variant until someone groks it ;-) - ft 2011sep28
-extern vector sels;
+extern vect sels;
//#define curselection (xhairwpsel ? vec(sels.last().x, sels.last().y, S(sels.last().x, sels.last().y)->floor+2.0f) : vec(player1->o.x, player1->o.y, player1->o.z))
#define curselection (vec(player1->o.x, player1->o.y, player1->o.z))
@@ -107,7 +107,7 @@ bool CWaypointClass::LoadWaypoints()
BotManager.m_sCurrentTriggerNr = -1;
// if file exists, read the waypoint structure from it
- if (bfp != NULL)
+ if (bfp != nullptr)
{
bfp->read(&header, sizeof(header));
@@ -156,7 +156,7 @@ bool CWaypointClass::LoadWaypoints()
if (!pCurrent)
{
- conoutf("Error: NULL path in waypoint file");
+ conoutf("Error: nullptr path in waypoint file");
continue;
}
@@ -169,7 +169,7 @@ bool CWaypointClass::LoadWaypoints()
if (!pTo)
{
- conoutf("Error: NULL path in waypoint file");
+ conoutf("Error: nullptr path in waypoint file");
continue;
}
@@ -218,7 +218,7 @@ bool CWaypointClass::LoadWaypoints()
if (!pCurrent)
{
- conoutf("Error: NULL path in waypoint file");
+ conoutf("Error: nullptr path in waypoint file");
for(j=0;jread(&to, sizeof(to)); // Read rest of block
continue;
@@ -357,7 +357,7 @@ void CWaypointClass::SaveWaypoints()
bfp->write(&p->Entry->v_origin, sizeof(p->Entry->v_origin)); // write the origin of this path
// now write out each path...
- while (pPath != NULL)
+ while (pPath != nullptr)
{
bfp->write(&pPath->Entry->v_origin, sizeof(pPath->Entry->v_origin));
pPath = pPath->next; // go to next node in linked list
@@ -391,7 +391,7 @@ bool CWaypointClass::LoadWPExpFile()
bfp = fopen(filename, "rb");
// if file exists, read the waypoint structure from it
- if (bfp != NULL)
+ if (bfp != nullptr)
{
fread(&header, sizeof(header), 1, bfp);
@@ -417,7 +417,7 @@ bool CWaypointClass::LoadWPExpFile()
if (!pCurrent)
{
- conoutf("Error: NULL node in waypoint experience file");
+ conoutf("Error: nullptr node in waypoint experience file");
continue;
}
@@ -532,7 +532,7 @@ void CWaypointClass::SaveWPExpFile()
fwrite(&num, sizeof(num), 1, bfp); // write the count
fwrite(&p->Entry->v_origin, sizeof(vec), 1, bfp); // write the origin of this node
- while (p2 != NULL)
+ while (p2 != nullptr)
{
// Write out the node which a bot can't reach with the current node
fwrite(&p2->Entry->v_origin, sizeof(vec), 1, bfp);
@@ -628,7 +628,7 @@ void CWaypointClass::DrawNearWaypoints()
glDisable(GL_CULL_FACE);
TLinkedList::node_s *pNode;
- node_s *pNearest = NULL;
+ node_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceilf(15.0f / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -902,8 +902,8 @@ void CWaypointClass::DeletePath(node_s *pWP1, node_s *pWP2)
void CWaypointClass::ManuallyCreatePath(vec v_src, int iCmd, bool TwoWay)
{
- static node_s *waypoint1 = NULL; // initialized to unassigned
- static node_s *waypoint2 = NULL; // initialized to unassigned
+ static node_s *waypoint1 = nullptr; // initialized to unassigned
+ static node_s *waypoint2 = nullptr; // initialized to unassigned
if (iCmd == 1) // assign source of path
{
@@ -943,8 +943,8 @@ void CWaypointClass::ManuallyCreatePath(vec v_src, int iCmd, bool TwoWay)
void CWaypointClass::ManuallyDeletePath(vec v_src, int iCmd, bool TwoWay)
{
- static node_s *waypoint1 = NULL; // initialized to unassigned
- static node_s *waypoint2 = NULL; // initialized to unassigned
+ static node_s *waypoint1 = nullptr; // initialized to unassigned
+ static node_s *waypoint2 = nullptr; // initialized to unassigned
if (iCmd == 1) // assign source of path
{
@@ -1008,7 +1008,7 @@ bool CWaypointClass::WPIsReachable(vec from, vec to)
v_new_dest.z = v_new_dest.z - (JUMP_HEIGHT + 1.0f);
// check if we didn't hit anything, if so then it's in mid-air
- if (::IsVisible(v_new_src, v_new_dest, NULL))
+ if (::IsVisible(v_new_src, v_new_dest, nullptr))
{
conoutf("to is in midair");
debugbeam(from, to);
@@ -1028,7 +1028,7 @@ bool CWaypointClass::WPIsReachable(vec from, vec to)
v_down.z = v_down.z - 100.0f; // straight down
- TraceLine(v_check, v_down, NULL, false, &tr);
+ TraceLine(v_check, v_down, nullptr, false, &tr);
// height from ground
last_height = GetDistance(v_check, tr.end);
@@ -1045,7 +1045,7 @@ bool CWaypointClass::WPIsReachable(vec from, vec to)
v_down = v_check;
v_down.z = v_down.z - 100.0f;
- TraceLine(v_check, v_down, NULL, false, &tr);
+ TraceLine(v_check, v_down, nullptr, false, &tr);
curr_height = GetDistance(v_check, tr.end);
@@ -1073,7 +1073,7 @@ bool CWaypointClass::WPIsReachable(vec from, vec to)
node_s *CWaypointClass::GetNearestWaypoint(vec v_src, float flRange)
{
TLinkedList::node_s *pNode;
- node_s *pNearest = NULL;
+ node_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -1103,7 +1103,7 @@ node_s *CWaypointClass::GetNearestWaypoint(vec v_src, float flRange)
flDist = GetDistance(v_src, pNode->Entry->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (IsVisible(v_src, pNode->Entry->v_origin, NULL))
+ if (IsVisible(v_src, pNode->Entry->v_origin, nullptr))
{
pNearest = pNode->Entry;
flNearestDist = flDist;
@@ -1120,7 +1120,7 @@ node_s *CWaypointClass::GetNearestWaypoint(vec v_src, float flRange)
node_s *CWaypointClass::GetNearestTriggerWaypoint(vec v_src, float flRange)
{
TLinkedList::node_s *pNode;
- node_s *pNearest = NULL;
+ node_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -1156,7 +1156,7 @@ node_s *CWaypointClass::GetNearestTriggerWaypoint(vec v_src, float flRange)
flDist = GetDistance(v_src, pNode->Entry->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (IsVisible(v_src, pNode->Entry->v_origin, NULL))
+ if (IsVisible(v_src, pNode->Entry->v_origin, nullptr))
{
pNearest = pNode->Entry;
flNearestDist = flDist;
@@ -1186,7 +1186,7 @@ node_s *CWaypointClass::GetWaypointFromVec(const vec &v_src)
pNode = pNode->next;
}
- return NULL;
+ return nullptr;
}
void CWaypointClass::CalcCost(node_s *pNode)
@@ -1211,7 +1211,7 @@ void CWaypointClass::CalcCost(node_s *pNode)
// See if there is a obstacle(cube or mapmodel) nearby
traceresult_s tr;
- TraceLine(pNode->v_origin, to, NULL, false, &tr);
+ TraceLine(pNode->v_origin, to, nullptr, false, &tr);
if (tr.collided)
{
float flFraction = (GetDistance(pNode->v_origin, tr.end) /
@@ -1223,7 +1223,7 @@ void CWaypointClass::CalcCost(node_s *pNode)
vec from = to;
to.z -= (JUMP_HEIGHT - 1.0f);
- TraceLine(from, to, NULL, false, &tr);
+ TraceLine(from, to, nullptr, false, &tr);
if (!tr.collided)
flCost += 0.5f;
}
@@ -1239,7 +1239,7 @@ void CWaypointClass::CalcCost(node_s *pNode)
// See if there is a obstacle(cube or mapmodel) nearby
traceresult_s tr;
- TraceLine(pNode->v_origin, to, NULL, false, &tr);
+ TraceLine(pNode->v_origin, to, nullptr, false, &tr);
if (tr.collided)
{
float flFraction = (GetDistance(pNode->v_origin, tr.end) /
@@ -1251,7 +1251,7 @@ void CWaypointClass::CalcCost(node_s *pNode)
vec from = to;
to.z -= (JUMP_HEIGHT - 1.0f);
- TraceLine(from, to, NULL, false, &tr);
+ TraceLine(from, to, nullptr, false, &tr);
if (!tr.collided)
flCost += 0.5f;
}
@@ -1443,7 +1443,7 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from)
return false;
}
- if (GetNearestFloodWP(from, 2.0f, NULL)) return false;
+ if (GetNearestFloodWP(from, 2.0f, nullptr)) return false;
for (a=(x-1);a<=(x+1);a++)
{
@@ -1455,7 +1455,7 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from)
v2 = v1;
v2.z -= 1000.0f;
- TraceLine(v1, v2, NULL, false, &tr, true);
+ TraceLine(v1, v2, nullptr, false, &tr, true);
to = tr.end;
if ((a >= (x-1)) && (a <= (x+1)) && (b >= (y-1)) && (b <= (y+1)))
@@ -1473,7 +1473,7 @@ bool CWaypointClass::CanPlaceNodeHere(const vec &from)
return false;
}
- TraceLine(from, to, NULL, false, &tr, true);
+ TraceLine(from, to, nullptr, false, &tr, true);
if (tr.collided)
return false;
}
@@ -1537,7 +1537,7 @@ void CWaypointClass::ConnectFloodWP(node_s *pWP)
flDist = GetDistance(pWP->v_origin, pNode->Entry->v_origin);
if (flDist <= flRange)
{
- if (IsVisible(pWP->v_origin, pNode->Entry->v_origin, NULL, true))
+ if (IsVisible(pWP->v_origin, pNode->Entry->v_origin, nullptr, true))
{
// Connect a with b
pWP->ConnectedWPs.AddNode(pNode->Entry);
@@ -1561,7 +1561,7 @@ node_s *CWaypointClass::GetNearestFloodWP(vec v_origin, float flRange, node_s *p
bool SkipTags)
{
TLinkedList::node_s *p;
- node_s *pNearest = NULL;
+ node_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -1597,7 +1597,7 @@ node_s *CWaypointClass::GetNearestFloodWP(vec v_origin, float flRange, node_s *p
flDist = GetDistance(v_origin, p->Entry->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (IsVisible(v_origin, p->Entry->v_origin, NULL, SkipTags))
+ if (IsVisible(v_origin, p->Entry->v_origin, nullptr, SkipTags))
{
pNearest = p->Entry;
flNearestDist = flDist;
@@ -1614,7 +1614,7 @@ node_s *CWaypointClass::GetNearestFloodWP(vec v_origin, float flRange, node_s *p
node_s *CWaypointClass::GetNearestTriggerFloodWP(vec v_origin, float flRange)
{
TLinkedList::node_s *p;
- node_s *pNearest = NULL;
+ node_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -1650,7 +1650,7 @@ node_s *CWaypointClass::GetNearestTriggerFloodWP(vec v_origin, float flRange)
flDist = GetDistance(v_origin, p->Entry->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (IsVisible(v_origin, p->Entry->v_origin, NULL))
+ if (IsVisible(v_origin, p->Entry->v_origin, nullptr))
{
pNearest = p->Entry;
flNearestDist = flDist;
@@ -1798,7 +1798,7 @@ void CCubeWaypointClass::StartFlood()
for (float y=(y1+1.0f);y<=(y2-1.0f);y++)
{
vec from = { x, y, floor+2.0f };
- if (GetNearestFloodWP(from, 2.0f, NULL)) continue;
+ if (GetNearestFloodWP(from, 2.0f, nullptr)) continue;
// Add WP
int flags = W_FL_FLOOD;
@@ -2141,7 +2141,7 @@ bool CBot::FindWaypoint()
for (index=0; index < 3; index++)
{
min_distance[index] = 9999.0;
- min_wp[index] = NULL;
+ min_wp[index] = nullptr;
}
TLinkedList::node_s *pNode = m_pCurrentWaypoint->pNode->ConnectedWPs.GetFirst();
@@ -2202,7 +2202,7 @@ bool CBot::FindWaypoint()
pNode = pNode->next;
}
- wpselect = NULL;
+ wpselect = nullptr;
// about 20% of the time choose a waypoint at random
// (don't do this any more often than every 10 seconds)
@@ -2352,7 +2352,7 @@ bool CBot::HeadToWaypoint()
{
// if waypoint not found, clear oldest previous index and try again
- m_pPrevWaypoints[index] = NULL;
+ m_pPrevWaypoints[index] = nullptr;
index--;
}
@@ -2525,7 +2525,7 @@ bool CBot::HeadToGoal()
else
{
// Current waypoint isn't reachable, search new one
- waypoint_s *pWP = NULL;
+ waypoint_s *pWP = nullptr;
#ifdef WP_FLOOD
if (m_pCurrentGoalWaypoint->pNode->iFlags & W_FL_FLOOD)
@@ -2580,7 +2580,7 @@ bool CBot::AStar()
static int iCurrentCycles;
static short newg;
static waypoint_s *n, *n2;
- static TLinkedList::node_s *pPath = NULL;
+ static TLinkedList::node_s *pPath = nullptr;
static bool bPathFailed;
iMaxCycles = BotManager.m_iFrameTime / 10;
@@ -2601,9 +2601,9 @@ bool CBot::AStar()
CleanAStarLists(false);
m_pCurrentWaypoint->g[0] = m_pCurrentWaypoint->g[1] = 0;
- m_pCurrentWaypoint->pParent[0] = m_pCurrentWaypoint->pParent[1] = NULL;
+ m_pCurrentWaypoint->pParent[0] = m_pCurrentWaypoint->pParent[1] = nullptr;
m_pCurrentGoalWaypoint->g[0] = m_pCurrentGoalWaypoint->g[1] = 0;
- m_pCurrentGoalWaypoint->pParent[0] = m_pCurrentGoalWaypoint->pParent[1] = NULL;
+ m_pCurrentGoalWaypoint->pParent[0] = m_pCurrentGoalWaypoint->pParent[1] = nullptr;
m_AStarNodeList.DeleteAllNodes();
@@ -2848,7 +2848,7 @@ void CBot::CleanAStarLists(bool bPathFailed)
waypoint_s *p = m_AStarOpenList[0].Pop();
p->bIsOpen[0] = p->bIsOpen[1] = false;
p->bIsClosed[0] = p->bIsClosed[1] = false;
- p->pParent[0] = p->pParent[1] = NULL;
+ p->pParent[0] = p->pParent[1] = nullptr;
p->g[0] = p->g[1] = 0;
}
@@ -2857,7 +2857,7 @@ void CBot::CleanAStarLists(bool bPathFailed)
waypoint_s *p = m_AStarOpenList[1].Pop();
p->bIsOpen[0] = p->bIsOpen[1] = false;
p->bIsClosed[0] = p->bIsClosed[1] = false;
- p->pParent[0] = p->pParent[1] = NULL;
+ p->pParent[0] = p->pParent[1] = nullptr;
p->g[0] = p->g[1] = 0;
}
@@ -2866,7 +2866,7 @@ void CBot::CleanAStarLists(bool bPathFailed)
waypoint_s *p = m_AStarClosedList[0].Pop();
p->bIsOpen[0] = p->bIsOpen[1] = false;
p->bIsClosed[0] = p->bIsClosed[1] = false;
- p->pParent[0] = p->pParent[1] = NULL;
+ p->pParent[0] = p->pParent[1] = nullptr;
p->g[0] = p->g[1] = 0;
if (bPathFailed)
p->pNode->FailedGoalList.AddNode(m_pCurrentGoalWaypoint->pNode);
@@ -2877,7 +2877,7 @@ void CBot::CleanAStarLists(bool bPathFailed)
waypoint_s *p = m_AStarClosedList[1].Pop();
p->bIsOpen[0] = p->bIsOpen[1] = false;
p->bIsClosed[0] = p->bIsClosed[1] = false;
- p->pParent[0] = p->pParent[1] = NULL;
+ p->pParent[0] = p->pParent[1] = nullptr;
p->g[0] = p->g[1] = 0;
if (bPathFailed)
p->pNode->FailedGoalList.AddNode(m_pCurrentWaypoint->pNode);
@@ -2887,13 +2887,13 @@ void CBot::CleanAStarLists(bool bPathFailed)
void CBot::ResetWaypointVars()
{
m_iWaypointTime = 0;
- m_pCurrentWaypoint = NULL;
- m_pCurrentGoalWaypoint = NULL;
- m_pPrevWaypoints[0] = NULL;
- m_pPrevWaypoints[1] = NULL;
- m_pPrevWaypoints[2] = NULL;
- m_pPrevWaypoints[3] = NULL;
- m_pPrevWaypoints[4] = NULL;
+ m_pCurrentWaypoint = nullptr;
+ m_pCurrentGoalWaypoint = nullptr;
+ m_pPrevWaypoints[0] = nullptr;
+ m_pPrevWaypoints[1] = nullptr;
+ m_pPrevWaypoints[2] = nullptr;
+ m_pPrevWaypoints[3] = nullptr;
+ m_pPrevWaypoints[4] = nullptr;
m_fPrevWaypointDistance = 0;
m_iWaypointHeadLastTurnLessTime = 0;
m_iWaypointHeadPauseTime = 0;
@@ -2911,7 +2911,7 @@ void CBot::SetCurrentWaypoint(node_s *pNode)
{
waypoint_s *pWP = GetWPFromNode(pNode);
#ifndef RELEASE_BUILD
- if (!pWP || !pNode) condebug("NULL WP In SetCurrentWP");
+ if (!pWP || !pNode) condebug("nullptr WP In SetCurrentWP");
#endif
m_pCurrentWaypoint = pWP;
@@ -2921,7 +2921,7 @@ void CBot::SetCurrentWaypoint(node_s *pNode)
void CBot::SetCurrentWaypoint(waypoint_s *pWP)
{
#ifndef RELEASE_BUILD
- if (!pWP) condebug("NULL WP In SetCurrentWP(2)");
+ if (!pWP) condebug("nullptr WP In SetCurrentWP(2)");
#endif
m_pCurrentWaypoint = pWP;
@@ -2932,7 +2932,7 @@ void CBot::SetCurrentGoalWaypoint(node_s *pNode)
{
waypoint_s *pWP = GetWPFromNode(pNode);
#ifndef RELEASE_BUILD
- if (!pWP || !pNode) condebug("NULL WP In SetCurrentGoalWP");
+ if (!pWP || !pNode) condebug("nullptr WP In SetCurrentGoalWP");
#endif
m_pCurrentGoalWaypoint = pWP;
@@ -2941,7 +2941,7 @@ void CBot::SetCurrentGoalWaypoint(node_s *pNode)
void CBot::SetCurrentGoalWaypoint(waypoint_s *pWP)
{
#ifndef RELEASE_BUILD
- if (!pWP) condebug("NULL WP In SetCurrentGoalWP(2)");
+ if (!pWP) condebug("nullptr WP In SetCurrentGoalWP(2)");
#endif
m_pCurrentGoalWaypoint = pWP;
@@ -2951,7 +2951,7 @@ bool CBot::CurrentWPIsValid()
{
if (!m_pCurrentWaypoint)
{
- //condebug("Invalid WP: Is NULL");
+ //condebug("Invalid WP: Is nullptr");
return false;
}
@@ -2984,7 +2984,7 @@ bool CBot::ReachedGoalWP()
waypoint_s *CBot::GetWPFromNode(node_s *pNode)
{
- if (!pNode) return NULL;
+ if (!pNode) return nullptr;
short x, y;
WaypointClass.GetNodeIndexes(pNode->v_origin, &x, &y);
@@ -2998,13 +2998,13 @@ waypoint_s *CBot::GetWPFromNode(node_s *pNode)
p = p->next;
}
- return NULL;
+ return nullptr;
}
waypoint_s *CBot::GetNearestWaypoint(vec v_src, float flRange)
{
TLinkedList::node_s *p;
- waypoint_s *pNearest = NULL;
+ waypoint_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -3040,7 +3040,7 @@ waypoint_s *CBot::GetNearestWaypoint(vec v_src, float flRange)
flDist = GetDistance(v_src, p->Entry->pNode->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (::IsVisible(v_src, p->Entry->pNode->v_origin, NULL))
+ if (::IsVisible(v_src, p->Entry->pNode->v_origin, nullptr))
{
pNearest = p->Entry;
flNearestDist = flDist;
@@ -3057,7 +3057,7 @@ waypoint_s *CBot::GetNearestWaypoint(vec v_src, float flRange)
waypoint_s *CBot::GetNearestTriggerWaypoint(vec v_src, float flRange)
{
TLinkedList::node_s *p;
- waypoint_s *pNearest = NULL;
+ waypoint_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -3093,7 +3093,7 @@ waypoint_s *CBot::GetNearestTriggerWaypoint(vec v_src, float flRange)
flDist = GetDistance(v_src, p->Entry->pNode->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (::IsVisible(v_src, p->Entry->pNode->v_origin, NULL))
+ if (::IsVisible(v_src, p->Entry->pNode->v_origin, nullptr))
{
pNearest = p->Entry;
flNearestDist = flDist;
@@ -3149,7 +3149,7 @@ void CBot::SyncWaypoints()
waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange)
{
TLinkedList::node_s *p;
- waypoint_s *pNearest = NULL;
+ waypoint_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -3185,7 +3185,7 @@ waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange)
flDist = GetDistance(v_origin, p->Entry->pNode->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (::IsVisible(v_origin, p->Entry->pNode->v_origin, NULL))
+ if (::IsVisible(v_origin, p->Entry->pNode->v_origin, nullptr))
{
pNearest = p->Entry;
flNearestDist = flDist;
@@ -3202,7 +3202,7 @@ waypoint_s *CBot::GetNearestFloodWP(vec v_origin, float flRange)
waypoint_s *CBot::GetNearestTriggerFloodWP(vec v_origin, float flRange)
{
TLinkedList::node_s *p;
- waypoint_s *pNearest = NULL;
+ waypoint_s *pNearest = nullptr;
short i, j, MinI, MaxI, MinJ, MaxJ, Offset = (short)ceil(flRange / MAX_MAP_GRIDS);
float flNearestDist = 9999.99f, flDist;
@@ -3238,7 +3238,7 @@ waypoint_s *CBot::GetNearestTriggerFloodWP(vec v_origin, float flRange)
flDist = GetDistance(v_origin, p->Entry->pNode->v_origin);
if ((flDist < flNearestDist) && (flDist <= flRange))
{
- if (::IsVisible(v_origin, p->Entry->pNode->v_origin, NULL))
+ if (::IsVisible(v_origin, p->Entry->pNode->v_origin, nullptr))
{
pNearest = p->Entry;
flNearestDist = flDist;
diff --git a/source/src/bot/bot_waypoint.h b/source/src/bot/bot_waypoint.h
index 5ee0dbdb3..887917aac 100644
--- a/source/src/bot/bot_waypoint.h
+++ b/source/src/bot/bot_waypoint.h
@@ -50,7 +50,7 @@ struct waypoint_version_1_s
waypoint_version_1_s *pParent;
// Construction
- waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(NULL) { };
+ waypoint_version_1_s(void) : iFlags(0), f(0.0f), g(0.0f), pParent(nullptr) { };
};
struct node_s
@@ -82,8 +82,8 @@ struct waypoint_s
bool bIsOpen[2], bIsClosed[2];
// Construction
- waypoint_s(void) : pNode(NULL) { bIsOpen[0] = bIsOpen[1] = bIsClosed[0] =
- bIsClosed[1] = false; pParent[0] = pParent[1] = NULL;
+ waypoint_s(void) : pNode(nullptr) { bIsOpen[0] = bIsOpen[1] = bIsClosed[0] =
+ bIsClosed[1] = false; pParent[0] = pParent[1] = nullptr;
g[0] = g[1] = 0; };
};
@@ -116,6 +116,81 @@ class CWaypointClass
CWaypointClass(void);
virtual ~CWaypointClass(void) { Clear(); };
+ CWaypointClass& CWaypointClass::operator=(const CWaypointClass& other){
+ strcpy(m_szMapName, other.m_szMapName);
+ m_bDrawWaypoints = other.m_bDrawWaypoints;
+ m_bDrawWPPaths = other.m_bDrawWPPaths;
+ m_bAutoWaypoint = other.m_bAutoWaypoint;
+ m_bAutoPlacePaths = other.m_bAutoPlacePaths;
+ m_bDrawWPText = other.m_bDrawWPText;
+ m_vLastCreatedWP = other.m_vLastCreatedWP;
+ m_fPathDrawTime = other.m_fPathDrawTime;
+ m_bFlooding = other.m_bFlooding;
+ m_bFilteringNodes = other.m_bFilteringNodes;
+ m_iFloodStartTime = other.m_iFloodStartTime;
+ m_iCurFloodX = other.m_iCurFloodX;
+ m_iCurFloodY = other.m_iCurFloodY;
+ m_iFloodSize = other.m_iFloodSize;
+ m_iFilteredNodes = other.m_iFilteredNodes;
+ return *this;
+ }
+
+ CWaypointClass::CWaypointClass(const CWaypointClass& other){
+ strcpy(m_szMapName, other.m_szMapName);
+ m_bDrawWaypoints = other.m_bDrawWaypoints;
+ m_bDrawWPPaths = other.m_bDrawWPPaths;
+ m_bAutoWaypoint = other.m_bAutoWaypoint;
+ m_bAutoPlacePaths = other.m_bAutoPlacePaths;
+ m_bDrawWPText = other.m_bDrawWPText;
+ m_vLastCreatedWP = other.m_vLastCreatedWP;
+ m_fPathDrawTime = other.m_fPathDrawTime;
+ m_bFlooding = other.m_bFlooding;
+ m_bFilteringNodes = other.m_bFilteringNodes;
+ m_iFloodStartTime = other.m_iFloodStartTime;
+ m_iCurFloodX = other.m_iCurFloodX;
+ m_iCurFloodY = other.m_iCurFloodY;
+ m_iFloodSize = other.m_iFloodSize;
+ m_iFilteredNodes = other.m_iFilteredNodes;
+ }
+
+ CWaypointClass& CWaypointClass::operator=(CWaypointClass&& other){
+ delete[] m_szMapName;
+ strcpy(m_szMapName, other.m_szMapName);
+ m_bDrawWaypoints = other.m_bDrawWaypoints;
+ m_bDrawWPPaths = other.m_bDrawWPPaths;
+ m_bAutoWaypoint = other.m_bAutoWaypoint;
+ m_bAutoPlacePaths = other.m_bAutoPlacePaths;
+ m_bDrawWPText = other.m_bDrawWPText;
+ m_vLastCreatedWP = other.m_vLastCreatedWP;
+ m_fPathDrawTime = other.m_fPathDrawTime;
+ m_bFlooding = other.m_bFlooding;
+ m_bFilteringNodes = other.m_bFilteringNodes;
+ m_iFloodStartTime = other.m_iFloodStartTime;
+ m_iCurFloodX = other.m_iCurFloodX;
+ m_iCurFloodY = other.m_iCurFloodY;
+ m_iFloodSize = other.m_iFloodSize;
+ m_iFilteredNodes = other.m_iFilteredNodes;
+ return *this;
+ }
+
+ CWaypointClass::CWaypointClass(CWaypointClass&& other){
+ strcpy(m_szMapName, other.m_szMapName);
+ m_bDrawWaypoints = other.m_bDrawWaypoints;
+ m_bDrawWPPaths = other.m_bDrawWPPaths;
+ m_bAutoWaypoint = other.m_bAutoWaypoint;
+ m_bAutoPlacePaths = other.m_bAutoPlacePaths;
+ m_bDrawWPText = other.m_bDrawWPText;
+ m_vLastCreatedWP = other.m_vLastCreatedWP;
+ m_fPathDrawTime = other.m_fPathDrawTime;
+ m_bFlooding = other.m_bFlooding;
+ m_bFilteringNodes = other.m_bFilteringNodes;
+ m_iFloodStartTime = other.m_iFloodStartTime;
+ m_iCurFloodX = other.m_iCurFloodX;
+ m_iCurFloodY = other.m_iCurFloodY;
+ m_iFloodSize = other.m_iFloodSize;
+ m_iFilteredNodes = other.m_iFilteredNodes;
+ }
+
void Think(void);
void Init(void);
void Clear(void);
@@ -162,7 +237,7 @@ class CWaypointClass
bool CanPlaceNodeHere(const vec &from);
void ConnectFloodWP(node_s *pWP);
node_s *GetNearestFloodWP(vec v_origin, float flRange, node_s *pIgnore, bool SkipTags=false);
- node_s *GetNearestFloodWP(dynent *d, float flRange) { return GetNearestFloodWP(d->o, flRange, NULL); };
+ node_s *GetNearestFloodWP(dynent *d, float flRange) { return GetNearestFloodWP(d->o, flRange, nullptr); };
node_s *GetNearestTriggerFloodWP(vec v_origin, float flRange);
#endif
};
diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp
index f227a50dd..5519a8304 100644
--- a/source/src/bot/botmanager.cpp
+++ b/source/src/bot/botmanager.cpp
@@ -34,7 +34,7 @@ void CBotManager::Init()
LoadBotNamesFile();
//WaypointClass.Init();
- lsrand(time(NULL));
+ lsrand(time(nullptr));
}
void CBotManager::Think()
@@ -71,7 +71,7 @@ void CBotManager::Think()
b->pBot->m_pMyEnt = b;
// create skills
- b->pBot->m_pBotSkill = NULL;
+ b->pBot->m_pBotSkill = nullptr;
b->pBot->MakeSkill(b->level);
// Sync waypoints
@@ -94,7 +94,7 @@ void CBotManager::LoadBotNamesFile()
// Load bot file
char szNameFileName[256];
- MakeBotFileName("bot_names.txt", NULL, szNameFileName);
+ MakeBotFileName("bot_names.txt", nullptr, szNameFileName);
FILE *fp = fopen(szNameFileName, "r");
char szNameBuffer[256];
int iIndex, iStrIndex;
@@ -105,7 +105,7 @@ void CBotManager::LoadBotNamesFile()
return;
}
- while (fgets(szNameBuffer, 80, fp) != NULL)
+ while (fgets(szNameBuffer, 80, fp) != nullptr)
{
if (m_sBotNameCount >= MAXBOTNAMES)
{
@@ -183,7 +183,7 @@ void playerent::removeai()
}
loopv(players)
if(players[i] && this == players[i]->enemy)
- players[i]->enemy = NULL;
+ players[i]->enemy = nullptr;
}
void CBotManager::EndMap()
@@ -279,18 +279,17 @@ void CBotManager::DelWaypoint(node_s *pNode)
void CBotManager::MakeBotFileName(const char *szFileName, const char *szDir1, char *szOutput)
{
- const char *DirSeperator;
+ if (szDir1)
+ {
+ const char *DirSeperator;
#ifdef WIN32
- DirSeperator = "\\";
- strcpy(szOutput, "bot\\");
+ DirSeperator = "\\";
+ strcpy(szOutput, "bot\\");
#else
- DirSeperator = "/";
- strcpy(szOutput, "bot/");
+ DirSeperator = "/";
+ strcpy(szOutput, "bot/");
#endif
-
- if (szDir1)
- {
strcat(szOutput, szDir1);
strcat(szOutput, DirSeperator);
}
@@ -331,7 +330,7 @@ void CBotManager::PickNextTrigger()
vec o(e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight);
- node_s *pWptNearEnt = NULL;
+ node_s *pWptNearEnt = nullptr;
pWptNearEnt = WaypointClass.GetNearestTriggerWaypoint(o, 2.0f);
diff --git a/source/src/client.cpp b/source/src/client.cpp
index c330f4e82..c3547b3a0 100644
--- a/source/src/client.cpp
+++ b/source/src/client.cpp
@@ -5,8 +5,8 @@
VAR(connected, 1, 0, 0);
-ENetHost *clienthost = NULL;
-ENetPeer *curpeer = NULL, *connpeer = NULL;
+ENetHost *clienthost = nullptr;
+ENetPeer *curpeer = nullptr, *connpeer = nullptr;
int connmillis = 0, connattempts = 0, discmillis = 0;
SVAR(curdemofile, "n/a");
extern int searchlan;
@@ -18,7 +18,7 @@ bool multiplayer(bool msg)
{
// check not correct on listen server?
if(curpeer && msg) conoutf(_("operation not available in multiplayer"));
- return curpeer!=NULL;
+ return curpeer!=nullptr;
}
VAR(edithack, 0, 0, 1); // USE AT YOUR OWN RISK
@@ -49,17 +49,17 @@ void abortconnect()
if(!connpeer) return;
clientpassword[0] = '\0';
if(connpeer->state!=ENET_PEER_STATE_DISCONNECTED) enet_peer_reset(connpeer);
- connpeer = NULL;
+ connpeer = nullptr;
#if 0
if(!curpeer)
{
enet_host_destroy(clienthost);
- clienthost = NULL;
+ clienthost = nullptr;
}
#endif
}
-void connectserv_(const char *servername, int serverport = 0, const char *password = NULL)
+void connectserv_(const char *servername, int serverport = 0, const char *password = nullptr)
{
if(serverport <= 0) serverport = CUBE_DEFAULT_SERVER_PORT;
if(watchingdemo) enddemoplayback();
@@ -92,7 +92,7 @@ void connectserv_(const char *servername, int serverport = 0, const char *passwo
}
if(!clienthost)
- clienthost = enet_host_create(NULL, 2, 3, 0, 0);
+ clienthost = enet_host_create(nullptr, 2, 3, 0, 0);
if(clienthost)
{
@@ -115,7 +115,7 @@ void connectserv(char *servername, int *serverport, char *password)
void lanconnect()
{
- connectserv_(NULL);
+ connectserv_(nullptr);
}
void whereami()
@@ -148,7 +148,7 @@ void disconnect(int onlyclean, int async)
if(async) return;
enet_peer_reset(curpeer);
}
- curpeer = NULL;
+ curpeer = nullptr;
discmillis = 0;
connected = 0;
conoutf(_("disconnected"));
@@ -169,7 +169,7 @@ void disconnect(int onlyclean, int async)
if(!connpeer && clienthost)
{
enet_host_destroy(clienthost);
- clienthost = NULL;
+ clienthost = nullptr;
}
#endif
if(!onlyclean) localconnect();
@@ -276,7 +276,7 @@ void echo(char *text)
do
{
conoutf("%s", s ? s : "");
- s = strtok(NULL, "\n");
+ s = strtok(nullptr, "\n");
}
while(s);
}
@@ -289,7 +289,7 @@ void hudecho(char *text)
do
{
outf("%s", s ? s : "");
- s = strtok(NULL, "\n");
+ s = strtok(nullptr, "\n");
}
while(s);
}
@@ -371,13 +371,13 @@ void cleanupclient()
if(clienthost)
{
enet_host_destroy(clienthost);
- clienthost = NULL;
+ clienthost = nullptr;
}
}
// collect c2s messages conveniently
-vector messages;
+vect messages;
bool messagereliable = false;
void addmsg(int type, const char *fmt, ...)
@@ -436,7 +436,7 @@ void sendpackettoserv(int chan, ENetPacket *packet)
void c2skeepalive()
{
- if(clienthost && (curpeer || connpeer)) enet_host_service(clienthost, NULL, 0);
+ if(clienthost && (curpeer || connpeer)) enet_host_service(clienthost, nullptr, 0);
}
extern string masterpwd;
@@ -645,13 +645,13 @@ void gets2c() // get updates from the server
return;
}
}
- while(clienthost!=NULL && enet_host_service(clienthost, &event, 0)>0)
+ while(clienthost!=nullptr && enet_host_service(clienthost, &event, 0)>0)
switch(event.type)
{
case ENET_EVENT_TYPE_CONNECT:
disconnect(1);
curpeer = connpeer;
- connpeer = NULL;
+ connpeer = nullptr;
connected = 1;
conoutf(_("connected to server"));
if(identexists("onConnect"))
@@ -699,7 +699,7 @@ void gets2c() // get updates from the server
// for AUTH:
-vector authkeys;
+vect authkeys;
VARP(autoauth, 0, 1, 1);
@@ -707,12 +707,12 @@ authkey *findauthkey(const char *desc)
{
loopv(authkeys) if(!strcmp(authkeys[i]->desc, desc) && !strcmp(authkeys[i]->name, player1->name)) return authkeys[i];
loopv(authkeys) if(!strcmp(authkeys[i]->desc, desc)) return authkeys[i];
- return NULL;
+ return nullptr;
}
void addauthkey(const char *name, const char *key, const char *desc)
{
- loopvrev(authkeys) if(!strcmp(authkeys[i]->desc, desc) && !strcmp(authkeys[i]->name, name)) delete authkeys.remove(i);
+ loopvrev(authkeys) if(!strcmp(authkeys[i]->desc, desc) && !strcmp(authkeys[i]->name, name)) authkeys.remove(i);
if(name[0] && key[0]) authkeys.add(new authkey(name, key, desc));
}
@@ -726,7 +726,7 @@ bool _hasauthkey(const char *name, const char *desc)
void genauthkey(const char *secret)
{
if(!secret[0]) { conoutf("you must specify a secret password"); return; }
- vector privkey, pubkey;
+ vect privkey, pubkey;
genprivkey(secret, privkey, pubkey);
conoutf("private key: %s", privkey.getbuf());
conoutf("public key: %s", pubkey.getbuf());
@@ -768,7 +768,7 @@ COMMANDF(auth, "s", (char *desc) { intret(tryauth(desc)); });
// sendmap/getmap commands, should be replaced by more intuitive map downloading
-vector securemaps;
+vect securemaps;
void resetsecuremaps() { securemaps.deletearrays(); }
void securemap(char *map) { if(map) securemaps.add(newstring(map)); }
@@ -925,7 +925,7 @@ COMMANDN(rewind, rewinddemo, "i");
// packages auto - downloader
// arrays
-vector pckservers;
+vect pckservers;
hashtable pendingpackages;
// cubescript
@@ -970,12 +970,12 @@ int pckserversort(pckserver **a, pckserver **b)
return (*a)->ping == (*b)->ping ? 0 : ((*a)->ping < (*b)->ping ? -1 : 1);
}
-SDL_Thread* pingpcksrvthread = NULL;
-SDL_mutex *pingpcksrvlock = NULL;
+SDL_Thread* pingpcksrvthread = nullptr;
+SDL_mutex *pingpcksrvlock = nullptr;
int pingpckservers(void *data)
{
SDL_mutexP(pingpcksrvlock);
- vector serverstoping;
+ vect serverstoping;
loopv(pckservers) serverstoping.add(*pckservers[i]);
SDL_mutexV(pingpcksrvlock);
// measure the time it took to receive each's server response
@@ -995,7 +995,7 @@ int pingpckservers(void *data)
curl_easy_getinfo(cu, CURLINFO_NAMELOOKUP_TIME, &namelookup);
ping -= namelookup; // ignore DNS lookup time as it should be performed only once
curl_easy_cleanup(cu);
- cu = NULL;
+ cu = nullptr;
if(result == CURLE_OPERATION_TIMEDOUT || result == CURLE_COULDNT_RESOLVE_HOST)
serv->responsive = false;
else
@@ -1015,8 +1015,8 @@ int pingpckservers(void *data)
SDL_mutexV(pingpcksrvlock);
SDL_DestroyMutex(pingpcksrvlock);
- pingpcksrvthread = NULL;
- pingpcksrvlock = NULL;
+ pingpcksrvthread = nullptr;
+ pingpcksrvlock = nullptr;
return 0;
}
@@ -1024,7 +1024,7 @@ void sortpckservers()
{
if(pingpcksrvthread || !havecurl) return;
pingpcksrvlock = SDL_CreateMutex();
- pingpcksrvthread = SDL_CreateThread(pingpckservers, NULL);
+ pingpcksrvthread = SDL_CreateThread(pingpckservers, nullptr);
}
COMMAND(sortpckservers, "");
@@ -1035,7 +1035,7 @@ static size_t write_callback(void *ptr, size_t size, size_t nmemb, FILE *stream)
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
- package *pck = (package *)clientp;
+ package *pck = reinterpret_cast(clientp);
loadingscreen(_("downloading package %d out of %d...\n%s %.0f/%.0f KB (%.1f%%)\n(ESC to cancel)"), pck->number + 1, pck->number + pendingpackages.numelems,
pck->name, dlnow/double(1000.0), dltotal/double(1000.0), dltotal == 0 ? 0 : (dlnow/dltotal * double(100.0)));
if(interceptkey(SDLK_ESCAPE))
@@ -1066,7 +1066,7 @@ int processdownload(package *pck)
case PCK_MAP: case PCK_MAPMODEL:
{
- addzip(tmpname, pck->name, NULL, true, pck->type);
+ addzip(tmpname, pck->name, nullptr, true, pck->type);
break;
}
@@ -1074,7 +1074,7 @@ int processdownload(package *pck)
{
char *fname = newstring(pck->name), *ls = strrchr(fname, '/');
if(ls) *ls = '\0';
- addzip(tmpname, fname, NULL, true, pck->type);
+ addzip(tmpname, fname, nullptr, true, pck->type);
break;
}
@@ -1118,7 +1118,7 @@ double dlpackage(package *pck)
curl_easy_getinfo(pck->curl, CURLINFO_RESPONSE_CODE, &httpresult);
curl_easy_getinfo(pck->curl, CURLINFO_SIZE_DOWNLOAD, &dlsize);
curl_easy_cleanup(pck->curl);
- pck->curl = NULL;
+ pck->curl = nullptr;
fclose(outfile);
pck->pending = false;
@@ -1129,7 +1129,7 @@ double dlpackage(package *pck)
conoutf(_("\f3could not connect to %s"), pck->source->addr);
// try to find another source
- pckserver *source = NULL;
+ pckserver *source = nullptr;
loopv(pckservers) if(pckservers[i]->responsive) { source = pckservers[i]; break; }
if(!source)
{
diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp
index 07498a6fa..54dceb704 100644
--- a/source/src/clientgame.cpp
+++ b/source/src/clientgame.cpp
@@ -57,7 +57,7 @@ int arenaintermission = 0;
struct serverstate servstate = { 0 };
playerent *player1 = newplayerent(); // our client
-vector players; // other clients
+vect players; // other clients
int lastmillis = 0, totalmillis = 0, nextmillis = 0;
int lasthit = 0;
@@ -135,7 +135,7 @@ const char *highlight(const char *text)
}
l = s + strlen(s);
}
- s = strtok(NULL, sep);
+ s = strtok(nullptr, sep);
}
if(MAXTRANS - strlen(result) > strlen(text) - (l - temp)) strcat(result, text + (l - temp));
delete[] temp;
@@ -263,7 +263,7 @@ void curmodeattr(char *attr)
COMMANDN(team, newteam, "s");
COMMANDN(name, newname, "s");
COMMAND(benchme, "");
-COMMANDF(isclient, "i", (int *cn) { intret(getclient(*cn) != NULL ? 1 : 0); } );
+COMMANDF(isclient, "i", (int *cn) { intret(getclient(*cn) != nullptr ? 1 : 0); } );
COMMANDF(curmastermode, "", (void) { intret(servstate.mastermode); });
COMMANDF(curautoteam, "", (void) { intret(servstate.autoteam); });
COMMAND(curmodeattr, "s");
@@ -624,7 +624,7 @@ void showrespawntimer()
}
struct scriptsleep { int wait, millis; char *cmd; bool persist; };
-vector sleeps;
+vect sleeps;
void addsleep(int msec, const char *cmd, bool persist)
{
@@ -660,7 +660,7 @@ void updateworld(int curtime, int lastmillis) // main game update loop
if(lastmillis - sleeps[i].millis >= sleeps[i].wait)
{
char *cmd = sleeps[i].cmd;
- sleeps[i].cmd = NULL;
+ sleeps[i].cmd = nullptr;
execute(cmd);
delete[] cmd;
if(sleeps[i].cmd || !sleeps.inrange(i)) break;
@@ -942,10 +942,10 @@ playerent *newclient(int cn) // ensure valid entity
if(cn<0 || cn>=MAXCLIENTS)
{
neterr("clientnum");
- return NULL;
+ return nullptr;
}
if(cn == getclientnum()) return player1;
- while(cn>=players.length()) players.add(NULL);
+ while(cn>=players.length()) players.add(nullptr);
playerent *d = players[cn];
if(d) return d;
d = newplayerent();
@@ -957,7 +957,7 @@ playerent *newclient(int cn) // ensure valid entity
playerent *getclient(int cn) // ensure valid entity
{
if(cn == player1->clientnum) return player1;
- return players.inrange(cn) ? players[cn] : NULL;
+ return players.inrange(cn) ? players[cn] : nullptr;
}
void initclient()
@@ -977,7 +977,7 @@ void initflag(int i)
flaginfo &f = flaginfos[i];
f.flagent = &flagdummies[i];
f.pos = vec(f.flagent->x, f.flagent->y, f.flagent->z);
- f.actor = NULL;
+ f.actor = nullptr;
f.actor_cn = -1;
f.team = i;
f.state = m_keep(gamemode) ? CTFF_IDLE : CTFF_INBASE;
@@ -1011,7 +1011,7 @@ void preparectf(bool cleanonly=false)
}
struct mdesc { int mode, muts; char *desc; };
-vector gmdescs, mutdescs, gspdescs;
+vect gmdescs, mutdescs, gspdescs;
void gamemodedesc(int *modenr, char *desc)
{
@@ -1361,7 +1361,7 @@ const char *votestring(int type, const votedata &vote)
votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, const votedata &vote)
{
- if(type < 0 || type >= SA_NUM) return NULL;
+ if(type < 0 || type >= SA_NUM) return nullptr;
votedisplayinfo *v = new votedisplayinfo();
v->owner = owner;
v->type = type;
@@ -1370,7 +1370,7 @@ votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, const votedata &
return v;
}
-votedisplayinfo *curvote = NULL;
+votedisplayinfo *curvote = nullptr;
void callvote(int type, const votedata &vote)
{
@@ -1518,7 +1518,7 @@ COMMANDF(vote, "i", (int *v) { vote(*v); });
void cleanplayervotes(playerent *p)
{
- if(curvote && curvote->owner==p) curvote->owner = NULL;
+ if(curvote && curvote->owner==p) curvote->owner = nullptr;
}
void whois(int *cn)
@@ -1550,21 +1550,21 @@ void setadmin(int *claim, char *password)
COMMAND(setadmin, "is");
struct mline { string name, cmd; };
-static vector mlines;
+static vect mlines;
-void *kickmenu = NULL, *banmenu = NULL, *forceteammenu = NULL, *giveadminmenu = NULL;
+void *kickmenu = nullptr, *banmenu = nullptr, *forceteammenu = nullptr, *giveadminmenu = nullptr;
void refreshsopmenu(void *menu, bool init)
{
menureset(menu);
mlines.shrink(0);
- mlines.reserve(players.length());
+ mlines.reserveR(players.length());
loopv(players) if(players[i])
{
mline &m = mlines.add();
copystring(m.name, colorname(players[i]));
string kbr;
- if(getalias("_kickbanreason")!=NULL) formatstring(kbr)(" [ %s ]", getalias("_kickbanreason")); // leading space!
+ if(getalias("_kickbanreason")!=nullptr) formatstring(kbr)(" [ %s ]", getalias("_kickbanreason")); // leading space!
else kbr[0] = '\0';
formatstring(m.cmd)("%s %d%s", menu==kickmenu ? "kick" : (menu==banmenu ? "ban" : (menu==forceteammenu ? "forceteam" : "giveadmin")), i, (menu==kickmenu||menu==banmenu)?(strlen(kbr)>8?kbr:" NONE"):""); // 8==3 + "format-extra-chars"
menumanual(menu, m.name, m.cmd);
@@ -1584,14 +1584,14 @@ playerent *updatefollowplayer(int shiftdirection)
}
// collect spec-able players
- vector available;
+ vect available;
loopv(players) if(players[i])
{
if(player1->team != TEAM_SPECT && !watchingdemo && m_team(gamemode, mutators) && team_base(players[i]->team) != team_base(player1->team)) continue;
if(players[i]->state==CS_DEAD || players[i]->isspectating()) continue;
available.add(players[i]);
}
- if(!available.length()) return NULL;
+ if(!available.length()) return nullptr;
// rotate
int oldidx = available.find(focus);
diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp
index 6ce7f484b..c35369128 100644
--- a/source/src/clients2c.cpp
+++ b/source/src/clients2c.cpp
@@ -227,7 +227,7 @@ void parsepositions(ucharbuf &p)
// when playing a demo spectate first player we know about
if(player1->isspectating() && player1->spectatemode==SM_NONE) togglespect();
extern void clamproll(physent *pl);
- if(maxrollremote) clamproll((physent *) d);
+ if(maxrollremote) clamproll(dynamic_cast(d));
break;
}
@@ -238,7 +238,7 @@ void parsepositions(ucharbuf &p)
}
extern int checkarea(int maplayout_factor, char *maplayout);
-char *mlayout = NULL;
+char *mlayout = nullptr;
int Mv = 0, Ma = 0, F2F = 1000 * MINFF; // moved up:, MA = 0;
float Mh = 0;
extern int connected;
@@ -745,7 +745,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
if(d == player1 && m_duke(gamemode, mutators) && !localwrongmap)
{
if (!m_zombie(gamemode) && !m_convert(gamemode, mutators)) arenaintermission = 0;
- //closemenu(NULL);
+ //closemenu(nullptr);
conoutf(_("new round starting... fight!"));
hudeditf(HUDMSG_TIMER, "FIGHT!");
}
@@ -893,7 +893,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
getstring(text, p);
if(a && a->lastauth && lastmillis - a->lastauth < 60*1000)
{
- vector buf;
+ vect buf;
answerchallenge(a->key, text, buf);
//conoutf("answering %u, challenge %s with %s", id, text, buf.getbuf());
addmsg(SV_AUTHANS, "rsis", a->desc, id, buf.getbuf());
@@ -940,7 +940,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
case SV_REGEN:
case SV_HEAL:
{
- playerent *healer = type == SV_HEAL ? getclient(getint(p)) : NULL;
+ playerent *healer = type == SV_HEAL ? getclient(getint(p)) : nullptr;
const int cn = getint(p), health = getint(p);
playerent *d = getclient(cn);
if (!d) break;
@@ -1391,7 +1391,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
int cn = getint(p), type = getint(p), voteremain = getint(p);
playerent *d = getclient(cn);
if( type < 0 || type >= SA_NUM ) break;
- votedisplayinfo *v = NULL;
+ votedisplayinfo *v = nullptr;
// vote data storage
static votedata vote = votedata(text);
vote = votedata(text); // reset it
@@ -1473,7 +1473,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
{
int vres = getint(p), vetocn = getint(p);
playerent *d = getclient(vetocn);
- curvote->veto = (d != NULL);
+ curvote->veto = (d != nullptr);
if (curvote && vres >= 0 && vres < VOTE_NUM)
{
curvote->result = vres;
@@ -1619,7 +1619,7 @@ const char *parseDemoFilename(char *srvfinfo)
char sep[] = ":";
char *pch;
pch = strtok (srvfinfo,sep);
- while (pch != NULL && fip < 4)
+ while (pch != nullptr && fip < 4)
{
fip++;
switch(fip)
@@ -1631,7 +1631,7 @@ const char *parseDemoFilename(char *srvfinfo)
case 4: stamp = atoi(pch); break;
default: break;
}
- pch = strtok (NULL, sep);
+ pch = strtok (nullptr, sep);
}
copystring(srvmap, pch);
}
@@ -1709,7 +1709,7 @@ void receivefile(uchar *data, int len)
default:
p.len = 0;
- parsemessages(-1, NULL, p);
+ parsemessages(-1, nullptr, p);
break;
}
}
@@ -1720,7 +1720,7 @@ void servertoclient(int chan, uchar *buf, int len, bool demo) // processes any
switch(chan)
{
case 0: parsepositions(p); break;
- case 1: parsemessages(-1, NULL, p, demo); break;
+ case 1: parsemessages(-1, nullptr, p, demo); break;
case 2: receivefile(p.buf, p.maxlen); break;
}
}
diff --git a/source/src/command.cpp b/source/src/command.cpp
index d2d19b526..624d0703f 100644
--- a/source/src/command.cpp
+++ b/source/src/command.cpp
@@ -7,7 +7,7 @@ bool allowidentaccess(ident *id);
char *exchangestr(char *o, const char *n) { delete[] o; return newstring(n); }
void scripterr();
-vector contextstack;
+vect contextstack;
bool contextsealed = false;
bool contextisolated[IEXC_NUM] = { false };
int execcontext;
@@ -15,7 +15,7 @@ int execcontext;
bool loop_break = false, loop_skip = false; // break or continue (skip) current loop
int loop_level = 0; // avoid bad calls of break & continue
-hashtable *idents = NULL; // contains ALL vars/commands/aliases
+hashtable *idents = nullptr; // contains ALL vars/commands/aliases
VAR(persistidents, 0, 1, 1);
@@ -34,7 +34,7 @@ void clearstack(ident &id)
stack = stack->next;
delete tmp;
}
- id.stack = NULL;
+ id.stack = nullptr;
}
void pushident(ident &id, char *val, int context = execcontext)
@@ -309,12 +309,12 @@ int getvar(const char *name)
return *id->storage.i;
}
-bool identexists(const char *name) { return idents->access(name)!=NULL; }
+bool identexists(const char *name) { return idents->access(name)!=nullptr; }
const char *getalias(const char *name)
{
ident *i = idents->access(name);
- return i && i->type==ID_ALIAS ? i->action : NULL;
+ return i && i->type==ID_ALIAS ? i->action : nullptr;
}
void _getalias(char *name)
{
@@ -372,7 +372,7 @@ char *parseexp(const char *&p, int right) // parse any nested set of
p--;
conoutf("missing \"%c\"", right);
scripterr();
- return NULL;
+ return nullptr;
}
}
char *s = newstring(word, p-word-1);
@@ -417,7 +417,7 @@ char *parseword(const char *&p, int arg, int &infix) // pa
if(*p=='[') return parseexp(p, ']');
const char *word = p;
p += strcspn(p, "; \t\r\n\0");
- if(p-word==0) return NULL;
+ if(p-word==0) return nullptr;
if(arg==1 && p-word==1) switch(*word)
{
case '=': infix = *word; break;
@@ -444,7 +444,7 @@ char *conc(char **w, int n, bool space)
VARN(numargs, _numargs, 25, 0, 0);
-char *commandret = NULL;
+char *commandret = nullptr;
void intret(int v)
{
@@ -475,13 +475,13 @@ void result(const char *s) { commandret = newstring(s); }
#if 0
// seer : script evaluation excessive recursion
static int seer_count = 0; // count calls to executeret, check time every n1 (100) calls
-static int seer_index = -1; // position in timestamp vector
-vector seer_t1; // timestamp of last n2 (10) level-1 calls
-vector seer_t2; // timestamp of last n3 (10) level-2 calls
+static int seer_index = -1; // position in timestamp vect
+vect seer_t1; // timestamp of last n2 (10) level-1 calls
+vect seer_t2; // timestamp of last n3 (10) level-2 calls
#endif
char *executeret(const char *p) // all evaluation happens here, recursively
{
- if(!p || !p[0]) return NULL;
+ if(!p || !p[0]) return nullptr;
bool noproblem = true;
#if 0
if(execcontext>IEXC_CFG) // only PROMPT and MAP-CFG are checked for this, fooling with core/cfg at your own risk!
@@ -490,7 +490,7 @@ char *executeret(const char *p) // all evaluation hap
if(seer_count>=100)
{
seer_index = (seer_index+1)%10;
- long long cts = (long long) time(NULL);
+ long long cts = (long long) time(nullptr);
if(seer_t1.length()>=10) seer_t1[seer_index] = cts;
seer_t1.add(cts);
int lc = (seer_index+11)%10;
@@ -520,7 +520,7 @@ char *executeret(const char *p) // all evaluation hap
#endif
const int MAXWORDS = 25; // limit, remove
char *w[MAXWORDS];
- char *retval = NULL;
+ char *retval = nullptr;
#define setretval(v) { char *rv = v; if(rv) retval = rv; }
if(noproblem) // if the "seer"-algorithm doesn't object
{
@@ -550,7 +550,7 @@ char *executeret(const char *p) // all evaluation hap
{
case '=':
DELETEA(w[1]);
- swap(w[0], w[1]);
+ swapB(w[0], w[1]);
c = "alias";
break;
}
@@ -583,21 +583,21 @@ char *executeret(const char *p) // all evaluation hap
if(strstr(id->sig, "v")) ((void (__cdecl *)(char **, int))id->fun)(&w[1], numargs-1);
else if(strstr(id->sig, "c") || strstr(id->sig, "w"))
{
- char *r = conc(w+1, numargs-1, strstr(id->sig, "c") != NULL);
+ char *r = conc(w+1, numargs-1, strstr(id->sig, "c") != nullptr);
((void (__cdecl *)(char *))id->fun)(r);
delete[] r;
}
else if(strstr(id->sig, "d"))
{
#ifndef STANDALONE
- ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=NULL);
+ ((void (__cdecl *)(bool))id->fun)(addreleaseaction(id->name)!=nullptr);
#endif
}
else
{
int ib1, ib2, ib3, ib4, ib5, ib6, ib7, ib8;
float fb1, fb2, fb3, fb4, fb5, fb6, fb7, fb8;
- #define ARG(i) (id->sig[i-1] == 'i' ? ((void *)&(ib##i=strtol(w[i], NULL, 0))) : (id->sig[i-1] == 'f' ? ((void *)&(fb##i=atof(w[i]))) : (void *)w[i]))
+ #define ARG(i) (id->sig[i-1] == 'i' ? ((void *)&(ib##i=strtol(w[i], nullptr, 0))) : (id->sig[i-1] == 'f' ? ((void *)&(fb##i=atof(w[i]))) : (void *)w[i]))
switch(strlen(id->sig)) // use very ad-hoc function signature, and just call it
{
@@ -616,7 +616,7 @@ char *executeret(const char *p) // all evaluation hap
}
setretval(commandret);
- commandret = NULL;
+ commandret = nullptr;
break;
}
@@ -664,7 +664,7 @@ char *executeret(const char *p) // all evaluation hap
case ID_ALIAS: // alias, also used as functions and (global) variables
delete[] w[0];
- static vector argids;
+ static vect argids;
for(int i = 1; i argids.length())
@@ -702,12 +702,12 @@ int execute(const char *p)
// tab-completion of all idents
static int completesize = -1, completeidx = 0;
-static playerent *completeplayer = NULL;
+static playerent *completeplayer = nullptr;
void resetcomplete()
{
completesize = -1;
- completeplayer = NULL;
+ completeplayer = nullptr;
}
bool nickcomplete(char *s)
@@ -720,7 +720,7 @@ bool nickcomplete(char *s)
if(completesize < 0) { completesize = (int)strlen(cp); completeidx = 0; }
int idx = 0;
- if(completeplayer!=NULL)
+ if(completeplayer!=nullptr)
{
idx = players.find(completeplayer)+1;
if(!players.inrange(idx)) idx = 0;
@@ -755,10 +755,10 @@ struct completeval
{
int type;
char *dir, *ext;
- vector dirlist;
- vector list;
+ vect dirlist;
+ vect list;
- completeval(int type, const char *dir, const char *ext) : type(type), dir(dir && dir[0] ? newstring(dir) : NULL), ext(ext && ext[0] ? newstring(ext) : NULL) {}
+ completeval(int type, const char *dir, const char *ext) : type(type), dir(dir && dir[0] ? newstring(dir) : nullptr), ext(ext && ext[0] ? newstring(ext) : nullptr) {}
~completeval() { DELETEA(dir); DELETEA(ext); dirlist.deletearrays(); list.deletearrays(); }
};
@@ -785,7 +785,7 @@ void addcomplete(char *command, int type, char *dir, char *ext)
if(ext)
{
if(strchr(ext, '*')) ext[0] = '\0';
- if(!ext[0]) ext = NULL;
+ if(!ext[0]) ext = nullptr;
}
}
completekey key(type, dir, ext);
@@ -820,12 +820,12 @@ void addfilecomplete(char *command, char *dir, char *ext)
void addlistcomplete(char *command, char *list)
{
- addcomplete(command, COMPLETE_LIST, list, NULL);
+ addcomplete(command, COMPLETE_LIST, list, nullptr);
}
void addnickcomplete(char *command)
{
- addcomplete(command, COMPLETE_NICK, NULL, NULL);
+ addcomplete(command, COMPLETE_NICK, nullptr, nullptr);
}
COMMANDN(complete, addfilecomplete, "sss");
@@ -880,7 +880,7 @@ void commandcomplete(char *s)
if(*cp == ' ') init = true;
}
- completeval *cdata = NULL;
+ completeval *cdata = nullptr;
char *end = strchr(s+1, ' '); //find end of command name
@@ -941,7 +941,7 @@ void complete(char *s)
}
#endif
-const char *curcontext = NULL, *curinfo = NULL;
+const char *curcontext = nullptr, *curinfo = nullptr;
void scripterr()
{
@@ -957,7 +957,7 @@ void setcontext(const char *context, const char *info)
void resetcontext()
{
- curcontext = curinfo = NULL;
+ curcontext = curinfo = nullptr;
}
bool execfile(const char *cfgfile)
@@ -965,7 +965,7 @@ bool execfile(const char *cfgfile)
string s;
copystring(s, cfgfile);
setcontext("file", cfgfile);
- char *buf = loadfile(path(s), NULL);
+ char *buf = loadfile(path(s), nullptr);
if(!buf)
{
resetcontext();
@@ -986,7 +986,7 @@ void execdir(const char *dir)
{
if(dir[0])
{
- vector files;
+ vect files;
listfiles(dir, "cfg", files);
loopv(files)
{
@@ -1065,7 +1065,7 @@ void format(char **args, int numargs)
return;
}
- vector s;
+ vect s;
char *f = args[0];
while(*f)
{
@@ -1090,7 +1090,7 @@ void format(char **args, int numargs)
#define whitespaceskip s += strspn(s, "\n\t \r")
#define elementskip *s=='"' ? (++s, s += strcspn(s, "\"\n\0"), s += *s=='"') : s += strcspn(s, "\n\t \0")
-void explodelist(const char *s, vector &elems)
+void explodelist(const char *s, vect &elems)
{
whitespaceskip;
while(*s)
@@ -1108,7 +1108,7 @@ void looplist(char *list, char *var, char *body)
if(id->type!=ID_ALIAS) return;
char *buf = newstring(MAXSTRLEN);
- vector elems;
+ vect elems;
explodelist(list, elems);
loop_level++;
@@ -1255,7 +1255,7 @@ void testchar(char *s, int *type)
char *strreplace(char *dest, const char *source, const char *search, const char *replace)
{
- vector buf;
+ vect buf;
int searchlen = strlen(search);
if(!searchlen) { copystring(dest, source); return dest; }
@@ -1292,7 +1292,7 @@ void sortlist(char *list)
return;
}
- vector elems;
+ vect elems;
explodelist(list, elems);
elems.sort(stringsort);
@@ -1320,14 +1320,14 @@ void sortlist(char *list)
return;
}
- vector elems;
+ vect elems;
explodelist(list, elems);
- vector swap;
- explodelist(v, swap);
+ vect swapB;
+ explodelist(v, swapB);
if (strcmp(v, "") == 0 || //no input
- swap.length()%2 != 0) //incorrect input
+ swapB.length()%2 != 0) //incorrect input
{
result(buf);
delete [] buf;
@@ -1336,13 +1336,13 @@ void sortlist(char *list)
char tmp[255]; strcpy (tmp, "");
- for(int i = 0; i < swap.length(); i+=2)
+ for(int i = 0; i < swapB.length(); i+=2)
{
- if (elems.inrange(atoi(swap[i])) && elems.inrange(atoi(swap[i + 1])))
+ if (elems.inrange(atoi(swapB[i])) && elems.inrange(atoi(swapB[i + 1])))
{
- strcpy(tmp, elems[atoi(swap[i])]);
- strcpy(elems[atoi(swap[i])], elems[atoi(swap[i+1])]);
- strcpy(elems[atoi(swap[i+1])], tmp);
+ strcpy(tmp, elems[atoi(swapB[i])]);
+ strcpy(elems[atoi(swapB[i])], elems[atoi(swapB[i+1])]);
+ strcpy(elems[atoi(swapB[i+1])], tmp);
}
}
@@ -1491,7 +1491,7 @@ void deletecfg()
}
#endif
-void identnames(vector &names, bool builtinonly)
+void identnames(vect &names, bool builtinonly)
{
enumeratekt(*idents, const char *, name, ident, id,
{
diff --git a/source/src/command.h b/source/src/command.h
index a3ca68a9f..6195f989b 100644
--- a/source/src/command.h
+++ b/source/src/command.h
@@ -45,32 +45,32 @@ struct ident
// ID_VAR
ident(int type, const char *name, int minval, int maxval, int *i, void (*fun)(), bool persist, int context)
: type(type), name(name), isconst(false), minval(minval), maxval(maxval), fun(fun),
- sig(NULL), action(NULL), executing(NULL), persist(persist), context(context)
+ sig(nullptr), action(nullptr), executing(nullptr), persist(persist), context(context)
{ storage.i = i; }
// ID_FVAR
ident(int type, const char *name, float minval, float maxval, float *f, void (*fun)(), bool persist, int context)
: type(type), name(name), isconst(false), minvalf(minval), maxvalf(maxval), fun(fun),
- sig(NULL), action(NULL), executing(NULL), persist(persist), context(context)
+ sig(nullptr), action(nullptr), executing(nullptr), persist(persist), context(context)
{ storage.f = f; }
// ID_SVAR
ident(int type, const char *name, char **s, void (*fun)(), bool persist, int context)
: type(type), name(name), isconst(false), minval(0), maxval(0), fun(fun),
- sig(NULL), action(NULL), executing(NULL), persist(persist), context(context)
+ sig(nullptr), action(nullptr), executing(nullptr), persist(persist), context(context)
{ storage.s = s; }
// ID_ALIAS
ident(int type, const char *name, char *action, bool persist, int context)
: type(type), name(name), isconst(false), minval(0), maxval(0), stack(0),
- sig(NULL), action(action), executing(NULL), persist(persist), context(context)
- { storage.i = NULL; }
+ sig(nullptr), action(action), executing(nullptr), persist(persist), context(context)
+ { storage.i = nullptr; }
// ID_COMMAND
ident(int type, const char *name, void (*fun)(), const char *sig, int context)
: type(type), name(name), isconst(false), minval(0), maxval(0), fun(fun),
- sig(sig), action(NULL), executing(NULL), persist(false), context(context)
- { storage.i = NULL; }
+ sig(sig), action(nullptr), executing(nullptr), persist(false), context(context)
+ { storage.i = nullptr; }
};
enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_MDLCFG, IEXC_NUM }; // script execution context
@@ -80,22 +80,22 @@ enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_MDLCFG, IEXC_NUM
#define COMMAND(name, sig) COMMANDN(name, name, sig)
#define COMMANDF(name, sig, inlinefunc) static void __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, sig)
-#define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, true)
-#define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, false)
-#define VARN(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, false)
-#define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, true)
+#define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, nullptr, true)
+#define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, nullptr, false)
+#define VARN(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, nullptr, false)
+#define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, nullptr, true)
#define VARF(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, false)
#define VARFP(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, true)
-#define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, true)
-#define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, false)
+#define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, nullptr, true)
+#define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, nullptr, false)
#define FVARF(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, false)
#define FVARFP(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, true)
-#define SVARP(name, cur) char *name = svariable(#name, cur, &name, NULL, true)
-#define SVAR(name, cur) char *name = svariable(#name, cur, &name, NULL, false)
+#define SVARP(name, cur) char *name = svariable(#name, cur, &name, nullptr, true)
+#define SVAR(name, cur) char *name = svariable(#name, cur, &name, nullptr, false)
#define SVARF(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, false)
#define SVARFP(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, true)
-#define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers
+#define ATOI(s) strtol(s, nullptr, 0) // supports hexadecimal numbers
diff --git a/source/src/console.cpp b/source/src/console.cpp
index 628fac19b..831d3fd9a 100644
--- a/source/src/console.cpp
+++ b/source/src/console.cpp
@@ -273,7 +273,8 @@ struct obitlist : consolebuffer
if (fullconsole || (i < FADEMAX && totalmillis - conlines[i].millis < obitfade * 1000))
if (cl.mergable(conlines[i]))
{
- cl.merge(conlines.remove(i)); // remove, and "merge" into our line
+ cl.merge(conlines[i]); // remove, and "merge" into our line
+ conlines.remove(i);
break;
}
return conlines.insert(0, cl);
@@ -285,8 +286,10 @@ struct obitlist : consolebuffer
loopv(conlines) loopvjrev(conlines)
{
if (j <= i) break;
- else if (conlines[i].mergable(conlines[j]))
- conlines[i].merge(conlines.remove(j));
+ else if (conlines[i].mergable(conlines[j])){
+ conlines[i].merge(conlines[j]);
+ conlines.remove(j);
+ }
}
}
@@ -347,7 +350,7 @@ struct obitlist : consolebuffer
console con;
chatlist chat;
textinputbuffer cmdline;
-char *cmdaction = NULL, *cmdprompt = NULL;
+char *cmdaction = nullptr, *cmdprompt = nullptr;
bool saycommandon = false;
VARFP(maxcon, 10, 200, 1000, con.setmaxlines(maxcon));
@@ -469,7 +472,7 @@ int rendercommand_wip(int x, int y, int w)
// keymap is defined externally in keymap.cfg
-vector keyms;
+vect keyms;
const char *keycmds[keym::NUMACTIONS] = { "bind", "specbind", "editbind" };
inline const char *keycmd(int type) { return type >= 0 && type < keym::NUMACTIONS ? keycmds[type] : ""; }
@@ -486,19 +489,19 @@ COMMAND(keymap, "is");
keym *findbind(const char *key)
{
loopv(keyms) if(!strcasecmp(keyms[i].name, key)) return &keyms[i];
- return NULL;
+ return nullptr;
}
keym *findbinda(const char *action, int type)
{
loopv(keyms) if(!strcasecmp(keyms[i].actions[type], action)) return &keyms[i];
- return NULL;
+ return nullptr;
}
keym *findbindc(int code)
{
loopv(keyms) if(keyms[i].code==code) return &keyms[i];
- return NULL;
+ return nullptr;
}
void findkey(int *code)
@@ -534,8 +537,8 @@ void findkeycode(const char* s)
COMMAND(findkey, "i");
COMMAND(findkeycode, "s");
-keym *keypressed = NULL;
-char *keyaction = NULL;
+keym *keypressed = nullptr;
+char *keyaction = nullptr;
bool bindkey(keym *km, const char *action, int type)
{
@@ -572,7 +575,7 @@ void searchbinds(const char *action, int type)
{
if(!action || !action[0]) return;
if(type < keym::ACTION_DEFAULT || type >= keym::NUMACTIONS) { conoutf("invalid bind type \"%i\"", type); return; }
- vector names;
+ vect names;
loopv(keyms)
{
if(!strcmp(keyms[i].actions[type], action))
@@ -602,11 +605,11 @@ struct releaseaction
keym *key;
char *action;
};
-vector releaseactions;
+vect releaseactions;
char *addreleaseaction(const char *s)
{
- if(!keypressed) return NULL;
+ if(!keypressed) return nullptr;
releaseaction &ra = releaseactions.add();
ra.key = keypressed;
ra.action = newstring(s);
@@ -622,7 +625,7 @@ COMMAND(onrelease, "s");
void saycommand(char *init) // turns input to the command line on or off
{
- SDL_EnableUNICODE(saycommandon = (init!=NULL));
+ SDL_EnableUNICODE(saycommandon = (init!=nullptr));
setscope(false);
setburst(false);
if(!editmode) keyrepeat(saycommandon);
@@ -668,7 +671,7 @@ void pasteconsole(char *dst)
{
#ifdef WIN32
if(!IsClipboardFormatAvailable(CF_TEXT)) return;
- if(!OpenClipboard(NULL)) return;
+ if(!OpenClipboard(nullptr)) return;
char *cb;
do cb = (char *)GlobalLock(GetClipboardData(CF_TEXT));
while(!cb);
@@ -707,7 +710,7 @@ struct hline
{
char *buf, *action, *prompt;
- hline() : buf(NULL), action(NULL), prompt(NULL) {}
+ hline() : buf(nullptr), action(nullptr), prompt(nullptr) {}
~hline()
{
DELETEA(buf);
@@ -728,8 +731,8 @@ struct hline
bool shouldsave()
{
return strcmp(cmdline.buf, buf) ||
- (cmdaction ? !action || strcmp(cmdaction, action) : action!=NULL) ||
- (cmdprompt ? !prompt || strcmp(cmdprompt, prompt) : prompt!=NULL);
+ (cmdaction ? !action || strcmp(cmdaction, action) : action!=nullptr) ||
+ (cmdprompt ? !prompt || strcmp(cmdprompt, prompt) : prompt!=nullptr);
}
void save()
@@ -754,7 +757,7 @@ struct hline
popscontext();
}
};
-vector history;
+vect history;
int histpos = 0;
VARP(maxhistory, 0, 1000, 10000);
@@ -793,7 +796,7 @@ void execbind(keym &k, bool isdown)
keyaction = action;
keypressed = &k;
execute(keyaction);
- keypressed = NULL;
+ keypressed = nullptr;
if(keyaction!=action) delete[] keyaction;
}
k.pressed = isdown;
@@ -849,7 +852,7 @@ void consolekey(int code, bool isdown, int cooked)
// make laptop users happy; LMB shall only work with history
if(code == SDL_AC_BUTTON_LEFT && histpos == history.length()) return;
- hline *h = NULL;
+ hline *h = nullptr;
if(cmdline.buf[0])
{
if(history.empty() || history.last()->shouldsave())
@@ -864,20 +867,20 @@ void consolekey(int code, bool isdown, int cooked)
else h = history.last();
}
histpos = history.length();
- saycommand(NULL);
+ saycommand(nullptr);
if(h) h->run();
}
else if(code==SDLK_ESCAPE || code== SDL_AC_BUTTON_RIGHT)
{
histpos = history.length();
- saycommand(NULL);
+ saycommand(nullptr);
}
}
}
void keypress(int code, bool isdown, int cooked, SDLMod mod)
{
- keym *haskey = NULL;
+ keym *haskey = nullptr;
loopv(keyms) if(keyms[i].code==code) { haskey = &keyms[i]; break; }
if(haskey && haskey->pressed) execbind(*haskey, isdown); // allow pressed keys to release
else if(saycommandon) consolekey(code, isdown, cooked); // keystrokes go to commandline
@@ -899,7 +902,7 @@ void keypress(int code, bool isdown, int cooked, SDLMod mod)
char *getcurcommand()
{
- return saycommandon ? cmdline.buf : NULL;
+ return saycommandon ? cmdline.buf : nullptr;
}
void writebinds(stream *f)
diff --git a/source/src/console.h b/source/src/console.h
index a9e31bc71..a97f70b08 100644
--- a/source/src/console.h
+++ b/source/src/console.h
@@ -1,10 +1,43 @@
-struct cline { char *line; int millis; void cleanup(){ delete[] line; } };
+struct cline {
+ char *line; int millis; void cleanup(){ delete[] line; }
+
+ cline::cline() : line(nullptr), millis(0) {}
+
+ cline& cline::operator=(const cline& other){
+ line = other.line ? newstring(other.line) : nullptr;
+ millis = other.millis;
+ return *this;
+ }
+
+ cline::cline(const cline& other){
+ line = other.line ? newstring(other.line) : nullptr;
+ millis = other.millis;
+ }
+
+ cline& cline::operator=(cline&& other){
+ DELETEA(line);
+ line = other.line;
+ other.line = nullptr;
+ millis = other.millis;
+ return *this;
+ }
+
+ cline::cline(cline&& other){
+ line = other.line;
+ other.line = nullptr;
+ millis = other.millis;
+ }
+
+ virtual cline::~cline(){
+ delete[] line;
+ }
+};
extern int fullconsole;
template struct consolebuffer
{
int maxlines;
- vector conlines;
+ vect conlines;//should be a queue
consolebuffer(int maxlines = 100) : maxlines(maxlines) {}
@@ -13,10 +46,10 @@ template struct consolebuffer
LINE cl;
// constrain the buffer size
if (conlines.length() && conlines.length()>maxlines)
- conlines.pop().cleanup();
- cl.line = newstringbuf("");
+ conlines.pop();
+ cl.line = newstringbuf(sf);
+
cl.millis = millis; // for how long to keep line on screen
- copystring(cl.line, sf);
return conlines.insert(0, cl);
}
diff --git a/source/src/crypto.cpp b/source/src/crypto.cpp
index 72e69d3d6..c90a745b6 100644
--- a/source/src/crypto.cpp
+++ b/source/src/crypto.cpp
@@ -195,12 +195,12 @@ template struct bigint
void print(stream *out) const
{
- vector buf;
+ vect buf;
printdigits(buf);
out->write(buf.getbuf(), buf.length());
}
- void printdigits(vector &buf) const
+ void printdigits(vect &buf) const
{
loopi(len)
{
@@ -215,7 +215,7 @@ template struct bigint
}
}
- template bigint &operator=(const bigint &y)
+ template bigint &operator=(const bigint &y)
{
len = y.len;
memcpy(digits, y.digits, len*sizeof(digit));
@@ -670,7 +670,7 @@ struct ecjacobian
return true;
}
- void print(vector &buf)
+ void print(vect &buf)
{
normalize();
buf.add(y.hasbit(0) ? '-' : '+');
@@ -727,7 +727,7 @@ const ecjacobian ecjacobian::base(
#error Unsupported GF
#endif
-void genprivkey(const char *seed, vector &privstr, vector &pubstr)
+void genprivkey(const char *seed, vect &privstr, vect &pubstr)
{
tiger::hashval hash;
tiger::hash((const uchar *)seed, (int)strlen(seed), hash);
@@ -770,7 +770,7 @@ const char *genpwdhash(const char *name, const char *pwd, int salt)
return temp;
}
-void answerchallenge(const char *privstr, const char *challenge, vector &answerstr)
+void answerchallenge(const char *privstr, const char *challenge, vect &answerstr)
{
gfint privkey;
privkey.parse(privstr);
@@ -791,10 +791,10 @@ void *parsepubkey(const char *pubstr)
void freepubkey(void *pubkey)
{
- delete (ecjacobian *)pubkey;
+ delete reinterpret_cast(pubkey);
}
-void *genchallenge(void *pubkey, const void *seed, int seedlen, vector &challengestr)
+void *genchallenge(void *pubkey, const void *seed, int seedlen, vect &challengestr)
{
tiger::hashval hash;
tiger::hash((const uchar *)seed, sizeof(seed), hash);
@@ -803,7 +803,7 @@ void *genchallenge(void *pubkey, const void *seed, int seedlen, vector &ch
challenge.len = 8*sizeof(hash.bytes)/BI_DIGIT_BITS;
challenge.shrink();
- ecjacobian answer(*(ecjacobian *)pubkey);
+ ecjacobian answer(*reinterpret_cast(pubkey));
answer.mul(challenge);
answer.normalize();
@@ -850,7 +850,7 @@ uint randomMT()
int cur = next;
if(++next >= N)
{
- if(next > N) { seedMT(5489U + time(NULL)); cur = next++; }
+ if(next > N) { seedMT(5489U + time(nullptr)); cur = next++; }
else next = 0;
}
uint y = (state[cur] & 0x80000000U) | (state[next] & 0x7FFFFFFFU);
diff --git a/source/src/crypto_tools.h b/source/src/crypto_tools.h
index 9efab90e1..086ebc96f 100644
--- a/source/src/crypto_tools.h
+++ b/source/src/crypto_tools.h
@@ -1,9 +1,9 @@
#ifndef __CRYPTO_TOOLS_H__
#define __CRYPTO_TOOLS_H__
-#ifdef NULL
-#undef NULL
+#ifdef nullptr
+#undef nullptr
#endif
-#define NULL 0
+#define nullptr 0
typedef unsigned int uint;
diff --git a/source/src/cube.h b/source/src/cube.h
index 14cd633e9..2f8003d85 100644
--- a/source/src/cube.h
+++ b/source/src/cube.h
@@ -37,11 +37,11 @@ extern int cubicsize, mipsize; // cubicsize = ssize^2
extern physent *camera1; // camera representing perspective of player, usually player1
extern playerent *player1; // special client ent that receives input and acts as camera
extern playerent *focus; // the camera points here, or else it's player1
-extern vector players; // all the other clients (in multiplayer)
-extern vector bounceents;
+extern vect players; // all the other clients (in multiplayer)
+extern vect bounceents;
extern bool editmode;
-extern vector ents; // map entities
-extern vector eh_ents; // edithide entities
+extern vect ents; // map entities
+extern vect eh_ents; // edithide entities
extern vec worldpos, camup, camright, camdir; // current target of the crosshair in the world
extern playerent *worldhit; extern int worldhitzone; extern vec worldhitpos;
extern int lastmillis, totalmillis, nextmillis; // last time
diff --git a/source/src/docs.cpp b/source/src/docs.cpp
index b182b7180..34a6d5731 100644
--- a/source/src/docs.cpp
+++ b/source/src/docs.cpp
@@ -11,20 +11,59 @@ struct docargument
char *token, *desc, *values;
bool vararg;
- docargument() : token(NULL), desc(NULL), values(NULL), vararg(false) {};
+ docargument() : token(nullptr), desc(nullptr), values(nullptr), vararg(false) {};
~docargument()
{
DELETEA(token);
DELETEA(desc);
DELETEA(values);
}
+
+ docargument& docargument::operator=(const docargument& other){
+ token = other.token ? newstring(other.token) : nullptr;
+ desc = other.desc ? newstring(other.desc) : nullptr;
+ values = other.values ? newstring(other.values) : nullptr;
+ vararg = other.vararg;
+ return *this;
+ }
+
+ docargument::docargument(const docargument& other){
+ token = other.token ? newstring(other.token) : nullptr;
+ desc = other.desc ? newstring(other.desc) : nullptr;
+ values = other.values ? newstring(other.values) : nullptr;
+ vararg = other.vararg;
+ }
+
+ docargument& docargument::operator=(docargument&& other){
+ DELETEA(token);
+ token = other.token;
+ other.token = nullptr;
+ DELETEA(desc);
+ desc = other.desc;
+ other.desc = nullptr;
+ DELETEA(values);
+ values = other.values;
+ other.values = nullptr;
+ vararg = other.vararg;
+ return *this;
+ }
+
+ docargument::docargument(docargument&& other){
+ token = other.token;
+ other.token = nullptr;
+ desc = other.desc;
+ other.desc = nullptr;
+ values = other.values;
+ other.values = nullptr;
+ vararg = other.vararg;
+ }
};
struct docref
{
char *name, *ident, *url, *article;
- docref() : name(NULL), ident(NULL), url(NULL), article(NULL) {}
+ docref() : name(nullptr), ident(nullptr), url(nullptr), article(nullptr) {}
~docref()
{
DELETEA(name);
@@ -32,74 +71,256 @@ struct docref
DELETEA(url);
DELETEA(article);
}
+
+ docref& docref::operator=(const docref& other){
+ name = other.name ? newstring(other.name) : nullptr;
+ ident = other.ident ? newstring(other.ident) : nullptr;
+ url = other.url ? newstring(other.url) : nullptr;
+ article = other.article ? newstring(other.article) : nullptr;
+ return *this;
+ }
+
+ docref::docref(const docref& other){
+ name = other.name ? newstring(other.name) : nullptr;
+ ident = other.ident ? newstring(other.ident) : nullptr;
+ url = other.url ? newstring(other.url) : nullptr;
+ article = other.article ? newstring(other.article) : nullptr;
+ }
+
+ docref& docref::operator=(docref&& other){
+ DELETEA(name);
+ name = other.name;
+ other.name = nullptr;
+ DELETEA(ident);
+ ident = other.ident;
+ other.ident = nullptr;
+ DELETEA(url);
+ url = other.url;
+ other.url = nullptr;
+ DELETEA(article);
+ article = other.article;
+ other.article = nullptr;
+ return *this;
+ }
+
+ docref::docref(docref&& other){
+ name = other.name;
+ other.name = nullptr;
+ ident = other.ident;
+ other.ident = nullptr;
+ url = other.url;
+ other.url = nullptr;
+ article = other.article;
+ other.article = nullptr;
+ }
};
struct docexample
{
char *code, *explanation;
- docexample() : code(NULL), explanation(NULL) {}
+ docexample() : code(nullptr), explanation(nullptr) {}
~docexample()
{
DELETEA(code);
DELETEA(explanation);
}
+
+ docexample& docexample::operator=(const docexample& other) {
+ code = other.code ? newstring(other.code) : nullptr;
+ explanation = other.explanation ? newstring(other.explanation) : nullptr;
+ return *this;
+ }
+
+ docexample& docexample::operator=(docexample&& other) {
+ DELETEA(code);
+ DELETEA(explanation);
+ code = other.code;
+ explanation = other.explanation;
+ other.code = nullptr;
+ other.explanation = nullptr;
+ return *this;
+ }
+
+ docexample::docexample(docexample&& other){
+ code = other.code;
+ other.code = nullptr;
+ explanation = other.explanation;
+ other.explanation = nullptr;
+ };
+
+ docexample::docexample(const docexample& other){
+ code = other.code ? newstring(other.code) : nullptr;
+ explanation = other.explanation ? newstring(other.explanation) : nullptr;
+ };
};
struct dockey
{
char *alias, *name, *desc;
- dockey() : alias(NULL), name(NULL), desc(NULL) {}
+ dockey() : alias(nullptr), name(nullptr), desc(nullptr) {}
~dockey()
{
DELETEA(alias);
DELETEA(name);
DELETEA(desc);
}
+
+ dockey& dockey::operator=(const dockey& other){
+ alias = other.alias ? newstring(other.alias) : nullptr;
+ name = other.name ? newstring(other.name) : nullptr;
+ desc = other.desc ? newstring(other.desc) : nullptr;
+ return *this;
+ }
+
+ dockey::dockey(const dockey& other){
+ alias = other.alias ? newstring(other.alias) : nullptr;
+ name = other.name ? newstring(other.name) : nullptr;
+ desc = other.desc ? newstring(other.desc) : nullptr;
+ }
+
+ dockey& dockey::operator=(dockey&& other){
+ DELETEA(alias);
+ alias = other.alias;
+ other.alias = nullptr;
+ DELETEA(name);
+ name = other.name;
+ other.name = nullptr;
+ DELETEA(desc);
+ desc = other.desc;
+ other.desc = nullptr;
+ return *this;
+ }
+
+ dockey::dockey(dockey&& other){
+ alias = other.alias;
+ other.alias = nullptr;
+ name = other.name;
+ other.name = nullptr;
+ desc = other.desc;
+ other.desc = nullptr;
+ }
};
struct docident
{
char *name, *desc;
- vector arguments;
- vector remarks;
- vector references;
- vector examples;
- vector keys;
+ vect arguments;
+ vect remarks;
+ vect references;
+ vect examples;
+ vect keys;
- docident() : name(NULL), desc(NULL) {}
+ docident() : name(nullptr), desc(nullptr) {}
~docident()
{
DELETEA(name);
DELETEA(desc);
}
+
+ docident& docident::operator=(const docident& other){
+ name = other.name ? newstring(other.name) : nullptr;
+ desc = other.desc ? newstring(other.desc) : nullptr;
+ arguments = other.arguments;
+ remarks = other.remarks;
+ references = other.references;
+ examples = other.examples;
+ keys = other.keys;
+ return *this;
+ }
+
+ docident::docident(const docident& other){
+ name = other.name ? newstring(other.name) : nullptr;
+ desc = other.desc ? newstring(other.desc) : nullptr;
+ arguments = other.arguments;
+ remarks = other.remarks;
+ references = other.references;
+ examples = other.examples;
+ keys = other.keys;
+ }
+
+ docident& docident::operator=(docident&& other){
+ DELETEA(name);
+ name = other.name;
+ other.name = nullptr;
+ DELETEA(desc);
+ desc = other.desc;
+ other.desc = nullptr;
+ arguments = other.arguments;
+ remarks = other.remarks;
+ references = other.references;
+ examples = other.examples;
+ keys = other.keys;
+ return *this;
+ }
+
+ docident::docident(docident&& other){
+ name = other.name;
+ other.name = nullptr;
+ desc = other.desc;
+ other.desc = nullptr;
+ arguments = other.arguments;
+ remarks = other.remarks;
+ references = other.references;
+ examples = other.examples;
+ keys = other.keys;
+ }
};
struct docsection
{
char *name;
- vector idents;
+ vect idents;
void *menu;
- docsection() : name(NULL), menu(NULL) {};
+ docsection() : name(nullptr), menu(nullptr) {};
~docsection()
{
DELETEA(name);
}
+
+ docsection& docsection::operator=(const docsection& other){
+ name = other.name ? newstring(other.name) : nullptr;
+ idents = other.idents;
+ menu = other.menu;
+ return *this;
+ }
+
+ docsection::docsection(const docsection& other){
+ name = other.name ? newstring(other.name) : nullptr;
+ idents = other.idents;
+ menu = other.menu;
+ }
+
+ docsection& docsection::operator=(docsection&& other){
+ DELETEA(name);
+ name = other.name;
+ other.name = nullptr;
+ idents = other.idents;
+ menu = other.menu;
+ return *this;
+ }
+
+ docsection::docsection(docsection&& other){
+ name = other.name;
+ other.name = nullptr;
+ idents = other.idents;
+ menu = other.menu;
+ }
};
-vector sections;
+vect sections;
hashtable docidents; // manage globally instead of a section tree to ensure uniqueness
-docsection *lastsection = NULL;
-docident *lastident = NULL;
+docsection *lastsection = nullptr;
+docident *lastident = nullptr;
void adddocsection(char *name)
{
if(!name) return;
docsection &s = sections.add();
s.name = newstring(name);
- s.menu = addmenu(s.name, NULL, true, renderdocsection);
+ s.menu = addmenu(s.name, nullptr, true, renderdocsection);
lastsection = &s;
}
@@ -120,7 +341,8 @@ void adddocargument(char *token, char *desc, char *values, char *vararg)
docargument &a = lastident->arguments.add();
a.token = newstring(token);
a.desc = newstring(desc);
- a.values = values && strlen(values) ? newstring(values) : NULL;
+ a.values = values && strlen(values) ? newstring(values) :
+ nullptr;
a.vararg = vararg && atoi(vararg) == 1 ? true : false;
}
@@ -135,9 +357,9 @@ void adddocref(char *name, char *ident, char *url, char *article) // FIXME... so
if(!lastident || !name) return;
docref &r = lastident->references.add();
r.name = newstring(name);
- r.ident = ident && strlen(ident) ? newstring(ident) : NULL;
- r.url = url && strlen(url) ? newstring(url) : NULL;
- r.article = article && strlen(article) ? newstring(article) : NULL;
+ r.ident = ident && strlen(ident) ? newstring(ident) : nullptr;
+ r.url = url && strlen(url) ? newstring(url) : nullptr;
+ r.article = article && strlen(article) ? newstring(article) : nullptr;
}
void adddocexample(char *code, char *explanation)
@@ -145,7 +367,7 @@ void adddocexample(char *code, char *explanation)
if(!lastident || !code) return;
docexample &e = lastident->examples.add();
e.code = newstring(code);
- e.explanation = explanation && strlen(explanation) ? newstring(explanation) : NULL;
+ e.explanation = explanation && strlen(explanation) ? newstring(explanation) : nullptr;
}
void adddockey(char *alias, char *name, char *desc)
@@ -153,8 +375,8 @@ void adddockey(char *alias, char *name, char *desc)
if(!lastident || !alias) return;
dockey &k = lastident->keys.add();
k.alias = newstring(alias);
- k.name = name && strlen(name) ? newstring(name) : NULL;
- k.desc = desc && strlen(desc) ? newstring(desc) : NULL;
+ k.name = name && strlen(name) ? newstring(name) : nullptr;
+ k.desc = desc && strlen(desc) ? newstring(desc) : nullptr;
}
COMMANDN(docsection, adddocsection, "s");
@@ -165,10 +387,10 @@ COMMANDN(docref, adddocref, "ssss");
COMMANDN(docexample, adddocexample, "ss");
COMMANDN(dockey, adddockey, "sss");
-char *cvecstr(vector &cvec, const char *substr, int *rline = NULL)
+char *cvecstr(vect &cvec, const char *substr, int *rline = nullptr)
{
- char *r = NULL;
- loopv(cvec) if(cvec[i]) if((r = strstr(cvec[i], substr)) != NULL)
+ char *r = nullptr;
+ loopv(cvec) if(cvec[i]) if((r = strstr(cvec[i], substr)) != nullptr)
{
if(rline) *rline = i;
break;
@@ -176,7 +398,7 @@ char *cvecstr(vector &cvec, const char *substr, int *rline = NULL)
return r;
}
-void listundoneidents(vector &inames, int allidents)
+void listundoneidents(vect &inames, int allidents)
{
enumeratekt(*idents, const char *, name, ident, id,
{
@@ -185,7 +407,7 @@ void listundoneidents(vector &inames, int allidents)
docident *id = docidents.access(name);
if(id) // search for substrings that indicate undoneness
{
- vector srch;
+ vect srch;
srch.add(id->name);
srch.add(id->desc);
loopvj(id->remarks) srch.add(id->remarks[j]);
@@ -201,7 +423,7 @@ void listundoneidents(vector &inames, int allidents)
srch.add(id->references[j].name);
srch.add(id->references[j].url);
}
- if(cvecstr(srch, "TODO") || cvecstr(srch, "UNDONE")) id = NULL;
+ if(cvecstr(srch, "TODO") || cvecstr(srch, "UNDONE")) id = nullptr;
}
if(!id) inames.add(name);
}
@@ -211,7 +433,7 @@ void listundoneidents(vector &inames, int allidents)
void docundone(int *allidents)
{
- vector inames;
+ vect inames;
listundoneidents(inames, *allidents);
inames.sort(stringsort);
loopv(inames) conoutf("%s", inames[i]);
@@ -219,7 +441,7 @@ void docundone(int *allidents)
void docinvalid()
{
- vector inames;
+ vect inames;
identnames(inames, true);
inames.sort(stringsort);
enumerate(docidents, docident, d,
@@ -233,7 +455,7 @@ void docfind(char *search)
{
enumerate(docidents, docident, i,
{
- vector srch;
+ vect srch;
srch.add(i.name);
srch.add(i.desc);
loopvk(i.remarks) srch.add(i.remarks[k]);
@@ -252,7 +474,7 @@ void docfind(char *search)
char *xmlstringenc(char *d, const char *s, size_t len)
{
- if(!d || !s) return NULL;
+ if(!d || !s) return nullptr;
struct spchar { char c; char repl[8]; } const spchars[] = { {'&', "&"}, {'<', "<"}, {'>', "gt;"}, {'"', """}, {'\'', "'"}};
char *dc = d;
@@ -285,7 +507,7 @@ void docwriteref(int allidents, const char *ref, const char *schemalocation, con
if(!f) return;
char desc[] = "TODO: Description";
- vector inames;
+ vect inames;
if(allidents < 0) identnames(inames, true); // -1: all builtin
else listundoneidents(inames, allidents); // 0: todo builtin, 1: todo builtin + alias
inames.sort(stringsort);
@@ -378,7 +600,7 @@ int numargs(char *args)
if(!args || !strlen(args)) return -1;
int argidx = -1;
- char *argstart = NULL;
+ char *argstart = nullptr;
for(char *t = args; *t; t++)
{
@@ -392,7 +614,7 @@ int numargs(char *args)
case '"': if(*(t-1) != '"') continue; break;
default: break;
}
- argstart = NULL;
+ argstart = nullptr;
}
}
return argidx;
@@ -420,7 +642,7 @@ void renderdoc(int x, int y, int doch)
char *openblock = strrchr(exp+1, '('); //find last open parenthesis
char *closeblock = strrchr(exp+1, ')'); //find last closed parenthesis
- char *temp = NULL;
+ char *temp = nullptr;
if (openblock)
{
@@ -431,14 +653,14 @@ void renderdoc(int x, int y, int doch)
if(!exp || (*exp != '/' && f == 0) || strlen(exp) < 2) return;
char *c = exp+1; if (f > 0) c = exp;
- char *d = NULL; if (temp) d = temp;
+ char *d = nullptr; if (temp) d = temp;
size_t clen = strlen(c);
size_t dlen = 0; if (d) dlen = strlen(d);
bool nc = false; //tests if text after open parenthesis is not a command
- docident *ident = NULL;
+ docident *ident = nullptr;
for(size_t i = 0; i < clen; i++) // search first matching cmd doc by stripping arguments of exp from right to left
{
@@ -472,7 +694,7 @@ void renderdoc(int x, int y, int doch)
if(ident)
{
- vector doclines;
+ vect doclines;
char *label = newstringbuf(); // label
doclines.add(label);
@@ -482,10 +704,10 @@ void renderdoc(int x, int y, int doch)
concatstring(label, " ");
concatstring(label, ident->arguments[j].token);
}
- doclines.add(NULL);
+ doclines.add(nullptr);
doclines.add(ident->desc);
- doclines.add(NULL);
+ doclines.add(nullptr);
if(ident->arguments.length() > 0) // args
{
@@ -530,13 +752,13 @@ void renderdoc(int x, int y, int doch)
a->values ? "(" : "", a->values ? a->values : "", a->values ? ")" : "");
}
- doclines.add(NULL);
+ doclines.add(nullptr);
}
if(ident->remarks.length()) // remarks
{
loopvj(ident->remarks) doclines.add(ident->remarks[j]);
- doclines.add(NULL);
+ doclines.add(nullptr);
}
if(ident->examples.length()) // examples
@@ -547,7 +769,7 @@ void renderdoc(int x, int y, int doch)
doclines.add(ident->examples[j].code);
doclines.add(ident->examples[j].explanation);
}
- doclines.add(NULL);
+ doclines.add(nullptr);
}
if(ident->keys.length()) // default keys
@@ -559,7 +781,7 @@ void renderdoc(int x, int y, int doch)
defformatstring(line)("~%-10s %s", k.name ? k.name : k.alias, k.desc ? k.desc : "");
doclines.add(newstring(line));
}
- doclines.add(NULL);
+ doclines.add(nullptr);
}
if(ident->references.length()) // references
@@ -633,7 +855,7 @@ void renderdoc(int x, int y, int doch)
}
}
-void *docmenu = NULL;
+void *docmenu = nullptr;
struct msection { char *name; string cmd; };
@@ -644,7 +866,7 @@ int msectionsort(const msection *a, const msection *b)
void renderdocsection(void *menu, bool init)
{
- static vector msections;
+ static vect msections;
msections.shrink(0);
loopv(sections)
@@ -668,7 +890,7 @@ struct maction { string cmd; };
void renderdocmenu(void *menu, bool init)
{
- static vector actions;
+ static vect actions;
actions.shrink(0);
menureset(menu);
loopv(sections)
diff --git a/source/src/editing.cpp b/source/src/editing.cpp
index 2354ce06c..d68d57dce 100644
--- a/source/src/editing.cpp
+++ b/source/src/editing.cpp
@@ -8,7 +8,7 @@ bool editmode = false;
// invariant: all code assumes that these are kept inside MINBORD distance of the edge of the map
// => selections are checked when they are made or when the world is reloaded
-vector sels;
+vect sels;
#define loopselxy(sel, b) { makeundo(sel); loop(x,(sel).xs) loop(y,(sel).ys) if(!OUTBORD(sel.x+x, sel.y+y)) { sqr *s = S((sel).x+x, (sel).y+y); b; } remip(sel); }
#define loopselsxy(b) { loopv(sels) loopselxy(sels[i], b); }
@@ -83,9 +83,9 @@ bool noselection()
char *editinfo()
{
static string info;
- if(!editmode) return NULL;
+ if(!editmode) return nullptr;
int e = closestent();
- if(e<0) return NULL;
+ if(e<0) return nullptr;
entity &c = ents[e];
string selinfo = "no selection";
if(selset()) formatstring(selinfo)("selection = (%d, %d)", (sels.last()).xs, (sels.last()).ys);
@@ -231,7 +231,7 @@ void cursorupdate() // called every frame fr
glLineWidth(1);
}
-vector undos; // unlimited undo
+vect undos; // unlimited undo
VAR(undomegs, 0, 1, 10); // bounded by n megs
void pruneundos(int maxremain) // bound memory
@@ -240,7 +240,7 @@ void pruneundos(int maxremain) // bound memory
loopvrev(undos)
{
t += undos[i]->xs*undos[i]->ys*sizeof(sqr);
- if(t>maxremain) delete[] (uchar *)undos.remove(i);
+ if(t>maxremain) undos.remove(i);
}
}
@@ -259,7 +259,7 @@ void editundo()
freeblock(p);
}
-vector copybuffers;
+vect copybuffers;
void resetcopybuffers()
{
@@ -350,8 +350,8 @@ void editdrag(bool isdown)
if (identexists("newselkeys"))
{
- extern vector keyms;
- vector elems;
+ extern vect keyms;
+ vect elems;
explodelist(getalias("newselkeys"), elems);
loopi(keyms.length()) if(keyms[i].pressed) loopj(elems.length())
@@ -686,7 +686,7 @@ void selfliprotate(block &sel, int dir)
{
makeundo(sel);
block *org = blockcopy(sel);
- const sqr *q = (const sqr *)(org + 1);
+ const sqr *q = reinterpret_cast(org + 1);
int x1 = sel.x, x2 = sel.x + sel.xs - 1, y1 = sel.y, y2 = sel.y + sel.ys - 1, x, y;
switch(dir)
{
diff --git a/source/src/entities.cpp b/source/src/entities.cpp
index ada9df670..9011972db 100644
--- a/source/src/entities.cpp
+++ b/source/src/entities.cpp
@@ -5,8 +5,8 @@
VAR(showclips, 0, 1, 1);
VAR(showmodelclipping, 0, 1, 1);
-vector ents;
-vector eh_ents; // edithide entities
+vect ents;
+vect eh_ents; // edithide entities
const char *entmdlnames[] =
{
"pistolclips", "ammobox", "nade", "health", "helmet", "kevlar", "akimbo", "nades", //FIXME
@@ -98,7 +98,7 @@ void setedithide(char *text) // FIXME: human indexing inside
if(sn!=-1) { loopv(eh_ents) { if(eh_ents[i]==sn) { k = true; } } }
else sn = tn;
if(!k) { if(sn>0 && snweapons[GUN_AKIMBO]; break;
@@ -483,7 +483,7 @@ void flagstolen(int flag, int act)
{
playerent *actor = getclient(act);
flaginfo &f = flaginfos[flag];
- f.actor = actor; // could be NULL if we just connected
+ f.actor = actor; // could be nullptr if we just connected
f.actor_cn = act;
f.flagent->spawned = false;
}
@@ -531,7 +531,7 @@ void flagdropped(int flag, float x, float y, float z)
void flaginbase(int flag)
{
flaginfo &f = flaginfos[flag];
- f.actor = NULL; f.actor_cn = -1;
+ f.actor = nullptr; f.actor_cn = -1;
f.pos = vec(f.flagent->x, f.flagent->y, f.flagent->z);
f.flagent->spawned = true;
}
@@ -582,7 +582,7 @@ void entstats(void)
COMMAND(entstats, "");
-vector changedents;
+vect changedents;
int lastentsync = 0;
void syncentchanges(bool force)
diff --git a/source/src/entity.h b/source/src/entity.h
index 0021977a6..1cc43c90f 100644
--- a/source/src/entity.h
+++ b/source/src/entity.h
@@ -249,7 +249,7 @@ class dynent : public physent // animated ent
prev[i].reset();
current[i].reset();
lastanimswitchtime[i] = -1;
- lastmodel[i] = NULL;
+ lastmodel[i] = nullptr;
}
lastrendered = 0;
}
@@ -339,7 +339,7 @@ class playerstate
case I_ARMOUR:
return &powerupstats[type-I_HEALTH];
default:
- return NULL;
+ return nullptr;
}
}
@@ -582,7 +582,7 @@ struct eventicon
TOTAL
};
int type, millis;
- eventicon(int type, int millis) : type(type), millis(millis){}
+ eventicon(int type=0, int millis=0) : type(type), millis(millis){}
};
struct damageinfo
@@ -617,7 +617,7 @@ class playerent : public dynent, public playerstate
int spectatemode, thirdperson;
int eardamagemillis;
int respawnoffset;
- vector icons;
+ vect icons;
kd weapstats[NUMGUNS];
bool allowmove() { return state!=CS_DEAD || spectatemode==SM_FLY; }
@@ -646,10 +646,10 @@ class playerent : public dynent, public playerstate
frags(0), flagscore(0), deaths(0), points(0), lastpain(0), lastvoicecom(0), lasthit(0), clientrole(CR_DEFAULT),
vote(VOTE_NEUTRAL), voternum(0),
team(TEAM_SPECT), build(0), spectatemode(SM_NONE), thirdperson(0), eardamagemillis(0), respawnoffset(0),
- prevweaponsel(NULL), weaponsel(NULL), nextweaponsel(NULL), lastattackweapon(NULL),
+ prevweaponsel(nullptr), weaponsel(nullptr), nextweaponsel(nullptr), lastattackweapon(nullptr),
smoothmillis(-1),
head(-1, -1, -1), eject(-1, -1, -1), muzzle(-1, -1, -1), ignored(false), muted(false),
- ownernum(-1), level(0), pBot(NULL), enemy(NULL)
+ ownernum(-1), level(0), pBot(nullptr), enemy(nullptr)
{
type = ENT_PLAYER;
name[0] = 0;
@@ -657,7 +657,7 @@ class playerent : public dynent, public playerstate
aboveeye = PLAYERABOVEEYE;
radius = PLAYERRADIUS;
maxspeed = 16.0f;
- skin_noteam = skin_cla = skin_rvsf = NULL;
+ skin_noteam = skin_cla = skin_rvsf = nullptr;
loopi(2) nextskin[i] = 0;
loopi(NUMGUNS) weapstats[i].deaths = weapstats[i].kills = 0;
respawn(G_DM, G_M_NONE);
@@ -728,7 +728,7 @@ class playerent : public dynent, public playerstate
history.reset();
if(weaponsel) weaponsel->reset();
lastaction = 0;
- lastattackweapon = NULL;
+ lastattackweapon = nullptr;
attacking = false;
//extern int lastmillis;
weaponchanging = 0; // spawnkill is bad though // lastmillis - weapons[gunselect]->weaponchangetime / 2; // 2011jan16:ft: for a little no-shoot after spawn
@@ -797,7 +797,7 @@ class bounceent : public physent
bool plclipped;
playerent *owner;
- bounceent() : bouncetype(BT_NONE), rotspeed(1.0f), plclipped(false), owner(NULL)
+ bounceent() : bouncetype(BT_NONE), rotspeed(1.0f), plclipped(false), owner(nullptr)
{
type = ENT_BOUNCE;
maxspeed = 40;
@@ -838,7 +838,7 @@ struct pckserver
bool pending, responsive;
int ping;
- pckserver() : addr(NULL), pending(false), responsive(true), ping(-1) {}
+ pckserver() : addr(nullptr), pending(false), responsive(true), ping(-1) {}
};
enum { PCK_TEXTURE, PCK_SKYBOX, PCK_MAPMODEL, PCK_AUDIO, PCK_MAP, PCK_NUM };
@@ -851,6 +851,6 @@ struct package
pckserver *source;
CURL *curl;
- package() : name(NULL), type(-1), number(0), pending(false), source(NULL), curl(NULL) {}
+ package() : name(nullptr), type(-1), number(0), pending(false), source(nullptr), curl(nullptr) {}
};
#endif
diff --git a/source/src/hudgun.h b/source/src/hudgun.h
index 1ff4aaf3f..3950684e6 100644
--- a/source/src/hudgun.h
+++ b/source/src/hudgun.h
@@ -97,7 +97,7 @@ struct weaponmove
swayspeed *= plspeed/2;
swayupspeed *= plspeed/2;
- swap(sway.x, sway.y);
+ swapB(sway.x, sway.y);
sway.y = -sway.y;
swayupspeed = fabs(swayupspeed); // sway a semicirle only
diff --git a/source/src/log.cpp b/source/src/log.cpp
index d893755a3..5d7ffe318 100644
--- a/source/src/log.cpp
+++ b/source/src/log.cpp
@@ -21,7 +21,7 @@
static const char *levelprefix[] = { "", "", "", "WARNING: ", "ERROR: " };
static const char *levelname[] = { "DEBUG", "VERBOSE", "INFO", "WARNING", "ERROR", "DISABLED" };
-static FILE *fp = NULL;
+static FILE *fp = nullptr;
static string filepath, ident, ident_full;
static int facility = -1,
#ifdef AC_USE_SYSLOG_DISABLE
@@ -54,7 +54,7 @@ bool initlogging(const char *identity, int facility_, int consolethres, int file
}
static int lognum = 0;
formatstring(filepath)("serverlog_%s_%s.part%d.txt", timestring(true), identity, ++lognum);
- if(fp) { fclose(fp); fp = NULL; }
+ if(fp) { fclose(fp); fp = nullptr; }
if(filethreshold < ACLOG_NUM)
{
fp = fopen(filepath, "w");
@@ -72,7 +72,7 @@ bool initlogging(const char *identity, int facility_, int consolethres, int file
void exitlogging()
{
- if(fp) { fclose(fp); fp = NULL; }
+ if(fp) { fclose(fp); fp = nullptr; }
#ifdef AC_USE_SYSLOG
if(syslogthreshold < ACLOG_NUM) closelog();
#endif
diff --git a/source/src/main.cpp b/source/src/main.cpp
index 3730289b1..d58348b4e 100644
--- a/source/src/main.cpp
+++ b/source/src/main.cpp
@@ -17,7 +17,7 @@ void cleanup(char *msg) // single program exit point;
if(msg)
{
#ifdef WIN32
- MessageBox(NULL, msg, "ACR fatal error", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR);
+ MessageBox(nullptr, msg, "ACR fatal error", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR);
#else
printf("%s", msg);
#endif
@@ -37,7 +37,7 @@ void quit() // normal exit
writepcksourcecfg();
if(resetcfg) deletecfg();
else writecfg();
- cleanup(NULL);
+ cleanup(nullptr);
popscontext();
exit(EXIT_SUCCESS);
}
@@ -61,7 +61,7 @@ void fatal(const char *s, ...) // failure exit
exit(EXIT_FAILURE);
}
-SDL_Surface *screen = NULL;
+SDL_Surface *screen = nullptr;
static int initing = NOT_INITING;
static bool restoredinits = false;
@@ -288,7 +288,7 @@ void jpeg_screenshot(const char *imagepath, bool mapshot = false)
VARP(pngcompress, 0, 9, 9);
-void writepngchunk(stream *f, const char *type, uchar *data = NULL, uint len = 0)
+void writepngchunk(stream *f, const char *type, uchar *data = nullptr, uint len = 0)
{
f->putbig(len);
f->write(type, 4);
@@ -325,9 +325,9 @@ int save_png(const char *filename, SDL_Surface *image)
crc = crc32(crc, (const Bytef *)"IDAT", 4);
z_stream z;
- z.zalloc = NULL;
- z.zfree = NULL;
- z.opaque = NULL;
+ z.zalloc = nullptr;
+ z.zfree = nullptr;
+ z.opaque = nullptr;
if(deflateInit(&z, pngcompress) != Z_OK)
goto error;
@@ -542,7 +542,7 @@ void setupscreen(int &usedcolorbits, int &useddepthbits, int &usedfsaa)
putenv("SDL_VIDEO_CENTERED=1"); //Center window
#endif
if(fullscreen) flags |= SDL_FULLSCREEN;
- SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL|flags);
+ SDL_Rect **modes = SDL_ListModes(nullptr, SDL_OPENGL|flags);
if(modes && modes!=(SDL_Rect **)-1)
{
bool hasmode = false;
@@ -714,7 +714,7 @@ void keyrepeat(bool on)
SDL_DEFAULT_REPEAT_INTERVAL);
}
-vector events;
+vect events;
void pushevent(const SDL_Event &e)
{
@@ -816,7 +816,7 @@ void checkinput()
int tdx=0,tdy=0;
while(events.length() || SDL_PollEvent(&event))
{
- if(events.length()) event = events.remove(0);
+ if(events.length()) { event = events[0]; events.remove(0); }
switch(event.type)
{
@@ -892,7 +892,7 @@ VARP(gamestarts, 0, 0, INT_MAX);
const char *rndmapname()
{
- vector maps;
+ vect maps;
listfiles("packages/maps/official", "cgz", maps);
char *map = newstring(maps[rnd(maps.length())]);
maps.deletearrays();
@@ -949,7 +949,7 @@ void connectprotocol(char *protocolstring, string &servername, int &serverport,
}
#if defined(WIN32) && !defined(__GNUC__)
-static char *parsecommandline(const char *src, vector &args)
+static char *parsecommandline(const char *src, vect &args)
{
char *buf = new char[strlen(src) + 1], *dst = buf;
for(;;)
@@ -965,14 +965,14 @@ static char *parsecommandline(const char *src, vector &args)
}
*dst++ = '\0';
}
- args.add(NULL);
+ args.add(nullptr);
return buf;
}
int WINAPI WinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrev, _In_ LPSTR szCmdLine, _In_ int sw)
{
- vector args;
+ vect args;
char *buf = parsecommandline(GetCommandLine(), args);
SDL_SetModuleHandle(hInst);
int status = SDL_main(args.length()-1, args.getbuf());
@@ -998,13 +998,13 @@ int main(int argc, char **argv)
bool dedicated = false;
bool quitdirectly = false;
- char *initscript = NULL;
- char *initdemo = NULL;
+ char *initscript = nullptr;
+ char *initdemo = nullptr;
bool direct_connect = false; // to connect via assaultcube:// browser switch
string servername, password;
int serverport;
- const char *initmap = NULL;
+ const char *initmap = nullptr;
pushscontext(IEXC_CFG);
@@ -1116,7 +1116,7 @@ int main(int argc, char **argv)
//initfont();
initlog("video: misc");
- SDL_WM_SetCaption("AssaultCube Reloaded", NULL);
+ SDL_WM_SetCaption("AssaultCube Reloaded", nullptr);
keyrepeat(false);
SDL_ShowCursor(0);
@@ -1147,15 +1147,15 @@ int main(int argc, char **argv)
initlog("cfg");
extern void *scoremenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu;
- scoremenu = addmenu("score", "columns", false, renderscores, NULL, false, true);
- servmenu = addmenu("server", NULL, true, refreshservers, serverskey);
- searchmenu = addmenu("search", NULL, true, refreshservers, serverskey);
- serverinfomenu = addmenu("serverinfo", NULL, true, refreshservers, serverinfokey);
- kickmenu = addmenu("kick player", NULL, true, refreshsopmenu);
- banmenu = addmenu("ban player", NULL, true, refreshsopmenu);
- forceteammenu = addmenu("force team", NULL, true, refreshsopmenu);
- giveadminmenu = addmenu("give admin", NULL, true, refreshsopmenu);
- docmenu = addmenu("reference", NULL, true, renderdocmenu);
+ scoremenu = addmenu("score", "columns", false, renderscores, nullptr, false, true);
+ servmenu = addmenu("server", nullptr, true, refreshservers, serverskey);
+ searchmenu = addmenu("search", nullptr, true, refreshservers, serverskey);
+ serverinfomenu = addmenu("serverinfo", nullptr, true, refreshservers, serverinfokey);
+ kickmenu = addmenu("kick player", nullptr, true, refreshsopmenu);
+ banmenu = addmenu("ban player", nullptr, true, refreshsopmenu);
+ forceteammenu = addmenu("force team", nullptr, true, refreshsopmenu);
+ giveadminmenu = addmenu("give admin", nullptr, true, refreshsopmenu);
+ docmenu = addmenu("reference", nullptr, true, renderdocmenu);
applymenu = addmenu("apply", "apply changes now?", true, refreshapplymenu);
exec("config/scontext.cfg");
@@ -1329,4 +1329,4 @@ int main(int argc, char **argv)
}
VAR(version, 1, AC_VERSION, 0);
-VAR(protocol, 1, PROTOCOL_VERSION, 0);
\ No newline at end of file
+VAR(protocol, 1, PROTOCOL_VERSION, 0);
diff --git a/source/src/master.cpp b/source/src/master.cpp
index ad0cc490f..f3011e1d7 100644
--- a/source/src/master.cpp
+++ b/source/src/master.cpp
@@ -15,7 +15,7 @@
#define KEEPALIVE_TIME (65*60*1000)
#define SERVER_LIMIT (10*1024)
-FILE *logfile = NULL;
+FILE *logfile = nullptr;
// for AUTH:
struct userinfo
@@ -46,7 +46,7 @@ struct baninfo
{
enet_uint32 ip, mask;
};
-vector bans, servbans, gbans;
+vect bans, servbans, gbans;
void clearbans()
{
@@ -56,14 +56,14 @@ void clearbans()
}
COMMAND(clearbans, "");
-void addban(vector &bans, const char *name)
+void addban(vect &bans, const char *name)
{
union { uchar b[sizeof(enet_uint32)]; enet_uint32 i; } ip, mask;
ip.i = 0;
mask.i = 0;
loopi(4)
{
- char *end = NULL;
+ char *end = nullptr;
int n = strtol(name, &end, 10);
if(!end) break;
if(end > name) { ip.b[i] = n; mask.b[i] = 0xFF; }
@@ -94,7 +94,7 @@ char *printban(const baninfo &ban, char *buf)
return buf;
}
-bool checkban(vector &bans, enet_uint32 host)
+bool checkban(vect &bans, enet_uint32 host)
{
loopv(bans) if((host & bans[i].mask) == bans[i].ip) return true;
return false;
@@ -116,15 +116,15 @@ struct gameserver
int port, numpings;
enet_uint32 lastping, lastpong;
};
-vector gameservers;
+vect gameservers;
struct messagebuf
{
- vector &owner;
- vector buf;
+ vect &owner;
+ vect buf;
int refs;
- messagebuf(vector &owner) : owner(owner), refs(0) {}
+ messagebuf(vect &owner) : owner(owner), refs(0) {}
const char *getbuf() { return buf.getbuf(); }
int length() { return buf.length(); }
@@ -146,7 +146,7 @@ struct messagebuf
buf.put(m.buf.getbuf(), m.buf.length());
}
};
-vector gameserverlists, gbanlists;
+vect gameserverlists, gbanlists;
bool updateserverlist = true;
struct client
@@ -155,18 +155,18 @@ struct client
ENetSocket socket;
char input[INPUT_LIMIT];
messagebuf *message;
- vector output;
+ vect output;
int inputpos, outputpos;
enet_uint32 connecttime, lastinput;
int servport;
enet_uint32 lastauth; // for AUTH
- vector authreqs; // for AUTH
+ vect authreqs; // for AUTH
bool shouldpurge;
bool registeredserver;
- client() : message(NULL), inputpos(0), outputpos(0), servport(-1), lastauth(0), shouldpurge(false), registeredserver(false) {}
+ client() : message(nullptr), inputpos(0), outputpos(0), servport(-1), lastauth(0), shouldpurge(false), registeredserver(false) {}
};
-vector clients;
+vect clients;
ENetSocket serversocket = ENET_SOCKET_NULL;
@@ -234,7 +234,7 @@ bool setuppingsocket()
return true;
}
-void setupserver(int port, const char *ip = NULL)
+void setupserver(int port, const char *ip = nullptr)
{
ENetAddress address;
address.host = ENET_HOST_ANY;
@@ -258,7 +258,7 @@ void setupserver(int port, const char *ip = NULL)
enet_time_set(0);
- starttime = time(NULL);
+ starttime = time(nullptr);
char *ct = ctime(&starttime);
if(strchr(ct, '\n')) *strchr(ct, '\n') = '\0';
conoutf("*** Starting master server on %s %d at %s ***", ip ? ip : "localhost", port, ct);
@@ -355,7 +355,7 @@ client *findclient(gameserver &s)
if(s.address.host == c.address.host && s.port == c.servport)
return &c;
}
- return NULL;
+ return nullptr;
}
void servermessage(gameserver &s, const char *msg)
@@ -482,7 +482,7 @@ void reqauth(client &c, uint id, char *name)
purgeauths(c);
- time_t t = time(NULL);
+ time_t t = time(nullptr);
char *ct = ctime(&t);
if(ct)
{
@@ -511,7 +511,7 @@ void reqauth(client &c, uint id, char *name)
a.reqtime = servtime;
a.id = id;
uint seed[3] = { starttime, servtime, randomMT() };
- static vector buf;
+ static vect buf;
buf.setsize(0);
a.answer = genchallenge(u->pubkey, seed, sizeof(seed), buf);
@@ -650,7 +650,7 @@ void checkclients()
ENetBuffer buf;
buf.data = (void *)&data[c.outputpos];
buf.dataLength = len-c.outputpos;
- int res = enet_socket_send(c.socket, NULL, &buf, 1);
+ int res = enet_socket_send(c.socket, nullptr, &buf, 1);
if(res>=0)
{
c.outputpos += res;
@@ -660,7 +660,7 @@ void checkclients()
else
{
c.message->purge();
- c.message = NULL;
+ c.message = nullptr;
}
c.outputpos = 0;
if(!c.message && c.output.empty() && c.shouldpurge)
@@ -677,7 +677,7 @@ void checkclients()
ENetBuffer buf;
buf.data = &c.input[c.inputpos];
buf.dataLength = sizeof(c.input) - c.inputpos;
- int res = enet_socket_receive(c.socket, NULL, &buf, 1);
+ int res = enet_socket_receive(c.socket, nullptr, &buf, 1);
if(res>0)
{
c.inputpos += res;
@@ -712,14 +712,14 @@ int main(int argc, char **argv)
int port = AC_MASTER_PORT;
if(argc>=2) dir = argv[1];
if(argc>=3 && argv[2][0]) port = atoi(argv[2]);
- if(argc>=4) ip = argv[3][0] ? argv[3] : NULL;
+ if(argc>=4) ip = argv[3][0] ? argv[3] : nullptr;
defformatstring(logname)("%smaster.log", dir);
defformatstring(cfgname)("%smaster.cfg", dir);
path(logname);
path(cfgname);
logfile = fopen(logname, "a");
if(!logfile) logfile = stdout;
- setvbuf(logfile, NULL, _IOLBF, 0);
+ setvbuf(logfile, nullptr, _IOLBF, 0);
#ifndef WIN32
signal(SIGUSR1, reloadsignal);
#endif
diff --git a/source/src/md2.h b/source/src/md2.h
index 580cf6061..e52cbce40 100644
--- a/source/src/md2.h
+++ b/source/src/md2.h
@@ -34,10 +34,10 @@ struct md2 : vertmodel
struct md2part : part
{
- void gentcverts(int *glcommands, vector &tcverts, vector &vindexes, vector &tris)
+ void gentcverts(int *glcommands, vect &tcverts, vect