X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Frace.qc;h=8fc38aa2c5e028ed1d44f8cd5f3b7128454ddda9;hb=7a6a774eae9edb72477fd83a1145f381e2982243;hp=c4e94cd13ddca230dd60a5bd766c522799c104d8;hpb=8e0690ba978a6a0c7287bc3cfa2873a05b15fc5f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index c4e94cd13..8fc38aa2c 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -1,11 +1,10 @@ #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" @@ -698,10 +697,10 @@ void checkpoint_passed(entity this, entity player) } } -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) @@ -833,15 +832,14 @@ void trigger_race_checkpoint_verify(entity this) 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); } - } + }); } } @@ -905,7 +903,7 @@ vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spawnfunc(trigger_race_checkpoint) { vector o; - if(!g_race && !g_cts) { remove(this); return; } + if(!g_race && !g_cts) { delete(this); return; } EXACTTRIGGER_INIT; @@ -947,13 +945,15 @@ spawnfunc(trigger_race_checkpoint) 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; @@ -1031,7 +1031,7 @@ void race_RetractPlayer(entity this) 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); @@ -1092,13 +1092,13 @@ void race_ImposePenaltyTime(entity pl, float penalty, string reason) } } -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); } } @@ -1143,7 +1143,7 @@ float race_GetFractionalLapCount(entity e) vector o0, o1; float bestfraction, fraction; - entity lastcp, cp0, cp1; + entity lastcp; float nextcpindex, lastcpindex; nextcpindex = max(e.race_checkpoint, 0); @@ -1154,26 +1154,26 @@ float race_GetFractionalLapCount(entity e) 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