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