void LogisticsSaveDialog::updateCampaignMissionInfo()
{

	FitIniFile file;
	FullPathFileName path;
	path.init( campaignPath, selectedName, ".fit" );
	if ( NO_ERR != file.open( path ) )
	{
		Assert( 0, 0, "coudln't find the campaign file\n" );
	}

	char fileName[256];

	if ( NO_ERR == file.seekBlock( "Group0Mission0" ) )
	{
		if ( NO_ERR != file.readIdString( "FileName", fileName, 1023 ) )
		{				
			setMission( "" );
		}		
		else
		{
			setMission( fileName );
		}
	}	
	else
		setMission( "" );

}
bool LogisticsSaveDialog::isCorrectVersionSaveGame( char* fileName )
{
	FullPathFileName path;
	path.init( savePath, fileName, ".fit" );

	FitIniFile file;

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

	
	long result = file.seekBlock( "Version" );
	if (result != NO_ERR)
		return false;

	long testVersionNum = 0;
	result = file.readIdLong( "VersionNumber", testVersionNum );
	if ( (result == NO_ERR) && (testVersionNum == SaveGameVersionNumber))
		return true;

	return false;
}
void LogisticsSaveDialog::readCampaignNameFromFile( char* fileName, char* resultName, long len )
{
	FullPathFileName path;
	path.init( campaignPath, fileName, ".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( "Campaign" );
	Assert( result == NO_ERR, 0, "Coudln't find the mission settings block in the mission file" );

	resultName[0] = 0;
	long lName = 0;

	result = file.readIdLong( "NameID", lName );
	if ( result == NO_ERR )
	{
		cLoadString( lName, resultName, len );
	}
	else
	{
		result = file.readIdString( "CampaignName", resultName, len );
		Assert( result == NO_ERR, 0, "couldn't find the missionName" );
	}
}
void MPLoadMap::seedFromFile( const char* pFileName )
{
	FullPathFileName path;
	path.init( missionPath, pFileName, ".csv" );

	CSVFile file;
	if ( NO_ERR != file.open( path ) )
	{
		Assert( 0, 0, "couldn't open multiplayer mission .csv file" );
		return;
	}

	int i = 1; 
	char fileName[255];
	while( true )
	{
		if ( NO_ERR != file.readString( i, 1, fileName, 255 ) )
			break;

		path.init( missionPath, fileName, ".fit" );
		if ( fileExists( path ) )
		{		
			addFile( fileName, false );
		}

		i++;
	}
}
Example #5
0
void HotKeyListItem::init()
{
	if ( s_item )
		return;

	s_item = new HotKeyListItem();
	FitIniFile file;
	FullPathFileName path;
	path.init( artPath, "mcl_options_combobox1", ".fit" );
	if ( NO_ERR != file.open( path ) )
	{
		char error[256];
		sprintf( error, "couldn't open file %s", path );
		Assert( 0, 0, error );
		return;	
	}

	s_item->description.init( &file, "Text0" );
	s_item->text.init( &file, "Text1" );

	s_item->animations[0].init( &file, "Animation0" );
	s_item->animations[1].init( &file, "Animation1" );
	s_item->animations[2].init( &file, "Animation2" );

	s_item->rects[0].init( &file, "Rect0" );
	s_item->rects[1].init( &file, "Rect1" );
}
int	LogisticsMechDisplay::init( )
{
	FitIniFile file;
	FullPathFileName path;
	path.init( artPath, "mcl_mechinfo", ".fit" );
	if ( NO_ERR !=  file.open( path ) )
	{
		Assert( 0, 0, "Couldn't open mcl_mechinfo.fit" );
		return 0;
	}

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
	
	mechCamera.init( rects[1].left(), rects[2].top(),
			rects[2].left(), rects[2].bottom() );

	char blockName[64];
	for ( int i = 0; i < 3; i++ )
	{
		sprintf( blockName, "AttributeMeter%ld", i );
		attributeMeters[i].init( &file, blockName );
	}

	
	componentListBox.init( rects[0].left(), rects[0].top(),
		rects[0].width(), rects[0].height() );


	return 1;


}
Example #7
0
int aBmpListItem::setBmp( const char* pFileName )
{
	if ( strlen( pFileName ) >= MAXLEN_INSIGNIA_FILE )
		return 0;

	FullPathFileName path;
	path.init( "data\\multiplayer\\insignia\\", pFileName, ".tga" );

	TGAFileHeader header;
	File file;
	if ( NO_ERR == file.open( path ) )
	{
		file.read( (BYTE*)&header, sizeof( header ) );
		if ( header.width != 32 || header.height != 32 || header.pixel_depth < 24 )
			return 0;
	}
	else
		return 0;

	file.close();
		
	bmp.moveTo( 2, 2 );
	bmp.resize( 32, 32 );
	bmp.setTexture( path );
	bmp.setUVs( 0, 0, 32, 32 );
	bmp.setColor( 0xffffffff );
	
	resize( 64, 36 );

	addChild( &bmp );

	fileName = pFileName;
	return true;
}
Example #8
0
//-------------------------------------------------------------------------------
int32_t Radio::init(PSTR fileName, uint32_t heapSize, PSTR movie)
{
	FullPathFileName pilotAudioPath;
	pilotAudioPath.init(CDsoundPath, fileName, ".pak");
	FullPathFileName noisePath;
	noisePath.init(CDsoundPath, "noise", ".pak");
	//--------------------------------------
	// Startup the packet file.
	radioID				  = currentRadio;
	messagesFile[radioID] = new PacketFile;
	gosASSERT(messagesFile[radioID] != nullptr);
	int32_t result = messagesFile[radioID]->open(pilotAudioPath);
	gosASSERT(result == NO_ERROR);
	if (!noiseFile)
	{
		//--------------------------------------
		// Startup the Noise packet file.
		noiseFile = new PacketFile;
		gosASSERT(noiseFile != nullptr);
		result = noiseFile->open(noisePath);
		gosASSERT(result == NO_ERROR);
	}
	// load message parameters
	if (!messageInfoLoaded)
	{
		if (loadMessageInfo() == NO_ERROR)
			messageInfoLoaded = TRUE;
		else
			Fatal(0, "Unable to load message info.");
	}
	radioList[currentRadio] = this;
	currentRadio++;
	return (NO_ERROR);
}
void MechLabScreen::beginDrag( LogisticsComponent* pComponent )
{
	if ( !pDragComponent )
	{
		pDragComponent = pComponent;

		if ( pDragComponent )
		{
			//initialize the drag object
			int sizeX = pComponent->getComponentWidth();
			int sizeY = pComponent->getComponentHeight();
			
			const char* pFile = pComponent->getIconFileName();

			FullPathFileName path;
			path.init( artPath, pFile, "tga" );

			dragIcon.setTexture( path );
			dragIcon.resize( sizeX * LogisticsComponent::XICON_FACTOR, sizeY * LogisticsComponent::YICON_FACTOR);
			dragIcon.setUVs( 0.f, 0.f, sizeX * 48.f, sizeY * 32.f );
			dragIcon.setColor( 0xffffffff );

			selRect = &selRects[sizeX-1][sizeY-1];

			if ( pComponent->getType() == COMPONENT_FORM_JUMPJET )
			{
				selRect = &selJumpJetRect;
			}

		}
	}
}
ComponentListItem::ComponentListItem(LogisticsComponent* pComp)
{
	if(s_templateItem)
		*this = *s_templateItem;
	pComponent = pComp;
	if(pComp)
	{
		name.setText(pComponent->getName());
		char numericText[32];
		sprintf(numericText, "%ld", pComponent->getCost());
		costText.setText(numericText);
		sprintf(numericText, "%.0lf", pComponent->getHeat());
		heatText.setText(numericText);
		int32_t sizeX = pComponent->getComponentWidth();
		int32_t sizeY = pComponent->getComponentHeight();
		PCSTR pFile = pComponent->getIconFileName();
		FullPathFileName path;
		path.init(artPath, pFile, "tga");
		icon.setTexture(path);
		icon.resize(sizeX * LogisticsComponent::XICON_FACTOR, sizeY * LogisticsComponent::YICON_FACTOR);
		icon.setUVs(0.f, 0.f, sizeX * 48.f, sizeY * 32.f);
		// figure out the difference between this thing's size and
		// the template objects
		int32_t deltaY = icon.height() - s_templateItem->icon.height();
		int32_t deltaX = icon.width() - s_templateItem->icon.width();
		// resize outlines and icon outlines
		outline.resize(outline.width(), outline.height() + deltaY);
		iconOutline.resize(iconOutline.width() + deltaX, iconOutline.height() + deltaY);
		disabledText.resize(outline.width(), outline.height());
		disabledText.moveTo(0, 0);
		disabledText.alignment = 3;
		aObject::init(outline.left(), outline.top(), outline.width(), outline.height());
		addChild(&icon);
		addChild(&name);
		addChild(&costText);
		addChild(&heatText);
		addChild(&costIcon);
		addChild(&heatIcon);
		addChild(&disabledText);
		if(s_templateItem)
		{
			for(size_t i = 0; i < 6; i++)
			{
				for(size_t j = 0; j < COMP_ANIMATION_COUNT; j++)
				{
					if(s_templateItem->pChildAnims[i] == &s_templateItem->animations[j])
					{
						pChildAnims[i] = &animations[j];
					}
				}
			}
		}
	}
}
Example #11
0
//---------------------------------------------------------------------
// class CraterManager
long CraterManager::init (long numCraters, unsigned long craterTypeSize, char *craterFileName)
{
	init();
	
	//-----------------------------------------------------
	// Allocate Heap to store crater Info
	maxCraters = numCraters;
	craterPosHeapSize = numCraters * (sizeof(CraterData) + allocatedBlockSize);
	
	//-----------------------------------------------------
	// create Heaps
	craterPosHeap = new HeapManager;
	gosASSERT(craterPosHeap != NULL);
	
	long result = craterPosHeap->createHeap(craterPosHeapSize);
	gosASSERT(result == NO_ERR);
		
	result = craterPosHeap->commitHeap(craterPosHeapSize);
	gosASSERT(result == NO_ERR);

	numCraterTextures = MAX_CRATER_TEXTURES;
	//---------------------------------------------------------
	// Setup Crater Texture handles
	craterTextureHandles = (DWORD *)malloc(sizeof(DWORD) * numCraterTextures);
	memset((MemoryPtr)craterTextureHandles,0xff,sizeof(DWORD) * numCraterTextures);

	craterTextureIndices = (DWORD *)malloc(sizeof(DWORD) * numCraterTextures);
	memset((MemoryPtr)craterTextureIndices,0xff,sizeof(DWORD) * numCraterTextures);

	//-----------------------------------------------------
	// Preload all of the craters for the mission.
	// This should just be one texture with all of the craters on it
	// and a generic set of UVs to mark each one.
	for (long i=0;i<numCraterTextures;i++)
	{
		char craterName[1024];
		sprintf(craterName,"defaults\\feet%04d",i);
		
		FullPathFileName craterPath;
		craterPath.init(texturePath,craterName,".tga");

		if (!i)
			craterTextureIndices[i] = mcTextureManager->loadTexture(craterPath, gos_Texture_Keyed, gosHint_DisableMipmap);
		else
			craterTextureIndices[i] = mcTextureManager->loadTexture(craterPath, gos_Texture_Alpha, gosHint_DisableMipmap);
	}

	//-----------------------------------------------------
	// Setup pointer and initial values
	craterList = (CraterDataPtr)craterPosHeap->getHeapPtr();
	memset(craterPosHeap->getHeapPtr(),-1,craterPosHeapSize);

	return(NO_ERR);
}	
long	MissionBriefingScreen::getMissionTGA(const char* missionName)
{
	if (!missionName)
		return 0;

	// do I need to open the file?  I guess so, if this proves too slow,
	// it could be done when a stage is completed
	FullPathFileName path;
	path.init(missionPath, missionName, ".pak");

	if ( 1 == fileExists( path ) )
	{

		// big hack here for some reason we can open files while they're being transferred.
		HANDLE hFile = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0); // MCHD TODO: What is this all about?

		if ( hFile == INVALID_HANDLE_VALUE )
			return 0;

		CloseHandle( hFile );
	}

	// read the tga out of the pak file
	PacketFile file;
	if ( NO_ERR == file.open( path ) ) // in case file has just been created
	{
		if ( file.getNumPackets() > 3 )
		{
	
			file.seekPacket(3);
			long size = file.getPacketSize( );
			BYTE* mem = new BYTE[size];

			file.readPacket( 3, mem );
			
			TGAFileHeader* pHeader = (TGAFileHeader*)mem;
			long bmpWidth = pHeader->width;
			long bmpHeight = pHeader->height;
			flipTopToBottom( (BYTE*)(pHeader + 1), pHeader->pixel_depth, bmpWidth, bmpHeight );
			
			// set up the texture
			long tmpMapTextureHandle = mcTextureManager->textureFromMemory( (unsigned long*)(pHeader+1), gos_Texture_Solid, 0, bmpWidth );

			delete mem;

			return tmpMapTextureHandle;
		}
	}

	return 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( "" );

	}

}
int	LogisticsMechDisplay::init( )
{
	FitIniFile file;
	FullPathFileName path;
	//path.init( artPath, "mcl_mechinfo", ".fit" );
	/*//magic 16092011 begin
	if ( Environment.screenWidth == 800 ) 
		path.init( artPath, "mcl_mechinfo", ".fit" );
	if ( Environment.screenWidth == 1280 )
		path.init( artPath, "mcl_mechinfo_1280x1024", ".fit" );
	if ( Environment.screenWidth == 1440 )
		path.init( artPath, "mcl_mechinfo_1440x900", ".fit" );
	//magic 16092011 end*/
	//magic 26092011 begin
	if ( Environment.screenWidth == 1280 )
		path.init( artPath, "mcl_mechinfo_1280x1024", ".fit" );
	else if ( Environment.screenWidth == 1440 )
		path.init( artPath, "mcl_mechinfo_1440x900", ".fit" );
	else
		path.init( artPath, "mcl_mechinfo", ".fit" );

	//magic 26092011 end
	if ( NO_ERR !=  file.open( path ) )
	{
		Assert( 0, 0, "Couldn't open mcl_mechinfo.fit" );
		return 0;
	}

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
	
	mechCamera.init( rects[1].left(), rects[2].top(),
			rects[2].left(), rects[2].bottom() );

	char blockName[64];
	for ( int i = 0; i < 3; i++ )
	{
		sprintf( blockName, "AttributeMeter%ld", i );
		attributeMeters[i].init( &file, blockName );
	}

	
	componentListBox.init( rects[0].left(), rects[0].top(),
		rects[0].width(), rects[0].height() );


	return 1;


}
Example #15
0
void SplashIntro::init()
{
	FullPathFileName path;
	path.init( artPath, "mcl_splashscreenintro", ".fit" );

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

	LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
}
Example #16
0
//---------------------------------------------------------------------------
long SoundSystem::playDigitalStream (const char *streamName)
{
	//-------------------------------------------------------------------
	// Make sure we have a real music filename.
	if (useSound)
	{
		char actualName[1024];
		_splitpath(streamName,NULL,NULL,actualName,NULL);

		//---------------------------------------------------------------------------------------------
		// Just start tune.  No fade necessary.  Set fadeTime to 0.0 to tell update to leave it alone.
		// Use Stream1 by default.
		FullPathFileName digitalStream;
		digitalStream.init(soundPath,actualName,".wav");

		//---------------------------------------------
		// Gotta check if music file is there
		// new sound system can't handle it if its not.
		if (fileExists(digitalStream))
		{
			if (!stream3Active)
			{
				if (stream3Handle)
				{
					gosAudio_DestroyResource(&stream3Handle);
					stream3Handle = 0;
				}
						
				gosAudio_CreateResource(&stream3Handle, gosAudio_StreamedFile, (const char *) digitalStream);
				
				stream3Active = false;
				
				gosAudio_AssignResourceToChannel( STREAM3CHANNEL, stream3Handle );
				gosAudio_SetChannelSlider( STREAM3CHANNEL,gosAudio_Volume, digitalMasterVolume * bettyVolume );
				gosAudio_SetChannelSlider( STREAM3CHANNEL, gosAudio_Panning,0.0f );
			}
			else
			{
				return(-1);
			}
		}
	}

	return(NO_ERR);
}
Example #17
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();
}	
Example #18
0
//---------------------------------------------------------------------------
// Class Clouds
void Clouds::init (char *textureName, long gSize)
{
	FullPathFileName cloudName;
	cloudName.init(texturePath,textureName,".tga");
	
	//-------------------------------------
	// Load Texture here.
	mcTextureNodeIndex = mcTextureManager->loadTexture(cloudName,gos_Texture_Alpha,/*gosHint_DisableMipmap |*/ gosHint_DontShrink);
	
	//-------------------------------------
	// Create the CloudVertices here.
	gridSize = gSize;
	long gridTotal = gridSize * gridSize;
	cloudVertices = (CloudVertexPtr)systemHeap->Malloc(sizeof(CloudVertex)*gridTotal);
	gosASSERT(cloudVertices != NULL);
	
	memset(cloudVertices,0,sizeof(CloudVertex)*gridTotal);
}
int32_t LogisticsMapInfoDialog::init()
{
	FitIniFile file;
	FullPathFileName path;
	path.init(artPath, "mcl_mp_mapinfo", ".fit");
	if (NO_ERROR != file.open(path))
	{
		char buffer2[512];
		sprintf(buffer2, "couldn't open file %s", (PSTR)path);
		Assert(0, 0, buffer2);
		return false;
	}
	LogisticsScreen::init(file, "Static", "Text", "Rect", "Button", "Edit");
	file.seekBlock("InAnim");
	enterAnim.init(&file, "");
	file.seekBlock("OutAnim");
	exitAnim.init(&file, "");
	return 1;
}
void MissionResults::end()
{
	//Need to save the game here so salvage and pilot promotion get saved as well!
	// Pity we never call ::end!
	const char* pMissionName = LogisticsData::instance->getLastMission();

	if ( pMissionName && !LogisticsData::instance->isSingleMission() && !LogisticsData::instance->campaignOver() && !MPlayer )
	{
		FitIniFile file;
		char name[256];
		cLoadString( IDS_AUTOSAVE_NAME, name, 255 );
		char fullName[256];
		sprintf( fullName, name, pMissionName );
		FullPathFileName path;
		path.init( savePath, fullName, ".fit" );
		if ( NO_ERR == file.create( path ) )
			LogisticsData::instance->save( file );
	}
}
Example #21
0
void Logistics::playFullScreenVideo( const char* fileName )
{
	if ( !fileName || !fileName[0])
		return;

	FullPathFileName path;
	path.init( moviePath, fileName, ".bik" );

	RECT movieRect;
	movieRect.top = 100;
	movieRect.left = 0;
	movieRect.right = Environment.screenWidth;
	movieRect.bottom = 500;

	bMovie = new MC2Movie;
	bMovie->init(path,movieRect,true);

	soundSystem->stopDigitalMusic();
}
int32_t MissionBriefingScreen::getMissionTGA(PCSTR missionName)
{
	if (!missionName)
		return 0;
	// do I need to open the file?  I guess so, if this proves too slow,
	// it could be done when a stage is completed
	FullPathFileName path;
	path.init(missionPath, missionName, ".pak");
	if (1 == fileExists(path))
	{
		// big hack here for some reason we can open files while they're being
		// transferred.
		HANDLE hFile  = CreateFile(path, GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, 0);
		int32_t error = GetLastError();
		if (hFile == INVALID_HANDLE_VALUE)
			return 0;
		CloseHandle(hFile);
	}
	// read the tga out of the pak file
	PacketFile file;
	if (NO_ERROR == file.open(path)) // in case file has just been created
	{
		if (file.getNumPackets() > 3)
		{
			file.seekPacket(3);
			int32_t size = file.getPacketSize();
			puint8_t mem = new uint8_t[size];
			file.readPacket(3, mem);
			TGAFileHeader* pHeader = (TGAFileHeader*)mem;
			int32_t bmpWidth	   = pHeader->width;
			int32_t bmpHeight	  = pHeader->height;
			flipTopToBottom((puint8_t)(pHeader + 1), pHeader->pixel_depth, bmpWidth, bmpHeight);
			// set up the texture
			int32_t tmpMapTextureHandle = mcTextureManager->textureFromMemory(
				(uint32_t*)(pHeader + 1), gos_Texture_Solid, 0, bmpWidth);
			delete mem;
			return tmpMapTextureHandle;
		}
	}
	return 0;
}
Example #23
0
int32_t ObjectTypeManager::init(PSTR objectFileName, int32_t objectTypeCacheSize, int32_t objectCacheSize, int32_t maxObjectTypes)
{
	FullPathFileName objectName;
	objectName.init(objectPath, objectFileName, ".pak");
	objectFile = new PacketFile;
	if(!objectFile)
		return NO_RAM_FOR_OBJECT_TYPE_FILE;
	int32_t result = objectFile->open(objectName);
	if(result != NO_ERROR)
		return(result);
	objectTypeCache = new UserHeap;
	if(!objectTypeCache)
		return NO_RAM_FOR_OBJECT_TYPE_CACHE;
	result = objectTypeCache->init(objectTypeCacheSize, "ObjectTypeHeap");
	if(result != NO_ERROR)
		return(result);
	objectCache = new UserHeap;
	if(!objectCache)
		return NO_RAM_FOR_OBJECT_CACHE;
	result = objectCache->init(objectCacheSize, "ObjectHeap");
	if(result != NO_ERROR)
		return(result);
	numObjectTypes = maxObjectTypes;
	table = (ObjectTypePtr*)objectTypeCache->Malloc(sizeof(ObjectTypePtr) * numObjectTypes);
	if(!table)
		Fatal(0, " ObjectTypeManager.init: unable to create table ");
	for(size_t i = 0; i < numObjectTypes; i++)
		table[i] = nullptr;
	//---------------------------------------------------------------------------
	// Since MC1 handled all of these MiscTerrainObjectTypes with one ObjectType,
	// we set aside 5 separate typeHandles so they can be more logically
	// managed. If we never have to load MC1/MCX missions, we can simply init
	// the objectType packfile with 5 sep. types to begin with and avoid this
	// hack-like "fix"...
	bridgeTypeHandle = numObjectTypes - 5;
	forestTypeHandle = numObjectTypes - 4;
	wallHeavyTypeHandle = numObjectTypes - 3;
	wallMediumTypeHandle = numObjectTypes - 2;
	wallLightTypeHandle = numObjectTypes - 1;
	return(NO_ERROR);
}
Example #24
0
//---------------------------------------------------------------------------------
void WeaponEffects::init (char *effectCSVFileName)
{
	FullPathFileName effectsName;
	effectsName.init(objectPath,effectCSVFileName,".csv");
	
	CSVFile effectFile;
	long result = effectFile.open(effectsName);
	if (result != NO_ERR)
		STOP(("Unable to open Effects File %s",effectsName));
		
	numEffects = effectFile.getNumLines() - 1;	//Always subtract one for the column headers

	effects = (EffectData *)systemHeap->Malloc(sizeof(EffectData) * numEffects);
	gosASSERT(effects != NULL);
	
	for (long i=0;i<numEffects;i++)
	{
		effectFile.readString(i+2,2,effects[i].effectName,49);
		effectFile.readString(i+2,3,effects[i].muzzleFlashName,49);
		effectFile.readString(i+2,4,effects[i].hitEffectName,49);
		effectFile.readString(i+2,6,effects[i].missEffectName,49);
		effectFile.readLong(i+2,5,effects[i].effectObjNum);
	}
}
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" );
	}
}
Example #26
0
//---------------------------------------------------------------------------
long SoundSystem::playDigitalMusic (long musicId)
{
	//-------------------------------------------------------------------
	// Make sure we have a real music filename.
	if (useMusic)
	{
		if ((musicId >= 0) && (musicId < numDMS) && (strncmp(digitalMusicIds[musicId],"NONE",4) != 0))
		{
			if (musicId == currentMusicId)
				return(-1);
				
			if (useSound)
			{
				//---------------------------------------------------------------------------------------------
				// Just start tune.  No fade necessary.  Set fadeTime to 0.0 to tell update to leave it alone.
				// Use Stream1 by default.
				FullPathFileName digitalStream;
				digitalStream.init(soundPath,digitalMusicIds[musicId],".wav");

				//---------------------------------------------
				// Gotta check if music file is there
				// new sound system can't handle it if its not.
				if (fileExists(digitalStream))
				{
					if (!stream1Active && !stream2Active)
					{
						if (stream1Handle)
						{
							gosAudio_DestroyResource(&stream1Handle);
							stream1Handle = 0;
						}
							
						gosAudio_CreateResource(&stream1Handle, gosAudio_StreamedFile, (const char *) digitalStream);
						
						stream1Time = streamFadeDownTime;
						
						gosAudio_SetChannelSlider( STREAM1CHANNEL, gosAudio_Volume, 0.0f );
						gosAudio_SetChannelSlider( STREAM1CHANNEL, gosAudio_Panning,0.0f );
						gosAudio_AssignResourceToChannel( STREAM1CHANNEL, stream1Handle );

						currentMusicId = musicId;
						stream1Id = musicId;
					}
					else if (!stream2Active)
					{
						if (stream2Handle)
						{
							gosAudio_DestroyResource( &stream2Handle );
							stream2Handle = 0;
						}
							
						gosAudio_CreateResource( &stream2Handle, gosAudio_StreamedFile, (const char *) digitalStream );
						
						//Need to check if stream1 ever got all the way faded up!
						if (stream1Time > 0.0f)
							stream1Time = -stream1Time;
						else
							stream1Time = -streamFadeDownTime;

						stream2Time = streamFadeDownTime;
						
						gosAudio_SetChannelSlider( STREAM2CHANNEL, gosAudio_Volume, 0.0f );
						gosAudio_SetChannelSlider( STREAM2CHANNEL, gosAudio_Panning,0.0f );
						gosAudio_AssignResourceToChannel( STREAM2CHANNEL, stream2Handle );
							
						currentMusicId = musicId;
						stream2Id = musicId;
					}
					else if (!stream1Active)
					{
						if (stream1Handle)
						{
							gosAudio_DestroyResource(&stream1Handle);
							stream1Handle = 0;
						}
							
						gosAudio_CreateResource(&stream1Handle, gosAudio_StreamedFile, (const char *) digitalStream);
						
						stream1Time = streamFadeDownTime;

						//Need to check if stream2 ever got all the way faded up!
						if (stream2Time > 0.0f)
							stream2Time = -stream2Time;
						else
							stream2Time = -streamFadeDownTime;

						gosAudio_SetChannelSlider( STREAM1CHANNEL, gosAudio_Volume, 0.0f );
						gosAudio_SetChannelSlider( STREAM1CHANNEL, gosAudio_Panning,0.0f );
						gosAudio_AssignResourceToChannel( STREAM1CHANNEL, stream1Handle );
							
						currentMusicId = musicId;
						stream1Id = musicId;
					}
					else
					{
						return(-1);
					}
				}
			}
		}
	}

	return(NO_ERR);
}
Example #27
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);
}
Example #28
0
//-----------------------------
int32_t convertASE2TGL(PSTR file)
{
	//---------------------------------------------------
	// Get all of the .ASE files in the tgl directory.
	char findString[1024];
	char armFileName[1024];
	if (file[0] == '\0')
	{
		sprintf(findString, "%s*.ini", tglPath);
	}
	else
	{
		strcpy(findString, tglPath);
		strcat(findString, file);
	}
	int32_t count = 0;
	WIN32_FIND_DATA findResult;
	HANDLE searchHandle = FindFirstFile(findString, &findResult);
	do
	{
		if ((findResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
		{
			//-----------------------------------
			// Search for TGLData
			FullPathFileName iniName;
			iniName.init(tglPath, findResult.cFileName, "");
			FitIniFile iniFile;
			int32_t result = iniFile.open(iniName);
			if (result != NO_ERROR)
				return result;
			// ARM
			IProviderAssetPtr iniAsset =
				armProvider->OpenAsset((PSTR)iniName, AssetType_Physical, ProviderType_Primary);
			iniAsset->AddProperty("Type", "Object Definition");
			iniAsset->AddProperty("Version", "1.0");
			TG_TypeMultiShape* shape = nullptr;
			result					 = iniFile.seekBlock("TGLData");
			if (result == NO_ERROR)
			{
				char fileName[1024];
				result = iniFile.readIdString("FileName", fileName, 1023);
				if (result != NO_ERROR)
				{
					//---------------------------------------------
					// We have LODs -- handle differently
					// We will get animation from LAST LOD loaded
					int32_t i = 0;
					char fileCheck[1024];
					sprintf(fileCheck, "FileName%d", i);
					result = iniFile.readIdString(fileCheck, fileName, 1023);
					while (result == NO_ERROR)
					{
						if (shape)
						{
							delete shape;
							shape = nullptr;
						}
						char aseName[1024];
						sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
						//---------------------------------------------------------------------------------------------
						// Load Base Shape or LOD 0 Shape.
						shape = new TG_TypeMultiShape;
						gosASSERT(shape != nullptr);
						printf("Processing Main Shape %s\n", aseName);
						char lodID[4];
						sprintf(lodID, "%02d", count);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("LOD Shape", aseName);
						armLink->AddProperty("LOD", lodID);
						shape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
						i++;
						sprintf(fileCheck, "FileName%d", i);
						result = iniFile.readIdString(fileCheck, fileName, 1023);
					}
				}
				char aseName[1024];
				sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
				//---------------------------------------------------------------------------------------------
				// Load Base Shape or LOD 0 Shape.
				shape = new TG_TypeMultiShape;
				gosASSERT(shape != nullptr);
				printf("Processing Main Shape %s\n", aseName);
				IProviderRelationshipPtr armLink = iniAsset->AddRelationship("Main Shape", aseName);
				shape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
				//-------------------------------------------
				// Gotta make the special shadow shape now!!
				// MUST use its own shape or animation below
				// will go straight to HELL!!
				result = iniFile.readIdString("ShadowName", fileName, 1023);
				if (result == NO_ERROR)
				{
					char aseName[1024];
					sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
					//---------------------------------------------------------------------------------------------
					// Load Base Shape or LOD 0 Shape.
					TG_TypeMultiShapePtr shadowShape = new TG_TypeMultiShape;
					gosASSERT(shadowShape != nullptr);
					printf("Processing Shadow Shape %s\n", aseName);
					IProviderRelationshipPtr armLink =
						iniAsset->AddRelationship("Shadow Shape", aseName);
					shadowShape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
					delete shadowShape;
					shadowShape = nullptr;
				}
				int32_t i = 0;
				char animCheck[1024];
				sprintf(animCheck, "Animation:%d", i);
				result = iniFile.seekBlock(animCheck);
				while (result == NO_ERROR) // This thing has animations. Process them!
				{
					char fileName[1024];
					result = iniFile.readIdString("AnimationName", fileName, 1023);
					if (result == NO_ERROR)
					{
						FullPathFileName aseName;
						aseName.init(tglPath, fileName, ".ase");
						TG_AnimateShape* anim = new TG_AnimateShape;
						gosASSERT(mechAnim != nullptr);
						//-----------------------------------------------
						// Skip this one if its already a binary file.
						// Happens ALOT!
						printf("Processing Animation %s\n", aseName);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("Animation", (PSTR)aseName);
						anim->LoadTGMultiShapeAnimationFromASE(aseName, shape, true);
						delete anim;
						anim = nullptr;
					}
					i++;
					sprintf(animCheck, "Animation:%d", i);
					result = iniFile.seekBlock(animCheck);
				}
				if (!i) // No Animations, BUT they may mean we are a MECH!!!
				{
					if (iniFile.seekBlock("Gestures0") == NO_ERROR)
					{
						// We ARE a mech. Load all of the animations for this
						// mech and write 'em out.
						for (size_t i = 0; i < MaxGestures; i++)
						{
							char name[MAX_PATH];
							_splitpath(findResult.cFileName, nullptr, nullptr, name, nullptr);
							char mechFileName[1024];
							sprintf(
								mechFileName, "%s%s%s.ase", tglPath, name, MechAnimationNames[i]);
							TG_AnimateShape* anim = new TG_AnimateShape;
							gosASSERT(anim != nullptr);
							//-----------------------------------------------
							// Skip this one if its already a binary file.
							// Happens ALOT!
							printf("Processing Animation %s\n", mechFileName);
							IProviderRelationshipPtr armLink =
								iniAsset->AddRelationship("Animation", mechFileName);
							anim->LoadTGMultiShapeAnimationFromASE(mechFileName, shape, true);
							delete anim;
							anim = nullptr;
						}
					}
				}
				if (!i) // No Animations, BUT they may mean we are a MECH!!!
				{
					if (iniFile.seekBlock("Gestures0") == NO_ERROR)
					{
						// We ARE a mech. Load all of the destroyed shapes for
						// this mech and write 'em out.
						for (size_t i = MaxGestures; i < MaxGestures + 2; i++)
						{
							char name[MAX_PATH];
							_splitpath(findResult.cFileName, nullptr, nullptr, name, nullptr);
							char mechFileName[1024];
							sprintf(
								mechFileName, "%s%s%s.ase", tglPath, name, MechAnimationNames[i]);
							//-----------------------------------------------
							shape = new TG_TypeMultiShape;
							gosASSERT(shape != nullptr);
							printf("Processing Animation %s\n", mechFileName);
							IProviderRelationshipPtr armLink =
								iniAsset->AddRelationship("Destroyed Shape", mechFileName);
							shape->LoadTGMultiShapeFromASE(mechFileName, true, armProvider);
							delete shape;
							shape = nullptr;
						}
					}
				}
				if (iniFile.seekBlock("TGLDamage") == NO_ERROR)
				{
					char fileName[1024];
					result = iniFile.readIdString("FileName", fileName, 1023);
					if (result == NO_ERROR)
					{
						if (shape)
						{
							delete shape;
							shape = nullptr;
						}
						char aseName[1024];
						sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
						//---------------------------------------------------------------------------------------------
						// Load Base Shape or LOD 0 Shape.
						shape = new TG_TypeMultiShape;
						gosASSERT(shape != nullptr);
						printf("Processing Damage Shape %s\n", aseName);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("Damage Shape", aseName);
						shape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
					}
					//-------------------------------------------
					// Gotta make the special shadow shape now!!
					// MUST use its own shape or animation below
					// will go straight to HELL!!
					result = iniFile.readIdString("ShadowName", fileName, 1023);
					if (result == NO_ERROR)
					{
						char aseName[1024];
						sprintf(aseName, "%s%s%s", tglPath, fileName, ".ase");
						//---------------------------------------------------------------------------------------------
						// Load Base Shape or LOD 0 Shape.
						TG_TypeMultiShapePtr shadowShape = new TG_TypeMultiShape;
						gosASSERT(shadowShape != nullptr);
						printf("Processing Damage Shadow Shape %s\n", aseName);
						IProviderRelationshipPtr armLink =
							iniAsset->AddRelationship("Damage Shadow Shape", aseName);
						shadowShape->LoadTGMultiShapeFromASE(aseName, true, armProvider);
						delete shadowShape;
						shadowShape = nullptr;
					}
				}
			}
			delete shape;
			shape = nullptr;
			iniAsset->Close();
		}
	} while (FindNextFile(searchHandle, &findResult) != 0);
	FindClose(searchHandle);
	return 0;
}
Example #29
0
void MPHostGame::init()
{
	FullPathFileName path;
	FitIniFile file;
	path.init(artPath, "mcl_mp_hostgamedialog", ".fit");
	if (NO_ERROR != file.open(path))
	{
		char error[256];
		sprintf(error, "couldn't open file %s", path);
		Assert(0, 0, error);
		return;
	}
	LogisticsScreen::init(file, "Static", "Text", "Rect", "Button");
	file.seekBlock("InAnim");
	enterAnim.init(&file, "");
	file.seekBlock("OutAnim");
	exitAnim.init(&file, "");
	if (buttonCount)
	{
		for (size_t i = 0; i < buttonCount; i++)
		{
			buttons[i].setMessageOnRelease();
			if (buttons[i].getID() == 0)
			{
				buttons[i].setID(FIRST_BUTTON_ID + i);
			}
		}
	}
	edits[0].limitEntry(24);
	edits[0].allowIME(false);
	/*	int32_t tmpX, tmpY;
		file.seekBlock( "ComboBox0" );
		file.readIdLong( "XLocation", tmpX );
		file.readIdLong( "YLocation", tmpY );


		char tmpStr[256];
		file.readIdString( "FileName", tmpStr, 255 );
		{
			FullPathFileName tmpPath;
			tmpPath.init( artPath, tmpStr, ".fit" );

			FitIniFile PNfile;
			if ( NO_ERROR != PNfile.open( tmpPath ) )
			{
				char error[256];
				sprintf( error, "couldn't open file %s", (PSTR)tmpPath );
				Assert( 0, 0, error );
				return;
			}
			numPlayersDropList.init( &PNfile, "ComboBox0");

			aStyle5TextListItem *pTmp2;
			int32_t i;
			for (i = 2; i < MAX_MC_PLAYERS+1; i += 1)
			{
				pTmp2 = new aStyle5TextListItem;
				pTmp2->init(&PNfile, "Text0");
				char txt[32];
				sprintf( txt, "%ld", i );
				pTmp2->setText( txt );
				pTmp2->sizeToText();
				pTmp2->resize( numPlayersDropList.width() -
	   numPlayersDropList.ListBox().getScrollBarWidth() + 5, pTmp2->height() );
				numPlayersDropList.AddItem(pTmp2);
			}
			numPlayersDropList.SelectItem(0);
		}

		numPlayersDropList.moveTo( tmpX, tmpY );
		numPlayersDropList.ListBox().setOrange( true );
		numPlayersDropList.EditBox().limitEntry( 1 );
		numPlayersDropList.EditBox().setNumeric( 1 );
		numPlayersDropList.setReadOnly( 0 );*/
}
Example #30
0
//---------------------------------------------------------------------------
long Terrain::init( unsigned long verticesPerMapSide, PacketFile* pakFile, unsigned long visibleVertices,
				   volatile float& percent,
					float percentRange)
{
	//Did we pass in the hi-res colormap?
	// If so, convert back to old verticesPerMapSide!
	if (verticesPerMapSide > 300)
		verticesPerMapSide /= 12.8;
		
	realVerticesMapSide = verticesPerMapSide;
	halfVerticesMapSide = realVerticesMapSide >> 1;
	blocksMapSide = realVerticesMapSide / verticesBlockSide;
	worldUnitsMapSide = realVerticesMapSide * worldUnitsPerVertex;
	if (worldUnitsMapSide > Stuff::SMALL)
		oneOverWorldUnitsMapSide = 1.0f / worldUnitsMapSide;
	else
		oneOverWorldUnitsMapSide = 0.0f;

	Terrain::numObjBlocks = blocksMapSide * blocksMapSide;
	visibleVerticesPerSide = visibleVertices;
	terrainHeapSize = MAX_TERRAIN_HEAP_SIZE;

	//-----------------------------------------------------------------
	// Startup to Terrain Heap
	if( !terrainHeap )
	{
		terrainHeap = new UserHeap;
		gosASSERT(terrainHeap != NULL);
		terrainHeap->init(terrainHeapSize,"TERRAIN");
	}

	percent += percentRange/5.f;
	//-----------------------------------------------------------------
	// Startup the Terrain Texture Maps
	if ( !terrainTextures )
	{
		char baseName[256];
		if (pakFile)
		{
			_splitpath(pakFile->getFilename(),NULL,NULL,baseName,NULL);
		}
		else
		{
			strcpy(baseName,"newmap");
		}

		terrainTextures = new TerrainTextures;
		terrainTextures->init("textures",baseName);
	}

	percent += percentRange/5.f;


	if ( !pakFile && !realVerticesMapSide )
		return NO_ERR;

	//-----------------------------------------------------------------
	// Startup the Terrain Color Map
	if ( !terrainTextures2 && pakFile)
	{
		char name[1024];

		_splitpath(pakFile->getFilename(),NULL,NULL,name,NULL);
		terrainName = new char[strlen(name)+1];
		strcpy(terrainName,name);

		if (colorMapName)
			strcpy(name,colorMapName);

		FullPathFileName tgaColorMapName;
		tgaColorMapName.init(texturePath,name,".tga");
		
		FullPathFileName tgaColorMapBurninName;
		tgaColorMapBurninName.init(texturePath,name,".burnin.tga");

		FullPathFileName tgaColorMapJPGName;
		tgaColorMapJPGName.init(texturePath,name,".burnin.jpg");
				
		if (fileExists(tgaColorMapName) || fileExists(tgaColorMapBurninName) || fileExists(tgaColorMapJPGName))
		{
			terrainTextures2 = new TerrainColorMap;		//Otherwise, this will stay NULL and we know not to use them
		}
	}

	percent += percentRange/5.f;


	mapTopLeft3d.x = -worldUnitsMapSide / 2.0f;
	mapTopLeft3d.y = worldUnitsMapSide / 2.0f;

	percent += percentRange/5.f;


	//----------------------------------------------------------------------
	// Setup number of blocks
	long numberBlocks = blocksMapSide * blocksMapSide;
	
	numObjBlocks = numberBlocks;
	objBlockInfo = (ObjBlockInfo *)terrainHeap->Malloc(sizeof(ObjBlockInfo)*numObjBlocks);
	gosASSERT(objBlockInfo != NULL);
	
	memset(objBlockInfo,0,sizeof(ObjBlockInfo)*numObjBlocks);
	
	objVertexActive = (bool *)terrainHeap->Malloc(sizeof(bool) * realVerticesMapSide * realVerticesMapSide);
	gosASSERT(objVertexActive != NULL);
	
	memset(objVertexActive,0,sizeof(bool)*numObjBlocks);
	
	moverBlockList = (long *)terrainHeap->Malloc(sizeof(long) * numberBlocks);
	gosASSERT(moverBlockList != NULL);
	
	usedBlockList = (long *)terrainHeap->Malloc(sizeof(long) * numberBlocks);
	gosASSERT(usedBlockList != NULL);
	
	clearList();
	clearMoverList();

	//----------------------------------------------------------------------
	// Calculate size of each mapblock
	long blockSize = verticesBlockSide * verticesBlockSide;
	blockSize *= sizeof(PostcompVertex);

	//----------------------------------------------------------------------
	// Create the MapBlock Manager and allocate its RAM
	if ( !mapData )
	{
		mapData = new MapData;
		if ( pakFile )
			mapData->newInit( pakFile, realVerticesMapSide*realVerticesMapSide);
		else
			mapData->newInit( realVerticesMapSide*realVerticesMapSide );

		mapTopLeft3d.z = mapData->getTopLeftElevation();
	}

	percent += percentRange/5.f;

	
	//----------------------------------------------------------------------
	// Create the VertexList
	numberVertices = 0;
	vertexList = (VertexPtr)terrainHeap->Malloc(sizeof(Vertex) * visibleVertices * visibleVertices);
	gosASSERT(vertexList != NULL);
	memset(vertexList,0,sizeof(Vertex) * visibleVertices * visibleVertices);

	//----------------------------------------------------------------------
	// Create the QuadList
	numberQuads = 0;
	quadList = (TerrainQuadPtr)terrainHeap->Malloc(sizeof(TerrainQuad) * visibleVertices * visibleVertices);
	gosASSERT(quadList != NULL);
	memset(quadList,0,sizeof(TerrainQuad) * visibleVertices * visibleVertices);

	//-------------------------------------------------------------------
	initMapCellArrays();

	//-----------------------------------------------------------------
	// Startup the Terrain Color Map
	if ( terrainTextures2  && !(terrainTextures2->colorMapStarted))
	{
		if (colorMapName)
			terrainTextures2->init(colorMapName);
		else
			terrainTextures2->init(terrainName);
	}

	return NO_ERR;
}