示例#1
0
static int G_DoTestVis (const int team, edict_t * check, bool perish, int playerMask, const edict_t *ent)
{
	int status = 0;
	const int visFlags = perish ? VT_PERISH : 0;
	const int vis = G_TestVis(team, check, visFlags);

	/* visibility has changed ... */
	if (vis & VIS_CHANGE) {
		/* swap the vis mask for the given team */
		const bool appear = (vis & VIS_YES) == VIS_YES;
		if (playerMask == 0) {
			G_VisFlagsSwap(check, G_TeamToVisMask(team));
		} else {
			G_AppearPerishEvent(playerMask, appear, check, ent);
		}

		/* ... to visible */
		if (vis & VIS_YES) {
			status |= VIS_APPEAR;
			if (G_VisShouldStop(check))
				status |= VIS_STOP;
		} else
			status |= VIS_PERISH;
	}
	return status;
}
示例#2
0
文件: g_vis.cpp 项目: drone-pl/ufoai
/**
 * @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;
}
示例#3
0
/**
 * @brief Send the appear or perish event to the affected clients
 * @param[in] playerMask These are the affected players or clients
 * In case of e.g. teamplay there can be more than one client affected - thus
 * this is a player mask
 * @param[in] appear Is this event about an appearing actor (or a perishing one)
 * @param[in] check The edict we are talking about (that appears or perishes)
 * @param[in] ent The edict that was responsible for letting the check edict appear
 * or perish. Might be @c NULL.
 * @sa CL_ActorAppear
 */
void G_AppearPerishEvent (playermask_t playerMask, bool appear, edict_t *check, const edict_t *ent)
{
	teammask_t teamMaskDiff;

	/* test for pointless player mask */
	if (!playerMask)
		return;

	teamMaskDiff = G_PMToVis(playerMask);
	G_VisFlagsSwap(check, teamMaskDiff);

	if (appear) {
		/* appear */
		switch (check->type) {
		case ET_ACTOR:
		case ET_ACTOR2x2:
			G_EventActorAppear(playerMask, check, ent);
			break;

		case ET_CAMERA:
			G_EventCameraAppear(playerMask, check);
			break;

		case ET_ITEM:
			G_EventEdictAppear(playerMask, check);
			G_SendInventory(playerMask, check);
			break;

		case ET_PARTICLE:
			G_EventEdictAppear(playerMask, check);
			G_EventSendParticle(playerMask, check);
			break;

		case ET_TRIGGER_RESCUE:
			G_EventAddBrushModel(playerMask, check);
			break;

		default:
			if (G_IsVisibleOnBattlefield(check))
				gi.Error("Missing edict type %i in G_AppearPerishEvent", check->type);
			break;
		}
	} else if (G_IsVisibleOnBattlefield(check)) {
		G_EventEdictPerish(playerMask, check);
	}
}