Split maplist to its own getreply func, clean up
authorSamual Lenks <samual@xonotic.org>
Sun, 25 Aug 2013 20:40:53 +0000 (16:40 -0400)
committerSamual Lenks <samual@xonotic.org>
Sun, 25 Aug 2013 20:40:53 +0000 (16:40 -0400)
commands.cfg
qcsrc/common/util.qh
qcsrc/server/command/common.qc
qcsrc/server/command/getreplies.qc
qcsrc/server/command/getreplies.qh
qcsrc/server/g_world.qc

index 3259478..dca2334 100644 (file)
@@ -43,7 +43,6 @@ alias cvar_purechanges     "qc_cmd_svcmd  cvar_purechanges     ${* ?}" // Prints
 alias info                 "qc_cmd_svcmd  info                 ${* ?}" // Request for unique server information set up by admin
 alias ladder               "qc_cmd_svcmd  ladder               ${* ?}" // Get information about top players if supported
 alias lsmaps               "qc_cmd_svcmd  lsmaps               ${* ?}" // List maps which can be used with the current game mode
-alias lsnewmaps            "qc_cmd_svcmd  lsnewmaps            ${* ?}" // List maps which have no records or are seemingly unplayed yet
 alias printmaplist         "qc_cmd_svcmd  printmaplist         ${* ?}" // Display full server maplist reply
 alias rankings             "qc_cmd_svcmd  rankings             ${* ?}" // Print information about rankings
 alias records              "qc_cmd_svcmd  records              ${* ?}" // List top 10 records for the current map
index e9bd01c..ad612f9 100644 (file)
@@ -203,7 +203,7 @@ float compressShotOrigin(vector v);
 vector decompressShotOrigin(float f);
 
 #ifdef SVQC
-string rankings_reply, ladder_reply, lsmaps_reply, lsnewmaps_reply, maplist_reply; // cached replies
+string rankings_reply, ladder_reply, lsmaps_reply, maplist_reply; // cached replies
 string records_reply[10];
 #endif
 
index 73bf0df..80b1d23 100644 (file)
@@ -360,26 +360,6 @@ void CommonCommand_lsmaps(float request, entity caller)
        }
 }
 
-void CommonCommand_lsnewmaps(float request, entity caller)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       print_to(caller, lsnewmaps_reply);
-                       return; // never fall through to usage
-               }
-                       
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " lsnewmaps"));
-                       print_to(caller, "  No arguments required.");
-                       return;
-               }
-       }
-}
-
 void CommonCommand_printmaplist(float request, entity caller)
 {
        switch(request)
@@ -693,7 +673,6 @@ void CommonCommand_(float request, entity caller)
        COMMON_COMMAND("info", CommonCommand_info(request, caller, arguments), "Request for unique server information set up by admin") \
        COMMON_COMMAND("ladder", CommonCommand_ladder(request, caller), "Get information about top players if supported") \
        COMMON_COMMAND("lsmaps", CommonCommand_lsmaps(request, caller), "List maps which can be used with the current game mode") \
-       COMMON_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request, caller), "List maps which have no records or are seemingly unplayed yet") \
        COMMON_COMMAND("printmaplist", CommonCommand_printmaplist(request, caller), "Display full server maplist reply") \
        COMMON_COMMAND("rankings", CommonCommand_rankings(request, caller), "Print information about rankings") \
        COMMON_COMMAND("records", CommonCommand_records(request, caller), "List top 10 records for the current map") \
index fb1c108..ea914e9 100644 (file)
@@ -286,53 +286,52 @@ string getladder()
                return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s);
 }
 
-string getlsmaps()
+string getmaplist()
 {
-       print("^1================= Executing getlsmaps()! =================\n");
+       //print("^1================= Executing getmaplist()! =================\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)
+       string maplist = "", col;
+       float i, argc;
+       
+       argc = tokenize_console(autocvar_g_maplist);
+       for(i = 0; i < argc; ++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, " ");
-                       }
+               if(MapInfo_CheckMap(argv(i)))
+               {
+                       if(mod(i, 2)) { col = "^2"; }
+                       else { col = "^3"; }
+                       maplist = sprintf("%s%s%s ", maplist, col, argv(i));
+               }
        }
 
-       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"));
+       MapInfo_ClearTemps();
+       return sprintf("^7Maps in list: %s\n", maplist);
+}
+
+       
+string getlsmaps()
+{
+       //print("^1================= Executing getlsmaps()! =================\n");
 
-       maplist_reply = "^7Maps in list: ";
-       n = tokenize_console(autocvar_g_maplist);
-       for(i = 0, j = 0; i < n; ++i)
+       string lsmaps = "", col;
+       float i;
+       
+       for(i = 0; i < MapInfo_count; ++i)
        {
-               if(MapInfo_CheckMap(argv(i)))
+               if((MapInfo_Get_ByID(i)) && !(MapInfo_Map_flags & MapInfo_ForbiddenFlags()))
                {
-                       if(mod(j, 2))
-                               col = "^2";
-                       else
-                               col = "^3";
-                       maplist_reply = strcat(maplist_reply, col, argv(i), " ");
-                       ++j;
+                       if(mod(i, 2)) { col = "^2"; }
+                       else if(
+                               (g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time"))))
+                               ||
+                               (g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time"))))
+                       ) { col = "^5*"; }
+                       else { col = "^3"; }
+
+                       lsmaps = sprintf("%s%s%s ", lsmaps, col, MapInfo_Map_bspname);
                }
        }
-       maplist_reply = strzone(strcat(maplist_reply, "\n"));
+
        MapInfo_ClearTemps();
-       return lsmaps;
+       return sprintf("^7Maps available: %s\n", lsmaps);
 }
index e63b898..77da272 100644 (file)
@@ -15,4 +15,5 @@ float top_scores[LADDER_SIZE];
 string getrecords(float page);
 string getrankings(void);
 string getladder(void);
+string getmaplist(void);
 string getlsmaps(void);
index 56200fe..e3b796c 100644 (file)
@@ -814,6 +814,7 @@ void spawnfunc_worldspawn (void)
        detect_maptype();
 
        // set up information replies for clients and server to use
+       maplist_reply = strzone(getmaplist());
        lsmaps_reply = strzone(getlsmaps());
        for(i = 0; i < 10; ++i)
        {