Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
race.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void race_AbandonRaceCheck (entity p)
void race_checkAndWriteName (entity player)
void race_ClearPlayerRecords (entity player)
void race_ClearRecords ()
float race_GetFractionalLapCount (entity e)
void race_ImposePenaltyTime (entity pl, float penalty, string reason)
float race_NextCheckpoint (float f)
void race_PreparePlayer (entity this)
float race_PreviousCheckpoint (float f)
string race_readName (string map, float pos)
float race_readTime (string map, float pos)
string race_readUID (string map, float pos)
void race_RetractPlayer (entity this)
void race_send_rankings_cnt (float msg)
void race_send_recordtime (float msg)
void race_send_speedaward (float msg)
void race_send_speedaward_alltimebest (float msg)
void race_SendAll (entity player, bool only_rankings)
void race_SendNextCheckpoint (entity e, float spec)
void race_SendRanking (float pos, float prevpos, float del, float msg)
void race_setTime (string map, float t, string myuid, string mynetname, entity e, bool showmessage)
void race_SpeedAwardFrame (entity player)
void race_StartCompleting ()
 spawnfunc (target_checkpoint)
string uid2name (string myuid)
void write_recordmarker (entity pl, float tstart, float dt)

Variables

bool autocvar_g_allow_checkpoints
int autocvar_g_cts_send_rankings_cnt = 15
bool autocvar_g_race_cptimes_onlyself = false
int g_race_qualifying
float race_completed
float race_completing
float race_fraglimit
float race_highest_place_spawn
float race_laptime
float race_leadlimit
float race_lowest_place_spawn
float race_movetime
float race_movetime_count
float race_movetime_frac
float race_place
float race_respawn_checkpoint
entity race_respawn_spotref
float race_spawns
float race_started
float race_teams
float race_timelimit
float speedaward_alltimebest
string speedaward_alltimebest_holder
string speedaward_alltimebest_uid
string speedaward_holder
float speedaward_lastsent
float speedaward_lastupdate
float speedaward_speed
string speedaward_uid
const float ST_RACE_LAPS = 1

Function Documentation

◆ race_AbandonRaceCheck()

void race_AbandonRaceCheck ( entity p)

Definition at line 1229 of file race.qc.

1230{
1232 {
1233 CS(p).race_completed = 1;
1235 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_ABANDONED, p.netname);
1236 ClientData_Touch(p, true);
1237 }
1238}
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define NULL
Definition post.qh:14
void ClientData_Touch(entity e, bool to_spectators_too)
Definition client.qc:185
#define MAKE_INDEPENDENT_PLAYER(e)
Definition client.qh:313
float race_completed
Definition race.qh:26
float race_completing
Definition race.qh:28
ClientState CS(Client this)
Definition state.qh:47

References ClientData_Touch(), CS(), entity(), MAKE_INDEPENDENT_PLAYER, NULL, race_completed, race_completing, and Send_Notification().

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and race_StartCompleting().

◆ race_checkAndWriteName()

void race_checkAndWriteName ( entity player)

Definition at line 134 of file race.qc.

135{
136 if(CS_CVAR(player).cvar_cl_allow_uidtracking == 1 && CS_CVAR(player).cvar_cl_allow_uid2name == 1)
137 {
138 if (!player.stored_netname)
139 player.stored_netname = strzone(uid2name(player.crypto_idfp));
140 if(player.stored_netname != player.netname)
141 {
142 db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname);
143 strcpy(player.stored_netname, player.netname);
144 }
145 }
146}
ERASEABLE void db_put(int db, string key, string value)
Definition map.qh:101
string strzone(string s)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
string uid2name(string myuid)
Definition race.qc:36
#define CS_CVAR(this)
Definition state.qh:51
#define strcpy(this, s)
Definition string.qh:52
float ServerProgsDB
Definition world.qh:128

References CS_CVAR, db_put(), entity(), ServerProgsDB, strcat(), strcpy, strzone(), and uid2name().

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ race_ClearPlayerRecords()

void race_ClearPlayerRecords ( entity player)

