}
// 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
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);
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
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
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
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));