Xonotic
getreplies.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LADDER_CNT   10
 

Functions

void GetCvars (entity this, entity store, int f)
 
void GetCvars_handleFloat (entity this, entity store, string thisname, float f,.float field, string name)
 
void GetCvars_handleString (entity this, entity store, string thisname, float f,.string field, string name)
 
string getladder ()
 
string getlsmaps ()
 
string getmaplist ()
 
string getmonsterlist ()
 
string getrankings ()
 
string getrecords (float page)
 

Variables

const int LADDER_FIRSTPOINT = 100
 
const int LADDER_SIZE = 30
 
float top_scores [LADDER_SIZE]
 
string top_uids [LADDER_SIZE]
 

Macro Definition Documentation

◆ LADDER_CNT

#define LADDER_CNT   10

Definition at line 10 of file getreplies.qh.

Referenced by getladder().

Function Documentation

◆ GetCvars()

void GetCvars ( entity  this,
entity  store,
int  f 
)
Parameters
f-1: cleanup, 0: request, 1: receive

Definition at line 381 of file getreplies.qc.

References argv(), get_cvars_f, get_cvars_s, GetCvars(), LOG_INFO, MUTATOR_CALLHOOK, and string_null.

Referenced by ClientCommand_sentcvar(), ClientState_detach(), and GetCvars().

382 {
383  string s = string_null;
384 
385  if (f == 0)
386  LOG_INFO("Warning: requesting cvar values is deprecated. Client should send them automatically using REPLICATE.\n");
387 
388  if (f > 0)
389  s = strcat1(argv(f));
390 
391  get_cvars_f = f;
392  get_cvars_s = s;
394 
395  Notification_GetCvars(this, store);
396 
397  ReplicateVars(this, store, s, f);
398  if (f > 0)
399  ReplicateVars_ApplyChange(this, store, s, f);
400 }
string string_null
Definition: nil.qh:9
void GetCvars(entity this, entity store, int f)
Definition: getreplies.qc:381
string get_cvars_s
Definition: events.qh:336
#define LOG_INFO(...)
Definition: log.qh:70
float get_cvars_f
Definition: events.qh:335
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCvars_handleFloat()

void GetCvars_handleFloat ( entity  this,
entity  store,
string  thisname,
float  f,
.float  field,
string  name 
)

Definition at line 341 of file getreplies.qc.

References argv(), stof(), strcat(), and stuffcmd.

