Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(MCE): Format, Verify cached values, Loop improvements #27

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/mapchooser_extended.sp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#tryinclude <zleader>
#define REQUIRE_PLUGIN

#define MCE_VERSION "1.12.5"
#define MCE_VERSION "1.12.6"

#define ZLEADER "zleader"
#define DYNCHANNELS "DynamicChannels"
Expand Down Expand Up @@ -102,7 +102,7 @@ public void OnPluginStart()

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
if(LibraryExists("mapchooser"))
if (LibraryExists("mapchooser"))
{
strcopy(error, err_max, "MapChooser already loaded, aborting.");
return APLRes_Failure;
Expand Down Expand Up @@ -174,6 +174,6 @@ public void OnClientDisconnect(int client)

public void OnMapTimeLeftChanged()
{
if(GetArraySize(g_MapList))
if (GetArraySize(g_MapList))
SetupTimeleftTimer();
}
10 changes: 5 additions & 5 deletions addons/sourcemod/scripting/mce/commands.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Action Command_Version(int client, int args)

public Action Command_SetNextmap(int client, int args)
{
if(args < 1)
if (args < 1)
{
CReplyToCommand(client, "{green}[MCE]{default} Usage: {lightgreen}sm_setnextmap <map>");
return Plugin_Handled;
Expand All @@ -44,7 +44,7 @@ public Action Command_SetNextmap(int client, int args)
static char map[PLATFORM_MAX_PATH];
GetCmdArg(1, map, PLATFORM_MAX_PATH);

if(!IsMapValid(map))
if (!IsMapValid(map))
{
CReplyToCommand(client, "{green}[MCE]{default} %t", "Map was not found", map);
return Plugin_Handled;
Expand All @@ -70,12 +70,12 @@ public Action Command_ShowConfig(int client, int args)
{
char map[PLATFORM_MAX_PATH];

if(args == 0)
if (args == 0)
GetCurrentMap(map, sizeof(map));
else
{
GetCmdArg(1, map, sizeof(map));
if(FindStringInArray(g_MapList, map) == -1)
if (FindStringInArray(g_MapList, map) == -1)
{
CReplyToCommand(client, "{green}[MCE]{default} %t", "Map was not found", map);
return Plugin_Handled;
Expand All @@ -97,7 +97,7 @@ public Action Command_ShowConfig(int client, int args)
// char desc[MAX_DESCRIPTION_LENGTH];
// bool descr = InternalGetMapDescription(map, desc, sizeof(desc));

if(GetCmdReplySource() == SM_REPLY_TO_CHAT)
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
{
CPrintToChat(client, "{green}[MCE]{default} %t", "See console for output");
}
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/mce/cvars.inc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ float g_fTimerUnlockNoms;

stock void CvarsEngineInit(EngineVersion version)
{
switch(version)
switch (version)
{
case Engine_TF2:
{
Expand Down Expand Up @@ -381,4 +381,4 @@ public void OnConVarChanged(ConVar convar, char[] oldValue, char[] newValue)
g_bShowNominator = GetConVarBool(g_Cvar_ShowNominator);
else if (convar == g_Cvar_SharedCDMode)
g_iSharedCDMode = GetConVarInt(g_Cvar_SharedCDMode);
}
}
52 changes: 26 additions & 26 deletions addons/sourcemod/scripting/mce/events.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

stock void EventsInit(EngineVersion version)
{
if(g_Cvar_Winlimit != INVALID_HANDLE || g_Cvar_Maxrounds != INVALID_HANDLE)
if (g_Cvar_Winlimit != INVALID_HANDLE || g_Cvar_Maxrounds != INVALID_HANDLE)
{
switch(version)
switch (version)
{
case Engine_TF2:
{
Expand Down Expand Up @@ -50,7 +50,7 @@ stock void EventsInit(EngineVersion version)
}
}

if(g_Cvar_Fraglimit != INVALID_HANDLE)
if (g_Cvar_Fraglimit != INVALID_HANDLE)
HookEvent("player_death", Event_PlayerDeath);
}

Expand All @@ -62,7 +62,7 @@ public void Event_TFRestartRound(Handle event, const char[] name, bool dontBroad

public void Event_TeamPlayWinPanel(Handle event, const char[] name, bool dontBroadcast)
{
if(g_ChangeMapAtRoundEnd)
if (g_ChangeMapAtRoundEnd)
{
g_ChangeMapAtRoundEnd = false;
CreateTimer(2.0, Timer_ChangeMap, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
Expand All @@ -72,16 +72,16 @@ public void Event_TeamPlayWinPanel(Handle event, const char[] name, bool dontBro
int bluescore = GetEventInt(event, "blue_score");
int redscore = GetEventInt(event, "red_score");

if(GetEventInt(event, "round_complete") == 1 || strcmp(name, "arena_win_panel") == 0)
if (GetEventInt(event, "round_complete") == 1 || strcmp(name, "arena_win_panel") == 0)
{
g_TotalRounds++;

if(!GetArraySize(g_MapList) || g_HasVoteStarted || g_MapVoteCompleted || !g_bEndOfMapVote)
if (!GetArraySize(g_MapList) || g_HasVoteStarted || g_MapVoteCompleted || !g_bEndOfMapVote)
return;

CheckMaxRounds(g_TotalRounds);

switch(GetEventInt(event, "winning_team"))
switch (GetEventInt(event, "winning_team"))
{
case 3:
{
Expand All @@ -102,10 +102,10 @@ public void Event_TeamPlayWinPanel(Handle event, const char[] name, bool dontBro

public void Event_MvMWinPanel(Handle event, const char[] name, bool dontBroadcast)
{
if(GetEventInt(event, "winning_team") == 2)
if (GetEventInt(event, "winning_team") == 2)
{
int objectiveEnt = EntRefToEntIndex(g_ObjectiveEnt);
if(objectiveEnt != INVALID_ENT_REFERENCE)
if (objectiveEnt != INVALID_ENT_REFERENCE)
{
g_TotalRounds = GetEntProp(g_ObjectiveEnt, Prop_Send, "m_nMannVsMachineWaveCount");
CheckMaxRounds(g_TotalRounds);
Expand All @@ -121,7 +121,7 @@ public void Event_Intermission(Handle event, const char[] name, bool dontBroadca
public void Event_PhaseEnd(Handle event, const char[] name, bool dontBroadcast)
{
/* announce_phase_end fires for both half time and the end of the map, but intermission fires first for end of the map. */
if(g_HasIntermissionStarted)
if (g_HasIntermissionStarted)
return;

/* No intermission yet, so this must be half time. Swap the score counters. */
Expand All @@ -133,7 +133,7 @@ public void Event_PhaseEnd(Handle event, const char[] name, bool dontBroadcast)
public void Event_WeaponRank(Handle event, const char[] name, bool dontBroadcast)
{
int rank = GetEventInt(event, "weaponrank");
if(rank > g_TotalRounds)
if (rank > g_TotalRounds)
{
g_TotalRounds = rank;
CheckMaxRounds(g_TotalRounds);
Expand All @@ -146,7 +146,7 @@ public void Event_WinPanel(Handle event, const char[] name, bool dontBroadcast)
return;

char nextMap[64];
if(!GetNextMap(nextMap, sizeof(nextMap)))
if (!GetNextMap(nextMap, sizeof(nextMap)))
return;

bool bDynamicAvailable = false;
Expand All @@ -169,9 +169,9 @@ public void Event_WinPanel(Handle event, const char[] name, bool dontBroadcast)

if (!bDynamicAvailable && g_hHud != INVALID_HANDLE || bDynamicAvailable)
{
for(int i = 1; i <= MaxClients; i++)
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i) || IsFakeClient(i))
if (!IsClientInGame(i) || IsFakeClient(i))
continue;

if (bDynamicAvailable)
Expand All @@ -194,33 +194,33 @@ public void Event_WinPanel(Handle event, const char[] name, bool dontBroadcast)
/* You ask, why don't you just use team_score event? And I answer... Because CSS doesn't. */
public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
if(g_RoundCounting == RoundCounting_ArmsRace)
if (g_RoundCounting == RoundCounting_ArmsRace)
return;

if(g_ChangeMapAtRoundEnd)
if (g_ChangeMapAtRoundEnd)
{
g_ChangeMapAtRoundEnd = false;
CreateTimer(2.0, Timer_ChangeMap, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
g_ChangeMapInProgress = true;
}

int winner;
if(strcmp(name, "round_win") == 0 || strcmp(name, "dod_round_win") == 0)
if (strcmp(name, "round_win") == 0 || strcmp(name, "dod_round_win") == 0)
winner = GetEventInt(event, "team"); // Nuclear Dawn & DoD:S
else
winner = GetEventInt(event, "winner");

if(winner == 0 || winner == 1 || !g_bEndOfMapVote)
if (winner == 0 || winner == 1 || !g_bEndOfMapVote)
return;

if(winner >= MAXTEAMS)
if (winner >= MAXTEAMS)
SetFailState("Mod exceed maximum team count - Please file a bug report.");

g_TotalRounds++;

g_winCount[winner]++;

if(!GetArraySize(g_MapList) || g_HasVoteStarted || g_MapVoteCompleted)
if (!GetArraySize(g_MapList) || g_HasVoteStarted || g_MapVoteCompleted)
{
return;
}
Expand All @@ -231,23 +231,23 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)

public void Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
if(!GetArraySize(g_MapList) || g_Cvar_Fraglimit == INVALID_HANDLE || g_HasVoteStarted)
if (!GetArraySize(g_MapList) || g_Cvar_Fraglimit == INVALID_HANDLE || g_HasVoteStarted)
return;

if(!GetConVarInt(g_Cvar_Fraglimit) || !g_bEndOfMapVote)
if (!GetConVarInt(g_Cvar_Fraglimit) || !g_bEndOfMapVote)
return;

if(g_MapVoteCompleted)
if (g_MapVoteCompleted)
return;

int fragger = GetClientOfUserId(GetEventInt(event, "attacker"));

if(!fragger)
if (!fragger)
return;

if(GetClientFrags(fragger) >= (GetConVarInt(g_Cvar_Fraglimit) - g_iStartFrags))
if (GetClientFrags(fragger) >= (GetConVarInt(g_Cvar_Fraglimit) - g_iStartFrags))
{
if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
if (!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
{
SetupWarningTimer(WarningType_Vote, MapChange_MapEnd);
//InitiateVote(MapChange_MapEnd, INVALID_HANDLE);
Expand Down
Loading