Definition at line 1276 of file race.qc.

1277{
1278 for(int i = 0; i < MAX_CHECKPOINTS; ++i)
1279 {
1280 player.race_checkpoint_record[i] = 0;
1281 player.race_checkpoint_recordspeed[i] = 0;
1282 }
1283}
const float MAX_CHECKPOINTS
Definition race.qc:149

References entity(), and MAX_CHECKPOINTS.

Referenced by ClientCommand_clear_bestcptimes().

◆ race_ClearRecords()

void race_ClearRecords ( )

Definition at line 1285 of file race.qc.

1286{
1287 for(int j = 0; j < MAX_CHECKPOINTS; ++j)
1288 {
1292 }
1293
1294 FOREACH_CLIENT(true, {
1295 float p = it.race_place;
1297 it.race_place = p;
1298 });
1299}
float race_checkpoint_recordspeeds[MAX_CHECKPOINTS]
Definition race.qc:160
void race_PreparePlayer(entity this)
Definition race.qc:1246
float race_checkpoint_records[MAX_CHECKPOINTS]
Definition race.qc:159
string race_checkpoint_recordholders[MAX_CHECKPOINTS]
Definition race.qc:161
#define strfree(this)
Definition string.qh:59
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References FOREACH_CLIENT, MAX_CHECKPOINTS, race_checkpoint_recordholders, race_checkpoint_records, race_checkpoint_recordspeeds, race_PreparePlayer(), and strfree.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ race_GetFractionalLapCount()

float race_GetFractionalLapCount ( entity e)

Definition at line 1365 of file race.qc.

1366{
1367 // interesting metrics (idea by KrimZon) to maybe sort players in the
1368 // scoreboard, immediately updates when overtaking
1369 //
1370 // requires the track to be built so you never get farther away from the
1371 // next checkpoint, though, and current Xonotic race maps are not built that
1372 // way
1373 //
1374 // also, this code is slow and would need optimization (i.e. "next CP"
1375 // links on CP entities)
1376
1377 float l;
1378 l = GameRules_scoring_add(e, RACE_LAPS, 0);
1379 if(CS(e).race_completed)
1380 return l; // not fractional
1381
1382 vector o0, o1;
1383 float bestfraction, fraction;
1384 entity lastcp;
1385 float nextcpindex, lastcpindex;
1386
1387 nextcpindex = max(e.race_checkpoint, 0);
1388 lastcpindex = e.race_respawn_checkpoint;
1389 lastcp = e.race_respawn_spotref;
1390
1391 if(nextcpindex == lastcpindex)
1392 return l; // finish
1393
1394 bestfraction = 1;
1396 {
1397 if(it.race_checkpoint != lastcpindex)
1398 continue;
1399 if(lastcp)
1400 if(it != lastcp)
1401 continue;
1402 o0 = (it.absmin + it.absmax) * 0.5;
1404 {
1405 if(it.race_checkpoint != nextcpindex)
1406 continue;
1407 o1 = (it.absmin + it.absmax) * 0.5;
1408 if(o0 == o1)
1409 continue;
1410 fraction = bound(0.0001, vlen(e.origin - o1) / vlen(o0 - o1), 1);
1411 if(fraction < bestfraction)
1412 bestfraction = fraction;
1413 });
1414 });
1415
1416 // we are at CP "nextcpindex - bestfraction"
1417 // race_timed_checkpoint == 4: then nextcp==4 means 0.9999x, nextcp==0 means 0.0000x
1418 // race_timed_checkpoint == 0: then nextcp==0 means 0.9999x
1419 float c, nc;
1420 nc = race_highest_checkpoint + 1;
1421 c = ((nextcpindex - race_timed_checkpoint + nc + nc - 1) % nc) + 1 - bestfraction;
1422
1423 return l + c / nc;
1424}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IL_EACH(this, cond, body)
float bound(float min, float value, float max)
float vlen(vector v)
float max(float f,...)
vector
Definition self.qh:92
float race_highest_checkpoint
Definition race.qc:169
float race_timed_checkpoint
Definition race.qc:170
IntrusiveList g_racecheckpoints
Definition race.qc:67
#define GameRules_scoring_add(client, fld, value)
Definition sv_rules.qh:85

