RADAR.CPP 109 KB

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