From b8840c4571e000795d4ec5627c3e0df3a52176ce Mon Sep 17 00:00:00 2001 From: Chairn Date: Sat, 2 Jul 2022 02:13:59 +0200 Subject: [PATCH] Replaced magic number with `MAX_CHECKPOINTS` --- src/engine/shared/protocol.h | 1 + src/game/server/entities/character.h | 2 +- src/game/server/save.cpp | 4 ++-- src/game/server/save.h | 2 +- src/game/server/scoreworker.h | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/engine/shared/protocol.h b/src/engine/shared/protocol.h index 0777a0569..01f08e0d1 100644 --- a/src/engine/shared/protocol.h +++ b/src/engine/shared/protocol.h @@ -85,6 +85,7 @@ enum SERVERINFO_MAX_CLIENTS = 128, MAX_CLIENTS = 64, VANILLA_MAX_CLIENTS = 16, + MAX_CHECKPOINTS = 25, MAX_INPUT_SIZE = 128, MAX_SNAPSHOT_PACKSIZE = 900, diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index fca628606..0f7508181 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -208,7 +208,7 @@ public: int m_TimeCpBroadcastEndTick; int m_LastTimeCp; int m_LastTimeCpBroadcasted; - float m_aCurrentTimeCp[25]; + float m_aCurrentTimeCp[MAX_CHECKPOINTS]; int m_TileIndex; int m_TileFIndex; diff --git a/src/game/server/save.cpp b/src/game/server/save.cpp index f4aca7c5c..3dc498741 100644 --- a/src/game/server/save.cpp +++ b/src/game/server/save.cpp @@ -65,7 +65,7 @@ void CSaveTee::Save(CCharacter *pChr) m_LastTimeCp = pChr->m_LastTimeCp; m_LastTimeCpBroadcasted = pChr->m_LastTimeCpBroadcasted; - for(int i = 0; i < 25; i++) + for(int i = 0; i < MAX_CHECKPOINTS; i++) m_aCurrentTimeCp[i] = pChr->m_aCurrentTimeCp[i]; m_NotEligibleForFinish = pChr->m_pPlayer->m_NotEligibleForFinish; @@ -158,7 +158,7 @@ void CSaveTee::Load(CCharacter *pChr, int Team, bool IsSwap) pChr->m_LastTimeCp = m_LastTimeCp; pChr->m_LastTimeCpBroadcasted = m_LastTimeCpBroadcasted; - for(int i = 0; i < 25; i++) + for(int i = 0; i < MAX_CHECKPOINTS; i++) pChr->m_aCurrentTimeCp[i] = m_aCurrentTimeCp[i]; pChr->m_pPlayer->m_NotEligibleForFinish = pChr->m_pPlayer->m_NotEligibleForFinish || m_NotEligibleForFinish; diff --git a/src/game/server/save.h b/src/game/server/save.h index 2d571dcbd..7d25f65f6 100644 --- a/src/game/server/save.h +++ b/src/game/server/save.h @@ -77,7 +77,7 @@ private: int m_TimeCpBroadcastEndTime; int m_LastTimeCp; int m_LastTimeCpBroadcasted; - float m_aCurrentTimeCp[25]; + float m_aCurrentTimeCp[MAX_CHECKPOINTS]; int m_NotEligibleForFinish; diff --git a/src/game/server/scoreworker.h b/src/game/server/scoreworker.h index bd580ffd5..733d3b5b6 100644 --- a/src/game/server/scoreworker.h +++ b/src/game/server/scoreworker.h @@ -18,7 +18,7 @@ class IGameController; enum { - NUM_CHECKPOINTS = 25, + NUM_CHECKPOINTS = MAX_CHECKPOINTS, TIMESTAMP_STR_LENGTH = 20, // 2019-04-02 19:38:36 };