References bound(), CS(), entity(), g_racecheckpoints, GameRules_scoring_add, IL_EACH, max(), race_completed, race_highest_checkpoint, race_timed_checkpoint, vector, and vlen().

◆ race_ImposePenaltyTime()

void race_ImposePenaltyTime ( entity pl,
float penalty,
string reason )

Definition at line 1301 of file race.qc.

1302{
1304 {
1305 pl.race_penalty_accumulator += penalty;
1306 if(IS_REAL_CLIENT(pl))
1307 {
1308 msg_entity = pl;
1309 WRITESPECTATABLE_MSG_ONE(msg_entity, {
1310 WriteHeader(MSG_ONE, TE_CSQC_RACE);
1312 WriteShort(MSG_ONE, TIME_ENCODE(penalty));
1313 WriteString(MSG_ONE, reason);
1314 });
1315 }
1316 }
1317 else
1318 {
1319 pl.race_penalty = time + penalty;
1320 if(IS_REAL_CLIENT(pl))
1321 {
1322 msg_entity = pl;
1323 WRITESPECTATABLE_MSG_ONE(msg_entity, {
1324 WriteHeader(MSG_ONE, TE_CSQC_RACE);
1326 WriteShort(MSG_ONE, TIME_ENCODE(penalty));
1327 WriteString(MSG_ONE, reason);
1328 });
1329 }
1330 }
1331}
#define TIME_ENCODE(t)
Definition util.qh:100
float time
#define WriteHeader(to, id)
Definition net.qh:221
float MSG_ONE
Definition menudefs.qc:56
void WriteString(string data, float dest, float desto)
void WriteShort(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
const int RACE_NET_PENALTY_RACE
Definition net_linked.qh:17
const int RACE_NET_PENALTY_QUALIFYING
Definition net_linked.qh:18
entity msg_entity
Definition progsdefs.qc:63
int g_race_qualifying
Definition race.qh:13
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

References entity(), g_race_qualifying, IS_REAL_CLIENT, msg_entity, MSG_ONE, RACE_NET_PENALTY_QUALIFYING, RACE_NET_PENALTY_RACE, time, TIME_ENCODE, WriteByte(), WriteHeader, WriteShort(), and WriteString().

Referenced by CheatCommand(), penalty_touch(), and penalty_use().

◆ race_NextCheckpoint()

float race_NextCheckpoint ( float f)

Definition at line 175 of file race.qc.

176{
178 return 0;
179 else
180 return f + 1;
181}

References race_highest_checkpoint.

Referenced by havocbot_role_cts(), havocbot_role_race(), and trigger_race_checkpoint_verify().

◆ race_PreparePlayer()

void race_PreparePlayer ( entity this)

◆ race_PreviousCheckpoint()

float race_PreviousCheckpoint ( float f)

Definition at line 183 of file race.qc.

184{
185 if(f == -1)
186 return 0;
187 else if(f == 0)
189 else
190 return f - 1;
191}

References race_highest_checkpoint.

◆ race_readName()

string race_readName ( string map,
float pos )

Definition at line 129 of file race.qc.

130{
131 return uid2name(db_get(ServerProgsDB, strcat(map, record_type, "crypto_idfp", ftos(pos))));
132}
ERASEABLE string db_get(int db, string key)
Definition map.qh:91
string ftos(float f)
string record_type
Definition world.qh:55

References db_get(), ftos(), record_type, ServerProgsDB, strcat(), and uid2name().

Referenced by getrankings(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), race_SendRanking(), and race_setTime().

◆ race_readTime()

float race_readTime ( string map,
float pos )

◆ race_readUID()

string race_readUID ( string map,
float pos )

Definition at line 74 of file race.qc.

75{
76 return db_get(ServerProgsDB, strcat(map, record_type, "crypto_idfp", ftos(pos)));
77}

References db_get(), ftos(), record_type, ServerProgsDB, and strcat().

Referenced by getladder(), race_deleteTime(), race_setTime(), and race_writeTime().

◆ race_RetractPlayer()

void race_RetractPlayer ( entity this)

Definition at line 1255 of file race.qc.

1256{
1257 if(!g_race && !g_cts)
1258 return;
1260 race_ClearTime(this);
1262}
#define g_race
Definition race.qh:48
#define g_cts
Definition cts.qh:36
float race_checkpoint
Definition racetimer.qh:8

References entity(), g_cts, g_race, race_checkpoint, race_ClearTime(), race_respawn_checkpoint, and race_timed_checkpoint.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ race_send_rankings_cnt()

void race_send_rankings_cnt ( float msg)

Definition at line 286 of file race.qc.

287{
288 WriteHeader(msg, TE_CSQC_RACE);
291 WriteByte(msg, m);
292}
const int RANKINGS_CNT
Definition constants.qh:31
float min(float f,...)
const int RACE_NET_RANKINGS_CNT
Definition net_linked.qh:26
int autocvar_g_cts_send_rankings_cnt
Definition race.qh:10

References autocvar_g_cts_send_rankings_cnt, min(), RACE_NET_RANKINGS_CNT, RANKINGS_CNT, WriteByte(), and WriteHeader.

Referenced by race_SendAll().

◆ race_send_recordtime()

void race_send_recordtime ( float msg)

Definition at line 260 of file race.qc.

261{
262 // send the server best time
263 WriteHeader(msg, TE_CSQC_RACE);
265 WriteInt24_t(msg, race_readTime(GetMapname(), 1));
266}
string GetMapname()
const int RACE_NET_SERVER_RECORD
Definition net_linked.qh:19
float race_readTime(string map, float pos)
Definition race.qc:69

References GetMapname(), RACE_NET_SERVER_RECORD, race_readTime(), WriteByte(), and WriteHeader.

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

◆ race_send_speedaward()

void race_send_speedaward ( float msg)

Definition at line 268 of file race.qc.

269{
270 // send the best speed of the round
271 WriteHeader(msg, TE_CSQC_RACE);
273 WriteInt24_t(msg, floor(speedaward_speed+0.5));
275}
float floor(float f)
const int RACE_NET_SPEED_AWARD
Definition net_linked.qh:20
float speedaward_speed
Definition race.qh:59
string speedaward_holder
Definition race.qh:60

References floor(), RACE_NET_SPEED_AWARD, speedaward_holder, speedaward_speed, WriteByte(), WriteHeader, and WriteString().

Referenced by race_SendAll(), and race_SpeedAwardFrame().

◆ race_send_speedaward_alltimebest()

void race_send_speedaward_alltimebest ( float msg)

Definition at line 277 of file race.qc.

278{
279 // send the best speed
280 WriteHeader(msg, TE_CSQC_RACE);
282 WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
284}
const int RACE_NET_SPEED_AWARD_BEST
Definition net_linked.qh:21
float speedaward_alltimebest
Definition race.qh:63
string speedaward_alltimebest_holder
Definition race.qh:64

References floor(), RACE_NET_SPEED_AWARD_BEST, speedaward_alltimebest, speedaward_alltimebest_holder, WriteByte(), WriteHeader, and WriteString().

Referenced by race_SendAll(), and race_SpeedAwardFrame().

◆ race_SendAll()

void race_SendAll ( entity player,
bool only_rankings )

Definition at line 333 of file race.qc.

334{
335 if(!IS_REAL_CLIENT(player))
336 return;
337
338 msg_entity = player;
339 if (!only_rankings)
340 {
343
347 }
348
351 for (int i = 1; i <= m; ++i)
352 race_SendRanking(i, 0, 0, MSG_ONE);
353}
void race_SendRanking(float pos, float prevpos, float del, float msg)
Definition race.qc:294
void race_send_speedaward_alltimebest(float msg)
Definition race.qc:277
void race_send_speedaward(float msg)
Definition race.qc:268
void race_send_recordtime(float msg)
Definition race.qc:260
void race_send_rankings_cnt(float msg)
Definition race.qc:286

References autocvar_g_cts_send_rankings_cnt, db_get(), entity(), GetMapname(), IS_REAL_CLIENT, min(), msg_entity, MSG_ONE, race_send_rankings_cnt(), race_send_recordtime(), race_send_speedaward(), race_send_speedaward_alltimebest(), race_SendRanking(), RANKINGS_CNT, record_type, ServerProgsDB, speedaward_alltimebest, speedaward_alltimebest_holder, stof(), strcat(), and uid2name().

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ race_SendNextCheckpoint()

void race_SendNextCheckpoint ( entity e,
float spec )

Definition at line 209 of file race.qc.

210{
211 if(!e.race_laptime)
212 return;
213
214 int cp = e.race_checkpoint;
215 float recordtime;
216 float recordspeed;
217 float myrecordtime = e.race_checkpoint_record[cp];
218 float myrecordspeed = e.race_checkpoint_recordspeed[cp];
219 string recordholder;
221 recordtime = myrecordtime;
222 recordspeed = myrecordspeed;
223 recordholder = "";
224 } else {
225 recordtime = race_checkpoint_records[cp];
226 recordspeed = race_checkpoint_recordspeeds[cp];
227 recordholder = race_checkpoint_recordholders[cp];
228
229 if(recordholder == e.netname)
230 recordholder = "";
231 }
232
233 if(!IS_REAL_CLIENT(e))
234 return;
235
236 if(!spec)
237 msg_entity = e;
238 WRITESPECTATABLE_MSG_ONE(msg_entity, {
239 WriteHeader(MSG_ONE, TE_CSQC_RACE);
240 if(spec)
241 {
243 //WriteCoord(MSG_ONE, e.race_laptime - e.race_penalty_accumulator);
244 WriteCoord(MSG_ONE, time - e.race_movetime - e.race_penalty_accumulator);
245 }
246 else
248 WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player will be at next
249 WriteInt24_t(MSG_ONE, recordtime);
250 if(!spec)
251 WriteInt24_t(MSG_ONE, myrecordtime);
252 WriteString(MSG_ONE, recordholder);
253 // All speeds networked as floats to have decimal precision
254 WriteFloat(MSG_ONE, recordspeed);
255 if(!spec)
256 WriteFloat(MSG_ONE, myrecordspeed);
257 });
258}
void WriteCoord(float data, float dest, float desto)
const int RACE_NET_CHECKPOINT_NEXT_QUALIFYING
Definition net_linked.qh:13
const int RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING
Definition net_linked.qh:16
float race_CheckpointNetworkID(float f)
Definition race.qc:197
bool autocvar_g_race_cptimes_onlyself
Definition race.qh:11

