From: TimePath Date: Thu, 24 Dec 2015 06:46:58 +0000 (+1100) Subject: WRITESPECTATABLE_MSG_ONE: cleanup X-Git-Tag: xonotic-v0.8.2~1397 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7e4acb81f8d607198c345461d94b68c55e4be362;p=xonotic%2Fxonotic-data.pk3dir.git WRITESPECTATABLE_MSG_ONE: cleanup --- diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index d870ef1f9..2473d672c 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -346,20 +346,17 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); } } // allow writing to also pass through to spectators (like so spectators see the same centerprints as players for example) - #define WRITESPECTATABLE_MSG_ONE_VARNAME(varname, statement) \ - entity varname; varname = msg_entity; \ - FOR_EACH_REALCLIENT(msg_entity) \ - if (msg_entity == varname || (msg_entity.classname == STR_SPECTATOR && msg_entity.enemy == varname)) \ - statement msg_entity = varname - #define WRITESPECTATABLE_MSG_ONE(statement) \ - MACRO_BEGIN \ - { \ - WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement); \ - } MACRO_END - #define WRITESPECTATABLE(msg, statement) \ - if (msg == MSG_ONE) WRITESPECTATABLE_MSG_ONE(statement); \ - else \ - statement float WRITESPECTATABLE_workaround = 0 + #define WRITESPECTATABLE_MSG_ONE(statement) MACRO_BEGIN { \ + entity dst = msg_entity; \ + FOREACH_CLIENT(IS_REAL_CLIENT(it), { \ + if (it == dst || (it.classname == STR_SPECTATOR && it.enemy == dst)) \ + { \ + msg_entity = it; \ + LAMBDA(statement); \ + } \ + }); \ + msg_entity = dst; \ + } MACRO_END #endif #endif diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index dbc59457b..42d7e5dd6 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -236,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({ WriteHeader(msg, TE_CSQC_RACE); WriteByte(msg, RACE_NET_SERVER_STATUS); WriteShort(msg, id); @@ -444,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({ 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 @@ -472,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({ 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 @@ -498,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({ 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 @@ -1102,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({ WriteHeader(MSG_ONE, TE_CSQC_RACE); WriteByte(MSG_ONE, RACE_NET_PENALTY_RACE); WriteShort(MSG_ONE, TIME_ENCODE(penalty));