Skip to content

Commit 46298aa

Browse files
committed
Use TIMING_* enums for next-map timing
Switch timing handling to use the TIMING_* enum (0=NextMap, 1=NextRound, 2=Instant). Updated API docs, command validation/error text, native input bounds checks, and callsites to stop using 1..3 and iTiming-1 adjustments. Affected files: include/multimode.inc (doc comment), multimode_adminmenu.sp (menu mapping), multimode_core.sp (native validation and ExecuteModeChange call), and multimode_randomcycle.sp (use TIMING_NEXTMAP constant). This unifies timing semantics and avoids off-by-one conversions.
1 parent a71e15c commit 46298aa

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

addons/sourcemod/scripting/include/multimode.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ native bool MultiMode_GetCurrentVoteId(char[] buffer, int maxlen);
156156
* Sets the next map (equivalent to multimode_setnextmap command).
157157
*
158158
* @param map Map name to set as next map.
159-
* @param timing Timing mode: 1 = Next Map, 2 = Next Round, 3 = Instant.
159+
* @param timing Timing mode: 0 = Next Map, 1 = Next Round, 2 = Instant (see TimingMode enum).
160160
* @param gamemode Gamemode name (optional, empty string to auto-detect).
161161
* @param subgroup Subgroup name (optional, empty string if not specified).
162162
* @return True on success, false on failure.

addons/sourcemod/scripting/multimode_adminmenu.sp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,11 +1030,11 @@ public int ForceTimingMenuHandler(Menu menu, MenuAction action, int client, int
10301030
char timingStr[16];
10311031
menu.GetItem(param2, timingStr, sizeof(timingStr));
10321032

1033-
int timing = 1;
1033+
int timing = TIMING_NEXTMAP;
10341034
if (StrEqual(timingStr, "nextround"))
1035-
timing = 2;
1035+
timing = TIMING_NEXTROUND;
10361036
else if (StrEqual(timingStr, "instant"))
1037-
timing = 3;
1037+
timing = TIMING_INSTANT;
10381038

10391039
ExecuteModeChange(
10401040
g_sClientPendingGameMode[client],

addons/sourcemod/scripting/multimode_core.sp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,11 +2693,11 @@ public int NativeMMC_SetNextMap(Handle plugin, int numParams)
26932693
}
26942694

26952695
int iTiming = GetNativeCell(2);
2696-
if (iTiming < 1 || iTiming > 3)
2696+
if (iTiming < view_as<int>(TIMING_NEXTMAP) || iTiming > view_as<int>(TIMING_INSTANT))
26972697
{
26982698
return false;
26992699
}
2700-
2700+
27012701
char sGroup[64];
27022702
char sSubGroup[64];
27032703
GetNativeString(3, sGroup, sizeof(sGroup));
@@ -2773,7 +2773,7 @@ public int NativeMMC_SetNextMap(Handle plugin, int numParams)
27732773
}
27742774
}
27752775

2776-
ExecuteModeChange(sGroup, sMap, iTiming - 1, sSubGroup);
2776+
ExecuteModeChange(sGroup, sMap, iTiming, sSubGroup);
27772777
return true;
27782778
}
27792779

@@ -3419,9 +3419,9 @@ public Action Command_SetNextMap(int client, int args)
34193419
GetCmdArg(2, sTiming, sizeof(sTiming));
34203420
int iTiming = StringToInt(sTiming);
34213421

3422-
if (iTiming < 1 || iTiming > 3)
3422+
if (iTiming < view_as<int>(TIMING_NEXTMAP) || iTiming > view_as<int>(TIMING_INSTANT))
34233423
{
3424-
ReplyToCommand(client, "[MultiMode] Error: Invalid timing. Use 1, 2 ou 3.");
3424+
ReplyToCommand(client, "[MultiMode] Error: Invalid timing. Use 0 (NextMap), 1 (NextRound) or 2 (Instant).");
34253425
return Plugin_Handled;
34263426
}
34273427

@@ -3514,7 +3514,7 @@ public Action Command_SetNextMap(int client, int args)
35143514
}
35153515

35163516
ReplyToCommand(client, "[MultiMode] Setting next map to '%s' (Group: %s, Subgroup: %s).", sMap, sGroup, strlen(sSubGroup) > 0 ? sSubGroup : "NoN");
3517-
ExecuteModeChange(sGroup, sMap, iTiming - 1, sSubGroup);
3517+
ExecuteModeChange(sGroup, sMap, iTiming, sSubGroup);
35183518

35193519
return Plugin_Handled;
35203520
}

addons/sourcemod/scripting/multimode_randomcycle.sp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ void SelectRandomNextMap(bool bSetNextMap = false)
191191
{
192192
if (strlen(selectedSubgroup) > 0 && strlen(selectedGroup) > 0)
193193
{
194-
MultiMode_SetNextMap(selectedMap, 1, selectedGroup, selectedSubgroup);
194+
MultiMode_SetNextMap(selectedMap, TIMING_NEXTMAP, selectedGroup, selectedSubgroup);
195195
}
196196
else if (strlen(selectedGroup) > 0)
197197
{
198-
MultiMode_SetNextMap(selectedMap, 1, selectedGroup);
198+
MultiMode_SetNextMap(selectedMap, TIMING_NEXTMAP, selectedGroup);
199199
}
200200
else
201201
{
202-
MultiMode_SetNextMap(selectedMap, 1);
202+
MultiMode_SetNextMap(selectedMap, TIMING_NEXTMAP);
203203
}
204204

205205
DataPack pack = new DataPack();

0 commit comments

Comments
 (0)