From: Mario Date: Sat, 11 Jul 2020 13:49:25 +0000 (+1000) Subject: Split the gamelog code out of miscfunctions and into its own file X-Git-Tag: xonotic-v0.8.5~882 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c1c5a398025611690a8d7d6bd64219ccf452e673;p=xonotic%2Fxonotic-data.pk3dir.git Split the gamelog code out of miscfunctions and into its own file --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 9f38cd9c3..4721d5ef4 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc index 4e219eae7..c08176cf8 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc @@ -1,6 +1,7 @@ #include "sv_cts.qh" #include +#include #include float autocvar_g_cts_finish_kill_delay; diff --git a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc index 32e39e204..6e333c17e 100644 --- a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc +++ b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc @@ -1,5 +1,6 @@ #include "sv_domination.qh" +#include #include bool g_domination; diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index f3c140fd1..735b01b30 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -1,6 +1,7 @@ #include "sv_keepaway.qh" #include +#include .entity ballcarried; diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index 5d52ed7cb..40870a790 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -1,5 +1,7 @@ #include "sv_keyhunt.qh" +#include + float autocvar_g_balance_keyhunt_damageforcescale; float autocvar_g_balance_keyhunt_delay_collect; float autocvar_g_balance_keyhunt_delay_damage_return; diff --git a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc index 38b7a7f53..079b181f0 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc @@ -1,5 +1,7 @@ #include "sv_nexball.qh" +#include + .entity ballcarried; int autocvar_g_nexball_goalleadlimit; diff --git a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc index bef3b1971..baf2131c8 100644 --- a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc @@ -1,5 +1,6 @@ #include "sv_race.qh" +#include #include #define autocvar_g_race_laps_limit cvar("g_race_laps_limit") diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index af74e6a5a..2e793d10a 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -1,6 +1,8 @@ #include "sv_minigames.qh" #include "minigames.qh" +#include + void player_clear_minigame(entity player) { CS(player).active_minigame = NULL; diff --git a/qcsrc/server/_mod.inc b/qcsrc/server/_mod.inc index 2ec838695..6c66dd95f 100644 --- a/qcsrc/server/_mod.inc +++ b/qcsrc/server/_mod.inc @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/server/_mod.qh b/qcsrc/server/_mod.qh index cc27baf12..06bb03df3 100644 --- a/qcsrc/server/_mod.qh +++ b/qcsrc/server/_mod.qh @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 9327a2034..fa4af040b 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -3,6 +3,7 @@ #include "antilag.qh" #include "autocvars.qh" #include "defs.qh" +#include #include "miscfunctions.qh" #include "command/common.qh" diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 2c687286b..5047334f0 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -20,6 +20,7 @@ #include "clientkill.qh" #include "cheats.qh" #include "g_world.qh" +#include #include "race.qh" #include "antilag.qh" #include "campaign.qh" diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 2f5f41efd..f98242ad6 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -1,6 +1,7 @@ #include "vote.qh" #include +#include #include #include diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 33627e24a..274378f17 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -3,6 +3,7 @@ #include #include "bot/api.qh" #include "g_hook.qh" +#include #include #include "teamplay.qh" #include "scores.qh" diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 48da1b5dc..7acb35d69 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -11,6 +11,7 @@ #include "command/sv_cmd.qh" #include "command/vote.qh" #include "g_hook.qh" +#include #include "ipban.qh" #include "mapvoting.qh" #include diff --git a/qcsrc/server/gamelog.qc b/qcsrc/server/gamelog.qc new file mode 100644 index 000000000..2c61419c5 --- /dev/null +++ b/qcsrc/server/gamelog.qc @@ -0,0 +1,56 @@ +#include "gamelog.qh" + +#include +#include + +string GameLog_ProcessIP(string s) +{ + if(!autocvar_sv_eventlog_ipv6_delimiter) + return s; + return strreplace(":", "_", s); +} + +void GameLogEcho(string s) +{ + if (autocvar_sv_eventlog_files) + { + if (!logfile_open) + { + logfile_open = true; + int matches = autocvar_sv_eventlog_files_counter + 1; + cvar_set("sv_eventlog_files_counter", itos(matches)); + string fn = ftos(matches); + if (strlen(fn) < 8) + fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn); + fn = strcat(autocvar_sv_eventlog_files_nameprefix, fn, autocvar_sv_eventlog_files_namesuffix); + logfile = fopen(fn, FILE_APPEND); + fputs(logfile, ":logversion:3\n"); + } + if (logfile >= 0) + { + if (autocvar_sv_eventlog_files_timestamps) + fputs(logfile, strcat(":time:", strftime(true, "%Y-%m-%d %H:%M:%S", "\n", s, "\n"))); + else + fputs(logfile, strcat(s, "\n")); + } + } + if (autocvar_sv_eventlog_console) + { + dedicated_print(strcat(s, "\n")); + } +} + +void GameLogInit() +{ + logfile_open = false; + // will be opened later +} + +void GameLogClose() +{ + if (logfile_open && logfile >= 0) + { + fclose(logfile); + logfile = -1; + } +} diff --git a/qcsrc/server/gamelog.qh b/qcsrc/server/gamelog.qh new file mode 100644 index 000000000..2fac52e47 --- /dev/null +++ b/qcsrc/server/gamelog.qh @@ -0,0 +1,12 @@ +#pragma once + +bool logfile_open; +float logfile; + +string GameLog_ProcessIP(string s); + +void GameLogEcho(string s); + +void GameLogInit(); + +void GameLogClose(); diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index 523d32bbc..fe8748f38 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -1,6 +1,7 @@ #include "mapvoting.qh" #include +#include #include #include "g_world.qh" #include "command/cmd.qh" diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index d4d5d3494..98bd7756a 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -4,6 +4,7 @@ #include "command/common.qh" #include "constants.qh" #include "g_hook.qh" +#include #include "ipban.qh" #include #include "../common/t_items.qh" @@ -84,61 +85,6 @@ void dedicated_print(string input) if (server_is_dedicated) print(input); } -string GameLog_ProcessIP(string s) -{ - if(!autocvar_sv_eventlog_ipv6_delimiter) - return s; - return strreplace(":", "_", s); -} - -void GameLogEcho(string s) -{ - string fn; - int matches; - - if (autocvar_sv_eventlog_files) - { - if (!logfile_open) - { - logfile_open = true; - matches = autocvar_sv_eventlog_files_counter + 1; - cvar_set("sv_eventlog_files_counter", itos(matches)); - fn = ftos(matches); - if (strlen(fn) < 8) - fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn); - fn = strcat(autocvar_sv_eventlog_files_nameprefix, fn, autocvar_sv_eventlog_files_namesuffix); - logfile = fopen(fn, FILE_APPEND); - fputs(logfile, ":logversion:3\n"); - } - if (logfile >= 0) - { - if (autocvar_sv_eventlog_files_timestamps) - fputs(logfile, strcat(":time:", strftime(true, "%Y-%m-%d %H:%M:%S", "\n", s, "\n"))); - else - fputs(logfile, strcat(s, "\n")); - } - } - if (autocvar_sv_eventlog_console) - { - dedicated_print(strcat(s, "\n")); - } -} - -void GameLogInit() -{ - logfile_open = 0; - // will be opened later -} - -void GameLogClose() -{ - if (logfile_open && logfile >= 0) - { - fclose(logfile); - logfile = -1; - } -} - entity findnearest(vector point, bool checkitems, vector axismod) { vector dist; diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 35fc07bea..e94ee9c6c 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -56,14 +56,6 @@ string formatmessage(entity this, string msg); /** print(), but only print if the server is not local */ void dedicated_print(string input); -string GameLog_ProcessIP(string s); - -void GameLogEcho(string s); - -void GameLogInit(); - -void GameLogClose(); - void GetCvars(entity this, entity store, int f); string GetMapname(); @@ -115,9 +107,6 @@ void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomo // copies a string to a tempstring (so one can strunzone it) string strcat1(string s) = #115; // FRIK_FILE -float logfile_open; -float logfile; - /* // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN. // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 531a1537b..09446203d 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -4,6 +4,7 @@ #include "g_hook.qh" #include "g_damage.qh" #include "g_world.qh" +#include #include "bot/api.qh" diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index a7c7205c1..83f1d3856 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -1,6 +1,7 @@ #include "teamplay.qh" #include "client.qh" +#include #include "race.qh" #include "scores.qh" #include "scores_rules.qh"