Skip to content

Commit f0c3beb

Browse files
committed
Refactor map commands; reduce emptyClients array
Initialize emptyClients as a fixed 66-entry zeroed array (replacing the 102-loop) in multimode_endvote.sp to simplify and reduce memory. Refactor map command handling in multimode_mapcommands.sp: split ExecuteSubgroupCommandsAndConfig into ExecuteGroupCommands (executes group-level MAPCYCLE_KEY_COMMAND and MAPCYCLE_KEY_CONFIG entries and logs them) and ExecuteSubgroupCommands; run group commands before subgroup commands and adjust KeyValues traversal. Updated compiled plugin binaries (.smx) to match the script changes.
1 parent 5f80a2a commit f0c3beb

4 files changed

Lines changed: 54 additions & 6 deletions

File tree

-73 Bytes
Binary file not shown.
355 Bytes
Binary file not shown.

addons/sourcemod/scripting/multimode_endvote.sp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ void PerformEndVote()
360360
char mapcycle[256];
361361
strcopy(mapcycle, sizeof(mapcycle), "");
362362

363-
int emptyClients[102];
364-
for (int i = 0; i < 102; i++) emptyClients[i] = 0;
363+
int emptyClients[66] = {0};
365364

366365
char startSound[256] = "";
367366
char endSound[256] = "";
@@ -461,8 +460,7 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
461460
char mapcycle[256];
462461
strcopy(mapcycle, sizeof(mapcycle), "");
463462

464-
int emptyClients[102];
465-
for (int i = 0; i < 102; i++) emptyClients[i] = 0;
463+
int emptyClients[66] = {0};
466464

467465
char startSound[256] = "";
468466
char endSound[256] = "";

addons/sourcemod/scripting/multimode_mapcommands.sp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,55 @@ bool GetMapCycleKeyValue(KeyValues kv, const char[] gamemode, const char[] subgr
188188
return false;
189189
}
190190

191-
void ExecuteSubgroupCommandsAndConfig(const char[] gamemode, const char[] subgroup, const char[] map)
191+
void ExecuteGroupCommands(const char[] gamemode, const char[] map)
192+
{
193+
if (g_kvMapcycle == null)
194+
return;
195+
196+
g_kvMapcycle.Rewind();
197+
if (!g_kvMapcycle.JumpToKey(gamemode))
198+
{
199+
g_kvMapcycle.Rewind();
200+
return;
201+
}
202+
203+
char command[512];
204+
if (g_kvMapcycle.GotoFirstSubKey(false))
205+
{
206+
do
207+
{
208+
char keyName[64];
209+
g_kvMapcycle.GetSectionName(keyName, sizeof(keyName));
210+
if (StrEqual(keyName, MAPCYCLE_KEY_COMMAND))
211+
{
212+
g_kvMapcycle.GetString(NULL_STRING, command, sizeof(command), "");
213+
if (strlen(command) > 0)
214+
{
215+
ServerCommand("%s", command);
216+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed group command for map %s (group: %s): %s",
217+
map, gamemode, command);
218+
}
219+
}
220+
} while (g_kvMapcycle.GotoNextKey(false));
221+
g_kvMapcycle.GoBack();
222+
}
223+
224+
char config[PLATFORM_MAX_PATH];
225+
g_kvMapcycle.GetString(MAPCYCLE_KEY_CONFIG, config, sizeof(config), "");
226+
if (strlen(config) > 0)
227+
{
228+
char configPath[PLATFORM_MAX_PATH];
229+
Format(configPath, sizeof(configPath), "cfg/%s", config);
230+
ServerCommand("exec \"%s\"", configPath);
231+
MMC_WriteToLogFile(null, "[MultiMode MapCycle Commands] Executed group config for map %s (group: %s): %s",
232+
map, gamemode, config);
233+
}
234+
235+
g_kvMapcycle.GoBack();
236+
g_kvMapcycle.Rewind();
237+
}
238+
239+
void ExecuteSubgroupCommands(const char[] gamemode, const char[] subgroup, const char[] map)
192240
{
193241
g_kvMapcycle.Rewind();
194242
if (!g_kvMapcycle.JumpToKey(gamemode) || !g_kvMapcycle.JumpToKey("subgroup") || !g_kvMapcycle.JumpToKey(subgroup))
@@ -244,8 +292,10 @@ void ExecuteMapCommand(const char[] gamemode, const char[] subgroup, const char[
244292
return;
245293
}
246294

295+
ExecuteGroupCommands(gamemode, map);
296+
247297
if (strlen(subgroup) > 0)
248-
ExecuteSubgroupCommandsAndConfig(gamemode, subgroup, map);
298+
ExecuteSubgroupCommands(gamemode, subgroup, map);
249299

250300
KeyValues mapKv = null;
251301
if (strlen(subgroup) > 0)

0 commit comments

Comments
 (0)