Beispiel #1
0
//---------------------------------------------------------------------------
int32_t ObjectType::init(FitIniFilePtr objFile)
{
	int32_t result = 0;
	result = objFile->seekBlock("ObjectType");
	if(result != NO_ERROR)
		return(result);
	numUsers = 0;
	//--------------------------------------------------------------------
	// Read in the rest of the Object type Data here.  This includes
	// exposions, collision extents, etc.
	char apprName[512];
	result = objFile->readIdString("AppearanceName", apprName, 511);
	if(result == NO_ERROR)
	{
		appearName = (PSTR)ObjectTypeManager::objectTypeCache->Malloc(strlen(apprName) + 1);
		strcpy(appearName, apprName);
	}
	result = objFile->readIdLong("ExplosionObject", explosionObject);
	if(result != NO_ERROR)
		return(result);
	result = objFile->readIdLong("DestroyedObject", destroyedObject);
	if(result != NO_ERROR)
		return(result);
	result = objFile->readIdFloat("ExtentRadius", extentRadius);
	if(result != NO_ERROR)
		extentRadius = 0.0f;
	result = objFile->readIdLong("IconNumber", iconNumber);
	if(result != NO_ERROR)
		iconNumber = -1;
	keepMe = true;					//Never cache out anymore!
	teamId = -1;		//Everything starts out Neutral now.
	return(NO_ERROR);
}
Beispiel #2
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;
}
Beispiel #3
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
}