X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fgetreplies.qc;h=a55e0e0cd28706f7199c06db12aae058a02c1dbc;hb=85119d4a165562bcd7206c151255b8e680000367;hp=29b707b93da4bf08de5116d1ece08abda4956bc6;hpb=d03bf59652dab079deef7cf35e5b80599b13df05;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/getreplies.qc b/qcsrc/server/command/getreplies.qc index 29b707b93d..a55e0e0cd2 100644 --- a/qcsrc/server/command/getreplies.qc +++ b/qcsrc/server/command/getreplies.qc @@ -9,12 +9,14 @@ // without using any extra processing time. // See common.qc for their proper commands - + string getrecords(float page) // 50 records per page -{ - float rec, r, i; +{ + float rec = 0, r, i; string h, s; + s = ""; + if (g_ctf) { for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i) @@ -22,10 +24,10 @@ string getrecords(float page) // 50 records per page if (MapInfo_Get_ByID(i)) { r = stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/time"))); - - if (r == 0) + + 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"); @@ -41,10 +43,10 @@ string getrecords(float page) // 50 records per page if (MapInfo_Get_ByID(i)) { r = race_readTime(MapInfo_Map_bspname, 1); - - if (r == 0) + + 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; @@ -59,10 +61,10 @@ string getrecords(float page) // 50 records per page if (MapInfo_Get_ByID(i)) { r = race_readTime(MapInfo_Map_bspname, 1); - - if (r == 0) + + 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; @@ -72,7 +74,7 @@ string getrecords(float page) // 50 records per page MapInfo_ClearTemps(); - if (s == "" && page == 0) + if(s == "" && page == 0) return "No records are available on this server.\n"; else return s; @@ -85,15 +87,16 @@ string getrankings() map = GetMapname(); + s = ""; for (i = 1; i <= RANKINGS_CNT; ++i) { t = race_readTime(map, i); - + if (t == 0) continue; - + n = race_readName(map, i); - p = race_placeName(i); + p = count_ordinal(i); s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t)), " ", n, "\n"); } @@ -107,9 +110,9 @@ string getrankings() string getladder() { - float i, j, k, uidcnt, thiscnt; + float i, j, k, uidcnt = 0, thiscnt; string s, temp_s, rr, myuid, thisuid; - + if(g_cts) rr = CTS_RECORD; else @@ -144,12 +147,12 @@ string getladder() // LADDER_CNT+1 = total points temp_s = db_get(TemporaryDB, strcat("ladder", myuid)); - + if(temp_s == "") { db_put(TemporaryDB, strcat("uid", ftos(uidcnt)), myuid); ++uidcnt; - + for(j = 0; j <= LADDER_CNT + 1; ++j) { if(j != LADDER_CNT + 1) @@ -222,7 +225,7 @@ string getladder() top_uids[k] = top_uids[k-1]; top_scores[k] = top_scores[k-1]; } - + top_uids[j] = thisuid; top_scores[j] = thiscnt; break; @@ -230,21 +233,21 @@ string getladder() } } } - + s = "^3-----------------------\n\n"; - + s = strcat(s, "Pos ^3|"); s = strcat(s, " ^7Total ^3|"); - + for(i = 1; i <= LADDER_CNT; ++i) - { s = strcat(s, " ^7", race_placeName(i), " ^3|"); } - + { s = strcat(s, " ^7", count_ordinal(i), " ^3|"); } + s = strcat(s, " ^7Speed awards ^3| ^7Name"); s = strcat(s, "\n^3----+--------"); - + for(i = 1; i <= min(9, LADDER_CNT); ++i) { s = strcat(s, "+-----"); } - + #if LADDER_CNT > 9 for(i = 1; i <= LADDER_CNT - 9; ++i) { s = strcat(s, "+------"); } @@ -256,16 +259,16 @@ string getladder() { temp_s = db_get(TemporaryDB, strcat("ladder", top_uids[i])); tokenize_console(temp_s); - + if(argv(LADDER_CNT+1) == "") // total is 0, skip continue; - - s = strcat(s, strpad(4, race_placeName(i+1)), "^3| ^7"); // pos + + s = strcat(s, strpad(4, count_ordinal(i+1)), "^3| ^7"); // pos s = strcat(s, strpad(7, argv(LADDER_CNT+1)), "^3| ^7"); // total - + for(j = 1; j <= min(9, LADDER_CNT); ++j) { s = strcat(s, strpad(4, argv(j)), "^3| ^7"); } // 1st, 2nd, 3rd etc cnt - + #if LADDER_CNT > 9 for(j = 10; j <= LADDER_CNT; ++j) { s = strcat(s, strpad(4, argv(j)), " ^3| ^7"); } // 1st, 2nd, 3rd etc cnt @@ -281,4 +284,59 @@ string getladder() return "No ladder on this server!\n"; else return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s); -} \ No newline at end of file +} + +string getmaplist() +{ + string maplist = "", col; + float i, argc; + + argc = tokenize_console(autocvar_g_maplist); + for(i = 0; i < argc; ++i) + { + if(MapInfo_CheckMap(argv(i))) + { + if(mod(i, 2)) { col = "^2"; } + else { col = "^3"; } + maplist = sprintf("%s%s%s ", maplist, col, argv(i)); + } + } + + MapInfo_ClearTemps(); + return sprintf("^7Maps in list: %s\n", maplist); +} + + +string getlsmaps() +{ + string lsmaps = "", col; + float i, newmaps = 0; + + for(i = 0; i < MapInfo_count; ++i) + { + if((MapInfo_Get_ByID(i)) && !(MapInfo_Map_flags & MapInfo_ForbiddenFlags())) + { + // todo: Check by play count of maps for other game types? + 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")))) + ) + { + newmaps = TRUE; + if(mod(i, 2)) { col = "^4*"; } + else { col = "^5*"; } + } + else + { + if(mod(i, 2)) { col = "^2"; } + else { col = "^3"; } + } + + lsmaps = sprintf("%s%s%s ", lsmaps, col, MapInfo_Map_bspname); + } + } + + MapInfo_ClearTemps(); + return sprintf("^7Maps available%s: %s\n", (newmaps ? " (New maps have asterisks marked in blue)" : ""), lsmaps); +}