/** * @param[in] team The team looking at the edict (or not) * @param[in] check The edict to check the visibility for * @param[in] visFlags The flags for the vis check * @param[in] playerMask The mask for the players to send the appear/perish events to. If this is @c 0 the events * are not sent - we only update the visflags of the edict * @param[in] ent The edict that was responsible for letting the check edict appear and is looking */ static int G_DoTestVis (const int team, Edict* check, const vischeckflags_t visFlags, playermask_t playerMask, const Edict* ent) { int status = 0; const int vis = G_TestVis(team, check, visFlags); /* visibility has changed ... */ if (vis & VS_CHANGE) { /* swap the vis mask for the given team */ const bool appear = (vis & VS_YES) == VS_YES; if (playerMask == 0) { G_VisFlagsSwap(*check, G_TeamToVisMask(team)); } else { G_AppearPerishEvent(playerMask, appear, *check, ent); } /* ... to visible */ if (vis & VS_YES) { status |= VIS_APPEAR; if (G_VisShouldStop(check)) status |= VIS_STOP; } else { status |= VIS_PERISH; } } else if (vis == 0 && (visFlags & VT_NEW)) { if (G_IsActor(check)) { G_EventActorAdd(playerMask, *check); } } return status; }
/** * @brief This function sends all the actors to the client that are not visible * initially - this is needed because an actor can e.g. produce sounds that are * send over the net. And the client can only handle them if he knows the * @c le_t (local entity) already * @note Call this for the first @c G_CheckVis call for every new * actor or player * @sa G_CheckVis * @sa CL_ActorAdd */ void G_SendInvisible (const player_t* player) { const int team = player->pers.team; assert(team != TEAM_NO_ACTIVE); if (level.num_alive[team]) { edict_t* ent = NULL; /* check visibility */ while ((ent = G_EdictsGetNextActor(ent))) { if (ent->team != team) { /* not visible for this team - so add the le only */ if (!G_IsVisibleForTeam(ent, team)) { G_EventActorAdd(G_PlayerToPM(player), ent); } } } } }