#include "race.qh"
-#include "cl_client.qh"
+#include "client.qh"
#include "portals.qh"
#include "scores.qh"
#include "spawnpoints.qh"
-#include "bot/waypoints.qh"
-#include "bot/navigation.qh"
+#include "bot/api.qh"
#include "command/getreplies.qh"
#include "../common/deathtypes/all.qh"
#include "../common/notifications/all.qh"
#include "../common/mapinfo.qh"
+#include <common/net_linked.qh>
#include "../common/triggers/subs.qh"
#include "../lib/warpzone/util_server.qh"
#include "../lib/warpzone/common.qh"
}
}
-void checkpoint_touch(entity this)
+void checkpoint_touch(entity this, entity toucher)
{
- EXACTTRIGGER_TOUCH;
- checkpoint_passed(this, other);
+ EXACTTRIGGER_TOUCH(this, toucher);
+ checkpoint_passed(this, toucher);
}
void checkpoint_use(entity this, entity actor, entity trigger)
race_timed_checkpoint = 255;
}
} else {
- for (entity cp = NULL; (cp = find(cp, classname, "trigger_race_checkpoint")); ) {
- if (cp.sprite) {
- if (cp.race_checkpoint == 0) {
- WaypointSprite_UpdateSprites(cp.sprite, WP_RaceStart, WP_Null, WP_Null);
- } else if (cp.race_checkpoint == race_timed_checkpoint) {
- WaypointSprite_UpdateSprites(cp.sprite, WP_RaceFinish, WP_Null, WP_Null);
- }
+ IL_EACH(g_racecheckpoints, it.sprite,
+ {
+ if (it.race_checkpoint == 0) {
+ WaypointSprite_UpdateSprites(it.sprite, WP_RaceStart, WP_Null, WP_Null);
+ } else if (it.race_checkpoint == race_timed_checkpoint) {
+ WaypointSprite_UpdateSprites(it.sprite, WP_RaceFinish, WP_Null, WP_Null);
}
- }
+ });
}
}
spawnfunc(trigger_race_checkpoint)
{
vector o;
- if(!g_race && !g_cts) { remove(this); return; }
+ if(!g_race && !g_cts) { delete(this); return; }
EXACTTRIGGER_INIT;
this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
this.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
+ IL_PUSH(g_racecheckpoints, this);
+
InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
}
spawnfunc(target_checkpoint) // defrag entity
{
vector o;
- if(!g_race && !g_cts) { remove(this); return; }
+ if(!g_race && !g_cts) { delete(this); return; }
defrag_ents = 1;
EXACTTRIGGER_INIT;
spawnfunc(info_player_race)
{
- if(!g_race && !g_cts) { remove(this); return; }
+ if(!g_race && !g_cts) { delete(this); return; }
++race_spawns;
spawnfunc_info_player_deathmatch(this);
}
}
-void penalty_touch(entity this)
+void penalty_touch(entity this, entity toucher)
{
- EXACTTRIGGER_TOUCH;
- if(other.race_lastpenalty != this)
+ EXACTTRIGGER_TOUCH(this, toucher);
+ if(toucher.race_lastpenalty != this)
{
- other.race_lastpenalty = this;
- race_ImposePenaltyTime(other, this.race_penalty, this.race_penalty_reason);
+ toucher.race_lastpenalty = this;
+ race_ImposePenaltyTime(toucher, this.race_penalty, this.race_penalty_reason);
}
}
vector o0, o1;
float bestfraction, fraction;
- entity lastcp, cp0, cp1;
+ entity lastcp;
float nextcpindex, lastcpindex;
nextcpindex = max(e.race_checkpoint, 0);
return l; // finish
bestfraction = 1;
- for(cp0 = NULL; (cp0 = find(cp0, classname, "trigger_race_checkpoint")); )
+ IL_EACH(g_racecheckpoints, true,
{
- if(cp0.race_checkpoint != lastcpindex)
+ if(it.race_checkpoint != lastcpindex)
continue;
if(lastcp)
- if(cp0 != lastcp)
+ if(it != lastcp)
continue;
- o0 = (cp0.absmin + cp0.absmax) * 0.5;
- for(cp1 = NULL; (cp1 = find(cp1, classname, "trigger_race_checkpoint")); )
+ o0 = (it.absmin + it.absmax) * 0.5;
+ IL_EACH(g_racecheckpoints, true,
{
- if(cp1.race_checkpoint != nextcpindex)
+ if(it.race_checkpoint != nextcpindex)
continue;
- o1 = (cp1.absmin + cp1.absmax) * 0.5;
+ o1 = (it.absmin + it.absmax) * 0.5;
if(o0 == o1)
continue;
fraction = bound(0.0001, vlen(e.origin - o1) / vlen(o0 - o1), 1);
if(fraction < bestfraction)
bestfraction = fraction;
- }
- }
+ });
+ });
// we are at CP "nextcpindex - bestfraction"
// race_timed_checkpoint == 4: then nextcp==4 means 0.9999x, nextcp==0 means 0.0000x