Skip to content

Commit 46d9985

Browse files
committed
Other bug fixes.
1 parent dc8ccff commit 46d9985

4 files changed

Lines changed: 63 additions & 39 deletions

File tree

-16 Bytes
Binary file not shown.
220 Bytes
Binary file not shown.

addons/sourcemod/scripting/multimode_core.sp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void OnPluginStart()
176176

177177
AutoExecConfig(true, "multimode_core");
178178

179-
LoadGameModesConfig();
179+
LoadGameModesConfig(false);
180180
g_VoteManagersBackup = new StringMap();
181181

182182
ConVar nextmap = FindConVar("sm_nextmap");
@@ -294,12 +294,6 @@ public void OnConfigsExecuted()
294294
}
295295

296296
g_iLastMapCycleLoadTime = GetTime();
297-
298-
if (g_OnMapCycleReloadedForward != null)
299-
{
300-
Call_StartForward(g_OnMapCycleReloadedForward);
301-
Call_Finish();
302-
}
303297
}
304298

305299
public void OnMapStart()
@@ -319,7 +313,7 @@ public void OnMapStart()
319313
if (timeSinceLastLoad >= 2)
320314
{
321315
MMC_WriteToLogFile(g_Cvar_Logs, "[MultiMode Core] Workshop dynamic reload triggered after name sync.");
322-
LoadGameModesConfig();
316+
LoadGameModesConfig(false);
323317
}
324318
else
325319
{
@@ -496,7 +490,7 @@ public void OnClientDisconnect(int client)
496490
g_sClientPendingSubGroup[client][0] = '\0';
497491
}
498492

499-
public void LoadGameModesConfig()
493+
public void LoadGameModesConfig(bool notifyPlugins)
500494
{
501495
delete g_kvGameModes;
502496
g_kvGameModes = new KeyValues("Mapcycle");
@@ -750,7 +744,7 @@ public void LoadGameModesConfig()
750744

751745
g_iLastMapCycleLoadTime = GetTime();
752746

753-
if (g_OnMapCycleReloadedForward != null)
747+
if (notifyPlugins && g_OnMapCycleReloadedForward != null)
754748
{
755749
Call_StartForward(g_OnMapCycleReloadedForward);
756750
Call_Finish();
@@ -5545,7 +5539,7 @@ public void OnGamemodeConfigLoaded()
55455539

55465540
public Action Command_ReloadGamemodes(int client, int args)
55475541
{
5548-
LoadGameModesConfig();
5542+
LoadGameModesConfig(true);
55495543

55505544
CReplyToCommand(client, "%t", "Reload Gamemodes Successful");
55515545
return Plugin_Handled;

addons/sourcemod/scripting/multimode_mapcommands.sp

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -105,43 +105,36 @@ void LoadMapcycle()
105105
public void MultiMode_OnMapCycleReloaded()
106106
{
107107
LoadMapcycle();
108-
109-
CreateTimer(0.5, Timer_ReexecuteCommands, _, TIMER_FLAG_NO_MAPCHANGE);
110-
}
111108

112-
public Action Timer_ReexecuteCommands(Handle timer)
113-
{
114109
char currentMap[PLATFORM_MAX_PATH];
115110
GetCurrentMap(currentMap, sizeof(currentMap));
116-
111+
117112
char currentGroup[64];
118113
char currentSubGroup[64];
119114
MultiMode_GetCurrentGameMode(currentGroup, sizeof(currentGroup), currentSubGroup, sizeof(currentSubGroup));
120-
115+
121116
strcopy(g_sCurrentMap, sizeof(g_sCurrentMap), currentMap);
122117
strcopy(g_sCurrentGroup, sizeof(g_sCurrentGroup), currentGroup);
123118
strcopy(g_sCurrentSubGroup, sizeof(g_sCurrentSubGroup), currentSubGroup);
124-
119+
125120
if (strlen(currentMap) > 0)
126121
{
127122
if (!g_bMapCommandsExecutedThisMap)
128123
{
129-
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Mapcycle reloaded, executing commands for current map \"%s\" (group: %s, subgroup: %s)",
124+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Mapcycle reloaded, executing commands for current map \"%s\" (group: %s, subgroup: %s)",
130125
currentMap, strlen(currentGroup) > 0 ? currentGroup : "none", strlen(currentSubGroup) > 0 ? currentSubGroup : "none");
131-
126+
132127
ExecuteMapCommand(g_sCurrentGroup, g_sCurrentSubGroup, g_sCurrentMap);
133128
g_bMapCommandsExecutedThisMap = true;
134129
}
135-
else if (StrEqual(currentMap, g_sCurrentMap))
130+
else
136131
{
137-
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Mapcycle reloaded after modification, re-executing commands for current map \"%s\" (group: %s, subgroup: %s)",
132+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Mapcycle reloaded, re-executing commands for current map \"%s\" (group: %s, subgroup: %s)",
138133
currentMap, strlen(currentGroup) > 0 ? currentGroup : "none", strlen(currentSubGroup) > 0 ? currentSubGroup : "none");
139-
134+
140135
ExecuteMapCommand(g_sCurrentGroup, g_sCurrentSubGroup, g_sCurrentMap);
141136
}
142137
}
143-
144-
return Plugin_Stop;
145138
}
146139

147140
KeyValues GetMapcycle()
@@ -204,23 +197,60 @@ void ExecuteMapCommand(const char[] gamemode, const char[] subgroup, const char[
204197
return;
205198
}
206199

207-
char command[512];
208-
char config[PLATFORM_MAX_PATH];
200+
KeyValues mapKv = null;
201+
if (strlen(subgroup) > 0)
202+
mapKv = MMC_GetSubGroupMapKv(g_kvMapcycle, gamemode, subgroup, map);
203+
else
204+
mapKv = MMC_GetMapKv(g_kvMapcycle, gamemode, map);
209205

210-
if (GetMapCycleKeyValue(g_kvMapcycle, gamemode, subgroup, map, MAPCYCLE_KEY_COMMAND, command, sizeof(command)))
206+
if (mapKv != null)
211207
{
212-
ServerCommand("%s", command);
213-
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed command for map %s (group: %s, subgroup: %s): %s",
214-
map, gamemode, strlen(subgroup) > 0 ? subgroup : "none", command);
215-
}
208+
char command[512];
209+
if (mapKv.GotoFirstSubKey(false))
210+
{
211+
do
212+
{
213+
char keyName[64];
214+
mapKv.GetSectionName(keyName, sizeof(keyName));
215+
if (StrEqual(keyName, MAPCYCLE_KEY_COMMAND))
216+
{
217+
mapKv.GetString(NULL_STRING, command, sizeof(command), "");
218+
if (strlen(command) > 0)
219+
{
220+
ServerCommand("%s", command);
221+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed command for map %s (group: %s, subgroup: %s): %s",
222+
map, gamemode, strlen(subgroup) > 0 ? subgroup : "none", command);
223+
}
224+
}
225+
} while (mapKv.GotoNextKey(false));
226+
mapKv.GoBack();
227+
}
228+
mapKv.Rewind();
216229

