Skip to content

Commit

Permalink
Add get5_pretty_print_json cvar.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Sep 22, 2019
1 parent b47eda9 commit 7edaf9e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ ConVar g_MaxPausesCvar;
ConVar g_MaxPauseTimeCvar;
ConVar g_MessagePrefixCvar;
ConVar g_PausingEnabledCvar;
ConVar g_PrettyPrintJsonCvar;
ConVar g_ResetPausesEachHalfCvar;
ConVar g_ServerIdCvar;
ConVar g_SetClientClanTagCvar;
Expand Down Expand Up @@ -299,6 +300,7 @@ public void OnPluginStart() {
CreateConVar("get5_reset_pauses_each_half", "1",
"Whether pause limits will be reset each halftime period");
g_PausingEnabledCvar = CreateConVar("get5_pausing_enabled", "1", "Whether pausing is allowed.");
g_PrettyPrintJsonCvar = CreateConVar("get5_pretty_print_json", "1", "Whether all JSON output is in pretty-print format.");
g_ServerIdCvar = CreateConVar(
"get5_server_id", "0",
"Integer that identifies your server. This is used in temp files to prevent collisions.");
Expand Down Expand Up @@ -1353,7 +1355,7 @@ public Action Command_Status(int client, int args) {
}

char buffer[4096];
json.Encode(buffer, sizeof(buffer), true);
json.Encode(buffer, sizeof(buffer), g_PrettyPrintJsonCvar.BoolValue);
ReplyToCommand(client, buffer);

json.Cleanup();
Expand Down
2 changes: 1 addition & 1 deletion scripting/get5/eventlogger.sp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static void EventLogger_LogEvent(const char[] eventName, JSON_Object params) {
const int kMaxCharacters = 1000;
char buffer[2048];

json.Encode(buffer, sizeof(buffer));
json.Encode(buffer, sizeof(buffer), g_PrettyPrintJsonCvar.BoolValue);
if (strlen(buffer) > kMaxCharacters) {
LogError("Event JSON too long (%d characters, %d max): %s", eventName, strlen(buffer),
kMaxCharacters);
Expand Down
2 changes: 1 addition & 1 deletion scripting/get5_apistats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Action Command_Avaliable(int client, int args) {
json.SetInt("available", 1);
json.SetString("plugin_version", versionString);

char buffer[128];
char buffer[256];
json.Encode(buffer, sizeof(buffer), true);
ReplyToCommand(client, buffer);

Expand Down

0 comments on commit 7edaf9e

Please sign in to comment.