Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdnk committed Dec 23, 2022
1 parent dba1db5 commit c54cd78
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 85 deletions.
6 changes: 4 additions & 2 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,10 @@ public void OnPluginStart() {
RegAdminCmd("get5_dumpstats", Command_DumpStats, ADMFLAG_CHANGEMAP, "Dumps match stats to a file");
RegAdminCmd("get5_listbackups", Command_ListBackups, ADMFLAG_CHANGEMAP,
"Lists get5 match backups for the current matchid or a given one");
RegAdminCmd("get5_loadbackup", Command_LoadBackup, ADMFLAG_CHANGEMAP, "Loads a Get5 match backup from a file relative to the csgo directory.");
RegAdminCmd("get5_loadbackup_url", Command_LoadBackupUrl, ADMFLAG_CHANGEMAP, "Downloads and loads a Get5 match backup from a URL.");
RegAdminCmd("get5_loadbackup", Command_LoadBackup, ADMFLAG_CHANGEMAP,
"Loads a Get5 match backup from a file relative to the csgo directory.");
RegAdminCmd("get5_loadbackup_url", Command_LoadBackupUrl, ADMFLAG_CHANGEMAP,
"Downloads and loads a Get5 match backup from a URL.");
RegAdminCmd("get5_debuginfo", Command_DebugInfo, ADMFLAG_CHANGEMAP,
"Dumps debug info to a file (addons/sourcemod/logs/get5_debuginfo.txt by default)");

Expand Down
2 changes: 1 addition & 1 deletion scripting/get5/backups.sp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ bool RestoreFromBackup(const char[] path, char[] error) {

bool backupIsForDifferentMap = !StrEqual(currentMap, loadedMapName, false);
bool backupIsForDifferentMatch = g_GameState != Get5State_Live || g_MapNumber != loadedMapNumber ||
backupIsForDifferentMap || !StrEqual(loadedMatchId, g_MatchID);
backupIsForDifferentMap || !StrEqual(loadedMatchId, g_MatchID);

if (backupIsForDifferentMatch) {
// We must stop recording to fire the Get5_OnDemoFinished event when loading a backup to another match or map, and
Expand Down
69 changes: 25 additions & 44 deletions scripting/get5/chatcommands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -17,80 +17,63 @@ static void AddChatAlias(const char[] alias, const char[] command) {
}

void MapChatCommand(const Get5ChatCommand command, const char[] alias) {
switch (command)
{
case Get5ChatCommand_Ready:
{
switch (command) {
case Get5ChatCommand_Ready: {
AddAliasedCommand(alias, Command_Ready, "Marks the client as ready.");
}
case Get5ChatCommand_Unready:
{
case Get5ChatCommand_Unready: {
AddAliasedCommand(alias, Command_NotReady, "Marks the client as not ready.");
}
case Get5ChatCommand_ForceReady:
{
case Get5ChatCommand_ForceReady: {
AddAliasedCommand(alias, Command_ForceReadyClient, "Marks the client's entire team as ready.");
}
case Get5ChatCommand_Tech:
{
case Get5ChatCommand_Tech: {
AddAliasedCommand(alias, Command_TechPause, "Calls for a technical pause.");
}
case Get5ChatCommand_Pause:
{
case Get5ChatCommand_Pause: {
AddAliasedCommand(alias, Command_Pause, "Calls for a tactical pause.");
}
case Get5ChatCommand_Unpause:
{
case Get5ChatCommand_Unpause: {
AddAliasedCommand(alias, Command_Unpause, "Unpauses the game.");
}
case Get5ChatCommand_Coach:
{
case Get5ChatCommand_Coach: {
AddAliasedCommand(alias, Command_SmCoach, "Requests to become a coach.");
}
case Get5ChatCommand_Stay:
{
case Get5ChatCommand_Stay: {
AddAliasedCommand(alias, Command_Stay, "Elects to stay on the current side after winning a knife round.");
}
case Get5ChatCommand_Swap:
{
case Get5ChatCommand_Swap: {
AddAliasedCommand(alias, Command_Swap, "Elects to swap to the other side after winning a knife round.");
}
case Get5ChatCommand_T:
{
case Get5ChatCommand_T: {
AddAliasedCommand(alias, Command_T, "Elects to start on T side after winning a knife round.");
}
case Get5ChatCommand_CT:
{
case Get5ChatCommand_CT: {
AddAliasedCommand(alias, Command_Ct, "Elects to start on CT side after winning a knife round.");
}
case Get5ChatCommand_Stop:
{
case Get5ChatCommand_Stop: {
AddAliasedCommand(alias, Command_Stop, "Elects to stop the game to reload a backup file for the current round.");
}
case Get5ChatCommand_Surrender:
{
case Get5ChatCommand_Surrender: {
AddAliasedCommand(alias, Command_Surrender, "Starts a vote for surrendering for your team.");
}
case Get5ChatCommand_FFW:
{
case Get5ChatCommand_FFW: {
AddAliasedCommand(alias, Command_FFW, "Starts a countdown to win if a full team disconnects from the server.");
}
case Get5ChatCommand_CancelFFW:
{
case Get5ChatCommand_CancelFFW: {
AddAliasedCommand(alias, Command_CancelFFW, "Cancels a pending request to win by forfeit.");
}
default:
{
default: {
LogError("Failed to map Get5ChatCommand with value %d to a command. It is missing from MapChatCommand.", command);
return;
}
}

char commandAsString[64]; // "ready"; base command
char commandAliasFormatted[64]; // "!readyalias"; the alias to use, with ! in front
char commandAsString[64]; // "ready"; base command
char commandAliasFormatted[64]; // "!readyalias"; the alias to use, with ! in front
ChatCommandToString(command, commandAsString, sizeof(commandAsString));
FormatEx(commandAliasFormatted, sizeof(commandAliasFormatted), "!%s", alias);
g_ChatCommands.SetString(commandAsString, commandAliasFormatted); // maps ready -> !readyalias
g_ChatCommands.SetString(commandAsString, commandAliasFormatted); // maps ready -> !readyalias
}

void GetChatAliasForCommand(const Get5ChatCommand command, char[] buffer, int bufferSize, bool format) {
Expand All @@ -116,17 +99,15 @@ int LoadCustomChatAliases(const char[] file) {

KeyValues chatAliases = new KeyValues("Commands");
if (!chatAliases.ImportFromFile(file)) {
LogError("Failed to read chat command aliases file at '%s'.", file);
delete chatAliases;
return loadedAliases;
LogError("Failed to read chat command aliases file at '%s'.", file);
delete chatAliases;
return loadedAliases;
}

if (chatAliases.GotoFirstSubKey(false))
{
if (chatAliases.GotoFirstSubKey(false)) {
char alias[255];
char command[255];
do
{
do {
chatAliases.GetSectionName(alias, sizeof(alias));
chatAliases.GetString(NULL_STRING, command, sizeof(command));

Expand Down
3 changes: 2 additions & 1 deletion scripting/get5/pausing.sp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ static Action Timer_PauseTimeCheck(Handle timer) {
// unpause on their own. The PrintHintText below will inform users that they can now
// unpause.
char formattedUnpauseCommand[64];
GetChatAliasForCommand(Get5ChatCommand_Unpause, formattedUnpauseCommand, sizeof(formattedUnpauseCommand), true);
GetChatAliasForCommand(Get5ChatCommand_Unpause, formattedUnpauseCommand, sizeof(formattedUnpauseCommand),
true);
Get5_MessageToAll("%t", "TechPauseRunoutInfoMessage", formattedUnpauseCommand);
}
}
Expand Down
3 changes: 2 additions & 1 deletion scripting/get5/surrender.sp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ static void AnnounceRemainingForfeitTime(const int remainingSeconds, const Get5T

if (forfeitingTeam != Get5Team_None) {
char formattedCancelFFWCommand[64];
GetChatAliasForCommand(Get5ChatCommand_CancelFFW, formattedCancelFFWCommand, sizeof(formattedCancelFFWCommand), true);
GetChatAliasForCommand(Get5ChatCommand_CancelFFW, formattedCancelFFWCommand, sizeof(formattedCancelFFWCommand),
true);
Get5_MessageToAll("%t", "WinByForfeitCountdownStarted", g_FormattedTeamNames[OtherMatchTeam(forfeitingTeam)],
formattedTimeRemaining, g_FormattedTeamNames[forfeitingTeam], formattedCancelFFWCommand);
} else {
Expand Down
55 changes: 19 additions & 36 deletions scripting/get5/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -777,71 +777,55 @@ stock bool IsDoingRestoreOrMapChange() {
}

stock void ChatCommandToString(const Get5ChatCommand command, char[] buffer, const int bufferSize) {
switch (command)
{
case Get5ChatCommand_Ready:
{
switch (command) {
case Get5ChatCommand_Ready: {
FormatEx(buffer, bufferSize, "ready");
}
case Get5ChatCommand_Unready:
{
case Get5ChatCommand_Unready: {
FormatEx(buffer, bufferSize, "unready");
}
case Get5ChatCommand_ForceReady:
{
case Get5ChatCommand_ForceReady: {
FormatEx(buffer, bufferSize, "forceready");
}
case Get5ChatCommand_Tech:
{
case Get5ChatCommand_Tech: {
FormatEx(buffer, bufferSize, "tech");
}
case Get5ChatCommand_Pause:
{
case Get5ChatCommand_Pause: {
FormatEx(buffer, bufferSize, "pause");
}
case Get5ChatCommand_Unpause:
{
case Get5ChatCommand_Unpause: {
FormatEx(buffer, bufferSize, "unpause");
}
case Get5ChatCommand_Coach:
{
case Get5ChatCommand_Coach: {
FormatEx(buffer, bufferSize, "coach");
}
case Get5ChatCommand_Stay:
{
case Get5ChatCommand_Stay: {
FormatEx(buffer, bufferSize, "stay");
}
case Get5ChatCommand_Swap:
{
case Get5ChatCommand_Swap: {
FormatEx(buffer, bufferSize, "swap");
}
case Get5ChatCommand_T:
{
case Get5ChatCommand_T: {
FormatEx(buffer, bufferSize, "t");
}
case Get5ChatCommand_CT:
{
case Get5ChatCommand_CT: {
FormatEx(buffer, bufferSize, "ct");
}
case Get5ChatCommand_Stop:
{
case Get5ChatCommand_Stop: {
FormatEx(buffer, bufferSize, "stop");
}
case Get5ChatCommand_Surrender:
{
case Get5ChatCommand_Surrender: {
FormatEx(buffer, bufferSize, "surrender");
}
case Get5ChatCommand_FFW:
{
case Get5ChatCommand_FFW: {
FormatEx(buffer, bufferSize, "ffw");
}
case Get5ChatCommand_CancelFFW:
{
case Get5ChatCommand_CancelFFW: {
FormatEx(buffer, bufferSize, "cancelffw");
}
default:
{
LogError("Failed to map Get5ChatCommand with value %d to a string. It is missing from ChatCommandToString.", command);
default: {
LogError("Failed to map Get5ChatCommand with value %d to a string. It is missing from ChatCommandToString.",
command);
}
}
}
Expand Down Expand Up @@ -881,4 +865,3 @@ stock Get5ChatCommand StringToChatCommand(const char[] string) {
return Get5ChatCommand_Unknown;
}
}

0 comments on commit c54cd78

Please sign in to comment.