Пример #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;
	}
}
Пример #2
0
void __stdcall TerminateGameEngine()
{
	if(pMechlopedia)
		delete pMechlopedia;
	if(userInput)
		delete userInput;
	if(soundSystem)
		delete soundSystem;
	if(pLogData)
		delete pLogData;
	//------------------------------------------------
	// shutdown the MC Texture Manager.
	if(mcTextureManager)
	{
		mcTextureManager->destroy();
		delete mcTextureManager;
		mcTextureManager = nullptr;
	}
	//--------------------------------------------------------------
	// End the SystemHeap and globalHeapList
	if(systemHeap)
	{
		systemHeap->destroy();
		delete systemHeap;
		systemHeap = nullptr;
	}
	if(globalHeapList)
	{
		globalHeapList->destroy();
		delete globalHeapList;
		globalHeapList = nullptr;
	}
	//----------------------------------------------------
	// Shutdown the MLR and associated stuff libraries
	//----------------------------------------------------
	gos_PushCurrentHeap(gosFX::Heap);
	delete effectStream;
	delete gosFX::LightManager::Instance;
	gos_PopCurrentHeap();
	//
	//-------------------
	// Turn off libraries
	//-------------------
	//
	gosFX::TerminateClasses();
	MidLevelRenderer::TerminateClasses();
	Stuff::TerminateClasses();
	//Redundant. Something else is shutting this down.
	//GOS sure does think its bad to delete something multiple times though.
	//Even though it simply never is!
	//gos_DeleteFont(gosFontHandle);
	gos_CloseResourceDLL(gosResourceHandle);
	//
	//--------------------------
	// Turn off the fast Files
	//--------------------------
	//
	FastFileFini();
}
Пример #3
0
void GoalManager::destroy (void) {

	if (goalObjectPool) {
		missionHeap->Free(goalObjectPool);
		goalObjectPool = NULL;
	}
	numGoalObjects = 0;
	goalObjectPoolSize = 0;
}
Пример #4
0
void GoalManager::setup (long poolSize) {

	goalObjectPoolSize = poolSize;
	if (goalObjectPoolSize  < 10)
		Fatal(0, " GoalManager.setup: goalObjectPoolSize must be greater than 10 ");

	goalObjectPool = (GoalObjectPtr)missionHeap->Malloc(sizeof(GoalObject) * goalObjectPoolSize);
	clear();
}
Пример #5
0
//---------------------------------------------------------------------------
long File::readRAW (unsigned long * &buffer, UserHeapPtr heap)
{
	long result = 0;
	
	if (fastFile && heap && fastFile->isLZCompressed())
	{
		long lzSizeNeeded = fastFile->lzSizeFast(fastFileHandle);
		buffer = (unsigned long *)heap->Malloc(lzSizeNeeded);

		result = fastFile->readFastRAW(fastFileHandle,buffer,lzSizeNeeded);
		logicalPosition += result;
	}
	
	return result;
}
Пример #6
0
long SensorSystemManager::init (bool debug) {

	if (MAX_SENSORS < 2)
		Fatal(0, " Way too few sensors in Sensor System Manager! ");

	sensorPool = (SensorSystemPtr*)missionHeap->Malloc(MAX_SENSORS * sizeof(SensorSystemPtr));
	gosASSERT(sensorPool!=NULL);

	for (long i = 0; i < MAX_SENSORS; i++)
		sensorPool[i] = new SensorSystem;

	//-----------------------------------------------------
	// This assumes we have at least 2 sensors in the pool
	// when initializing the pool...
	sensorPool[0]->id = 0;
	sensorPool[0]->prev = NULL;
	sensorPool[0]->next = sensorPool[1];

	for (i = 1; i < (MAX_SENSORS - 1); i++) {
		sensorPool[i]->id = i;
		sensorPool[i]->prev = sensorPool[i - 1];
		sensorPool[i]->next = sensorPool[i + 1];
	}

	sensorPool[MAX_SENSORS - 1]->id = MAX_SENSORS - 1;
	sensorPool[MAX_SENSORS - 1]->prev = sensorPool[MAX_SENSORS - 2];
	sensorPool[MAX_SENSORS - 1]->next = NULL;

	//------------------------------
	// All start on the free list...
	freeList = sensorPool[0];
	freeSensors = MAX_SENSORS;

	for (i = 0; i < MAX_TEAMS; i++)
		teamSensors[i] = NULL;

	Assert (!debug || (Team::numTeams > 0), 0, " SensorSystemManager.init: 0 teams ");

	for (i = 0; i < Team::numTeams; i++) {
		teamSensors[i] = new TeamSensorSystem;
		teamSensors[i]->teamId = i;
	}

	SensorSystem::numSensors = 0;

	return(NO_ERR);
}
Пример #7
0
void GoalObject::addLink (GoalObjectPtr gobject, GoalLinkType type) {

	GoalLinkPtr newLink = (GoalLink*)missionHeap->Malloc(sizeof(GoalLink));
	
}
Пример #8
0
void GoalObject::operator delete (void* us) {

	missionHeap->Free(us);
}
Пример #9
0
void* GoalObject::operator new (size_t ourSize) {

	void *result = missionHeap->Malloc(ourSize);
	return(result);
}
Пример #10
0
void WorldChunk::operator delete(PVOID us)
{
	systemHeap->Free(us);
}
Пример #11
0
void GameDebugWindow::operator delete(PVOID us)
{
    systemHeap->Free(us);
}
Пример #12
0
void SensorSystem::operator delete (void* us) {

	missionHeap->Free(us);
}
Пример #13
0
void ContactInfo::operator delete (void* us) {

	missionHeap->Free(us);
}	
Пример #14
0
PVOID MultiPlayer::operator new(size_t ourSize)
{
	PVOID result = systemHeap->Malloc(ourSize);
	return(result);
}
Пример #15
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();
}
Пример #16
0
void TeamSensorSystem::operator delete(PVOID us)
{
	missionHeap->Free(us);
}
Пример #17
0
PVOID TeamSensorSystem::operator new(size_t mySize)
{
	PVOID result = missionHeap->Malloc(mySize);
	return(result);
}
Пример #18
0
void SensorSystemManager::operator delete(PVOID us)
{
	missionHeap->Free(us);
}
Пример #19
0
void MultiPlayer::operator delete(PVOID us)
{
	systemHeap->Free(us);
}
Пример #20
0
void* ContactInfo::operator new (size_t ourSize) {

	void* result;
	result = missionHeap->Malloc(ourSize);
	return(result);
}
Пример #21
0
//---------------------------------------------------------------------------
void InitializeGameEngine()
{
	//---------------------------------------------------------------------
	float doubleClickThreshold = 0.2f;
	long dragThreshold = 10;

	Environment.Key_Exit=-1; // so escape doesn't kill your app

	//--------------------------------------------------------------
	// Read in System.CFG
	FitIniFilePtr systemFile = new FitIniFile;

#ifdef _DEBUG
	long systemOpenResult = 
#endif
		systemFile->open("system.cfg");
		   
#ifdef _DEBUG
	if( systemOpenResult != NO_ERR)
	{
		char Buffer[256];
		gos_GetCurrentPath( Buffer, 256 );
		STOP(( "Cannot find \"system.cfg\" file in %s",Buffer ));
	}
#endif

	{
#ifdef _DEBUG
		long systemBlockResult = 
#endif
			systemFile->seekBlock("systemHeap");
		gosASSERT(systemBlockResult == NO_ERR);
		{
			long result = systemFile->readIdULong("systemHeapSize",systemHeapSize);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdULong("guiHeapSize",guiHeapSize);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdULong("logisticsHeapSize",logisticsHeapSize);
			gosASSERT(result == NO_ERR);
		}

#ifdef _DEBUG
		long systemPathResult = 
#endif
			systemFile->seekBlock("systemPaths");
		gosASSERT(systemPathResult == NO_ERR);
		{
			long result = systemFile->readIdString("terrainPath",terrainPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("artPath",artPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("fontPath",fontPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("savePath",savePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("spritePath",spritePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("shapesPath",shapesPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("soundPath",soundPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("objectPath",objectPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("cameraPath",cameraPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("tilePath",tilePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("missionPath",missionPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("warriorPath",warriorPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("profilePath",profilePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("interfacepath",interfacePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("moviepath",moviePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("CDsoundPath",CDsoundPath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("CDmoviepath",CDmoviePath,79);
			gosASSERT(result == NO_ERR);

			result = systemFile->readIdString("CDspritePath",CDspritePath,79);
			gosASSERT(result == NO_ERR);
		}

#ifdef _DEBUG
		long fastFileResult = 
#endif
			systemFile->seekBlock("FastFiles");
		gosASSERT(fastFileResult == NO_ERR);
		{
			long result = systemFile->readIdLong("NumFastFiles",maxFastFiles);
			if (result != NO_ERR)
				maxFastFiles = 0;

			if (maxFastFiles)
			{
				fastFiles = (FastFile **)malloc(maxFastFiles*sizeof(FastFile *));
				memset(fastFiles,0,maxFastFiles*sizeof(FastFile *));

				long fileNum = 0;
				char fastFileId[10];
				char fileName[100];
				sprintf(fastFileId,"File%d",fileNum);
	
				while (systemFile->readIdString(fastFileId,fileName,99) == NO_ERR)
				{
					FastFileInit(fileName);
					fileNum++;
					sprintf(fastFileId,"File%d",fileNum);
					numFastFiles++;
				}
			}
		}
		
		long result = systemFile->seekBlock("UseMusic");
		if (result == NO_ERR)
			useMusic = TRUE;
		else
			useMusic = FALSE;
			
		result = systemFile->seekBlock("UseSound");
		if (result == NO_ERR)
		{
			useSound = TRUE;
		}
		else
		{
			useSound = FALSE;
			useMusic = FALSE;
		}
	}

	systemFile->close();
	delete systemFile;
	systemFile = NULL;

	//--------------------------------------------------------------
	// Read in Prefs.cfg
	FitIniFilePtr prefs = new FitIniFile;

#ifdef _DEBUG
	long prefsOpenResult = 
#endif
		prefs->open("prefs.cfg");

	gosASSERT (prefsOpenResult == NO_ERR);
	{
#ifdef _DEBUG
		long prefsBlockResult = 
#endif
			prefs->seekBlock("MechCommander2");
		gosASSERT(prefsBlockResult == NO_ERR);
		{
			long filterSetting;
			long result = prefs->readIdLong("FilterState",filterSetting);
			if (result == NO_ERR)
			{
				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_ERR)
				TERRAIN_TXM_SIZE = 64;

			result = prefs->readIdLong("Resolution",resolution);
			if (result != NO_ERR)
				resolution = 0;

			result = prefs->readIdLong("ObjectTextureRes",ObjectTextureSize);
			if (result != NO_ERR)
				ObjectTextureSize = 128;

			result = prefs->readIdLong("Difficulty",GameDifficulty);
			if (result != NO_ERR)
				GameDifficulty = 1;

			result = prefs->readIdLong("Brightness",gammaLevel);
			if (result != NO_ERR)
				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_ERR)
				DigitalMasterVolume = 255;

			result = prefs->readIdLong("MusicVolume",MusicVolume);
			if (result != NO_ERR)
				MusicVolume = 64;

			result = prefs->readIdLong("RadioVolume",RadioVolume);
			if (result != NO_ERR)
				RadioVolume = 64;

			result = prefs->readIdLong("SFXVolume",SFXVolume);
			if (result != NO_ERR)
				SFXVolume = 64;

			result = prefs->readIdFloat("DoubleClickThreshold",doubleClickThreshold);
			if (result != NO_ERR)
				doubleClickThreshold = 0.2f;

			result = prefs->readIdLong("DragThreshold",dragThreshold);
			if (result != NO_ERR)
				dragThreshold = 10;
				
			result = prefs->readIdULong("BaseVertexColor",BaseVertexColor);
			if (result != NO_ERR)
				BaseVertexColor = 0x00000000;
				
			result = prefs->readIdBoolean("UnlimitedAmmo",useUnlimitedAmmo);
			if (result != NO_ERR)
				useUnlimitedAmmo = true;
				
			result = prefs->readIdBoolean("RealLOS",useRealLOS);
			if (result != NO_ERR)
				useRealLOS = true;
		}
	}
	
	prefs->close();
	
	delete prefs;
	prefs = NULL;
	//---------------------------------------------------------------------

	switch (resolution)
	{
		case 0:			//640by480
			gos_SetScreenMode(640,480);
			break;

		case 1:			//800by600
			gos_SetScreenMode(800,600);
			break;

		case 2:			//1024by768
			gos_SetScreenMode(1024,768);
			break;

		case 3:			//1280by1024
			gos_SetScreenMode(1280,1024);
			break;

		case 4:			//1600by1200
			gos_SetScreenMode(1600,1200);
			break;
	}

	//--------------------------------------------------
	// Setup Mouse Parameters from Prefs.CFG
	//userInput = new UserInput;
	//userInput->init();
	//userInput->setMouseDoubleClickThreshold(doubleClickThreshold);
	//userInput->setMouseDragThreshold(dragThreshold);
	//--------------------------------------------------

	gosResourceHandle = gos_OpenResourceDLL("mc2res.dll");

	gosFontHandle = gos_LoadFont("assets\\graphics\\arial8.tga");

	globalFloatHelp = new FloatHelp [MAX_FLOAT_HELPS];

	//
	//----------------------------------
	// Start associated stuff.
	//----------------------------------
	Stuff::InitializeClasses();
	
	//--------------------------------------------------------------
	// Start the GUI Heap.
	systemHeap = new UserHeap;
	gosASSERT(systemHeap != NULL);
	
	systemHeap->init(systemHeapSize,"SYSTEM");
	
	//--------------------------------------------------------------
	// Start the GUI Heap.
	guiHeap = new UserHeap;
	gosASSERT(guiHeap != NULL);
	
	guiHeap->init(guiHeapSize,"GUI");
	
	//------------------------------------------------
	// Fire up the MC Texture Manager.
	mcTextureManager = new MC_TextureManager;
	mcTextureManager->start();

	//--------------------------------------------------------------
	// Load up the mouse cursors
	//userInput->initMouseCursors("cursors");
	//userInput->mouseOff();
	//userInput->setMouseCursor(mState_NORMAL);

	//------------------------------------------------
	// Give the Sound System a Whirl!
	//soundSystem = new GameSoundSystem;
	//soundSystem->init();
	//((SoundSystem *)soundSystem)->init("sound");
	
	//---------------------------------------------------------
	// Start the Mission, Scenario and Logistics classes here
	logistics = new Logistics;
	logistics->start(log_SPLASH);				//Always start with logistics in Splash Screen Mode
}
Пример #22
0
void* SensorSystem::operator new (size_t mySize) {

	void *result = missionHeap->Malloc(mySize);
	return(result);
}
Пример #23
0
void TerminateGameEngine()
{
	gosScript_ShutdownProcessor();

	//---------------------------------------------------------
	// End the Mission, Operation and Logistics classes here
	if (logistics)
	{
		logistics->destroy();
		delete logistics;
		logistics = NULL;
	}

	//-------------------------------------------------------------
	// Shut down the soundSytem for a change!
	//if (soundSystem)
	//{
	//	soundSystem->destroy();
	//
	//	delete soundSystem;
	//	soundSystem = NULL;
	//}

	//------------------------------------------------
	// shutdown the MC Texture Manager.
	if (mcTextureManager)
	{
		mcTextureManager->destroy();

		delete mcTextureManager;
		mcTextureManager = NULL;
	}

	//--------------------------------------------------------------
	// End the SystemHeap and globalHeapList
	if (systemHeap)
	{
		systemHeap->destroy();

		delete systemHeap;
		systemHeap = NULL;
	}

	if (globalHeapList)
	{
		globalHeapList->destroy();

		delete globalHeapList;
		globalHeapList = NULL;
	}

	//----------------------------------------------------
	// Shutdown the MLR and associated stuff libraries
	//----------------------------------------------------

	//
	//-------------------
	// Turn off libraries
	//-------------------
	//
	Stuff::TerminateClasses();

	//Redundant.  Something else is shutting this down.
	//GOS sure does think its bad to delete something multiple times though.
	//Even though it simply never is!
	//gos_DeleteFont(gosFontHandle);

	gos_CloseResourceDLL(gosResourceHandle);

	//
	//--------------------------
	// Turn off the fast Files
	//--------------------------
	//
	FastFileFini();
}
Пример #24
0
PVOID GameDebugWindow::operator new(size_t ourSize)
{
    PVOID result = systemHeap->Malloc(ourSize);
    return(result);
}
Пример #25
0
void GoalManager::operator delete (void* us) {

	missionHeap->Free(us);
}
Пример #26
0
//-----------------------------
int32_t APIENTRY WinMain(
	HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int32_t nCmdShow)
{
	WNDCLASS wc;
	if (!hPrevInstance)
	{
		wc.style		 = CS_HREDRAW | CS_VREDRAW;
		wc.lpfnWndProc   = (WNDPROC)WndProc;
		wc.cbClsExtra	= 0;
		wc.cbWndExtra	= 0;
		wc.hInstance	 = hInstance;
		wc.hIcon		 = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
		wc.hCursor		 = LoadCursor(nullptr, IDC_ARROW);
		wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
		wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1);
		wc.lpszClassName = lpszAppName;
		if (RegisterClass(&wc) == 0)
			return false;
	}
	hInst = hInstance;
	char appTitle[1024];
	sprintf(appTitle, "MechCommander 2 Data Editor %s", versionStamp);
	appWnd = CreateWindow(lpszAppName, appTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
		640, 480, nullptr, nullptr, hInstance, nullptr);
	if (appWnd == nullptr)
		return false;
	globalHeapList = new HeapList;
	assert(globalHeapList != nullptr);
	systemHeap = new UserHeap;
	assert(systemHeap != nullptr);
	systemHeap->init(2048000);
	//---------------------------------------------------------
	// Start the Tiny Geometry Layer Heap.
	TG_Shape::tglHeap = new UserHeap;
	TG_Shape::tglHeap->init(tglHeapSize, "TinyGeom");
	//--------------------------------------------------------------
	// Read in System.CFG
	FitIniFilePtr systemFile = new FitIniFile;
#ifdef _DEBUG
	int32_t systemOpenResult =
#endif
		systemFile->open("system.cfg");
#ifdef _DEBUG
	assert(systemOpenResult == NO_ERROR);
#endif
	{
#ifdef _DEBUG
		int32_t systemPathResult =
#endif
			systemFile->seekBlock("systemPaths");
		assert(systemPathResult == NO_ERROR);
		{
			int32_t result = systemFile->readIdString("terrainPath", terrainPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("artPath", artPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("fontPath", fontPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("savePath", savePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("spritePath", spritePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("shapesPath", shapesPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("soundPath", soundPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("objectPath", objectPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("cameraPath", cameraPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("tilePath", tilePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("missionPath", missionPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("warriorPath", warriorPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("profilePath", profilePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("interfacepath", interfacePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("moviepath", moviePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("tglpath", tglPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("texturepath", texturePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("CDsoundPath", CDsoundPath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("CDmoviepath", CDmoviePath, 79);
			assert(result == NO_ERROR);
			result = systemFile->readIdString("CDspritePath", CDspritePath, 79);
			assert(result == NO_ERROR);
		}
	}
	systemFile->close();
	delete systemFile;
	systemFile = nullptr;
	//
	// Init GameOS with window created
	//
	// InitGameOS( hInstance, appWnd, lpCmdLine );
	Platform = Platform_DLL;
	//-------------------------------------------------------------
	// 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, ".\\");
	//-------------------------------------------------------
	// Check if we are running this from the command line
	// with ASE2TGL as the command line parameter. If so,
	// for each .INI file in data\tgl, find the corresponding
	// .ASE file and convert to .TGL. Then Exit!
	silentMode = true;
	memset(fileName, 0, sizeof(fileName));
	memset(listName, 0, sizeof(listName));
	ParseCommandLine(lpCmdLine);
	// Initialize COM and create an instance of the InterfaceImplementation
	// class:
	CoInitialize(nullptr);
	armProvider = CreateProviderEngine("AseConv", versionStamp);
	assert(armProvider);
	if (listName[0] == 0)
	{
		convertASE2TGL(fileName);
	}
	else
	{
		//
		// A list file was provided
		//
		File file;
		if (file.open(listName) == NO_ERROR)
		{
			while (!file.eof())
			{
				char line[1024];
				file.readLine((puint8_t)line, 1024);
				if (line[0] != 0)
					convertASE2TGL(line);
			}
			file.close();
		}
	}
	/*
	//Time BOMB goes here.
	// Set Date and write Binary data to registry under key
	// GraphicsDataInit!!
	SYSTEMTIME bombDate;
	uint32_t dataSize = sizeof(SYSTEMTIME);
	gos_LoadDataFromRegistry("GraphicsDataInit", &bombDate, &dataSize);
	if (dataSize == 0)
	{
	bombDate.wYear = 2001;
	bombDate.wMonth = 3;
	bombDate.wDayOfWeek = 4;
	bombDate.wDay = 31;
	bombDate.wHour = 0;
	bombDate.wMinute = 0;
	bombDate.wSecond = 0;
	bombDate.wMilliseconds = 0;

	dataSize = sizeof(SYSTEMTIME);
	gos_SaveDataToRegistry("GraphicsDataInit", &bombDate, dataSize);
	}
	*/
	//
	// Exit app
	//
	CoUninitialize();
	// ExitGameOS();
	return 0;
}
Пример #27
0
PVOID WorldChunk::operator new(size_t ourSize)
{
	PVOID result = systemHeap->Malloc(ourSize);
	return(result);
}