From: Mario Date: Wed, 14 Oct 2015 11:17:44 +0000 (+1000) Subject: Fix another function full of gamemode specific blocks X-Git-Tag: xonotic-v0.8.2~1801^2~40 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d590b31e05a556e74208f9b0d07c3161ce1c3c84;p=xonotic%2Fxonotic-data.pk3dir.git Fix another function full of gamemode specific blocks --- diff --git a/qcsrc/server/command/getreplies.qc b/qcsrc/server/command/getreplies.qc index b3eeb1a69..fd312bff6 100644 --- a/qcsrc/server/command/getreplies.qc +++ b/qcsrc/server/command/getreplies.qc @@ -21,67 +21,12 @@ // See common.qc for their proper commands -string getrecords(float page) // 50 records per page +string getrecords(int page) // 50 records per page { - float rec = 0, r, i; - string h, s; + string s = ""; - s = ""; - - if (g_ctf) - { - for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i) - { - if (MapInfo_Get_ByID(i)) - { - r = stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/time"))); - - if (!r) - continue; - - // TODO: uid2name - h = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/netname")); - s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-6, ftos_decimals(r, 2)), " ", h, "\n"); - ++rec; - } - } - } - - if (g_race) - { - for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i) - { - if (MapInfo_Get_ByID(i)) - { - r = race_readTime(MapInfo_Map_bspname, 1); - - if (!r) - continue; - - h = race_readName(MapInfo_Map_bspname, 1); - s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n"); - ++rec; - } - } - } - - if (g_cts) - { - for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i) - { - if (MapInfo_Get_ByID(i)) - { - r = race_readTime(MapInfo_Map_bspname, 1); - - if (!r) - continue; - - h = race_readName(MapInfo_Map_bspname, 1); - s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n"); - ++rec; - } - } - } + MUTATOR_CALLHOOK(GetRecords, page, s); + s = ret_string; MapInfo_ClearTemps(); diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 1492b9f6a..bc034a660 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -635,4 +635,12 @@ MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize); /** player */ i(entity, other) \ /**/ MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch); + +#define EV_GetRecords(i, o) \ + /**/ i(int, record_page) \ + /**/ i(string, ret_string) \ + /**/ o(string, ret_string) \ + /**/ +int record_page; +MUTATOR_HOOKABLE(GetRecords, EV_GetRecords); #endif diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index ecbbc6ed8..0b2cad28c 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -2239,6 +2239,26 @@ MUTATOR_HOOKFUNCTION(ctf, SpectateCopy) return false; } +MUTATOR_HOOKFUNCTION(ctf, GetRecords) +{ + for(int i = record_page * 200; i < MapInfo_count && i < record_page * 200 + 200; ++i) + { + if (MapInfo_Get_ByID(i)) + { + float r = stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/time"))); + + if(!r) + continue; + + // TODO: uid2name + string h = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/netname")); + ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-6, ftos_decimals(r, 2)), " ", h, "\n"); + } + } + + return false; +} + // ========== // Spawnfuncs @@ -2434,7 +2454,6 @@ void ctf_Initialize() InitializeEntity(world, ctf_DelayedInit, INITPRIO_GAMETYPE); } - REGISTER_MUTATOR(ctf, g_ctf) { ActivateTeamplay(); diff --git a/qcsrc/server/mutators/gamemode_cts.qc b/qcsrc/server/mutators/gamemode_cts.qc index bdaee8c31..21d96d82f 100644 --- a/qcsrc/server/mutators/gamemode_cts.qc +++ b/qcsrc/server/mutators/gamemode_cts.qc @@ -285,6 +285,25 @@ MUTATOR_HOOKFUNCTION(cts, SetModname) return false; } +MUTATOR_HOOKFUNCTION(cts, GetRecords) +{ + for(int i = record_page * 200; i < MapInfo_count && i < record_page * 200 + 200; ++i) + { + if(MapInfo_Get_ByID(i)) + { + float r = race_readTime(MapInfo_Map_bspname, 1); + + if(!r) + continue; + + string h = race_readName(MapInfo_Map_bspname, 1); + ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n"); + } + } + + return false; +} + void cts_Initialize() { cts_ScoreRules(); diff --git a/qcsrc/server/mutators/gamemode_race.qc b/qcsrc/server/mutators/gamemode_race.qc index fa2e24f45..34196b38e 100644 --- a/qcsrc/server/mutators/gamemode_race.qc +++ b/qcsrc/server/mutators/gamemode_race.qc @@ -281,6 +281,25 @@ MUTATOR_HOOKFUNCTION(rc, Scores_CountFragsRemaining) return false; } +MUTATOR_HOOKFUNCTION(rc, GetRecords) +{ + for(int i = record_page * 200; i < MapInfo_count && i < record_page * 200 + 200; ++i) + { + if(MapInfo_Get_ByID(i)) + { + float r = race_readTime(MapInfo_Map_bspname, 1); + + if(!r) + continue; + + string h = race_readName(MapInfo_Map_bspname, 1); + ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n"); + } + } + + return false; +} + void race_Initialize() { race_ScoreRules();