void G_UpdateTeamMapData( void ) {
	int i, j /*, k*/;
	gentity_t *ent, *ent2;
	mapEntityData_t *mEnt;

	if ( level.time - level.lastMapEntityUpdate < 500 ) {
		return;
	}
	level.lastMapEntityUpdate = level.time;

	for ( i = 0, ent = g_entities; i < level.num_entities; i++, ent++ ) {
		if ( !ent->inuse ) {
//			mapEntityData[0][i].valid = qfalse;
//			mapEntityData[1][i].valid = qfalse;
			continue;
		}

		switch ( ent->s.eType ) {
		case ET_PLAYER:
			G_UpdateTeamMapData_Player( ent, qfalse, qfalse );
			for ( j = 0; j < 2; j++ ) {
				mapEntityData_Team_t *teamList = &mapEntityData[j];

				mEnt = G_FindMapEntityDataSingleClient( teamList, NULL, ent->s.number, -1 );

				while ( mEnt ) {
					VectorCopy( ent->client->ps.origin, mEnt->org );
					mEnt->yaw = ent->client->ps.viewangles[YAW];
					mEnt = G_FindMapEntityDataSingleClient( teamList, mEnt, ent->s.number, -1 );
				}
			}
			break;
		case ET_CONSTRUCTIBLE_INDICATOR:
			if ( ent->parent && ent->parent->entstate == STATE_DEFAULT ) {
				G_UpdateTeamMapData_Construct( ent );
			}
			break;
		case ET_EXPLOSIVE_INDICATOR:
			if ( ent->parent && ent->parent->entstate == STATE_DEFAULT ) {
				G_UpdateTeamMapData_Destruct( ent );
			}
			break;
		case ET_TANK_INDICATOR:
		case ET_TANK_INDICATOR_DEAD:
			G_UpdateTeamMapData_Tank( ent );
			break;
		case ET_MISSILE:
			if ( ent->methodOfDeath == MOD_LANDMINE ) {
				G_UpdateTeamMapData_LandMine( ent, qfalse, qfalse );
			}
			break;
		case ET_COMMANDMAP_MARKER:
			G_UpdateTeamMapData_CommandmapMarker( ent );
			break;
		default:
			break;
		}
	}

	//for(i = 0, ent = g_entities; i < MAX_CLIENTS; i++, ent++) {
	for ( i = 0, ent = g_entities; i < level.num_entities; i++, ent++ ) {
		qboolean f1, f2;
		if ( !ent->inuse || !ent->client ) {
			continue;
		}

		if ( ent->client->sess.playerType == PC_FIELDOPS ) {
			if ( ent->client->sess.skill[SK_SIGNALS] >= 4 && ent->health > 0 ) {
				vec3_t pos[3];

				f1 = ent->client->sess.sessionTeam == TEAM_ALLIES ? qtrue : qfalse;
				f2 = ent->client->sess.sessionTeam == TEAM_AXIS ?   qtrue : qfalse;

				G_SetupFrustum( ent );

				for ( j = 0, ent2 = g_entities; j < level.maxclients; j++, ent2++ ) {
					if ( !ent2->inuse || ent2 == ent ) {
						continue;
					}

					//if( ent2->s.eType != ET_PLAYER ) {
					//	continue;
					//}

					if ( ent2->client->sess.sessionTeam == TEAM_SPECTATOR ) {
						continue;
					}

					if ( ent2->health <= 0 ||
						 ent2->client->sess.sessionTeam == ent->client->sess.sessionTeam ||
						 !ent2->client->ps.powerups[PW_OPS_DISGUISED] ) {
						continue;
					}

					VectorCopy( ent2->client->ps.origin, pos[0] );
					pos[0][2] += ent2->client->ps.mins[2];
					VectorCopy( ent2->client->ps.origin, pos[1] );
					VectorCopy( ent2->client->ps.origin, pos[2] );
					pos[2][2] += ent2->client->ps.maxs[2];

					if ( G_VisibleFromBinoculars( ent, ent2, pos[0] ) ||
						 G_VisibleFromBinoculars( ent, ent2, pos[1] ) ||
						 G_VisibleFromBinoculars( ent, ent2, pos[2] ) ) {
						G_UpdateTeamMapData_DisguisedPlayer( ent, ent2, f1, f2 );
					}
				}
			}
		} else if ( ent->client->sess.playerType == PC_COVERTOPS ) {
			if ( ent->health > 0 ) {
				f1 = ent->client->sess.sessionTeam == TEAM_ALLIES ? qtrue : qfalse;
				f2 = ent->client->sess.sessionTeam == TEAM_AXIS ?   qtrue : qfalse;

				G_SetupFrustum( ent );

				for ( j = 0, ent2 = g_entities; j < level.num_entities; j++, ent2++ ) {
					if ( !ent2->inuse || ent2 == ent ) {
						continue;
					}

					switch ( ent2->s.eType ) {
					case ET_PLAYER:
					{
						vec3_t pos[3];
						VectorCopy( ent2->client->ps.origin, pos[0] );
						pos[0][2] += ent2->client->ps.mins[2];
						VectorCopy( ent2->client->ps.origin, pos[1] );
						VectorCopy( ent2->client->ps.origin, pos[2] );
						pos[2][2] += ent2->client->ps.maxs[2];
						if ( ent2->health > 0 && ( G_VisibleFromBinoculars( ent, ent2, pos[0] ) ||
												   G_VisibleFromBinoculars( ent, ent2, pos[1] ) ||
												   G_VisibleFromBinoculars( ent, ent2, pos[2] ) ) ) {
							if ( ent2->client->sess.sessionTeam != ent->client->sess.sessionTeam ) {
								int k;

								switch ( ent2->client->sess.sessionTeam ) {
								case TEAM_AXIS:
									mEnt = G_FindMapEntityData( &mapEntityData[0], ent2 - g_entities );
									if ( mEnt && level.time - mEnt->startTime > 5000 ) {
										for ( k = 0; k < MAX_CLIENTS; k++ ) {
											if ( g_entities[k].inuse && g_entities[k].client && g_entities[k].client->sess.sessionTeam == ent->client->sess.sessionTeam ) {
												trap_SendServerCommand( k, va( "tt \"ENEMY SPOTTED <STOP> CHECK COMMAND MAP FOR DETAILS <STOP>\"\n" ) );
											}
										}
									}
									break;

								case TEAM_ALLIES:
									mEnt = G_FindMapEntityData( &mapEntityData[1], ent2 - g_entities );
									if ( mEnt && level.time - mEnt->startTime > 5000 ) {
										for ( k = 0; k < MAX_CLIENTS; k++ ) {
											if ( g_entities[k].inuse && g_entities[k].client && g_entities[k].client->sess.sessionTeam == ent->client->sess.sessionTeam ) {
												trap_SendServerCommand( k, va( "tt \"ENEMY SPOTTED <STOP> CHECK COMMAND MAP FOR DETAILS <STOP>\"\n" ) );
											}
										}
									}
									break;

								default:
									break;
								}
							}

							G_UpdateTeamMapData_Player( ent2, f1, f2 );
						}
						break;
					}
					default:
						break;
					}
				}

				if ( ent->client->ps.eFlags & EF_ZOOMING ) {
					G_SetupFrustum_ForBinoculars( ent );

					for ( j = 0, ent2 = g_entities; j < level.num_entities; j++, ent2++ ) {
						if ( !ent2->inuse || ent2 == ent ) {
							continue;
						}

						switch ( ent2->s.eType ) {
						case ET_MISSILE:
							if ( ent2->methodOfDeath == MOD_LANDMINE ) {
								if ( ( ent2->s.teamNum < 4 || ent2->s.teamNum >= 8 ) && ( ent2->s.teamNum % 4 != ent->client->sess.sessionTeam ) ) {
									// TAT - as before, we can only detect a mine if we can see it from our binoculars
									if ( G_VisibleFromBinoculars( ent, ent2, ent2->r.currentOrigin ) ) {
										G_UpdateTeamMapData_LandMine( ent2, f1, f2 );

										switch ( ent2->s.teamNum % 4 ) {
										case TEAM_AXIS:
											if ( !ent2->s.modelindex2 ) {
												ent->client->landmineSpottedTime = level.time;
												ent->client->landmineSpotted = ent2;
												ent2->s.density = ent - g_entities + 1;
												ent2->missionLevel = level.time;

												ent->client->landmineSpotted->count2 += 50;
												if ( ent->client->landmineSpotted->count2 >= 250 ) {
//													int k;
													ent->client->landmineSpotted->count2 = 250;

													ent->client->landmineSpotted->s.modelindex2 = 1;

													// for marker
													ent->client->landmineSpotted->s.frame = rand() % 20;
													ent->client->landmineSpotted->r.contents = CONTENTS_CORPSE;
													trap_LinkEntity( ent->client->landmineSpotted );

													{
														gentity_t* pm = G_PopupMessage( PM_MINES );
														VectorCopy( ent->client->landmineSpotted->r.currentOrigin, pm->s.origin );
														pm->s.effect2Time = TEAM_AXIS;
														pm->s.effect3Time = ent - g_entities;
													}

/*													for( k = 0; k < MAX_CLIENTS; k++ ) {
														if(g_entities[k].inuse && g_entities[k].client && g_entities[k].client->sess.sessionTeam == ent->client->sess.sessionTeam) {
															trap_SendServerCommand( k, va( "tt \"LANDMINES SPOTTED BY %s^0<STOP> CHECK COMMAND MAP FOR DETAILS <STOP>\"\n", ent->client->pers.netname));
														}
													}*/

													trap_SendServerCommand( ent - g_entities, "cp \"Landmine Revealed\n\"" );

													AddScore( ent, 1 );
													//G_AddExperience( ent, 1.f );

													G_AddSkillPoints( ent, SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS, 3.f );
													G_DebugAddSkillPoints( ent, SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS, 3.f, "spotting a landmine" );
												}
											}
											break;

										case TEAM_ALLIES:
											if ( !ent2->s.modelindex2 ) {
												ent->client->landmineSpottedTime = level.time;
												ent->client->landmineSpotted = ent2;
												ent2->s.density = ent - g_entities + 1;
												ent2->missionLevel = level.time;

												ent->client->landmineSpotted->count2 += 50;
												if ( ent->client->landmineSpotted->count2 >= 250 ) {
//													int k;
													ent->client->landmineSpotted->count2 = 250;

													ent->client->landmineSpotted->s.modelindex2 = 1;

													// for marker
													ent->client->landmineSpotted->s.frame = rand() % 20;
													ent->client->landmineSpotted->r.contents = CONTENTS_CORPSE;
													trap_LinkEntity( ent->client->landmineSpotted );

													{
														gentity_t* pm = G_PopupMessage( PM_MINES );
														VectorCopy( ent->client->landmineSpotted->r.currentOrigin, pm->s.origin );

														pm->s.effect2Time = TEAM_ALLIES;
														pm->s.effect3Time = ent - g_entities;
													}

/*													for( k = 0; k < MAX_CLIENTS; k++ ) {
														if(g_entities[k].inuse && g_entities[k].client && g_entities[k].client->sess.sessionTeam == ent->client->sess.sessionTeam) {
															trap_SendServerCommand( k, va( "tt \"LANDMINES SPOTTED BY %s^0<STOP> CHECK COMMAND MAP FOR DETAILS <STOP>\"\n", ent->client->pers.netname));
														}
													}*/

													trap_SendServerCommand( ent - g_entities, "cp \"Landmine Revealed\n\"" );

													AddScore( ent, 1 );
													//G_AddExperience( ent, 1.f );

													G_AddSkillPoints( ent, SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS, 3.f );
													G_DebugAddSkillPoints( ent, SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS, 3.f, "spotting a landmine" );
												}
											}
											break;
										} // end switch
									} // end (G_VisibleFromBinoculars( ent, ent2, ent2->r.currentOrigin ))
									else
									{
										// TAT - if we can't see the mine from our binoculars, make sure we clear out the landmineSpotted ptr,
										//		because bots looking for mines are getting confused
										ent->client->landmineSpotted = NULL;
									}
								}
							}
							break;
						default:
							break;
						}
					}

/*					if(ent->client->landmineSpotted && !ent->client->landmineSpotted->s.modelindex2) {
						ent->client->landmineSpotted->count2 += 10;
						if(ent->client->landmineSpotted->count2 >= 250) {
							int k;
							ent->client->landmineSpotted->count2 = 250;

							ent->client->landmineSpotted->s.modelindex2 = 1;

							// for marker
							ent->client->landmineSpotted->s.frame = rand() % 20;

							for( k = 0; k < MAX_CLIENTS; k++ ) {
								if(g_entities[k].inuse && g_entities[k].client && g_entities[k].client->sess.sessionTeam == ent->client->sess.sessionTeam) {
									trap_SendServerCommand( k, va( "tt \"LANDMINES SPOTTED <STOP> CHECK COMMAND MAP FOR DETAILS <STOP>\"\n" ));
								}
							}
							trap_SendServerCommand( ent-g_entities, "cp \"Landmine Revealed\n\"" );

							AddScore( ent, 1 );
							//G_AddExperience( ent, 1.f );

							G_AddSkillPoints( ent, SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS, 3.f );
							G_DebugAddSkillPoints( ent, SK_MILITARY_INTELLIGENCE_AND_SCOPED_WEAPONS, 3.f, "spotting a landmine" );
						}
					}*/

/*					{
						// find any landmines that don't actually exist anymore, see if the covert ops can see the spot and if so - wipe them
						mapEntityData_Team_t *teamList = ent->client->sess.sessionTeam == TEAM_AXIS ? &mapEntityData[0] : &mapEntityData[1];

						mEnt = teamList->activeMapEntityData.next;
						while( mEnt && mEnt != &teamList->activeMapEntityData ) {
							if( mEnt->type == ME_LANDMINE && mEnt->entNum == -1 ) {
								if( G_VisibleFromBinoculars( ent, NULL, mEnt->org ) ) {
									mEnt = G_FreeMapEntityData( teamList, mEnt );

									trap_SendServerCommand( ent-g_entities, "print \"Old Landmine Cleared\n\"" );
									AddScore( ent, 1 );
									continue;
								}
							}

							mEnt = mEnt->next;
						}
					}*/
				}
			}
		}
	}

//	G_SendAllMapEntityInfo();
}
Пример #2
0
void G_UpdateTeamMapData(void)
{
	int             i, j;
	gentity_t       *ent, *ent2;
	mapEntityData_t *mEnt;
	qboolean        f1, f2;

	G_CheckSpottedLandMines();

	if (level.time - level.lastMapEntityUpdate < 1000)
	{
		return;
	}
	level.lastMapEntityUpdate = level.time;

	// all ents - comon update
	for (i = 0; i < level.num_entities; i++)
	{
		ent = &g_entities[i];

		if (!ent->inuse)
		{
			//mapEntityData[0][i].valid = qfalse;
			//mapEntityData[1][i].valid = qfalse;
			continue;
		}

		switch (ent->s.eType)
		{
		case ET_PLAYER:
			G_UpdateTeamMapData_Player(ent, qfalse, qfalse);
			for (j = 0; j < 2; j++)
			{
				mapEntityData_Team_t *teamList = &mapEntityData[j];

				mEnt = G_FindMapEntityDataSingleClient(teamList, NULL, ent->s.number, -1);

				while (mEnt)
				{
					VectorCopy(ent->client->ps.origin, mEnt->org);
					mEnt->yaw = ent->client->ps.viewangles[YAW];
					mEnt      = G_FindMapEntityDataSingleClient(teamList, mEnt, ent->s.number, -1);
				}
			}
			break;
		case ET_CONSTRUCTIBLE_INDICATOR:
			if (ent->parent && ent->parent->entstate == STATE_DEFAULT)
			{
				G_UpdateTeamMapData_Construct(ent);
			}
			break;
		case ET_EXPLOSIVE_INDICATOR:
			if (ent->parent && ent->parent->entstate == STATE_DEFAULT)
			{
				G_UpdateTeamMapData_Destruct(ent);
			}
			break;
		case ET_TANK_INDICATOR:
		case ET_TANK_INDICATOR_DEAD:
			G_UpdateTeamMapData_Tank(ent);
			break;
		case ET_MISSILE:
			if (ent->methodOfDeath == MOD_LANDMINE)
			{
				G_UpdateTeamMapData_LandMine(ent);
			}
			break;
		case ET_COMMANDMAP_MARKER:
			G_UpdateTeamMapData_CommandmapMarker(ent);
			break;
		default:
			break;
		}
	}

	// clients again - do special stuff for field- and covert ops
	for (i = 0; i < level.numConnectedClients; i++)
	{
		ent = &g_entities[level.sortedClients[i]];

		f1 = ent->client->sess.sessionTeam == TEAM_ALLIES ? qtrue : qfalse;
		f2 = ent->client->sess.sessionTeam == TEAM_AXIS ? qtrue : qfalse;

		if (!ent->inuse)
		{
			continue;
		}

		if (ent->health <= 0)
		{
			continue;
		}

		// must be in a valid team
		if (ent->client->sess.sessionTeam == TEAM_SPECTATOR || ent->client->sess.sessionTeam == TEAM_FREE)
		{
			continue;
		}

		if (ent->client->ps.pm_flags & PMF_LIMBO)
		{
			continue;
		}

		if (ent->client->sess.playerType == PC_FIELDOPS && (ent->client->ps.eFlags & EF_ZOOMING) && ent->client->sess.skill[SK_SIGNALS] >= 4)
		{
			vec3_t pos[3];

			G_SetupFrustum_ForBinoculars(ent);

			for (j = 0; j < level.numConnectedClients; j++)
			{
				ent2 = &g_entities[level.sortedClients[j]];

				if (!ent2->inuse || ent2 == ent)
				{
					continue;
				}

				// players are sometimes of type ET_GENERAL
				if (ent2->s.eType != ET_PLAYER)
				{
					continue;
				}

				if (ent2->client->sess.sessionTeam == TEAM_SPECTATOR)
				{
					continue;
				}

				if (ent2->health <= 0 ||
				    ent2->client->sess.sessionTeam == ent->client->sess.sessionTeam ||
				    !ent2->client->ps.powerups[PW_OPS_DISGUISED])
				{
					continue;
				}

				VectorCopy(ent2->client->ps.origin, pos[0]);
				VectorCopy(ent2->client->ps.mins, pos[1]);
				VectorCopy(ent2->client->ps.maxs, pos[2]);

				if (G_VisibleFromBinoculars_Box(ent, ent2, pos[0], pos[1], pos[2]))
				{
					G_UpdateTeamMapData_DisguisedPlayer(ent, ent2, f1, f2);
				}
			}
		}
		else if (ent->client->sess.playerType == PC_COVERTOPS)
		{
			vec3_t pos[3];

			G_SetupFrustum(ent);

			for (j = 0; j < level.numConnectedClients; j++)
			{
				ent2 = &g_entities[level.sortedClients[j]];

				if (!ent2->inuse || ent2 == ent)
				{
					continue;
				}

				// players are sometimes of type ET_GENERAL
				if (ent2->s.eType != ET_PLAYER)
				{
					continue;
				}

				// no spectators thanks
				if (ent2->client->sess.sessionTeam == TEAM_SPECTATOR || ent2->client->sess.sessionTeam == TEAM_FREE)
				{
					continue;
				}

				// do not add 'dead' players
				if (ent2->health <= 0)
				{
					continue;
				}

				// we will only add other team members here
				if (ent2->client->sess.sessionTeam == ent->client->sess.sessionTeam)
				{
					continue;
				}

				VectorCopy(ent2->client->ps.origin, pos[0]);
				VectorCopy(ent2->client->ps.mins, pos[1]);
				VectorCopy(ent2->client->ps.maxs, pos[2]);

				if (G_VisibleFromBinoculars_Box(ent, ent2, pos[0], pos[1], pos[2]))
				{
					G_UpdateTeamMapData_Player(ent2, f1, f2);
				}
			}
		}
	}
}