]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix another function full of gamemode specific blocks
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 11:17:44 +0000 (21:17 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 11:17:44 +0000 (21:17 +1000)
qcsrc/server/command/getreplies.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_cts.qc
qcsrc/server/mutators/gamemode_race.qc

index b3eeb1a69bdf2627042ceacb8daf94e107f7d55f..fd312bff6174b840d0c808f2370d01ee5407dc46 100644 (file)
 
 // 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();
 
index 1492b9f6af3d07a06aa8a782a8d4a846ea60bea0..bc034a6607c1164413546b986083abfe69c1de48 100644 (file)
@@ -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
index ecbbc6ed82f08750ac11727a8a22cd194928ea08..0b2cad28c9b51767bd482c3240d6be344151bb89 100644 (file)
@@ -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();
index bdaee8c314f66eeb1595a261bca15b31f6df5285..21d96d82f262afa8e741504fdc4c71a59c0028e6 100644 (file)
@@ -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();
index fa2e24f4527157cfa4ef2ab1f6710b11719398e6..34196b38e336f23809aae036d2d28655912afdd8 100644 (file)
@@ -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();