profile.cpp
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:28k
源码类别:

游戏

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: Profile.cpp
  3. //
  4. // Copyright (c) Microsoft Corporation. All rights reserved
  5. //-----------------------------------------------------------------------------
  6. #include "stdafx.h"
  7. //-----------------------------------------------------------------------------
  8. // Name: 
  9. // Desc: 
  10. //-----------------------------------------------------------------------------
  11. CProfile::CProfile()
  12. {
  13.     nNumThemes = 0;
  14.     aThemes = NULL;
  15.     aEnemyStyles = NULL;
  16. }
  17. //-----------------------------------------------------------------------------
  18. // Name: 
  19. // Desc: 
  20. //-----------------------------------------------------------------------------
  21. CProfile::~CProfile()
  22. {
  23.     SAFE_DELETE_ARRAY( aThemes );
  24.     SAFE_DELETE_ARRAY( aEnemyStyles );
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Name: 
  28. // Desc: this function reads our profile into member variables of the profile object.
  29. //-----------------------------------------------------------------------------
  30. VOID CProfile::GetProfile( LPCTSTR szIniName )
  31. {
  32.     HRESULT hr;
  33.     lstrcpy( m_szIniName, szIniName );
  34.     GetBulletParameters( "BULLET1", &Blaster );
  35.     Get3DSoundParameters( "ExplosionDonut", &ExplosionDonut );
  36.     GetShipParameters( "Ship", &Ship );
  37.     bLoadAudio                  = GetLong(  "GLOBAL", TEXT("LoadAudio"),                    TEXT("1") );
  38.     bRenderSplash               = GetLong(  "GLOBAL", TEXT("RenderSplash"),                 TEXT("1") );
  39.     bRenderUI                   = GetLong(  "GLOBAL", TEXT("RenderUI"),                     TEXT("1") );
  40.     bRenderRadar                = GetLong(  "GLOBAL", TEXT("RenderRadar"),                  TEXT("1") );
  41.     bRenderGround               = GetLong(  "GLOBAL", TEXT("RenderGround"),                 TEXT("1") );
  42.     bRenderSky                  = GetLong(  "GLOBAL", TEXT("RenderSky"),                    TEXT("1") );
  43.     bRenderEnemies              = GetLong(  "GLOBAL", TEXT("RenderEnemies"),                TEXT("1") );
  44.     bRenderParticles            = GetLong(  "GLOBAL", TEXT("RenderParticles"),              TEXT("1") );
  45.     bFullScreen                 = GetLong(  "GLOBAL", TEXT("FullScreen"),                   TEXT("0") );
  46.     bLoadFast                   = GetLong(  "GLOBAL", TEXT("LoadFast"),                     TEXT("0") );
  47.     bForceREF                   = GetLong(  "GLOBAL", TEXT("ForceREF"),                     TEXT("0") );
  48.     bForceSoftwareVP            = GetLong(  "GLOBAL", TEXT("ForceSoftwareVP"),              TEXT("0") );
  49.     bForceHardwareVP            = GetLong(  "GLOBAL", TEXT("ForceHardwareVP"),              TEXT("0") );
  50.     fChangeGunRecharge          = GetFloat( "GLOBAL", TEXT("ChangeGunRecharge"),            TEXT("0.5") );
  51.     flDistanceFactor            = GetFloat( "GLOBAL", TEXT("DistanceFactor"),               TEXT("1.0") );
  52.     flRolloffFactor             = GetFloat( "GLOBAL", TEXT("RolloffFactor"),                TEXT("1.0") );
  53.     flDopplerFactor             = GetFloat( "GLOBAL", TEXT("DopplerFactor"),                TEXT("1.0") );
  54.     nNumEnemiesPerLevelScale    = GetLong(  "GLOBAL", TEXT("NumEnemiesPerLevelScale"),      TEXT("2") );
  55.     nNumEnemiesBase             = GetLong(  "GLOBAL", TEXT("NumEnemiesBase"),               TEXT("3") );
  56.     nRenderTerrianStyle         = GetLong(  "GLOBAL", TEXT("RenderTerrainStyle"),           TEXT("1") );
  57.     nWorldHeight                = GetLong(  "GLOBAL", TEXT("WorldHeight"),                  TEXT("3") );
  58.     nWorldWidth                 = GetLong(  "GLOBAL", TEXT("WorldWidth"),                   TEXT("3") );
  59.     dwRenderText                = GetLong(  "GLOBAL", TEXT("RenderText"),                   TEXT("1") );
  60.     fFOV                        = GetFloat( "GLOBAL", TEXT("FOV"),                          TEXT("0.7853") );
  61.     bGenerateMipMaps = GetLong(  "GLOBAL", TEXT("GenerateMipMaps"), TEXT("1") );
  62.     bOptimizeMesh               = GetLong(  "GLOBAL", TEXT("OptimizeMesh"),                 TEXT("1") );
  63.     bCompactMesh                = GetLong(  "GLOBAL", TEXT("CompactMesh"),                  TEXT("1") );
  64.     bSimplifyMesh               = GetLong(  "GLOBAL", TEXT("SimplifyMesh"),                 TEXT("1") );
  65.     fSimplifyMeshFactor         = GetFloat( "GLOBAL", TEXT("SimplifyMeshFactor"),           TEXT("0.25") );
  66.     fRenderDist                 = GetFloat( "GLOBAL", TEXT("RenderDist"),                   TEXT("250.0f") );
  67.     fZFarDist                   = GetFloat( "GLOBAL", TEXT("ZFarDist"),                     TEXT("250.0f") );
  68.     fFogStart                   = GetFloat( "GLOBAL", TEXT("FogStart"),                     TEXT("80.0f") );
  69.     fFogEnd                     = GetFloat( "GLOBAL", TEXT("FogEnd"),                       TEXT("300.0f") );
  70.     nNumThemes                  = GetLong( "THEMES", TEXT("NumThemes"),                     TEXT("1") );
  71.     if( NULL == aThemes )
  72.     {
  73.         aThemes = new CThemeStyle[nNumThemes];
  74.         if( NULL == aThemes )
  75.             return;
  76.         ZeroMemory( aThemes, sizeof(CThemeStyle)*nNumThemes );
  77.     }
  78.     for( int iTheme=0; iTheme<nNumThemes; iTheme++ )
  79.     {
  80.         TCHAR strName[MAX_PATH];
  81.         TCHAR strFileName[MAX_PATH];
  82.         TCHAR strFilePath[MAX_PATH];
  83.         wsprintf( strName, "Theme%d", iTheme+1 );
  84.         GetString( strFileName, TEXT("THEMES"), strName, TEXT("theme1.ini") );
  85.         if( FAILED( hr = CMyApplication::FindMediaFileCch( strFilePath, sizeof(strFilePath)/sizeof(TCHAR), strFileName ) ) )
  86.         {
  87.             g_pApp->CleanupAndDisplayError( DONUTSERR_ARTLOADFAILED, strFileName, strFilePath );
  88.             DXTRACE_ERR( TEXT("FindMediaFileCch"), hr );
  89.             return;
  90.         }
  91.         GetTheme( &aThemes[iTheme], strFilePath );
  92.     }
  93.     bForceThemeSelect = GetLong( "THEMES", TEXT("ForceThemeSelect"), TEXT("0") );
  94.     nSelectTheme      = GetLong( "THEMES", TEXT("SelectTheme"),      TEXT("1") ) - 1;
  95.     GetString( szUITextureMap,     TEXT("GLOBAL"), TEXT("UITextureMap"),     TEXT("ui.bmp") );
  96.     GetString( szSplashTextureMap, TEXT("GLOBAL"), TEXT("SplashTextureMap"), TEXT("splash.bmp") );
  97.     GetString( szAudioScript,      TEXT("GLOBAL"), TEXT("AudioScript"),      TEXT("donuts4.spt") );
  98.     
  99.     nNumEnemies         = GetLong( "GLOBAL", TEXT("NumEnemies"),            TEXT("1") );
  100.     bForceEnemySelect   = GetLong( "GLOBAL", TEXT("ForceEnemySelect"),      TEXT("0") );
  101.     nSelectEnemy        = GetLong( "GLOBAL", TEXT("SelectEnemy"),           TEXT("1") ) - 1;
  102.     if( NULL == aEnemyStyles )
  103.     {
  104.         aEnemyStyles = new CEnemyStyle[nNumEnemies];
  105.         if( NULL == aEnemyStyles )
  106.             return;
  107.         ZeroMemory( aEnemyStyles, sizeof(CEnemyStyle)*nNumEnemies );
  108.     }
  109.     for( int iEnemy=0; iEnemy<nNumEnemies; iEnemy++ )
  110.     {
  111.         TCHAR strName[MAX_PATH];
  112.         wsprintf( strName, "ENEMY%d", iEnemy+1 );
  113.         GetEnemyStyle( &aEnemyStyles[iEnemy], strName );
  114.     }
  115.     for( int i=0; i<10; i++ )
  116.     {
  117.         TCHAR strName[MAX_PATH];
  118.         wsprintf( strName, "NTemp%d", i );
  119.         nTemp[i] = GetLong( "GLOBAL", strName, TEXT("1") );
  120.         wsprintf( strName, "FTemp%d", i );
  121.         fTemp[i] = GetFloat( "GLOBAL", strName, TEXT("1.0f") );
  122.     }
  123. }
  124. //-----------------------------------------------------------------------------
  125. // Name: 
  126. // Desc: 
  127. //-----------------------------------------------------------------------------
  128. VOID CProfile::GetEnemyStyle( CEnemyStyle* pEnemyStyle, TCHAR* strSection )
  129. {
  130.     TCHAR strName[MAX_PATH];
  131.     GetString( strName, strSection, TEXT("EnemyCreationType"), TEXT("FromFile") );
  132.     if( lstrcmp( strName, TEXT("FromFile" ) ) == 0 )
  133.         pEnemyStyle->EnemyCreationType = ECT_FromFile;
  134.     else if( lstrcmp( strName, TEXT("CreateTest" ) ) == 0 )
  135.         pEnemyStyle->EnemyCreationType = ECT_CreateTest;
  136.     GetString( pEnemyStyle->strEnemyModel, strSection, TEXT("EnemyModel"), TEXT("enemy.x") );
  137.     pEnemyStyle->fEnemySpeedFactor   = GetFloat( strSection, TEXT("EnemySpeedFactor"),       TEXT("30.0f") );
  138.     pEnemyStyle->dwEnemyAmbientLight = GetHex( strSection, TEXT("EnemyAmbientLight"), TEXT("0x00000000") );
  139.     GetString( strName, strSection, TEXT("EnemyMovementType"), TEXT("MoveRandom") );
  140.     if( lstrcmp( strName, TEXT("None" ) ) == 0 )
  141.         pEnemyStyle->EnemyMovementType = EMT_None;
  142.     else if( lstrcmp( strName, TEXT("MoveRandom" ) ) == 0 )
  143.         pEnemyStyle->EnemyMovementType = EMT_MoveRandom;
  144.     else if( lstrcmp( strName, TEXT("MoveTowards" ) ) == 0 )
  145.         pEnemyStyle->EnemyMovementType = EMT_MoveTowards;
  146.     else
  147.         MessageBox( NULL, "Unknown EnemyMovementType", strName, MB_OK );
  148.     GetString( strName, strSection, TEXT("EnemyAttackType"), TEXT("None") );
  149.     if( lstrcmp( strName, TEXT("None" ) ) == 0 )
  150.         pEnemyStyle->EnemyAttackType = EAT_None;
  151.     else
  152.         MessageBox( NULL, "Unknown EnemyAttackType", strName, MB_OK );
  153.     pEnemyStyle->fMoveRandomCountdown    = GetFloat( strSection, TEXT("MoveRandomCountdown"),        TEXT("1.0f") );
  154.     pEnemyStyle->fThrustCountdown        = GetFloat( strSection, TEXT("ThrustCountdown"),            TEXT("1.0f") );
  155.     pEnemyStyle->fTurnCountdown          = GetFloat( strSection, TEXT("TurnCountdown"),              TEXT("0.1f") );
  156.     pEnemyStyle->fMoveTowardsAccuracy    = GetFloat( strSection, TEXT("MoveTowardsAccuracy"),        TEXT("0.1f") );
  157.     pEnemyStyle->fMaxHealth              = GetFloat( strSection, TEXT("MaxHealth"),                  TEXT("100.0") );
  158.     pEnemyStyle->fMass                   = GetFloat( strSection, TEXT("Mass"),                       TEXT("5.0") );
  159.     pEnemyStyle->fInvulnerableCountdown  = GetFloat( strSection, TEXT("InvulnerableCountdown"),      TEXT("0.0") );
  160.     pEnemyStyle->fHitAnimationCountdown  = GetFloat( strSection, TEXT("HitAnimationCountdown"),      TEXT("1.0") );
  161.     pEnemyStyle->fDeathAnimationCountdown= GetFloat( strSection, TEXT("DeathAnimationCountdown"),    TEXT("1.0") );
  162.     pEnemyStyle->fDamage                 = GetFloat( strSection, TEXT("Damage"),                     TEXT("10.0") );
  163.     DWORD dwColor;
  164.     dwColor                              = GetHex( strSection, TEXT("AliveColor"),                   TEXT("0x00000000") );
  165.     pEnemyStyle->clrAlive = dwColor;
  166.     dwColor                              = GetHex( strSection, TEXT("DeadColor"),                    TEXT("0x00000000") );
  167.     pEnemyStyle->clrDead  = dwColor;
  168.     pEnemyStyle->fMass                   = GetFloat( strSection, TEXT("Mass"),                       TEXT("5.0") );
  169. }
  170. //-----------------------------------------------------------------------------
  171. // Name: 
  172. // Desc: This function gets the sound parameters from
  173. //       the specified section of the private profile. 
  174. //-----------------------------------------------------------------------------
  175. VOID CProfile::GetLandType( CZoneStyleParameter* pLandType, TCHAR* strSection )
  176. {
  177.     TCHAR strName[MAX_PATH];
  178.     GetString( strName, strSection, TEXT("HeightCreationType"), TEXT("FromFile") );
  179.     if( lstrcmp( strName, TEXT("FromFile" ) ) == 0 )
  180.         pLandType->HeightCreationType = HCT_FromFile;
  181.     else if( lstrcmp( strName, TEXT("CreateTest" ) ) == 0 )
  182.         pLandType->HeightCreationType = HCT_CreateTest;
  183.     GetString( pLandType->szHeightMap, strSection, TEXT("HeightMap"), TEXT("land.bmp") );
  184.     GetString( strName, strSection, TEXT("TextureCreationType"), TEXT("FromLayers") );
  185.     if( lstrcmp( strName, TEXT("FromFile" ) ) == 0 )
  186.         pLandType->TextureCreationType = TCT_FromFile;
  187.     else if( lstrcmp( strName, TEXT("CreateTest" ) ) == 0 )
  188.         pLandType->TextureCreationType = TCT_CreateTest;
  189.     else if( lstrcmp( strName, TEXT("CreateFromHeight" ) ) == 0 )
  190.         pLandType->TextureCreationType = TCT_CreateFromHeight;
  191.     else if( lstrcmp( strName, TEXT("FromLayers" ) ) == 0 )
  192.         pLandType->TextureCreationType = TCT_FromLayers;
  193.     pLandType->dwTextureSize = GetLong( strSection, TEXT("TextureSize"), TEXT("256") );
  194.     if( pLandType->TextureCreationType == TCT_FromLayers || 
  195.         pLandType->TextureCreationType == TCT_CreateFromHeight )
  196.     {
  197.         pLandType->dwNumLayers           = GetLong( strSection, TEXT("NumLayers"), TEXT("1") );
  198.         assert( pLandType->dwNumLayers <= MAX_SOURCE_TEXTURES );
  199.         for( DWORD iLayer=0; iLayer<pLandType->dwNumLayers; iLayer++ )
  200.         {
  201.             wsprintf( strName, "LayerTexture%d", iLayer+1 );
  202.             GetString( pLandType->aLayerTexture[iLayer], strSection, strName, TEXT("gfx\land_sand64.bmp") );
  203.             wsprintf( strName, "LayerHeight%d", iLayer+1 );
  204.             pLandType->aLayerHeight[iLayer] = GetFloat( strSection, strName, TEXT("0.0f") ) / MAX_HEIGHT_OF_MAP;
  205.             wsprintf( strName, "LayerTile%d", iLayer+1 );
  206.             pLandType->aLayerTile[iLayer] = GetFloat( strSection, strName, TEXT("4.0f") );
  207.             wsprintf( strName, "LayerRandomness%d", iLayer+1 );
  208.             pLandType->aLayerRandomness[iLayer] = GetFloat( strSection, strName, TEXT("0.05f") );
  209.             wsprintf( strName, "LayerColor%d", iLayer+1 );
  210.             pLandType->aLayerColor[iLayer] = GetHex( strSection, strName, TEXT("0xFF0000FF") );
  211.             wsprintf( strName, "LayerBlendFactor%d", iLayer+1 );
  212.             pLandType->fLayerBlendFactor[iLayer] = GetFloat( strSection, strName, TEXT("1.4f") );
  213.         }
  214.     }
  215.     GetString( pLandType->szTextureMap, strSection, TEXT("TextureMap"), TEXT("land.bmp") );
  216.     pLandType->bSaveMedia = GetLong( strSection, TEXT("SaveMedia"), TEXT("0") );
  217. }
  218. //-----------------------------------------------------------------------------
  219. // Name: 
  220. // Desc: 
  221. //-----------------------------------------------------------------------------
  222. VOID CProfile::GetSkyParameters( CSkyParameter* pSky, LPCTSTR strSection )
  223. {
  224.     GetString( pSky->szModel, TEXT("SKY"), TEXT("Model"), TEXT("sky-model.x") );
  225.     GetString( pSky->szTextureMap, TEXT("SKY"), TEXT("TextureMap"), TEXT("sky-texture.bmp") );
  226.     pSky->dwFogColor = GetHex( TEXT("SKY"), TEXT("FogColor"), TEXT("0xFF0000FF") );
  227.     pSky->dwClearColor = GetHex( TEXT("SKY"), TEXT("ClearColor"), TEXT("0xFF000000") );
  228.     pSky->fOffsetY   = GetFloat( TEXT("SKY"), TEXT("OffsetY"), TEXT("-400.0f") );
  229.     pSky->fScaleX    = GetFloat( TEXT("SKY"), TEXT("ScaleX"), TEXT("1.0f") );
  230.     pSky->fScaleY    = GetFloat( TEXT("SKY"), TEXT("ScaleY"), TEXT("1.0f") );
  231.     pSky->fScaleZ    = GetFloat( TEXT("SKY"), TEXT("ScaleZ"), TEXT("1.0f") );
  232. }
  233. //-----------------------------------------------------------------------------
  234. // Name: 
  235. // Desc: This function gets the sound parameters from
  236. //       the specified section of the private profile. 
  237. //-----------------------------------------------------------------------------
  238. VOID CProfile::GetSoundParameters(TCHAR* strSection, CSoundParameter* pSoundParam)
  239. {
  240.     TCHAR szBuffer[MAX_PATH];
  241.     GetPrivateProfileString( strSection, TEXT("WavFile"), TEXT(""), 
  242.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  243.     lstrcpy( pSoundParam->szFile, szBuffer );
  244.     GetPrivateProfileString( strSection, TEXT("SampleRateOffset"), TEXT("0"), 
  245.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  246.     pSoundParam->lSampleRateOffset = _ttol(szBuffer);
  247.     GetPrivateProfileString( strSection, TEXT("SampleRateDelta"), TEXT("0"), 
  248.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  249.     pSoundParam->lSampleRateDelta = _ttol(szBuffer);
  250.     GetPrivateProfileString( strSection, TEXT("Volume"), TEXT("0"), 
  251.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  252.     pSoundParam->lVolume = _ttol(szBuffer);
  253.     GetPrivateProfileString( strSection, TEXT("BufferCount"), TEXT("1"), 
  254.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  255.     pSoundParam->lBufferCount = _ttol(szBuffer);
  256. }
  257. //-----------------------------------------------------------------------------
  258. // Name: 
  259. // Desc: Reads the parameters for a bullet from the specified section
  260. //       of the private profile. 
  261. //-----------------------------------------------------------------------------
  262. VOID CProfile::Get3DSoundParameters(TCHAR* strSection, C3DSoundParameter * p3DSoundParam)
  263. {   
  264.     TCHAR szBuffer[MAX_PATH];
  265.     GetSoundParameters(strSection, p3DSoundParam);
  266.     GetPrivateProfileString( strSection, TEXT("MinDistance"), TEXT("0.0"), 
  267.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  268.     p3DSoundParam->flMinDistance= (D3DVALUE)_tcstod(szBuffer,TEXT(''));
  269.     GetPrivateProfileString( strSection, TEXT("MaxDistance"), TEXT("10.0"), 
  270.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  271.     p3DSoundParam->flMaxDistance = (D3DVALUE)_tcstod(szBuffer,TEXT(''));
  272. }
  273. //-----------------------------------------------------------------------------
  274. // Name: 
  275. // Desc: Reads the parameters for a bullet from the specified section
  276. //       of the private profile. 
  277. //-----------------------------------------------------------------------------
  278. VOID CProfile::GetBulletParameters(TCHAR* strSection, CBulletParameter * pBulletParam)
  279. {
  280.     GetSoundParameters(strSection, pBulletParam);
  281.     pBulletParam->fRechargeTime     = GetFloat( strSection, TEXT("RechargeTime"), TEXT("1.0f") );
  282.     pBulletParam->fDamage           = GetFloat( strSection, TEXT("Damage"), TEXT("10.0f") );
  283.     pBulletParam->fExpireCountdown  = GetFloat( strSection, TEXT("ExpireCountdown"), TEXT("5.0f") );
  284.     pBulletParam->fSpeed            = GetFloat( strSection, TEXT("Speed"), TEXT("5.0f") );
  285.     pBulletParam->bUseParticles             = GetLong(  strSection, TEXT("UseParticles"), TEXT("1") );
  286.     GetString( pBulletParam->szParticleTextureMap, strSection, TEXT("ParticleTextureMap"), TEXT("particle.bmp") );
  287.     pBulletParam->fParticleRadius           = GetFloat(  strSection, TEXT("ParticleRadius"), TEXT("0.03f") );
  288.     pBulletParam->dwNumParticlesToEmit      = GetLong(  strSection, TEXT("NumParticlesToEmit"), TEXT("10") );
  289.     pBulletParam->dwParticleColor           = GetHex( strSection, TEXT("ParticleColor"), TEXT("0xFFFFFFFF") );
  290.     pBulletParam->dwParticleColorFade       = GetHex( strSection, TEXT("ParticleColorFade"), TEXT("0xFF3030FF") );
  291.     pBulletParam->fEmitVel                  = GetFloat( strSection, TEXT("EmitVel"),                  TEXT("8.0") );
  292.     pBulletParam->fMass                     = GetFloat( strSection, TEXT("Mass"),                      TEXT("5.0") );
  293.     GetString( pBulletParam->strBulletModel, strSection, TEXT("Model"), TEXT("bullet.x") );
  294.     pBulletParam->dwAmbientLight = GetHex( strSection, TEXT("AmbientLight"), TEXT("0x00000000") );
  295. }
  296. //-----------------------------------------------------------------------------
  297. // Name: 
  298. // Desc: Reads the parameters for a bullet from the specified section
  299. //       of the private profile. 
  300. //-----------------------------------------------------------------------------
  301. VOID CProfile::GetShipParameters( TCHAR* strSection, CShipParameter * pShipParam)
  302. {
  303.     pShipParam->fShowDelay     = GetFloat( strSection, TEXT("ShowDelay"),     TEXT("2.0") );
  304.     pShipParam->fAccelFactor   = GetFloat( strSection, TEXT("AccelFactor"),   TEXT("5.0") );
  305.     pShipParam->fDecelFactor   = GetFloat( strSection, TEXT("DecelFactor"),   TEXT("0.5") );
  306.     pShipParam->fSpeedFactor   = GetFloat( strSection, TEXT("SpeedFactor"),   TEXT("2.5") );
  307.     pShipParam->fRollDecelFactor  = GetFloat( strSection, TEXT("RollDecelFactor"),   TEXT("0.9") );
  308.     pShipParam->fStartX        = GetFloat( strSection, TEXT("StartX"),       TEXT("0.0") );
  309.     pShipParam->fStartY        = GetFloat( strSection, TEXT("StartY"),       TEXT("0.0") );
  310.     pShipParam->fStartZ        = GetFloat( strSection, TEXT("StartZ"),       TEXT("0.0") );
  311.     pShipParam->fMaxSlope      = GetFloat( strSection, TEXT("MaxSlope"),     TEXT("2.0") );
  312.     pShipParam->fFollowTerrianStartHeight = GetFloat( strSection, TEXT("FollowTerrianStartHeight"),  TEXT("10.0") );
  313.     pShipParam->fFollowTerrianOffset      = GetFloat( strSection, TEXT("FollowTerrianOffset"),       TEXT("10.0") );
  314.     pShipParam->fMinHeight                = GetFloat( strSection, TEXT("MinHeight"),                 TEXT("20.0") );
  315.     pShipParam->fFallRate                 = GetFloat( strSection, TEXT("FallRate"),                 TEXT("5.0") );
  316.     pShipParam->fRiseRate                 = GetFloat( strSection, TEXT("RiseRate"),                 TEXT("50.0") );
  317.     pShipParam->fMass           = GetFloat( strSection, TEXT("Mass"),                 TEXT("5.0") );
  318.     pShipParam->fMaxShield      = GetFloat( strSection, TEXT("MaxShield"),                  TEXT("100.0") );
  319. }
  320. //-----------------------------------------------------------------------------
  321. // Name: 
  322. // Desc: 
  323. //-----------------------------------------------------------------------------
  324. VOID CProfile::GetLight( CLightParameter* pLight, TCHAR* strSection )
  325. {
  326.     pLight->vDirection.x       = GetFloat( strSection, TEXT("DirectionX"),     TEXT("1.0") );
  327.     pLight->vDirection.y       = GetFloat( strSection, TEXT("DirectionY"),     TEXT("-1.0") );
  328.     pLight->vDirection.z       = GetFloat( strSection, TEXT("DirectionZ"),     TEXT("1.0") );
  329.     pLight->vDiffuse.x       = GetFloat( strSection, TEXT("DiffuseR"),     TEXT("1.0") );
  330.     pLight->vDiffuse.y       = GetFloat( strSection, TEXT("DiffuseG"),     TEXT("1.0") );
  331.     pLight->vDiffuse.z       = GetFloat( strSection, TEXT("DiffuseB"),     TEXT("1.0") );
  332.     pLight->vSpecular.x       = GetFloat( strSection, TEXT("SpecularR"),     TEXT("0.0") );
  333.     pLight->vSpecular.y       = GetFloat( strSection, TEXT("SpecularG"),     TEXT("0.0") );
  334.     pLight->vSpecular.z       = GetFloat( strSection, TEXT("SpecularB"),     TEXT("0.0") );
  335.     pLight->vAmbient.x       = GetFloat( strSection, TEXT("AmbientR"),     TEXT("0.0") );
  336.     pLight->vAmbient.y       = GetFloat( strSection, TEXT("AmbientG"),     TEXT("0.0") );
  337.     pLight->vAmbient.z       = GetFloat( strSection, TEXT("AmbientB"),     TEXT("0.0") );
  338. }
  339. //-----------------------------------------------------------------------------
  340. // Name: 
  341. // Desc: 
  342. //-----------------------------------------------------------------------------
  343. VOID CProfile::GetTheme( CThemeStyle* pTheme, TCHAR* strFile )
  344. {
  345.     TCHAR szTmp[MAX_PATH];
  346.     lstrcpy( szTmp, m_szIniName );
  347.     lstrcpy( m_szIniName, strFile );
  348.     lstrcpy( pTheme->szFile, strFile );
  349.     pTheme->nNumZoneStyles = GetLong( "GLOBAL", TEXT("NumZoneStyles"),          TEXT("1") );
  350.     if( NULL == pTheme->aZoneStyles )
  351.     {
  352.         pTheme->aZoneStyles = new CZoneStyleParameter[pTheme->nNumZoneStyles];
  353.         if( NULL == pTheme->aZoneStyles )
  354.             return;
  355.         ZeroMemory( pTheme->aZoneStyles, sizeof(CZoneStyleParameter)*pTheme->nNumZoneStyles );
  356.     }
  357.     for( DWORD iLand=0; iLand<pTheme->nNumZoneStyles; iLand++ )
  358.     {
  359.         TCHAR strSection[MAX_PATH];
  360.         wsprintf( strSection, "ZONESTYLE%d", iLand+1 );
  361.         GetLandType( &pTheme->aZoneStyles[iLand], strSection );
  362.     }
  363.     pTheme->dwAmbientLight = GetHex( TEXT("GLOBAL"), TEXT("AmbientLight"), TEXT("0x44444444") );
  364.     pTheme->nNumLights = GetLong( "GLOBAL", TEXT("NumLights"),          TEXT("1") );
  365.     if( NULL == pTheme->aLights )
  366.     {
  367.         pTheme->aLights = new CLightParameter[pTheme->nNumLights];
  368.         if( NULL == pTheme->aLights )
  369.             return;
  370.         ZeroMemory( pTheme->aLights, sizeof(CLightParameter)*pTheme->nNumLights );
  371.     }
  372.     for( int iLight=0; iLight<pTheme->nNumLights; iLight++ )
  373.     {
  374.         TCHAR strSection[MAX_PATH];
  375.         wsprintf( strSection, "LIGHT%d", iLight+1 );
  376.         GetLight( &pTheme->aLights[iLight], strSection );
  377.     }
  378.     GetSkyParameters( &pTheme->Sky, TEXT("SKY") );
  379.     lstrcpy( m_szIniName, szTmp );
  380. }
  381. //-----------------------------------------------------------------------------
  382. // Name: 
  383. // Desc: 
  384. //-----------------------------------------------------------------------------
  385. DWORD CProfile::GetHex( TCHAR* strSection, TCHAR* szName, TCHAR* szDefault )
  386. {
  387.     TCHAR szBuffer[MAX_PATH];
  388.     DWORD dwResult = 0;
  389.     GetPrivateProfileString( strSection, szName, szDefault, 
  390.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  391.     if( _stscanf( szBuffer, TEXT("0x%x"), &dwResult ) != 1 )
  392.     {
  393.         dwResult = 0;
  394.     }
  395.     return dwResult;
  396. }
  397. //-----------------------------------------------------------------------------
  398. // Name: 
  399. // Desc: 
  400. //-----------------------------------------------------------------------------
  401. float CProfile::GetFloat( TCHAR* strSection, TCHAR* szName, TCHAR* szDefault )
  402. {
  403.     TCHAR szBuffer[MAX_PATH];
  404.     GetPrivateProfileString( strSection, szName, szDefault, 
  405.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  406.     return (float)_tcstod(szBuffer,TEXT(''));
  407. }
  408. //-----------------------------------------------------------------------------
  409. // Name: 
  410. // Desc: 
  411. //-----------------------------------------------------------------------------
  412. long CProfile::GetLong( TCHAR* strSection, TCHAR* szName, TCHAR* szDefault )
  413. {
  414.     TCHAR szBuffer[MAX_PATH];
  415.     GetPrivateProfileString( strSection, szName, szDefault, 
  416.                              szBuffer, sizeof(szBuffer), m_szIniName ); 
  417.     return _tcstol(szBuffer,TEXT(''),10);  
  418. }
  419. //-----------------------------------------------------------------------------
  420. // Name: 
  421. // Desc: 
  422. //-----------------------------------------------------------------------------
  423. void CProfile::GetString( TCHAR* szValue, TCHAR* strSection, TCHAR* szName, TCHAR* szDefault )
  424. {
  425.     GetPrivateProfileString( strSection, szName, szDefault, 
  426.                              szValue, MAX_PATH, m_szIniName ); 
  427. }
  428. //-----------------------------------------------------------------------------
  429. // Name: 
  430. // Desc: 
  431. //-----------------------------------------------------------------------------
  432. CSoundParameter::CSoundParameter()
  433. {
  434.     lstrcpy( szFile, TEXT("") );
  435.     lBufferCount        = 1;
  436.     lVolume             = 0L;
  437.     lSampleRateOffset   = 0L;
  438.     lSampleRateDelta    = 0L;
  439. }
  440. //-----------------------------------------------------------------------------
  441. // Name: 
  442. // Desc: 
  443. //-----------------------------------------------------------------------------
  444. CZoneStyleParameter::CZoneStyleParameter()
  445. {
  446.     HeightCreationType = HCT_FromFile;
  447.     lstrcpy( szHeightMap, TEXT("") );
  448.     TextureCreationType = TCT_FromFile;
  449.     dwNumLayers = 0;
  450.     dwTextureSize = 0;
  451.     for( int i=0; i<MAX_SOURCE_TEXTURES; i++ )
  452.     {
  453.         lstrcpy( aLayerTexture[i], TEXT("") );
  454.         aLayerColor[i] = 0;
  455.         aLayerHeight[i] = 0.0f;
  456.     }
  457. }
  458. //-----------------------------------------------------------------------------
  459. // Name: 
  460. // Desc: 
  461. //-----------------------------------------------------------------------------
  462. CSkyParameter::CSkyParameter()
  463. {
  464.     lstrcpy( szModel, TEXT("") );
  465.     lstrcpy( szTextureMap, TEXT("") );
  466. }
  467. //-----------------------------------------------------------------------------
  468. // Name: 
  469. // Desc: 
  470. //-----------------------------------------------------------------------------
  471. CThemeStyle::CThemeStyle()
  472. {  
  473.     nNumZoneStyles = 0;
  474.     aZoneStyles = NULL;
  475.     aLights = NULL;
  476. }
  477. //-----------------------------------------------------------------------------
  478. // Name: 
  479. // Desc: 
  480. //-----------------------------------------------------------------------------
  481. CEnemyStyle::CEnemyStyle()
  482. {  
  483.     pModel = NULL;
  484. }
  485. //-----------------------------------------------------------------------------
  486. // Name: 
  487. // Desc: 
  488. //-----------------------------------------------------------------------------
  489. CEnemyStyle::~CEnemyStyle()
  490. {  
  491.     SAFE_DELETE( pModel );
  492. }
  493. //-----------------------------------------------------------------------------
  494. // Name: 
  495. // Desc: 
  496. //-----------------------------------------------------------------------------
  497. CThemeStyle::~CThemeStyle()
  498. {
  499.     SAFE_DELETE_ARRAY( aZoneStyles );
  500.     SAFE_DELETE_ARRAY( aLights );
  501. }