1 // =========================================================
2 // Reply messages for common commands, re-worked by Samual
3 // Last updated: December 30th, 2011
4 // =========================================================
6 // These strings are set usually during init in g_world.qc,
7 // or also by some game modes or other functions manually,
8 // and their purpose is to output information to clients
9 // without using any extra processing time.
11 // See common.qc for their proper commands
13 string getrecords(float page) // 50 records per page
22 for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i)
24 if (MapInfo_Get_ByID(i))
26 r = stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/time")));
32 h = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, "/captimerecord/netname"));
33 s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-6, ftos_decimals(r, 2)), " ", h, "\n");
41 for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i)
43 if (MapInfo_Get_ByID(i))
45 r = race_readTime(MapInfo_Map_bspname, 1);
50 h = race_readName(MapInfo_Map_bspname, 1);
51 s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n");
59 for (i = page * 200; i < MapInfo_count && i < page * 200 + 200; ++i)
61 if (MapInfo_Get_ByID(i))
63 r = race_readTime(MapInfo_Map_bspname, 1);
68 h = race_readName(MapInfo_Map_bspname, 1);
69 s = strcat(s, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n");
77 if(s == "" && page == 0)
78 return "No records are available on this server.\n";
91 for (i = 1; i <= RANKINGS_CNT; ++i)
93 t = race_readTime(map, i);
98 n = race_readName(map, i);
100 s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t)), " ", n, "\n");
103 MapInfo_ClearTemps();
106 return strcat("No records are available for the map: ", map, "\n");
108 return strcat("Records for ", map, ":\n", s);
113 float i, j, k, uidcnt = 0, thiscnt;
114 string s, temp_s, rr, myuid, thisuid;
116 rr = (g_cts) ? CTS_RECORD : RACE_RECORD;
118 for(k = 0; k < MapInfo_count; ++k)
120 if(MapInfo_Get_ByID(k))
122 for(i = 0; i <= LADDER_CNT; ++i) // i = 0 because it is the speed award
124 if(i == 0) // speed award
126 if(stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/speed"))) == 0)
129 myuid = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/crypto_idfp"));
131 else // normal record, if it exists (else break)
133 if(race_readTime(MapInfo_Map_bspname, i) == 0)
136 myuid = race_readUID(MapInfo_Map_bspname, i);
139 // string s contains:
140 // arg 0 = # of speed recs
141 // arg 1 = # of 1st place recs
142 // arg 2 = # of 2nd place recs
144 // LADDER_CNT+1 = total points
146 temp_s = db_get(TemporaryDB, strcat("ladder", myuid));
150 db_put(TemporaryDB, strcat("uid", ftos(uidcnt)), myuid);
153 for(j = 0; j <= LADDER_CNT + 1; ++j)
155 if(j != LADDER_CNT + 1)
156 temp_s = strcat(temp_s, "0 ");
158 temp_s = strcat(temp_s, "0");
162 tokenize_console(temp_s);
165 if(i == 0) // speed award
167 for(j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string
169 if(j == 0) // speed award
170 s = strcat(s, ftos(stof(argv(j)) +1)); // add 1 to speed rec count and write
172 s = strcat(s, " ", argv(j)); // just copy over everything else
177 for(j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string
180 s = strcat(s, argv(j)); // speed award, dont prefix with " "
181 else if(j == i) // wanted rec!
182 s = strcat(s, " ", ftos(stof(argv(j)) +1)); // update argv(j)
184 s = strcat(s, " ", argv(j)); // just copy over everything else
188 // total points are (by default) calculated like this:
189 // speedrec = floor(100 / 10) = 10 points
190 // 1st place = floor(100 / 1) = 100 points
191 // 2nd place = floor(100 / 2) = 50 points
192 // 3rd place = floor(100 / 3) = 33 points
193 // 4th place = floor(100 / 4) = 25 points
194 // 5th place = floor(100 / 5) = 20 points
198 s = strcat(s, " ", ftos(stof(argv(LADDER_CNT+1)) + LADDER_FIRSTPOINT / 10)); // speed award, add LADDER_FIRSTPOINT / 10 points
200 s = strcat(s, " ", ftos(stof(argv(LADDER_CNT+1)) + floor(LADDER_FIRSTPOINT / i))); // record, add LADDER_FIRSTPOINT / i points
202 db_put(TemporaryDB, strcat("ladder", myuid), s);
207 for(i = 0; i <= uidcnt; ++i) // for each known uid
209 thisuid = db_get(TemporaryDB, strcat("uid", ftos(i)));
210 temp_s = db_get(TemporaryDB, strcat("ladder", thisuid));
211 tokenize_console(temp_s);
212 thiscnt = stof(argv(LADDER_CNT+1));
214 if(thiscnt > top_scores[LADDER_SIZE-1])
216 for(j = 0; j < LADDER_SIZE; ++j) // for each place in ladder
218 if(thiscnt > top_scores[j])
220 for(k = LADDER_SIZE-1; k >= j; --k)
222 top_uids[k] = top_uids[k-1];
223 top_scores[k] = top_scores[k-1];
226 top_uids[j] = thisuid;
227 top_scores[j] = thiscnt;
234 s = "^3-----------------------\n\n";
236 s = strcat(s, "Pos ^3|");
237 s = strcat(s, " ^7Total ^3|");
239 for(i = 1; i <= LADDER_CNT; ++i)
240 { s = strcat(s, " ^7", count_ordinal(i), " ^3|"); }
242 s = strcat(s, " ^7Speed awards ^3| ^7Name");
243 s = strcat(s, "\n^3----+--------");
245 for(i = 1; i <= min(9, LADDER_CNT); ++i)
246 { s = strcat(s, "+-----"); }
249 for(i = 1; i <= LADDER_CNT - 9; ++i)
250 { s = strcat(s, "+------"); }
253 s = strcat(s, "+--------------+--------------------\n");
255 for(i = 0; i < LADDER_SIZE; ++i)
257 temp_s = db_get(TemporaryDB, strcat("ladder", top_uids[i]));
258 tokenize_console(temp_s);
260 if(argv(LADDER_CNT+1) == "") // total is 0, skip
263 s = strcat(s, strpad(4, count_ordinal(i+1)), "^3| ^7"); // pos
264 s = strcat(s, strpad(7, argv(LADDER_CNT+1)), "^3| ^7"); // total
266 for(j = 1; j <= min(9, LADDER_CNT); ++j)
267 { s = strcat(s, strpad(4, argv(j)), "^3| ^7"); } // 1st, 2nd, 3rd etc cnt
270 for(j = 10; j <= LADDER_CNT; ++j)
271 { s = strcat(s, strpad(4, argv(j)), " ^3| ^7"); } // 1st, 2nd, 3rd etc cnt
274 s = strcat(s, strpad(13, argv(0)), "^3| ^7"); // speed award cnt
275 s = strcat(s, uid2name(top_uids[i]), "\n"); // name
278 MapInfo_ClearTemps();
281 return "No ladder on this server!\n";
283 return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s);
288 string maplist = "", col;
291 argc = tokenize_console(autocvar_g_maplist);
292 for(i = 0; i < argc; ++i)
294 if(MapInfo_CheckMap(argv(i)))
296 if(mod(i, 2)) { col = "^2"; }
298 maplist = sprintf("%s%s%s ", maplist, col, argv(i));
302 MapInfo_ClearTemps();
303 return sprintf("^7Maps in list: %s\n", maplist);
309 string lsmaps = "", col;
310 float i, newmaps = 0;
312 for(i = 0; i < MapInfo_count; ++i)
314 if((MapInfo_Get_ByID(i)) && !(MapInfo_Map_flags & MapInfo_ForbiddenFlags()))
316 // todo: Check by play count of maps for other game types?
318 (g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time"))))
320 (g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time"))))
324 if(mod(i, 2)) { col = "^4*"; }
325 else { col = "^5*"; }
329 if(mod(i, 2)) { col = "^2"; }
333 lsmaps = sprintf("%s%s%s ", lsmaps, col, MapInfo_Map_bspname);
337 MapInfo_ClearTemps();
338 return sprintf("^7Maps available (%d)%s: %s\n", tokenize_console(lsmaps), (newmaps ? " (New maps have asterisks marked in blue)" : ""), lsmaps);
341 string getmonsterlist()
343 string monsterlist = "", col;
346 for(i = MON_FIRST; i <= MON_LAST; ++i)
348 if(mod(i, 2)) { col = "^2"; }
350 monsterlist = sprintf("%s%s%s ", monsterlist, col, (get_monsterinfo(i)).netname);
353 return sprintf("^7Monsters available: %s\n", monsterlist);