Remove magic number: 256 -> NUM_TUNINGZONES

This commit is contained in:
def 2014-11-25 22:47:25 +01:00
parent bba82712e0
commit 21472046df
2 changed files with 18 additions and 12 deletions

View file

@ -1671,7 +1671,7 @@ void CGameContext::ConTuneZone(IConsole::IResult *pResult, void *pUserData)
const char *pParamName = pResult->GetString(1);
float NewValue = pResult->GetFloat(2);
if (List >= 0 && List < 256)
if (List >= 0 && List < NUM_TUNINGZONES)
{
if(pSelf->TuningList()[List].Set(pParamName, NewValue))
{
@ -1690,7 +1690,7 @@ void CGameContext::ConTuneDumpZone(IConsole::IResult *pResult, void *pUserData)
CGameContext *pSelf = (CGameContext *)pUserData;
int List = pResult->GetInteger(0);
char aBuf[256];
if (List >= 0 && List < 256)
if (List >= 0 && List < NUM_TUNINGZONES)
{
for(int i = 0; i < pSelf->TuningList()[List].Num(); i++)
{
@ -1709,7 +1709,7 @@ void CGameContext::ConTuneResetZone(IConsole::IResult *pResult, void *pUserData)
if (pResult->NumArguments())
{
int List = pResult->GetInteger(0);
if (List >= 0 && List < 256)
if (List >= 0 && List < NUM_TUNINGZONES)
{
pSelf->TuningList()[List] = TuningParams;
char aBuf[256];
@ -1720,7 +1720,7 @@ void CGameContext::ConTuneResetZone(IConsole::IResult *pResult, void *pUserData)
}
else
{
for (int i = 0; i < 256; i++)
for (int i = 0; i < NUM_TUNINGZONES; i++)
{
*(pSelf->TuningList()+i) = TuningParams;
pSelf->SendTuningParams(-1, i);
@ -1735,7 +1735,7 @@ void CGameContext::ConTuneSetZoneMsgEnter(IConsole::IResult *pResult, void *pUse
if (pResult->NumArguments())
{
int List = pResult->GetInteger(0);
if (List >= 0 && List < 256)
if (List >= 0 && List < NUM_TUNINGZONES)
{
str_format(pSelf->m_ZoneEnterMsg[List], sizeof(pSelf->m_ZoneEnterMsg[List]), pResult->GetString(1));
}
@ -1748,7 +1748,7 @@ void CGameContext::ConTuneSetZoneMsgLeave(IConsole::IResult *pResult, void *pUse
if (pResult->NumArguments())
{
int List = pResult->GetInteger(0);
if (List >= 0 && List < 256)
if (List >= 0 && List < NUM_TUNINGZONES)
{
str_format(pSelf->m_ZoneLeaveMsg[List], sizeof(pSelf->m_ZoneLeaveMsg[List]), pResult->GetString(1));
}
@ -2251,7 +2251,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
// Reset Tunezones
CTuningParams TuningParams;
for (int i = 0; i < 256; i++)
for (int i = 0; i < NUM_TUNINGZONES; i++)
{
TuningList()[i] = TuningParams;
TuningList()[i].Set("gun_curvature", 0);
@ -2261,7 +2261,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
TuningList()[i].Set("shotgun_speeddiff", 0);
}
for (int i = 0; i < 256; i++) // decided to send no text on changing Tunezones for now
for (int i = 0; i < NUM_TUNINGZONES; i++) // decided to send no text on changing Tunezones for now
{
str_format(m_ZoneEnterMsg[i], sizeof(m_ZoneEnterMsg[i]), "", i);
str_format(m_ZoneLeaveMsg[i], sizeof(m_ZoneLeaveMsg[i]), "", i);
@ -2319,7 +2319,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
Tuning()->Set("player_collision", 0);
Tuning()->Set("player_hooking", 0);
for (int i = 0; i < 256; i++)
for (int i = 0; i < NUM_TUNINGZONES; i++)
{
TuningList()[i].Set("player_collision", 0);
TuningList()[i].Set("player_hooking", 0);

View file

@ -45,6 +45,12 @@ typedef unsigned __int64 uint64_t;
All players (CPlayer::snap)
*/
enum
{
NUM_TUNINGZONES = 256
};
class CGameContext : public IGameServer
{
IServer *m_pServer;
@ -53,7 +59,7 @@ class CGameContext : public IGameServer
CCollision m_Collision;
CNetObjHandler m_NetObjHandler;
CTuningParams m_Tuning;
CTuningParams m_TuningList[256];
CTuningParams m_TuningList[NUM_TUNINGZONES];
static void ConTuneParam(IConsole::IResult *pResult, void *pUserData);
static void ConTuneReset(IConsole::IResult *pResult, void *pUserData);
@ -127,8 +133,8 @@ public:
char m_aVoteReason[VOTE_REASON_LENGTH];
int m_NumVoteOptions;
int m_VoteEnforce;
char m_ZoneEnterMsg[256][256]; // 0 is used for switching from or to area without tunings
char m_ZoneLeaveMsg[256][256];
char m_ZoneEnterMsg[NUM_TUNINGZONES][256]; // 0 is used for switching from or to area without tunings
char m_ZoneLeaveMsg[NUM_TUNINGZONES][256];
enum
{