GameSettings.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // GameSettings.cpp
  19. // Project: Postal
  20. //
  21. // History:
  22. // 03/31/97 JMI Started.
  23. //
  24. // 03/31/97 JMI Moved CGameSettings implementation from game.h to this
  25. // file.
  26. //
  27. // 03/31/97 JMI Now loads game play keys from prefs file.
  28. //
  29. // 04/07/97 JMI Added m_szServerName and m_usServerPort.
  30. //
  31. // 04/08/97 JMI Added m_szPlayerName and m_sPlayerColorIndex.
  32. //
  33. // 04/08/97 JMI Changed defualt for m_usServerPort from 9999 to 61663.
  34. //
  35. // 04/11/97 JMI No longer sets m_sClient and m_sServer in PreDemo().
  36. //
  37. // 04/14/97 JMI Added TEMP flag m_bDontBlit to allow us to speed up the
  38. // Snap() call by not blitting.
  39. //
  40. // 04/21/97 MJR Added m_pszRealm for the name of the realm prefs file.
  41. //
  42. // 04/22/97 JMI Added m_sCanRecordDemos indicating something obscure.
  43. //
  44. // 05/15/97 JMI Added m_sAlphaBlend and m_sXRayEffect.
  45. //
  46. // 05/19/97 JMI Added m_sDisplayInfo.
  47. //
  48. // 05/22/97 JMI Added m_s3dFog.
  49. //
  50. // 05/22/97 JMI Added m_sParticleEffects.
  51. //
  52. // 06/03/97 JMI Added m_lInitialDemoTimeOut and m_lPersistentDemoTimeOut.
  53. //
  54. // 06/09/97 JMI Added m_sCanTakeSnapShots.
  55. //
  56. // 06/09/97 JMI Added m_sCrossHair.
  57. //
  58. // 06/11/97 JMI Added m_szDontShowTitles.
  59. //
  60. // 06/12/97 MJR Renamed m_pszRealm to m_pszRealmPrefsFile.
  61. // Removed m_sServer and m_sClient and m_sDemo.
  62. // Everything now sets defaults in constructor instead of
  63. // some things doing it in the Load() portion.
  64. //
  65. // 06/13/97 MJR Removed m_bDontBlit and cleaned up the loads and saves
  66. // and made sure everything defaulted properly.
  67. //
  68. // 06/16/97 MJR Added m_pszDemoMovie.
  69. // Added m_sNetGetInputInterval
  70. // Added m_sNetSendInputInterval.
  71. // Added m_sNetMaxFrameLag.
  72. // Added m_sNetTimePerFrame.
  73. //
  74. // MJR Added m_lNetMaxBlockingTime.
  75. // Added m_sNetUsersMaxPlayers;
  76. //
  77. // JMI Added m_sTrickySystemQuit.
  78. //
  79. // 06/17/97 MJR Added m_lNetForceAbortTime.
  80. //
  81. // MJR Modified to call newer version of CorrectifyBasePath().
  82. //
  83. // 06/19/97 JMI Added m_sResetMPScoresEachLevel.
  84. //
  85. // 06/23/97 JMI Added m_szSynchLogFile.
  86. //
  87. // 07/07/97 JMI Added m_dGameFilmScale and m_dEditorFilmScale.
  88. //
  89. // 07/07/97 JMI Removed m_dEditorFilmScale and added m_sEditorViewWidth
  90. // and m_sEditorViewHeight.
  91. //
  92. // 07/08/97 MJR Added use of separate section ("MacPaths") for mac paths.
  93. //
  94. // 07/16/97 JMI Changed m_lTitleLoadLoops to m_lTitleDuration.
  95. //
  96. // 07/17/97 JMI Now saves and loads volume category settings.
  97. //
  98. // 07/20/97 JMI Added m_sVolumeDistance and m_sGripZoneRadius.
  99. // Also, now saves m_sDisplayInfo.
  100. //
  101. // 07/23/97 BRH Changed title durations so that each title screen
  102. // can have its own duration time rather than splitting
  103. // it up evenly across all title screens.
  104. //
  105. // 08/03/97 BRH Added m_usProtocol to be loaded and saved in the ini
  106. // file.
  107. //
  108. // 08/04/97 JMI Added m_sPlayAmbientSounds.
  109. //
  110. // 08/05/97 JMI Added m_eNetConnectionType and
  111. // ms_apszNetConnectionTypeNames[].
  112. //
  113. // 08/11/97 MJR Added m_szHostName and modified connection types and text.
  114. //
  115. // 08/13/97 JMI PreDemo() now uses difficulty level 10.
  116. //
  117. // 08/18/97 MJR Lots of changes to network-related stuff.
  118. //
  119. // 08/20/97 BRH Added Sound, Game and Hoods paths to give more
  120. // installation options.
  121. //
  122. // 08/23/97 JMI Added ms_apszPlayerColorDescriptions[] to provide color
  123. // descriptions and ms_sNumPlayerColorDescriptions.
  124. //
  125. // 08/24/97 JMI Editor width and height now default to 640 and 480.
  126. //
  127. // 08/25/97 JMI Changed some of the color descriptors.
  128. //
  129. // 08/25/97 JMI Now includes the m_eCurSoundQuality enum representing the
  130. // game's current sound quality.
  131. // Also, now sets all the default volumes to one value and
  132. // stores all values from 0 to the UserMaxVolume instead of
  133. // in the 0..MaxVolume scale samplemaster uses.
  134. //
  135. // 09/06/97 MJR Clamped net values to valid ranges.
  136. //
  137. // 09/07/97 MJR Now defaults to 2 for network lag.
  138. //
  139. //////////////////////////////////////////////////////////////////////////////
  140. //
  141. // Implementation for CGameSettings object. Each instance contains settings
  142. // for Postal.
  143. //
  144. //////////////////////////////////////////////////////////////////////////////
  145. #include "RSPiX.h"
  146. #include "GameSettings.h"
  147. #include "game.h"
  148. #include "net.h"
  149. #include "SampleMaster.h"
  150. #include "socket.h"
  151. #include "dude.h" // For MaxTextures.
  152. //////////////////////////////////////////////////////////////////////////////
  153. // Macros.
  154. //////////////////////////////////////////////////////////////////////////////
  155. // Determines the number of elements in the passed array at compile time.
  156. #define NUM_ELEMENTS(a) (sizeof(a) / sizeof(a[0]) )
  157. // Clamp the specified value so it's between min and max, inclusive
  158. template <class T>
  159. inline T CLAMP(T val, T min,T max)
  160. {
  161. if (val < min)
  162. val = min;
  163. if (val > max)
  164. val = max;
  165. return val;
  166. }
  167. //////////////////////////////////////////////////////////////////////////////
  168. // Instantiate static members.
  169. //////////////////////////////////////////////////////////////////////////////
  170. // Player color descriptions.
  171. char* CGameSettings::ms_apszPlayerColorDescriptions[CDude::MaxTextures + 1] =
  172. {
  173. "Black",
  174. "Green",
  175. "Blue",
  176. "Gray",
  177. "Brown",
  178. "Red",
  179. "Tan",
  180. "Purple",
  181. // Add new colors above this line.
  182. "Error", // Try to catch errors.
  183. };
  184. // Number of color descriptions.
  185. const short CGameSettings::ms_sNumPlayerColorDescriptions = NUM_ELEMENTS(ms_apszPlayerColorDescriptions) - 1;
  186. //////////////////////////////////////////////////////////////////////////////
  187. // Set settings to default values
  188. //////////////////////////////////////////////////////////////////////////////
  189. CGameSettings::CGameSettings(void)
  190. {
  191. m_pszCDPath[0] = 0;
  192. m_pszHDPath[0] = 0;
  193. m_pszVDPath[0] = 0;
  194. m_pszSoundPath[0] = 0;
  195. m_pszGamePath[0] = 0;
  196. m_pszHoodsPath[0] = 0;
  197. m_szNoSakDir[0] = 0;
  198. m_pszRealmPrefsFile[0] = 0;
  199. m_sDifficulty = 5;
  200. m_sViolence = 11;
  201. m_sCrossHair = TRUE;
  202. m_szServerName[0] = 0;
  203. m_usServerPort = 61663;
  204. m_usProtocol = RSocket::FirstProtocol;
  205. m_szPlayerName[0] = 0;
  206. m_sPlayerColorIndex = 0;
  207. m_sNetBandwidth = Net::Analog28_8;
  208. m_sHostMinBandwidth = Net::Analog14_4;
  209. m_sHostMaxPlayers = Net::MaxNumIDs;
  210. m_szHostName[0] = 0;
  211. m_sHostResetScoresEachLevel = TRUE;
  212. m_sHostRejuvenate = TRUE;
  213. m_sHostTimeLimit = 0;
  214. m_sHostKillLimit = 20;
  215. m_lNetMaxBlockingTime = 10000;
  216. m_lNetForceAbortTime = 5000;
  217. m_sNetGetInputInterval = 100;
  218. m_sNetSendInputInterval = 500;
  219. m_sNetMaxFrameLag = 2; // For the new networking stuff, 2 seems to be the "right" number
  220. m_sNetTimePerFrame = 200;
  221. /*** 12/5/97 AJC ***/
  222. m_szNetSyncLogFile[0] = 0;
  223. m_lStartRealmTime = 0L;
  224. m_bLogNetTime = false; // Default is not to log net time
  225. /*** 12/5/97 AJC ***/
  226. /*** 01/14/98 SPA ***/
  227. m_lPeerDropMaxWaitTime = 10000; // Default to 10 seconds
  228. /*** 01/14/98 SPA ***/
  229. m_lInitialDemoTimeOut = 10000;
  230. m_lPersistentDemoTimeOut = 60000;
  231. m_sCanRecordDemos = FALSE;
  232. m_szDemoDebugMovie[0] = 0;
  233. m_sNumAvailableDemos = 0;
  234. m_sGammaVal = 128;
  235. m_sUseCurrentDeviceDimensions = 0;
  236. m_sAlphaBlend = TRUE;
  237. m_sXRayEffect = TRUE;
  238. m_s3dFog = TRUE;
  239. m_sParticleEffects = TRUE;
  240. m_sVolumeDistance = TRUE;
  241. m_sPlayAmbientSounds = TRUE;
  242. m_sDisplayInfo = FALSE;
  243. m_sCanTakeSnapShots = FALSE;
  244. m_szDontShowTitles[0] = 0;
  245. m_sTrickySystemQuit = FALSE;
  246. m_szSynchLogFile[0] = '\0';
  247. m_dGameFilmScale = 1.0; // 100%
  248. m_sEditorViewWidth = 640;
  249. m_sEditorViewHeight = 480;
  250. m_sGripZoneRadius = 75;
  251. m_eCurSoundQuality = SampleMaster::SQ_22050_8;
  252. // Initialize all category volumes.
  253. short i;
  254. for (i = 0; i < SampleMaster::MAX_NUM_SOUND_CATEGORIES; i++)
  255. {
  256. m_asCategoryVolumes[i] = SampleMaster::UserDefaultVolume;
  257. }
  258. }
  259. //////////////////////////////////////////////////////////////////////////////
  260. // Destructor
  261. //////////////////////////////////////////////////////////////////////////////
  262. CGameSettings::~CGameSettings()
  263. {
  264. }
  265. //////////////////////////////////////////////////////////////////////////////
  266. // Read settings that are stored in preference file
  267. //////////////////////////////////////////////////////////////////////////////
  268. short CGameSettings::LoadPrefs(
  269. RPrefs* pPrefs)
  270. {
  271. short sResult = 0;
  272. pPrefs->GetVal("Paths", "CD", "", m_pszCDPath);
  273. #if defined(PANDORA) || defined(ODROID)
  274. strcpy(m_pszCDPath, ".");
  275. #endif
  276. sResult = (strlen(m_pszCDPath) + 1) <= RSP_MAX_PATH ? 0 : -1;
  277. if (sResult == 0)
  278. sResult = CorrectifyBasePath(m_pszCDPath, sizeof(m_pszCDPath));
  279. if (sResult)
  280. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadCDPath_s_s, "CD", "Paths");
  281. pPrefs->GetVal("Paths", "HD", "", m_pszHDPath);
  282. #if defined(PANDORA) || defined(ODROID)
  283. strcpy(m_pszHDPath, ".");
  284. #endif
  285. sResult = (strlen(m_pszHDPath) + 1) <= RSP_MAX_PATH ? 0 : -1;
  286. if (sResult == 0)
  287. sResult = CorrectifyBasePath(m_pszHDPath, sizeof(m_pszHDPath));
  288. if (sResult)
  289. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "HD", "Paths");
  290. pPrefs->GetVal("Paths", "VD", "", m_pszVDPath);
  291. #if defined(PANDORA) || defined(ODROID)
  292. strcpy(m_pszVDPath, ".");
  293. #endif
  294. sResult = (strlen(m_pszVDPath) + 1) <= RSP_MAX_PATH ? 0 : -1;
  295. if (sResult == 0)
  296. sResult = CorrectifyBasePath(m_pszVDPath, sizeof(m_pszVDPath));
  297. if (sResult)
  298. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "VD", "Paths");
  299. pPrefs->GetVal("Paths", "Sound", "", m_pszSoundPath);
  300. #if defined(PANDORA) || defined(ODROID)
  301. strcpy(m_pszSoundPath, ".");
  302. #endif
  303. sResult = (strlen(m_pszSoundPath) + 1) <= RSP_MAX_PATH ? 0 : -1;
  304. if (sResult == 0)
  305. sResult = CorrectifyBasePath(m_pszSoundPath, sizeof(m_pszSoundPath));
  306. if (sResult)
  307. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "Sound", "Paths");
  308. pPrefs->GetVal("Paths", "Game", "", m_pszGamePath);
  309. #if defined(PANDORA) || defined(ODROID)
  310. strcpy(m_pszGamePath, ".");
  311. #endif
  312. sResult = (strlen(m_pszGamePath) + 1) <= RSP_MAX_PATH ? 0 : -1;
  313. if (sResult == 0)
  314. sResult = CorrectifyBasePath(m_pszGamePath, sizeof(m_pszGamePath));
  315. if (sResult)
  316. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "Game", "Paths");
  317. pPrefs->GetVal("Paths", "Hoods", "", m_pszHoodsPath);
  318. #if defined(PANDORA) || defined(ODROID)
  319. strcpy(m_pszHoodsPath, ".");
  320. #endif
  321. sResult = (strlen(m_pszHoodsPath) + 1) <= RSP_MAX_PATH ? 0 : -1;
  322. if (sResult == 0)
  323. sResult = CorrectifyBasePath(m_pszHoodsPath, sizeof(m_pszHoodsPath));
  324. if (sResult)
  325. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "Hoods", "Paths");
  326. pPrefs->GetVal("Paths", "NoSakDir", "", m_szNoSakDir);
  327. sResult = (strlen(m_szNoSakDir) + 1) <= RSP_MAX_PATH ? 0 : -1;
  328. if (sResult == 0)
  329. sResult = CorrectifyBasePath(m_szNoSakDir, sizeof(m_szNoSakDir));
  330. if (sResult)
  331. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "NoSakDir", "Paths");
  332. pPrefs->GetVal("Realms", "File", "", m_pszRealmPrefsFile);
  333. if (strlen(m_pszRealmPrefsFile) == 0)
  334. {
  335. sResult = -1;
  336. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "File", "Realms");
  337. }
  338. else if ((strlen(m_pszRealmPrefsFile) + 1) >= RSP_MAX_PATH)
  339. {
  340. sResult = -1;
  341. rspMsgBox(RSP_MB_ICN_STOP | RSP_MB_BUT_OK, g_pszCriticalErrorTitle, g_pszBadPath_s_s, "File", "Realms");
  342. }
  343. pPrefs->GetVal("Game", "RecentDifficulty", m_sDifficulty, &m_sDifficulty);
  344. if (m_sDifficulty < 0)
  345. m_sDifficulty = 0;
  346. if (m_sDifficulty > 11)
  347. m_sDifficulty = 11;
  348. pPrefs->GetVal("Game", "RecentViolence", m_sViolence, &m_sViolence);
  349. if (m_sViolence < 0)
  350. m_sViolence = 0;
  351. if (m_sViolence > 11)
  352. m_sViolence = 11;
  353. pPrefs->GetVal("Game", "UseCrossHair", m_sCrossHair, &m_sCrossHair);
  354. pPrefs->GetVal("Multiplayer", "Server", m_szServerName, m_szServerName);
  355. pPrefs->GetVal("Multiplayer", "Port", m_usServerPort, &m_usServerPort);
  356. pPrefs->GetVal("Multiplayer", "Protocol", m_usProtocol, &m_usProtocol);
  357. if (m_usProtocol >= RSocket::NumProtocols)
  358. m_usProtocol = RSocket::FirstProtocol;
  359. pPrefs->GetVal("Multiplayer", "Name", m_szPlayerName, m_szPlayerName);
  360. pPrefs->GetVal("Multiplayer", "Color", m_sPlayerColorIndex, &m_sPlayerColorIndex);
  361. pPrefs->GetVal("Multiplayer", "Bandwidth", m_sNetBandwidth, &m_sNetBandwidth);
  362. if (m_sNetBandwidth < 0) m_sNetBandwidth = 0;
  363. if (m_sNetBandwidth >= Net::NumBandwidths) m_sNetBandwidth = Net::NumBandwidths - 1;
  364. pPrefs->GetVal("Multiplayer", "HostMinBandwidth", m_sHostMinBandwidth, &m_sHostMinBandwidth);
  365. if (m_sHostMinBandwidth < 0) m_sHostMinBandwidth = 0;
  366. if (m_sHostMinBandwidth >= Net::NumBandwidths) m_sHostMinBandwidth = Net::NumBandwidths - 1;
  367. pPrefs->GetVal("Multiplayer", "HostMaxPlayers", m_sHostMaxPlayers, &m_sHostMaxPlayers);
  368. if (m_sHostMaxPlayers > Net::MaxNumIDs)
  369. m_sHostMaxPlayers = Net::MaxNumIDs;
  370. char szHostName[RSP_MAX_PATH];
  371. pPrefs->GetVal("Multiplayer", "HostName", "", szHostName);
  372. strncpy(m_szHostName, szHostName, sizeof(m_szHostName));
  373. m_szHostName[sizeof(m_szHostName)-1] = 0;
  374. pPrefs->GetVal("Multiplayer", "HostResetScoresEachLevel", m_sHostResetScoresEachLevel, &m_sHostResetScoresEachLevel);
  375. pPrefs->GetVal("Multiplayer", "HostRejuvenate", m_sHostRejuvenate, &m_sHostRejuvenate);
  376. pPrefs->GetVal("Multiplayer", "HostTimeLimit", m_sHostTimeLimit, &m_sHostTimeLimit);
  377. pPrefs->GetVal("Multiplayer", "HostKillLimit", m_sHostKillLimit, &m_sHostKillLimit);
  378. pPrefs->GetVal("Multiplayer", "GetInputInterval", m_sNetGetInputInterval, &m_sNetGetInputInterval);
  379. pPrefs->GetVal("Multiplayer", "SendInputInterval", m_sNetSendInputInterval, &m_sNetSendInputInterval);
  380. pPrefs->GetVal("Multiplayer", "MaxFrameLag", m_sNetMaxFrameLag, &m_sNetMaxFrameLag);
  381. m_sNetMaxFrameLag = CLAMP(m_sNetMaxFrameLag, (short)0, (short)Net::MaxAheadSeq);
  382. pPrefs->GetVal("Multiplayer", "TimePerFrame", m_sNetTimePerFrame, &m_sNetTimePerFrame);
  383. m_sNetTimePerFrame = CLAMP(m_sNetTimePerFrame, (short)Net::MinFrameTime, (short)200);
  384. pPrefs->GetVal("Multiplayer", "MaxBlockingTime", m_lNetMaxBlockingTime, &m_lNetMaxBlockingTime);
  385. pPrefs->GetVal("Multiplayer", "ForceAbortTime", m_lNetForceAbortTime, &m_lNetForceAbortTime);
  386. /*** 12/5/97 AJC ***/
  387. char szLogNetTime[256];
  388. szLogNetTime[0] = 0;
  389. pPrefs->GetVal("Multiplayer", "LogNetTime", "", szLogNetTime);
  390. if (szLogNetTime[0] == 'y' || szLogNetTime[0] == 'Y')
  391. {
  392. m_bLogNetTime = true;
  393. pPrefs->GetVal("Multiplayer", "NetSyncLogFile", "netsync.log", m_szNetSyncLogFile);
  394. }
  395. else
  396. m_bLogNetTime = false;
  397. /*** 12/5/97 AJC ***/
  398. /*** 01/14/98 SPA ***/
  399. pPrefs->GetVal("Multiplayer", "PeerDropMaxWaitTime", m_lPeerDropMaxWaitTime, &m_lPeerDropMaxWaitTime);
  400. m_lPeerDropMaxWaitTime *= 1000; // Change to milliseconds
  401. /*** 01/14/98 SPA ***/
  402. pPrefs->GetVal("Demo", "InitialTimeOut", m_lInitialDemoTimeOut, &m_lInitialDemoTimeOut);
  403. pPrefs->GetVal("Demo", "PersistentTimeOut", m_lPersistentDemoTimeOut, &m_lPersistentDemoTimeOut);
  404. pPrefs->GetVal("Demo", "CanRecordDemos", m_sCanRecordDemos, &m_sCanRecordDemos);
  405. pPrefs->GetVal("Demo", "DemoDebugMovie", m_szDemoDebugMovie, m_szDemoDebugMovie);
  406. pPrefs->GetVal("Demo", "NumAvailable", m_sNumAvailableDemos, &m_sNumAvailableDemos);
  407. short i;
  408. char szDurationName[100];
  409. for (i = 0; i < MAX_TITLE_SCREENS; i++)
  410. {
  411. sprintf(szDurationName, "Duration%d", i+1);
  412. pPrefs->GetVal("Title", szDurationName, 3000, &(m_alTitleDurations[i]));
  413. }
  414. pPrefs->GetVal("Video", "GammaVal", m_sGammaVal, &m_sGammaVal);
  415. pPrefs->GetVal("Video", "UseCurrentDeviceDimensions", m_sUseCurrentDeviceDimensions, &m_sUseCurrentDeviceDimensions);
  416. pPrefs->GetVal("Video", "GameFilmScale", m_dGameFilmScale, &m_dGameFilmScale);
  417. pPrefs->GetVal("Video", "EditorViewWidth", m_sEditorViewWidth, &m_sEditorViewWidth);
  418. pPrefs->GetVal("Video", "EditorViewHeight", m_sEditorViewHeight, &m_sEditorViewHeight);
  419. pPrefs->GetVal("Features", "AlphaBlend", m_sAlphaBlend, &m_sAlphaBlend);
  420. pPrefs->GetVal("Features", "XRayEffect", m_sXRayEffect, &m_sXRayEffect);
  421. pPrefs->GetVal("Features", "3DLighting", m_s3dFog, &m_s3dFog);
  422. pPrefs->GetVal("Features", "ParticleEffects", m_sParticleEffects, &m_sParticleEffects);
  423. pPrefs->GetVal("Features", "VolumeDistance", m_sVolumeDistance, &m_sVolumeDistance);
  424. pPrefs->GetVal("Features", "PlayAmbientSounds", m_sPlayAmbientSounds, &m_sPlayAmbientSounds);
  425. pPrefs->GetVal("Debug", "DisplayInfo", m_sDisplayInfo, &m_sDisplayInfo);
  426. pPrefs->GetVal("Debug", "IfLog", m_szSynchLogFile, m_szSynchLogFile);
  427. pPrefs->GetVal("Can", "TakeSnapShots", m_sCanTakeSnapShots, &m_sCanTakeSnapShots);
  428. pPrefs->GetVal("Title", "DontShow", m_szDontShowTitles, m_szDontShowTitles);
  429. pPrefs->GetVal("Shell", "TrickySystemQuit", m_sTrickySystemQuit, &m_sTrickySystemQuit);
  430. for (i = 0; i < SampleMaster::MAX_NUM_SOUND_CATEGORIES; i++)
  431. {
  432. pPrefs->GetVal("Volumes", SampleMaster::ms_apszSoundCategories[i], SampleMaster::UserDefaultVolume, &m_asCategoryVolumes[i]);
  433. }
  434. // Verify we're in bounds.
  435. if (m_sPlayerColorIndex >= CDude::MaxTextures || m_sPlayerColorIndex < 0)
  436. {
  437. m_sPlayerColorIndex = 0;
  438. }
  439. if (!sResult)
  440. {
  441. if (pPrefs->IsError())
  442. sResult = -1;
  443. }
  444. return sResult;
  445. }
  446. //////////////////////////////////////////////////////////////////////////////
  447. // Write settings that are stored in preference file
  448. //////////////////////////////////////////////////////////////////////////////
  449. short CGameSettings::SavePrefs(
  450. RPrefs* pPrefs)
  451. {
  452. pPrefs->SetVal("Game", "RecentDifficulty", m_sDifficulty);
  453. pPrefs->SetVal("Game", "RecentViolence", m_sViolence);
  454. pPrefs->SetVal("Game", "UseCrossHair", m_sCrossHair);
  455. pPrefs->SetVal("Multiplayer", "Server", m_szServerName);
  456. pPrefs->SetVal("Multiplayer", "Port", m_usServerPort);
  457. pPrefs->SetVal("Multiplayer", "Protocol", m_usProtocol);
  458. pPrefs->SetVal("Multiplayer", "Name", m_szPlayerName);
  459. pPrefs->SetVal("Multiplayer", "Color", m_sPlayerColorIndex);
  460. pPrefs->SetVal("Multiplayer", "Bandwidth", (long)m_sNetBandwidth);
  461. pPrefs->SetVal("Multiplayer", "HostMinBandwidth", (long)m_sHostMinBandwidth);
  462. pPrefs->SetVal("Multiplayer", "HostMaxPlayers", m_sHostMaxPlayers);
  463. pPrefs->SetVal("Multiplayer", "HostName", m_szHostName);
  464. pPrefs->SetVal("Multiplayer", "HostResetScoresEachLevel", m_sHostResetScoresEachLevel);
  465. pPrefs->SetVal("Multiplayer", "HostRejuvenate", m_sHostRejuvenate);
  466. pPrefs->SetVal("Multiplayer", "HostTimeLimit", m_sHostTimeLimit);
  467. pPrefs->SetVal("Multiplayer", "HostKillLimit", m_sHostKillLimit);
  468. pPrefs->SetVal("Video", "GammaVal", m_sGammaVal);
  469. pPrefs->SetVal("Video", "GameFilmScale", m_dGameFilmScale);
  470. pPrefs->SetVal("Video", "EditorViewWidth", m_sEditorViewWidth);
  471. pPrefs->SetVal("Video", "EditorViewHeight", m_sEditorViewHeight);
  472. pPrefs->SetVal("Features", "AlphaBlend", m_sAlphaBlend);
  473. pPrefs->SetVal("Features", "XRayEffect", m_sXRayEffect);
  474. pPrefs->SetVal("Features", "3DLighting", m_s3dFog);
  475. pPrefs->SetVal("Features", "ParticleEffects", m_sParticleEffects);
  476. pPrefs->SetVal("Features", "VolumeDistance", m_sVolumeDistance);
  477. pPrefs->SetVal("Features", "PlayAmbientSounds", m_sPlayAmbientSounds);
  478. pPrefs->SetVal("Debug", "DisplayInfo", m_sDisplayInfo);
  479. short i;
  480. for (i = 0; i < SampleMaster::MAX_NUM_SOUND_CATEGORIES; i++)
  481. {
  482. // Save volume scaled to user mode.
  483. pPrefs->SetVal("Volumes", SampleMaster::ms_apszSoundCategories[i], m_asCategoryVolumes[i] );
  484. }
  485. return pPrefs->IsError();
  486. }
  487. //////////////////////////////////////////////////////////////////////////////
  488. // Load settings that are stored in game file
  489. //////////////////////////////////////////////////////////////////////////////
  490. short CGameSettings::LoadGame(
  491. RFile* pFile)
  492. {
  493. pFile->Read(&m_sDifficulty);
  494. pFile->Read(&m_sViolence);
  495. return 0;
  496. }
  497. //////////////////////////////////////////////////////////////////////////////
  498. // Save settings that are stored in game file
  499. //////////////////////////////////////////////////////////////////////////////
  500. short CGameSettings::SaveGame(
  501. RFile* pFile)
  502. {
  503. pFile->Write(&m_sDifficulty);
  504. pFile->Write(&m_sViolence);
  505. return 0;
  506. }
  507. //////////////////////////////////////////////////////////////////////////////
  508. // Temporarily set settings for demo mode (file is for saving current settings)
  509. //////////////////////////////////////////////////////////////////////////////
  510. short CGameSettings::PreDemo(
  511. RFile* pFile)
  512. {
  513. pFile->Write(&m_sDifficulty);
  514. pFile->Write(&m_sViolence);
  515. m_sDifficulty = 10;
  516. m_sViolence = 11;
  517. return 0;
  518. }
  519. //////////////////////////////////////////////////////////////////////////////
  520. // Restore settings to what they were prior to demo mode
  521. //////////////////////////////////////////////////////////////////////////////
  522. short CGameSettings::PostDemo(
  523. RFile* pFile)
  524. {
  525. pFile->Read(&m_sDifficulty);
  526. pFile->Read(&m_sViolence);
  527. return 0;
  528. }
  529. ///////////////////////////////////////////////////////////////////////////////
  530. // EOF
  531. ///////////////////////////////////////////////////////////////////////////////