From de295c2008095603d2d39b1bf1169370d60143b2 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 17 Jan 2017 16:02:11 +1000 Subject: [PATCH] Show the race checkpoint marker on the triggers, instead of the target entity (makes guessing where the real ending is a whole lot easier) --- qcsrc/server/race.qc | 49 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index a3cbc685f..9cdfb7bcf 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -15,6 +15,9 @@ #include "../lib/warpzone/common.qh" #include "../common/mutators/mutator/waypoints/waypointsprites.qh" +IntrusiveList g_race_targets; +STATIC_INIT(g_race_targets) { g_race_targets = IL_NEW(); } + void race_InitSpectator() { if(g_race_qualifying) @@ -800,19 +803,36 @@ void trigger_race_checkpoint_verify(entity this) g_race_qualifying = qual; + IL_EACH(g_race_targets, true, + { + entity cpt = it; + FOREACH_ENTITY_STRING(target, cpt.targetname, + { + vector org = (this.absmin + this.absmax) * 0.5; + if(cpt.race_checkpoint == 0) + WaypointSprite_SpawnFixed(WP_RaceStart, org, it, sprite, RADARICON_NONE); + else + WaypointSprite_SpawnFixed(WP_RaceCheckpoint, org, it, sprite, RADARICON_NONE); + + it.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player; + }); + }); + if (race_timed_checkpoint) { if (defrag_ents) { - for (entity cp = NULL; (cp = find(cp, classname, "target_startTimer"));) { - WaypointSprite_UpdateSprites(cp.sprite, WP_RaceStart, WP_Null, WP_Null); - } - for (entity cp = NULL; (cp = find(cp, classname, "target_stopTimer"));) { - WaypointSprite_UpdateSprites(cp.sprite, WP_RaceFinish, WP_Null, WP_Null); - } - for (entity cp = NULL; (cp = find(cp, classname, "target_checkpoint"));) { - if (cp.race_checkpoint == -2) { // something's wrong with the defrag cp file or it has not been written yet, set defragcpexists to -1 so that it will be rewritten when someone finishes - defragcpexists = -1; - } - } + IL_EACH(g_race_targets, true, + { + entity cpt = it; + if(it.classname == "target_startTimer" || it.classname == "target_stopTimer") { + FOREACH_ENTITY_STRING(target, cpt.targetname, { + WaypointSprite_UpdateSprites(it.sprite, ((cpt.classname == "target_startTimer") ? WP_RaceStart : WP_RaceFinish), WP_Null, WP_Null); + }); + } + if(it.classname == "target_checkpoint") { + if(it.race_checkpoint == -2) + defragcpexists = -1; // something's wrong with the defrag cp file or it has not been written yet, set defragcpexists to -1 so that it will be rewritten when someone finishes + } + }); if (defragcpexists != -1) { float largest_cp_id = 0; for (entity cp = NULL; (cp = find(cp, classname, "target_checkpoint"));) { @@ -991,12 +1011,7 @@ spawnfunc(target_checkpoint) // defrag entity race_timed_checkpoint = 1; - if(this.race_checkpoint == 0) - WaypointSprite_SpawnFixed(WP_RaceStart, org, this, sprite, RADARICON_NONE); - else - WaypointSprite_SpawnFixed(WP_RaceCheckpoint, org, this, sprite, RADARICON_NONE); - - this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player; + IL_PUSH(g_race_targets, this); InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET); } -- 2.39.2