Esempio n. 1
0
void OptionsHotKeys::makeKeyString( long newKey, char* keysString )
{
	char shift[32];
	char control[32];
	char alt[32];

	cLoadString( IDS_SHIFT, shift, 31 );
	cLoadString( IDS_CONTROL, control, 31 );
	cLoadString( IDS_ALT, alt, 31 );

	long key = newKey;
	char* pKey = gos_DescribeKey( (key & 0x000fffff) << 8 );

	if ( ((key & SHIFT)) )
	{
		strcat( keysString, shift );
		strcat( keysString, " + " );
	}

	if ( ((key & CTRL)) )
	{
		strcat( keysString, control );
		strcat( keysString, " + " );
	}
		
	if ( ((key & ALT)) )
	{
		strcat( keysString, alt );
		strcat( keysString, " + " );
	}	
	
	strcat( keysString, pKey );

}
int	LogisticsVariantDialog::handleMessage ( unsigned long what, unsigned long who )
{
	
	if ( YES == who )
	{
		 edits[0].getEntry(selectedName);
		 bool bFound = 0;

		 // look and see if you are overwriting anything here...
		 for ( int i= 0; i < gameListBox.GetItemCount(); i++ )
		 {
			 if ( selectedName.Compare( ((aTextListItem*)gameListBox.GetItem( i ))->getText(), 0 ) == 0 )
			 {
				 // do prompt here
				 
				char str[256];
				cLoadString( IDS_DIALOG_OVERWRITE_PROMPT, str, 255 );
				char promptString[256];
				sprintf( promptString, str, (const char*)selectedName );
				LogisticsOKDialog::instance()->setText( IDS_DIALOG_QUIT_PROMPT,
					IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->setText( promptString );
				LogisticsOKDialog::instance()->begin();
				bPromptOverwrite = true;
				bFound = 1;
				break;
			 }
		 }

		 if ( !bFound )
		 {
			status = YES;
			end();
		 }
	}
	if ( NO == who )
	{
		selectedName = "";
		status = NO;
		end();
	}
	if ( DELETE_BUTTON == who )
	{
		edits[0].getEntry(selectedName);
		char str[256];
		cLoadString( IDS_DIALOG_DELETE_PROMPT, str, 255 );
		char promptString[256];
		sprintf( promptString, str, (const char*)selectedName );

		LogisticsOKDialog::instance()->setText( IDS_DIALOG_QUIT_PROMPT,
					IDS_DIALOG_NO, IDS_DIALOG_YES );	
		LogisticsOKDialog::instance()->setText( promptString );
		LogisticsOKDialog::instance()->begin();

		bDeletePrompt = true;
	
	}

	return 0;
}
SingleValueDlg::SingleValueDlg( int captionID, int staticTextID, int newVal)
: CDialog( IDD_VALUE )
{
	cLoadString( captionID, caption, 256, gameResourceHandle );
	cLoadString( staticTextID, staticText, 256, gameResourceHandle );
	
	val = newVal;
}
Esempio n. 4
0
long MechListBox::AddItem(aListItem* itemString)
{
	itemString->setID( ID );
	MechListBoxItem* pItem = dynamic_cast<MechListBoxItem*>(itemString);
	EString addedName;
	char tmp[256];
	cLoadString( pItem->getMech()->getChassisName(), tmp, 255 );
	addedName = tmp;
	
	if ( pItem )
	{
		pItem->bOrange = bOrange;
		pItem->bIncludeForceGroup = bIncludeForceGroup;

		if ( !bDeleteIfNoInventory )
		{
			pItem->countText.setColor( 0 );
			pItem->countText.showGUIWindow( 0 );
		}
	
		EString chassisName;
		for ( int i = 0; i < itemCount; i++ )
		{

			long ID = ((MechListBoxItem*)items[i])->pMech->getChassisName();
			char tmpChassisName[256];
			cLoadString( ID, tmpChassisName, 255 );
			chassisName = tmpChassisName;
			if ( ((MechListBoxItem*)items[i])->pMech->getMaxWeight() < pItem->pMech->getMaxWeight() )
			{
				return InsertItem( itemString, i );
				break;
			}
			else if ( ((MechListBoxItem*)items[i])->pMech->getMaxWeight() == pItem->pMech->getMaxWeight()
				&& chassisName.Compare( addedName ) > 0 )
			{
				return InsertItem( itemString, i );
			}
			else if ( ((MechListBoxItem*)items[i])->pMech->getMaxWeight() == pItem->pMech->getMaxWeight()
				&& chassisName.Compare( addedName ) == 0 
				&& ((MechListBoxItem*)itemString)->pMech->getName().Find("Prime") != -1 )
			{
				return InsertItem( itemString, i );
			}
			else if ( ((MechListBoxItem*)items[i])->pMech->getMaxWeight() == pItem->pMech->getMaxWeight()
				&& chassisName.Compare( addedName ) == 0 
				&& ( ((MechListBoxItem*)items[i])->pMech->getName().Find("Prime" ) == -1 ) 
				&& ((MechListBoxItem*)items[i])->pMech->getName().Compare( pItem->pMech->getName() ) > 0 )
			{
				return InsertItem( itemString, i );
			}
		}

	}

	
	return aListBox::AddItem( itemString );
}
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 LogisticsScreen::update()
{
	int32_t i;
	for(i = 0; i < staticCount; i++)
	{
		statics[i].update();
	}
	for(i = 0; i < buttonCount; i++)
	{
		buttons[i].update();
	}
	for(i = 0; i < textCount; i++)
		textObjects[i].update();
	for(i = 0; i < rectCount; i++)
		rects[i].update();
	// help text
	if(helpTextArrayID != -1)
	{
		if(::helpTextID)
		{
			EString helpText;
			char tmp[1024];
			//	if ( helpTextHeaderID )
			//	{
			//		cLoadString( helpTextHeaderID, tmp, 255 );
			//		helpText = tmp;
			//		helpText.MakeUpper();
			//		helpText += '\n';
			//	}
			cLoadString(helpTextID, tmp, 1024);
			helpText = tmp;
			textObjects[helpTextArrayID].setText(helpText);
		}
		else
			textObjects[helpTextArrayID].setText("");
	}
	for(i = 0; i < editCount; i++)
	{
		edits[i].update();
	}
	for(i = 0; i < animObjectsCount; i++)
		animObjects[i].update();
//	if ( gos_GetKeyStatus( KEY_RETURN ) == KEY_RELEASED )
//	{
//		if ( getButton( 50 /*MB_MSG_NEXT*/ ) )
//		{
//			if ( getButton(50 )->isEnabled() )
//				handleMessage( aMSG_LEFTMOUSEDOWN, 50 );
//		}
//	}
//	if ( gos_GetKeyStatus( KEY_ESCAPE ) == KEY_RELEASED )
//	{
//		if ( getButton( 57 /*MB_MSG_MAINMENU*/ ) )
//		{
//			if ( getButton(57 )->isEnabled() )
//				handleMessage( aMSG_LEFTMOUSEDOWN, 57 );
//		}
//	}
	helpTextID = 0;
}
void PauseWindow::render()
{
    if ( !currentTime )
        return;
    drawRect( backgrounds[0], 0xff000000 );
    drawRect( backgrounds[1], 0xff000000 );

    for ( int i = 0; i < buttonCount; i++ )
    {
        buttons[i].render();
    }

    for ( i = 0; i < staticCount; i++ )
    {
        statics[i].render();
    }


    char buffer[256];
    cLoadString( IDS_GAMEPAUSED, buffer, 256 );
    headerFont.render( buffer, backgrounds[1].left, backgrounds[1].top,
                       backgrounds[1].right - backgrounds[1].left,
                       backgrounds[1].bottom - backgrounds[1].top,
                       0xff5c96c2, 0, 3 );


    if ( bPromptToQuit || bPromptToAbort )
    {
        LogisticsOKDialog::instance()->render();
    }


}
Esempio n. 8
0
int	aTcpipPanel::handleMessage( unsigned long message, unsigned long who)
{
	switch ( who )
	{
	case TCPIP_PANEL_FIRST_BUTTON_ID:
		{
		bConnectingDlg = true;
		bFoundConnection = 0;
		LogisticsOneButtonDialog::instance()->setText( IDS_MP_CON_MODEM_CONNECTING, IDS_PM_CANCEL, IDS_PM_CANCEL );
		char text[256];
		char Display[256];
		cLoadString( IDS_MP_CON_MODEM_CONNECTING, text, 255 );
		EString str;
		comboBox.EditBox().getEntry( str );
		sprintf( Display, text, (const char*)str );
		LogisticsOneButtonDialog::instance()->setText( Display );
		LogisticsOneButtonDialog::instance()->begin();

		if ( MPlayer->beginSessionScan ( (char*)(const char*)str) )
		{
			LogisticsOneButtonDialog::instance()->setText( IDS_MP_CONNECT_ERROR_NO_CONNECTION, IDS_DIALOG_OK, IDS_DIALOG_OK );
		}
		connectingTime = 0.f;

		break;
		}
	case TCPIP_PANEL_FIRST_BUTTON_ID + 1:
		if (pParentScreen)
		{
			pParentScreen->handleMessage(message, who);
		}
		break;
	}
	return 0;
}
Esempio n. 9
0
void aTextListItem::setText( long resID )
{
	char tmp[4096];
	tmp[0] = 0;
	cLoadString( resID, tmp, 4095 );
	text = tmp;
}
Esempio n. 10
0
//----------------------------------------------------------------------------
void InitDW (void)
{
	cLoadString(IDS_WATSON_CRASH_MSG,WatsonCrashMessage,4095);
	AnsiToUnicode(WatsonCrashMessage,&WatsonCrashMessageUnicode);

	SetUnhandledExceptionFilter(DwExceptionFilter);
}
Esempio n. 11
0
int OptionsHotKeys::makeInputKeyString( long& tmpKey, char* hotKeyString )
{
		const char* pText = gos_DescribeKey( tmpKey & 0x0001ff00 );

		long tmp = ( tmpKey >> 8 ) & 0x01ff;
		if ( tmp == KEY_LSHIFT || tmp == KEY_LMENU || tmp == KEY_LCONTROL )
			return -1;

		long hotKey = tmp;

		bool shiftDn = userInput->shift();
		if ( shiftDn )
		{
			char shift[32];
			cLoadString( IDS_SHIFT, shift, 31 );

			hotKey |= SHIFT;
			strcat( hotKeyString, shift );
			strcat( hotKeyString, " + " );
		}
		bool ctrlDn = userInput->ctrl();
		if ( ctrlDn )
		{
			char control[32];
			cLoadString( IDS_CONTROL, control, 31 );

			hotKey |= CTRL;
			strcat( hotKeyString, control );
			strcat( hotKeyString, " + " );
		}
		bool altDn = userInput->alt();

		if ( altDn )
		{
			char alt[32];
			cLoadString( IDS_ALT, alt, 31 );

			hotKey |= ALT;
			strcat( hotKeyString, alt );
			strcat( hotKeyString, " + " );
		}

		strcat( hotKeyString, pText );
		tmpKey = hotKey;

		return 0;
}
void LogisticsMechDisplay::setMech( LogisticsMech* pMech, bool bFromLB )
{
		if ( pMech != pCurMech )
		{
			pCurMech = pMech;
			if ( pCurMech )
			{
				textObjects[0].setText( pCurMech->getChassisName() );
				textObjects[1].setText( pCurMech->getName() );

				char text[64];
				char tmpStr[64];
				cLoadString( IDS_MB_MECH_WEIGHT, tmpStr, 63 );
				sprintf( text, tmpStr, pCurMech->getMaxWeight(), (const char*)pCurMech->getMechClass() );
				textObjects[3].setText( text );
				
				long tmpColor;
				textObjects[2].setText( pCurMech->getVariant()->getOptimalRangeString( tmpColor ) );
				textObjects[2].setColor( tmpColor );

				sprintf( text, "%ld", pCurMech->getArmor() );
				textObjects[4].setText( text );

				sprintf( text, "%ld", pCurMech->getDisplaySpeed() );
				textObjects[5].setText( text );

				sprintf( text, "%ld", pCurMech->getJumpRange() * 25);
				textObjects[6].setText( text );

				attributeMeters[0].setValue( pCurMech->getArmor()/MAX_ARMOR_RANGE);
				attributeMeters[1].setValue( pCurMech->getSpeed()/MAX_SPEED_RANGE);
				attributeMeters[2].setValue( pCurMech->getJumpRange() * 25 / MAX_JUMP_RANGE);

				
				EString fileName = pMech->getFileName();
				int index = fileName.Find( '.' );
				fileName = fileName.Left( index );
				index = fileName.ReverseFind( '\\' );
				fileName = fileName.Right( fileName.Length() - index - 1 );
				mechCamera.setMech( fileName, prefs.baseColor, prefs.highlightColor, prefs.highlightColor );	
				mechCamera.setScale( pMech->getVariant()->getChassis()->getScale() );
				
				componentListBox.setMech( pCurMech->getVariant() );

			}
			else
			{
				for ( int i = 0; i < 6; i++ )
					textObjects[i].setText( "" );

				attributeMeters[0].setValue( 0 );
				attributeMeters[1].setValue( 0 );
				attributeMeters[2].setValue( 0 );

				componentListBox.setMech( 0 );
				mechCamera.setMech( NULL );
			}
		}
}
void LogisticsVehicle::init(FitIniFile& file)
{
	componentCount = 0;
	file.seekBlock("ObjectType");
	char tmp[256];
	file.readIdString("AppearanceName", tmp, 255);
	fileName = tmp;
	file.seekBlock("General");
	file.readIdLong("DescIndex", chassisNameID);
	file.readIdFloat("CurTonnage", maxWeight);
	char tmpWeightClass[256];
	cLoadString(IDS_VEHICLE_CLASS, tmpWeightClass, 256);
	mechClass = tmpWeightClass;
	if(NO_ERROR != file.readIdLong("HouseID", houseID))
	{
		houseID = -1;
	}
	if(NO_ERROR != file.readIdLong("EncyclopediaID", encyclopediaID))
	{
		encyclopediaID = IDS_VEHICLE_DESCRIPTION_0;
	}
	file.seekBlock("VehicleDynamics");
	file.readIdFloat("MaxVelocity", speed);
	PSTR parts[5] = { "Front", "Left", "Right", "Rear", "Turret" };
	baseArmor = 0;
	uint8_t pts;
	int32_t i;
	for(i = 0; i < 5; i++)
	{
		file.seekBlock(parts[i]);
		file.readIdUChar("MaxArmorPoints", pts);
		baseArmor += pts;
		file.readIdUChar("CurInternalStructure", pts);
		baseArmor += pts;
	}
	file.seekBlock("InventoryInfo");
	file.readIdUChar("NumWeapons", pts);
	char blockName[256];
	for(i = 4; i < 4 + pts; i++)
	{
		sprintf(blockName, "Item:%ld", i);
		if(NO_ERROR == file.seekBlock(blockName))
		{
			uint8_t fitID;
			file.readIdUChar("MasterID", fitID);
			LogisticsComponent* pComponent = LogisticsData::instance->getComponent(fitID);
			if(pComponent)
			{
				components[componentCount].component = pComponent;
				components[componentCount].xCoord = 0;
				components[componentCount].yCoord = 0;
				componentCount++;
			}
		}
	}
}
Esempio n. 14
0
static BOOL CSLoadString(int resourceID, CString &targetStr) {
	char szTmp[16384/*max string length*/];
	cLoadString( resourceID, szTmp, 16384/*max string length*/ );
	targetStr = szTmp;
	CString tmpStr;
	tmpStr.Format("mc2res.dll:%d Not defined", resourceID);
	if (0 == strcmp(tmpStr.GetBuffer(0), szTmp)) {
		return (0);
	}
	return (!0);
}
Esempio n. 15
0
void aButton::render()
{
	if ( state != HIDDEN )
	{
		if ( textureHandle )
		{
			unsigned long gosID = mcTextureManager->get_gosTextureHandle( textureHandle );
			gos_SetRenderState( gos_State_Texture, gosID ); 
		}
		else
			gos_SetRenderState( gos_State_Texture, 0 ); 

			gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
			gos_SetRenderState( gos_State_Filter, gos_FilterNone);
			gos_SetRenderState( gos_State_AlphaTest, true);
			gos_SetRenderState( gos_State_TextureAddress, gos_TextureClamp );
			gos_SetRenderState( gos_State_TextureMapBlend,gos_BlendModulateAlpha );

			gos_DrawQuads( location, 4 );


		if ( data.textID && data.textFont )
		{
			char buffer[256];
			cLoadString( data.textID, buffer, 256 );
			DWORD width, height;
			gos_TextSetAttributes(data.textFont, data.textColors[state], data.textSize, true, true, false, false, data.textAlign);			
			gos_TextSetRegion( data.textRect.left, data.textRect.top, data.textRect.right, data.textRect.bottom );
			gos_TextStringLength( &width, &height, buffer );
			gos_TextSetPosition( data.textRect.left, (data.textRect.top + data.textRect.bottom)/2 - height/2 + 1 );
			gos_TextDraw( buffer );

			if ( data.outlineText )
			{
				drawEmptyRect( data.textRect, data.textColors[state], data.textColors[state] );
			}
		}
		if ( data.outline )
		{
			GUI_RECT tmp;
			tmp.left = location[0].x;
			tmp.top = location[0].y;
			tmp.right = location[2].x;
			tmp.bottom = location[2].y;

			drawEmptyRect( tmp, location[0].argb, location[0].argb );
		}

		for ( int i = 0; i < numberOfChildren(); i++ )
		{
			pChildren[i]->render();
		}
	}
}
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( "" );

	}

}
Esempio n. 17
0
void aText::setText(int32_t resID)
{
	char tmp[1280];
	cLoadString(resID, tmp, 1279);
	if (tmp[0] != 0)
		text = tmp;
	else
	{
		char tmpy[1280];
		memset(tmpy, 0, 1280);
		sprintf(tmpy, "nullptr for ID: %d", resID);
		text = tmpy;
	}
}
Esempio n. 18
0
void OptionsHotKeys::reset( bool useOld )
{

	hotKeyList.removeAllItems( true );
	char shift[32];
	char control[32];
	char alt[32];
	char descText[128];
	char keysString[128];

	cLoadString( IDS_SHIFT, shift, 31 );
	cLoadString( IDS_CONTROL, control, 31 );
	cLoadString( IDS_ALT, alt, 31 );

	MissionInterfaceManager::Command* commands = MissionInterfaceManager::getCommands();
	long*	oldKeys = MissionInterfaceManager::getOldKeys();
	for ( int i = 0; i < MAX_COMMAND; i++ )
	{
		if ( commands[i].hotKeyDescriptionText != -1 )
		{
			keysString[0] = 0;
			cLoadString( commands[i].hotKeyDescriptionText, descText, 127 );
			long key = useOld ? oldKeys[i] : commands[i].key;
			makeKeyString( key, keysString );

			HotKeyListItem* item = new HotKeyListItem();
			item->setDescription( descText );
			item->setKey( keysString );		
			item->setHotKey( key );
			item->setCommand( i );
			hotKeyList.AddItem( item );
			


		}
	}
}
DeadPilotListItem::DeadPilotListItem( LogisticsPilot* pPilot )
{
	char tmpText[256];	
	char realText[256];

	aObject::init( s_area->left(), s_area->top(), s_area->width(), s_area->height() );

	killsText = *s_killsText;
	nameText = *s_nameText;
	rankText = *s_rankText;
	missionText = *s_missionText;

	int missions = pPilot->getNumberMissions();
	cLoadString( IDS_PILOT_MISSIONS, tmpText, 255 );
	sprintf( realText, tmpText, missions );	
	missionText.setText( realText);


	int numberOfKills = pPilot->getInfantryKills() + pPilot->getMechKills() + pPilot->getVehicleKills();
	cLoadString( IDS_PILOT_KILLS, tmpText, 255 );
	sprintf( realText, tmpText, numberOfKills );	
	killsText.setText( realText);

	const char* name = pPilot->getName();
	cLoadString( IDS_PILOT_NAME, tmpText, 255 );
	sprintf( realText, tmpText, name );	
	nameText.setText( realText);


	long rank = pPilot->getRank();
	char rankStr[32];
	//ACE Not Contiguous with other ranks.  Added too late.
	if (rank != 4)
		cLoadString( rank + IDS_GREEN, rankStr, 31 );
	else
		cLoadString( IDS_ACE, rankStr, 31 );

	cLoadString( IDS_PILOT_RANK, tmpText, 255 );
	sprintf( realText, tmpText, rankStr );	
	rankText.setText( realText);

	
	addChild( &killsText );
	addChild( &nameText );
	addChild( &rankText );
	addChild( &missionText );

	liveIcon = new PilotIcon( );
	liveIcon->setTextureIndex( pPilot->getPhotoIndex() );
	deadIcon = new PilotIcon( );
	deadIcon->setTextureIndex( PilotIcon::DEAD_PILOT_INDEX );

	showWindow = 0;


}
Esempio n. 20
0
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 );
	}
}
Esempio n. 21
0
HGOSFONT3D aFont::loadFont( long resourceID, long& size )
{
	size = 1;
	char buffer[256];
	cLoadString( resourceID, buffer, 255 );

	char* pStr = strstr( buffer, "," );
	if ( pStr )
	{
		size = -atoi( pStr + 1 );
		*pStr = NULL;
	}

	char path[256];
	strcpy( path, "assets\\graphics\\" );
	strcat( path, buffer );
	_strlwr( path );
	HGOSFONT3D retFont = gos_LoadFont( path );

	return retFont;
}
Esempio n. 22
0
void MainMenu::setHostLeftDlg( const char* playerName )
{
	char leaveStr[256];
	char formatStr[256];

	cLoadString( IDS_PLAYER_LEFT, leaveStr, 255 );
	sprintf( formatStr, leaveStr, playerName );

	LogisticsOneButtonDialog::instance()->setText( IDS_PLAYER_LEFT,
					IDS_DIALOG_OK, IDS_DIALOG_OK );
	LogisticsOneButtonDialog::instance()->setText( formatStr );

	if ( MPlayer && MPlayer->playerInfo[MPlayer->commanderID].booted )
	{
		LogisticsOneButtonDialog::instance()->setText( IDS_MP_PLAYER_KICKED,
					IDS_DIALOG_OK, IDS_DIALOG_OK );

	}
	LogisticsOneButtonDialog::instance()->begin();
	bHostLeftDlg = true;

}
Esempio n. 23
0
void aText::init(FitIniFile* file, PCSTR header)
{
	int32_t result = file->seekBlock(header);
	if (result != NO_ERROR)
	{
		char errorStr[256];
		sprintf(errorStr, "couldn't find the text block%s", header);
		Assert(result == NO_ERROR, 0, errorStr);
		return;
	}
	int32_t lfont;
	file->readIdLong("Font", lfont);
	font.init(lfont);
	int32_t left, top, width, height;
	file->readIdLong("XLocation", left);
	file->readIdLong("YLocation", top);
	file->readIdLong("Width", width);
	file->readIdLong("Height", height);
	aObject::init(left, top, width, height);
	int32_t color;
	file->readIdLong("Color", color);
	for (size_t i = 0; i < 4; i++)
		location[i].argb = color;
	file->readIdLong("Alignment", alignment);
	int32_t textID;
	if (NO_ERROR == file->readIdLong("TextID", textID))
	{
		// WAY too small.  Good crash.  Only crashes in profile.
		// cLoadString now checks buffer length and keeps game from crashing!!
		// -fs
		char tmp[1024];
		cLoadString(textID, tmp, 1023);
		text = tmp;
	}
	file->readIdLong("HelpCaption", helpHeader);
	file->readIdLong("HelpDesc", helpID);
}
Esempio n. 24
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" );
	}
}
int LogisticsChassis::init( CSVFile* file, int chassisID )
{
	ID = chassisID;
	char buffer[256];
	
	fileName = file->getFilename();
	fileName.MakeLower();

	long result = file->readLong( 11, 5, baseCost );
	gosASSERT( result == NO_ERR );

	result = file->readLong( 5, 2, chassisNameID );
	gosASSERT( result == NO_ERR );
	
	result = file->readFloat(  3, 5, maxWeight );
	gosASSERT( result == NO_ERR );

	result = file->readLong( 12, 5, maxArmor );
	gosASSERT( result == NO_ERR );
	
	result = file->readLong( 8,2, helpID );
	gosASSERT( result == NO_ERR );
	
	result = file->readLong( 6, 2,  encyclopediaID );
	gosASSERT( result == NO_ERR );

	file->readLong( 12, 2, iconPictureIndex );
	gosASSERT( result == NO_ERR );

	
	houseID;
	result = file->readLong( 4, 2, houseID );
	ID |= ((houseID << 8) & 0x0000ff00);
	gosASSERT( result == NO_ERR );

	for ( int row = 9; row < 12; ++row )
	{
		result = file->readString( row, 2, buffer, 256 );
		gosASSERT( result == NO_ERR );
		iconFileNames[row - 9] = buffer;
	}

	result = file->readBoolean(  3, 8, canHaveAdvSensor );
	gosASSERT( result == NO_ERR );
	
	result = file->readBoolean(4, 8, canHaveOptics );
	gosASSERT( result == NO_ERR );
	
	result = file->readBoolean( 5, 8, canHaveGlobalSensor );
	gosASSERT( result == NO_ERR );
	
	result = file->readBoolean( 6, 8, canHaveECM );
	gosASSERT( result == NO_ERR );
	
	result = file->readBoolean( 7, 8, canHaveActiveProbe );
	gosASSERT( result == NO_ERR );

	result = file->readBoolean( 8,8, canHaveJumpJets );
	 gosASSERT( result == NO_ERR );

 	result = file->readBoolean( 9,8, canHaveExtendedSensor );
	 gosASSERT( result == NO_ERR );


	result = file->readFloat(  7, 5, speed );
	gosASSERT( result == NO_ERR );

	result = file->readLong( 4, 5, maxHeat );
	gosASSERT( result == NO_ERR );

	result = file->readLong( 6, 5, baseArmor );
	gosASSERT( result == NO_ERR );

	result = file->readLong( 13, 2, componentAreaWidth );
	gosASSERT( result == NO_ERR );

	result = file->readLong( 14, 2, componentAreaHeight );
	gosASSERT( result == NO_ERR );

	int ID = IDS_VERY_LIGHT;
	for ( int i = 4; i > -1; --i )
	{
		if ( maxWeight > weightClasses[i] )
		{
			ID = IDS_VERY_LIGHT + i + 1;
			break;
		}		
	}

	char tmpWeightClass[256];

	cLoadString( ID, tmpWeightClass, 256 );

	mechClass = tmpWeightClass;
		
	return 0;
	
	
}
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;

}
Esempio n. 27
0
int	MainMenu::handleMessage( unsigned long what, unsigned long who )
{
	switch ( who )
	{
		case MM_MSG_NEW_CAMPAIGN:
			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = MM_MSG_NEW_CAMPAIGN;
				promptToDisconnect = true;
			}
			else
			{
				endAnim.begin();
				beginAnim.end();
				bLoadCampaign = true;
				LogisticsSaveDialog::instance()->beginCampaign();
				if ( LogisticsSaveDialog::instance()->isDone() )
				{
					LogisticsData::instance->startNewCampaign( LogisticsSaveDialog::instance()->getFileName());
					status = RESTART;
				}
			}
			break;
		case MM_MSG_SAVE:
			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
		
				// need to pop dialog here
				LogisticsSaveDialog::instance()->begin();
				endAnim.begin();
				beginAnim.end();
				bSave = true;
			}
			break;

		case MM_MSG_LOAD:

			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
			
				// need to pop dialog here
				LogisticsSaveDialog::instance()->beginLoad();
				endAnim.begin();
				beginAnim.end();
				bLoad = true;
			}
			break;
		case MM_MSG_MULTIPLAYER:
			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
				endAnim.begin();
				beginAnim.end();
				endResult = MULTIPLAYERRESTART;
				LogisticsData::instance->startMultiPlayer();
			}
			break;

		case MM_MSG_RETURN_TO_GAME:
			{
			if ( !bDrawBackground )
			{
				endAnim.begin();
				beginAnim.end();
				endResult = NEXT;
				soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );
				soundSystem->playDigitalMusic(LogisticsData::instance->getCurrentMissionTune());
			}
			}
			break;
		case MM_MSG_OPTIONS:
			// need to throw up the options screen here...
			if (!optionsScreenWrapper)
			{
				optionsScreenWrapper = new OptionsScreenWrapper;
				optionsScreenWrapper->init();
			}
			optionsScreenWrapper->begin();

			bOptions = true;
			break;
		case MM_MSG_ENCYCLOPEDIA:
			bDrawMechlopedia = true;
			beginFadeOut(1.0);
			if ( !mechlopedia )
			{
				mechlopedia = new Mechlopedia;
				mechlopedia->init();
			}

			mechlopedia->begin();
			break;
		case MM_MSG_EXIT:
			promptToQuit = 1;
			// may need to set the text here
			LogisticsOKDialog::instance()->setText( IDS_DIALOG_QUIT_PROMPT,
					IDS_DIALOG_NO, IDS_DIALOG_YES );
				
			LogisticsOKDialog::instance()->begin();
			getButton( who )->press( 0 );
			break;

		case MM_MSG_SINGLE_MISSION:

			if ( MPlayer )
			{
				LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
				LogisticsOKDialog::instance()->begin();
				endResult = who;
				promptToDisconnect = true;
			}
			else
			{
				bLoadSingle = true;
				endAnim.begin();
				beginAnim.end();
				singleLoadDlg.beginSingleMission();
				getButton( who )->press( 0 );
			}
			break;

		case MM_MSG_LEGAL:
			{
				bLegal = 1;
				// may need to set the text here
				if ( !LogisticsLegalDialog::instance() )
				{
					FullPathFileName path;
					path.init( artPath, "mcl_dialoglegal", ".fit" );
					FitIniFile file;
					file.open( path );
					LogisticsLegalDialog::init( file );
				}
				LogisticsLegalDialog::instance()->setText( IDS_DIALOG_OK,
						IDS_DIALOG_OK, IDS_DIALOG_OK );
				//Needs to be this long for LOC!
				// -fs
				char realText[2048];
				cLoadString(IDS_LAWYER_BABBLE, realText, 2047 );
				char lawyerBabble[2048];
				unsigned long pIDLen = 64;
				char pID[64];
				sprintf( pID, "INVALID ID" );
				gos_LoadDataFromRegistry("PID", pID, &pIDLen);
				sprintf( lawyerBabble, realText, pID );
				LogisticsLegalDialog::instance()->setText( lawyerBabble );
				LogisticsLegalDialog::instance()->begin();
				LogisticsLegalDialog::instance()->setFont( IDS_LAWYER_BABBLE_FONT );				
				getButton( who )->press( 0 );
			}
			break;
		default:
			break;
	}

	return 0;
}
int32_t LogisticsComponent::init(PSTR dataLine)
{
	PSTR line  = dataLine;
	PSTR pLine = line;
	char pBuffer[1025];
	ID = (extractInt(pLine));
	// the type
	extractString(pLine, pBuffer, 1024);
	int32_t i;
	for (i = 0; i < NUM_COMPONENT_FORMS; ++i)
	{
		if (0 == _stricmp(ComponentFormString[i], pBuffer))
		{
			Type = i;
			break;
		}
	}
	if (i == NUM_COMPONENT_FORMS)
		return -1;
	// name, probably aren't going to use this, they should be in the RC.
	extractString(pLine, pBuffer, 1024);
	// name, probably aren't going to use this, they should be in the RC.
	extractString(pLine, pBuffer, 1024); // ignore critical hits
	recycleTime = extractFloat(pLine);
	heat		= extractFloat(pLine);
	// weight
	weight = extractFloat(pLine);
	damage = extractFloat(pLine);
	// ignore battle rating
	extractString(pLine, pBuffer, 1024);
	// cost
	cost = extractInt(pLine);
	// range
	extractString(pLine, pBuffer, 1024);
	if (!isWeapon())
		rangeType = NO_RANGE;
	else if (!strcmp(pBuffer, "int32_t"))
		rangeType = int32_t;
	else if (!strcmp(pBuffer, "medium"))
		rangeType = MEDIUM;
	else
		rangeType = int16_t;
	// we need to figure out where things can go
	extractString(pLine, pBuffer, 1024);
	bHead = _stricmp(pBuffer, "Yes") ? false : true;
	extractString(pLine, pBuffer, 1024);
	bTorso = _stricmp(pBuffer, "Yes") ? false : true;
	// ignore the next 4 columns
	for (i = 0; i < 4; ++i)
		extractString(pLine, pBuffer, 1024);
	extractString(pLine, pBuffer, 1024);
	bLegs = _stricmp(pBuffer, "Yes") ? false : true;
	// ignore the next 4 columns
	for (i = 0; i < 4; ++i)
		extractString(pLine, pBuffer, 1024);
	Ammo = extractInt(pLine);
	// now read in icon info
	extractString(pLine, pBuffer, 1024);
	if (*pBuffer && (pBuffer[0] != '0'))
	{
		iconFileName = new char[strlen(pBuffer) + 1];
		strcpy(iconFileName, pBuffer);
	}
	else
		return -1; // fail if no picture
	extractString(pLine, pBuffer, 1024);
	if (*pBuffer)
	{
		pictureFileName =
			new char[strlen(pBuffer) + 1]; // Forgot the nullptr all over the place did we?
		strcpy(pictureFileName, pBuffer);
	}
	stringID	 = extractInt(pLine);
	helpStringID = extractInt(pLine);
	iconX		 = extractInt(pLine);
	iconY		 = extractInt(pLine);
	char nameBuffer[256];
	cLoadString(stringID, nameBuffer, 256);
	name = flavorText = new char[strlen(nameBuffer) + 1]; // Lets not forget the nullptr!!!
	strcpy(name, nameBuffer);
	return ID;
}
Esempio n. 29
0
void OptionsGraphics::init(long xOffset, long yOffset)
{
	FullPathFileName path;
	path.init( artPath, "mcl_options_combobox0", ".fit" );
	FitIniFile file;
	if ( NO_ERR !=file.open( path ) )
	{
		char error[256];
		sprintf( error, "couldn't open file %s", path );
		Assert( 0, 0, error );
		return;	
	}

	getButton( MSG_RESET )->setMessageOnRelease();

	resolutionList.init( &file, "PlayerNameComboBox" );
	resolutionList.move( globalX(), globalY() );
	resolutionList.move( xOffset, yOffset );
	resolutionList.ListBox().setOrange( true );

	for ( int i = IDS_RESOLUTION0; i < IDS_RESOLUTION9 + 1; i++ )
	{
		if ( 1!=gos_GetMachineInformation( gos_Info_ValidMode, 
			Environment.FullScreenDevice, 
			resModes[i-IDS_RESOLUTION0].xRes, 
			resModes[i-IDS_RESOLUTION0].yRes,
			resModes[i-IDS_RESOLUTION0].bitDepth) )
		{
			availableMode[i-IDS_RESOLUTION0] = false;
		}
		else
		{
			char cstr[256];
			cLoadString (i, cstr, 255 );
			resolutionList.AddItem( cstr, 0xffffffff );
		}
	}

	file.close();

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

	getButton( MSG_RESET )->setMessageOnRelease();

	cardList.init( &file, "PlayerNameComboBox" );
	cardList.move( globalX(), globalY() );
	cardList.move( xOffset, yOffset );
	cardList.ListBox().setOrange( true );

	DWORD numDevices = 0;
	numDevices = gos_GetMachineInformation( gos_Info_NumberDevices );

	//Theoretically impossible but config would probably like to know if it happens!
	if (numDevices <= 0)
		STOP(("GameOS said there were no video cards in the system!"));

	long usableCardCount = 0;
	for (i=0;i<numDevices;i++)
	{
		DWORD minTextureRam = 6291456;

		//If we are a Voodoo 2, we may be a 4/8 or a 4/4.  Try allowing a 4/4 to run
		// and see what happens!!  NO good has come of this!
		/*
		if ((gos_GetMachineInformation(gos_Info_GetDeviceVendorID,i) == 0x121a) &&
			(gos_GetMachineInformation(gos_Info_GetDeviceDeviceID,i) == 0x0002))
			minTextureRam = 4096000;
		*/

		if (gos_GetMachineInformation(gos_Info_GetDeviceLocalMemory, i) >= minTextureRam)
		{
			char *deviceName = (char*)gos_GetMachineInformation( gos_Info_GetDeviceName, i);
		
			//Save name to other string here.
			cardList.AddItem( deviceName, 0xffffffff );

			if ( Environment.FullScreenDevice == i )
				cardList.SelectItem( usableCardCount );

			usableCardCount++;
		}
	}

//ALL of this is a lie.  Code is now correct but I would ignore this.
// Sorry Heidi!
// -fs

//Turns out, its the same for both.

//Environment.Renderer tells you what device you are currently using as follows:
//	If the value is 0 or 1 you are using the default device or the primary display adapter (One and the same always)
//	If the value is 2 you are using the second video card.
//	If the value is 3 you are using BLADE software renderer.

//If you set the values to any of the above, you will switch to that device.


	for ( i = 0; i < buttonCount; i++ )
	{
		buttons[i].setPressFX( LOG_VIDEOBUTTONS );
		buttons[i].setHighlightFX( LOG_DIGITALHIGHLIGHT );
		buttons[i].setDisabledFX( LOG_WRONGBUTTON );
	}


	move( xOffset, yOffset );

	helpTextArrayID = 1;



	
}
Esempio n. 30
0
//******************************************************************************************
long MasterComponent::initEXCEL (char* dataLine, float baseSensorRange) {

	//----------------------------------------------------------
	// Component data was read in, so parse it. First, parse the
	// fields common to all components...
	char* field = strtok(dataLine, ",");

	int ammoAmount = 1;

	health = 1;

	masterID = atoi(field);

	cLoadString(COMPONENT_NAME_START+masterID,name,MAXLEN_COMPONENT_NAME);
	cLoadString(COMPONENT_ABBR_START+masterID,abbreviation,MAXLEN_COMPONENT_ABBREV);
	
	field = strtok(NULL, ",");
	long formIndex;
	for (formIndex = 0; ComponentFormString[formIndex] != NULL; formIndex++)
		if (strcmp(field, ComponentFormString[formIndex]) == 0)
			break;
	if (ComponentFormString[formIndex] == NULL)
		return(-1);

	if (strcmp(field, "undefined") == 0) {
		masterID = -1;
		return(NO_ERR);
	}

	form = (ComponentFormType)formIndex;
	
	field = strtok(NULL, ","); // name, ignore

	field = strtok(NULL, ",");
	size = atof(field);

	field = strtok(NULL, ",");
	float recycleTime = atof(field);
	
	field = strtok(NULL, ",");
	float heat = (unsigned long)atof(field);

	field = strtok(NULL, ","); 
	tonnage = atof( field );

	field = strtok(NULL, ",");
	float damage = atof(field);

	field = strtok(NULL, ",");
	CV = atof(field);
	
	field = strtok(NULL, ",");
	resourcePoints = atoi(field);
	
	field = strtok(NULL, ",");
	unsigned char rangeType = 255;
	_strlwr(field);
	if (strcmp(field, "0") != 0) {
		if (strcmp(field, WeaponRangeString[WEAPON_RANGE_SHORT]) == 0)
			rangeType = WEAPON_RANGE_SHORT;
		else if (strcmp(field, WeaponRangeString[WEAPON_RANGE_MEDIUM]) == 0)
			rangeType = WEAPON_RANGE_MEDIUM;
		else if (strcmp(field, WeaponRangeString[WEAPON_RANGE_LONG]) == 0)
			rangeType = WEAPON_RANGE_LONG;
		else
			Fatal(0, " MasterComponent.initEXCEL: bad weapon range type in compbase ");
	}

	field = strtok(NULL, ",");
	for (long location = 0; location < NUM_BODY_LOCATIONS; location++) 
	{
		if ( field )
		{
			if (strcmp(field, "No") == 0)
				criticalSpacesReq[location] = -1;
			else if (strcmp(field, "Yes") == 0)
				criticalSpacesReq[location] = 0;
			else
				criticalSpacesReq[location] = atoi(field);
		}
			field = strtok(NULL, ",");

	}

	int ammoType = WEAPON_AMMO_NONE;
	if ( field )
	{
		if (strcmp(field, "1") == 0)
			ammoType = WEAPON_AMMO_LIMITED;
		else if (strcmp(field, "SRM") == 0)
			ammoType = WEAPON_AMMO_SRM;
		else if (strcmp(field, "LRM") == 0)
			ammoType = WEAPON_AMMO_LRM;
		else if (strcmp(field, "ST") == 0)
			ammoType = WEAPON_AMMO_ST;
	}

	field = strtok( NULL, "," );
	int flags = 0;
	if ( field )
		flags = atoi(field);
	
	field = strtok(NULL, ",");
	int specialEffect = 0;
	if ( field )
		specialEffect = (char)atoi(field);
	
	field = strtok(NULL, ",");
	int ammoMasterId = 0;
	if ( field )
		ammoMasterId = (char)atoi(field);
	
	switch (form) {
		case COMPONENT_FORM_SIMPLE:
			//----------------------
			// No additional data...
			break;
		case COMPONENT_FORM_COCKPIT:
			break;
		case COMPONENT_FORM_SENSOR:
			stats.sensor.range = damage * baseSensorRange;
			break;
		case COMPONENT_FORM_ECM:
			stats.ecm.effect = damage;
			field = strtok(NULL, ",");
			stats.ecm.range = recycleTime;
			break;
		case COMPONENT_FORM_JAMMER:
			stats.jammer.effect = damage;
			break;
		case COMPONENT_FORM_PROBE:
			stats.probe.effect = damage;
			break;
		case COMPONENT_FORM_ACTUATOR:
			break;
		case COMPONENT_FORM_ENGINE:
			stats.engine.rating = 0;
			break;
		case COMPONENT_FORM_HEATSINK:
			stats.heatsink.dissipation = damage;
			break;
		case COMPONENT_FORM_WEAPON_ENERGY:
		case COMPONENT_FORM_WEAPON_MISSILE:
		case COMPONENT_FORM_WEAPON_BALLISTIC:
			stats.weapon.damage = damage;
			stats.weapon.recycleTime = recycleTime;
			stats.weapon.heat = heat;
			stats.weapon.ammoAmount = 1;
			stats.weapon.ammoType = ammoType;
			stats.weapon.range = rangeType;
			stats.weapon.specialEffect = specialEffect;
			stats.weapon.ammoMasterId = ammoMasterId;
			stats.weapon.flags = ammoType == WEAPON_AMMO_ST ? WEAPON_FLAG_STREAK : 0;
			stats.weapon.ammoAmount = ammoAmount;
			break;
		case COMPONENT_FORM_AMMO:
			stats.ammo.ammoPerTon = recycleTime;
			stats.ammo.explosiveDamage = damage;
			break;
		case COMPONENT_FORM_JUMPJET:
			stats.jumpjet.rangeMod = damage;
			break;
		case COMPONENT_FORM_CASE:
			break;
		case COMPONENT_FORM_LIFESUPPORT:
			break;
		case COMPONENT_FORM_GYROSCOPE:
			break;
		case COMPONENT_FORM_POWER_AMPLIFIER:
			break;
		case COMPONENT_FORM_BULK:
			break;
		default:
			return(-2);
	}

	return(NO_ERR);
}