RADAR.CPP 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607
  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/RADAR.CPP 3 3/12/97 2:35p 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 : RADAR.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/15/94 *
  30. * *
  31. * Last Update : September 16, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * Get_Multi_Color -- Get the multi color offset number *
  36. * RadarClass::AI -- Processes radar input (non-tactical). *
  37. * RadarClass::Cell_On_Radar -- Determines if a cell is currently visible on radar. *
  38. * RadarClass::Click_Cell_Calc -- Determines what cell the pixel coordinate is over. *
  39. * RadarClass::Click_In_Radar -- Check to see if a click is in radar map *
  40. * RadarClass::Click_In_Radar -- Converts a radar click into cell X and Y coordinate. *
  41. * RadarClass::Draw_It -- Displays the radar map of the terrain. *
  42. * RadarClass::Draw_Names -- draws players' names on the radar map *
  43. * RadarClass::Get_Jammed -- Fetch the current radar jammed state for the player. *
  44. * RadarClass::Init_Clear -- Sets the radar map to a known state *
  45. * RadarClass::Is_Radar_Active -- Determines if the radar map is currently being displayed. *
  46. * RadarClass::Is_Radar_Existing -- Queries to see if radar map is available. *
  47. * RadarClass::Is_Zoomable -- Determines if the map can be zoomed. *
  48. * RadarClass::Map_Cell -- Updates radar map when a cell becomes mapped. *
  49. * RadarClass::One_Time -- Handles one time processing for the radar map. *
  50. * RadarClass::Player_Names -- toggles the Player-Names mode of the radar map *
  51. * RadarClass::Plot_Radar_Pixel -- Updates the radar map with a terrain pixel. *
  52. * RadarClass::RTacticalClass::Action -- I/O function for the radar map. *
  53. * RadarClass::RadarClass -- Default constructor for RadarClass object. *
  54. * RadarClass::Radar_Activate -- Controls radar activation. *
  55. * RadarClass::Radar_Anim -- Renders current frame of radar animation *
  56. * RadarClass::Radar_Cursor -- Adjust the position of the radar map cursor. *
  57. * RadarClass::Radar_Pixel -- Mark a cell to be rerendered on the radar map. *
  58. * RadarClass::Radar_Position -- Returns with the current position of the radar map. *
  59. * RadarClass::Refresh_Cells -- Intercepts refresh request and updates radar if needed *
  60. * RadarClass::Render_Infantry -- Displays objects on the radar map. *
  61. * RadarClass::Render_Overlay -- Renders an icon for given overlay *
  62. * RadarClass::Render_Terrain -- Render the terrain over the given cell *
  63. * RadarClass::Set_Map_Dimensions -- Sets the tactical map dimensions. *
  64. * RadarClass::Set_Radar_Position -- Sets the radar position to center around specified cell.*
  65. * RadarClass::Set_Tactical_Position -- Called when setting the tactical display position. *
  66. * RadarClass::Set_Tactical_Position -- Called when setting the tactical display position. *
  67. * RadarClass::Set_Tactical_Position -- Sets the map's tactical position and adjusts radar to*
  68. * RadarClass::Zoom_Mode(void) -- Handles toggling zoom on the map *
  69. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  70. #include "function.h"
  71. //void const * RadarClass::CoverShape;
  72. RadarClass::RTacticalClass RadarClass::RadarButton;
  73. void const * RadarClass::RadarAnim = NULL;
  74. void const * RadarClass::RadarPulse = NULL;
  75. void const * RadarClass::RadarFrame = NULL;
  76. static bool FullRedraw = false;
  77. static GraphicBufferClass _IconStage(3,3);
  78. static GraphicBufferClass _TileStage(24,24);
  79. /***********************************************************************************************
  80. * RadarClass::RadarClass -- Default constructor for RadarClass object. *
  81. * *
  82. * This default constructor merely sets the radar specific values to default settings. The *
  83. * radar must be deliberately activated in order for it to be displayed. *
  84. * *
  85. * INPUT: none *
  86. * *
  87. * OUTPUT: none *
  88. * *
  89. * WARNINGS: none *
  90. * *
  91. * HISTORY: *
  92. * 12/16/1994 JLB : Created. *
  93. *=============================================================================================*/
  94. RadarClass::RadarClass(void) :
  95. IsToRedraw(false),
  96. RadarCursorRedraw(false),
  97. IsPulseActive(false),
  98. RadarPulseFrame(0),
  99. DoesRadarExist(false),
  100. IsRadarActive(false),
  101. IsRadarActivating(false),
  102. IsRadarDeactivating(false),
  103. IsRadarJammed(false),
  104. SpecialRadarFrame(0),
  105. RadarAnimFrame(0),
  106. RadarX(0),
  107. RadarY(0),
  108. RadarCellWidth(0),
  109. RadarCellHeight(0),
  110. RadarCell(0),
  111. BaseX(0),
  112. BaseY(0),
  113. RadarWidth(0),
  114. RadarHeight(0),
  115. IsZoomed(true),
  116. ZoomFactor(0),
  117. IsPlayerNames(false),
  118. IsHouseSpy(false),
  119. SpyingOn(HOUSE_SPAIN),
  120. PixelPtr(0)
  121. {
  122. }
  123. /***********************************************************************************************
  124. * RadarClass::One_Time -- Handles one time processing for the radar map. *
  125. * *
  126. * This routine handles any one time processing required in order for the radar map to *
  127. * function. This actually only requires an allocation of the radar staging buffer. This *
  128. * buffer is needed for those cases where the radar area of the page is being destroyed *
  129. * and it needs to be destroyed. *
  130. * *
  131. * INPUT: none *
  132. * *
  133. * OUTPUT: none *
  134. * *
  135. * WARNINGS: Be sure to call this routine only ONCE. *
  136. * *
  137. * HISTORY: *
  138. * 12/22/1994 JLB : Created. *
  139. *=============================================================================================*/
  140. void RadarClass::One_Time(void)
  141. {
  142. RadWidth = 80 * RESFACTOR;
  143. RadHeight = 70 * RESFACTOR;
  144. RadX = SeenBuff.Get_Width() - RadWidth;
  145. RadY = 7 * RESFACTOR;
  146. RadPWidth = 64 * RESFACTOR;
  147. RadPHeight = 64 * RESFACTOR;
  148. #ifdef WIN32
  149. RadOffX = 6;
  150. RadOffY = 7;
  151. RadIWidth = 128+18;//************
  152. RadIHeight = 128+2;//************
  153. #else
  154. RadOffX = 4;
  155. RadOffY = 1;
  156. RadIWidth = 72;
  157. RadIHeight = 69;
  158. #endif
  159. DisplayClass::One_Time();
  160. #ifdef OBSOLETE
  161. RadarButton.X = RadX+RadOffX;
  162. RadarButton.Y = RadY+RadOffY;
  163. RadarButton.Width = RadIWidth;
  164. RadarButton.Height = RadIHeight;
  165. #else
  166. RadarButton.X = RadX;
  167. RadarButton.Y = RadY;
  168. RadarButton.Width = RadWidth;
  169. RadarButton.Height = RadHeight;
  170. #endif
  171. }
  172. /***********************************************************************************************
  173. * RadarClass::Init_Clear -- Sets the radar map to a known state. *
  174. * *
  175. * This routine is used to initialize the radar map at the start of the scenario. It *
  176. * sets the radar map position and starts it in the disabled state. *
  177. * *
  178. * INPUT: theater -- The theater that the scenario is starting (unused by this routine). *
  179. * *
  180. * OUTPUT: none *
  181. * *
  182. * WARNINGS: none *
  183. * *
  184. * HISTORY: *
  185. * 12/22/1994 JLB : Created. *
  186. *=============================================================================================*/
  187. void RadarClass::Init_Clear(void)
  188. {
  189. DisplayClass::Init_Clear();
  190. IsRadarActive = false;
  191. IsToRedraw = true;
  192. RadarCursorRedraw = true;
  193. IsRadarActivating = false;
  194. IsRadarDeactivating = false;
  195. DoesRadarExist = false;
  196. PixelPtr = 0;
  197. IsPlayerNames = false;
  198. /*
  199. ** If we have a valid map lets make sure that we set it correctly
  200. */
  201. if (MapCellWidth || MapCellHeight) {
  202. #ifdef WIN32
  203. IsZoomed = false;
  204. #else
  205. IsZoomed = true;
  206. #endif
  207. Zoom_Mode(Coord_Cell(Map.TacticalCoord));
  208. }
  209. }
  210. /***********************************************************************************************
  211. * RadarClass::Radar_Activate -- Controls radar activation. *
  212. * *
  213. * Use this routine to turn the radar map on or off. *
  214. * *
  215. * INPUT: control -- What to do with the radar map: *
  216. * 0 = Turn radar off. *
  217. * 1 = Turn radar on. *
  218. * 2 = Remove Radar Gadgets *
  219. * 3 = Add Radar Gadgets *
  220. * 4 = Remove radar. *
  221. * -1= Toggle radar on or off. *
  222. * *
  223. * OUTPUT: bool; Was the radar map already on? *
  224. * *
  225. * WARNINGS: none *
  226. * *
  227. * HISTORY: *
  228. * 12/11/1994 JLB : Created. *
  229. *=============================================================================================*/
  230. bool RadarClass::Radar_Activate(int control)
  231. {
  232. bool old = IsRadarActive;
  233. switch (control) {
  234. /*
  235. ** Toggle the state of the radar map on or off.
  236. */
  237. case -1:
  238. {
  239. int temp = (IsRadarActive == false);
  240. if (temp) {
  241. Radar_Activate(1);
  242. } else {
  243. Radar_Activate(0);
  244. }
  245. }
  246. break;
  247. /*
  248. ** Turn the radar map off properly.
  249. */
  250. case 0:
  251. if (Map.IsSidebarActive) {
  252. if (IsRadarActive && !IsRadarDeactivating) {
  253. Sound_Effect(VOC_RADAR_OFF);
  254. IsRadarDeactivating = true;
  255. IsRadarActive = false;
  256. if (IsRadarActivating == true) {
  257. IsRadarActivating = false;
  258. } else {
  259. RadarAnimFrame = RADAR_ACTIVATED_FRAME;
  260. }
  261. }
  262. } else {
  263. Radar_Activate(2);
  264. }
  265. return(old);
  266. case 1:
  267. if (Map.IsSidebarActive) {
  268. if (!IsRadarActivating && !IsRadarActive) {
  269. Sound_Effect(VOC_RADAR_ON);
  270. IsRadarActivating = true;
  271. if (IsRadarDeactivating == true) {
  272. IsRadarDeactivating = false;
  273. } else {
  274. if (DoesRadarExist) {
  275. RadarAnimFrame = MAX_RADAR_FRAMES;
  276. } else {
  277. RadarAnimFrame = 0;
  278. }
  279. }
  280. }
  281. } else {
  282. Radar_Activate(3);
  283. }
  284. return(old);
  285. case 2:
  286. if (Session.Type==GAME_NORMAL) {
  287. SidebarClass::Zoom.Disable();
  288. } else {
  289. SidebarClass::Zoom.Enable();
  290. }
  291. IsRadarActive = false;
  292. IsRadarActivating = false;
  293. IsRadarDeactivating = false;
  294. break;
  295. case 3:
  296. if (Session.Type == GAME_NORMAL && Is_Zoomable()) {
  297. SidebarClass::Zoom.Enable();
  298. }
  299. IsRadarActive = true;
  300. IsRadarActivating = false;
  301. IsRadarDeactivating = false;
  302. break;
  303. case 4:
  304. IsRadarActive = false;
  305. IsRadarActivating = false;
  306. IsRadarDeactivating = false;
  307. DoesRadarExist = false;
  308. Flag_To_Redraw(false);
  309. IsToRedraw = true;
  310. break;
  311. default:
  312. break;
  313. }
  314. if (IsRadarActive != old) {
  315. IsToRedraw = true;
  316. Flag_To_Redraw(false);
  317. }
  318. FullRedraw = IsRadarActive;
  319. return(old);
  320. }
  321. /***********************************************************************************************
  322. * RadarClass::Draw_It -- Displays the radar map of the terrain. *
  323. * *
  324. * This is used to display the radar map that appears in the lower *
  325. * right corner. The main changes to this map are the vehicles and *
  326. * structure pixels. *
  327. * *
  328. * INPUT: none *
  329. * *
  330. * OUTPUT: none *
  331. * *
  332. * WARNINGS: none *
  333. * *
  334. * HISTORY: *
  335. * 04/24/1991 JLB : Created. *
  336. * 05/08/1994 JLB : Converted to member function. *
  337. *=============================================================================================*/
  338. void RadarClass::Draw_It(bool forced)
  339. {
  340. DisplayClass::Draw_It(forced);
  341. static char * _hiresradarnames[]={
  342. "natoradr.shp", //HOUSE_SPAIN,
  343. "natoradr.shp", //HOUSE_GREECE,
  344. "ussrradr.shp", //HOUSE_USSR,
  345. "natoradr.shp", //HOUSE_ENGLAND,
  346. "ussrradr.shp", //HOUSE_UKRAINE,
  347. "natoradr.shp", //HOUSE_GERMANY,
  348. "natoradr.shp", //HOUSE_FRANCE,
  349. "natoradr.shp", //HOUSE_TURKEY,
  350. "natoradr.shp", //HOUSE_GOOD
  351. "ussrradr.shp", //HOUSE_BAD
  352. };
  353. static char * _frames[]={
  354. "nradrfrm.shp", //HOUSE_SPAIN,
  355. "nradrfrm.shp", //HOUSE_GREECE,
  356. "uradrfrm.shp", //HOUSE_USSR,
  357. "nradrfrm.shp", //HOUSE_ENGLAND,
  358. "uradrfrm.shp", //HOUSE_UKRAINE,
  359. "nradrfrm.shp", //HOUSE_GERMANY,
  360. "nradrfrm.shp", //HOUSE_FRANCE,
  361. "nradrfrm.shp", //HOUSE_TURKEY,
  362. "nradrfrm.shp", //HOUSE_GOOD
  363. "uradrfrm.shp", //HOUSE_BAD
  364. };
  365. int radarforced = 0;
  366. /*
  367. ** Don't perform any rendering if none is requested.
  368. */
  369. if (!forced && !IsToRedraw && !FullRedraw) return;
  370. BStart(BENCH_RADAR);
  371. static HousesType _house = HOUSE_NONE;
  372. if (PlayerPtr->ActLike != _house) {
  373. char name[_MAX_FNAME + _MAX_EXT];
  374. // strcpy(name, "NATORADR.SHP" );
  375. // if (Session.Type == GAME_NORMAL) {
  376. strcpy(name, _hiresradarnames[PlayerPtr->ActLike]);
  377. // }
  378. #ifndef NDEBUG
  379. RawFileClass file(name);
  380. if (file.Is_Available()) {
  381. RadarAnim = Load_Alloc_Data(file);
  382. } else {
  383. RadarAnim = MFCD::Retrieve(name);
  384. }
  385. strcpy(name, "PULSE.SHP");
  386. RawFileClass file2(name);
  387. if (file2.Is_Available()) {
  388. RadarPulse = Load_Alloc_Data(file2);
  389. } else {
  390. RadarPulse = MFCD::Retrieve(name);
  391. }
  392. strcpy(name, _frames[PlayerPtr->ActLike]);
  393. RawFileClass file3(name);
  394. if (file3.Is_Available()) {
  395. RadarFrame = Load_Alloc_Data(file3);
  396. } else {
  397. RadarFrame = MFCD::Retrieve(_frames[PlayerPtr->ActLike]);
  398. }
  399. #else
  400. RadarAnim = MFCD::Retrieve(name);
  401. strcpy(name, "PULSE.SHP");
  402. RawFileClass file3(name);
  403. if (file3.Is_Available()) {
  404. RadarPulse = Load_Alloc_Data(file3);
  405. } else {
  406. RadarPulse = MFCD::Retrieve(name);
  407. }
  408. RadarFrame = MFCD::Retrieve(_frames[PlayerPtr->ActLike]);
  409. #endif
  410. _house = PlayerPtr->ActLike;
  411. }
  412. /*
  413. ** If in player name mode, just draw player names
  414. */
  415. if (IsPlayerNames) {
  416. Draw_Names();
  417. IsToRedraw = false;
  418. BEnd(BENCH_RADAR);
  419. return;
  420. }
  421. /*
  422. ** If in spy-on-radar facility mode, draw the appropriate info.
  423. */
  424. if (IsHouseSpy) {
  425. IsToRedraw = false;
  426. if (Draw_House_Info()) {
  427. BEnd(BENCH_RADAR);
  428. return;
  429. }
  430. }
  431. if (IsRadarActivating || IsRadarDeactivating || IsRadarJammed) {
  432. Radar_Anim();
  433. Map.Repair.Draw_Me(true);
  434. Map.Upgrade.Draw_Me(true);
  435. Map.Zoom.Draw_Me(true);
  436. IsToRedraw = false;
  437. BEnd(BENCH_RADAR);
  438. return;
  439. }
  440. if (Map.IsSidebarActive) {
  441. if (IsRadarActive) {
  442. /*
  443. ** If only a few of the radar pixels need to be redrawn, then find and redraw
  444. ** only these.
  445. */
  446. if (!forced && IsToRedraw && !FullRedraw && !IsPulseActive) {
  447. IsToRedraw = false;
  448. if (PixelPtr) {
  449. /*
  450. ** Render all pixels in the "to redraw" stack.
  451. */
  452. if (LogicPage->Lock()) {
  453. for (int index = 0; index < PixelPtr; index++) {
  454. CELL cell = PixelStack[index];
  455. if (Cell_On_Radar(cell)) {
  456. (*this)[cell].IsPlot = false;
  457. Plot_Radar_Pixel(cell);
  458. RadarCursorRedraw |= (*this)[cell].IsRadarCursor;
  459. }
  460. }
  461. LogicPage->Unlock();
  462. }
  463. /*
  464. ** Refill the stack if there is pending pixels yet to be plotted.
  465. ** This should only process in sections for speed reasons
  466. */
  467. if (PixelPtr == PIXELSTACK) {
  468. PixelPtr = 0;
  469. for (int y = 0; y < MapCellHeight; y++) {
  470. for (int x = 0; x < MapCellWidth; x++) {
  471. CELL cell = XY_Cell(MapCellX + x, MapCellY + y);
  472. if (Cell_On_Radar(cell)) {
  473. if ((*this)[cell].IsPlot) {
  474. PixelStack[PixelPtr++] = cell;
  475. IsToRedraw = true;
  476. if (PixelPtr == PIXELSTACK) break;
  477. }
  478. }
  479. }
  480. if (PixelPtr == PIXELSTACK) break;
  481. }
  482. } else {
  483. PixelPtr = 0;
  484. }
  485. }
  486. Radar_Cursor(RadarCursorRedraw);
  487. } else {
  488. #ifdef WIN32
  489. GraphicViewPortClass * oldpage = Set_Logic_Page(HidPage);
  490. #else
  491. GraphicBufferClass * oldpage = Set_Logic_Page(HidPage);
  492. #endif
  493. CC_Draw_Shape(RadarFrame, 1, RadX, RadY+(1 * RESFACTOR), WINDOW_MAIN, SHAPE_NORMAL);
  494. if (BaseX || BaseY) {
  495. if (!IsZoomed && BaseX && BaseY && RadarWidth< (RadIWidth-1) && RadarHeight < (RadIHeight-1)) {
  496. #ifdef WIN32
  497. LogicPage->Draw_Rect(RadX + RadOffX + BaseX -1,
  498. RadY + RadOffY + BaseY -1,
  499. RadX + RadOffX + BaseX + RadarWidth,
  500. // RadX + RadOffX + BaseX + RadarWidth +1,
  501. RadY + RadOffY + BaseY + RadarHeight,
  502. // RadY + RadOffY + BaseY + RadarHeight +1,
  503. WHITE);
  504. #endif
  505. }
  506. } else {
  507. LogicPage->Fill_Rect( RadX + RadOffX,
  508. RadY + RadOffY,
  509. RadX + RadOffX + RadIWidth - 1,
  510. RadY + RadOffY + RadIHeight - 1,
  511. BLACK);
  512. }
  513. /*
  514. ** Draw the entire radar map.
  515. */
  516. if (LogicPage->Lock()) {
  517. for (int index = 0; index < MAP_CELL_TOTAL; index++) {
  518. if (In_Radar(index) && Cell_On_Radar(index)) {
  519. Plot_Radar_Pixel(index);
  520. }
  521. }
  522. if (IsPulseActive) {
  523. CC_Draw_Shape(RadarPulse, RadarPulseFrame++, RadX + RadOffX, RadY+1*RESFACTOR, WINDOW_MAIN, SHAPE_NORMAL);
  524. }
  525. LogicPage->Unlock();
  526. }
  527. Radar_Cursor(true);
  528. FullRedraw = false;
  529. IsToRedraw = false;
  530. Map.Repair.Draw_Me(true);
  531. Map.Upgrade.Draw_Me(true);
  532. Map.Zoom.Draw_Me(true);
  533. if (oldpage == &SeenBuff) {
  534. Hide_Mouse();
  535. LogicPage->Blit(SeenBuff, RadX, RadY, RadX, RadY, RadWidth, RadHeight);
  536. Show_Mouse();
  537. }
  538. Set_Logic_Page(oldpage);
  539. }
  540. } else {
  541. /*
  542. ** If the radar is not active, then only draw the cover plate if forced to do so.
  543. */
  544. int val = (DoesRadarExist) ? MAX_RADAR_FRAMES : 0;
  545. CC_Draw_Shape(RadarAnim, val, RadX, RadY + (1 * RESFACTOR), WINDOW_MAIN, SHAPE_NORMAL);
  546. FullRedraw = false;
  547. IsToRedraw = false;
  548. /*
  549. ** Display the country name on the cover plate when in multi play only.
  550. */
  551. if (Session.Type != GAME_NORMAL) {
  552. Fancy_Text_Print(Text_String(HouseTypeClass::As_Reference(PlayerPtr->ActLike).Full_Name()), RadX+RadWidth/2, RadY+RadHeight-10*RESFACTOR, &ColorRemaps[PlayerPtr->RemapColor], TBLACK, TPF_CENTER|TPF_TEXT|TPF_DROPSHADOW);
  553. }
  554. Map.Repair.Draw_Me(true);
  555. Map.Upgrade.Draw_Me(true);
  556. Map.Zoom.Draw_Me(true);
  557. }
  558. }
  559. BEnd(BENCH_RADAR);
  560. }
  561. /***************************************************************************
  562. * RadarClass::Render_Terrain -- Render the terrain over the given cell *
  563. * *
  564. * INPUT: *
  565. * *
  566. * OUTPUT: *
  567. * *
  568. * WARNINGS: *
  569. * *
  570. * HISTORY: *
  571. * 04/12/1995 PWG : Created. *
  572. *=========================================================================*/
  573. void RadarClass::Render_Terrain(CELL cell, int x, int y, int size)
  574. {
  575. TerrainClass * list[4] = {0,0,0,0};
  576. int listidx = 0;
  577. int lp,lp2;
  578. ObjectClass * obj = Map[cell].Cell_Occupier();
  579. /*
  580. ** If the cell is occupied by a terrain type, add it to the sortable
  581. ** list.
  582. */
  583. if (obj && obj->What_Am_I() == RTTI_TERRAIN)
  584. list[listidx++] = (TerrainClass *)obj;
  585. /*
  586. ** Now loop through all the occupiers and add them to the list if they
  587. ** are terrain type.
  588. */
  589. for (lp = 0; lp < ARRAY_SIZE(Map[cell].Overlapper); lp ++) {
  590. obj = Map[cell].Overlapper[lp];
  591. if (obj && obj->What_Am_I() == RTTI_TERRAIN)
  592. list[listidx++] = (TerrainClass *)obj;
  593. }
  594. /*
  595. ** If there are no entries in our list then just get out.
  596. */
  597. if (!listidx) return;
  598. /*
  599. ** If there is terrain in this cell then draw a dark pixel to
  600. ** represent it.
  601. */
  602. if (size == 1) {
  603. LogicPage->Put_Pixel(x, y, 21);
  604. // LogicPage->Put_Pixel(x, y, 60);
  605. return;
  606. }
  607. /*
  608. ** Sort the list by its sort Y value so that we can render in the proper
  609. ** order.
  610. */
  611. for (lp = 0; lp < listidx - 1; lp ++) {
  612. for (lp2 = lp + 1; lp2 < listidx; lp2++) {
  613. if (list[lp]->Sort_Y() > list[lp2]->Sort_Y()) {
  614. TerrainClass * terrain = list[lp];
  615. list[lp] = list[lp2];
  616. list[lp2] = terrain;
  617. }
  618. }
  619. }
  620. /*
  621. ** loop through the list and take care of rendering the correct icon.
  622. */
  623. for (lp = 0; lp < listidx; lp ++) {
  624. unsigned char * icon = list[lp]->Radar_Icon(cell);
  625. if (!icon) continue;
  626. #ifdef WIN32
  627. Buffer_To_Page(0, 0, 3, 3, icon, _IconStage);
  628. _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, ZoomFactor, ZoomFactor, TRUE, (char *)&FadingBrighten[0]);
  629. #else
  630. for (int lpy = 0; lpy < 3; lpy++) {
  631. for (int lpx = 0; lpx < 3; lpx++) {
  632. if (*icon) {
  633. LogicPage->Put_Pixel(x + lpx, y + lpy, FadingBrighten[*icon]);
  634. }
  635. icon++;
  636. }
  637. }
  638. #endif //WIN32
  639. }
  640. }
  641. /***********************************************************************************************
  642. * RadarClass::Render_Infantry -- Displays objects on the radar map. *
  643. * *
  644. * This routine will display an object imagery at the location specified according to the *
  645. * condition of the specified cell. *
  646. * *
  647. * INPUT: cell -- The cell to use as reference when drawing the radar pixel. *
  648. * *
  649. * x,y -- The pixel coordinate to render the radar "pixel" at. *
  650. * *
  651. * size -- The size of the "pixel". When zoomed in, this value will be "3". *
  652. * *
  653. * OUTPUT: none *
  654. * *
  655. * WARNINGS: none *
  656. * *
  657. * HISTORY: *
  658. * 08/17/1995 JLB : Created. *
  659. *=============================================================================================*/
  660. void RadarClass::Render_Infantry(CELL cell, int x, int y, int size)
  661. {
  662. ObjectClass * obj;
  663. obj = (ObjectClass *)Map[cell].Cell_Occupier();
  664. while (obj) {
  665. if (obj->Is_Techno() && ((TechnoClass *)obj)->Is_Visible_On_Radar()) {
  666. int color = ColorRemaps[((InfantryClass *)obj)->House->RemapColor].Bar;
  667. // int color = ColorRemaps[((InfantryClass *)obj)->House->RemapColor].BrightColor;
  668. int xoff;
  669. int yoff;
  670. int subsize = max(1, size/3);
  671. switch (obj->What_Am_I()) {
  672. case RTTI_INFANTRY:
  673. xoff = (Coord_XLepton(obj->Coord) / (CELL_LEPTON_W/(size+1))) - subsize/2;
  674. xoff = max(xoff, 0);
  675. xoff = min(xoff, size-subsize);
  676. yoff = (Coord_YLepton(obj->Coord) / (CELL_LEPTON_H/(size+1))) - subsize/2;
  677. yoff = max(yoff, 0);
  678. yoff = min(yoff, size-subsize);
  679. /*
  680. ** Draw the infantryman's pixel. If he's a spy, draw in my house color
  681. */
  682. if (*(InfantryClass *)obj == INFANTRY_SPY) {
  683. color = ColorRemaps[PlayerPtr->RemapColor].Bar;
  684. // color = ColorRemaps[PlayerPtr->RemapColor].BrightColor;
  685. }
  686. LogicPage->Fill_Rect(x+xoff, y+yoff, x+xoff+(subsize-1), y+yoff+(subsize-1), color);
  687. break;
  688. case RTTI_UNIT:
  689. case RTTI_VESSEL:
  690. case RTTI_AIRCRAFT:
  691. LogicPage->Fill_Rect(x, y, x+size-1, y+size-1, color);
  692. break;
  693. default:
  694. break;
  695. }
  696. }
  697. obj = obj->Next;
  698. }
  699. }
  700. /***************************************************************************
  701. * RadarClass::Render_Overlay -- Renders an icon for given overlay *
  702. * *
  703. * INPUT: *
  704. * *
  705. * OUTPUT: *
  706. * *
  707. * WARNINGS: *
  708. * *
  709. * HISTORY: *
  710. * 04/18/1995 PWG : Created. *
  711. *=========================================================================*/
  712. void RadarClass::Render_Overlay(CELL cell, int x, int y, int size)
  713. {
  714. //int lpx,lpy;
  715. OverlayType overlay = (*this)[cell].Overlay;
  716. if (overlay != OVERLAY_NONE) {
  717. OverlayTypeClass const * otype = &OverlayTypeClass::As_Reference(overlay);
  718. if (otype->IsRadarVisible) {
  719. unsigned char * icon = otype->Radar_Icon((*this)[cell].OverlayData);
  720. if (!icon) return;
  721. #ifdef WIN32
  722. Buffer_To_Page(0, 0, 3, 3, icon, _IconStage);
  723. if (otype->IsTiberium) {
  724. if (size == 1) {
  725. LogicPage->Put_Pixel(x, y, DKGREY);
  726. // _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, size, size, TRUE, (char *)&FadingShade[0]);
  727. } else {
  728. _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, size, size, TRUE, (char *)&FadingYellow[0]);
  729. }
  730. // _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, size, size, TRUE, (char *)&FadingGreen[0]);
  731. // } else {
  732. // _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, size, size, TRUE, (char *)&FadingBrighten[0]);
  733. }
  734. #else
  735. for (int lpy = 0; lpy < size; lpy++) {
  736. for (int lpx = 0; lpx < size; lpx++) {
  737. if (size == 1) icon+=4;
  738. if (*icon) {
  739. if (otype->IsTiberium) {
  740. if (size == 1) {
  741. LogicPage->Put_Pixel(x + lpx, y + lpy, DKGREY);
  742. // LogicPage->Put_Pixel(x + lpx, y + lpy, FadingShade[*icon]);
  743. } else {
  744. LogicPage->Put_Pixel(x + lpx, y + lpy, FadingYellow[*icon]);
  745. }
  746. // LogicPage->Put_Pixel(x + lpx, y + lpy, FadingGreen[*icon]);
  747. // } else {
  748. // LogicPage->Put_Pixel(x + lpx, y + lpy, FadingBrighten[*icon]);
  749. }
  750. }
  751. if (size == 1) {
  752. icon+=5;
  753. } else {
  754. icon++;
  755. }
  756. icon++;
  757. }
  758. }
  759. #endif //WIN32
  760. }
  761. }
  762. }
  763. /***************************************************************************
  764. * RadarClass::Zoom_Mode -- Handles toggling zoom on the map *
  765. * *
  766. * INPUT: none *
  767. * *
  768. * OUTPUT: none *
  769. * *
  770. * HISTORY: *
  771. * 05/29/1995 PWG : Created. *
  772. *=========================================================================*/
  773. void RadarClass::Zoom_Mode(CELL cell)
  774. {
  775. int map_c_width;
  776. int map_c_height;
  777. /*
  778. ** Set all of the initial zoom mode variables to the correct
  779. ** setting.
  780. */
  781. #ifdef WIN32
  782. if (Is_Zoomable()) {
  783. IsZoomed = !IsZoomed;
  784. } else {
  785. IsZoomed = true;
  786. }
  787. #else
  788. IsZoomed = false;
  789. #endif
  790. BaseX = 0;
  791. BaseY = 0;
  792. /*
  793. ** Figure out exactly what size we need to zoom the map to.
  794. */
  795. if (!IsZoomed) {
  796. int xfactor = RadIWidth / MapCellWidth;
  797. int yfactor = RadIHeight / MapCellHeight;
  798. ZoomFactor = max(min(xfactor, yfactor) , 1);
  799. map_c_width = MapCellWidth;
  800. map_c_height = MapCellHeight;
  801. } else {
  802. ZoomFactor = 3;
  803. // ZoomFactor = 6;
  804. map_c_width = RadIWidth / ZoomFactor;
  805. map_c_height = RadIHeight / ZoomFactor;
  806. }
  807. /*
  808. ** Make sure we do not show more cells than are on the map.
  809. */
  810. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  811. #ifdef WIN32
  812. map_c_width = min(map_c_width, RadIWidth);
  813. map_c_width = min(map_c_width, MapCellWidth);
  814. map_c_height = min(map_c_height, RadIHeight);
  815. map_c_height = min(map_c_height, MapCellHeight);
  816. #else
  817. map_c_width = min(map_c_width, 62 * RESFACTOR);
  818. map_c_width = min(map_c_width, MapCellWidth);
  819. map_c_height = min(map_c_height, 62 * RESFACTOR);
  820. map_c_height = min(map_c_height, MapCellHeight);
  821. #endif
  822. #else
  823. map_c_width = min(map_c_width, 62 * RESFACTOR);
  824. map_c_width = min(map_c_width, MapCellWidth);
  825. map_c_height = min(map_c_height, 62 * RESFACTOR);
  826. map_c_height = min(map_c_height, MapCellHeight);
  827. #endif
  828. /*
  829. ** Find the amount of remainder because this will let us calculate
  830. ** how to center the thing.
  831. */
  832. int rem_x = RadIWidth - (map_c_width * ZoomFactor);
  833. int rem_y = RadIHeight - (map_c_height * ZoomFactor);
  834. /*
  835. ** Finally mark the map so it shows just as much as it is supposed
  836. ** to.
  837. */
  838. BaseX = rem_x / 2;
  839. BaseY = rem_y / 2;
  840. RadarCellWidth = map_c_width;
  841. RadarCellHeight = map_c_height;
  842. RadarWidth = RadIWidth - rem_x;
  843. RadarHeight = RadIHeight - rem_y;
  844. /*
  845. ** Set the radar position to the current cell.
  846. */
  847. Set_Radar_Position(cell);
  848. /*
  849. ** When zoom mode changes then we need to redraw the radar
  850. ** area.
  851. */
  852. IsToRedraw = true;
  853. /*
  854. ** Notify the map that we need to redraw a portion
  855. */
  856. Flag_To_Redraw(false);
  857. /*
  858. ** Since we have made a vast change we must redraw everything
  859. */
  860. FullRedraw = true;
  861. }
  862. /***********************************************************************************************
  863. * RadarClass::Is_Zoomable -- Determines if the map can be zoomed. *
  864. * *
  865. * This will check to see if the zoomed mode of the map would be just the same size as *
  866. * the non-zoomed mode. If this is true, then zooming would have no effect, so return *
  867. * false indicating that zooming is not allowed. *
  868. * *
  869. * INPUT: none *
  870. * *
  871. * OUTPUT: bool; Is zooming allowed? *
  872. * *
  873. * WARNINGS: none *
  874. * *
  875. * HISTORY: *
  876. * 09/16/1996 JLB : Created. *
  877. *=============================================================================================*/
  878. bool RadarClass::Is_Zoomable(void) const
  879. {
  880. int xfactor = RadIWidth / MapCellWidth;
  881. int yfactor = RadIHeight / MapCellHeight;
  882. int factor = max(min(xfactor, yfactor) , 1);
  883. if (factor == 3) {
  884. return(false);
  885. }
  886. return(true);
  887. }
  888. /***********************************************************************************************
  889. * RadarClass::Plot_Radar_Pixel -- Updates the radar map with a terrain pixel. *
  890. * *
  891. * This will update the radar map with a pixel. It is used to display *
  892. * vehicle positions on the radar map. *
  893. * *
  894. * INPUT: unit -- Pointer to unit to render at the given position. If *
  895. * NULL is passed in, then the underlying terrain is *
  896. * displayed instead. *
  897. * *
  898. * pos -- Position on the map to update. *
  899. * *
  900. * OUTPUT: none *
  901. * *
  902. * WARNINGS: This routine does NOT hide the mouse. It is up to you to *
  903. * do so. *
  904. * *
  905. * HISTORY: *
  906. * 06/04/1991 JLB : Created. *
  907. * 06/21/1991 JLB : Large blips for units & buildings. *
  908. * 02/14/1994 JLB : Revamped. *
  909. * 04/17/1995 PWG : Created. *
  910. * 04/18/1995 PWG : Created. *
  911. *=============================================================================================*/
  912. void RadarClass::Plot_Radar_Pixel(CELL cell)
  913. {
  914. if (cell == -1) cell = 1;
  915. int x,y; // Coordinate of cell location.
  916. /*
  917. ** Perform any clipping on the cell coordinate.
  918. */
  919. if (!IsRadarActive || (unsigned)cell > MAP_CELL_TOTAL) {
  920. return;
  921. }
  922. if (!In_Radar(cell) || !Cell_On_Radar(cell)) {
  923. return;
  924. }
  925. /*
  926. ** If we are zoomed in then calculate the pixel based off of the portion
  927. ** of the map the radar is viewing.
  928. */
  929. x = Cell_X(cell) - RadarX;
  930. y = Cell_Y(cell) - RadarY;
  931. if ((unsigned)x >= RadarCellWidth || (unsigned)y >= RadarCellHeight) {
  932. return;
  933. }
  934. bool usjamming = false;
  935. if (LogicPage->Lock()) {
  936. CellClass * cellptr = &(*this)[cell];
  937. x = RadX + RadOffX + BaseX + (x * ZoomFactor);
  938. y = RadY + RadOffY + BaseY + (y * ZoomFactor);
  939. /*
  940. ** Determine what (if any) vehicle or unit should be rendered in this blip.
  941. */
  942. int color=TBLACK; // Color of the pixel to plot.
  943. int housebit = (1 << PlayerPtr->Class->House);
  944. int celljammed = (*this)[cell].Jammed;
  945. int jammed = celljammed & (0xFFFF - housebit);
  946. if (!jammed && ((*this)[cell].IsMapped || Debug_Unshroud)) {
  947. // if (!jammed && ((*this)[cell].IsVisible || Debug_Unshroud)) {
  948. color = cellptr->Cell_Color(true);
  949. if ( (celljammed & housebit) && (color == TBLACK) ) {
  950. color = BLACK;//FadingWayDark[color];
  951. usjamming = true;
  952. }
  953. } else {
  954. color = BLACK;
  955. }
  956. /*
  957. ** If no color override occurs for this cell, then render the underlying
  958. ** terrain.
  959. */
  960. if (color == TBLACK) {
  961. if (ZoomFactor > 1) {
  962. void const * ptr = NULL;
  963. int icon;
  964. /*
  965. ** Fetch the template pointer and template icon number for the
  966. ** specified cell.
  967. */
  968. if (cellptr->TType != TEMPLATE_NONE && cellptr->TType != 255) {
  969. ptr = TemplateTypeClass::As_Reference(cellptr->TType).Get_Image_Data();
  970. icon = cellptr->TIcon;
  971. }
  972. /*
  973. ** If the template pointer is still NULL, then this means either a clear
  974. ** template or an illegal one. Setup for a clear template.
  975. */
  976. if (ptr == NULL) {
  977. ptr = TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1).Get_Image_Data();
  978. icon = cellptr->Clear_Icon();
  979. }
  980. IconsetClass const * iconset = (IconsetClass const *)ptr;
  981. unsigned char const * icondata = iconset->Icon_Data();
  982. /*
  983. ** Convert the logical icon number into the actual icon number.
  984. */
  985. icon &= 0x00FF;
  986. icon = *(iconset->Map_Data() + icon);
  987. unsigned char * data = (unsigned char *)icondata + icon*(24*24);
  988. Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
  989. _TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
  990. } else {
  991. // LogicPage->Fill_Rect(x, y, x+ZoomFactor-1, y+ZoomFactor-1, cellptr->Cell_Color(false));
  992. /*BG*/ LogicPage->Put_Pixel(x, y, cellptr->Cell_Color(false));
  993. }
  994. } else {
  995. LogicPage->Fill_Rect(x, y, x+ZoomFactor-1, y+ZoomFactor-1, color);
  996. ///*BG*/ LogicPage->Put_Pixel(x, y, color);
  997. }
  998. if (color != BLACK) {
  999. Render_Overlay(cell, x, y, ZoomFactor);
  1000. Render_Terrain(cell, x, y, ZoomFactor);
  1001. Render_Infantry(cell, x, y, ZoomFactor);
  1002. } else {
  1003. if(usjamming) {
  1004. Render_Infantry(cell, x, y, ZoomFactor);
  1005. }
  1006. }
  1007. LogicPage->Unlock();
  1008. }
  1009. }
  1010. /***********************************************************************************************
  1011. * RadarClass::Radar_Pixel -- Mark a cell to be rerendered on the radar map. *
  1012. * *
  1013. * This routine is used to inform the system that a pixel needs to be *
  1014. * rerendered on the radar map. The pixel(s) will be rendered the *
  1015. * next time the map is refreshed. *
  1016. * *
  1017. * INPUT: cell -- The map cell to be rerendered. *
  1018. * *
  1019. * OUTPUT: none *
  1020. * *
  1021. * WARNINGS: none *
  1022. * *
  1023. * HISTORY: *
  1024. * 07/12/1992 JLB : Created. *
  1025. * 05/08/1994 JLB : Converted to member function. *
  1026. *=============================================================================================*/
  1027. void RadarClass::Radar_Pixel(CELL cell)
  1028. {
  1029. if (IsRadarActive && Map.IsSidebarActive && Cell_On_Radar(cell)) {
  1030. IsToRedraw = true;
  1031. (*this)[cell].IsPlot = true;
  1032. if (PixelPtr < PIXELSTACK) {
  1033. PixelStack[PixelPtr++] = cell;
  1034. }
  1035. }
  1036. }
  1037. /***********************************************************************************************
  1038. * RadarClass::Click_In_Radar -- Converts a radar click into cell X and Y coordinate. *
  1039. * *
  1040. * This routine will examine the X and Y coordinate and convert them into the X and Y *
  1041. * cell coordinate value that corresponds to the location. *
  1042. * *
  1043. * INPUT: x,y -- The X and Y mouse coordinate already normalized to the radar upper left *
  1044. * corner. *
  1045. * *
  1046. * OUTPUT: Returns with success rating in addition, the X and Y values will now hold the *
  1047. * cell coordinates of the cell the pixel offsets indicated. *
  1048. * Result 1 = click was in radar region *
  1049. * Result 0 = click was outside radar region completely *
  1050. * Result-1 = click in radar area but not on clickable region of radar. *
  1051. * *
  1052. * WARNINGS: none *
  1053. * *
  1054. * HISTORY: *
  1055. * 05/30/1995 PWG : Created. *
  1056. * 07/16/1995 JLB : Recognizes when sidebar is closed now. *
  1057. *=============================================================================================*/
  1058. int RadarClass::Click_In_Radar(int &ptr_x, int &ptr_y, bool change) const
  1059. {
  1060. int x = ptr_x;
  1061. int y = ptr_y;
  1062. /*
  1063. ** If radar is not active the click could have been on a radar point
  1064. */
  1065. if (!IsRadarActive || !Map.IsSidebarActive) return(0);
  1066. x -= (RadX + RadOffX);
  1067. y -= (RadY + RadOffY);
  1068. if ((unsigned)x < RadIWidth && (unsigned)y < RadIHeight) {
  1069. x -= BaseX;
  1070. y -= BaseY;
  1071. if ((unsigned)x < RadarWidth + (ZoomFactor-1) && (unsigned)y < RadarHeight + (ZoomFactor-1)) {
  1072. // if ((unsigned)x < RadarWidth && (unsigned)y < RadarHeight) {
  1073. x = RadarX + (x / ZoomFactor);
  1074. y = RadarY + (y / ZoomFactor);
  1075. if (change) {
  1076. ptr_x = x;
  1077. ptr_y = y;
  1078. }
  1079. return(1);
  1080. }
  1081. return(-1);
  1082. }
  1083. return(0);
  1084. }
  1085. /***********************************************************************************************
  1086. * RadarClass::Click_Cell_Calc -- Determines what cell the pixel coordinate is over. *
  1087. * *
  1088. * This routine will examine the pixel coordinate provided and determine what cell it *
  1089. * represents. If the radar map is not active or the coordinates are not positioned over *
  1090. * the radar map, then it will fall into the base class corresponding routine. *
  1091. * *
  1092. * INPUT: x,y -- The pixel coordinate to convert into a cell number. *
  1093. * *
  1094. * OUTPUT: Returns with the cell number that the coordinate is over or -1 if not over any *
  1095. * cell. *
  1096. * *
  1097. * WARNINGS: none *
  1098. * *
  1099. * HISTORY: *
  1100. * 12/22/1994 JLB : Created. *
  1101. *=============================================================================================*/
  1102. CELL RadarClass::Click_Cell_Calc(int x, int y) const
  1103. {
  1104. int result = Click_In_Radar(x, y, true);
  1105. switch (result) {
  1106. case 1:
  1107. return(XY_Cell(x, y));
  1108. case -1:
  1109. return(-1);
  1110. default:
  1111. break;
  1112. }
  1113. return(DisplayClass::Click_Cell_Calc(x, y));
  1114. }
  1115. /***********************************************************************************************
  1116. * RadarClass::Map_Cell -- Updates radar map when a cell becomes mapped. *
  1117. * *
  1118. * This routine will update the radar map if a cell becomes mapped. *
  1119. * *
  1120. * INPUT: cell -- The cell that is being mapped. *
  1121. * *
  1122. * house -- The house that is doing the mapping. *
  1123. * *
  1124. * OUTPUT: bool; Was the cell mapped (for the first time) by this routine? *
  1125. * *
  1126. * WARNINGS: none *
  1127. * *
  1128. * HISTORY: *
  1129. * 12/22/1994 JLB : Created. *
  1130. *=============================================================================================*/
  1131. bool RadarClass::Map_Cell(CELL cell, HouseClass * house)
  1132. {
  1133. if (DisplayClass::Map_Cell(cell, house)) {
  1134. Radar_Pixel(cell);
  1135. return(true);
  1136. }
  1137. return(false);
  1138. }
  1139. void RadarClass::Cursor_Cell(CELL cell, int value)
  1140. {
  1141. /*
  1142. ** If this cell is not on the radar don't bother doing anything.
  1143. */
  1144. if (Cell_On_Radar(cell)) {
  1145. int temp = (*this)[cell].IsRadarCursor;
  1146. if (temp != value) {
  1147. /*
  1148. ** Record the new state of this cell.
  1149. */
  1150. (*this)[cell].IsRadarCursor = value;
  1151. /*
  1152. ** If we are erasing then erase the cell.
  1153. */
  1154. if (value == FALSE) {
  1155. Plot_Radar_Pixel(cell);
  1156. }
  1157. }
  1158. }
  1159. }
  1160. void RadarClass::Mark_Radar(int x1, int y1, int x2, int y2, int value, int barlen)
  1161. {
  1162. int x, y;
  1163. /*
  1164. ** First step is to convert pixel coordinates back to a CellX and CellY.
  1165. */
  1166. x1 = RadarX + (x1 / ZoomFactor);
  1167. y1 = RadarY + (y1 / ZoomFactor);
  1168. x2 = RadarX + (x2 / ZoomFactor);
  1169. y2 = RadarY + (y2 / ZoomFactor);
  1170. /*
  1171. ** Now we need to convert the Pixel length to a cell length.
  1172. */
  1173. barlen = (barlen / ZoomFactor) + 1;
  1174. /*
  1175. ** Now lets loop through and mark the map with the proper value.
  1176. */
  1177. for (int lp = 0; lp <= barlen; lp++) {
  1178. /*
  1179. ** Do Horizontal action to upper and lower left corners.
  1180. */
  1181. x = x1 + lp;
  1182. Cursor_Cell(XY_Cell(x, y1), value);
  1183. Cursor_Cell(XY_Cell(x, y2), value);
  1184. /*
  1185. ** Do Horizontal Action to upper and lower right corners
  1186. */
  1187. x = x2 - lp;
  1188. Cursor_Cell(XY_Cell(x, y1), value);
  1189. Cursor_Cell(XY_Cell(x, y2), value);
  1190. /*
  1191. ** Do Vertical Action to left and right upper corners
  1192. */
  1193. y = y1 + lp;
  1194. Cursor_Cell(XY_Cell(x1, y), value);
  1195. Cursor_Cell(XY_Cell(x2, y), value);
  1196. /*
  1197. ** Do Vertical action to left and right lower corners.
  1198. */
  1199. y = y2 - lp;
  1200. Cursor_Cell(XY_Cell(x1, y), value);
  1201. Cursor_Cell(XY_Cell(x2, y), value);
  1202. }
  1203. }
  1204. /***********************************************************************************************
  1205. * RadarClass::Cell_XY_To_Radar_Pixel-- Adjust the position of the radar map cursor. *
  1206. * *
  1207. * This routine will adjust the location (and visibility) of the radar *
  1208. * map cursor. It handles all restoration, drawing, and flashing. *
  1209. * *
  1210. * INPUT: pos - Cell position for the cursor. If the value is -1 then *
  1211. * the cursor will be hidden. If the value is equal to *
  1212. * the last value passed in then cursor flashing will *
  1213. * be maintained. *
  1214. * *
  1215. * OUTPUT: none *
  1216. * *
  1217. * WARNINGS: none *
  1218. * *
  1219. * HISTORY: *
  1220. * 05/22/1991 JLB : Created. *
  1221. * 11/17/1995 PWG : Created. *
  1222. *=============================================================================================*/
  1223. void RadarClass::Cell_XY_To_Radar_Pixel(int cellx, int celly, int &x, int &y)
  1224. {
  1225. x = (cellx - RadarX) * ZoomFactor;
  1226. y = (celly - RadarY) * ZoomFactor;
  1227. }
  1228. /***********************************************************************************************
  1229. * RadarClass::Jam_Cell -- Updates radar map when a cell becomes jammed. *
  1230. * *
  1231. * This routine will update the radar map if a cell becomes jammed. *
  1232. * *
  1233. * INPUT: cell -- The cell that is being jammed. *
  1234. * *
  1235. * house -- The house that is doing the jamming. *
  1236. * *
  1237. * OUTPUT: *
  1238. * *
  1239. * WARNINGS: none *
  1240. * *
  1241. * HISTORY: *
  1242. * 11/09/1995 BWG : Created. *
  1243. *=============================================================================================*/
  1244. bool RadarClass::Jam_Cell(CELL cell, HouseClass * house/*KO, bool shadeit*/)
  1245. {
  1246. unsigned short jam = 1 << house->Class->House;
  1247. (*this)[cell].Jammed |= jam;
  1248. if (house != PlayerPtr) Shroud_Cell(cell/*KO, shadeit*/);
  1249. Radar_Pixel(cell);
  1250. return(true);
  1251. }
  1252. /***********************************************************************************************
  1253. * RadarClass::UnJam_Cell -- Updates radar map when a cell becomes jammed. *
  1254. * *
  1255. * This routine will update the radar map if a cell becomes jammed. *
  1256. * *
  1257. * INPUT: cell -- The cell that is being jammed. *
  1258. * *
  1259. * house -- The house that is doing the jamming. *
  1260. * *
  1261. * OUTPUT: *
  1262. * *
  1263. * WARNINGS: none *
  1264. * *
  1265. * HISTORY: *
  1266. * 11/09/1995 BWG : Created. *
  1267. *=============================================================================================*/
  1268. bool RadarClass::UnJam_Cell(CELL cell, HouseClass * house)
  1269. {
  1270. unsigned short jam = 1 << house->Class->House;
  1271. (*this)[cell].Redraw_Objects();
  1272. (*this)[cell].Jammed &= (0xFFFF - jam);
  1273. Radar_Pixel(cell);
  1274. return(true);
  1275. }
  1276. /***********************************************************************************************
  1277. * RadarClass::Radar_Cursor -- Adjust the position of the radar map cursor. *
  1278. * *
  1279. * This routine will adjust the location (and visibility) of the radar *
  1280. * map cursor. It handles all restoration, drawing, and flashing. *
  1281. * *
  1282. * INPUT: pos - Cell position for the cursor. If the value is -1 then *
  1283. * the cursor will be hidden. If the value is equal to *
  1284. * the last value passed in then cursor flashing will *
  1285. * be maintained. *
  1286. * *
  1287. * OUTPUT: none *
  1288. * *
  1289. * WARNINGS: none *
  1290. * *
  1291. * HISTORY: *
  1292. * 05/22/1991 JLB : Created. *
  1293. * 11/17/1995 PWG : Created. *
  1294. *=============================================================================================*/
  1295. #pragma argsused
  1296. void RadarClass::Radar_Cursor(int forced)
  1297. {
  1298. static _last_pos = -1;
  1299. static _last_frame = -1;
  1300. #ifdef WIN32
  1301. GraphicViewPortClass * oldpage;
  1302. #else
  1303. GraphicBufferClass * oldpage;
  1304. #endif
  1305. int x1, y1, x2, y2;
  1306. /*
  1307. ** figure out these function calls as we will need to call them multiple times.
  1308. */
  1309. int tac_cell = Coord_Cell(TacticalCoord);
  1310. int tac_cell_x = Cell_X(tac_cell);
  1311. int tac_cell_y = Cell_Y(tac_cell);
  1312. int barlen = 6;
  1313. /*
  1314. ** If the current tactical cell is invalid or we haven't moved and we are not forced to redraw then
  1315. ** just skip the redraw process.
  1316. */
  1317. if (tac_cell != -1 && _last_pos == tac_cell && _last_frame == SpecialRadarFrame && !forced) return;
  1318. if ( _last_pos != -1 ) {
  1319. /*
  1320. ** The first thing we need to do is take care of erasing the last radar cell position. We do this
  1321. ** by converting to pixel coordinates, then adjusting for the pixel coords for the current frame and
  1322. ** finally taking care of calling the erase procedure which will convert the pixel coordinates back
  1323. ** to the cells that need to be redraw.
  1324. **/
  1325. int last_cell_x = Cell_X(_last_pos);
  1326. int last_cell_y = Cell_Y(_last_pos);
  1327. Cell_XY_To_Radar_Pixel(last_cell_x, last_cell_y, x1, y1);
  1328. Cell_XY_To_Radar_Pixel(last_cell_x + Lepton_To_Cell(TacLeptonWidth), last_cell_y + Lepton_To_Cell(TacLeptonHeight), x2, y2);
  1329. x2--;
  1330. y2--;
  1331. /*
  1332. ** Adjust the current coordinates based on the last animation frame.
  1333. */
  1334. x1-= _last_frame;
  1335. y1-= _last_frame;
  1336. x2+= _last_frame;
  1337. y2+= _last_frame;
  1338. /*
  1339. ** Finally mark the map (actually remove the marks that indicate the radar cursor was there
  1340. */
  1341. Mark_Radar(x1, y1, x2, y2, FALSE, barlen);
  1342. }
  1343. /*
  1344. ** Find the upper left and lower right corners of the radar cursor.
  1345. ** Remember to adjust x2 and y2 back by one pixel as they will not be
  1346. ** pointing to the right value otherwise. They point one cell ahead
  1347. ** of where they should.
  1348. */
  1349. Cell_XY_To_Radar_Pixel(tac_cell_x, tac_cell_y, x1, y1);
  1350. Cell_XY_To_Radar_Pixel(tac_cell_x + Lepton_To_Cell(TacLeptonWidth), tac_cell_y + Lepton_To_Cell(TacLeptonHeight), x2, y2);
  1351. x2--;
  1352. y2--;
  1353. /*
  1354. ** Adjust the coordinates based on the current frame of radar animation.
  1355. */
  1356. x1-= SpecialRadarFrame;
  1357. y1-= SpecialRadarFrame;
  1358. x2+= SpecialRadarFrame;
  1359. y2+= SpecialRadarFrame;
  1360. Mark_Radar(x1, y1, x2, y2, TRUE, barlen);
  1361. /*
  1362. ** setup a graphic view port class so we can write all the pixels relative
  1363. ** to 0,0 rather than relative to full screen coordinates.
  1364. */
  1365. oldpage = Set_Logic_Page(HidPage);
  1366. GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
  1367. RadX + RadOffX + BaseX + LogicPage->Get_XPos(),
  1368. RadY + RadOffY + BaseY + LogicPage->Get_YPos(),
  1369. RadarWidth,
  1370. RadarHeight);
  1371. draw_window.Draw_Line(x1, y1, x1 + barlen, y1, LTGREEN);
  1372. draw_window.Draw_Line(x1, y1, x1, y1 + barlen, LTGREEN);
  1373. // Draw upper right hand corner
  1374. draw_window.Draw_Line(x2 - barlen, y1, x2, y1, LTGREEN);
  1375. draw_window.Draw_Line(x2, y1, x2, y1 + barlen, LTGREEN);
  1376. // Draw lower left hand corner
  1377. draw_window.Draw_Line(x1, y2 - barlen, x1, y2, LTGREEN);
  1378. draw_window.Draw_Line(x1, y2, x1 + barlen, y2, LTGREEN);
  1379. // Draw lower right hand corner
  1380. draw_window.Draw_Line(x2, y2 - barlen, x2, y2, LTGREEN);
  1381. draw_window.Draw_Line(x2 - barlen, y2, x2, y2, LTGREEN);
  1382. Set_Logic_Page(oldpage);
  1383. _last_pos = tac_cell;
  1384. _last_frame = SpecialRadarFrame;
  1385. RadarCursorRedraw = FALSE;
  1386. }
  1387. /***************************************************************************
  1388. * RadarClass::Radar_Anim -- Renders current frame of radar animation *
  1389. * *
  1390. * *
  1391. * *
  1392. * INPUT: *
  1393. * *
  1394. * OUTPUT: *
  1395. * *
  1396. * WARNINGS: *
  1397. * *
  1398. * HISTORY: *
  1399. * 04/19/1995 PWG : Created. *
  1400. *=========================================================================*/
  1401. void RadarClass::Radar_Anim(void)
  1402. {
  1403. /*
  1404. ** Do nothing if we're in player-name mode
  1405. */
  1406. if (IsPlayerNames)
  1407. return;
  1408. if (!Map.IsSidebarActive) return;
  1409. #ifdef WIN32
  1410. GraphicViewPortClass * oldpage= Set_Logic_Page(HidPage);
  1411. GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
  1412. RadX + RadOffX + LogicPage->Get_XPos(),
  1413. RadY + RadOffY + LogicPage->Get_YPos(),
  1414. RadIWidth,
  1415. RadIHeight);
  1416. #else
  1417. GraphicBufferClass * oldpage= Set_Logic_Page(HidPage);
  1418. GraphicViewPortClass draw_window(LogicPage,
  1419. RadX + RadOffX,
  1420. RadY + RadOffY,
  1421. RadIWidth,
  1422. RadIHeight-2);
  1423. #endif
  1424. //Mono_Set_Cursor(0,0);
  1425. #ifdef WIN32
  1426. Draw_Box(RadX+RadOffX-1, RadY+RadOffY-1, RadIWidth+2, RadIHeight+2, BOXSTYLE_RAISED, true);
  1427. #endif
  1428. draw_window.Clear();
  1429. CC_Draw_Shape(RadarAnim, RadarAnimFrame, RadX, RadY+1*RESFACTOR, WINDOW_MAIN, SHAPE_NORMAL);
  1430. Flag_To_Redraw(false);
  1431. Set_Logic_Page(oldpage);
  1432. }
  1433. /***********************************************************************************************
  1434. * RadarClass::AI -- Processes radar input (non-tactical). *
  1435. * *
  1436. * This routine intercepts any player input that concerns the radar map, but not those *
  1437. * areas that represent the tactical map. These are handled by the tactical map AI *
  1438. * processor. Primarily, this routine handles the little buttons that border the radar *
  1439. * map. *
  1440. * *
  1441. * INPUT: input -- The player input code. *
  1442. * *
  1443. * x,y -- Mouse coordinate parameters to use. *
  1444. * *
  1445. * OUTPUT: none *
  1446. * *
  1447. * WARNINGS: none *
  1448. * *
  1449. * HISTORY: *
  1450. * 12/23/1994 JLB : Created. *
  1451. * 12/26/1994 JLB : Moves tactical map with click or drag. *
  1452. * 12/31/1994 JLB : Uses mouse coordinate parameters. *
  1453. *=============================================================================================*/
  1454. void RadarClass::AI(KeyNumType & input, int x, int y)
  1455. {
  1456. /*
  1457. ** Check to see if we need to animate the radar cursor
  1458. */
  1459. if (IsRadarActive && Map.IsSidebarActive && SpecialRadarFrame) {
  1460. SpecialRadarFrame--;
  1461. RadarCursorRedraw = TRUE;
  1462. IsToRedraw = TRUE;
  1463. Flag_To_Redraw(FALSE);
  1464. }
  1465. /*
  1466. ** Check goes here to see if there is enough power to run the radar
  1467. */
  1468. if (IsRadarActivating) {
  1469. if (!DoesRadarExist) {
  1470. RadarAnimFrame++;
  1471. if (RadarAnimFrame < RADAR_ACTIVATED_FRAME) {
  1472. IsToRedraw = true;
  1473. Flag_To_Redraw(false);
  1474. } else {
  1475. DoesRadarExist = true;
  1476. Radar_Activate(3);
  1477. }
  1478. } else {
  1479. RadarAnimFrame--;
  1480. if (RadarAnimFrame > RADAR_ACTIVATED_FRAME) {
  1481. IsToRedraw = true;
  1482. Flag_To_Redraw(false);
  1483. } else {
  1484. Radar_Activate(3);
  1485. }
  1486. }
  1487. }
  1488. /*
  1489. ** Check goes here to see if there is enough power to run the radar
  1490. */
  1491. if (IsRadarDeactivating) {
  1492. RadarAnimFrame++;
  1493. if (RadarAnimFrame == MAX_RADAR_FRAMES) {
  1494. IsRadarDeactivating = false;
  1495. } else {
  1496. IsToRedraw = true;
  1497. Flag_To_Redraw(false);
  1498. }
  1499. }
  1500. /*
  1501. ** Check here to see if radar is being jammed, so we can update the
  1502. ** animation with snow.
  1503. */
  1504. if (!IsRadarActivating && !IsRadarDeactivating && IsRadarJammed) {
  1505. RadarAnimFrame++;
  1506. if (RadarAnimFrame < RADAR_ACTIVATED_FRAME) RadarAnimFrame = RADAR_ACTIVATED_FRAME;
  1507. if (RadarAnimFrame > (3 + RADAR_ACTIVATED_FRAME)) RadarAnimFrame = RADAR_ACTIVATED_FRAME;
  1508. IsToRedraw = true;
  1509. Flag_To_Redraw(false);
  1510. }
  1511. /*
  1512. ** Check here to see if the sonar pulse is active, and if it is, flag the
  1513. ** radar to redraw so the pulse ping will display.
  1514. */
  1515. if (IsPulseActive) {
  1516. Flag_To_Redraw(true);
  1517. IsToRedraw = true;
  1518. if (RadarPulseFrame >= 8) {
  1519. RadarPulseFrame = 0;
  1520. IsPulseActive = false;
  1521. }
  1522. }
  1523. DisplayClass::AI(input, x, y);
  1524. }
  1525. /***********************************************************************************************
  1526. * RadarClass::RTacticalClass::Action -- I/O function for the radar map. *
  1527. * *
  1528. * This is the main action function for handling player I/O on the radar map. It processes *
  1529. * mouse clicks as well as mouse moves. *
  1530. * *
  1531. * INPUT: flags -- The event flags that trigger this function call. *
  1532. * *
  1533. * key -- Reference the keyboard event that applies to the trigger event. *
  1534. * *
  1535. * OUTPUT: Should further processing of the input list be aborted? *
  1536. * *
  1537. * WARNINGS: none *
  1538. * *
  1539. * HISTORY: *
  1540. * 05/08/1995 JLB : Created. *
  1541. *=============================================================================================*/
  1542. int RadarClass::RTacticalClass::Action(unsigned flags, KeyNumType & key)
  1543. {
  1544. CELL cell; // cell num click happened over
  1545. int x,y; // Sub cell pixel coordinates.
  1546. int cellx,celly; // Sub cell pixel coordinates.
  1547. bool shadow; // is the cell in shadow or not
  1548. ObjectClass * object = 0; // what object is in the cell
  1549. ActionType action = ACTION_NONE; // Action possible with currently selected object.
  1550. /*
  1551. ** Force any help label to disappear when the mouse is held over the
  1552. ** radar map.
  1553. */
  1554. if (Map.IsSidebarActive) {
  1555. Map.Help_Text(TXT_NONE);
  1556. }
  1557. if (!Map.IsRadarActive) {
  1558. if (Map.IsSidebarActive) {
  1559. Map.Override_Mouse_Shape(MOUSE_NORMAL);
  1560. // Map.Override_Mouse_Shape(MOUSE_NORMAL, true);
  1561. }
  1562. return(false);
  1563. }
  1564. /*
  1565. ** Disable processing if the player names are up
  1566. */
  1567. if (Map.Is_Player_Names()) {
  1568. GadgetClass::Action(0, key);
  1569. return(true);
  1570. }
  1571. /*
  1572. ** Set some working variables that depend on the mouse position. For the press
  1573. ** or release event, special mouse queuing storage variables are used. Other
  1574. ** events must use the current mouse position globals.
  1575. */
  1576. if (flags & (LEFTPRESS|LEFTRELEASE|RIGHTPRESS|RIGHTRELEASE)) {
  1577. x = Keyboard->MouseQX;
  1578. y = Keyboard->MouseQY;
  1579. } else {
  1580. x = Get_Mouse_X();
  1581. y = Get_Mouse_Y();
  1582. }
  1583. /*
  1584. ** See if the mouse is over the radar general area, but not yet
  1585. ** over the active region of the radar map. In such a case, the
  1586. ** mouse is overridden to be the normal cursor and no other
  1587. ** action is performed.
  1588. */
  1589. if (x < Map.RadX+Map.RadOffX || x >= Map.RadX+Map.RadIWidth || y < Map.RadY+Map.RadOffY || y >= Map.RadY+Map.RadIHeight) {
  1590. Map.Override_Mouse_Shape(MOUSE_NORMAL);
  1591. return(false);
  1592. }
  1593. int result = Map.RadarClass::Click_In_Radar(x, y, false);
  1594. if (result == 1) {
  1595. cell = Map.RadarClass::Click_Cell_Calc(x, y);
  1596. if (cell != -1 && Map.In_Radar(cell)) {
  1597. shadow = (!Map[cell].IsMapped && !Debug_Unshroud);
  1598. // shadow = (!Map[cell].IsVisible && !Debug_Unshroud);
  1599. cellx = 12;
  1600. celly = 12;
  1601. /*
  1602. ** Determine the object that the mouse is currently over.
  1603. */
  1604. if (!shadow) {
  1605. object = Map.Cell_Object(cell, cellx, celly);
  1606. }
  1607. /*
  1608. ** If there is a currently selected object, then the action to perform if
  1609. ** the left mouse button were clicked must be determined.
  1610. */
  1611. if (CurrentObject.Count()) {
  1612. if (object) {
  1613. action = CurrentObject[0]->What_Action(object);
  1614. } else {
  1615. action = CurrentObject[0]->What_Action(cell);
  1616. }
  1617. /*
  1618. ** If this is not a valid radar map action then we are not going to do
  1619. ** anything.
  1620. */
  1621. switch (action) {
  1622. case ACTION_MOVE:
  1623. case ACTION_NOMOVE:
  1624. case ACTION_ATTACK:
  1625. case ACTION_ENTER:
  1626. case ACTION_CAPTURE:
  1627. case ACTION_SABOTAGE:
  1628. break;
  1629. default:
  1630. action = ACTION_NONE;
  1631. object = NULL;
  1632. break;
  1633. }
  1634. /*
  1635. ** On the radar map the only reason we would want the normal cursor to
  1636. ** appear is if we were over one of our own selected units. Otherwise
  1637. ** we can't move there.
  1638. **/
  1639. if (action == ACTION_NONE) {
  1640. if (object && object->IsSelected) {
  1641. object = NULL;
  1642. } else {
  1643. action = ACTION_NOMOVE;
  1644. }
  1645. }
  1646. /*
  1647. ** A right mouse button press toggles the zoom mode.
  1648. */
  1649. if (flags & RIGHTPRESS) {
  1650. Map.Mouse_Right_Press();
  1651. }
  1652. /*
  1653. ** When the mouse buttons aren't pressed, only the mouse cursor shape is processed.
  1654. ** The shape changes depending on what object the mouse is currently over and what
  1655. ** object is currently selected.
  1656. */
  1657. if (flags & LEFTUP) {
  1658. Map.Mouse_Left_Up(-1, shadow, object, action, true);
  1659. }
  1660. /*
  1661. ** Normal actions occur when the mouse button is released. The press event is
  1662. ** intercepted and possible rubber-band mode is flagged.
  1663. */
  1664. if (flags & LEFTPRESS) {
  1665. Map.Mouse_Left_Release(cell, cellx, celly, object, action, true);
  1666. }
  1667. } else {
  1668. Map.Set_Default_Mouse(MOUSE_RADAR_CURSOR, !Map.IsZoomed);
  1669. if (flags & LEFTPRESS) {
  1670. cell = Map.RadarClass::Click_Cell_Calc(x, y);
  1671. if (cell != -1) {
  1672. int cellx = Cell_X(cell);
  1673. int celly = Cell_Y(cell);
  1674. cellx -= Lepton_To_Cell(Map.TacLeptonWidth) / 2;
  1675. cellx = max(cellx, Map.MapCellX);
  1676. celly -= Lepton_To_Cell(Map.TacLeptonHeight) / 2;
  1677. celly = max(celly, Map.MapCellY);
  1678. cell = XY_Cell(cellx, celly);
  1679. shadow = (!Map[cell].IsMapped && !Debug_Unshroud);
  1680. // shadow = (!Map[cell].IsVisible && !Debug_Unshroud);
  1681. Map.Set_Tactical_Position(Cell_Coord(cell));
  1682. cell = Coord_Cell(Map.DesiredTacticalCoord);
  1683. Map.DisplayClass::IsToRedraw = true;
  1684. Map.Flag_To_Redraw(true);
  1685. Map.SpecialRadarFrame = 4;
  1686. }
  1687. }
  1688. /*
  1689. ** A right mouse button press toggles the zoom mode.
  1690. */
  1691. if (flags & RIGHTPRESS) {
  1692. Map.Zoom_Mode(cell);
  1693. }
  1694. }
  1695. }
  1696. }
  1697. if (result == -1) {
  1698. Map.Override_Mouse_Shape(MOUSE_NORMAL, true);
  1699. }
  1700. GadgetClass::Action(0, key);
  1701. return(true);
  1702. }
  1703. /***********************************************************************************************
  1704. * RadarClass::Refresh_Cells -- Intercepts refresh request and updates radar if needed *
  1705. * *
  1706. * This routine intercepts the refresh cells request and if it detects that the sidebar *
  1707. * should be rerendered, it flags the radar map to redraw during the next draw operation. *
  1708. * *
  1709. * INPUT: cell -- The origin cell that the refresh cell offset list is based upon. *
  1710. * *
  1711. * list -- Pointer to the list of offsets from the origin cell that specifies the *
  1712. * cells to be flagged for redraw. If the list starts with the special *
  1713. * code to refresh the sidebar, then this routine recognizes it and flags *
  1714. * the radar map to be redrawn accordingly. *
  1715. * *
  1716. * OUTPUT: none *
  1717. * *
  1718. * WARNINGS: none *
  1719. * *
  1720. * HISTORY: *
  1721. * 01/01/1995 JLB : Created. *
  1722. *=============================================================================================*/
  1723. void RadarClass::Refresh_Cells(CELL cell, short const * list)
  1724. {
  1725. if (*list == REFRESH_SIDEBAR) {
  1726. IsToRedraw = true;
  1727. Flag_To_Redraw(false);
  1728. }
  1729. DisplayClass::Refresh_Cells(cell, list);
  1730. }
  1731. /***********************************************************************************************
  1732. * RadarClass::Set_Radar_Position -- Sets the radar position to center around specified cell. *
  1733. * *
  1734. * This routine will try to center the radar map around the cell position specified. *
  1735. * *
  1736. * INPUT: cell -- The cell to try and position the radar map around. *
  1737. * *
  1738. * OUTPUT: none *
  1739. * *
  1740. * WARNINGS: none *
  1741. * *
  1742. * HISTORY: *
  1743. * 05/08/1995 JLB : Created. *
  1744. *=============================================================================================*/
  1745. void RadarClass::Set_Radar_Position(CELL cell)
  1746. {
  1747. #ifdef WIN32
  1748. int oldx, oldy;
  1749. int newx, newy;
  1750. int newcell;
  1751. if (ZoomFactor != 1) {
  1752. oldx = (Cell_X(cell) - MapCellX);
  1753. oldy = (Cell_Y(cell) - MapCellY);
  1754. } else {
  1755. oldx = 0;
  1756. oldy = 0;
  1757. }
  1758. Confine_Rect(&oldx, &oldy, RadarCellWidth, RadarCellHeight, MapCellWidth, MapCellHeight);
  1759. newx = oldx + MapCellX;
  1760. newy = oldy + MapCellY;
  1761. newcell = XY_Cell(newx, newy);
  1762. if (RadarCell != newcell) {
  1763. int forced = FALSE;
  1764. int xmod = newx;
  1765. int ymod = newy;
  1766. int radx = (Cell_X(RadarCell)) - xmod;
  1767. int rady = (Cell_Y(RadarCell)) - ymod;
  1768. RadarX = newx;
  1769. RadarY = newy;
  1770. RadarCell = newcell;
  1771. if (Map.IsSidebarActive && Map.IsRadarActive) {
  1772. int radw = RadarCellWidth-ABS(radx); // Replicable width.
  1773. int radh = RadarCellHeight-ABS(rady); // Replicable height.
  1774. if (radw < 1) forced = true;
  1775. if (radh < 1) forced = true;
  1776. if (!forced && (radw != RadarWidth || radh != RadarHeight)) {
  1777. /*
  1778. ** Blit the section that is actually overlapping.
  1779. **
  1780. ** If the video card isnt able to blit overlapped regions then we have
  1781. ** to do the blit in two stages via an intermediate buffer. The test to allow
  1782. ** overlapped blits is done in the library at the time of setting the video mode.
  1783. */
  1784. if (OverlappedVideoBlits || !HidPage.Get_IsDirectDraw()) {
  1785. /*
  1786. ** Overlapped blits are OK or we dont have a video memory hid page so blits are
  1787. ** always done in software by the library anyway.
  1788. */
  1789. HidPage.Blit(HidPage,
  1790. (((radx < 0) ? -radx : 0) * ZoomFactor) + RadX + RadOffX + BaseX,
  1791. (((rady < 0) ? -rady : 0) * ZoomFactor) + RadY + RadOffY + BaseY,
  1792. (((radx < 0) ? 0 : radx) * ZoomFactor) + RadX+ RadOffX + BaseX,
  1793. (((rady < 0) ? 0 : rady) * ZoomFactor) + RadY + RadOffY + BaseY,
  1794. radw * ZoomFactor,
  1795. radh * ZoomFactor);
  1796. } else {
  1797. /*
  1798. ** Create a temporary intermediate surface
  1799. */
  1800. GraphicBufferClass temp_surface;
  1801. temp_surface.Init((RadarWidth + 16) & 0xfffffff0,
  1802. (RadarHeight + 16) & 0xfffffff0,
  1803. NULL, 0, (GBC_Enum) GBC_VIDEOMEM);
  1804. /*
  1805. ** Do the blit in 2 stages.
  1806. */
  1807. HidPage.Blit(temp_surface,
  1808. (((radx < 0) ? -radx : 0) * ZoomFactor) + RadX + RadOffX + BaseX,
  1809. (((rady < 0) ? -rady : 0) * ZoomFactor) + RadY + RadOffY + BaseY,
  1810. 0,
  1811. 0,
  1812. RadarWidth,
  1813. RadarHeight);
  1814. temp_surface.Blit(HidPage,
  1815. 0,
  1816. 0,
  1817. (((radx < 0) ? 0 : radx) * ZoomFactor) + RadX+ RadOffX + BaseX,
  1818. (((rady < 0) ? 0 : rady) * ZoomFactor) + RadY + RadOffY + BaseY,
  1819. radw * ZoomFactor,
  1820. radh * ZoomFactor);
  1821. }
  1822. /*
  1823. ** Now we need to flag the section of the map that is going to redraw.
  1824. */
  1825. if ( radx != 0 ) {
  1826. int min;
  1827. int max;
  1828. if ( radx < 0 ) { // this mean regen the right edge
  1829. min = radw;
  1830. max = radw+ABS(radx);
  1831. } else { // this mean regen the left edge
  1832. min = 0;
  1833. max = radx;
  1834. }
  1835. for (int x = min; x < max; x++ ) {
  1836. for (int y = 0; y < RadarCellHeight; y++ ) {
  1837. Radar_Pixel(XY_Cell(newx + x, newy + y));
  1838. }
  1839. }
  1840. }
  1841. if ( newy != 0 ) {
  1842. int min;
  1843. int max;
  1844. if ( rady < 0 ) { // this mean regen the bottom edge
  1845. min = radh;
  1846. max = radh+ABS(rady);
  1847. } else { // this mean regen the top edge
  1848. min = 0;
  1849. max = rady;
  1850. }
  1851. for (int y = min; y < max; y++ ) {
  1852. for ( int x = 0; x < RadarCellWidth; x++ ) {
  1853. Radar_Pixel(XY_Cell(newx + x, newy + y));
  1854. }
  1855. }
  1856. }
  1857. }
  1858. }
  1859. RadarCursorRedraw = IsRadarActive;
  1860. IsToRedraw = IsRadarActive;
  1861. Flag_To_Redraw(false);
  1862. if (ZoomFactor > 4) {
  1863. FullRedraw = forced;
  1864. }
  1865. } else {
  1866. RadarCursorRedraw = IsRadarActive;
  1867. IsToRedraw = IsRadarActive;
  1868. Flag_To_Redraw(false);
  1869. }
  1870. #else
  1871. if (cell != RadarCell) {
  1872. int oldx = RadarX;
  1873. int oldy = RadarY;
  1874. CELL oldcell = RadarCell;
  1875. int x = Cell_X(cell);
  1876. int y = Cell_Y(cell);
  1877. /*
  1878. ** If the new radar position is not too close to the edge of the
  1879. ** current radar display, then don't bother to change the radar position.
  1880. */
  1881. if ((unsigned)(x - (RadarX+10)) > RadarCellWidth-20) {
  1882. oldx = (Cell_X(cell)-MapCellX)-RadarCellWidth/2;
  1883. } else {
  1884. oldx = Cell_X(RadarCell)-MapCellX;
  1885. }
  1886. if ((unsigned)(y - (RadarY+10)) > RadarCellHeight-20) {
  1887. oldy = (Cell_Y(cell)-MapCellY)-RadarCellHeight/2;
  1888. } else {
  1889. oldy = Cell_Y(RadarCell)-MapCellY;
  1890. }
  1891. #ifdef NEVER
  1892. if ((unsigned)(x - (RadarX+10)) > RadarWidth-20 || (unsigned)(y - (RadarY+10)) > RadarHeight-20) {
  1893. oldx = (Cell_X(cell)-MapCellX)-RadarCellWidth/2;
  1894. oldy = (Cell_Y(cell)-MapCellY)-RadarCellHeight/2;
  1895. } else {
  1896. oldx = Cell_X(RadarCell)-MapCellX;
  1897. oldy = Cell_Y(RadarCell)-MapCellY;
  1898. }
  1899. #endif
  1900. Confine_Rect(&oldx, &oldy, RadarCellWidth, RadarCellHeight, MapCellWidth, MapCellHeight);
  1901. RadarX = oldx + MapCellX;
  1902. RadarY = oldy + MapCellY;
  1903. RadarCell = XY_Cell(RadarX, RadarY);
  1904. IsToRedraw = true;
  1905. Flag_To_Redraw(false);
  1906. if (oldcell != RadarCell) {
  1907. FullRedraw = IsRadarActive;
  1908. }
  1909. }
  1910. #endif
  1911. }
  1912. /***********************************************************************************************
  1913. * RadarClass::Radar_Position -- Returns with the current position of the radar map. *
  1914. * *
  1915. * This returns the cell number of the upper left corner of the radar map. *
  1916. * *
  1917. * INPUT: none *
  1918. * *
  1919. * OUTPUT: Returns with the radar map upper left corner cell position. *
  1920. * *
  1921. * WARNINGS: none *
  1922. * *
  1923. * HISTORY: *
  1924. * 05/08/1995 JLB : Created. *
  1925. *=============================================================================================*/
  1926. CELL RadarClass::Radar_Position(void)
  1927. {
  1928. return(RadarCell);
  1929. }
  1930. /***********************************************************************************************
  1931. * RadarClass::Set_Map_Dimensions -- Sets the tactical map dimensions. *
  1932. * *
  1933. * This routine is called when the tactical map changes its dimensions. This occurs when *
  1934. * the tactical map moves and when the sidebar pops on or off. *
  1935. * *
  1936. * INPUT: x,y -- The cell coordinate of the upper left corner of the tactical map. *
  1937. * *
  1938. * w,y -- The cell width and height of the tactical map. *
  1939. * *
  1940. * OUTPUT: none *
  1941. * *
  1942. * WARNINGS: none *
  1943. * *
  1944. * HISTORY: *
  1945. * 05/08/1995 JLB : Created. *
  1946. *=============================================================================================*/
  1947. void RadarClass::Set_Map_Dimensions(int x, int y, int w, int h)
  1948. {
  1949. Set_Radar_Position(XY_Cell(x, y));
  1950. DisplayClass::Set_Map_Dimensions(x, y, w, h);
  1951. }
  1952. /***********************************************************************************************
  1953. * RadarClass::Set_Tactical_Position -- Sets the map's tactical position and adjusts radar to *
  1954. * *
  1955. * This routine is called when the tactical map is to change position. The radar map might *
  1956. * be adjusted as well by this routine. *
  1957. * *
  1958. * INPUT: coord -- The new coordinate to use for the upper left corner of the tactical *
  1959. * map. *
  1960. * *
  1961. * OUTPUT: none *
  1962. * *
  1963. * WARNINGS: none *
  1964. * *
  1965. * HISTORY: *
  1966. * 08/17/1995 JLB : Created. *
  1967. *=============================================================================================*/
  1968. void RadarClass::Set_Tactical_Position(COORDINATE coord)
  1969. {
  1970. DisplayClass::Set_Tactical_Position(coord);
  1971. Set_Radar_Position(Coord_Cell(TacticalCoord));
  1972. }
  1973. /***********************************************************************************************
  1974. * RadarClass::Cell_On_Radar -- Determines if a cell is currently visible on radar. *
  1975. * *
  1976. * This routine will examine the specified cell number and return whether it is visible *
  1977. * on the radar map. This depends on the radar map position. *
  1978. * *
  1979. * INPUT: cell -- The cell number to check. *
  1980. * *
  1981. * OUTPUT: Is the specified cell visible on the radar map currently? *
  1982. * *
  1983. * WARNINGS: none *
  1984. * *
  1985. * HISTORY: *
  1986. * 05/03/1995 JLB : Created. *
  1987. *=============================================================================================*/
  1988. bool RadarClass::Cell_On_Radar(CELL cell)
  1989. {
  1990. if ((unsigned)cell > MAP_CELL_TOTAL)
  1991. return(false);
  1992. if (!IsZoomed) {
  1993. return(true);
  1994. }
  1995. return(!(((Cell_X(cell) - RadarX) > RadarCellWidth) || ((Cell_Y(cell) - RadarY) > RadarCellHeight)));
  1996. }
  1997. /***********************************************************************************************
  1998. * RadarClass::Player_Names -- toggles the Player-Names mode of the radar map *
  1999. * *
  2000. * INPUT: *
  2001. * on true = turn on; false = turn off *
  2002. * *
  2003. * OUTPUT: *
  2004. * none. *
  2005. * *
  2006. * WARNINGS: *
  2007. * none. *
  2008. * *
  2009. * HISTORY: *
  2010. * 06/07/1995 BRR : Created. *
  2011. *=============================================================================================*/
  2012. void RadarClass::Player_Names(bool on)
  2013. {
  2014. IsPlayerNames = on;
  2015. IsToRedraw = true;
  2016. if (on) {
  2017. Flag_To_Redraw(true);
  2018. // Flag_To_Redraw(false);
  2019. } else {
  2020. Flag_To_Redraw(true); // force drawing of the plate
  2021. }
  2022. }
  2023. /***********************************************************************************************
  2024. * RadarClass::Spy_Next_House -- advances to the next house we're spying on, or returns NULL *
  2025. * *
  2026. * INPUT: *
  2027. * *
  2028. * OUTPUT: *
  2029. * 0 = no house to spy on, 1 = found house to spy on *
  2030. * *
  2031. * WARNINGS: *
  2032. * none. *
  2033. * *
  2034. * HISTORY: *
  2035. * 03/20/1996 BWG : Created. *
  2036. *=============================================================================================*/
  2037. bool RadarClass::Spy_Next_House(void)
  2038. {
  2039. bool tospy = false;
  2040. int spiedby = (1<<(PlayerPtr->Class->House));
  2041. IsPlayerNames = false;
  2042. IsToRedraw = true;
  2043. HousesType maxhouse;
  2044. HousesType firsthouse;
  2045. HousesType house;
  2046. if (Session.Type == GAME_NORMAL) {
  2047. firsthouse = HOUSE_SPAIN;
  2048. maxhouse = HOUSE_GOOD;
  2049. } else {
  2050. firsthouse = HOUSE_MULTI1;
  2051. maxhouse = HOUSE_COUNT;
  2052. }
  2053. if (IsHouseSpy) {
  2054. house = (HousesType)(SpyingOn+1);
  2055. } else {
  2056. house = firsthouse;
  2057. }
  2058. if (house < firsthouse) house = firsthouse;
  2059. while (house < maxhouse && !tospy) {
  2060. HouseClass * hptr = HouseClass::As_Pointer(house);
  2061. if (hptr && hptr->IsActive && hptr != PlayerPtr) {
  2062. if (hptr->RadarSpied & spiedby) {
  2063. tospy = true;
  2064. SpyingOn = house;
  2065. break;
  2066. }
  2067. }
  2068. house++;
  2069. }
  2070. IsHouseSpy = tospy;
  2071. Flag_To_Redraw(true); // force drawing of the plate
  2072. return(tospy);
  2073. }
  2074. /***********************************************************************************************
  2075. * Draw_House_Info -- Print house statistics on the radar map *
  2076. * *
  2077. * INPUT: *
  2078. * none. *
  2079. * *
  2080. * OUTPUT: *
  2081. * none. *
  2082. * *
  2083. * WARNINGS: *
  2084. * none. *
  2085. * *
  2086. * HISTORY: *
  2087. * 03/20/1996 BWG : Created. *
  2088. *=============================================================================================*/
  2089. bool RadarClass::Draw_House_Info(void)
  2090. {
  2091. int y;
  2092. char txt[40];
  2093. /*
  2094. ** Do nothing if the sidebar isn't there
  2095. */
  2096. if (!Map.IsSidebarActive) {
  2097. return false;
  2098. }
  2099. CC_Draw_Shape(RadarFrame, 1, RadX, RadY + 1*RESFACTOR, WINDOW_MAIN, SHAPE_NORMAL);
  2100. y = RadY + RadOffY + (2*RESFACTOR);
  2101. Map.Repair.Draw_Me(true);
  2102. Map.Upgrade.Draw_Me(true);
  2103. Map.Zoom.Draw_Me(true);
  2104. Fancy_Text_Print (TXT_SPY_INFO, RadX + RadOffX + (6 * RESFACTOR), y,
  2105. &ColorRemaps[PCOLOR_GREY], TBLACK,
  2106. TPF_6PT_GRAD | TPF_NOSHADOW);
  2107. y += 7*RESFACTOR;
  2108. HouseClass * ptr = HouseClass::As_Pointer(SpyingOn);
  2109. if (ptr && (ptr->RadarSpied & (1<<(PlayerPtr->Class->House))) ) {
  2110. PlayerColorType c_idx;
  2111. RemapControlType * color;
  2112. TextPrintType style;
  2113. c_idx = ptr->RemapColor;
  2114. color = &ColorRemaps[c_idx];
  2115. style = TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW;
  2116. /*
  2117. ** Print house's name below 'spy report'
  2118. */
  2119. txt[0] = 0;
  2120. sprintf(txt, "%s", ptr->IniName);//Text_String(ptr->Class->FullName));
  2121. // sprintf(txt, "%s", ptr->Name());//Text_String(ptr->Class->FullName));
  2122. if (strlen(txt)) {
  2123. if (strlen(txt) > 9) {
  2124. txt[9] = '.';
  2125. txt[10] = '\0';
  2126. }
  2127. Fancy_Text_Print (txt, RadX + RadOffX + (6 * RESFACTOR), y, color, BLACK, style);
  2128. } else {
  2129. strcpy(txt,"________");
  2130. }
  2131. y += (6 * RESFACTOR) + 1;
  2132. Fancy_Text_Print(TXT_BUILDNGS, RadX + RadOffX + (6 * RESFACTOR), y, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_6PT_GRAD | TPF_NOSHADOW);
  2133. y += (6 * RESFACTOR) + 1;
  2134. // count & print buildings
  2135. itoa(ptr->CurBuildings, txt, 10);
  2136. Fancy_Text_Print(txt, RadX + RadOffX + (6 * RESFACTOR), y, color, BLACK, style);
  2137. y += (6 * RESFACTOR) + 1;
  2138. Fancy_Text_Print(TXT_UNITS, RadX + RadOffX + (6 * RESFACTOR), y, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_6PT_GRAD | TPF_NOSHADOW);
  2139. y += (6 * RESFACTOR) + 1;
  2140. // count & print units
  2141. itoa(ptr->CurUnits, txt, 10);
  2142. Fancy_Text_Print(txt, RadX + RadOffX + 6 * RESFACTOR, y, color, BLACK, style);
  2143. y += (6 * RESFACTOR) + 1;
  2144. Fancy_Text_Print(TXT_INFANTRY, RadX + RadOffX + (6 * RESFACTOR), y, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_6PT_GRAD | TPF_NOSHADOW);
  2145. y += (6 * RESFACTOR) + 1;
  2146. // count & print infantry
  2147. itoa(ptr->CurInfantry, txt, 10);
  2148. Fancy_Text_Print(txt, RadX + RadOffX + (6 * RESFACTOR), y, color, BLACK, style);
  2149. #if(0)
  2150. y += (6 * RESFACTOR) + 1;
  2151. Fancy_Text_Print(TXT_AIRCRAFT, RADAR_X + RADAR_OFF_X + 6, y,
  2152. &ColorRemaps[PCOLOR_GREY], TBLACK,
  2153. TPF_6PT_GRAD | TPF_NOSHADOW);
  2154. y += (6 * RESFACTOR) + 1;
  2155. // count & print aircraft
  2156. for (i = AIRCRAFT_NONE+1, count = 0; i < AIRCRAFT_COUNT; i++) {
  2157. count += ptr->AQuantity[i];
  2158. }
  2159. itoa(count, txt, 10);
  2160. Fancy_Text_Print(txt, RadX + RadOffX, y,
  2161. color, BLACK, style);
  2162. #endif
  2163. return(true);
  2164. } else {
  2165. return(false);
  2166. }
  2167. }
  2168. /***********************************************************************************************
  2169. * Draw_Names -- draws players' names on the radar map *
  2170. * *
  2171. * INPUT: *
  2172. * none. *
  2173. * *
  2174. * OUTPUT: *
  2175. * none. *
  2176. * *
  2177. * WARNINGS: *
  2178. * none. *
  2179. * *
  2180. * HISTORY: *
  2181. * 06/07/1995 BRR : Created. *
  2182. *=============================================================================================*/
  2183. void RadarClass::Draw_Names(void)
  2184. {
  2185. PlayerColorType c_idx;
  2186. HousesType house;
  2187. HouseClass * ptr;
  2188. int y;
  2189. char txt[40];
  2190. HousesType h;
  2191. int kills;
  2192. RemapControlType * color;
  2193. TextPrintType style;
  2194. /*
  2195. ** Do nothing if the sidebar isn't there
  2196. */
  2197. if (!Map.IsSidebarActive) {
  2198. return;
  2199. }
  2200. // CC_Draw_Shape(RadarAnim, RADAR_ACTIVATED_FRAME, RADAR_X, RADAR_Y+1,
  2201. // WINDOW_MAIN, SHAPE_NORMAL);
  2202. CC_Draw_Shape(RadarFrame, 1, RadX, RadY + 1*RESFACTOR, WINDOW_MAIN, SHAPE_NORMAL);
  2203. y = RadY + RadOffY+(2*RESFACTOR);
  2204. Fancy_Text_Print (TXT_NAME_COLON, RadX + RadOffX, y, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_6PT_GRAD | TPF_NOSHADOW);
  2205. Fancy_Text_Print (TXT_KILLS_COLON, RadX + RadOffX + RadIWidth - 2, y, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_RIGHT | TPF_6PT_GRAD | TPF_NOSHADOW);
  2206. y += 6*RESFACTOR+1;
  2207. LogicPage->Draw_Line(RadX + RadOffX, y, RadX + RadOffX + RadIWidth - 1, y, LTGREY);
  2208. y += 2*RESFACTOR;
  2209. for (house = HOUSE_MULTI1; house < (HOUSE_MULTI1 + Session.MaxPlayers); house++) {
  2210. ptr = HouseClass::As_Pointer(house);
  2211. if (!ptr) continue;
  2212. /*
  2213. ** Decode this house's color
  2214. */
  2215. c_idx = ptr->RemapColor;
  2216. if (ptr->IsDefeated) {
  2217. color = &GreyScheme;
  2218. style = TPF_6PT_GRAD | TPF_NOSHADOW;
  2219. } else {
  2220. color = &ColorRemaps[c_idx];
  2221. style = TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW;
  2222. }
  2223. /*
  2224. ** Initialize our message
  2225. */
  2226. txt[0] = 0;
  2227. // sprintf(txt, "%s", ptr->Name());
  2228. sprintf(txt, "%s", ptr->IsHuman ? ptr->IniName : Text_String(TXT_COMPUTER));
  2229. if (strlen(txt) == 0) {
  2230. strcpy(txt,"________");
  2231. }
  2232. /*
  2233. ** Print the player name, and the # of kills
  2234. */
  2235. #ifdef WIN32
  2236. if (strlen(txt) > 9) {
  2237. txt[9] = '.';
  2238. txt[10] = '\0';
  2239. }
  2240. #else
  2241. if (strlen(txt) > 8) {
  2242. txt[8] = '.';
  2243. txt[9] = '\0';
  2244. }
  2245. #endif
  2246. Fancy_Text_Print (txt, RadX + RadOffX, y, color, TBLACK, style);
  2247. kills = 0;
  2248. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  2249. kills += ptr->UnitsKilled[h];
  2250. kills += ptr->BuildingsKilled[h];
  2251. }
  2252. sprintf(txt, "%2d", kills);
  2253. Fancy_Text_Print (txt, RadX + RadOffX + RadIWidth - 2, y, color, TBLACK, style | TPF_RIGHT);
  2254. y += 6*RESFACTOR+1;
  2255. }
  2256. Map.Repair.Draw_Me(true);
  2257. Map.Upgrade.Draw_Me(true);
  2258. Map.Zoom.Draw_Me(true);
  2259. }
  2260. void RadarClass::Activate_Pulse(void)
  2261. {
  2262. if (IsRadarActive || PlayerPtr->IsGPSActive) {
  2263. IsPulseActive = true;
  2264. RadarPulseFrame = 0;
  2265. }
  2266. }
  2267. /***********************************************************************************************
  2268. * RadarClass::Is_Radar_Active -- Determines if the radar map is currently being displayed. *
  2269. * *
  2270. * Determines if the radar map is currently being displayed. *
  2271. * *
  2272. * INPUT: none *
  2273. * *
  2274. * OUTPUT: bool; Is the radar map currently being displayed as active? *
  2275. * *
  2276. * WARNINGS: none *
  2277. * *
  2278. * HISTORY: *
  2279. * 08/12/1996 JLB : Created. *
  2280. *=============================================================================================*/
  2281. bool RadarClass::Is_Radar_Active(void)
  2282. {
  2283. return(IsRadarActive || PlayerPtr->IsGPSActive);
  2284. // return IsRadarActive || PlayerPtr->IsGPSActive;
  2285. }
  2286. /***********************************************************************************************
  2287. * RadarClass::Is_Radar_Existing -- Queries to see if radar map is available. *
  2288. * *
  2289. * This will determine if the radar map is available. If available, the radar will show *
  2290. * representations of terrain, units, and buildings. *
  2291. * *
  2292. * INPUT: none *
  2293. * *
  2294. * OUTPUT: bool; Is the radar map available to be displayed? *
  2295. * *
  2296. * WARNINGS: none *
  2297. * *
  2298. * HISTORY: *
  2299. * 08/12/1996 JLB : Created. *
  2300. *=============================================================================================*/
  2301. bool RadarClass::Is_Radar_Existing(void)
  2302. {
  2303. return(DoesRadarExist || PlayerPtr->IsGPSActive);
  2304. }
  2305. /***********************************************************************************************
  2306. * RadarClass::Get_Jammed -- Fetch the current radar jammed state for the player. *
  2307. * *
  2308. * This will fetch the current state of the radar jamming for the player. *
  2309. * *
  2310. * INPUT: none *
  2311. * *
  2312. * OUTPUT: bool; Is the radar currently jammed? *
  2313. * *
  2314. * WARNINGS: none *
  2315. * *
  2316. * HISTORY: *
  2317. * 08/12/1996 JLB : Created. *
  2318. *=============================================================================================*/
  2319. bool RadarClass::Get_Jammed(void)
  2320. {
  2321. if(PlayerPtr->IsGPSActive) return(false);
  2322. return(IsRadarJammed);
  2323. }
  2324. void RadarClass::Flag_Cell(CELL cell)
  2325. {
  2326. // Radar_Pixel(cell);
  2327. DisplayClass::Flag_Cell(cell);
  2328. }