Skip to content

Commit a71e15c

Browse files
committed
Separate end-vote timing into new ConVar
Introduce a new ConVar multimode_endvote_type (g_Cvar_EndVoteType) to control end-vote timing (Next Map / Next Round / Instant). Refactor PerformEndVote and Event_RoundEnd to keep vote method selection using multimode_endvote_method while using the new multimode_endvote_type for TimingMode calculation and clamping. Update logging and local variable names accordingly.
1 parent 539f217 commit a71e15c

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

addons/sourcemod/scripting/multimode_endvote.sp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ConVar g_Cvar_EndVoteRounds;
2929
ConVar g_Cvar_EndVoteFrags;
3030
ConVar g_Cvar_EndVoteOnRoundEnd;
3131
ConVar g_Cvar_EndVoteMethod;
32+
ConVar g_Cvar_EndVoteType;
3233
ConVar g_hCvarTimeLimit;
3334

3435
// Vote Configuration ConVars
@@ -73,6 +74,7 @@ public void OnPluginStart()
7374
g_Cvar_EndVoteFrags = CreateConVar("multimode_endvote_frags", "10", "Frags remaining before map ends to trigger vote (0 = disabled)", _, true, 0.0);
7475
g_Cvar_EndVoteOnRoundEnd = CreateConVar("multimode_endvote_onroundend", "0", "Wait for round end before starting vote", _, true, 0.0, true, 1.0);
7576
g_Cvar_EndVoteMethod = CreateConVar("multimode_endvote_method", "1", "Vote method for end vote: 1 = Groups then Maps, 2 = Groups only (random map), 3 = Maps only", _, true, 1.0, true, 3.0);
77+
g_Cvar_EndVoteType = CreateConVar("multimode_endvote_type", "1", "Voting Type for End Vote: 1 = Next Map, 2 = Next Round, 3 = Instant", _, true, 1.0, true, 3.0);
7678
g_hCvarTimeLimit = FindConVar("mp_timelimit");
7779

7880
g_Cvar_VoteTime = CreateConVar("multimode_endvote_vote_time", "20", "Vote duration in seconds");
@@ -333,29 +335,29 @@ void PerformEndVote()
333335
return;
334336
}
335337

336-
int endType = g_Cvar_EndVoteMethod.IntValue;
337-
if (endType < 1) endType = 1;
338-
else if (endType > 3) endType = 3;
339-
340-
TimingMode timing = view_as<TimingMode>(endType - 1);
338+
int voteTypeInt = g_Cvar_EndVoteMethod.IntValue;
341339
MultimodeMethodType voteType;
342-
343-
int method = g_Cvar_EndVoteMethod.IntValue;
344-
if (method == 3)
340+
if (voteTypeInt == 3)
345341
{
346342
voteType = VOTE_TYPE_MAPS_ONLY;
347343
}
348-
else if (method == 2)
344+
else if (voteTypeInt == 2)
349345
{
350346
voteType = VOTE_TYPE_GROUPS_ONLY;
351347
}
352348
else
353349
{
354350
voteType = VOTE_TYPE_GROUPS_THEN_MAPS;
355351
}
352+
353+
int endType = g_Cvar_EndVoteType.IntValue;
354+
if (endType < 1) endType = 1;
355+
else if (endType > 3) endType = 3;
356+
357+
TimingMode timing = view_as<TimingMode>(endType - 1);
356358

357359
if (g_Cvar_EndVoteDebug.BoolValue)
358-
MMC_WriteToLogFile(g_Cvar_EndVoteLogs, "[MultiMode End Vote] Vote type selected: %d (Timing: %d)", endType, timing);
360+
MMC_WriteToLogFile(g_Cvar_EndVoteLogs, "[MultiMode End Vote] Vote type selected: %d (Timing: %d)", voteTypeInt, timing);
359361

360362
char mapcycle[256];
361363
strcopy(mapcycle, sizeof(mapcycle), "");
@@ -436,19 +438,13 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
436438
{
437439
g_bEndVotePending = false;
438440

439-
int endType = g_Cvar_EndVoteMethod.IntValue;
440-
if (endType < 1) endType = 1;
441-
else if (endType > 3) endType = 3;
442-
443-
TimingMode timing = view_as<TimingMode>(endType - 1);
441+
int voteTypeInt = g_Cvar_EndVoteMethod.IntValue;
444442
MultimodeMethodType voteType;
445-
446-
int method = g_Cvar_EndVoteMethod.IntValue;
447-
if (method == 3)
443+
if (voteTypeInt == 3)
448444
{
449445
voteType = VOTE_TYPE_MAPS_ONLY;
450446
}
451-
else if (method == 2)
447+
else if (voteTypeInt == 2)
452448
{
453449
voteType = VOTE_TYPE_GROUPS_ONLY;
454450
}
@@ -457,6 +453,12 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
457453
voteType = VOTE_TYPE_GROUPS_THEN_MAPS;
458454
}
459455

456+
int endType = g_Cvar_EndVoteType.IntValue;
457+
if (endType < 1) endType = 1;
458+
else if (endType > 3) endType = 3;
459+
460+
TimingMode timing = view_as<TimingMode>(endType - 1);
461+
460462
char mapcycle[256];
461463
strcopy(mapcycle, sizeof(mapcycle), "");
462464

0 commit comments

Comments
 (0)