References autocvar_g_race_cptimes_onlyself, entity(), IS_REAL_CLIENT, msg_entity, MSG_ONE, race_checkpoint_recordholders, race_checkpoint_records, race_checkpoint_recordspeeds, race_CheckpointNetworkID(), RACE_NET_CHECKPOINT_NEXT_QUALIFYING, RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING, time, WriteByte(), WriteCoord(), WriteHeader, and WriteString().

Referenced by SetSpectatee_status().

◆ race_SendRanking()

void race_SendRanking ( float pos,
float prevpos,
float del,
float msg )

Definition at line 294 of file race.qc.

295{
296 WriteHeader(msg, TE_CSQC_RACE);
298 WriteShort(msg, pos);
299 WriteShort(msg, prevpos);
300 WriteShort(msg, del);
302 WriteInt24_t(msg, race_readTime(GetMapname(), pos));
303}
const int RACE_NET_SERVER_RANKINGS
Definition net_linked.qh:22
string race_readName(string map, float pos)
Definition race.qc:129

References GetMapname(), RACE_NET_SERVER_RANKINGS, race_readName(), race_readTime(), WriteByte(), WriteHeader, WriteShort(), and WriteString().

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

◆ race_setTime()

void race_setTime ( string map,
float t,
string myuid,
string mynetname,
entity e,
bool showmessage )

Definition at line 374 of file race.qc.

375{
376 // netname only used TEMPORARILY for printing
377 int newpos = race_readPos(map, t);
378
379 int player_prevpos = 0;
380 for(int i = 1; i <= RANKINGS_CNT; ++i)
381 {
382 if(race_readUID(map, i) == myuid)
383 player_prevpos = i;
384 }
385
386 float oldrec;
387 string oldrec_holder;
388 if (player_prevpos && (player_prevpos < newpos || !newpos))
389 {
390 oldrec = race_readTime(GetMapname(), player_prevpos);
391 race_SendStatus(0, e); // "fail"
392 if(showmessage)
393 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_FAIL_RANKED, mynetname, player_prevpos, t, oldrec);
394 return;
395 }
396 else if (!newpos)
397 {
398 // no ranking, time worse than the worst ranked
400 race_SendStatus(0, e); // "fail"
401 if(showmessage)
402 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_FAIL_UNRANKED, mynetname, RANKINGS_CNT, t, oldrec);
403 return;
404 }
405
406 // if we didn't hit a return yet, we have a new record!
407
408 // if the player does not have a UID we can unfortunately not store the record, as the rankings system relies on UIDs
409 if(myuid == "")
410 {
411 if(showmessage)
412 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_NEW_MISSING_UID, mynetname, t);
413 return;
414 }
415
416 if(CS_CVAR(e).cvar_cl_allow_uidtracking != 1 || CS_CVAR(e).cvar_cl_allow_uid2name != 1
417 || uid2name(myuid) == "^1Unregistered Player")
418 {
419 if(showmessage)
420 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_NEW_MISSING_NAME, mynetname, t);
421 return;
422 }
423
424 oldrec = race_readTime(GetMapname(), newpos);
425 oldrec_holder = race_readName(GetMapname(), newpos);
426
427 // store new ranking
428 race_writeTime(GetMapname(), t, myuid);
429
430 if (newpos == 1 && showmessage)
431 {
434 }
435
436 race_SendRanking(newpos, player_prevpos, 0, MSG_ALL);
438
439 if(newpos == player_prevpos)
440 {
441 if(showmessage)
442 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_NEW_IMPROVED, mynetname, newpos, t, oldrec);
443 if(newpos == 1) { race_SendStatus(3, e); } // "new server record"
444 else { race_SendStatus(1, e); } // "new time"
445 }
446 else if(oldrec == 0)
447 {
448 if(showmessage)
449 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_NEW_SET, mynetname, newpos, t);
450 if(newpos == 1) { race_SendStatus(3, e); } // "new server record"
451 else { race_SendStatus(2, e); } // "new rank"
452 }
453 else
454 {
455 if(showmessage)
456 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_NEW_BROKEN, mynetname, oldrec_holder, newpos, t, oldrec);
457 if(newpos == 1) { race_SendStatus(3, e); } // "new server record"
458 else { race_SendStatus(2, e); } // "new rank"
459 }
460}
string rankings_reply
Definition util.qh:161
#define TIME_DECODE(n)
Definition util.qh:101
string getrankings()
Definition getreplies.qc:46
float MSG_ALL
Definition menudefs.qc:57
void write_recordmarker(entity pl, float tstart, float dt)
Definition race.qc:57
float race_readPos(string map, float t)
Definition race.qc:79
void race_SendStatus(float id, entity e)
Definition race.qc:355
string race_readUID(string map, float pos)
Definition race.qc:74
void race_writeTime(string map, float t, string myuid)
Definition race.qc:91

References CS_CVAR, entity(), GetMapname(), getrankings(), MSG_ALL, NULL, race_readName(), race_readPos(), race_readTime(), race_readUID(), race_send_recordtime(), race_SendRanking(), race_SendStatus(), race_writeTime(), RANKINGS_CNT, rankings_reply, Send_Notification(), strcpy, time, TIME_DECODE, uid2name(), and write_recordmarker().

Referenced by ctf_CaptureRecord(), and race_SendTime().

◆ race_SpeedAwardFrame()

void race_SpeedAwardFrame ( entity player)

Definition at line 305 of file race.qc.

306{
307 if (IS_OBSERVER(player))
308 return;
309
310 if(vdist(player.velocity - player.velocity_z * '0 0 1', >, speedaward_speed))
311 {
312 speedaward_speed = vlen(player.velocity - player.velocity_z * '0 0 1');
313 speedaward_holder = player.netname;
314 speedaward_uid = player.crypto_idfp;
316 }
318 {
322 {
329 }
330 }
331}
bool intermission_running
float speedaward_lastupdate
Definition race.qh:16
string speedaward_alltimebest_uid
Definition race.qh:65
string speedaward_uid
Definition race.qh:61
float speedaward_lastsent
Definition race.qh:15
#define IS_OBSERVER(v)
Definition utils.qh:11
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8

References db_put(), entity(), ftos(), GetMapname(), intermission_running, IS_OBSERVER, MSG_ALL, race_send_speedaward(), race_send_speedaward_alltimebest(), record_type, ServerProgsDB, speedaward_alltimebest, speedaward_alltimebest_holder, speedaward_alltimebest_uid, speedaward_holder, speedaward_lastsent, speedaward_lastupdate, speedaward_speed, speedaward_uid, strcat(), time, vdist, and vlen().

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ race_StartCompleting()

void race_StartCompleting ( )

Definition at line 1240 of file race.qc.

1241{
1242 race_completing = 1;
1244}
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
void race_AbandonRaceCheck(entity p)
Definition race.qc:1229

References FOREACH_CLIENT, IS_DEAD, IS_PLAYER, race_AbandonRaceCheck(), and race_completing.

Referenced by InitiateSuddenDeath(), and race_SendTime().

◆ spawnfunc()

spawnfunc ( target_checkpoint )

Definition at line 1219 of file race.qc.

1220{
1221 // xonotic defrag entity
1223}
void target_checkpoint_setup(entity this)
Definition race.qc:1168

References target_checkpoint_setup().

◆ uid2name()

string uid2name ( string myuid)

Definition at line 36 of file race.qc.

37{
38 string s = db_get(ServerProgsDB, strcat("/uid2name/", myuid));
39
40 // FIXME remove this later after 0.6 release
41 // convert old style broken records to correct style
42 if(s == "")
43 {
44 s = db_get(ServerProgsDB, strcat("uid2name", myuid));
45 if(s != "")
46 {
47 db_put(ServerProgsDB, strcat("/uid2name/", myuid), s);
48 db_remove(ServerProgsDB, strcat("uid2name", myuid));
49 }
50 }
51
52 if(s == "")
53 s = "^1Unregistered Player";
54 return s;
55}
#define db_remove(db, key)
Definition map.qh:98

References db_get(), db_put(), db_remove, ServerProgsDB, and strcat().

Referenced by getladder(), race_checkAndWriteName(), race_readName(), race_SendAll(), and race_setTime().

◆ write_recordmarker()

void write_recordmarker ( entity pl,
float tstart,
float dt )

Definition at line 57 of file race.qc.

58{
59 GameLogEcho(strcat(":recordset:", ftos(pl.playerid), ":", ftos(dt)));
60 // also write a marker into demo files for demotc-race-record-extractor to find
61 stuffcmd(pl,
62 sprintf("//%s RECORD SET %s %f %f\n", strconv(2, 0, 0, GetGametype()),
63 TIME_ENCODED_TOSTRING(TIME_ENCODE(dt), false), tstart, dt));
64}
#define TIME_ENCODED_TOSTRING(n, compact)
Definition util.qh:96
void GameLogEcho(string s)
Definition gamelog.qc:15
string GetGametype()
#define stuffcmd(cl,...)
Definition progsdefs.qh:23

References entity(), ftos(), GameLogEcho(), GetGametype(), strcat(), stuffcmd, TIME_ENCODE, and TIME_ENCODED_TOSTRING.

Referenced by ctf_CaptureRecord(), and race_setTime().

Variable Documentation

◆ autocvar_g_allow_checkpoints

