Reads or writes the contents of .map files into a standard internal format, which can then be moved into private formats for collision detection, map processing, or editor use. No validation (duplicate planes, null area brushes, etc) is performed. There are no limits to the number of any of the elements in maps. The order of entities, brushes, and sides is maintained.
Inheritance: IDisposable
Beispiel #1
0
		private void LoadMap(string mapName, int randomSeed)
		{
			bool isSameMap = ((_currentMapFile != null) && (_currentMapFileName.ToLower() == mapName.ToLower()));

			// clear the sound system
			_currentSoundWorld.ClearAllSoundEmitters();

			InitAsyncNetwork();

			if((isSameMap == false) || ((_currentMapFile != null) && (_currentMapFile.NeedsReload == true)))
			{
				// load the .map file
				if(_currentMapFile != null)
				{
					_currentMapFile.Dispose();
					_currentMapFile = null;
				}

				_currentMapFile = new idMapFile();

				if(_currentMapFile.Parse(mapName) == false)
				{
					_currentMapFile.Dispose();
					_currentMapFile = null;

					idConsole.Error("Couldn't load {0}", mapName);
				}
			}

			_currentMapFileName = _currentMapFile.Name;

			// load the collision map
			idR.CollisionModelManager.LoadMap(_currentMapFile);

			_clientCount = 0;

			// initialize all entities for this game
			_entities = new idEntity[idR.MaxGameEntities];
			_spawnIds = new int[idR.MaxGameEntities];

			_userCommands = new idUserCommand[0];
			_spawnCount = idGame.InitialSpawnCount;

			_spawnedEntities.Clear();
			_activeEntities.Clear();
			_entitiesToDeactivate = 0;

			_sortTeamMasters = false;
			_sortPushers = false;
			/*lastGUIEnt = NULL;
			lastGUI = 0;*/

			_globalMaterial = null;
			_globalMaterialParameters = new float[idE.MaxGlobalMaterialParameters];

			// always leave room for the max number of clients,
			// even if they aren't all used, so numbers inside that
			// range are NEVER anything but clients

			_entityCount = idR.MaxClients;
			_firstFreeIndex = idR.MaxClients;

			// reset the random number generator.
			_random = new Random((this.IsMultiplayer == true) ? randomSeed : 0);

			/*

			camera			= NULL;
			world			= NULL;
			testmodel		= NULL;
			testFx			= NULL;

			lastAIAlertEntity = NULL;
			lastAIAlertTime = 0;*/
			_previousTime = 0;
			_time = 0;
			_frameCount = 0;

			_sessionCommand = string.Empty;
			/*
			nextGibTime		= 0;

			vacuumAreaNum = -1;		// if an info_vacuum is spawned, it will set this

			*/

			_gravity = new Vector3(0, 0, -idR.CvarSystem.GetFloat("g_gravity"));
			_spawnArgs.Clear();

			/*skipCinematic = false;
			inCinematic = false;
			cinematicSkipTime = 0;
			cinematicStopTime = 0;
			cinematicMaxSkipTime = 0;*/

			_clip.Init();

			/*pvs.Init();
			playerPVS.i = -1;
			playerConnectedAreas.i = -1;

			// load navigation system for all the different monster sizes
			for( i = 0; i < aasNames.Num(); i++ ) {
				aasList[ i ]->Init( idStr( mapFileName ).SetFileExtension( aasNames[ i ] ).c_str(), mapFile->GetGeometryCRC() );
			}

			// clear the smoke particle free list
			smokeParticles->Init();*/

			// cache miscellanious media references
			FindEntityDef("preCacheExtras", false);

			if(isSameMap == false)
			{
				_currentMapFile.RemovePrimitiveData();
			}
		}
		private void BuildModels(idMapFile mapFile)
		{
			idConsole.Warning("TODO: idTimer");
			/*idTimer timer;
			timer.Start();*/

			if(LoadCollisionModelFile(mapFile.Name, 0 /* TODO: mapFile->GetGeometryCRC()*/) == false)
			{
				idConsole.Warning("TODO: no collision model, compile");

				/*if ( !mapFile->GetNumEntities() ) {
					return;
				}

				// load the .proc file bsp for data optimisation
				LoadProcBSP( mapFile->GetName() );

				// convert brushes and patches to collision data
				for ( i = 0; i < mapFile->GetNumEntities(); i++ ) {
					mapEnt = mapFile->GetEntity(i);

					if ( numModels >= MAX_SUBMODELS ) {
						common->Error( "idCollisionModelManagerLocal::BuildModels: more than %d collision models", MAX_SUBMODELS );
						break;
					}
					models[numModels] = CollisionModelForMapEntity( mapEnt );
					if ( models[ numModels] ) {
						numModels++;
					}
				}

				// free the proc bsp which is only used for data optimization
				Mem_Free( procNodes );
				procNodes = NULL;

				// write the collision models to a file
				WriteCollisionModelsToFile( mapFile->GetName(), 0, numModels, mapFile->GetGeometryCRC() );*/
			}

			idConsole.Warning("TODO: timer.Stop();");

			// print statistics on collision data
			/*cm_model_t model;
			AccumulateModelInfo( &model );
			common->Printf( "collision data:\n" );
			common->Printf( "%6i models\n", numModels );
			PrintModelInfo( &model );
			common->Printf( "%.0f msec to load collision data.\n", timer.Milliseconds() );*/
		}
