X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Frace.qc;h=dd3a11cc0929cca2c1760004755d4728c780e128;hb=2aff8d6ec1d0c014f3ffecfffd51be23585b9587;hp=bc9fafc4c293f821ef6e3f36e951e123946cf39b;hpb=db7c0f258711d75763876f234a08ad8e5bb5a6c5;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index bc9fafc4c..dd3a11cc0 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -8,13 +8,20 @@ #include "bot/navigation.qh" #include "command/getreplies.qh" #include "../common/deathtypes/all.qh" -#include "../common/notifications.qh" +#include "../common/notifications/all.qh" #include "../common/mapinfo.qh" #include "../common/triggers/subs.qh" #include "../lib/warpzone/util_server.qh" #include "../lib/warpzone/common.qh" #include "../common/mutators/mutator/waypoints/waypointsprites.qh" +void race_InitSpectator() +{ + if(g_race_qualifying) + if(msg_entity.enemy.race_laptime) + race_SendNextCheckpoint(msg_entity.enemy, 1); +} + void W_Porto_Fail(float failhard); float race_readTime(string map, float pos) @@ -164,7 +171,7 @@ void race_SendNextCheckpoint(entity e, float spec) // qualifying only if(!spec) msg_entity = e; - WRITESPECTATABLE_MSG_ONE({ + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); if(spec) { @@ -229,7 +236,7 @@ void race_SendStatus(float id, entity e) else msg = MSG_ALL; msg_entity = e; - WRITESPECTATABLE_MSG_ONE_VARNAME(dummy3, { + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(msg, TE_CSQC_RACE); WriteByte(msg, RACE_NET_SERVER_STATUS); WriteShort(msg, id); @@ -350,7 +357,6 @@ void race_deleteTime(string map, float pos) void race_SendTime(entity e, float cp, float t, float tvalid) { float snew, l; - entity p; if(g_race_qualifying) t += e.race_penalty_accumulator; @@ -420,9 +426,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) race_checkpoint_recordholders[cp] = strzone(e.netname); if(g_race_qualifying) { - FOR_EACH_REALPLAYER(p) - if(p.race_checkpoint == cp) - race_SendNextCheckpoint(p, 0); + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.race_checkpoint == cp, LAMBDA(race_SendNextCheckpoint(it, 0))); } } } @@ -440,7 +444,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) msg_entity = e; if(g_race_qualifying) { - WRITESPECTATABLE_MSG_ONE_VARNAME(dummy1, { + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_QUALIFYING); WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at @@ -468,7 +472,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) if(IS_REAL_CLIENT(e)) { msg_entity = e; - WRITESPECTATABLE_MSG_ONE_VARNAME(dummy2, { + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_RACE); WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at @@ -494,7 +498,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) if(IS_REAL_CLIENT(oth)) { msg_entity = oth; - WRITESPECTATABLE_MSG_ONE_VARNAME(dummy3, { + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT); WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at @@ -527,7 +531,7 @@ void race_ClearTime(entity e) return; msg_entity = e; - WRITESPECTATABLE_MSG_ONE({ + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_CLEAR); // next }); @@ -661,7 +665,7 @@ void checkpoint_passed() other.race_checkpoint = race_NextCheckpoint(self.race_checkpoint); other.race_started = 1; - race_SendTime(other, self.race_checkpoint, other.race_movetime, !!other.race_laptime); + race_SendTime(other, self.race_checkpoint, other.race_movetime, boolean(other.race_laptime)); if(!self.race_checkpoint) // start line { @@ -930,7 +934,7 @@ spawnfunc(trigger_race_checkpoint) self.touch = checkpoint_touch; o = (self.absmin + self.absmax) * 0.5; - tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self); + tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self); waypoint_spawnforitem_force(self, trace_endpos); self.nearestwaypointtimeout = time + 1000000000; @@ -979,7 +983,7 @@ spawnfunc(target_checkpoint) // defrag entity self.touch = checkpoint_touch; o = (self.absmin + self.absmax) * 0.5; - tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self); + tracebox(o, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), o - '0 0 1' * (o.z - self.absmin.z), MOVE_NORMAL, self); waypoint_spawnforitem_force(self, trace_endpos); self.nearestwaypointtimeout = time + 1000000000; @@ -1023,11 +1027,8 @@ void race_AbandonRaceCheck(entity p) void race_StartCompleting() { - entity p; race_completing = 1; - FOR_EACH_PLAYER(p) - if(p.deadflag != DEAD_NO) - race_AbandonRaceCheck(p); + FOREACH_CLIENT(IS_PLAYER(it) && IS_DEAD(it), LAMBDA(race_AbandonRaceCheck(it))); } void race_PreparePlayer() @@ -1072,13 +1073,11 @@ void race_ClearRecords() race_checkpoint_recordholders[i] = string_null; } - entity e; - FOR_EACH_CLIENT(e) - { - float p = e.race_place; - WITH(entity, self, e, race_PreparePlayer()); - e.race_place = p; - } + FOREACH_CLIENT(true, LAMBDA( + float p = it.race_place; + WITH(entity, self, it, race_PreparePlayer()); + it.race_place = p; + )); } void race_ImposePenaltyTime(entity pl, float penalty, string reason) @@ -1089,7 +1088,7 @@ void race_ImposePenaltyTime(entity pl, float penalty, string reason) if(IS_REAL_CLIENT(pl)) { msg_entity = pl; - WRITESPECTATABLE_MSG_ONE({ + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_PENALTY_QUALIFYING); WriteShort(MSG_ONE, TIME_ENCODE(penalty)); @@ -1103,7 +1102,7 @@ void race_ImposePenaltyTime(entity pl, float penalty, string reason) if(IS_REAL_CLIENT(pl)) { msg_entity = pl; - WRITESPECTATABLE_MSG_ONE_VARNAME(dummy, { + WRITESPECTATABLE_MSG_ONE(msg_entity, { WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_PENALTY_RACE); WriteShort(MSG_ONE, TIME_ENCODE(penalty));