OPTIONS.CPP 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: F:\projects\c&c\vcs\code\options.cpv 2.17 16 Oct 1995 16:51:28 JOE_BOSTIC $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : OPTIONS.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : June 8, 1994 *
  26. * *
  27. * Last Update : June 30, 1995 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * OptionsClass::Adjust_Palette -- Adjusts the palette according to the settings specified. *
  32. * OptionsClass::Get_Brightness -- Fetches the current brightness setting. *
  33. * OptionsClass::Get_Color -- Fetches the current color setting. *
  34. * OptionsClass::Get_Contrast -- Gets the current contrast setting. *
  35. * OptionsClass::Get_Game_Speed -- Fetches the current game speed setting. *
  36. * OptionsClass::Get_Scroll_Rate -- Fetches the current scroll rate setting. *
  37. * OptionsClass::Get_Tint -- Fetches the current tint setting. *
  38. * OptionsClass::Load_Settings -- reads options settings from the INI file *
  39. * OptionsClass::Normalize_Delay -- Normalizes delay factor to keep rate constant. *
  40. * OptionsClass::One_Time -- This performs any one time initialization for the options class.*
  41. * OptionsClass::OptionsClass -- The default constructor for the options class. *
  42. * OptionsClass::Process -- Handles all the options graphic interface. *
  43. * OptionsClass::Save_Settings -- writes options settings to the INI file *
  44. * OptionsClass::Set -- Sets options based on current settings *
  45. * OptionsClass::Set_Brightness -- Sets the brightness level to that specified. *
  46. * OptionsClass::Set_Color -- Sets the color to the value specified. *
  47. * OptionsClass::Set_Contrast -- Sets the contrast to the value specified. *
  48. * OptionsClass::Set_Game_Speed -- Sets the game speed as specified. *
  49. * OptionsClass::Set_Repeat -- Controls the score repeat option. *
  50. * OptionsClass::Set_Score_Volume -- Sets the global score volume to that specified. *
  51. * OptionsClass::Set_Scroll_Rate -- Sets the scroll rate as specified. *
  52. * OptionsClass::Set_Shuffle -- Controls the play shuffle setting. *
  53. * OptionsClass::Set_Sound_Volume -- Sets the sound effects volume level. *
  54. * OptionsClass::Set_Tint -- Sets the tint setting. *
  55. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  56. #include "function.h"
  57. #include "options.h"
  58. /***********************************************************************************************
  59. * OptionsClass::OptionsClass -- The default constructor for the options class. *
  60. * *
  61. * This is the constructor for the options class. It handles setting up all the globals *
  62. * necessary for the options. This includes setting them to their default state. *
  63. * *
  64. * INPUT: none *
  65. * *
  66. * OUTPUT: none *
  67. * *
  68. * WARNINGS: none *
  69. * *
  70. * HISTORY: *
  71. * 07/21/1994 JLB : Created. *
  72. *=============================================================================================*/
  73. OptionsClass::OptionsClass(void)
  74. {
  75. GameSpeed = TIMER_SECOND / TICKS_PER_SECOND;
  76. ScrollRate = TIMER_SECOND / TICKS_PER_SECOND;
  77. Volume = 0xE0;
  78. ScoreVolume = 0x90;
  79. Contrast = 0x80;
  80. Color = 0x80;
  81. Contrast = 0x80;
  82. Tint = 0x80;
  83. Brightness = 0x80;
  84. AutoScroll = true;
  85. #if (GERMAN | FRENCH)
  86. IsDeathAnnounce = true;
  87. #else
  88. IsDeathAnnounce = false;
  89. #endif
  90. IsScoreRepeat = false;
  91. IsScoreShuffle = false;
  92. IsFreeScroll = false;
  93. }
  94. /***********************************************************************************************
  95. * OptionsClass::One_Time -- This performs any one time initialization for the options class. *
  96. * *
  97. * This routine should be called only once and it will perform any inializations for the *
  98. * options class that is needed. This may include things like file loading and memory *
  99. * allocation. *
  100. * *
  101. * INPUT: none *
  102. * *
  103. * OUTPUT: none *
  104. * *
  105. * WARNINGS: Only call this routine once. *
  106. * *
  107. * HISTORY: *
  108. * 07/21/1994 JLB : Created. *
  109. *=============================================================================================*/
  110. void OptionsClass::One_Time(void)
  111. {
  112. Set_Score_Vol(ScoreVolume);
  113. }
  114. /***********************************************************************************************
  115. * OptionsClass::Process -- Handles all the options graphic interface. *
  116. * *
  117. * This routine is the main control for the visual representation of the options *
  118. * screen. It handles the visual overlay and the player input. *
  119. * *
  120. * INPUT: none *
  121. * *
  122. * OUTPUT: none *
  123. * *
  124. * WARNINGS: none *
  125. * *
  126. * HISTORY: *
  127. * 07/21/1994 JLB : Created. *
  128. *=============================================================================================*/
  129. void OptionsClass::Process(void)
  130. {
  131. }
  132. /***********************************************************************************************
  133. * OptionsClass::Set_Shuffle -- Controls the play shuffle setting. *
  134. * *
  135. * This routine will control the score shuffle flag. The setting to use is provided as *
  136. * a parameter. When shuffling is on, the score play order is scrambled. *
  137. * *
  138. * INPUT: on -- Should the shuffle option be activated? *
  139. * *
  140. * OUTPUT: none *
  141. * *
  142. * WARNINGS: none *
  143. * *
  144. * HISTORY: *
  145. * 01/19/1995 JLB : Created. *
  146. *=============================================================================================*/
  147. void OptionsClass::Set_Shuffle(int on)
  148. {
  149. IsScoreShuffle = on;
  150. }
  151. /***********************************************************************************************
  152. * OptionsClass::Set_Repeat -- Controls the score repeat option. *
  153. * *
  154. * This routine is used to control whether scores repeat or not. The setting to use for *
  155. * the repeat flag is provided as a parameter. *
  156. * *
  157. * INPUT: on -- Should the scores repeat? *
  158. * *
  159. * OUTPUT: none *
  160. * *
  161. * WARNINGS: none *
  162. * *
  163. * HISTORY: *
  164. * 01/19/1995 JLB : Created. *
  165. *=============================================================================================*/
  166. void OptionsClass::Set_Repeat(int on)
  167. {
  168. IsScoreRepeat = on;
  169. }
  170. /***********************************************************************************************
  171. * OptionsClass::Set_Score_Volume -- Sets the global score volume to that specified. *
  172. * *
  173. * This routine will set the global score volume to the value specified. The value ranges *
  174. * from zero to 255. *
  175. * *
  176. * INPUT: volume -- The new volume setting to use for scores. *
  177. * *
  178. * OUTPUT: none *
  179. * *
  180. * WARNINGS: none *
  181. * *
  182. * HISTORY: *
  183. * 01/19/1995 JLB : Created. *
  184. *=============================================================================================*/
  185. void OptionsClass::Set_Score_Volume(int volume)
  186. {
  187. volume = Bound(volume, 0, 255);
  188. ScoreVolume = volume;
  189. Set_Score_Vol(ScoreVolume);
  190. }
  191. /***********************************************************************************************
  192. * OptionsClass::Set_Sound_Volume -- Sets the sound effects volume level. *
  193. * *
  194. * This routine will set the sound effect volume level as indicated. It can generate a *
  195. * sound effect for feedback purposes if desired. The volume setting can range from zero *
  196. * to 255. The value of 255 is the loudest. *
  197. * *
  198. * INPUT: volume -- The volume setting to use for the new value. 0 to 255. *
  199. * *
  200. * feedback -- Should a feedback sound effect be generated? *
  201. * *
  202. * OUTPUT: none *
  203. * *
  204. * WARNINGS: none *
  205. * *
  206. * HISTORY: *
  207. * 01/19/1995 JLB : Created. *
  208. *=============================================================================================*/
  209. void OptionsClass::Set_Sound_Volume(int volume, int feedback)
  210. {
  211. volume = Bound(volume, 0, 255);
  212. Volume = volume;
  213. if (feedback) {
  214. Sound_Effect(VOC_BLEEPY3, NULL);
  215. }
  216. }
  217. /***********************************************************************************************
  218. * OptionsClass::Set_Brightness -- Sets the brightness level to that specified. *
  219. * *
  220. * This routine will set the current brightness level to the value specified. This value *
  221. * can range from zero to 255, with 128 being the normal (default) brightness level. *
  222. * *
  223. * INPUT: brightness -- The brightness level to set as current. *
  224. * *
  225. * OUTPUT: none *
  226. * *
  227. * WARNINGS: none *
  228. * *
  229. * HISTORY: *
  230. * 01/19/1995 JLB : Created. *
  231. *=============================================================================================*/
  232. void OptionsClass::Set_Brightness(int brightness)
  233. {
  234. Brightness = 0x40 + Fixed_To_Cardinal(0x80, brightness);
  235. Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast);
  236. if (InMainLoop){
  237. Set_Palette(GamePalette);
  238. }
  239. }
  240. /***********************************************************************************************
  241. * OptionsClass::Get_Brightness -- Fetches the current brightness setting. *
  242. * *
  243. * This routine will fetch the current setting for the brightness level. The value ranges *
  244. * from zero to 255, with 128 being the normal (default) value. *
  245. * *
  246. * INPUT: none *
  247. * *
  248. * OUTPUT: Returns with the current brightness setting. *
  249. * *
  250. * WARNINGS: none *
  251. * *
  252. * HISTORY: *
  253. * 01/19/1995 JLB : Created. *
  254. *=============================================================================================*/
  255. int OptionsClass::Get_Brightness(void) const
  256. {
  257. return(Cardinal_To_Fixed(0x80, Brightness-0x40));
  258. }
  259. /***********************************************************************************************
  260. * OptionsClass::Set_Color -- Sets the color to the value specified. *
  261. * *
  262. * This routine will set the color value to that specified. The value specified can range *
  263. * from zero to 255. The value of 128 is the normal default color setting. *
  264. * *
  265. * INPUT: color -- The new color value to set as current. *
  266. * *
  267. * OUTPUT: none *
  268. * *
  269. * WARNINGS: none *
  270. * *
  271. * HISTORY: *
  272. * 01/19/1995 JLB : Created. *
  273. *=============================================================================================*/
  274. void OptionsClass::Set_Color(int color)
  275. {
  276. Color = color;
  277. Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast);
  278. if (InMainLoop){
  279. Set_Palette(GamePalette);
  280. }
  281. }
  282. /***********************************************************************************************
  283. * OptionsClass::Get_Color -- Fetches the current color setting. *
  284. * *
  285. * This routine will fetch the current color setting. This value ranges from zero to *
  286. * 255. *
  287. * *
  288. * INPUT: none *
  289. * *
  290. * OUTPUT: Returns with the current color setting. The value of 128 is the normal (default) *
  291. * color setting. *
  292. * *
  293. * WARNINGS: none *
  294. * *
  295. * HISTORY: *
  296. * 01/19/1995 JLB : Created. *
  297. *=============================================================================================*/
  298. int OptionsClass::Get_Color(void) const
  299. {
  300. return(Color);
  301. }
  302. /***********************************************************************************************
  303. * OptionsClass::Set_Contrast -- Sets the contrast to the value specified. *
  304. * *
  305. * This routine will set the constrast to the setting specified. This setting ranges from *
  306. * zero to 255. The value o 128 is the normal default value. *
  307. * *
  308. * INPUT: contrast -- The constrast setting to make as the current setting. *
  309. * *
  310. * OUTPUT: none *
  311. * *
  312. * WARNINGS: none *
  313. * *
  314. * HISTORY: *
  315. * 01/19/1995 JLB : Created. *
  316. *=============================================================================================*/
  317. void OptionsClass::Set_Contrast(int contrast)
  318. {
  319. Contrast = 0x40 + Fixed_To_Cardinal(0x80, contrast);
  320. Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast);
  321. if (InMainLoop){
  322. Set_Palette(GamePalette);
  323. }
  324. }
  325. /***********************************************************************************************
  326. * OptionsClass::Get_Contrast -- Gets the current contrast setting. *
  327. * *
  328. * This routine will get the current contrast setting. The value returned is in the range *
  329. * of zero to 255. *
  330. * *
  331. * INPUT: none *
  332. * *
  333. * OUTPUT: Returns the current contrast setting. A setting of 128 is the normal default value.*
  334. * *
  335. * WARNINGS: none *
  336. * *
  337. * HISTORY: *
  338. * 01/19/1995 JLB : Created. *
  339. *=============================================================================================*/
  340. int OptionsClass::Get_Contrast(void) const
  341. {
  342. return(Cardinal_To_Fixed(0x80, Contrast-0x40));
  343. }
  344. /***********************************************************************************************
  345. * OptionsClass::Set_Tint -- Sets the tint setting. *
  346. * *
  347. * This routine will change the current tint setting according to the value specified. *
  348. * *
  349. * INPUT: tint -- The desired tint setting. This value ranges from zero to 255. *
  350. * *
  351. * OUTPUT: none *
  352. * *
  353. * WARNINGS: The value of 128 is the default (normal) tint setting. *
  354. * *
  355. * HISTORY: *
  356. * 01/19/1995 JLB : Created. *
  357. *=============================================================================================*/
  358. void OptionsClass::Set_Tint(int tint)
  359. {
  360. Tint = tint;
  361. Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast);
  362. if (InMainLoop){
  363. Set_Palette(GamePalette);
  364. }
  365. }
  366. /***********************************************************************************************
  367. * OptionsClass::Get_Tint -- Fetches the current tint setting. *
  368. * *
  369. * This fetches the current tint setting. The value is returned as a number between *
  370. * zero and 255. This has been adjusted for the valid range allowed. *
  371. * *
  372. * INPUT: none *
  373. * *
  374. * OUTPUT: Returns with the current tint setting. Normal tint setting is 128. *
  375. * *
  376. * WARNINGS: none *
  377. * *
  378. * HISTORY: *
  379. * 01/19/1995 JLB : Created. *
  380. *=============================================================================================*/
  381. int OptionsClass::Get_Tint(void) const
  382. {
  383. return(Tint);
  384. }
  385. /***********************************************************************************************
  386. * OptionsClass::Adjust_Palette -- Adjusts the palette according to the settings specified. *
  387. * *
  388. * This routine is used to adjust the palette according to the settings provided. It is *
  389. * used by the options class to monkey with the palette. *
  390. * *
  391. * INPUT: oldpal -- Pointer to the original (unmodified) palette. *
  392. * *
  393. * newpal -- The new palette to create according to the settings provided. *
  394. * *
  395. * brightness -- The brightness level (0..255). *
  396. * *
  397. * color -- The color level (0..255). *
  398. * *
  399. * tint -- The tint (hue) level (0..255). *
  400. * *
  401. * contrast -- The contrast level (0..255). *
  402. * *
  403. * OUTPUT: none *
  404. * *
  405. * WARNINGS: none *
  406. * *
  407. * HISTORY: *
  408. * 07/21/1994 JLB : Created. *
  409. *=============================================================================================*/
  410. void OptionsClass::Adjust_Palette(void *oldpal, void *newpal, unsigned char brightness, unsigned char color, unsigned char tint, unsigned char contrast) const
  411. {
  412. // ST - 1/3/2019 10:49AM
  413. #if (0)
  414. int index;
  415. unsigned h,s,v;
  416. unsigned r,g,b;
  417. if (!oldpal || !newpal) return;
  418. /*
  419. ** Adjust for palette.
  420. */
  421. for (index = 0; index < 256; index++) {
  422. if (/*index == LTGREEN ||*/ index == 255) {
  423. memcpy(&((char*)newpal)[index*3], &((char*)oldpal)[index*3], 3);
  424. } else {
  425. r = ((char*)oldpal)[(index*3)+0];
  426. g = ((char*)oldpal)[(index*3)+1];
  427. b = ((char*)oldpal)[(index*3)+2];
  428. Convert_RGB_To_HSV(r, g, b, &h, &s, &v);
  429. /*
  430. ** Adjust contrast by moving the value toward the center according to the
  431. ** percentage indicated.
  432. */
  433. int temp;
  434. temp = (v * brightness) / 0x80; // Brightness
  435. temp = Bound(temp, 0, 0xFF);
  436. v = temp;
  437. temp = (((((int)v) - 0x80) * contrast) / 0x80) + 0x80; // Contrast
  438. temp = Bound(temp, 0, 0xFF);
  439. v = temp;
  440. temp = (s * color) / 0x80; // Color
  441. temp = Bound(temp, 0, 0xFF);
  442. s = temp;
  443. temp = (h * tint) / 0x80; // Tint
  444. temp = Bound(temp, 0, 0xFF);
  445. h = temp;
  446. Convert_HSV_To_RGB(h, s, v, &r, &g, &b);
  447. ((char*)newpal)[(index*3)+0] = r;
  448. ((char*)newpal)[(index*3)+1] = g;
  449. ((char*)newpal)[(index*3)+2] = b;
  450. }
  451. }
  452. #endif
  453. }
  454. /***********************************************************************************************
  455. * OptionsClass::Load_Settings -- reads options settings from the INI file *
  456. * *
  457. * INPUT: *
  458. * none. *
  459. * *
  460. * OUTPUT: *
  461. * none. *
  462. * *
  463. * WARNINGS: *
  464. * none. *
  465. * *
  466. * HISTORY: *
  467. * 02/14/1995 BR : Created. *
  468. *=============================================================================================*/
  469. void OptionsClass::Load_Settings (void)
  470. {
  471. char *buffer; // INI staging buffer pointer.
  472. /*
  473. ** Fetch working pointer to the INI staging buffer. Make sure that the buffer
  474. ** is cleared out before proceeding. (Don't use the HidPage for this, since
  475. ** the HidPage may be needed for various uncompressions during the INI
  476. ** parsing.)
  477. */
  478. buffer = (char *)_ShapeBuffer;
  479. memset(buffer, '\0', _ShapeBufferSize);
  480. /*
  481. ** Create filename and read the file.
  482. */
  483. CCFileClass file ("CONQUER.INI");
  484. if (!file.Is_Available()) {
  485. return;
  486. } else {
  487. file.Read(buffer, _ShapeBufferSize-1);
  488. }
  489. file.Close();
  490. /*
  491. ** Read in the Options values
  492. */
  493. GameSpeed = WWGetPrivateProfileInt("Options", "GameSpeed", 4, buffer);
  494. ScrollRate = WWGetPrivateProfileInt("Options", "ScrollRate", 4, buffer);
  495. Set_Brightness(WWGetPrivateProfileInt("Options", "Brightness", 0x80, buffer));
  496. Set_Sound_Volume(WWGetPrivateProfileInt("Options", "Volume", 0xA0, buffer),false);
  497. Set_Score_Volume(WWGetPrivateProfileInt("Options", "ScoreVolume", 0xFF, buffer));
  498. Set_Contrast(WWGetPrivateProfileInt("Options", "Contrast", 0x80, buffer));
  499. Set_Color(WWGetPrivateProfileInt("Options", "Color", 0x80, buffer));
  500. Set_Tint(WWGetPrivateProfileInt("Options", "Tint", 0x80, buffer));
  501. AutoScroll = WWGetPrivateProfileInt("Options", "AutoScroll", 1, buffer);
  502. Set_Repeat(WWGetPrivateProfileInt("Options", "IsScoreRepeat", 0, buffer));
  503. Set_Shuffle(WWGetPrivateProfileInt("Options", "IsScoreShuffle", 0, buffer));
  504. IsDeathAnnounce = WWGetPrivateProfileInt("Options", "DeathAnnounce", 0, buffer);
  505. IsFreeScroll = WWGetPrivateProfileInt("Options", "FreeScrolling", 0, buffer);
  506. SlowPalette = WWGetPrivateProfileInt("Options", "SlowPalette", 1, buffer);
  507. char workbuf[128];
  508. /*
  509. ** Check for and possible enable true object names.
  510. */
  511. WWGetPrivateProfileString("Options", "TrueNames", "", workbuf, sizeof(workbuf), buffer);
  512. if (Obfuscate(workbuf) == PARM_TRUENAME) {
  513. Special.IsNamed = true;
  514. }
  515. /*
  516. ** Enable 6 player games if special flag is detected.
  517. */
  518. WWGetPrivateProfileString("Options", "Players", "", workbuf, sizeof(workbuf), buffer);
  519. if (Obfuscate(workbuf) == PARM_6PLAYER) {
  520. MPlayerMax = 6;
  521. }
  522. /*
  523. ** Enable three point turning logic as indicated.
  524. */
  525. WWGetPrivateProfileString("Options", "Rotation", "", workbuf, sizeof(workbuf), buffer);
  526. if (Obfuscate(workbuf) == PARM_3POINT) {
  527. Special.IsThreePoint = true;
  528. }
  529. /*
  530. ** Allow purchase of the helipad separately from the helicopter.
  531. */
  532. WWGetPrivateProfileString("Options", "Helipad", "", workbuf, sizeof(workbuf), buffer);
  533. if (Obfuscate(workbuf) == PARM_HELIPAD) {
  534. Special.IsSeparate = true;
  535. }
  536. /*
  537. ** Allow the MCV to undeploy rather than sell.
  538. */
  539. WWGetPrivateProfileString("Options", "MCV", "", workbuf, sizeof(workbuf), buffer);
  540. if (Obfuscate(workbuf) == PARM_MCV) {
  541. Special.IsMCVDeploy = true;
  542. }
  543. /*
  544. ** Allow disabling of building bibs so that tigher building packing can occur.
  545. */
  546. WWGetPrivateProfileString("Options", "Bibs", "", workbuf, sizeof(workbuf), buffer);
  547. if (Obfuscate(workbuf) == PARM_BIB) {
  548. Special.IsRoad = true;
  549. }
  550. /*
  551. ** Allow targeting of trees without having to hold down the shift key.
  552. */
  553. WWGetPrivateProfileString("Options", "TreeTarget", "", workbuf, sizeof(workbuf), buffer);
  554. if (Obfuscate(workbuf) == PARM_TREETARGET) {
  555. Special.IsTreeTarget = true;
  556. }
  557. /*
  558. ** Allow infantry to fire while moving. Attacker gets advantage with this flag.
  559. */
  560. WWGetPrivateProfileString("Options", "Combat", "", workbuf, sizeof(workbuf), buffer);
  561. if (Obfuscate(workbuf) == PARM_COMBAT) {
  562. Special.IsDefenderAdvantage = false;
  563. }
  564. /*
  565. ** Allow custom scores.
  566. */
  567. WWGetPrivateProfileString("Options", "Scores", "", workbuf, sizeof(workbuf), buffer);
  568. if (Obfuscate(workbuf) == PARM_SCORE) {
  569. Special.IsVariation = true;
  570. }
  571. /*
  572. ** Smarter self defense logic. Tanks will try to run over adjacent infantry. Buildings
  573. ** will automatically return fire if they are fired upon. Infantry will run from an
  574. ** incoming explosive (grenade or napalm) or damage that can't be directly addressed.
  575. */
  576. WWGetPrivateProfileString("Options", "CombatIQ", "", workbuf, sizeof(workbuf), buffer);
  577. if (Obfuscate(workbuf) == PARM_IQ) {
  578. Special.IsSmartDefense = true;
  579. Special.IsScatter = true;
  580. }
  581. /*
  582. ** Enable the infantry squish marks when run over by a vehicle.
  583. */
  584. WWGetPrivateProfileString("Options", "Overrun", "", workbuf, sizeof(workbuf), buffer);
  585. if (Obfuscate(workbuf) == PARM_SQUISH) {
  586. Special.IsGross = true;
  587. }
  588. /*
  589. ** Enable the human generated sound effects.
  590. */
  591. WWGetPrivateProfileString("Options", "Sounds", "", workbuf, sizeof(workbuf), buffer);
  592. if (Obfuscate(workbuf) == PARM_HUMAN) {
  593. Special.IsJuvenile = true;
  594. }
  595. /*
  596. ** Scrolling is disabled over the tabs with this option.
  597. */
  598. WWGetPrivateProfileString("Options", "Scrolling", "", workbuf, sizeof(workbuf), buffer);
  599. if (Obfuscate(workbuf) == PARM_SCROLLING) {
  600. Special.IsScrollMod = true;
  601. }
  602. }
  603. /***********************************************************************************************
  604. * OptionsClass::Save_Settings -- writes options settings to the INI file *
  605. * *
  606. * INPUT: *
  607. * none. *
  608. * *
  609. * OUTPUT: *
  610. * none. *
  611. * *
  612. * WARNINGS: *
  613. * none. *
  614. * *
  615. * HISTORY: *
  616. * 02/14/1995 BR : Created. *
  617. *=============================================================================================*/
  618. void OptionsClass::Save_Settings (void)
  619. {
  620. char * buffer; // INI staging buffer pointer.
  621. CCFileClass file;
  622. /*
  623. ** Get a working pointer to the INI staging buffer. Make sure that the buffer
  624. ** starts cleared out of any data.
  625. */
  626. buffer = (char *)_ShapeBuffer;
  627. memset(buffer, '\0', _ShapeBufferSize);
  628. file.Set_Name("CONQUER.INI");
  629. if (file.Is_Available()) {
  630. file.Read(buffer, _ShapeBufferSize-1);
  631. }
  632. /*
  633. ** Save Options settings
  634. */
  635. WWWritePrivateProfileInt("Options", "GameSpeed", GameSpeed, buffer);
  636. WWWritePrivateProfileInt("Options", "ScrollRate", ScrollRate, buffer);
  637. WWWritePrivateProfileInt("Options", "Brightness", Brightness, buffer);
  638. WWWritePrivateProfileInt("Options", "Volume", Volume, buffer);
  639. WWWritePrivateProfileInt("Options", "ScoreVolume", ScoreVolume, buffer);
  640. WWWritePrivateProfileInt("Options", "Contrast", Contrast, buffer);
  641. WWWritePrivateProfileInt("Options", "Color", Color, buffer);
  642. WWWritePrivateProfileInt("Options", "Tint", Tint, buffer);
  643. WWWritePrivateProfileInt("Options", "AutoScroll", AutoScroll, buffer);
  644. WWWritePrivateProfileInt("Options", "IsScoreRepeat", IsScoreRepeat, buffer);
  645. WWWritePrivateProfileInt("Options", "IsScoreShuffle", IsScoreShuffle, buffer);
  646. WWWritePrivateProfileInt("Options", "DeathAnnounce", IsDeathAnnounce, buffer);
  647. WWWritePrivateProfileInt("Options", "FreeScrolling", IsFreeScroll, buffer);
  648. /*
  649. ** Write the INI data out to a file.
  650. */
  651. file.Write(buffer,strlen(buffer));
  652. }
  653. /***********************************************************************************************
  654. * OptionsClass::Set -- Sets options based on current settings *
  655. * *
  656. * Use this routine to adjust the palette or sound settings after a fresh scenario load. *
  657. * It assumes the values needed are already loaded into OptionsClass. *
  658. * *
  659. * INPUT: *
  660. * *
  661. * OUTPUT: *
  662. * *
  663. * WARNINGS: *
  664. * *
  665. * HISTORY: *
  666. * 06/24/1995 BRR : Created. *
  667. *=============================================================================================*/
  668. void OptionsClass::Set(void)
  669. {
  670. Set_Brightness(Brightness);
  671. Set_Contrast(Contrast);
  672. Set_Color(Color);
  673. Set_Tint(Tint);
  674. Set_Sound_Volume(Volume,false);
  675. Set_Score_Volume(ScoreVolume);
  676. Set_Repeat(IsScoreRepeat);
  677. Set_Shuffle(IsScoreShuffle);
  678. }
  679. /***********************************************************************************************
  680. * OptionsClass::Normalize_Delay -- Normalizes delay factor to keep rate constant. *
  681. * *
  682. * This routine is used to adjust delay factors that MUST be synchronized on all machines *
  683. * but should maintain a speed as close to constant as possible. Building animations are *
  684. * a good example of this. *
  685. * *
  686. * INPUT: delay -- The normal delay factor. *
  687. * *
  688. * OUTPUT: Returns with the delay to use that has been modified so that a reasonably constant *
  689. * rate will result. *
  690. * *
  691. * WARNINGS: This calculation is crude due to the coarse resolution that a 1/15 second timer *
  692. * allows. *
  693. * *
  694. * Use of this routine ASSUMES that the GameSpeed is synchronized on all machines. *
  695. * *
  696. * HISTORY: *
  697. * 06/18/1995 JLB : Created. *
  698. * 06/30/1995 JLB : Handles low values in a more consistent manner. *
  699. *=============================================================================================*/
  700. int OptionsClass::Normalize_Delay(int delay) const
  701. {
  702. static int _adjust[][8] = {
  703. {2,2,1,1,1,1,1,1},
  704. {3,3,3,2,2,2,1,1},
  705. {5,4,4,3,3,2,2,1},
  706. {7,6,5,4,4,4,3,2}
  707. };
  708. if (delay) {
  709. if (delay < 5) {
  710. delay = _adjust[delay-1][GameSpeed];
  711. } else {
  712. delay = ((delay * 8) / (GameSpeed+1));
  713. }
  714. }
  715. return(delay);
  716. }
  717. void OptionsClass::Fixup_Palette(void) const
  718. {
  719. Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast);
  720. }
  721. int OptionsClass::Normalize_Sound(int volume) const
  722. {
  723. return(Fixed_To_Cardinal(volume, Volume));
  724. }