Start working on lsmaps reply: update lsmaps on endmatch (gametype change)
authorSamual Lenks <samual@xonotic.org>
Sun, 25 Aug 2013 02:59:32 +0000 (22:59 -0400)
committerSamual Lenks <samual@xonotic.org>
Sun, 25 Aug 2013 02:59:32 +0000 (22:59 -0400)
qcsrc/server/command/getreplies.qc
qcsrc/server/command/getreplies.qh
qcsrc/server/g_world.qc

index 3920696..fb1c108 100644 (file)
@@ -285,3 +285,54 @@ string getladder()
        else
                return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s);
 }
+
+string getlsmaps()
+{
+       print("^1================= Executing getlsmaps()! =================\n");
+
+       string lsmaps, lsnewmaps, col;
+       float i, j, n;
+       lsmaps = "^7Maps available: ";
+       lsnewmaps = "^7Maps without a record set: ";
+       for(i = 0, j = 0; i < MapInfo_count; ++i)
+       {
+               if(MapInfo_Get_ByID(i))
+                       if not(MapInfo_Map_flags & MapInfo_ForbiddenFlags())
+                       {
+                               if(mod(i, 2))
+                                       col = "^2";
+                               else
+                                       col = "^3";
+
+                               ++j;
+
+                               lsmaps = strcat(lsmaps, col, MapInfo_Map_bspname, " ");
+
+                               if(g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time"))))
+                                       lsnewmaps = strcat(lsnewmaps, col, MapInfo_Map_bspname, " ");
+                               else if(g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time"))))
+                                       lsnewmaps = strcat(lsnewmaps, col, MapInfo_Map_bspname, " ");
+                       }
+       }
+
+       lsmaps = strzone(strcat(lsmaps, "\n"));
+       lsnewmaps = strzone(strcat(((!g_race && !g_cts) ? "Need to be playing race or CTS for lsnewmaps to work." : lsnewmaps), "\n"));
+
+       maplist_reply = "^7Maps in list: ";
+       n = tokenize_console(autocvar_g_maplist);
+       for(i = 0, j = 0; i < n; ++i)
+       {
+               if(MapInfo_CheckMap(argv(i)))
+               {
+                       if(mod(j, 2))
+                               col = "^2";
+                       else
+                               col = "^3";
+                       maplist_reply = strcat(maplist_reply, col, argv(i), " ");
+                       ++j;
+               }
+       }
+       maplist_reply = strzone(strcat(maplist_reply, "\n"));
+       MapInfo_ClearTemps();
+       return lsmaps;
+}
index af941a7..e63b898 100644 (file)
@@ -14,4 +14,5 @@ float top_scores[LADDER_SIZE];
 // allow functions to be used in other code like g_world.qc and race.qc
 string getrecords(float page);
 string getrankings(void);
-string getladder(void);
\ No newline at end of file
+string getladder(void);
+string getlsmaps(void);
index e8b3450..2f83973 100644 (file)
@@ -563,7 +563,7 @@ void WeaponStats_Shutdown();
 void spawnfunc_worldspawn (void)
 {
        float fd, l, i, j, n;
-       string s, col;
+       string s;
 
        cvar = cvar_normal;
        cvar_string = cvar_string_normal;
@@ -814,58 +814,14 @@ void spawnfunc_worldspawn (void)
        detect_maptype();
 
        // set up information replies for clients and server to use
-       lsmaps_reply = "^7Maps available: ";
-       lsnewmaps_reply = "^7Maps without a record set: ";
-       for(i = 0, j = 0; i < MapInfo_count; ++i)
-       {
-               if(MapInfo_Get_ByID(i))
-                       if not(MapInfo_Map_flags & MapInfo_ForbiddenFlags())
-                       {
-                               if(mod(i, 2))
-                                       col = "^2";
-                               else
-                                       col = "^3";
-
-                               ++j;
-
-                               lsmaps_reply = strcat(lsmaps_reply, col, MapInfo_Map_bspname, " ");
-
-                               if(g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time"))))
-                                       lsnewmaps_reply = strcat(lsnewmaps_reply, col, MapInfo_Map_bspname, " ");
-                               else if(g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time"))))
-                                       lsnewmaps_reply = strcat(lsnewmaps_reply, col, MapInfo_Map_bspname, " ");
-                       }
-       }
-
-       lsmaps_reply = strzone(strcat(lsmaps_reply, "\n"));
-       lsnewmaps_reply = strzone(strcat(((!g_race && !g_cts) ? "Need to be playing race or CTS for lsnewmaps to work." : lsnewmaps_reply), "\n"));
-
-       maplist_reply = "^7Maps in list: ";
-       n = tokenize_console(autocvar_g_maplist);
-       for(i = 0, j = 0; i < n; ++i)
-       {
-               if(MapInfo_CheckMap(argv(i)))
-               {
-                       if(mod(j, 2))
-                               col = "^2";
-                       else
-                               col = "^3";
-                       maplist_reply = strcat(maplist_reply, col, argv(i), " ");
-                       ++j;
-               }
-       }
-       maplist_reply = strzone(strcat(maplist_reply, "\n"));
-       MapInfo_ClearTemps();
-
+       lsmaps_reply = strzone(getlsmaps());
        for(i = 0; i < 10; ++i)
        {
                s = getrecords(i);
                if (s)
                        records_reply[i] = strzone(s);
        }
-
        ladder_reply = strzone(getladder());
-
        rankings_reply = strzone(getrankings());
 
        // begin other init
@@ -1583,6 +1539,10 @@ void NextLevel()
        if(autocvar_g_campaign)
                CampaignPreIntermission();
 
+       // update lsmaps in case the gametype changed, this way people can easily list maps for it
+       if(lsmaps_reply != "") { strunzone(lsmaps_reply); }
+       lsmaps_reply = strzone(getlsmaps());
+
        MUTATOR_CALLHOOK(MatchEnd);
 
        localcmd("\nsv_hook_gameend\n");