Beispiel #1
0
// RadioThink should be called once on each player per server frame.
void RadioThink (edict_t * ent)
{
	// Try to clean things up, a bit....
	if (ent->client->resp.radio_partner)
	{
		if (!ent->client->resp.radio_partner->inuse ||
			ent->client->resp.radio_partner->client->resp.radio_partner != ent)
		{
			ent->client->resp.radio_partner = NULL;
		}
	}
	if (ent->client->resp.partner_last_offered_to)
	{
		if (!ent->client->resp.partner_last_offered_to->inuse ||
			ent->client->resp.partner_last_offered_to->solid == SOLID_NOT)
		{
			ent->client->resp.partner_last_offered_to = NULL;
		}
	}
	if (ent->client->resp.partner_last_denied_from)
	{
		if (!ent->client->resp.partner_last_denied_from->inuse ||
			ent->client->resp.partner_last_denied_from->solid == SOLID_NOT)
		{
			ent->client->resp.partner_last_denied_from = NULL;
		}
	}
	// ................................

	if (ent->client->resp.radio_power_off)
	{
		ent->client->resp.radio_queue_size = 0;
		return;
	}

	if (ent->client->resp.radio_delay > 0)
	{
		ent->client->resp.radio_delay--;
		if(ent->client->resp.radio_delay)
			return;
	}


	if (ent->client->resp.radio_queue_size)
	{
		edict_t *from;
		int check;

		from = ent->client->resp.radio_queue[0].from_player;

		if (!ent->client->resp.radio_queue[0].click &&
			(!from->inuse || from->solid == SOLID_NOT
			|| from->deadflag == DEAD_DEAD))
		{
			if (ent->client->resp.radio_queue[0].from_gender)
			{
				ent->client->resp.radio_queue[0].sndIndex = globalRadio[RADIO_DEATH_FEMALE].sndIndex;
				ent->client->resp.radio_queue[0].length = globalRadio[RADIO_DEATH_FEMALE].length;
			}
			else
			{
				ent->client->resp.radio_queue[0].sndIndex = globalRadio[RADIO_DEATH_MALE].sndIndex;
				ent->client->resp.radio_queue[0].length = globalRadio[RADIO_DEATH_MALE].length;
			}

			for (check = 1; check < ent->client->resp.radio_queue_size; check++)
			{
				if (!ent->client->resp.radio_queue[check].click && ent->client->resp.radio_queue[check].from_player == from)
				{
					DeleteRadioQueueEntry (ent, check);
					check--;
				}
			}
		}

		unicastSound(ent, ent->client->resp.radio_queue[0].sndIndex, 1.0);
		ent->client->resp.radio_delay = ent->client->resp.radio_queue[0].length;
		DeleteRadioQueueEntry (ent, 0); //We can remove it here?
	}
}
Beispiel #2
0
// RadioThink should be called once on each player per server frame.
void RadioThink (edict_t * ent)
{
	radio_t *radio = &ent->client->resp.radio;

	// Try to clean things up, a bit....
	if (radio->partner)
	{
		if (!radio->partner->inuse ||
			radio->partner->client->resp.radio.partner != ent)
		{
			radio->partner = NULL;
		}
	}
	if (radio->partner_last_offered_to)
	{
		if (!radio->partner_last_offered_to->inuse ||
			radio->partner_last_offered_to->solid == SOLID_NOT)
		{
			radio->partner_last_offered_to = NULL;
		}
	}
	if (radio->partner_last_denied_from)
	{
		if (!radio->partner_last_denied_from->inuse ||
			radio->partner_last_denied_from->solid == SOLID_NOT)
		{
			radio->partner_last_denied_from = NULL;
		}
	}
	// ................................

	if (radio->power_off)
	{
		radio->queue_size = 0;
		return;
	}

	if (radio->delay > 0)
	{
		radio->delay--;
		if (radio->delay)
			return;
	}


	if (radio->queue_size)
	{
		edict_t *from;
		int check;

		from = radio->queue[0].from_player;

		if (!radio->queue[0].click && (!from->inuse || !IS_ALIVE(from)))
		{
			if (radio->queue[0].from_gender)
			{
				radio->queue[0].sndIndex = globalRadio[RADIO_DEATH_FEMALE].sndIndex;
				radio->queue[0].length = globalRadio[RADIO_DEATH_FEMALE].length;
			}
			else
			{
				radio->queue[0].sndIndex = globalRadio[RADIO_DEATH_MALE].sndIndex;
				radio->queue[0].length = globalRadio[RADIO_DEATH_MALE].length;
			}

			for (check = 1; check < radio->queue_size; check++)
			{
				if (!radio->queue[check].click && radio->queue[check].from_player == from)
				{
					DeleteRadioQueueEntry( radio, check );
					check--;
				}
			}
		}

		if( ! IsInIgnoreList( ent, from ) )
		{
			unicastSound( ent, radio->queue[0].sndIndex, 1.0 );
			radio->delay = radio->queue[0].length;
		}
		DeleteRadioQueueEntry( radio, 0 ); //We can remove it here?
	}
}