예제 #1
0
void LogisticsSaveDialog::setMission( const char* fileName)
{
	if ( strlen( fileName ) )
	{

		long textureHandle = MissionBriefingScreen::getMissionTGA( fileName );

		statics[MAP_STATIC].setTexture( textureHandle );
		statics[MAP_STATIC].setUVs( 0, 127, 127, 0);
		statics[MAP_STATIC].setColor( 0xffffffff );

		FullPathFileName path;
		FitIniFile file;

		path.init( missionPath, fileName, ".fit" );

		if ( NO_ERR == file.open( path ) )
		{
			char missionName[256];
			missionName[0] = 0;
			bool bRes = 0;

			file.seekBlock( "MissionSettings" );
			file.readIdBoolean( "MissionNameUseResourceString", bRes );
			if ( bRes )
			{
				unsigned long lRes;
				file.readIdULong( "MissionNameResourceStringID", lRes );
				cLoadString(lRes, missionName, 255);
			}
			else
			{
				file.readIdString("MissionName", missionName, 255);
			}

			textObjects[2].setText(missionName);

		}
		else
		{
			textObjects[2].setText( "" );
		}

	}
	else
	{
		statics[MAP_STATIC].setColor( 0 );
		textObjects[2].setText( "" );

	}

}
예제 #2
0
//----------------------------------------------------------------------------------
void initColorTables (void)
{
	FullPathFileName colorPath;
	colorPath.init(cameraPath,"colors",".fit");

	FitIniFile colorFile;
	long result = colorFile.open(colorPath);
	gosASSERT(result == NO_ERR);

	result = colorFile.seekBlock("Main");
	gosASSERT(result == NO_ERR);

	result = colorFile.readIdLong("NumTables",numColorRGBTables);
	gosASSERT(result == NO_ERR);

	colorRGBLookup = (DWORD **)systemHeap->Malloc(sizeof(DWORD *) * numColorRGBTables);
	gosASSERT(colorRGBLookup != NULL);

	memset(colorRGBLookup,0,sizeof(DWORD *) * numColorRGBTables);

	for (long i=0;i<numColorRGBTables;i++)
	{
		char tableBlock[256];
		sprintf(tableBlock,"Table%d",i);

		result = colorFile.seekBlock(tableBlock);
		gosASSERT(result == NO_ERR);

		colorRGBLookup[i] = (DWORD *)systemHeap->Malloc(sizeof(DWORD) * MAX_COLOR_ENTRIES);
		gosASSERT(colorRGBLookup[i] != NULL);

		DWORD *table = colorRGBLookup[i];

		for (long j=0;j<MAX_COLOR_ENTRIES;j++)
		{
			char colorBlock[256];
			sprintf(colorBlock,"Color%d",j);

			result = colorFile.readIdULong(colorBlock,table[j]);
			gosASSERT(result == NO_ERR);
		}
	}

	colorFile.close();
}	
예제 #3
0
void MPLoadMap::getMapNameFromFile( const char* pFileName, char* missionName, long bufferLength )
{
	FullPathFileName path;
	path.init( missionPath, pFileName, ".fit" );

	FitIniFile file;

	if ( NO_ERR != file.open( (char*)(const char*)path ) )
	{
		char errorStr[256];
		sprintf( errorStr, "couldn't open file %s", path );
		Assert( 0, 0, errorStr );
	}

	
	long result = file.seekBlock( "MissionSettings" );
	Assert( result == NO_ERR, 0, "Coudln't find the mission settings block in the mission file" );

	missionName[0] = 0;
	bool bRes = 0;

	result = file.readIdBoolean( "MissionNameUseResourceString", bRes );
	//Assert( result == NO_ERR, 0, "couldn't find the MissionNameUseResourceString" );
	if ( bRes )
	{
		unsigned long lRes;
		result = file.readIdULong( "MissionNameResourceStringID", lRes );
		Assert( result == NO_ERR, 0, "couldn't find the MissionNameResourceStringID" );
		cLoadString( lRes, missionName, bufferLength );
	}
	else
	{
		result = file.readIdString( "MissionName", missionName, bufferLength );
		Assert( result == NO_ERR, 0, "couldn't find the missionName" );
	}
}
예제 #4
0
//---------------------------------------------------------------------------
long SoundSystem::init (char *soundFileName)
{
	if (useSound)
	{
		FullPathFileName soundName;
		soundName.init(soundPath,soundFileName,".snd");
		
		FitIniFile soundFile;
		long result = soundFile.open(soundName);
		gosASSERT(result == NO_ERR);

		result = soundFile.seekBlock("SoundSetup");
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdULong("soundHeapSize",soundHeapSize);
		gosASSERT(result == NO_ERR);
		
		result = soundFile.readIdFloat("MaxSoundDistance",maxSoundDistance);
		gosASSERT(result == NO_ERR);

		soundHeap = new UserHeap;
		gosASSERT(soundHeap != NULL);

		result = soundHeap->init(soundHeapSize,"SOUND");
		gosASSERT(result == NO_ERR);

		//-----------------------------------------------------------------------
		// Startup the Sound packet File with the sound Blocks in it.
		// This works by sound ID.  The sound ID is the packet number.
		// When ordered to play a sample, the sound system check to see if that
		// sound ID is in the cache.  If not, it is loaded.  If there is no more
		// room, any idle sounds are flushed in order of priority.
		soundDataFile = new PacketFile;
		gosASSERT(soundDataFile != NULL);
		
		FullPathFileName soundDataPath;
		soundDataPath.init(CDsoundPath,soundFileName,".pak");
		
		result = soundDataFile->open(soundDataPath);
		gosASSERT(result == NO_ERR);
		
		bettyDataFile = new PacketFile;
		gosASSERT(bettyDataFile != NULL);
		
		FullPathFileName bettyDataPath;
		bettyDataPath.init(CDsoundPath,"Betty",".pak");
		
		result = bettyDataFile->open(bettyDataPath);
		gosASSERT(result == NO_ERR);

		numBettySamples = bettyDataFile->getNumPackets();
		
		supportDataFile = new PacketFile;
		gosASSERT(supportDataFile != NULL);
		
		FullPathFileName supportDataPath;
		supportDataPath.init(CDsoundPath,"support",".pak");
		
		result = supportDataFile->open(supportDataPath);
		gosASSERT(result == NO_ERR);

		numSupportSamples = supportDataFile->getNumPackets();
 		//-----------------------------------------------------------------------
		// Load all of the sound Bite data.  Do not load actual packet unless
		// preload field is TRUE.
		result = soundFile.seekBlock("SoundBites");
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdULong("numBites",numSoundBites);
		gosASSERT(result == NO_ERR);

		//-----------------------------------------------------------------------
		// Preallocate SoundBites
		sounds = (SoundBite *)soundHeap->Malloc(sizeof(SoundBite) * numSoundBites);
		gosASSERT(sounds != NULL);
		memset(sounds,0,sizeof(SoundBite) * numSoundBites);
		
		for (long i=0;i<(long)numSoundBites;i++)
		{
			char biteBlock[20];
			sprintf(biteBlock,"SoundBite%d",i);
			
			result = soundFile.seekBlock(biteBlock);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdULong("priority",sounds[i].priority);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdULong("cache",sounds[i].cacheStatus);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdULong("soundId",sounds[i].soundId);
			gosASSERT(result == NO_ERR);
			
			preloadSoundBite(i);		//ALWAYS Preload!!!!!!!!!!!!!

			result = soundFile.readIdFloat("volume",sounds[i].volume);
			gosASSERT(result == NO_ERR);
		}		

		//---------------------------------------------------------------
		// Load the digital Music Data Strings
		result = soundFile.seekBlock("DigitalMusic");
		gosASSERT(result == NO_ERR);
			
		result = soundFile.readIdLong("NumDMS",numDMS);
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdFloat("StreamFadeDownTime",streamFadeDownTime);
		gosASSERT(result == NO_ERR);

		result = soundFile.readIdULong("StreamBitDepth",digitalStreamBitDepth);
		gosASSERT(result == NO_ERR);
			
		result = soundFile.readIdULong("StreamChannels",digitalStreamChannels);
		gosASSERT(result == NO_ERR);

		digitalMusicIds = (char **)soundHeap->Malloc(sizeof(char *) * numDMS);
		gosASSERT(digitalMusicIds != NULL);
			
		digitalMusicLoopFlags = (bool *)soundHeap->Malloc(sizeof(bool)*numDMS);
		gosASSERT(digitalMusicLoopFlags != NULL);

		digitalMusicVolume = (float *)soundHeap->Malloc(sizeof(float) * numDMS);
			
		for (i=0;i<numDMS;i++)
		{
			char digitalMSId[20];
			sprintf(digitalMSId,"DMS%d",i);
			
			char digitalMSBId[20];
			sprintf(digitalMSBId,"DMSLoop%d",i);

			char digitalMSVId[25];
			sprintf(digitalMSVId,"DMSVolume%d",i);
			
			digitalMusicIds[i] = (char *)soundHeap->Malloc(30);
			result = soundFile.readIdString(digitalMSId,digitalMusicIds[i],29);
			gosASSERT(result == NO_ERR);
			
			result = soundFile.readIdBoolean(digitalMSBId,digitalMusicLoopFlags[i]);
			gosASSERT(result == NO_ERR);

			result = soundFile.readIdFloat(digitalMSVId,digitalMusicVolume[i]);
			if (result != NO_ERR)
				digitalMusicVolume[i] = 1.0f;
		}	
		
		soundFile.close();
		
		for (i=0;i<MAX_DIGITAL_SAMPLES+4;i++)
		{
			gosAudio_AllocateChannelSliders(i,gosAudio_Volume | gosAudio_Panning);
		}
	}
	
	digitalMasterVolume = float(DigitalMasterVolume) / 256.0f;
	SFXVolume = float(sfxVolume) / 256.0f;
	musicVolume = float(MusicVolume) / 256.0f;
	radioVolume = float(RadioVolume) / 256.0f;
	bettyVolume = float(BettyVolume) / 256.0f;

	stream1Id = stream2Id = 0;

	return(NO_ERR);
}
void MissionBriefingScreen::begin()
{
	missionListBox.removeAllItems( true );

	runTime = 0;
	bClicked = 0;

	statics[VIDEO_SCREEN].setColor( 0 );

	memset( objectiveButtons, 0, sizeof ( aObject* ) * MAX_OBJECTIVES );
	// need to set up all pertinent mission info
	EString missionName = LogisticsData::instance->getCurrentMission();


	long tmpMapTextureHandle = getMissionTGA(missionName);
	statics[MAP_INDEX].setTexture( tmpMapTextureHandle );
	statics[MAP_INDEX].setUVs( 0, 127, 127, 0 );
	statics[MAP_INDEX].setColor( 0xffffffff );


	// need to get all the objectives and stuff
	FullPathFileName fitPath;
	fitPath.init(missionPath, missionName, ".fit");
	FitIniFile fitFile;
	fitFile.open( fitPath );

	// put initial divider in list box
	addItem(IDS_MN_DIVIDER, 0xff005392, -1);

	fitFile.seekBlock( "MissionSettings" );

	long result = fitFile.seekBlock( "MissionSettings" );
	Assert( result == NO_ERR, 0, "Coudln't find the mission settings block in the mission file" );

	bool bRes;
	result = fitFile.readIdBoolean( "MissionNameUseResourceString", bRes );
	Assert( result == NO_ERR, 0, "couldn't find the MissionNameUseResourceString" );
	if ( bRes )
	{
		unsigned long ulRes;
		result = fitFile.readIdULong( "MissionNameResourceStringID", ulRes );
		Assert( result == NO_ERR, 0, "couldn't find the MissionNameResourceStringID" );
		addItem(ulRes, 0xff005392, -1);
	}
	else
	{
		char missionName[256];
		fitFile.readIdString("MissionName", missionName, 255);
		addLBItem(missionName, 0xff005392, -1);

	}

	addItem(IDS_MN_DIVIDER, 0xff005392, -1);
	addItem( IDS_MN_MISSION_OBJECTIVES, 0xff005392, -1 );
	addItem(IDS_MN_DIVIDER, 0xff005392, -1);

	// put in primary objectives
	fitFile.seekBlock( "Team0Objectives" );
	unsigned long objectiveCount;
	fitFile.readIdULong( "NumObjectives", objectiveCount );
	bool bHasSecondary = 0;
	int count = 0; 

	fitFile.seekBlock( "Terrain" );
	float terrainExtentX;
	float terrainExtentY;
	fitFile.readIdFloat( "TerrainMinX", terrainExtentX );
	if ( !terrainExtentX )
		terrainExtentX = 120 * 128;
	fitFile.readIdFloat( "TerrainMinY", terrainExtentY );
	if ( !terrainExtentY )
		terrainExtentY = 120 * 128;

	CObjectives Objectives(0/*alignment*/);
	/*Note that ObjectManager is probably NULL as these objectives are read, so it's not
	cool to call any of the Status() functions of this instance of objectives (access violation
	may ensue).*/
	Objectives.Read(&fitFile);

	gosASSERT( Objectives.Count() < MAX_OBJECTIVES );

	int buttonCount = 0;

	for ( int j = 1; j < 3; j++ )
	{
		CObjectives::EIterator it = Objectives.Begin();
		buttonCount = 0;
		for ( int i = 0; i < Objectives.Count(); i++, it++ )
		{
			CObjective *pObjective = (*it);
			if ( (!pObjective->IsHiddenTrigger()) && (pObjective->IsActive()) )
			{
				
				if ( pObjective->Priority() == j )
				{
					addObjectiveButton( pObjective->MarkerX(), pObjective->MarkerY(), buttonCount,pObjective->Priority(), fabs(terrainExtentX),
									fabs(terrainExtentY), pObjective->DisplayMarker());

					if ( j == 0 )
					{
						bHasSecondary = true;
						if ( i == 0 )
							addItem( IDS_MN_DIVIDER, 0xff005392, -1 );
					}

					addLBItem( (pObjective->LocalizedDescription()).Data(), 0xffffffff, count );

					objectiveModels[count] = (pObjective->ModelName()).Data();
					modelTypes[count] = pObjective->ModelType();

					modelColors[count][0] = pObjective->ModelBaseColor();
					modelColors[count][1] = pObjective->ModelHighlightColor();
					modelColors[count][2] = pObjective->ModelHighlightColor2();
					modelScales[count] = pObjective->ModelScale();

					count++;
					buttonCount++;
				}
			}
		}
	}
	
	addItem( IDS_MN_DIVIDER, 0xff005392, -1 );

	fitFile.seekBlock( "MissionSettings" );

	char blurb[4096];
	result = fitFile.readIdString("Blurb", blurb, 4095 );

	bool tmpBool = false;
	result = fitFile.readIdBoolean("BlurbUseResourceString", tmpBool);
	if (NO_ERR == result && tmpBool )
	{
		unsigned long tmpInt = 0;
		result = fitFile.readIdULong("BlurbResourceStringID", tmpInt);
		if (NO_ERR == result)
		{
			cLoadString( tmpInt, blurb, 2047 );
		}
	}


	addLBItem( blurb, 0xff005392, -1 );

	int RP = LogisticsData::instance->getCBills();
	char text[32];
	sprintf( text, "%ld ", RP );
	textObjects[RP_INDEX].setText( text );

	// need to find a drop zone, because our designers were never convinced to place
	// 'em explicitly, we need to do it for them
	int i = 1;
	while( true )
	{
		char blockName[32];
		sprintf( blockName, "Part%ld", i );
		i++;
		if ( NO_ERR != fitFile.seekBlock( blockName ) )
			break;
		
		bool bPlayer = 0;
		fitFile.readIdBoolean( "PlayerPart", bPlayer );

		if ( bPlayer )
		{
			float fX;
			float fY;

			fitFile.readIdFloat( "PositionX", fX );
			fitFile.readIdFloat( "PositionY", fY );

			setupDropZone( fX, fY, fabs(terrainExtentX), fabs(terrainExtentY) );
		
			break;
		}
	}

	statics[BUTTON_TEXT].showGUIWindow( 0 );
	status = RUNNING;

}
예제 #6
0
//---------------------------------------------------------------------------
long GateType::init (FilePtr objFile, unsigned long fileSize)
{
	long result = 0;
	
	FitIniFile bldgFile;
	result = bldgFile.open(objFile,fileSize);
	if (result != NO_ERR)
		return(result);
	
	//------------------------------------------------------------------
	// Read in the data needed for the Gates
	result = bldgFile.seekBlock("GateData");
	if (result != NO_ERR)
		return(result);

	result = bldgFile.readIdULong("DmgLevel",dmgLevel);
	if (result != NO_ERR)
		return(result);

	bldgFile.readIdULong("BlownEffectId",blownEffectId);
	if (result != NO_ERR)
		blownEffectId = -1;
		
	bldgFile.readIdULong("NormalEffectId",normalEffectId);
	if (result != NO_ERR)
		normalEffectId = -1;
		
	bldgFile.readIdULong("DamageEffectId",damageEffectId);
	if (result != NO_ERR)
		damageEffectId = -1;

	result = bldgFile.readIdLong("BasePixelOffsetX",basePixelOffsetX);
	if (result != NO_ERR)
		basePixelOffsetX = 0;
	
	result = bldgFile.readIdLong("BasePixelOffsetY",basePixelOffsetY);
	if (result != NO_ERR)	
		basePixelOffsetY = 0;

	result = bldgFile.readIdFloat("ExplosionRadius",explRad);
	if (result != NO_ERR)
		explRad = 0.0;
		
	result = bldgFile.readIdFloat("ExplosionDamage",explDmg);
	if (result != NO_ERR)
		explDmg = 0.0;

	result = bldgFile.readIdFloat("OpenRadius",openRadius);
	if (result != NO_ERR)
		return(result);

	result = bldgFile.readIdFloat("LittleExtent",littleExtent);
	if (result != NO_ERR)
		littleExtent = 20.0;

	result = bldgFile.readIdLong ("BuildingName", gateTypeName);
	if (result != NO_ERR)
		gateTypeName = IDS_BLDOBJ_NAME;

	result = bldgFile.readIdLong( "BuildingDescription", buildingDescriptionID );
	if ( result != NO_ERR )
			buildingDescriptionID = -1;


	result = bldgFile.readIdBoolean("BlocksLineOfFire",blocksLineOfFire);
	if (result != NO_ERR)
		blocksLineOfFire = FALSE;

	//------------------------------------------------------------------
	// Initialize the base object Type from the current file.
	result = ObjectType::init(&bldgFile);
	return(result);
}
예제 #7
0
long GateType::init (FilePtr objFile, unsigned long fileSize, const char* builName)
{
	long result = 0;
	//magic 24022011 begin
	//char tmp1[16]; //magic 29112011 disabled
	//sprintf( tmp1, "%ld", objFile ); //magic 29112011 disabled
	//char tmp2[256];
	//FitIniFile MtestFile;
	//MtestFile.open("data\\vehicle_load.fit", CREATE);
	//MtestFile.writeBlock( tmp1 );
	//MtestFile.writeBlock( vehicleName );
	//MtestFile.close();
	FitIniFile bldgFile;
	FitIniFile objTypeFile;
	
	result = objTypeFile.open(objFile, fileSize);
	if (result != NO_ERR)
	{
		FullPathFileName mFullFileName;
		mFullFileName.init(objectPath, builName, ".fit");
		//FitIniFile objTypeFile;
		//MtestFile.writeBlock( mFullFileName );
		//MtestFile.close();

		long result1 = bldgFile.open(mFullFileName);
		if (result1 != NO_ERR)
		{
			Fatal(objTypeNum, " BuildingType.init1: can't open building file ");
		}
	}
	else
		bldgFile.open(objFile, fileSize);

	objTypeFile.close();

	//magic 24022011 end	
	/*FitIniFile bldgFile;
	result = bldgFile.open(objFile,fileSize);
	if (result != NO_ERR)
		return(result);*/
	
	//------------------------------------------------------------------
	// Read in the data needed for the Gates
	result = bldgFile.seekBlock("GateData");
	if (result != NO_ERR)
		return(result);

	result = bldgFile.readIdULong("DmgLevel",dmgLevel);
	if (result != NO_ERR)
		return(result);

	bldgFile.readIdULong("BlownEffectId",blownEffectId);
	if (result != NO_ERR)
		blownEffectId = -1;
		
	bldgFile.readIdULong("NormalEffectId",normalEffectId);
	if (result != NO_ERR)
		normalEffectId = -1;
		
	bldgFile.readIdULong("DamageEffectId",damageEffectId);
	if (result != NO_ERR)
		damageEffectId = -1;

	result = bldgFile.readIdLong("BasePixelOffsetX",basePixelOffsetX);
	if (result != NO_ERR)
		basePixelOffsetX = 0;
	
	result = bldgFile.readIdLong("BasePixelOffsetY",basePixelOffsetY);
	if (result != NO_ERR)	
		basePixelOffsetY = 0;

	result = bldgFile.readIdFloat("ExplosionRadius",explRad);
	if (result != NO_ERR)
		explRad = 0.0;
		
	result = bldgFile.readIdFloat("ExplosionDamage",explDmg);
	if (result != NO_ERR)
		explDmg = 0.0;

	result = bldgFile.readIdFloat("OpenRadius",openRadius);
	if (result != NO_ERR)
		return(result);

	result = bldgFile.readIdFloat("LittleExtent",littleExtent);
	if (result != NO_ERR)
		littleExtent = 20.0;

	result = bldgFile.readIdLong ("BuildingName", gateTypeName);
	if (result != NO_ERR)
		gateTypeName = IDS_BLDOBJ_NAME;

	result = bldgFile.readIdLong( "BuildingDescription", buildingDescriptionID );
	if ( result != NO_ERR )
			buildingDescriptionID = -1;


	result = bldgFile.readIdBoolean("BlocksLineOfFire",blocksLineOfFire);
	if (result != NO_ERR)
		blocksLineOfFire = FALSE;

	//magic 09092011 begin
	char s[255];
	result = bldgFile.readIdString("Name",s,254); //magic 09092011
	strcpy_s(buildingName, s);//magic 09092011

	//magic 09092011 end

	//------------------------------------------------------------------
	// Initialize the base object Type from the current file.
	result = ObjectType::init(&bldgFile);
	return(result);
}
예제 #8
0
void LogisticsMapInfoDialog::setMap( const char* pFileName )
{
	long textureHandle = MissionBriefingScreen::getMissionTGA( pFileName );
	statics[10].setTexture( textureHandle );
	statics[10].setUVs( 0, 127, 127, 0  );
	statics[10].setColor( 0xffffffff );

	// need to set all the map info too....

		FitIniFile file;
		FullPathFileName path;
		path.init( missionPath, pFileName, ".fit" );

		if ( NO_ERR == file.open( path ) )
		{
		
			char missionName[256];
			char text[1024];
			missionName[0] = 0;
			char text2[1024];
			bool bRes = 0;

			char totalText[1024];

			file.seekBlock( "MissionSettings" );
			file.readIdBoolean( "MissionNameUseResourceString", bRes );
			if ( bRes )
			{
				unsigned long lRes;
				file.readIdULong( "MissionNameResourceStringID", lRes );
				cLoadString(lRes, missionName, 255);
			}
			else
			{
				file.readIdString("MissionName", missionName, 255);
			}
	
			cLoadString( IDS_MP_LM_MAP_LIST_MAP_NAME, text, 255 );
			sprintf(text2, text, missionName);

			sprintf( totalText, text2 );
			strcat( totalText, "\n" );

				unsigned long type = 0;
			file.readIdULong( "MissionType", type );
			cLoadString( IDS_MP_LM_MAP_LIST_TYPE, text, 255 );
			char mType[128];
			cLoadString( IDS_MP_LM_TYPE0 + type, mType, 127 );
			
			sprintf( text2, text, mType );

			strcat( totalText, text2 );
			strcat( totalText, "\n" );

			unsigned long numPlayers = 2;

			file.readIdULong( "MaximumNumberOfPlayers", numPlayers );
			cLoadString( IDS_MP_LM_MAP_LIST_MAX_PLAYERS, text, 255 );
			sprintf( text2, text, numPlayers );

			strcat( totalText, text2 );
			strcat( totalText, "\n" );

			textObjects[1].setText( totalText );

			char blurb[1024];
			long result = file.readIdString("Blurb2", blurb, 1023 );

			bool tmpBool = false;
			result = file.readIdBoolean("Blurb2UseResourceString", tmpBool);
			if (NO_ERR == result && tmpBool )
			{
				unsigned long tmpInt = 0;
				result = file.readIdULong("Blurb2ResourceStringID", tmpInt);
				if (NO_ERR == result)
				{
					cLoadString( tmpInt, blurb, 1024 );
				}
			}

			textObjects[2].setText( blurb );

		}

}
예제 #9
0
void MPLoadMap::updateMapInfo()
{
	int sel = mapList.GetSelectedItem();
	if ( sel != -1 )
	{

		FitIniFile file;
		FullPathFileName path;
		const char* fileName = ((aTextListItem*)mapList.GetItem( sel ))->getText();
		selMapName = ((aLocalizedListItem*)mapList.GetItem(sel))->getHiddenText();
		path.init( missionPath, selMapName, ".fit" );

		if ( NO_ERR == file.open( path ) )
		{
			
			char missionName[256];
			missionName[0] = 0;
			bool bRes = 0;

			char text[1024];
			char text2[1024];

			file.seekBlock( "MissionSettings" );
			file.readIdBoolean( "MissionNameUseResourceString", bRes );
			if ( bRes )
			{
				unsigned long lRes;
				file.readIdULong( "MissionNameResourceStringID", lRes );
				cLoadString( lRes, missionName, 255 );
			}
			else
			{
				file.readIdString( "MissionName", missionName, 255 );
			}

			long textureHandle = MissionBriefingScreen::getMissionTGA( selMapName );
			statics[18].setTexture( textureHandle );
			statics[18].setUVs( 0, 127, 127, 0 );
			statics[18].setColor( 0xffffffff );
 
			cLoadString( IDS_MP_LM_MAP_LIST_MAP_NAME, text, 255 );
			sprintf( text2, text, missionName );
			textObjects[3].setText( text2 );

			if ( !bIsSingle )
			{
				unsigned long type = 0;
				file.readIdULong( "MissionType", type );
				cLoadString( IDS_MP_LM_MAP_LIST_TYPE, text, 255 );
				char mType[128];
				cLoadString( IDS_MP_LM_TYPE0 + type, mType, 127 );
				
				sprintf( text2, text, mType );
				textObjects[4].setText( text2 );
			
	
				unsigned long numPlayers = 0;
				file.readIdULong( "MaximumNumberOfPlayers", numPlayers );

				cLoadString( IDS_MP_LM_MAP_LIST_MAX_PLAYERS, text, 255 );
				sprintf( text2, text, numPlayers );
				textObjects[2].setText( text2 );
			}
			else
			{
				textObjects[4].setText( "" );
				textObjects[2].setText( "" );
			}

			char blurb[1024];
			blurb[0] = 0;
			long result = file.readIdString("Blurb2", blurb, 1023 );

			bool tmpBool = false;
			result = file.readIdBoolean("Blurb2UseResourceString", tmpBool);
			if (NO_ERR == result && tmpBool )
			{
				unsigned long tmpInt = 0;
				result = file.readIdULong("Blurb2ResourceStringID", tmpInt);
				if (NO_ERR == result)
				{
					cLoadString( tmpInt, blurb, 1024 );
				}
			}

			textObjects[5].setText( blurb );

  

		}

	}
	else
	{
		textObjects[4].setText( "" );
		textObjects[3].setText( "" );
		textObjects[2].setText( "" );
		textObjects[5].setText( "" );
		statics[18].setColor( 0 );


	}
}
예제 #10
0
void MPLoadMap::addFile( const char* pFileName, bool bSeedSingle )
{

	FitIniFile tmp;
	FullPathFileName path;
	path.init( missionPath, pFileName, ".fit" );
	if ( NO_ERR == tmp.open( path ) )
	{
		if ( NO_ERR == tmp.seekBlock( "MissionSettings" ) )
		{
			unsigned long bSingle;
			long result = tmp.readIdULong( "IsSinglePlayer", bSingle );
			bool bSingleResult = (bSingle != 0);
			if ( (result == NO_ERR) && (bSingleResult == bSeedSingle) )
			{

				char* pExt = (char*)strstr( pFileName, ".fit" );
				if ( !pExt  )
				{
					pExt = (char*)(strstr( pFileName, ".FIT" ) );
				}
				if ( pExt )
					*pExt = NULL;

								
				
				aLocalizedListItem* pEntry = new aLocalizedListItem();
				*pEntry = templateItem;
				pEntry->resize( mapList.width() - mapList.getScrollBarWidth() - 30, pEntry->height());
				pEntry->setHiddenText( pFileName );
				char missionDisplayName[256];
				strcpy(missionDisplayName, "");
				getMapNameFromFile(pFileName, missionDisplayName, 255 );
				if (0 == strcmp("", missionDisplayName))
				{
					strcpy(missionDisplayName, pFileName);
				}
				pEntry->setText( missionDisplayName );
				pEntry->sizeToText();

				if ( !bSingle )
				{
					unsigned long type = 0;
					tmp.readIdULong( "MissionType", type );

					bool bFound = 0;
					// now go looking for the appropriate header
					for ( int i = 0; i < mapList.GetItemCount(); i++ )
					{
						if ( mapList.GetItem( i )->getID()  - IDS_MP_LM_TYPE0 == type )
						{
							pEntry->move( 10, 0 );
							mapList.InsertItem( pEntry, i+1 );
							bFound = true;
						}
					
					}

					if ( !bFound )
					{
						aLocalizedListItem* pHeaderEntry = new aLocalizedListItem();
						*pHeaderEntry = templateItem;
						pHeaderEntry->setText( 	IDS_MP_LM_TYPE0 + type );
						pHeaderEntry->resize( mapList.width() - mapList.getScrollBarWidth() - 30, pHeaderEntry->height());
						pHeaderEntry->sizeToText();
						pHeaderEntry->setID( IDS_MP_LM_TYPE0 + type );
						pHeaderEntry->setState( aListItem::DISABLED );
						mapList.AddItem( pHeaderEntry );
						pEntry->move( 10, 0 );
						mapList.AddItem( pEntry );

					}
				}
				else
					mapList.AddItem( pEntry );
			}
		}
	}
}
예제 #11
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();
}
예제 #12
0
int32_t BuildingType::init(FilePtr objFile, uint32_t fileSize)
{
	int32_t result = 0;
	FitIniFile bldgFile;
	result = bldgFile.open(objFile, fileSize);
	if(result != NO_ERROR)
		return(result);
	//-------------------------------------------------------------------
	// Since this object type handles MC1's Building and TreeBuilding
	// object types, we need to check for both. Basically, "TreeBuilding"
	// stands for animated building. Ultimately, would be nice to get
	// rid of this misleading legacy object type...
	result = bldgFile.seekBlock("TreeData");
	if(result != NO_ERROR)
	{
		result = bldgFile.seekBlock("BuildingData");
		if(result != NO_ERROR)
			return(result);
	}
	uint32_t dmgLevel;
	result = bldgFile.readIdULong("DmgLevel", dmgLevel);
	if(result != NO_ERROR)
		return(result);
	damageLevel = (float)dmgLevel;
	result = bldgFile.readIdBoolean("CanRefit", canRefit);
	if(result != NO_ERROR)
		canRefit = false;
	if(canRefit)
	{
		result = bldgFile.readIdBoolean("MechBay", mechBay);
		if(result != NO_ERROR)
			mechBay = false;
	}
	result = bldgFile.readIdFloat("ExplosionRadius", explRad);
	if(result != NO_ERROR)
		explRad = 0.0;
	result = bldgFile.readIdFloat("ExplosionDamage", explDmg);
	if(result != NO_ERROR)
		explDmg = 0.0;
	result = bldgFile.readIdFloat("Tonnage", baseTonnage);
	if(result != NO_ERROR)
		baseTonnage = 20;
	result = bldgFile.readIdLong("BattleRating", startBR);
	if(result != NO_ERROR)
		startBR = 20;
	result = bldgFile.readIdLong("NumMarines", numMarines);
	if(result != NO_ERROR)
		numMarines = 0;
	float realExtent = 0.0;
	result = bldgFile.readIdFloat("ExtentRadius", realExtent);
	if(result != NO_ERROR)
		realExtent = -1.0;
	result = bldgFile.readIdULong("ActivityEffectID", activityEffectId);
	if(result != NO_ERROR)
		activityEffectId = 0xffffffff;
	//----------------------------
	// Init sensor-related data...
	result = bldgFile.readIdLong("TeamID", teamId);
	if(result != NO_ERROR)
		teamId = -1;
	result = bldgFile.readIdFloat("SensorRange", sensorRange);
	if(result != NO_ERROR)
		sensorRange = -1.0;
	result = bldgFile.readIdLong("BuildingName", buildingTypeName);
	if(result != NO_ERROR)
		buildingTypeName = IDS_BLDOBJ_NAME;
	result = bldgFile.readIdLong("BuildingDescription", buildingDescriptionID);
	if(result != NO_ERROR)
		buildingDescriptionID = -1;
	result = bldgFile.readIdLong("BuildingDescription", buildingDescriptionID);
	if(result != NO_ERROR)
		buildingDescriptionID = -1;
	result = bldgFile.readIdLong("ResourcePoints", resourcePoints);
	if(result != NO_ERROR)
		resourcePoints = 0;
	result = bldgFile.readIdBoolean("ImpassableWhenDestroyed", marksImpassableWhenDestroyed);
	if(result != NO_ERROR)
		marksImpassableWhenDestroyed = true;
	result = bldgFile.readIdBoolean("Capturable", capturable);
	if(result != NO_ERROR)
		capturable = false;
	result = bldgFile.readIdBoolean("IsPowerSource", powerSource);
	if(result != NO_ERROR)
		powerSource = false;
	result = bldgFile.readIdFloat("LookoutTowerRange", lookoutTowerRange);
	if(result != NO_ERROR)
		lookoutTowerRange = 0.0f;
	result = bldgFile.readIdFloat("PerimeterAlarmRange", perimeterAlarmRange);
	if(result != NO_ERROR)
		perimeterAlarmRange = 0.0f;
	result = bldgFile.readIdFloat("PerimeterAlarmTimer", perimeterAlarmTimer);
	if(result != NO_ERROR)
		perimeterAlarmTimer = 0.0f;
	result = ObjectType::init(&bldgFile);
	extentRadius = realExtent;
	if(perimeterAlarmRange > 0.0f)
		extentRadius = perimeterAlarmRange;
	//--------------------------------------------------------------------------------
	// HACK!!!!! Must fix this for localization purposes--should be in the object type
	// data (can't look in the string!) --gd
	int32_t objectNameID = buildingTypeName;
	if(objectNameID < IDS_MC2_STRING_START)
		objectNameID += IDS_MC2_STRING_START;
	if(objectNameID != -1)
	{
		char s[255];
		cLoadString(objectNameID, s, 254);
	}
	for(size_t i = 0; i < 18; i++)
	{
		if(objTypeNum == WallType[i])
		{
			setSubType(BUILDING_SUBTYPE_WALL);
			break;
		}
	}
	if(objTypeNum == BRIDGE_TYPE)
		setSubType(BUILDING_SUBTYPE_LANDBRIDGE);
	return(result);
}