342 {
343  if (f < 0)
344  {
345  }
346  else if (f > 0)
347  {
348  if (thisname == name)
349  store.(field) = stof(argv(f + 1));
350  }
351  else
352  stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
353 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
+ Here is the call graph for this function:

◆ GetCvars_handleString()

void GetCvars_handleString ( entity  this,
entity  store,
string  thisname,
float  f,
.string  field,
string  name 
)

Definition at line 312 of file getreplies.qc.

References argv(), strcat(), strcpy, strfree, and stuffcmd.

Referenced by GetCvars_handleString_Fixup().

313 {
314  if (f < 0)
315  {
316  strfree(store.(field));
317  }
318  else if (f > 0)
319  {
320  if (thisname == name)
321  {
322  strcpy(store.(field), argv(f + 1));
323  }
324  }
325  else
326  stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
327 }
#define strcpy(this, s)
Definition: string.qh:49
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getladder()

string getladder ( )

Definition at line 71 of file getreplies.qc.

References argv(), count_ordinal(), CTS_RECORD, db_get(), db_put(), floor(), ftos(), g_cts, LADDER_CNT, LADDER_FIRSTPOINT, LADDER_SIZE, MapInfo_ClearTemps(), MapInfo_count, MapInfo_Get_ByID(), MapInfo_Map_bspname, min(), race_readTime(), race_readUID(), RACE_RECORD, ServerProgsDB, stof(), strcat(), TemporaryDB, tokenize_console, top_scores, top_uids, and uid2name().

Referenced by spawnfunc().

72 {
73  int i, j, k, uidcnt = 0, thiscnt;
74  string s, temp_s, rr, myuid, thisuid;
75 
76  rr = (g_cts) ? CTS_RECORD : RACE_RECORD;
77 
78  for (k = 0; k < MapInfo_count; ++k)
79  {
80  if (MapInfo_Get_ByID(k))
81  {
82  for (i = 0; i <= LADDER_CNT; ++i) // i = 0 because it is the speed award
83  {
84  if (i == 0) // speed award
85  {
86  if (stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/speed"))) == 0) continue;
87 
88  myuid = db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, rr, "speed/crypto_idfp"));
89  }
90  else // normal record, if it exists (else break)
91  {
92  if (race_readTime(MapInfo_Map_bspname, i) == 0) continue;
93 
95  }
96 
97  // string s contains:
98  // arg 0 = # of speed recs
99  // arg 1 = # of 1st place recs
100  // arg 2 = # of 2nd place recs
101  // ... etc
102  // LADDER_CNT+1 = total points
103 
104  temp_s = db_get(TemporaryDB, strcat("ladder", myuid));
105 
106  if (temp_s == "")
107  {
108  db_put(TemporaryDB, strcat("uid", ftos(uidcnt)), myuid);
109  ++uidcnt;
110 
111  for (j = 0; j <= LADDER_CNT + 1; ++j)
112  {
113  if (j != LADDER_CNT + 1) temp_s = strcat(temp_s, "0 ");
114  else temp_s = strcat(temp_s, "0");
115  }
116  }
117 
118  tokenize_console(temp_s);
119  s = "";
120 
121  if (i == 0) // speed award
122  {
123  for (j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string
124  {
125  if (j == 0) // speed award
126  s = strcat(s, ftos(stof(argv(j)) + 1)); // add 1 to speed rec count and write
127  else s = strcat(s, " ", argv(j)); // just copy over everything else
128  }
129  }
130  else // record
131  {
132  for (j = 0; j <= LADDER_CNT; ++j) // loop over each arg in the string
133  {
134  if (j == 0) s = strcat(s, argv(j)); // speed award, dont prefix with " "
135  else if (j == i) // wanted rec!
136  s = strcat(s, " ", ftos(stof(argv(j)) + 1)); // update argv(j)
137  else s = strcat(s, " ", argv(j)); // just copy over everything else
138  }
139  }
140 
141  // total points are (by default) calculated like this:
142  // speedrec = floor(100 / 10) = 10 points
143  // 1st place = floor(100 / 1) = 100 points
144  // 2nd place = floor(100 / 2) = 50 points
145  // 3rd place = floor(100 / 3) = 33 points
146  // 4th place = floor(100 / 4) = 25 points
147  // 5th place = floor(100 / 5) = 20 points
148  // ... etc
149 
150  if (i == 0) s = strcat(s, " ", ftos(stof(argv(LADDER_CNT + 1)) + LADDER_FIRSTPOINT / 10)); // speed award, add LADDER_FIRSTPOINT / 10 points
151  else s = strcat(s, " ", ftos(stof(argv(LADDER_CNT + 1)) + floor(LADDER_FIRSTPOINT / i))); // record, add LADDER_FIRSTPOINT / i points
152 
153  db_put(TemporaryDB, strcat("ladder", myuid), s);
154  }
155  }
156  }
157 
158  for (i = 0; i <= uidcnt; ++i) // for each known uid
159  {
160  thisuid = db_get(TemporaryDB, strcat("uid", ftos(i)));
161  temp_s = db_get(TemporaryDB, strcat("ladder", thisuid));
162  tokenize_console(temp_s);
163  thiscnt = stof(argv(LADDER_CNT + 1));
164 
165  if (thiscnt > top_scores[LADDER_SIZE - 1])
166  {
167  for (j = 0; j < LADDER_SIZE; ++j) // for each place in ladder
168  {
169  if (thiscnt > top_scores[j])
170  {
171  for (k = LADDER_SIZE - 1; k >= j; --k)
172  {
173  top_uids[k] = top_uids[k - 1];
174  top_scores[k] = top_scores[k - 1];
175  }
176 
177  top_uids[j] = thisuid;
178  top_scores[j] = thiscnt;
179  break;
180  }
181  }
182  }
183  }
184 
185  s = "^3-----------------------\n\n";
186 
187  s = strcat(s, "Pos ^3|");
188  s = strcat(s, " ^7Total ^3|");
189 
190  for (i = 1; i <= LADDER_CNT; ++i)
191  s = strcat(s, " ^7", count_ordinal(i), " ^3|");
192  s = strcat(s, " ^7Speed awards ^3| ^7Name");
193  s = strcat(s, "\n^3----+--------");
194 
195  for (i = 1; i <= min(9, LADDER_CNT); ++i)
196  s = strcat(s, "+-----");
197 #if LADDER_CNT > 9
198  for (i = 1; i <= LADDER_CNT - 9; ++i)
199  s = strcat(s, "+------");
200 #endif
201 
202  s = strcat(s, "+--------------+--------------------\n");
203 
204  for (i = 0; i < LADDER_SIZE; ++i)
205  {
206  temp_s = db_get(TemporaryDB, strcat("ladder", top_uids[i]));
207  tokenize_console(temp_s);
208 
209  if (argv(LADDER_CNT + 1) == "") // total is 0, skip
210  continue;
211 
212  s = strcat(s, strpad(4, count_ordinal(i + 1)), "^3| ^7"); // pos
213  s = strcat(s, strpad(7, argv(LADDER_CNT + 1)), "^3| ^7"); // total
214 
215  for (j = 1; j <= min(9, LADDER_CNT); ++j)
216  s = strcat(s, strpad(4, argv(j)), "^3| ^7"); // 1st, 2nd, 3rd etc cnt
217 
218 #if LADDER_CNT > 9
219  for (j = 10; j <= LADDER_CNT; ++j)
220  s = strcat(s, strpad(4, argv(j)), " ^3| ^7"); // 1st, 2nd, 3rd etc cnt
221 #endif
222 
223  s = strcat(s, strpad(13, argv(0)), "^3| ^7"); // speed award cnt
224  s = strcat(s, uid2name(top_uids[i]), "\n"); // name
225  }
226 
228 
229  if (s == "") return "No ladder on this server!\n";
230  else return strcat("Top ", ftos(LADDER_SIZE), " ladder rankings:\n", s);
231 }
ERASEABLE void db_put(int db, string key, string value)
Definition: map.qh:101
string uid2name(string myuid)
Definition: race.qc:36
float ServerProgsDB
Definition: world.qh:131
string race_readUID(string map, float pos)
Definition: race.qc:83
#define RACE_RECORD
Definition: util.qh:58
#define LADDER_CNT
Definition: getreplies.qh:10
bool MapInfo_Get_ByID(int i)
Definition: mapinfo.qc:256
#define CTS_RECORD
Definition: util.qh:59
ERASEABLE string count_ordinal(int interval)
Definition: counting.qh:66
float TemporaryDB
Definition: world.qh:132
float MapInfo_count
Definition: mapinfo.qh:144
#define g_cts
Definition: cts.qh:36
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float race_readTime(string map, float pos)
Definition: race.qc:78
ERASEABLE string db_get(int db, string key)
Definition: map.qh:91
void MapInfo_ClearTemps()
Definition: mapinfo.qc:1299
#define tokenize_console
Definition: dpextensions.qh:24
string MapInfo_Map_bspname
Definition: mapinfo.qh:6
const int LADDER_FIRSTPOINT
Definition: getreplies.qh:9
const int LADDER_SIZE
Definition: getreplies.qh:11
string top_uids[LADDER_SIZE]
Definition: getreplies.qh:13
float top_scores[LADDER_SIZE]
Definition: getreplies.qh:14
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getlsmaps()

string getlsmaps ( )

Definition at line 253 of file getreplies.qc.

References g_cts, g_race, LSMAPS_MAX, MapInfo_ClearTemps(), MapInfo_count, MapInfo_ForbiddenFlags(), MapInfo_Get_ByID(), MapInfo_Map_bspname, MapInfo_Map_flags, and race_readTime().

Referenced by GameCommand_gametype(), GameTypeVote_SetGametype(), and spawnfunc().

254 {
255  string lsmaps = "", col;
256  bool newmaps = false;
257  int added = 0;
258 
259  for (int i = 0; i < MapInfo_count; ++i)
260  {
262  {
263  ++added;
264 
265  if(added > LSMAPS_MAX)
266  continue; // we still get the added count, but skip the actual processing
267 
268  // todo: Check by play count of maps for other game types?
270  {
271  newmaps = true;
272  if (i % 2) col = "^4*"; else col = "^5*";
273  }
274  else
275  {
276  if (i % 2) col = "^2"; else col = "^3";
277  }
278 
279  lsmaps = sprintf("%s%s%s ", lsmaps, col, MapInfo_Map_bspname);
280  }
281  }
282 
283  if(added > LSMAPS_MAX)
284  lsmaps = sprintf("%s^7(%d not listed)", lsmaps, added - LSMAPS_MAX);
285 
287  return sprintf("^7Maps available (%d)%s: %s\n", added, (newmaps ? " (New maps have asterisks marked in blue)" : ""), lsmaps);
288 }
const int LSMAPS_MAX
Definition: getreplies.qc:252
bool MapInfo_Get_ByID(int i)
Definition: mapinfo.qc:256
int MapInfo_ForbiddenFlags()
Definition: mapinfo.qc:1324
int MapInfo_Map_flags
Definition: mapinfo.qh:15
float MapInfo_count
Definition: mapinfo.qh:144
#define g_cts
Definition: cts.qh:36
#define g_race
Definition: race.qh:46
float race_readTime(string map, float pos)
Definition: race.qc:78
void MapInfo_ClearTemps()
Definition: mapinfo.qc:1299
string MapInfo_Map_bspname
Definition: mapinfo.qh:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getmaplist()

string getmaplist ( )

Definition at line 233 of file getreplies.qc.

References argv(), autocvar_g_maplist, MapInfo_CheckMap(), MapInfo_ClearTemps(), and tokenize_console.

Referenced by spawnfunc().

234 {
235  string maplist = "", col;
236  int i, argc;
237 
239  for (i = 0; i < argc; ++i)
240  {
241  if (MapInfo_CheckMap(argv(i)))
242  {
243  if (i % 2) col = "^2"; else col = "^3";
244  maplist = sprintf("%s%s%s ", maplist, col, argv(i));
245  }
246  }
247 
249  return sprintf("^7Maps in list: %s\n", maplist);
250 }
#define autocvar_g_maplist
Definition: mapvoting.qh:3
float MapInfo_CheckMap(string s)
Definition: mapinfo.qc:1170
void MapInfo_ClearTemps()
Definition: mapinfo.qc:1299
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getmonsterlist()

string getmonsterlist ( )

Definition at line 290 of file getreplies.qc.

References FOREACH, and MON_FLAG_HIDDEN.

Referenced by spawnfunc().

291 {
292  string monsterlist = "";
293 
294  FOREACH(Monsters, it != MON_Null && !(it.spawnflags & MON_FLAG_HIDDEN),
295  {
296  string col = ((i % 2) ? "^2" : "^3");
297  monsterlist = sprintf("%s%s%s ", monsterlist, col, it.netname);
298  });
299 
300  return sprintf("^7Monsters available: %s\n", monsterlist);
301 }
const int MON_FLAG_HIDDEN
Definition: monster.qh:16
#define FOREACH(list, cond, body)
Definition: iter.qh:19
+ Here is the caller graph for this function:

◆ getrankings()

string getrankings ( )

Definition at line 46 of file getreplies.qc.

References count_ordinal(), GetMapname(), MapInfo_ClearTemps(), race_readName(), race_readTime(), strcat(), and TIME_ENCODED_TOSTRING.

Referenced by race_deleteTime(), race_setTime(), and spawnfunc().

47 {
48  float t, i;
49  string n, s, p, map;
50 
51  map = GetMapname();
52 
53  s = "";
54  for (i = 1; i <= RANKINGS_CNT; ++i)
55  {
56  t = race_readTime(map, i);
57 
58  if (t == 0) continue;
59 
60  n = race_readName(map, i);
61  p = count_ordinal(i);
62  s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t)), " ", n, "\n");
63  }
64 
66 
67  if (s == "") return strcat("No records are available for the map: ", map, "\n");
68  else return strcat("Records for ", map, ":\n", s);
69 }
string GetMapname()
Definition: intermission.qc:18
#define TIME_ENCODED_TOSTRING(n)
Definition: util.qh:57
ERASEABLE string count_ordinal(int interval)
Definition: counting.qh:66
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float race_readTime(string map, float pos)
Definition: race.qc:78
void MapInfo_ClearTemps()
Definition: mapinfo.qc:1299
string race_readName(string map, float pos)
Definition: race.qc:138
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getrecords()

string getrecords ( float  page)

Variable Documentation

◆ LADDER_FIRSTPOINT

const int LADDER_FIRSTPOINT = 100

Definition at line 9 of file getreplies.qh.

Referenced by getladder().

◆ LADDER_SIZE

const int LADDER_SIZE = 30

Definition at line 11 of file getreplies.qh.

Referenced by getladder().

◆ top_scores

float top_scores[LADDER_SIZE]

Definition at line 14 of file getreplies.qh.

Referenced by getladder().

◆ top_uids

string top_uids[LADDER_SIZE]

Definition at line 13 of file getreplies.qh.

Referenced by getladder().