reset that one global int

This commit is contained in:
jenz 2024-02-04 22:15:55 +01:00
parent b38426245c
commit 1e1eed7242

View File

@ -801,89 +801,92 @@ public Action AddDownloadContent()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void LoadExtraSettings() public void LoadExtraSettings()
{ {
Handle l_hFile = INVALID_HANDLE; g_iSoundIndexes = 0; //forgot to reset, would run out bounds as well.
char l_cLine[g_dLength];
if (!FileExists(g_cPathsExtra))
{ Handle l_hFile = INVALID_HANDLE;
char l_cLine[g_dLength];
if (!FileExists(g_cPathsExtra))
{
delete l_hFile; delete l_hFile;
LogError("create a extrasettings.txt file!"); LogError("create a extrasettings.txt file!");
return; return;
} }
l_hFile = OpenFile(g_cPathsExtra, "r"); l_hFile = OpenFile(g_cPathsExtra, "r");
while (!IsEndOfFile(l_hFile) && ReadFileLine(l_hFile, l_cLine, sizeof(l_cLine))) while (!IsEndOfFile(l_hFile) && ReadFileLine(l_hFile, l_cLine, sizeof(l_cLine)))
{ {
if (StrContains(l_cLine, "Respawn Time") > -1) if (StrContains(l_cLine, "Respawn Time") > -1)
{ {
ReplaceStrings(l_cLine, "Respawn Time"); ReplaceStrings(l_cLine, "Respawn Time");
if (StringToFloat(l_cLine) > 0.0) if (StringToFloat(l_cLine) > 0.0)
g_fRespawnTimer = StringToFloat(l_cLine); g_fRespawnTimer = StringToFloat(l_cLine);
else else
g_fRespawnTimer = 5.0; g_fRespawnTimer = 5.0;
} }
if (StrContains(l_cLine, "Global command") > -1) if (StrContains(l_cLine, "Global command") > -1)
{ {
ReplaceStrings(l_cLine, "Global command"); ReplaceStrings(l_cLine, "Global command");
if (strlen(l_cLine) > 1) if (strlen(l_cLine) > 1)
ServerCommand(l_cLine); ServerCommand(l_cLine);
} }
if (StrContains(l_cLine, "round start zclass time") > -1) if (StrContains(l_cLine, "round start zclass time") > -1)
{ {
ReplaceStrings(l_cLine, "round start zclass time"); ReplaceStrings(l_cLine, "round start zclass time");
if (StringToFloat(l_cLine) > 0.0) if (StringToFloat(l_cLine) > 0.0)
g_fSwitchingTimer = StringToFloat(l_cLine); g_fSwitchingTimer = StringToFloat(l_cLine);
else else
g_fSwitchingTimer = 15.0; g_fSwitchingTimer = 15.0;
} }
if (StrContains(l_cLine, "zm spawn protection") > -1) if (StrContains(l_cLine, "zm spawn protection") > -1)
{ {
ReplaceStrings(l_cLine, "zm spawn protection"); ReplaceStrings(l_cLine, "zm spawn protection");
if (StringToFloat(l_cLine) > 0.0) if (StringToFloat(l_cLine) > 0.0)
g_fZMSpawnProtection = StringToFloat(l_cLine); g_fZMSpawnProtection = StringToFloat(l_cLine);
else else
g_fZMSpawnProtection = 1.0; g_fZMSpawnProtection = 1.0;
} }
if (StrContains(l_cLine, "human spawn protection") > -1) if (StrContains(l_cLine, "human spawn protection") > -1)
{ {
ReplaceStrings(l_cLine, "human spawn protection"); ReplaceStrings(l_cLine, "human spawn protection");
if (StringToFloat(l_cLine) > 0.0) if (StringToFloat(l_cLine) > 0.0)
g_fHumanSpawnProtection = StringToFloat(l_cLine); g_fHumanSpawnProtection = StringToFloat(l_cLine);
else else
g_fHumanSpawnProtection = 4.0; g_fHumanSpawnProtection = 4.0;
} }
if (StrContains(l_cLine, "zmsoundInterval") > -1) if (StrContains(l_cLine, "zmsoundInterval") > -1)
{ {
ReplaceStrings(l_cLine, "zmsoundInterval"); ReplaceStrings(l_cLine, "zmsoundInterval");
if (StringToFloat(l_cLine) > 0.0) if (StringToFloat(l_cLine) > 0.0)
g_fZMSounds = StringToFloat(l_cLine); g_fZMSounds = StringToFloat(l_cLine);
else else
g_fZMSounds = 15.0; g_fZMSounds = 15.0;
} }
if (StrContains(l_cLine, "botStuckCount") > -1) if (StrContains(l_cLine, "botStuckCount") > -1)
{ {
ReplaceStrings(l_cLine, "botStuckCount"); ReplaceStrings(l_cLine, "botStuckCount");
if (StringToInt(l_cLine) > 1) if (StringToInt(l_cLine) > 1)
g_iBotStuckCounts = StringToInt(l_cLine); g_iBotStuckCounts = StringToInt(l_cLine);
else else
g_iBotStuckCounts = 3; g_iBotStuckCounts = 3;
} }
if (StrContains(l_cLine, "botStuckPush") > -1) if (StrContains(l_cLine, "botStuckPush") > -1)
{ {
ReplaceStrings(l_cLine, "botStuckPush"); ReplaceStrings(l_cLine, "botStuckPush");
if (StringToInt(l_cLine) > 1) if (StringToInt(l_cLine) > 1)
g_fBotStuckPush = StringToFloat(l_cLine); g_fBotStuckPush = StringToFloat(l_cLine);
else else
g_fBotStuckPush = 250.0; g_fBotStuckPush = 250.0;
} }
if (StrContains(l_cLine, "zmsoundsFile") > -1) if (StrContains(l_cLine, "zmsoundsFile") > -1)
{ {
ReplaceStrings(l_cLine, "zmsoundsFile"); ReplaceStrings(l_cLine, "zmsoundsFile");
ReplaceString(l_cLine, sizeof(l_cLine), "sound/", "*/"); ReplaceString(l_cLine, sizeof(l_cLine), "sound/", "*/");
Format(g_cZMSounds[g_iSoundIndexes][g_iLength], sizeof(g_cZMSounds), l_cLine); Format(g_cZMSounds[g_iSoundIndexes][g_iLength], sizeof(g_cZMSounds), l_cLine);
FakePrecacheSound(g_cZMSounds[g_iSoundIndexes][g_iLength]); FakePrecacheSound(g_cZMSounds[g_iSoundIndexes][g_iLength]);
g_iSoundIndexes++; g_iSoundIndexes++;
} }
} }
delete l_hFile; delete l_hFile;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose: