53 s =
"^1Unregistered Player";
62 sprintf(
"//%s RECORD SET %s %f %f\n", strconv(2, 0, 0,
GetGametype()),
84 if(!mytime || mytime > t)
105 for (i = prevpos; i > newpos; --i)
136 if(
CS_CVAR(player).cvar_cl_allow_uidtracking == 1 &&
CS_CVAR(player).cvar_cl_allow_uid2name == 1)
138 if (!player.stored_netname)
140 if(player.stored_netname != player.netname)
143 strcpy(player.stored_netname, player.netname);
214 int cp = e.race_checkpoint;
217 float myrecordtime = e.race_checkpoint_record[cp];
218 float myrecordspeed = e.race_checkpoint_recordspeed[cp];
221 recordtime = myrecordtime;
222 recordspeed = myrecordspeed;
229 if(recordholder == e.netname)
249 WriteInt24_t(
MSG_ONE, recordtime);
251 WriteInt24_t(
MSG_ONE, myrecordtime);
254 WriteFloat(
MSG_ONE, recordspeed);
256 WriteFloat(
MSG_ONE, myrecordspeed);
351 for (
int i = 1; i <= m; ++i)
379 int player_prevpos = 0;
387 string oldrec_holder;
388 if (player_prevpos && (player_prevpos < newpos || !newpos))
393 Send_Notification(NOTIF_ALL,
NULL, MSG_INFO, INFO_RACE_FAIL_RANKED, mynetname, player_prevpos, t, oldrec);
416 if(
CS_CVAR(e).cvar_cl_allow_uidtracking != 1 ||
CS_CVAR(e).cvar_cl_allow_uid2name != 1
417 ||
uid2name(myuid) ==
"^1Unregistered Player")
430 if (newpos == 1 && showmessage)
439 if(newpos == player_prevpos)
456 Send_Notification(NOTIF_ALL,
NULL, MSG_INFO, INFO_RACE_NEW_BROKEN, mynetname, oldrec_holder, newpos, t, oldrec);
466 string therank =
ftos(i);
489 t += e.race_penalty_accumulator;
513 CS(e).race_completed = 1;
517 e.bot_attack =
false;
527 float recordtimespeed;
535 recordtime = e.race_checkpoint_record[cp];
536 recordtimespeed = e.race_checkpoint_recordspeed[cp];
546 if(recordholder == e.netname)
558 if(t < recordtime || recordtime == 0)
584 if(it == e || (
IS_SPEC(it) && it.enemy == e))
591 WriteInt24_t(
MSG_ONE, recordtime);
592 WriteInt24_t(
MSG_ONE, ((tvalid) ? it.race_checkpoint_record[cp] : 0));
596 WriteFloat(
MSG_ONE, recordtimespeed);
597 WriteFloat(
MSG_ONE, ((tvalid) ? it.race_checkpoint_recordspeed[cp] : 0));
605 float myrecordtime = e.race_checkpoint_record[cp];
607 if(t < myrecordtime || myrecordtime == 0)
609 e.race_checkpoint_record[cp] = t;
610 e.race_checkpoint_recordspeed[cp] =
vlen(
vec2(e.velocity));
616 float mylaps, lother, othtime;
625 mylaps = lother = othtime = 0;
679 e.race_checkpoint = 0;
681 e.race_movetime = e.race_movetime_frac = e.race_movetime_count = 0;
682 e.race_penalty_accumulator = 0;
683 e.race_lastpenalty =
NULL;
698 player = player.owner;
703 if(player.classname ==
"porto")
732 player.porto_forbidden = 2;
740 if(it.race_checkpoint >= 0)
741 this.race_checkpoint = it.race_checkpoint;
747 int cp_amount = 0, largest_cp_id = 0;
751 if(it.race_checkpoint > largest_cp_id)
755 IL_EACH(g_race_targets, it.classname ==
"target_checkpoint",
757 if(it.race_checkpoint == -2)
762 largest_cp_id = it.race_checkpoint;
763 IL_EACH(g_race_targets, it.classname ==
"target_stopTimer",
765 it.race_checkpoint = largest_cp_id + 1;
767 race_highest_checkpoint = largest_cp_id + 1;
768 race_timed_checkpoint = largest_cp_id + 1;
776 it.race_checkpoint = 1;
783 if((player.race_checkpoint == -1 &&
this.race_checkpoint == 0) || (player.race_checkpoint == this.
race_checkpoint))
787 if(player.race_lastpenalty !=
this)
789 player.race_lastpenalty =
this;
794 if(player.race_penalty)
808 if(player.race_respawn_checkpoint !=
this.race_checkpoint || !player.race_started)
809 player.race_respawn_spotref =
this;
812 player.race_started = 1;
818 player.race_laptime =
time;
819 player.race_movetime = player.race_movetime_frac = player.race_movetime_count = 0;
820 player.race_penalty_accumulator = 0;
821 player.race_lastpenalty =
NULL;
835 fputs(fh, strcat(it.targetname,
" ", ftos(it.race_checkpoint),
"\n"));
848 Damage (player,
this,
this, 10000, DEATH_HURTTRIGGER.m_id,
DMG_NOWEP, player.origin,
'0 0 0');
860 if(trigger.classname ==
"info_player_deathmatch")
872 if(view.race_checkpoint == -1 || own.race_checkpoint == -2)
874 else if(view.race_checkpoint == own.race_checkpoint)
887 if (recursionlevel > 400)
889 LOG_WARNF(
"df cp wp loop: ^4\"target\" ^3\"%s\"^7, ^4\"targetname\" ^3\"%s\"^7",
891 targeted.targetname);
894 if (recursionlevel > 420)
896 LOG_WARNF(
"Aborted creating defrag checkpoint waypointsprites for ^2%s^7 due to a loop",
897 checkpoint.classname);
901 entity s = WP_RaceCheckpoint;
902 if (checkpoint.classname ==
"target_startTimer")
904 else if (checkpoint.classname ==
"target_stopTimer")
907 for (
entity t = findchain(
target, targeted.targetname); t; t = t.chain)
912 t.sprite.realowner = checkpoint;
916 if (t.targetname && t != checkpoint)
923 static bool have_verified;
924 if (have_verified)
return;
925 have_verified =
true;
929 int pl_race_checkpoint = 0;
930 int pl_race_place = 0;
940 error(
strcat(
"Checkpoint ",
ftos(i),
" misses a spawnpoint with race_place==",
ftos(pl_race_place),
" (used for respawning in race) - bailing out"));
948 error(
strcat(
"Checkpoint ",
ftos(i),
" misses a spawnpoint with race_place==",
ftos(pl_race_place),
" (used for qualifying) - bailing out"));
956 error(
strcat(
"Checkpoint ",
ftos(i),
" misses a spawnpoint with race_place==",
ftos(pl_race_place),
" (used for initially spawning in race) - bailing out"));
967 error(
strcat(
"Checkpoint 0 misses a spawnpoint with race_place==",
ftos(pl_race_place),
" (used for qualifying) - bailing out"));
977 bool broken_defragcp =
false;
982 while ((l =
fgets(fh))) {
985 broken_defragcp =
true;
989 if (
argv(0) == cp.targetname) {
990 if(cp.race_checkpoint != -2 && cp.race_checkpoint !=
stof(
argv(1))) {
991 broken_defragcp =
true;
997 if(broken_defragcp)
break;
1000 if(broken_defragcp) {
1005 cp.race_checkpoint = -2;
1015 IL_EACH(
g_race_targets, it.classname ==
"target_checkpoint" || it.classname ==
"target_startTimer" || it.classname ==
"target_stopTimer",
1017 defrag_waypointsprites(it, it, 0);
1019 if(it.classname ==
"target_checkpoint") {
1020 if(it.race_checkpoint == -2)
1021 defragcpexists = -1;
1025 float largest_cp_id = 0;
1027 if (cp.race_checkpoint > largest_cp_id) {
1028 largest_cp_id = cp.race_checkpoint;
1032 cp.race_checkpoint = largest_cp_id + 1;
1038 cp.race_checkpoint = 255;
1046 if (it.race_checkpoint == 0) {
1047 WaypointSprite_UpdateSprites(it.sprite, WP_RaceStart, WP_Null, WP_Null);
1049 WaypointSprite_UpdateSprites(it.sprite, WP_RaceFinish, WP_Null, WP_Null);
1058 if (targ.classname ==
"target_checkpoint" || targ.classname ==
"target_startTimer" || targ.classname ==
"target_stopTimer") {
1096 if(
this == player.race_respawn_spotref || spot == player.race_respawn_spotref)
1100 int pl = player.race_place;
1103 if(pl == 0 && !player.race_started)
1105 if(spot.race_place != pl)
1129 this.
message =
"went backwards";
1131 this.
message2 =
"was pushed backwards by";
1195 this.
message =
"went backwards";
1197 this.
message2 =
"was pushed backwards by";
1201 if(this.
classname ==
"target_startTimer")
1233 CS(p).race_completed = 1;
1268 spawnfunc_info_player_deathmatch(
this);
1280 player.race_checkpoint_record[i] = 0;
1281 player.race_checkpoint_recordspeed[i] = 0;
1295 float p = it.race_place;
1305 pl.race_penalty_accumulator += penalty;
1319 pl.race_penalty =
time + penalty;
1336 if(
toucher.race_lastpenalty !=
this)
1338 toucher.race_lastpenalty =
this;
1383 float bestfraction, fraction;
1385 float nextcpindex, lastcpindex;
1387 nextcpindex =
max(e.race_checkpoint, 0);
1388 lastcpindex = e.race_respawn_checkpoint;
1389 lastcp = e.race_respawn_spotref;
1391 if(nextcpindex == lastcpindex)
1397 if(it.race_checkpoint != lastcpindex)
1402 o0 = (it.absmin + it.absmax) * 0.5;
1405 if(it.race_checkpoint != nextcpindex)
1407 o1 = (it.absmin + it.absmax) * 0.5;
1410 fraction =
bound(0.0001,
vlen(e.origin - o1) /
vlen(o0 - o1), 1);
1411 if(fraction < bestfraction)
1412 bestfraction = fraction;
float nearestwaypointtimeout
IntrusiveList g_bot_targets
void waypoint_spawnforitem_force(entity e, vector org)
#define MUTATOR_CALLHOOK(id,...)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
#define autocvar_fraglimit
#define TIME_ENCODED_TOSTRING(n, compact)
const vector PL_MIN_CONST
const int INITPRIO_FINDTARGET
const vector PL_MAX_CONST
vector trace_plane_normal
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void GameLogEcho(string s)
bool intermission_running
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
void SUB_UseTargets(entity this, entity actor, entity trigger)
#define WriteHeader(to, id)
#define EXACTTRIGGER_TOUCH(e, t)
#define EXACTTRIGGER_INIT
#define db_remove(db, key)
ERASEABLE string db_get(int db, string key)
ERASEABLE void db_put(int db, string key, string value)
const int RACE_NET_CHECKPOINT_HIT_QUALIFYING
const int RACE_NET_SERVER_RECORD
const int RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT
const int RACE_NET_SPEED_AWARD
const int RACE_NET_CHECKPOINT_HIT_RACE
const int RACE_NET_PENALTY_RACE
const int RACE_NET_SERVER_STATUS
const int RACE_NET_PENALTY_QUALIFYING
const int RACE_NET_SPEED_AWARD_BEST
const int RACE_NET_CHECKPOINT_NEXT_QUALIFYING
const int RACE_NET_RANKINGS_CNT
const int RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING
const int RACE_NET_CHECKPOINT_CLEAR
const int RACE_NET_SERVER_RANKINGS
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
void Portal_ClearAll(entity own)
void W_Porto_Fail(entity this, float failhard)
void ClientData_Touch(entity e, bool to_spectators_too)
#define MAKE_INDEPENDENT_PLAYER(e)
float race_checkpoint_record[MAX_CHECKPOINTS]
float race_CheckpointNetworkID(float f)
void race_SendRanking(float pos, float prevpos, float del, float msg)
float race_readTime(string map, float pos)
float race_PreviousCheckpoint(float f)
float race_highest_checkpoint
void checkpoint_passed(entity this, entity player)
void race_SendAll(entity player, bool only_rankings)
float race_checkpoint_recordspeeds[MAX_CHECKPOINTS]
void race_PreparePlayer(entity this)
float race_checkpoint_lastlaps[MAX_CHECKPOINTS]
string race_penalty_reason
void race_SendNextCheckpoint(entity e, float spec)
void write_recordmarker(entity pl, float tstart, float dt)
void race_SpeedAwardFrame(entity player)
float race_checkpoint_recordspeed[MAX_CHECKPOINTS]
const float MAX_CHECKPOINTS
float race_timed_checkpoint
float race_readPos(string map, float t)
void race_SendTime(entity e, float cp, float t, float tvalid)
void race_ClearTime(entity e)
vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spot, vector current)
string race_readName(string map, float pos)
bool race_waypointsprite_visible_for_player(entity this, entity player, entity view)
float race_NextCheckpoint(float f)
void checkpoint_use(entity this, entity actor, entity trigger)
string uid2name(string myuid)
void race_StartCompleting()
float race_GetFractionalLapCount(entity e)
void race_checkAndWriteName(entity player)
IntrusiveList g_racecheckpoints
void race_send_speedaward_alltimebest(float msg)
void race_send_speedaward(float msg)
void race_RetractPlayer(entity this)
IntrusiveList g_race_targets
entity race_checkpoint_lastplayers[MAX_CHECKPOINTS]
void checkpoint_touch(entity this, entity toucher)
float race_checkpoint_records[MAX_CHECKPOINTS]
void race_setTime(string map, float t, string myuid, string mynetname, entity e, bool showmessage)
void race_SendStatus(float id, entity e)
void race_send_recordtime(float msg)
void defrag_waypointsprites(entity targeted, entity checkpoint, int recursionlevel)
string race_checkpoint_recordholders[MAX_CHECKPOINTS]
string race_readUID(string map, float pos)
void race_AbandonRaceCheck(entity p)
void penalty_use(entity this, entity actor, entity trigger)
float race_penalty_accumulator
void race_writeTime(string map, float t, string myuid)
void race_send_rankings_cnt(float msg)
void target_checkpoint_setup(entity this)
void race_ClearPlayerRecords(entity player)
void race_deleteTime(string map, float pos)
void trigger_race_checkpoint_verify(entity this)
float race_checkpoint_lasttimes[MAX_CHECKPOINTS]
void race_ImposePenaltyTime(entity pl, float penalty, string reason)
void penalty_touch(entity this, entity toucher)
bool autocvar_g_allow_checkpoints
bool autocvar_g_race_cptimes_onlyself
float speedaward_alltimebest
float race_lowest_place_spawn
entity race_respawn_spotref
float speedaward_lastupdate
float race_respawn_checkpoint
string speedaward_alltimebest_uid
float race_highest_place_spawn
int autocvar_g_cts_send_rankings_cnt
float speedaward_lastsent
string speedaward_alltimebest_holder
entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck, bool targetcheck)
const int SPAWN_PRIO_RACE_PREVIOUS_SPAWN
spawn_evalfunc_t spawn_evalfunc
ClientState CS(Client this)
if(frag_attacker.flagcarried)
#define GameRules_scoring_add(client, fld, value)
#define GameRules_scoring_add_team(client, fld, value)
#define IS_REAL_CLIENT(v)
#define FOREACH_CLIENT(cond, body)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
entity WaypointSprite_SpawnFixed(entity spr, vector ofs, entity own,.entity ownfield, entity icon)
void InitializeEntity(entity e, void(entity this) func, int order)