bool autocvar_g_allow_checkpoints

◆ autocvar_g_cts_send_rankings_cnt

int autocvar_g_cts_send_rankings_cnt = 15

Definition at line 10 of file race.qh.

Referenced by race_send_rankings_cnt(), and race_SendAll().

◆ autocvar_g_race_cptimes_onlyself

bool autocvar_g_race_cptimes_onlyself = false

Definition at line 11 of file race.qh.

Referenced by race_SendNextCheckpoint(), and race_SendTime().

◆ g_race_qualifying

◆ race_completed

◆ race_completing

float race_completing

Definition at line 28 of file race.qh.

Referenced by race_AbandonRaceCheck(), race_SendTime(), race_StartCompleting(), and ReadyRestart().

◆ race_fraglimit

float race_fraglimit

Definition at line 21 of file race.qh.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and rc_SetLimits().

◆ race_highest_place_spawn

float race_highest_place_spawn

◆ race_laptime

float race_laptime

Definition at line 27 of file race.qh.

◆ race_leadlimit

float race_leadlimit

Definition at line 22 of file race.qh.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and rc_SetLimits().

◆ race_lowest_place_spawn

float race_lowest_place_spawn

◆ race_movetime

float race_movetime

Definition at line 30 of file race.qh.

◆ race_movetime_count

float race_movetime_count

Definition at line 32 of file race.qh.

◆ race_movetime_frac

float race_movetime_frac

Definition at line 31 of file race.qh.

◆ race_place

float race_place

Definition at line 24 of file race.qh.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), race_PreparePlayer(), and spawnfunc().

◆ race_respawn_checkpoint

float race_respawn_checkpoint

Definition at line 34 of file race.qh.

Referenced by race_PreparePlayer(), and race_RetractPlayer().

◆ race_respawn_spotref

entity race_respawn_spotref

Definition at line 35 of file race.qh.

Referenced by race_PreparePlayer().

◆ race_spawns

float race_spawns

Definition at line 18 of file race.qh.

Referenced by Spawn_Score(), and spawnfunc().

◆ race_started

float race_started

Definition at line 25 of file race.qh.

Referenced by race_PreparePlayer().

◆ race_teams

float race_teams

Definition at line 5 of file race.qh.

Referenced by MUTATOR_HOOKFUNCTION(), race_ScoreRules(), and rc_SetLimits().

◆ race_timelimit

float race_timelimit

Definition at line 23 of file race.qh.

Referenced by MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), and rc_SetLimits().

◆ speedaward_alltimebest

float speedaward_alltimebest

Definition at line 63 of file race.qh.

Referenced by race_send_speedaward_alltimebest(), race_SendAll(), and race_SpeedAwardFrame().

◆ speedaward_alltimebest_holder

string speedaward_alltimebest_holder

Definition at line 64 of file race.qh.

Referenced by race_send_speedaward_alltimebest(), race_SendAll(), and race_SpeedAwardFrame().

◆ speedaward_alltimebest_uid

string speedaward_alltimebest_uid

Definition at line 65 of file race.qh.

Referenced by race_SpeedAwardFrame().

◆ speedaward_holder

string speedaward_holder

Definition at line 60 of file race.qh.

Referenced by race_send_speedaward(), and race_SpeedAwardFrame().

◆ speedaward_lastsent

float speedaward_lastsent

Definition at line 15 of file race.qh.

Referenced by race_SpeedAwardFrame().

◆ speedaward_lastupdate

float speedaward_lastupdate

Definition at line 16 of file race.qh.

Referenced by race_SpeedAwardFrame().

◆ speedaward_speed

float speedaward_speed

Definition at line 59 of file race.qh.

Referenced by race_send_speedaward(), and race_SpeedAwardFrame().

◆ speedaward_uid

string speedaward_uid

Definition at line 61 of file race.qh.

Referenced by race_SpeedAwardFrame().

◆ ST_RACE_LAPS

const float ST_RACE_LAPS = 1

Definition at line 8 of file race.qh.

Referenced by race_ScoreRules().