217-
if (GetMapCycleKeyValue(g_kvMapcycle, gamemode, subgroup, map, MAPCYCLE_KEY_CONFIG, config, sizeof(config)))
230+
char config[PLATFORM_MAX_PATH];
231+
mapKv.GetString(MAPCYCLE_KEY_CONFIG, config, sizeof(config), "");
232+
delete mapKv;
233+
234+
if (strlen(config) > 0)
235+
{
236+
char configPath[PLATFORM_MAX_PATH];
237+
Format(configPath, sizeof(configPath), "cfg/%s", config);
238+
ServerCommand("exec \"%s\"", configPath);
239+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed config for map %s (group: %s, subgroup: %s): %s",
240+
map, gamemode, strlen(subgroup) > 0 ? subgroup : "none", config);
241+
}
242+
}
243+
else
218244
{
219-
char configPath[PLATFORM_MAX_PATH];
220-
Format(configPath, sizeof(configPath), "cfg/%s", config);
221-
ServerCommand("exec \"%s\"", configPath);
222-
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed config for map %s (group: %s, subgroup: %s): %s",
223-
map, gamemode, strlen(subgroup) > 0 ? subgroup : "none", config);
245+
char config[PLATFORM_MAX_PATH];
246+
if (GetMapCycleKeyValue(g_kvMapcycle, gamemode, subgroup, map, MAPCYCLE_KEY_CONFIG, config, sizeof(config)))
247+
{
248+
char configPath[PLATFORM_MAX_PATH];
249+
Format(configPath, sizeof(configPath), "cfg/%s", config);
250+
ServerCommand("exec \"%s\"", configPath);
251+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed config for map %s (group: %s, subgroup: %s): %s",
252+
map, gamemode, strlen(subgroup) > 0 ? subgroup : "none", config);
253+
}
224254
}
225255
}
226256

0 commit comments

Comments
 (0)