void G_SendMapEntityInfo( gentity_t* e ) {
	mapEntityData_t *mEnt;
	mapEntityData_Team_t *teamList;
	char buffer[2048];
	int cnt = 0;

	if ( e->client->sess.sessionTeam == TEAM_SPECTATOR ) {
		G_SendSpectatorMapEntityInfo( e );
		return;
	}

	// something really went wrong if this evaluates to true
	if ( e->client->sess.sessionTeam != TEAM_AXIS && e->client->sess.sessionTeam != TEAM_ALLIES ) {
		return;
	}

	teamList = e->client->sess.sessionTeam == TEAM_AXIS ? &mapEntityData[0] : &mapEntityData[1];

	mEnt = teamList->activeMapEntityData.next;
	while ( mEnt && mEnt != &teamList->activeMapEntityData ) {
		if ( level.time - mEnt->startTime > 5000 ) {
			mEnt->status = 1;
			// we can free this player from the list now
			if ( mEnt->type == ME_PLAYER ) {
				mEnt = G_FreeMapEntityData( teamList, mEnt );
				continue;
			} else if ( mEnt->type == ME_PLAYER_DISGUISED ) {
				if ( mEnt->singleClient == e->s.clientNum ) {
					mEnt = G_FreeMapEntityData( teamList, mEnt );
					continue;
				}
			}
		} else {
			mEnt->status = 2;
		}
		cnt++;

		mEnt = mEnt->next;
	}

	if ( e->client->sess.sessionTeam == TEAM_AXIS ) {
		Com_sprintf( buffer, sizeof( buffer ), "entnfo %i 0", cnt );
	} else {
		Com_sprintf( buffer, sizeof( buffer ), "entnfo 0 %i", cnt );
	}

	for ( mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next ) {

		if ( mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient ) {
			continue;
		}

		G_PushMapEntityToBuffer( buffer, sizeof( buffer ), mEnt );
	}

	trap_SendServerCommand( e - g_entities, buffer );
}
void G_SendSpectatorMapEntityInfo( gentity_t* e ) {
	// special version, sends different set of ents - only the objectives, but also team info (string is split in two basically)
	mapEntityData_t *mEnt;
	mapEntityData_Team_t *teamList;
	char buffer[2048];
	int al_cnt, ax_cnt;

	// Axis data init
	teamList = &mapEntityData[0];
	
	ax_cnt = 0;
	for( mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next ) {
		if( mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD ) {
			continue;
		}

		if( mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient ) {
			continue;
		}

		ax_cnt++;

		
	}

	// Allied data init
	teamList = &mapEntityData[1];

	
	al_cnt = 0;
	for( mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next ) {
		if( mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD ) {
			continue;
		}

		if( mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient ) {
			continue;
		}

		al_cnt++;		
	}

	// Data setup
	Com_sprintf( buffer, sizeof( buffer ), "entnfo %i %i", ax_cnt, al_cnt );

	// Axis data
	teamList = &mapEntityData[0];

	for( mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next ) {

		if( mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD && mEnt->type != ME_DESTRUCT_2 )
			continue;

		if( mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient )
			continue;

		G_PushMapEntityToBuffer( buffer, sizeof( buffer ), mEnt );
	}

	// Allied data
	teamList = &mapEntityData[1];

	for( mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next ) {

		if( mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD && mEnt->type != ME_DESTRUCT_2 )
			continue;

		if( mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient )
			continue;

		G_PushMapEntityToBuffer( buffer, sizeof( buffer ), mEnt );
	}

	trap_SendServerCommand( e-g_entities, buffer );
}
Beispiel #3
0
/**
 * @brief G_SendSpectatorMapEntityInfo
 * @param[in] e
 */
void G_SendSpectatorMapEntityInfo(gentity_t *e)
{
	// special version, sends different set of ents - only the objectives, but also team info (string is split in two basically)
	mapEntityData_t      *mEnt;
	mapEntityData_Team_t *teamList = &mapEntityData[0]; // Axis data init
	char                 buffer[2048];
	int                  al_cnt = 0, ax_cnt = 0;

	buffer[0] = '\0';

	for (mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next)
	{
		if (mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_DESTRUCT_2 && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD && mEnt->type != ME_COMMANDMAP_MARKER)
		{
			continue;
		}

		if (mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient)
		{
			continue;
		}

		ax_cnt++;
	}

	// Allied data init
	teamList = &mapEntityData[1];

	for (mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next)
	{
		if (mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_DESTRUCT_2 && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD && mEnt->type != ME_COMMANDMAP_MARKER)
		{
			continue;
		}

		if (mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient)
		{
			continue;
		}

		al_cnt++;
	}

	// Data setup
	// FIXME: Find out why objective counts are reset to zero when a new player connects
	if (ax_cnt > 0 || al_cnt > 0)
	{
		Com_sprintf(buffer, sizeof(buffer), "entnfo %i %i", ax_cnt, al_cnt);
	}

	// Axis data
	teamList = &mapEntityData[0];

	for (mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next)
	{
		if (mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_DESTRUCT_2 && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD && mEnt->type != ME_COMMANDMAP_MARKER)
		{
			continue;
		}

		if (mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient)
		{
			continue;
		}

		G_PushMapEntityToBuffer(buffer, sizeof(buffer), mEnt);
	}

	// Allied data
	teamList = &mapEntityData[1];

	for (mEnt = teamList->activeMapEntityData.next; mEnt && mEnt != &teamList->activeMapEntityData; mEnt = mEnt->next)
	{
		if (mEnt->type != ME_CONSTRUCT && mEnt->type != ME_DESTRUCT && mEnt->type != ME_DESTRUCT_2 && mEnt->type != ME_TANK && mEnt->type != ME_TANK_DEAD && mEnt->type != ME_COMMANDMAP_MARKER)
		{
			continue;
		}

		if (mEnt->singleClient >= 0 && e->s.clientNum != mEnt->singleClient)
		{
			continue;
		}

		G_PushMapEntityToBuffer(buffer, sizeof(buffer), mEnt);
	}

	if (buffer[0] != '\0') // don't send an emtpy buffer
	{
		trap_SendServerCommand(e - g_entities, buffer);
	}
}