Exemplo n.º 1
0
void SensorSystemManager::destroy (void) {

	if (sensorPool)
	{
		for (long i = 0; i < MAX_SENSORS; i++) 
		{
			delete sensorPool[i];
			sensorPool[i] = NULL;
		}
		
		missionHeap->Free(sensorPool);
		sensorPool = NULL;
	}

	freeSensors = 0;
	freeList = NULL;

	for (long i = 0; i < Team::numTeams; i++) 
	{
		delete teamSensors[i];
		teamSensors[i] = NULL;
	}

	if (SensorSystem::sortList)
	{
		delete SensorSystem::sortList;
		SensorSystem::sortList = NULL;
	}
}
Exemplo n.º 2
0
void GoalManager::destroy (void) {

	if (goalObjectPool) {
		missionHeap->Free(goalObjectPool);
		goalObjectPool = NULL;
	}
	numGoalObjects = 0;
	goalObjectPoolSize = 0;
}
Exemplo n.º 3
0
void GameDebugWindow::operator delete(PVOID us)
{
    systemHeap->Free(us);
}
Exemplo n.º 4
0
void SensorSystem::operator delete (void* us) {

	missionHeap->Free(us);
}
Exemplo n.º 5
0
void ContactInfo::operator delete (void* us) {

	missionHeap->Free(us);
}	
Exemplo n.º 6
0
void GoalObject::operator delete (void* us) {

	missionHeap->Free(us);
}
Exemplo n.º 7
0
void GoalManager::operator delete (void* us) {

	missionHeap->Free(us);
}
Exemplo n.º 8
0
//---------------------------------------------------------------------------
void __stdcall InitializeGameEngine()
{
	gosResourceHandle = gos_OpenResourceDLL("mc2res.dll");
	char temp[256];
	cLoadString(IDS_FLOAT_HELP_FONT, temp, 255);
	PSTR pStr = strstr(temp, ",");
	if(pStr)
	{
		gosFontScale = atoi(pStr + 2);
		*pStr = 0;
	}
	char path [256];
	strcpy(path, "assets\\graphics\\");
	strcat(path, temp);
	gosFontHandle = gos_LoadFont(path);
	//-------------------------------------------------------------
	// Find the CDPath in the registry and save it off so I can
	// look in CD Install Path for files.
	//Changed for the shared source release, just set to current directory
	//uint32_t maxPathLength = 1023;
	//gos_LoadDataFromRegistry("CDPath", CDInstallPath, &maxPathLength);
	//if (!maxPathLength)
	// strcpy(CDInstallPath,"..\\");
	strcpy(CDInstallPath, ".\\");
	cLoadString(IDS_MC2_FILEMISSING, FileMissingString, 511);
	cLoadString(IDS_MC2_CDMISSING, CDMissingString, 1023);
	cLoadString(IDS_MC2_MISSING_TITLE, MissingTitleString, 255);
	//--------------------------------------------------------------
	// Start the SystemHeap and globalHeapList
	globalHeapList = new HeapList;
	gosASSERT(globalHeapList != nullptr);
	globalHeapList->init();
	globalHeapList->update(); //Run Instrumentation into GOS Debugger Screen
	systemHeap = new UserHeap;
	gosASSERT(systemHeap != nullptr);
	systemHeap->init(systemHeapSize, "SYSTEM");
	float doubleClickThreshold = 0.2f;
	int32_t dragThreshold = .016667;
	//--------------------------------------------------------------
	// Read in System.CFG
	FitIniFile systemFile;
#ifdef _DEBUG
	int32_t systemOpenResult =
#endif
		systemFile.open("system.cfg");
#ifdef _DEBUG
	if(systemOpenResult != NO_ERROR)
	{
		char Buffer[256];
		gos_GetCurrentPath(Buffer, 256);
		STOP(("Cannot find \"system.cfg\" file in %s", Buffer));
	}
#endif
	{
#ifdef _DEBUG
		int32_t systemBlockResult =
#endif
			systemFile.seekBlock("systemHeap");
		gosASSERT(systemBlockResult == NO_ERROR);
		{
			int32_t result = systemFile.readIdULong("systemHeapSize", systemHeapSize);
			result;
			gosASSERT(result == NO_ERROR);
		}
#ifdef _DEBUG
		int32_t systemPathResult =
#endif
			systemFile.seekBlock("systemPaths");
		gosASSERT(systemPathResult == NO_ERROR);
		{
			int32_t result = systemFile.readIdString("terrainPath", terrainPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("artPath", artPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("fontPath", fontPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("savePath", savePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("spritePath", spritePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("shapesPath", shapesPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("soundPath", soundPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("objectPath", objectPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("cameraPath", cameraPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("tilePath", tilePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("missionPath", missionPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("warriorPath", warriorPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("profilePath", profilePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("interfacepath", interfacePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("moviepath", moviePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("CDsoundPath", CDsoundPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("CDmoviepath", CDmoviePath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("tglPath", tglPath, 79);
			gosASSERT(result == NO_ERROR);
			result = systemFile.readIdString("texturePath", texturePath, 79);
			gosASSERT(result == NO_ERROR);
		}
#ifdef _DEBUG
		int32_t fastFileResult =
#endif
			systemFile.seekBlock("FastFiles");
		gosASSERT(fastFileResult == NO_ERROR);
		{
			int32_t result = systemFile.readIdLong("NumFastFiles", maxFastFiles);
			if(result != NO_ERROR)
				maxFastFiles = 0;
			if(maxFastFiles)
			{
				fastFiles = (FastFile**)malloc(maxFastFiles * sizeof(FastFile*));
				memset(fastFiles, 0, maxFastFiles * sizeof(FastFile*));
				int32_t fileNum = 0;
				char fastFileId[10];
				char fileName[100];
				sprintf(fastFileId, "File%d", fileNum);
				while(systemFile.readIdString(fastFileId, fileName, 99) == NO_ERROR)
				{
					bool result = FastFileInit(fileName);
					if(!result)
						STOP(("Unable to startup fastfiles. Probably an old one in the directory!!"));
					fileNum++;
					sprintf(fastFileId, "File%d", fileNum);
				}
			}
		}
	}
	systemFile.close();
	//--------------------------------------------------------------
	// Read in Prefs.cfg
	bool fullScreen = false;
	FitIniFilePtr prefs = new FitIniFile;
#ifdef _DEBUG
	int32_t prefsOpenResult =
#endif
		prefs->open("prefs.cfg");
	gosASSERT(prefsOpenResult == NO_ERROR);
	{
#ifdef _DEBUG
		int32_t prefsBlockResult =
#endif
			prefs->seekBlock("MechCommander2");
		gosASSERT(prefsBlockResult == NO_ERROR);
		{
			int32_t filterSetting;
			int32_t result = prefs->readIdLong("FilterState", filterSetting);
			if(result == NO_ERROR)
			{
				switch(filterSetting)
				{
					default:
					case 0:
						FilterState = gos_FilterNone;
						break;
					case 1:
						FilterState = gos_FilterBiLinear;
						break;
					case 2:
						FilterState = gos_FilterTriLinear;
						break;
				}
			}
			result = prefs->readIdLong("TerrainTextureRes", TERRAIN_TXM_SIZE);
			if(result != NO_ERROR)
				TERRAIN_TXM_SIZE = 64;
			result = prefs->readIdLong("ObjectTextureRes", ObjectTextureSize);
			if(result != NO_ERROR)
				ObjectTextureSize = 128;
			result = prefs->readIdLong("Brightness", gammaLevel);
			if(result != NO_ERROR)
				gammaLevel = 0;
			// store volume settings in global variable since soundsystem
			// does not exist yet. These will be set in SoundSystem::init()
			result = prefs->readIdLong("DigitalMasterVolume", DigitalMasterVolume);
			if(result != NO_ERROR)
				DigitalMasterVolume = 255;
			result = prefs->readIdLong("MusicVolume", MusicVolume);
			if(result != NO_ERROR)
				MusicVolume = 64;
			result = prefs->readIdLong("RadioVolume", RadioVolume);
			if(result != NO_ERROR)
				RadioVolume = 64;
			result = prefs->readIdLong("SFXVolume", sfxVolume);
			if(result != NO_ERROR)
				sfxVolume = 64;
			result = prefs->readIdFloat("DoubleClickThreshold", doubleClickThreshold);
			if(result != NO_ERROR)
				doubleClickThreshold = 0.2f;
			result = prefs->readIdLong("DragThreshold", dragThreshold);
			if(result != NO_ERROR)
				dragThreshold = .016667;
			result = prefs->readIdULong("BaseVertexColor", BaseVertexColor);
			if(result != NO_ERROR)
				BaseVertexColor = 0x00000000;
			result = prefs->readIdBoolean("FullScreen", fullScreen);
			if(result != NO_ERROR)
				fullScreen = true;
			result = prefs->readIdLong("Rasterizer", renderer);
			if(result != NO_ERROR)
				renderer = 0;
			if((renderer < 0) || (renderer > 3))
				renderer = 0;
		}
	}
	prefs->close();
	delete prefs;
	prefs = nullptr;
	//-------------------------------
	// Used to output debug stuff!
	// Mondo COOL!
	// simply do this in the code and stuff goes to the file called mc2.output
	// DEBUG_STREAM << thing_you_want_to_output
	//
	// IMPORTANT NOTE:
	Stuff::InitializeClasses();
	MidLevelRenderer::InitializeClasses(8192 * 4, 1024, 0, 0, true);
	gosFX::InitializeClasses();
	gos_PushCurrentHeap(MidLevelRenderer::Heap);
	MidLevelRenderer::TGAFilePool* pool = new MidLevelRenderer::TGAFilePool("data\\Effects\\");
	MidLevelRenderer::MLRTexturePool::Instance = new MidLevelRenderer::MLRTexturePool(pool);
	MidLevelRenderer::MLRSortByOrder* cameraSorter = new MidLevelRenderer::MLRSortByOrder(MidLevelRenderer::MLRTexturePool::Instance);
	theClipper = new MidLevelRenderer::MLRClipper(0, cameraSorter);
	gos_PopCurrentHeap();
	//------------------------------------------------------
	// Start the GOS FX.
	gos_PushCurrentHeap(gosFX::Heap);
	gosFX::EffectLibrary::Instance = new gosFX::EffectLibrary();
	Check_Object(gosFX::EffectLibrary::Instance);
	FullPathFileName effectsName;
	effectsName.init(effectsPath, "mc2.fx", "");
	File effectFile;
	int32_t result = effectFile.open(effectsName);
	if(result != NO_ERROR)
		STOP(("Could not find MC2.fx"));
	int32_t effectsSize = effectFile.fileSize();
	puint8_t effectsData = (puint8_t)systemHeap->Malloc(effectsSize);
	effectFile.read(effectsData, effectsSize);
	effectFile.close();
	effectStream = new Stuff::MemoryStream(effectsData, effectsSize);
	gosFX::EffectLibrary::Instance->Load(effectStream);
	gosFX::LightManager::Instance = new gosFX::LightManager();
	gos_PopCurrentHeap();
	systemHeap->Free(effectsData);
	//------------------------------------------------
	// Fire up the MC Texture Manager.
	mcTextureManager = new MC_TextureManager;
	mcTextureManager->start();
	//Startup the vertex array pool
	mcTextureManager->startVertices(500000);
	//--------------------------------------------------
	// Setup Mouse Parameters from Prefs.CFG
	userInput = new UserInput;
	userInput->init();
	userInput->setMouseDoubleClickThreshold(doubleClickThreshold);
	userInput->setMouseDragThreshold(dragThreshold);
	userInput->initMouseCursors("cursors");
	userInput->setMouseCursor(mState_NORMAL);
	userInput->mouseOn();
	// now the sound system
	soundSystem = new GameSoundSystem;
	soundSystem->init();
	((SoundSystem*)soundSystem)->init("sound");
	sndSystem = soundSystem; // for things in the lib that use sound
	soundSystem->playDigitalMusic(LOGISTICS_LOOP);
	pLogData = new LogisticsData;
	pLogData->init();
	pMechlopedia = new Mechlopedia;
	pMechlopedia->init();
	pMechlopedia->begin();
}
Exemplo n.º 9
0
void TeamSensorSystem::operator delete(PVOID us)
{
	missionHeap->Free(us);
}
Exemplo n.º 10
0
void SensorSystemManager::operator delete(PVOID us)
{
	missionHeap->Free(us);
}
Exemplo n.º 11
0
void MultiPlayer::operator delete(PVOID us)
{
	systemHeap->Free(us);
}
Exemplo n.º 12
0
void WorldChunk::operator delete(PVOID us)
{
	systemHeap->Free(us);
}