diff options
Diffstat (limited to 'src/core/Radar.cpp')
-rw-r--r-- | src/core/Radar.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 2b3e6f1e..9406f1bd 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -66,9 +66,17 @@ CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = { &WeaponSprite }; +// Why this doesn't coincide with world coordinates i don't know +#define RADAR_MIN_X (-2000.0f) +#define RADAR_MIN_Y (-2000.0f) +#define RADAR_MAX_X (2000.0f) +#define RADAR_MAX_Y (2000.0f) +#define RADAR_SIZE_X (RADAR_MAX_X - RADAR_MIN_X) +#define RADAR_SIZE_Y (RADAR_MAX_Y - RADAR_MIN_Y) + #define RADAR_NUM_TILES (8) -#define RADAR_TILE_SIZE (WORLD_SIZE_X / RADAR_NUM_TILES) -static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square"); +#define RADAR_TILE_SIZE (RADAR_SIZE_X / RADAR_NUM_TILES) +static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not a square"); #define RADAR_MIN_RANGE (120.0f) #define RADAR_MAX_RANGE (350.0f) @@ -523,8 +531,8 @@ void CRadar::DrawBlips() DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); } else { #ifdef TRIANGULAR_BLIPS - CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); - CVector &blipPos = blipEntity->GetPosition(); + const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + const CVector &blipPos = blipEntity->GetPosition(); uint8 mode = BLIP_MODE_TRIANGULAR_UP; if (blipPos.z - pos.z <= 2.0f) { if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; @@ -562,8 +570,8 @@ void CRadar::DrawBlips() DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); } else { #ifdef TRIANGULAR_BLIPS - CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); - CVector &blipPos = ms_RadarTrace[blipId].m_vecPos; + const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + const CVector &blipPos = ms_RadarTrace[blipId].m_vecPos; uint8 mode = BLIP_MODE_TRIANGULAR_UP; if (blipPos.z - pos.z <= 2.0f) { if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; @@ -629,8 +637,8 @@ void CRadar::DrawBlips() else #ifdef TRIANGULAR_BLIPS { - CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); - CVector &blipPos = blipEntity->GetPosition(); + const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + const CVector &blipPos = blipEntity->GetPosition(); uint8 mode = BLIP_MODE_TRIANGULAR_UP; if (blipPos.z - pos.z <= 2.0f) { if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; @@ -678,8 +686,8 @@ void CRadar::DrawBlips() else #ifdef TRIANGULAR_BLIPS { - CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); - CVector &blipPos = ms_RadarTrace[blipId].m_vecPos; + const CVector &pos = FindPlayerCentreOfWorld_NoSniperShift(); + const CVector &blipPos = ms_RadarTrace[blipId].m_vecPos; uint8 mode = BLIP_MODE_TRIANGULAR_UP; if (blipPos.z - pos.z <= 2.0f) { if (blipPos.z - pos.z < -4.0f) mode = BLIP_MODE_TRIANGULAR_DOWN; @@ -738,8 +746,8 @@ void CRadar::DrawRadarMap() DrawRadarMask(); // top left ist (0, 0) - int x = floorf((vec2DRadarOrigin.x - WORLD_MIN_X) / RADAR_TILE_SIZE); - int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - WORLD_MIN_Y) / RADAR_TILE_SIZE); + int x = floorf((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE); + int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE); StreamRadarSections(x, y); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); @@ -1064,6 +1072,13 @@ void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size) INITSAVEBUF WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE); +#ifdef MENU_MAP + if (TargetMarkerId != -1) { + ClearBlip(TargetMarkerId); + TargetMarkerId = -1; + } +#endif + for (int i = 0; i < NUMRADARBLIPS; i++) WriteSaveBuf(buf, ms_RadarTrace[i]); @@ -1253,8 +1268,8 @@ void CRadar::StreamRadarSections(int32 x, int32 y) void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y) { - out.x = in.x - (x * RADAR_TILE_SIZE + WORLD_MIN_X); - out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + WORLD_MIN_Y)); + out.x = in.x - (x * RADAR_TILE_SIZE + RADAR_MIN_X); + out.y = -(in.y - ((RADAR_NUM_TILES - y) * RADAR_TILE_SIZE + RADAR_MIN_Y)); out.x /= RADAR_TILE_SIZE; out.y /= RADAR_TILE_SIZE; } @@ -1420,9 +1435,9 @@ CRadar::DrawYouAreHereSprite(float x, float y) if (show) { float left = x - SCREEN_SCALE_X(12.0f); - float top = y - SCREEN_SCALE_Y(2.0f); + float top = y; float right = SCREEN_SCALE_X(12.0) + x; - float bottom = y - SCREEN_SCALE_Y(26.0f); + float bottom = y - SCREEN_SCALE_Y(24.0f); CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); } MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE; |