Beispiel #3
0
		private void Clear()
		{
			_serverInfo.Clear();

			int count = _userInfo.Length;

			for(int i = 0; i < count; i++)
			{
				_userInfo[i].Clear();
				_persistentPlayerInfo[i].Clear();
			}

			_isClient = false;
			_isServer = false;
			_isMultiplayer = false;

			_clientCount = 0;
			_spawnCount = idGame.InitialSpawnCount;
			_localClientIndex = 0;

			_currentMapFileName = string.Empty;

			if(_currentMapFile != null)
			{
				_currentMapFile.Dispose();
				_currentMapFile = null;
			}

			_userCommands = null;
			_spawnIds = new int[idR.MaxGameEntities];
			_entities = new idEntity[idR.MaxGameEntities];
			_playerStates = new PlayerState[idR.MaxClients];

			count = _playerStates.Length;

			for(int i = 0; i < count; i++)
			{
				_playerStates[i] = new PlayerState();
			}

			_spawnArgs.Clear();
			_spawnedEntities.Clear();

			_gameState = GameState.Uninitialized;
			_firstFreeIndex = 0;
			_entityCount = 0;
			_activeEntities.Clear();
			_entitiesToDeactivate = 0;
			
			_sortPushers = false;
			_sortTeamMasters = false;

/*			persistentLevelInfo.Clear();*/
			_globalMaterialParameters = new float[idE.MaxGlobalMaterialParameters];

			_random = new Random(0);

			_world = null;
			/*
			
			frameCommandThread = NULL;
			testmodel = NULL;
			testFx = NULL;*/
			// TODO: _clip.Shutdown();
			/*pvs.Shutdown();*/
			_sessionCommand = string.Empty;
			/*locationEntities = NULL;
			smokeParticles = NULL;
			editEntities = NULL;
			entityHash.Clear(1024, MAX_GENTITIES);
			inCinematic = false;
			cinematicSkipTime = 0;
			cinematicStopTime = 0;
			cinematicMaxSkipTime = 0;*/

			_frameCount = 0;
			_previousTime = 0;
			_time = 0;

			/*vacuumAreaNum = 0;
			
			mapSpawnCount = 0;
			camera = NULL;
			aasList.Clear();
			aasNames.Clear();
			lastAIAlertEntity = NULL;
			lastAIAlertTime = 0;

			gravity.Set(0, 0, -1);
			playerPVS.h = -1;
			playerConnectedAreas.h = -1;
			skipCinematic = false;
			influenceActive = false;*/

			_realClientTime = 0;

			/*isNewFrame = true;
			clientSmoothing = 0.1f;
			entityDefBits = 0;

			nextGibTime = 0;
			globalMaterial = NULL;
			newInfo.Clear();
			lastGUIEnt = NULL;
			lastGUI = 0;

			memset(clientEntityStates, 0, sizeof(clientEntityStates));
			memset(clientPVS, 0, sizeof(clientPVS));
			memset(clientSnapshots, 0, sizeof(clientSnapshots));

			eventQueue.Init();
			savedEventQueue.Init();

			memset(lagometer, 0, sizeof(lagometer));*/
		}
		public void LoadMap(idMapFile mapFile)
		{
			if(mapFile == null)
			{
				idConsole.Error("idCollisionModelManager::LoadMap: NULL mapFile");
			}

			// check whether we can keep the current collision map based on the mapName and mapFileTime
			if(_isLoaded == true)
			{
				if(_mapName.Equals(mapFile.Name, StringComparison.OrdinalIgnoreCase) == true)
				{
					idConsole.Warning("TODO: loadmap load check");
					/*if ( mapFile->GetFileTime() == mapFileTime ) {
						common->DPrintf( "Using loaded version\n" );
						return;
					}*/

					idConsole.DeveloperWriteLine("Reloading modified map");
				}

				idConsole.Warning("TODO: FreeMap();");
			}

			// clear the collision map
			Clear();

			// models
			_models = new CollisionModel[idE.MaxSubModels + 1];
			_modelCount = 0;

			// setup hash to speed up finding shared vertices and edges
			idConsole.Warning("TODO: SetupHash();");

			// setup trace model structure
			SetupTraceModelStructure();

			// build collision models
			BuildModels(mapFile);

			// save name and time stamp
			_mapName = mapFile.Name;
			idConsole.Warning("TODO: mapFileTime = mapFile->GetFileTime();");

			_isLoaded = true;

			// shutdown the hash
			idConsole.Warning("TODO: ShutdownHash();");
		}