MAPSEL.CPP 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/MAPSEL.CPP 1 3/03/97 10:25a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : MAPSEL.CPP *
  26. * *
  27. * Programmer : Barry W. Green *
  28. * *
  29. * Start Date : April 17, 1995 *
  30. * *
  31. * Last Update : April 27, 1995 [BWG] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * Bit_It_In -- Pixel fade graphic copy. *
  36. * Map_Selection -- Starts the whole process of selecting next map to go to *
  37. * Print_Statistics -- Prints statistics on country selected *
  38. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  39. #include "function.h"
  40. void Cycle_Call_Back_Delay(int time, PaletteClass &pal);
  41. extern int ControlQ;
  42. int Mouse_Over_Spot(int house, int scenario);
  43. void Set_Mouse(MouseType shape, int &start, int &count, int &delay, int &xspot, int &yspot);
  44. //VG for ant mission progression
  45. const char* antmission[] = {NULL, "SCA01EA.INI", "SCA02EA.INI", "SCA03EA.INI", "SCA04EA.INI"};
  46. struct point {
  47. int x;
  48. int y;
  49. } const MapCoords[2][14][3] = {
  50. {
  51. {{185,123},{ -1, -1},{ -1, -1}},
  52. {{173,112},{ -1, -1},{ -1, -1}},
  53. {{196,100},{200,112},{ -1, -1}},
  54. {{175,113},{ -1, -1},{ -1, -1}},
  55. {{187, 91},{202, 93},{206,105}},
  56. {{207,161},{212,172},{ -1, -1}},
  57. {{172, 92},{ -1, -1},{ -1, -1}},
  58. {{132,119},{146,125},{ -1, -1}},
  59. {{199, 73},{205, 86},{ -1, -1}},
  60. {{236,114},{ -1, -1},{ -1, -1}},
  61. {{219, 64},{225, 76},{ -1, -1}},
  62. {{256, 69},{ -1, -1},{ -1, -1}},
  63. {{262, 77},{ -1, -1},{ -1, -1}},
  64. {{249, 97},{ -1, -1},{ -1, -1}}
  65. },
  66. // Soviet coords
  67. {
  68. {{178,105},{ -1, -1},{ -1, -1}},
  69. {{163,101},{163,113},{ -1, -1}},
  70. {{160, 89},{ -1, -1},{ -1, -1}},
  71. {{142,101},{142,117},{ -1, -1}},
  72. {{212,163},{ -1, -1},{ -1, -1}},
  73. {{155,133},{171,144},{ -1, -1}},
  74. {{216,103},{ -1, -1},{ -1, -1}},
  75. {{132,145},{154,154},{ -1, -1}},
  76. {{122,117},{ -1, -1},{ -1, -1}},
  77. {{117,130},{ -1, -1},{ -1, -1}},
  78. {{ 99,107},{109,146},{ -1, -1}},
  79. {{134,125},{ -1, -1},{ -1, -1}},
  80. {{ 32,156},{ 46,171},{ -1, -1}},
  81. {{108, 97},{ -1, -1},{ -1, -1}}
  82. }
  83. };
  84. #ifndef WIN32
  85. extern short StreamLowImpact;
  86. #endif //WIN32
  87. /***********************************************************************************************
  88. * Map_Selection -- Starts the whole process of selecting next map to go to *
  89. * *
  90. * *
  91. * INPUT: *
  92. * *
  93. * OUTPUT: none *
  94. * *
  95. * WARNINGS: none *
  96. * *
  97. * HISTORY: *
  98. * 07/18/1996 BWG : Created. *
  99. *=============================================================================================*/
  100. extern int CopyType;
  101. #ifndef WIN32
  102. extern short StreamLowImpact;
  103. #endif
  104. char const * Map_Selection(void)
  105. {
  106. static char scenarioname[_MAX_FNAME+_MAX_EXT];
  107. #ifdef FIXIT_ANTS
  108. if (AntsEnabled) {
  109. strcpy(scenarioname, Scen.ScenarioName);
  110. char buf[10];
  111. sprintf(buf, "%02d", Scen.Scenario+1);
  112. memcpy(&scenarioname[3], buf, 2);
  113. return(scenarioname);
  114. }
  115. #endif
  116. char _filename[]="MSAA.WSA";
  117. int house = (PlayerPtr->Class->House == HOUSE_USSR || PlayerPtr->Class->House == HOUSE_UKRAINE);
  118. _filename[2] = house ? 'S' : 'A';
  119. _filename[3] = Scen.Scenario + 'A';
  120. PaletteClass mappalette;
  121. int scenario = Scen.Scenario;
  122. int selection;
  123. static CDTimerClass<SystemTimerClass> timer;
  124. int start = 0;
  125. int count = 0;
  126. int delay = 0;
  127. int xspot = 0;
  128. int yspot = 0;
  129. void const * appear1 = MFCD::Retrieve("MAPWIPE2.AUD");
  130. void const * bleep11 = MFCD::Retrieve("BLEEP11.AUD");
  131. void const * country4 = MFCD::Retrieve("MAPWIPE5.AUD");
  132. void const * toney7 = MFCD::Retrieve("TONEY7.AUD");
  133. void const * bleep17 = MFCD::Retrieve("BLEEP17.AUD");
  134. void const * scold1 = MFCD::Retrieve("TONEY4.AUD");
  135. void const * country1 = MFCD::Retrieve("TONEY10.AUD");
  136. #ifdef WIN32
  137. GraphicBufferClass *pseudoseenbuff = new GraphicBufferClass(320, 200, (void*)NULL);
  138. #endif
  139. // fixed oldvolume = Options.ScoreVolume;
  140. // Options.Set_Score_Volume(fixed(4, 10));
  141. Theme.Queue_Song(THEME_MAP);
  142. void *anim = Open_Animation(_filename, NULL, 0L, (WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE), mappalette);
  143. Keyboard->Clear();
  144. SeenPage.Clear();
  145. mappalette.Set(FADE_PALETTE_FAST, Call_Back);
  146. #ifdef WIN32
  147. pseudoseenbuff->Clear();
  148. Animate_Frame(anim, *pseudoseenbuff, 1);
  149. for(int x=0; x<256; x++) memset(&PaletteInterpolationTable[x][0],x,256);
  150. CopyType = 1;
  151. Interpolate_2X_Scale(pseudoseenbuff , &SeenBuff , 0);
  152. #else
  153. HidPage.Clear();
  154. Animate_Frame(anim, HidPage, 1);
  155. HidPage.Blit(SeenPage);
  156. #endif
  157. int frame = 1;
  158. StreamLowImpact = true;
  159. #ifdef WIN32
  160. Play_Sample(appear1, 255, Options.Normalize_Volume(170));
  161. #else
  162. Play_Sample(appear1, 255, Options.Normalize_Volume(55));
  163. #endif
  164. while (frame < Get_Animation_Frame_Count(anim)) {
  165. #ifdef WIN32
  166. CopyType = 1;
  167. Animate_Frame(anim, *pseudoseenbuff, frame++);
  168. Interpolate_2X_Scale(pseudoseenbuff , &SeenBuff , NULL);
  169. CopyType = 0;
  170. #else
  171. Animate_Frame(anim, SeenPage, frame++);
  172. #endif
  173. Call_Back_Delay(2);
  174. switch(frame) {
  175. case 16:
  176. #ifdef WIN32
  177. Play_Sample(bleep11, 255, Options.Normalize_Volume(170));
  178. #else
  179. Play_Sample(bleep11, 255, Options.Normalize_Volume(55));
  180. #endif
  181. break;
  182. case 30:
  183. #ifdef WIN32
  184. Play_Sample(country4, 255, Options.Normalize_Volume(170));
  185. #else
  186. Play_Sample(country4, 255, Options.Normalize_Volume(55));
  187. #endif
  188. break;
  189. case 51:
  190. #ifdef WIN32
  191. Play_Sample(toney7, 255, Options.Normalize_Volume(170));
  192. #else
  193. Play_Sample(toney7, 255, Options.Normalize_Volume(55));
  194. #endif
  195. break;
  196. case 61:
  197. #ifdef WIN32
  198. Play_Sample(bleep17, 255, Options.Normalize_Volume(170));
  199. #else
  200. Play_Sample(bleep17, 255, Options.Normalize_Volume(55));
  201. #endif
  202. break;
  203. }
  204. }
  205. StreamLowImpact = false;
  206. Call_Back();
  207. Close_Animation(anim);
  208. Show_Mouse();
  209. Keyboard->Clear();
  210. bool done = 0;
  211. MouseType shape = MOUSE_NORMAL;
  212. while (!done) {
  213. #ifdef WIN32
  214. /*
  215. ** If we have just received input focus again after running in the background then
  216. ** we need to redraw.
  217. */
  218. if (AllSurfaces.SurfacesRestored) {
  219. AllSurfaces.SurfacesRestored=FALSE;
  220. CopyType = 1;
  221. Interpolate_2X_Scale(pseudoseenbuff , &SeenBuff , NULL);
  222. CopyType = 0;
  223. }
  224. #endif
  225. Cycle_Call_Back_Delay(1, mappalette);
  226. int choice = Mouse_Over_Spot(house, scenario);
  227. if (choice == -1) {
  228. shape = MOUSE_NORMAL;
  229. } else {
  230. shape = MOUSE_CAN_ATTACK;
  231. }
  232. Set_Mouse(shape, start, count, delay, xspot, yspot);
  233. if (timer == 0) {
  234. frame++;
  235. frame %= count;
  236. timer = delay;
  237. Set_Mouse_Cursor(xspot, yspot, Extract_Shape(MouseClass::MouseShapes, start + frame));
  238. }
  239. if (Keyboard->Check()) {
  240. if ((Keyboard->Get() & 0x10FF) == KN_LMOUSE) {
  241. if (choice != -1) {
  242. done = 1;
  243. selection = choice;
  244. #ifdef WIN32
  245. Play_Sample(country1, 255, Options.Normalize_Volume(170));
  246. #else
  247. Play_Sample(country1, 255, Options.Normalize_Volume(50));
  248. #endif
  249. } else {
  250. #ifdef WIN32
  251. Play_Sample(scold1, 255, Options.Normalize_Volume(170));
  252. #else
  253. Play_Sample(scold1, 255, Options.Normalize_Volume(50));
  254. #endif
  255. }
  256. }
  257. }
  258. }
  259. Hide_Mouse();
  260. /*
  261. ** Restore the mouse to normal shape before leaving this routine.
  262. */
  263. Set_Mouse(MOUSE_NORMAL, start, count, delay, xspot, yspot);
  264. Set_Mouse_Cursor(xspot, yspot, Extract_Shape(MouseClass::MouseShapes, start));
  265. Keyboard->Clear();
  266. // BlackPalette.Set(FADE_PALETTE_SLOW, Call_Back);
  267. // SeenPage.Clear();
  268. Fancy_Text_Print(TXT_STAND_BY, 160 * RESFACTOR, 190 * RESFACTOR, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_CENTER|TPF_6PT_GRAD|TPF_DROPSHADOW);
  269. /*
  270. ** Create the new scenario filename from the selection. The filename is
  271. ** derived from the previous filename but it has the scenario number
  272. ** incremented and the chosen variation set.
  273. */
  274. //V.G. added so Ant Missions would progress
  275. if(Scen.ScenarioName[2] == 'A'){
  276. int antnum = Scen.Scenario++;
  277. if(antnum > 4) antnum = 1;
  278. strcpy(scenarioname, antmission[antnum]);
  279. }
  280. else{
  281. strcpy(scenarioname, Scen.ScenarioName);
  282. char buf[10];
  283. sprintf(buf, "%02d", Scen.Scenario+1);
  284. memcpy(&scenarioname[3], buf, 2);
  285. scenarioname[6] = 'A' + selection;
  286. }
  287. Theme.Fade_Out();
  288. // Options.Set_Score_Volume(oldvolume);
  289. // Scen.ScenVar = (ScenarioVarType)selection;
  290. //Mono_Printf("Chose variant %d \n", selection);
  291. return(scenarioname);
  292. }
  293. int Mouse_Over_Spot(int house, int scenario)
  294. {
  295. int retval = -1;
  296. for (int selection = 0; selection < 3 && MapCoords[house][scenario][selection].x != -1; selection++) {
  297. int mousex = Get_Mouse_X() / RESFACTOR;
  298. int mousey = Get_Mouse_Y() / RESFACTOR;
  299. if (mousex >= MapCoords[house][scenario][selection].x &&
  300. mousey >= MapCoords[house][scenario][selection].y &&
  301. mousex <= MapCoords[house][scenario][selection].x+11 &&
  302. mousey <= MapCoords[house][scenario][selection].y+9) {
  303. retval = selection;
  304. break;
  305. }
  306. }
  307. return(retval);
  308. }
  309. void Cycle_Call_Back_Delay(int time, PaletteClass &pal)
  310. {
  311. static CDTimerClass<SystemTimerClass> _ftimer;
  312. static bool _up = false;
  313. static int val = 255;
  314. while(time--) {
  315. /*
  316. ** Process the fading white color.
  317. */
  318. if (!_ftimer) {
  319. _ftimer = TIMER_SECOND/6;
  320. #define STEP_RATE 20
  321. if (_up) {
  322. val += STEP_RATE;
  323. if (val > 150) {
  324. val = 150;
  325. _up = false;
  326. }
  327. } else {
  328. val -= STEP_RATE;
  329. if (val < 0x20) {
  330. val = 0x20;
  331. _up = true;
  332. }
  333. }
  334. /*
  335. ** Set the pulse color as the proportional value between white and the
  336. ** minimum value for pulsing.
  337. */
  338. pal[254] = GamePalette[WHITE];
  339. pal[254].Adjust(val, BlackColor);
  340. pal.Set();
  341. }
  342. Call_Back_Delay(1);
  343. }
  344. }
  345. void Set_Mouse(MouseType shape, int &start, int &count, int &delay, int &xspot, int &yspot)
  346. {
  347. switch(shape) {
  348. case MOUSE_NORMAL:
  349. start = 0;
  350. count = 1;
  351. delay = 0;
  352. xspot = 0;
  353. yspot = 0;
  354. break;
  355. default:
  356. start = 21;
  357. count = 8;
  358. delay = 4;
  359. xspot = 14;
  360. yspot = 11;
  361. break;
  362. }
  363. }