From d18a55f429cd1845d5b5e97b37a2b222ac888bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 11 Oct 2020 05:25:15 +0300 Subject: SampleManager --- src/core/Frontend.cpp | 91 +++++++++++++++++++++++++++++++++++---------------- src/core/config.h | 2 -- 2 files changed, 63 insertions(+), 30 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 59649e93..63684c12 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -37,6 +37,7 @@ #include "Messages.h" #include "FileLoader.h" #include "User.h" +#include "sampman.h" // TODO(Miami): Remove that!! That was my map implementation for III, instead use MAP_ENHACEMENTS on some places #define CUSTOM_MAP @@ -376,8 +377,7 @@ CMenuManager::CMenuManager() m_bShowMouse = true; m_nHoverOption = HOVEROPTION_NOT_HOVERING; - // TODO(Miami) - // DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); + DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); m_bMenuActive = false; m_bActivateSaveMenu = false; m_bWantToLoad = false; @@ -426,9 +426,7 @@ CMenuManager::Initialise(void) DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); m_PrefsRadioStation = DMAudio.GetRadioInCar(); - - // TODO(Miami) - // DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); + DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); if (DMAudio.IsMP3RadioChannelAvailable()) { if (m_PrefsRadioStation < WILDSTYLE || m_PrefsRadioStation > USERTRACK) m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10; @@ -570,6 +568,7 @@ CMenuManager::CheckHover(int x1, int x2, int y1, int y2) m_nMousePosY > y1 && m_nMousePosY < y2; } +// --MIAMI: Done void CMenuManager::CheckSliderMovement(int value) { @@ -587,14 +586,27 @@ CMenuManager::CheckSliderMovement(int value) CRenderer::ms_lodDistScale = m_PrefsLOD; break; case MENUACTION_MUSICVOLUME: - m_PrefsMusicVolume += value * (128/32); - m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 65); - DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); + if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { + m_PrefsMusicVolume += value * (128 / 32); + m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 65); + DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); + } break; case MENUACTION_SFXVOLUME: - m_PrefsSfxVolume += value * (128/32); - m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 65); - DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); + if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { + m_PrefsSfxVolume += value * (128 / 32); + m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 65); + DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); + } + break; + case MENUACTION_MP3VOLUMEBOOST: + if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { + if (DMAudio.IsMP3RadioChannelAvailable()) { + m_PrefsMP3BoostVolume += value * (128 / 32); + m_PrefsMP3BoostVolume = clamp(m_PrefsMP3BoostVolume, 0, 65); + DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); + } + } break; case MENUACTION_MOUSESENS: TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ??? @@ -1065,20 +1077,17 @@ CMenuManager::DrawStandardMenus(bool activeScreen) else if (m_nPrefsAudio3DProviderIndex == -1) rightText = TheText.Get("FEA_ADP"); else { - char* provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex); - if (provider != NULL) { - if (!strcmp(strupr(provider), "DIRECTSOUND3D HARDWARE SUPPORT")) { - strcpy(provider, "DSOUND3D HARDWARE SUPPORT"); - } - else if (!strcmp(strupr(provider), "DIRECTSOUND3D SOFTWARE EMULATION")) { - strcpy(provider, "DSOUND3D SOFTWARE EMULATION"); - } - AsciiToUnicode(provider, unicodeTemp); - rightText = unicodeTemp; - } - else { - rightText = TheText.Get("not defined"); + char *rawProvider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex); + AsciiToUnicode(rawProvider, unicodeTemp); + char *provider = UnicodeToAscii(unicodeTemp); // genius + strupr(provider); + if (!strcmp(provider, "DIRECTSOUND3D HARDWARE SUPPORT")) { + strcpy(provider, "DSOUND3D HARDWARE SUPPORT"); + } else if (!strcmp(provider, "DIRECTSOUND3D SOFTWARE EMULATION")) { + strcpy(provider, "DSOUND3D SOFTWARE EMULATION"); } + AsciiToUnicode(provider, unicodeTemp); + rightText = unicodeTemp; } break; case MENUACTION_SPEAKERCONF: { @@ -4007,6 +4016,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u if (selectedProvider != NO_AUDIO_PROVIDER) { if (selectedProvider == -1) selectedProvider = m_nPrefsAudio3DProviderIndex = DMAudio.AutoDetect3DProviders(); + m_nPrefsAudio3DProviderIndex = DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); if (selectedProvider != m_nPrefsAudio3DProviderIndex) { SetHelperText(5); @@ -4039,7 +4049,7 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u m_PrefsMP3BoostVolume = 0; m_PrefsStereoMono = 1; m_PrefsSpeakers = 0; - // DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); // TODO(Miami) + DMAudio.SetMP3BoostVolume(m_PrefsMP3BoostVolume); DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -4180,11 +4190,36 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u break; #endif case MENUACTION_AUDIOHW: - // TODO(Miami): What are the extra things in here?? - if (m_nPrefsAudio3DProviderIndex != NO_AUDIO_PROVIDER) { m_nPrefsAudio3DProviderIndex += changeAmount; - m_nPrefsAudio3DProviderIndex = clamp(m_nPrefsAudio3DProviderIndex, 0, DMAudio.GetNum3DProvidersAvailable() - 1); + + bool checkIfForbidden = true; + while (checkIfForbidden) { + checkIfForbidden = false; + + if (m_nPrefsAudio3DProviderIndex < -1) + m_nPrefsAudio3DProviderIndex = DMAudio.GetNum3DProvidersAvailable() - 1; + else if (m_nPrefsAudio3DProviderIndex > DMAudio.GetNum3DProvidersAvailable() - 1) + m_nPrefsAudio3DProviderIndex = -1; + + // what a retarded move... + if (m_nPrefsAudio3DProviderIndex != -1) { + char* provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex); + strupr(provider); + if (!strcmp(provider, "MILES FAST 2D POSITIONAL AUDIO")) { + m_nPrefsAudio3DProviderIndex += changeAmount; + checkIfForbidden = true; + + } else if (!strcmp(provider, "AUREAL A3D 2.0 (TM)")) { + m_nPrefsAudio3DProviderIndex += changeAmount; + checkIfForbidden = true; + + } else if (!strcmp(provider, "AUREAL A3D INTERACTIVE (TM)")) { + m_nPrefsAudio3DProviderIndex += changeAmount; + checkIfForbidden = true; + } + } + } } break; case MENUACTION_SPEAKERCONF: diff --git a/src/core/config.h b/src/core/config.h index f85232ed..57978950 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -314,9 +314,7 @@ enum Config { #define FREE_CAM // Rotating cam // Audio -#ifndef AUDIO_OAL // is not working yet for openal #define AUDIO_CACHE // cache sound lengths to speed up the cold boot -#endif //#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS -- cgit v1.2.3 From be6b97b5d8fe253b6cca1c26214bfdc7d55bf42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 12 Oct 2020 20:30:49 +0300 Subject: Streaming and cross-platform fixes --- src/core/CdStreamPosix.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index a6ab62bc..fdc63a05 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -240,9 +240,8 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size) CdReadInfo *pChannel = &gpReadInfo[channel]; ASSERT( pChannel != nil ); - if ( pChannel->nSectorsToRead != 0 || pChannel->bReading ) { - if (pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size) + if (pChannel->hFile == hImage - 1 && pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size) return STREAM_SUCCESS; flushStream[channel] = 1; @@ -293,7 +292,6 @@ CdStreamGetStatus(int32 channel) if ( pChannel->nStatus != STREAM_NONE ) { int32 status = pChannel->nStatus; - pChannel->nStatus = STREAM_NONE; return status; @@ -322,15 +320,16 @@ CdStreamSync(int32 channel) pthread_kill(pChannel->pChannelThread, SIGUSR1); if (pChannel->bReading) { pChannel->bLocked = true; - sem_wait(pChannel->pDoneSemaphore); + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } #else pChannel->nSectorsToRead = 0; if (pChannel->bReading) { pChannel->bLocked = true; pthread_kill(_gCdStreamThread, SIGUSR1); - sem_wait(pChannel->pDoneSemaphore); - + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } #endif pChannel->bReading = false; @@ -341,8 +340,8 @@ CdStreamSync(int32 channel) if ( pChannel->nSectorsToRead != 0 ) { pChannel->bLocked = true; - - sem_wait(pChannel->pDoneSemaphore); + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } pChannel->bReading = false; @@ -443,9 +442,9 @@ void *CdStreamThread(void *param) #endif pChannel->nSectorsToRead = 0; - if ( pChannel->bLocked ) { + pChannel->bLocked = 0; sem_post(pChannel->pDoneSemaphore); } pChannel->bReading = false; -- cgit v1.2.3 From 3772be32bfeaee65de4ca1464786caa50ed30861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 12 Oct 2020 20:30:49 +0300 Subject: Streaming and cross-platform fixes --- src/core/CdStreamPosix.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index a6ab62bc..fdc63a05 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -240,9 +240,8 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size) CdReadInfo *pChannel = &gpReadInfo[channel]; ASSERT( pChannel != nil ); - if ( pChannel->nSectorsToRead != 0 || pChannel->bReading ) { - if (pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size) + if (pChannel->hFile == hImage - 1 && pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size) return STREAM_SUCCESS; flushStream[channel] = 1; @@ -293,7 +292,6 @@ CdStreamGetStatus(int32 channel) if ( pChannel->nStatus != STREAM_NONE ) { int32 status = pChannel->nStatus; - pChannel->nStatus = STREAM_NONE; return status; @@ -322,15 +320,16 @@ CdStreamSync(int32 channel) pthread_kill(pChannel->pChannelThread, SIGUSR1); if (pChannel->bReading) { pChannel->bLocked = true; - sem_wait(pChannel->pDoneSemaphore); + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } #else pChannel->nSectorsToRead = 0; if (pChannel->bReading) { pChannel->bLocked = true; pthread_kill(_gCdStreamThread, SIGUSR1); - sem_wait(pChannel->pDoneSemaphore); - + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } #endif pChannel->bReading = false; @@ -341,8 +340,8 @@ CdStreamSync(int32 channel) if ( pChannel->nSectorsToRead != 0 ) { pChannel->bLocked = true; - - sem_wait(pChannel->pDoneSemaphore); + while (pChannel->bLocked) + sem_wait(pChannel->pDoneSemaphore); } pChannel->bReading = false; @@ -443,9 +442,9 @@ void *CdStreamThread(void *param) #endif pChannel->nSectorsToRead = 0; - if ( pChannel->bLocked ) { + pChannel->bLocked = 0; sem_post(pChannel->pDoneSemaphore); } pChannel->bReading = false; -- cgit v1.2.3 From 6450fd269232a1b60adaecf37a401c4f39ff1956 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 12 Oct 2020 22:54:46 +0300 Subject: Fix zone saving on 64 bit --- src/core/Zones.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 288b975e..45fe6fff 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -633,14 +633,17 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size) INITSAVEBUF int i; +#define CZONE_SAVE_SIZE (sizeof(char)*8+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(float)+sizeof(eZoneType)+sizeof(eLevelName)+sizeof(int16)+sizeof(int16)+sizeof(int32)+sizeof(int32)+sizeof(int32)) + *size = SAVE_HEADER_SIZE + sizeof(m_CurrLevel) + sizeof(FindIndex) + sizeof(int16) // padding - + sizeof(NavigationZoneArray) + sizeof(InfoZoneArray) + sizeof(ZoneInfoArray) + + CZONE_SAVE_SIZE * ARRAY_SIZE(NavigationZoneArray) + CZONE_SAVE_SIZE * ARRAY_SIZE(InfoZoneArray) + sizeof(ZoneInfoArray) + sizeof(TotalNumberOfNavigationZones) + sizeof(TotalNumberOfInfoZones) + sizeof(TotalNumberOfZoneInfos) + sizeof(int16) // padding - + sizeof(MapZoneArray) + sizeof(AudioZoneArray) + + CZONE_SAVE_SIZE * ARRAY_SIZE(MapZoneArray) + sizeof(AudioZoneArray) + sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones); +#undef CZONE_SAVE_SIZE uint32 length = 0; WriteSaveHeaderWithLength(buffer, length, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE); -- cgit v1.2.3 From 3b40e003abd2dbc7a783615ff168731b0c56584c Mon Sep 17 00:00:00 2001 From: shfil Date: Mon, 12 Oct 2020 22:51:49 +0200 Subject: Fix typo in fire.cpp --- src/core/Fire.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 5b57cb73..a47ca3cf 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -406,8 +406,8 @@ CFireManager::ExtinguishPointWithWater(CVector point, float range) CFire *fireToExtinguish = &m_aFires[fireI]; fireToExtinguish->m_fWaterExtinguishCountdown -= 0.012f * CTimer::GetTimeStep(); CVector steamPos = fireToExtinguish->m_vecPos + - CVector((CGeneral::GetRandomNumber() - 128) * 31.f / 200.f, - (CGeneral::GetRandomNumber() - 128) * 31.f / 200.f, + CVector((CGeneral::GetRandomNumber() - 128) * 3.1f / 200.f, + (CGeneral::GetRandomNumber() - 128) * 3.1f / 200.f, CGeneral::GetRandomNumber() / 200.f); CParticle::AddParticle(PARTICLE_STEAM_NY_SLOWMOTION, steamPos, CVector(0.f, 0.f, 0.2f), nil, 0.5f); -- cgit v1.2.3 From b98864d134b747c8f594c9194918b93040f88c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 14 Oct 2020 18:07:05 +0300 Subject: Radar, WaterCannon, win/glfw skels --- src/core/Frontend.cpp | 57 +++- src/core/Radar.cpp | 756 +++++++++++++++++++++++++++++++------------------- src/core/Radar.h | 46 ++- src/core/config.h | 2 - 4 files changed, 561 insertions(+), 300 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 63684c12..4eda2301 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -4578,19 +4578,13 @@ CMenuManager::UnloadTextures() CUserDisplay::PlaceName.ProcessAfterFrontEndShutDown(); } +// --MIAMI: Done void CMenuManager::WaitForUserCD() { CSprite2d *splash; char *splashscreen = nil; -#if (!(defined RANDOMSPLASH) && !(defined GTA3_1_1_PATCH)) - if (CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) - splashscreen = "mainsc2"; - else - splashscreen = "mainsc1"; -#endif - splash = LoadSplash(splashscreen); if (RsGlobal.quit) @@ -4742,6 +4736,53 @@ CMenuManager::PrintMap(void) } CRadar::DrawBlips(); + if (m_PrefsShowLegends) { + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(40.0f)); + CFont::SetRightJustifyWrap(SCREEN_SCALE_X(84.0f)); + CFont::SetBackGroundOnlyTextOff(); + CFont::SetColor(CRGBA(255, 150, 225, FadeIn(255))); + CFont::SetDropShadowPosition(2); + CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetCentreOn(); + CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); + CFont::SetScale(SCREEN_SCALE_X(0.65f), SCREEN_SCALE_Y(0.95f)); + + int secondColumnStart = (CRadar::MapLegendCounter - 1) / 2; + int boxBottom = MENU_Y(100.0f); + + // + 3, because we want 19*3 px padding + for (int i = 0; i < secondColumnStart + 3; i++) { + boxBottom += MENU_Y(19.f); + } + + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(95.0f), MENU_Y(100.0f), MENU_X_LEFT_ALIGNED(555.f), boxBottom), + CRGBA(0, 0, 0, FadeIn(190))); + + CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), MENU_Y(102.0f), TheText.Get("FE_MLG")); + CFont::SetRightJustifyOff(); + CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); + if (m_PrefsLanguage == LANGUAGE_AMERICAN) + CFont::SetScale(SCREEN_SCALE_X(0.55f), SCREEN_SCALE_Y(0.55f)); + else + CFont::SetScale(SCREEN_SCALE_X(0.45f), SCREEN_SCALE_Y(0.55f)); + + CFont::SetColor(CRGBA(225, 225, 225, FadeIn(255))); + CFont::SetDropShadowPosition(0); + + int y = MENU_Y(127.0f); + int x = MENU_X_LEFT_ALIGNED(160.0f); + + for (int16 i = 0; i < CRadar::MapLegendCounter; i++) { + CRadar::DrawLegend(x, y, CRadar::MapLegendList[i]); + + if (i == secondColumnStart) { + x = MENU_X_LEFT_ALIGNED(350.0f); + y = MENU_Y(127.0f); + } else { + y += MENU_Y(19.0f); + } + } + } #ifdef CUSTOM_MAP CVector2D mapPoint; @@ -4820,7 +4861,7 @@ CMenuManager::PrintMap(void) #endif m_bMenuMapActive = false; - CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(5.0f)); + CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(10.0f)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(10.0f)); DisplayHelperText("FEH_MPH"); } diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 5317040f..78166252 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -15,6 +15,9 @@ #include "World.h" #include "Streaming.h" #include "SpecialFX.h" +#include "Font.h" + +// --MIAMI: file done float CRadar::m_radarRange; sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS]; @@ -123,7 +126,7 @@ static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not CRGBA CRadar::ArrowBlipColour1; CRGBA CRadar::ArrowBlipColour2; -uint16 CRadar::MapLegendCounter; +int16 CRadar::MapLegendCounter; int16 CRadar::MapLegendList[NUM_MAP_LEGENDS]; #ifdef MAP_ENHANCEMENTS int CRadar::TargetMarkerId = -1; @@ -153,7 +156,7 @@ void RequestMapSection(int32 x, int32 y) void RemoveMapSection(int32 x, int32 y) { - if (x >= 0 && x <= 7 && y >= 0 && y <= 7) + if (x >= 0 && x <= RADAR_NUM_TILES - 1 && y >= 0 && y <= RADAR_NUM_TILES - 1) CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]); } @@ -260,7 +263,6 @@ int LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVector2D & return edge; } - uint8 CRadar::CalculateBlipAlpha(float dist) { if (FrontEndMenuManager.m_bMenuMapActive) @@ -269,7 +271,7 @@ uint8 CRadar::CalculateBlipAlpha(float dist) if (dist <= 1.0f) return 255; - if (dist <= 5.0f) + if (dist <= 10.0f) return (128.0f * ((dist - 1.0f) / 4.0f)) + ((1.0f - (dist - 1.0f) / 4.0f) * 255.0f); return 128; @@ -507,7 +509,6 @@ void CRadar::DrawBlips() DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255); } - CEntity *blipEntity = nil; for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { if (!ms_RadarTrace[blipId].m_bInUse) continue; @@ -516,173 +517,65 @@ void CRadar::DrawBlips() case BLIP_CAR: case BLIP_CHAR: case BLIP_OBJECT: - if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE - || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_GUN) { + if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_PROPERTY + && (!CTheScripts::bPlayerIsInTheStatium || !FrontEndMenuManager.m_bMenuMapActive)) + DrawEntityBlip(blipId); - switch (ms_RadarTrace[blipId].m_eBlipType) { - case BLIP_CAR: - blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); - break; - case BLIP_CHAR: - blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); - if (blipEntity != nil) { - if (((CPed*)blipEntity)->InVehicle()) - blipEntity = ((CPed*)blipEntity)->m_pMyVehicle; - } - break; - case BLIP_OBJECT: - blipEntity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); - break; - default: - break; - } - if (blipEntity) { - uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { - if (CTheScripts::IsDebugOn()) { - ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius); - ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; - if (ms_RadarTrace[blipId].m_Radius < 1.0f) - ms_RadarTrace[blipId].m_Radius = 5.0f; - } - } - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { - TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); - float dist = LimitRadarPoint(in); - TransformRadarPointToScreenSpace(out, in); - if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) { - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { - DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); - } - else { -#ifdef TRIANGULAR_BLIPS - 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; - else mode = BLIP_MODE_SQUARE; - } - ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); -#else - ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); -#endif - } - } - } - } - } break; case BLIP_COORD: case BLIP_CONTACT_POINT: - if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE - || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_GUN) - && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { - - uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { - if (CTheScripts::IsDebugOn()) { - ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius); - ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; - if (ms_RadarTrace[blipId].m_Radius < 1.0f) - ms_RadarTrace[blipId].m_Radius = 5.0f; - } - } - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { - TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); - float dist = LimitRadarPoint(in); - TransformRadarPointToScreenSpace(out, in); - if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) { - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { - DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); - } - else { -#ifdef TRIANGULAR_BLIPS - 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; - else mode = BLIP_MODE_SQUARE; - } - ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); -#else - ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); -#endif - } - } - } - } + if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_PHONE + && (!CTheScripts::bPlayerIsInTheStatium || !FrontEndMenuManager.m_bMenuMapActive)) + DrawCoordBlip(blipId); + break; default: break; } } + + // New in VC: Always draw Hardware/gun/pay'n spray/save blips for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { if (!ms_RadarTrace[blipId].m_bInUse) continue; + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_HARDWARE + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN) + continue; + switch (ms_RadarTrace[blipId].m_eBlipType) { case BLIP_CAR: case BLIP_CHAR: case BLIP_OBJECT: - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE - && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN) { + if (!CTheScripts::bPlayerIsInTheStatium || !FrontEndMenuManager.m_bMenuMapActive) + DrawEntityBlip(blipId); - switch (ms_RadarTrace[blipId].m_eBlipType) { - case BLIP_CAR: - blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); - break; - case BLIP_CHAR: - blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); - if (blipEntity != nil) { - if (((CPed*)blipEntity)->InVehicle()) - blipEntity = ((CPed*)blipEntity)->m_pMyVehicle; - } - break; - case BLIP_OBJECT: - blipEntity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); - break; - default: - break; - } + break; + case BLIP_COORD: + case BLIP_CONTACT_POINT: + if (!CTheScripts::bPlayerIsInTheStatium || !FrontEndMenuManager.m_bMenuMapActive) + DrawCoordBlip(blipId); + + break; + default: + break; + } + } - if (blipEntity) { - uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { - if (CTheScripts::IsDebugOn()) { - ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius); - ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; - if (ms_RadarTrace[blipId].m_Radius < 1.0f) - ms_RadarTrace[blipId].m_Radius = 5.0f; - } - } - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { - TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); - float dist = LimitRadarPoint(in); - TransformRadarPointToScreenSpace(out, in); - if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) { - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) - DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); - else -#ifdef TRIANGULAR_BLIPS - { - 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; - else mode = BLIP_MODE_SQUARE; - } - ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); - } -#else - ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); -#endif - } - } - } - } + for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { + if (!ms_RadarTrace[blipId].m_bInUse) + continue; + + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_CAR: + case BLIP_CHAR: + case BLIP_OBJECT: + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_HARDWARE + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_PROPERTY + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN + && (!CTheScripts::bPlayerIsInTheStatium || !FrontEndMenuManager.m_bMenuMapActive)) + + DrawEntityBlip(blipId); break; default: break; @@ -695,44 +588,12 @@ void CRadar::DrawBlips() switch (ms_RadarTrace[blipId].m_eBlipType) { case BLIP_COORD: case BLIP_CONTACT_POINT: - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE - && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN - && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { - - uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { - if (CTheScripts::IsDebugOn()) { - ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius); - ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; - if (ms_RadarTrace[blipId].m_Radius < 1.0f) - ms_RadarTrace[blipId].m_Radius = 5.0f; - } - } - if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { - TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); - float dist = LimitRadarPoint(in); - TransformRadarPointToScreenSpace(out, in); - if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) { - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) - DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); - else -#ifdef TRIANGULAR_BLIPS - { - 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; - else mode = BLIP_MODE_SQUARE; - } - ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); - } -#else - ShowRadarTrace(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); -#endif - } - } - } + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_HARDWARE + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_PROPERTY + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_PHONE + && (!CTheScripts::bPlayerIsInTheStatium || !FrontEndMenuManager.m_bMenuMapActive)) + + DrawCoordBlip(blipId); break; default: break; @@ -740,7 +601,12 @@ void CRadar::DrawBlips() } if (FrontEndMenuManager.m_bMenuMapActive) { CVector2D in, out; - TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift()); + if (!CTheScripts::bPlayerIsInTheStatium) + TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift()); + else + TransformRealWorldPointToRadarSpace(in, CVector2D(-1302.5f, 1332.8f)); + + LimitRadarPoint(in); TransformRadarPointToScreenSpace(out, in); DrawYouAreHereSprite(out.x, out.y); } @@ -771,8 +637,6 @@ void CRadar::DrawMap() void CRadar::DrawRadarMap() { - // Game calculates an unused CRect here - DrawRadarMask(); // top left ist (0, 0) @@ -812,14 +676,20 @@ void CRadar::DrawRadarMask() }; RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +#if !defined(GTA_PS2_STUFF) && defined(RWLIBS) + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS); +#else + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); +#endif CVector2D out[8]; CVector2D in; @@ -840,7 +710,11 @@ void CRadar::DrawRadarMask() CSprite2d::SetMaskVertices(8, (float *)out); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8); - }; + } +#if !defined(GTA_PS2_STUFF) && defined(RWLIBS) + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); +#endif + } void CRadar::DrawRadarSection(int32 x, int32 y) @@ -858,11 +732,8 @@ void CRadar::DrawRadarSection(int32 x, int32 y) GetTextureCorners(x, y, worldPoly); ClipRadarTileCoords(x, y); - assert(CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y])); - txd = CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y])->texDict; - if (txd) - texture = GetFirstTexture(txd); - if (texture == nil) + if (!CTheScripts::bPlayerIsInTheStatium && + (!(txd = CTxdStore::GetSlot(gRadarTxdIds[x + RADAR_NUM_TILES * y])->texDict) || !(texture = GetFirstTexture(txd)))) return; for (i = 0; i < 4; i++) @@ -880,8 +751,15 @@ void CRadar::DrawRadarSection(int32 x, int32 y) TransformRealWorldToTexCoordSpace(texCoords[i], worldPoly[i], x, y); TransformRadarPointToScreenSpace(screenPoly[i], radarPoly[i]); } - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(texture)); - CSprite2d::SetVertices(numVertices, (float*)screenPoly, (float*)texCoords, CRGBA(255, 255, 255, 255)); + + if (CTheScripts::bPlayerIsInTheStatium) { + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + CSprite2d::SetVertices(numVertices, (float*)screenPoly, (float*)texCoords, CRGBA(204, 204, 204, 255)); + } else { + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(texture)); + CSprite2d::SetVertices(numVertices, (float*)screenPoly, (float*)texCoords, CRGBA(255, 255, 255, 255)); + } + // check done above now // if(numVertices > 2) RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), numVertices); @@ -907,28 +785,17 @@ void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha) void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha) { CVector curPosn[4]; - CVector oldPosn[4]; - - curPosn[0].x = x - SCREEN_SCALE_X(5.6f); - curPosn[0].y = y + SCREEN_SCALE_Y(5.6f); - - curPosn[1].x = x + SCREEN_SCALE_X(5.6f); - curPosn[1].y = y + SCREEN_SCALE_Y(5.6f); - - curPosn[2].x = x - SCREEN_SCALE_X(5.6f); - curPosn[2].y = y - SCREEN_SCALE_Y(5.6f); - - curPosn[3].x = x + SCREEN_SCALE_X(5.6f); - curPosn[3].y = y - SCREEN_SCALE_Y(5.6f); + const float sizeX = SCREEN_SCALE_X(8.0f); + const float correctedAngle = angle - PI / 4.f; + const float sizeY = SCREEN_SCALE_Y(8.0f); for (uint32 i = 0; i < 4; i++) { - oldPosn[i] = curPosn[i]; - - curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle); - curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle); + const float cornerAngle = i * HALFPI + correctedAngle; + curPosn[i].x = x + (0.0f * Cos(cornerAngle) + 1.0f * Sin(cornerAngle)) * sizeX; + curPosn[i].y = y - (0.0f * Sin(cornerAngle) - 1.0f * Cos(cornerAngle)) * sizeY; } - sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha)); + sprite->Draw(curPosn[3].x, curPosn[3].y, curPosn[2].x, curPosn[2].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha)); } int32 CRadar::GetActualBlipArrayIndex(int32 i) @@ -954,43 +821,43 @@ uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright) { int32 c; switch (color) { - case 0: + case RADAR_TRACE_RED: if (bright) c = 0x712B49FF; else c = 0x7F0000FF; break; - case 1: + case RADAR_TRACE_GREEN: if (bright) c = 0x5FA06AFF; else c = 0x007F00FF; break; - case 2: + case RADAR_TRACE_LIGHT_BLUE: if (bright) c = 0x80A7F3FF; else c = 0x00007FFF; break; - case 3: + case RADAR_TRACE_GRAY: if (bright) c = 0xE1E1E1FF; else c = 0x7F7F7FFF; break; - case 4: + case RADAR_TRACE_YELLOW: if (bright) c = 0xFFFF00FF; else c = 0x7F7F00FF; break; - case 5: + case RADAR_TRACE_MAGENTA: if (bright) c = 0xFF00FFFF; else c = 0x7F007FFF; break; - case 6: + case RADAR_TRACE_CYAN: if (bright) c = 0x00FFFFFF; else @@ -1055,12 +922,65 @@ void CRadar::LoadAllRadarBlips(uint8 *buf, uint32 size) INITSAVEBUF CheckSaveHeader(buf, 'R', 'D', 'R', '\0', size - SAVE_HEADER_SIZE); - for (int i = 0; i < NUMRADARBLIPS; i++) - ms_RadarTrace[i] = ReadSaveBuf(buf); + for (int i = 0; i < NUMRADARBLIPS; i++) { + ms_RadarTrace[i].m_nColor = ReadSaveBuf(buf); + ms_RadarTrace[i].m_eBlipType = ReadSaveBuf(buf); + ms_RadarTrace[i].m_nEntityHandle = ReadSaveBuf(buf); + ms_RadarTrace[i].m_vec2DPos.x = ReadSaveBuf(buf); // CVector2D + ms_RadarTrace[i].m_vec2DPos.y = ReadSaveBuf(buf); + ms_RadarTrace[i].m_vecPos = ReadSaveBuf(buf); + ms_RadarTrace[i].m_BlipIndex = ReadSaveBuf(buf); + ms_RadarTrace[i].m_bDim = ReadSaveBuf(buf); + ms_RadarTrace[i].m_bInUse = ReadSaveBuf(buf); + ms_RadarTrace[i].m_bShortRange = ReadSaveBuf(buf); + ms_RadarTrace[i].m_unused = ReadSaveBuf(buf); + ms_RadarTrace[i].m_Radius = ReadSaveBuf(buf); + ms_RadarTrace[i].m_wScale = ReadSaveBuf(buf); + ms_RadarTrace[i].m_eBlipDisplay = ReadSaveBuf(buf); + ms_RadarTrace[i].m_eRadarSprite = ReadSaveBuf(buf); + } VALIDATESAVEBUF(size); } +void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size) +{ + *size = SAVE_HEADER_SIZE + NUMRADARBLIPS * sizeof(sRadarTraceSave); + +INITSAVEBUF + WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE); + +#ifdef MAP_ENHANCEMENTS + if (TargetMarkerId != -1) { + ClearBlip(TargetMarkerId); + TargetMarkerId = -1; + } +#endif + + for (int i = 0; i < NUMRADARBLIPS; i++) { + sRadarTraceSave *saveStruct = (sRadarTraceSave*) buf; + + saveStruct->m_nColor = ms_RadarTrace[i].m_nColor; + saveStruct->m_eBlipType = ms_RadarTrace[i].m_eBlipType; + saveStruct->m_nEntityHandle = ms_RadarTrace[i].m_nEntityHandle; + saveStruct->m_vec2DPos = ms_RadarTrace[i].m_vec2DPos; + saveStruct->m_vecPos = ms_RadarTrace[i].m_vecPos; + saveStruct->m_BlipIndex = ms_RadarTrace[i].m_BlipIndex; + saveStruct->m_bDim = ms_RadarTrace[i].m_bDim; + saveStruct->m_bInUse = ms_RadarTrace[i].m_bInUse; + saveStruct->m_bShortRange = ms_RadarTrace[i].m_bShortRange; + saveStruct->m_unused = ms_RadarTrace[i].m_unused; + saveStruct->m_Radius = ms_RadarTrace[i].m_Radius; + saveStruct->m_wScale = ms_RadarTrace[i].m_wScale; + saveStruct->m_eBlipDisplay = ms_RadarTrace[i].m_eBlipDisplay; + saveStruct->m_eRadarSprite = ms_RadarTrace[i].m_eRadarSprite; + + SkipSaveBuf(buf, sizeof(sRadarTraceSave)); + } + +VALIDATESAVEBUF(*size); +} + void CRadar::LoadTextures() { @@ -1115,25 +1035,6 @@ void CRadar::RemoveRadarSections() RemoveMapSection(i, j); } -void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size) -{ - *size = SAVE_HEADER_SIZE + sizeof(ms_RadarTrace); -INITSAVEBUF - WriteSaveHeader(buf, 'R', 'D', 'R', '\0', *size - SAVE_HEADER_SIZE); - -#ifdef MAP_ENHANCEMENTS - if (TargetMarkerId != -1) { - ClearBlip(TargetMarkerId); - TargetMarkerId = -1; - } -#endif - - for (int i = 0; i < NUMRADARBLIPS; i++) - WriteSaveBuf(buf, ms_RadarTrace[i]); - -VALIDATESAVEBUF(*size); -} - void CRadar::SetBlipSprite(int32 i, int32 icon) { int index = CRadar::GetActualBlipArrayIndex(i); @@ -1142,7 +1043,7 @@ void CRadar::SetBlipSprite(int32 i, int32 icon) } } -int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display) +int CRadar::SetCoordBlip(eBlipType type, CVector pos, uint32 color, eBlipDisplay display) { int nextBlip; for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) { @@ -1154,7 +1055,7 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay return -1; #endif ms_RadarTrace[nextBlip].m_eBlipType = type; - ms_RadarTrace[nextBlip].m_nColor = color; + ms_RadarTrace[nextBlip].m_nColor = RADAR_TRACE_MAGENTA; ms_RadarTrace[nextBlip].m_bDim = true; ms_RadarTrace[nextBlip].m_bInUse = true; ms_RadarTrace[nextBlip].m_bShortRange = false; @@ -1168,7 +1069,7 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay return CRadar::GetNewUniqueBlipIndex(nextBlip); } -int CRadar::SetShortRangeCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display) +int CRadar::SetShortRangeCoordBlip(eBlipType type, CVector pos, uint32 color, eBlipDisplay display) { int index = SetCoordBlip(type, pos, color, display); if (index == -1) @@ -1177,7 +1078,7 @@ int CRadar::SetShortRangeCoordBlip(eBlipType type, CVector pos, int32 color, eBl return index; } -int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display) +int CRadar::SetEntityBlip(eBlipType type, int32 handle, uint32 color, eBlipDisplay display) { int nextBlip; for (nextBlip = 0; nextBlip < NUMRADARBLIPS; nextBlip++) { @@ -1189,7 +1090,7 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla return -1; #endif ms_RadarTrace[nextBlip].m_eBlipType = type; - ms_RadarTrace[nextBlip].m_nColor = color; + ms_RadarTrace[nextBlip].m_nColor = RADAR_TRACE_YELLOW; ms_RadarTrace[nextBlip].m_bDim = true; ms_RadarTrace[nextBlip].m_bInUse = true; ms_RadarTrace[nextBlip].m_bShortRange = false; @@ -1261,12 +1162,12 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, switch (mode) { case BLIP_MODE_TRIANGULAR_UP: - // size++; // VC does size + 1 for triangles + size++; CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(size + 3.0f), y + SCREEN_SCALE_Y(size + 2.0f), x - (SCREEN_SCALE_X(size + 3.0f)), y + SCREEN_SCALE_Y(size + 2.0f), x, y - (SCREEN_SCALE_Y(size + 3.0f)), x, y - (SCREEN_SCALE_Y(size + 3.0f)), CRGBA(0, 0, 0, alpha)); CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(size + 1.0f), y + SCREEN_SCALE_Y(size + 1.0f), x - (SCREEN_SCALE_X(size + 1.0f)), y + SCREEN_SCALE_Y(size + 1.0f), x, y - (SCREEN_SCALE_Y(size + 1.0f)), x, y - (SCREEN_SCALE_Y(size + 1.0f)), CRGBA(red, green, blue, alpha)); break; case BLIP_MODE_TRIANGULAR_DOWN: - // size++; // VC does size + 1 for triangles + size++; CSprite2d::Draw2DPolygon(x, y + SCREEN_SCALE_Y(size + 2.0f), x, y + SCREEN_SCALE_Y(size + 3.0f), x + SCREEN_SCALE_X(size + 3.0f), y - (SCREEN_SCALE_Y(size + 2.0f)), x - (SCREEN_SCALE_X(size + 3.0f)), y - (SCREEN_SCALE_Y(size + 2.0f)), CRGBA(0, 0, 0, alpha)); CSprite2d::Draw2DPolygon(x, y + SCREEN_SCALE_Y(size + 1.0f), x, y + SCREEN_SCALE_Y(size + 1.0f), x + SCREEN_SCALE_X(size + 1.0f), y - (SCREEN_SCALE_Y(size + 1.0f)), x - (SCREEN_SCALE_X(size + 1.0f)), y - (SCREEN_SCALE_Y(size + 1.0f)), CRGBA(red, green, blue, alpha)); break; @@ -1275,21 +1176,6 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha)); break; } - - // TODO(Miami): Map - // VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips - if (FrontEndMenuManager.m_bMenuMapActive) { - bool alreadyThere = false; - for (int i = 0; i < NUM_MAP_LEGENDS; i++) { - if (MapLegendList[i] == -1) - alreadyThere = true; - } - if (!alreadyThere) { - MapLegendList[MapLegendCounter] = -1; - MapLegendCounter++; - ArrowBlipColour1 = CRGBA(red, green, blue, alpha); - } - } } void CRadar::Shutdown() @@ -1338,7 +1224,8 @@ void CRadar::Shutdown() void CRadar::StreamRadarSections(const CVector &posn) { - StreamRadarSections(Floor((2000.0f + posn.x) / 500.0f), Ceil(7.0f - (2000.0f + posn.y) / 500.0f)); + if (!CStreaming::ms_disableStreaming) + StreamRadarSections(Floor((RADAR_MAX_X + posn.x) / RADAR_TILE_SIZE), Ceil((RADAR_NUM_TILES - 1) - (RADAR_MAX_Y + posn.y) / RADAR_TILE_SIZE)); } void CRadar::StreamRadarSections(int32 x, int32 y) @@ -1405,8 +1292,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D void CRadar::CalculateCachedSinCos() { - if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED - || FrontEndMenuManager.m_bMenuMapActive ) { + if (/*TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED || */ + FrontEndMenuManager.m_bMenuMapActive ) { cachedSin = 0.0f; cachedCos = 1.0f; } else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) { @@ -1445,7 +1332,7 @@ CRadar::InitFrontEndMap() void CRadar::DrawYouAreHereSprite(float x, float y) { - static uint32 lastChange = 0; + static PauseModeTime lastChange = 0; static bool show = true; if (show) { @@ -1461,13 +1348,30 @@ CRadar::DrawYouAreHereSprite(float x, float y) } if (show) { - float left = x - SCREEN_SCALE_X(12.0f); - float top = y; - float right = SCREEN_SCALE_X(12.0) + x; - float bottom = y - SCREEN_SCALE_Y(24.0f); - CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); + const float left = x - SCREEN_SCALE_X(8.0f); + const float top = y - SCREEN_SCALE_Y(40.0f); + const float right = x + SCREEN_SCALE_X(40.0); + const float bottom = y + SCREEN_SCALE_Y(8.0f); + MapHereSprite.Draw(CRect(left + SCREEN_SCALE_X(2.f), top + SCREEN_SCALE_Y(2.f), right + SCREEN_SCALE_X(2.f), bottom + SCREEN_SCALE_Y(2.f)), + CRGBA(0, 0, 0, 255)); + + MapHereSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); + + CFont::SetWrapx(right + SCREEN_SCALE_X(28.0f)); + CFont::SetRightJustifyWrap(right); + CFont::SetBackGroundOnlyTextOff(); + CFont::SetColor(CRGBA(255, 150, 225, 255)); + CFont::SetDropShadowPosition(2); + CFont::SetDropColor(CRGBA(0, 0, 0, 255)); + CFont::SetCentreOff(); + CFont::SetRightJustifyOff(); + CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); + CFont::SetScale(SCREEN_SCALE_X(0.65f), SCREEN_SCALE_Y(0.95f)); + CFont::PrintString(right, top, TheText.Get("MAP_YAH")); + CFont::SetDropShadowPosition(0); + CFont::DrawFonts(); } - MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE; + MapLegendList[MapLegendCounter++] = RADAR_SPRITE_MAP_HERE; } #ifdef MAP_ENHANCEMENTS @@ -1485,8 +1389,8 @@ CRadar::ToggleTargetMarker(float x, float y) return; ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD; - ms_RadarTrace[nextBlip].m_nColor = 0x333333FF; - ms_RadarTrace[nextBlip].m_bDim = 1; + ms_RadarTrace[nextBlip].m_nColor = RADAR_TRACE_GRAY; + ms_RadarTrace[nextBlip].m_bDim = 0; ms_RadarTrace[nextBlip].m_bInUse = 1; ms_RadarTrace[nextBlip].m_Radius = 1.0f; CVector pos(x, y, CWorld::FindGroundZForCoord(x,y)); @@ -1505,3 +1409,287 @@ CRadar::ToggleTargetMarker(float x, float y) } #endif +void +CRadar::DrawEntityBlip(int32 blipId) +{ + CVector2D out; + CVector2D in; + CEntity *blipEntity; + switch (ms_RadarTrace[blipId].m_eBlipType) { + case BLIP_CAR: + blipEntity = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + break; + case BLIP_CHAR: + blipEntity = CPools::GetPedPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + if (blipEntity != nil) { + if (((CPed*)blipEntity)->InVehicle()) + blipEntity = ((CPed*)blipEntity)->m_pMyVehicle; + } + break; + case BLIP_OBJECT: + blipEntity = CPools::GetObjectPool()->GetAt(ms_RadarTrace[blipId].m_nEntityHandle); + break; + default: + break; + } + if (blipEntity) { + uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { + if (CTheScripts::IsDebugOn()) { + ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius); + ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; + if (ms_RadarTrace[blipId].m_Radius < 1.0f) + ms_RadarTrace[blipId].m_Radius = 5.0f; + } + } + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { + TransformRealWorldPointToRadarSpace(in, blipEntity->GetPosition()); + float dist = LimitRadarPoint(in); + TransformRadarPointToScreenSpace(out, in); + if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) { + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { + DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); + } else { + 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; + else mode = BLIP_MODE_SQUARE; + } + ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); + + if (FrontEndMenuManager.m_bMenuMapActive) { + bool alreadyThere = false; + for (int i = 0; i < NUM_MAP_LEGENDS; i++) { + if (MapLegendList[i] == -2) + alreadyThere = true; + } + if (!alreadyThere) { + MapLegendList[MapLegendCounter] = -2; + MapLegendCounter++; + ArrowBlipColour2 = CRGBA((uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); + } + } + } + } + } + } +} + +void +CRadar::DrawCoordBlip(int32 blipId) +{ + CVector2D out; + CVector2D in; + if (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission()) { + + uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) { + if (CTheScripts::IsDebugOn()) { + ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius); + ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f; + if (ms_RadarTrace[blipId].m_Radius < 1.0f) + ms_RadarTrace[blipId].m_Radius = 5.0f; + } + } + if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) { + TransformRealWorldPointToRadarSpace(in, ms_RadarTrace[blipId].m_vec2DPos); + float dist = LimitRadarPoint(in); + TransformRadarPointToScreenSpace(out, in); + if (!ms_RadarTrace[blipId].m_bShortRange || dist <= 1.0f || FrontEndMenuManager.m_bMenuMapActive) { + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_NONE) { + DrawRadarSprite(ms_RadarTrace[blipId].m_eRadarSprite, out.x, out.y, CalculateBlipAlpha(dist)); + } else { + 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; + else mode = BLIP_MODE_SQUARE; + } + ShowRadarTraceWithHeight(out.x, out.y, ms_RadarTrace[blipId].m_wScale, (uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255, mode); + + if (FrontEndMenuManager.m_bMenuMapActive) { + bool alreadyThere = false; + for (int i = 0; i < NUM_MAP_LEGENDS; i++) { + if (MapLegendList[i] == -1) + alreadyThere = true; + } + if (!alreadyThere) { + MapLegendList[MapLegendCounter] = -1; + MapLegendCounter++; + ArrowBlipColour1 = CRGBA((uint8)(color >> 24), (uint8)(color >> 16), (uint8)(color >> 8), 255); + } + } + } + } + } + } +} + +void +CRadar::DrawLegend(int32 x, int32 y, int32 sprite) +{ + if (sprite < 0) { + static PauseModeTime lastChange = 0; + static int8 blipMode = 0; + + CRGBA color; + if (sprite == -1) { + color = ArrowBlipColour1; + } else { + color = ArrowBlipColour2; + } + + if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 600) { + lastChange = CTimer::GetTimeInMillisecondsPauseMode(); + if ( blipMode == 2 ) + blipMode = 0; + else + ++blipMode; + } + + switch (blipMode) { + case BLIP_MODE_TRIANGULAR_UP: + CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(14.0f), y + SCREEN_SCALE_Y(13.0f), x + SCREEN_SCALE_X(2.0f), y + SCREEN_SCALE_Y(13.0f), x + SCREEN_SCALE_X(8.f), y + SCREEN_SCALE_Y(2.0f), x + SCREEN_SCALE_X(8.f), y + SCREEN_SCALE_Y(2.0f), CRGBA(0, 0, 0, 255)); + CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(12.0f), y + SCREEN_SCALE_Y(12.0f), x + SCREEN_SCALE_X(4.0f), y + SCREEN_SCALE_Y(12.0f), x + SCREEN_SCALE_X(8.f), y + SCREEN_SCALE_Y(4.0f), x + SCREEN_SCALE_X(8.f), y + SCREEN_SCALE_Y(4.0f), color); + break; + case BLIP_MODE_TRIANGULAR_DOWN: + CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(14.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(14.0f), x + SCREEN_SCALE_X(2.f), y + SCREEN_SCALE_Y(3.0f), x + SCREEN_SCALE_X(2.f), y + SCREEN_SCALE_Y(3.0f), CRGBA(0, 0, 0, 255)); + CSprite2d::Draw2DPolygon(x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(12.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(12.0f), x + SCREEN_SCALE_X(12.f), y + SCREEN_SCALE_Y(4.0f), x + SCREEN_SCALE_X(4.f), y + SCREEN_SCALE_Y(4.0f), color); + break; + case BLIP_MODE_SQUARE: + CSprite2d::DrawRect(CRect(x + SCREEN_SCALE_X(4.0f), y + SCREEN_SCALE_Y(3.0f), SCREEN_SCALE_X(12.0f) + x, SCREEN_SCALE_Y(12.0f) + y), CRGBA(0, 0, 0, 255)); + CSprite2d::DrawRect(CRect(x + SCREEN_SCALE_X(5.0f), y + SCREEN_SCALE_Y(4.0f), SCREEN_SCALE_X(11.0f) + x, SCREEN_SCALE_Y(11.0f) + y), color); + break; + } + + } else { + RadarSprites[sprite]->Draw(CRect(x, y, x + SCREEN_SCALE_X(16.f), y + SCREEN_SCALE_X(16.f)), CRGBA(255, 255, 255, 255)); + } + + wchar *text; + switch ( sprite ) { + case RADAR_SPRITE_ENTITY_BLIP: + text = TheText.Get("LG_38"); + break; + case RADAR_SPRITE_COORD_BLIP: + text = TheText.Get("LG_35"); + break; + case RADAR_SPRITE_MAP_HERE: + text = TheText.Get("LG_01"); + break; + case RADAR_SPRITE_AVERY: + text = TheText.Get("LG_02"); + break; + case RADAR_SPRITE_BIKER: + text = TheText.Get("LG_03"); + break; + case RADAR_SPRITE_CORTEZ: + text = TheText.Get("LG_04"); + break; + case RADAR_SPRITE_DIAZ: + text = TheText.Get("LG_05"); + break; + case RADAR_SPRITE_KENT: + text = TheText.Get("LG_06"); + break; + case RADAR_SPRITE_LAWYER: + text = TheText.Get("LG_07"); + break; + case RADAR_SPRITE_PHIL: + text = TheText.Get("LG_08"); + break; + case RADAR_SPRITE_BIKERS: + text = TheText.Get("LG_03"); + break; + case RADAR_SPRITE_BOATYARD: + text = TheText.Get("LG_09"); + break; + case RADAR_SPRITE_MALIBU_CLUB: + text = TheText.Get("LG_10"); + break; + case RADAR_SPRITE_CUBANS: + text = TheText.Get("LG_11"); + break; + case RADAR_SPRITE_FILM: + text = TheText.Get("LG_12"); + break; + case RADAR_SPRITE_GUN: + text = TheText.Get("LG_13"); + break; + case RADAR_SPRITE_HAITIANS: + text = TheText.Get("LG_14"); + break; + case RADAR_SPRITE_HARDWARE: + text = TheText.Get("LG_15"); + break; + case RADAR_SPRITE_SAVE: + text = TheText.Get("LG_16"); + break; + case RADAR_SPRITE_STRIP: + text = TheText.Get("LG_37"); + break; + case RADAR_SPRITE_ICE: + text = TheText.Get("LG_17"); + break; + case RADAR_SPRITE_KCABS: + text = TheText.Get("LG_18"); + break; + case RADAR_SPRITE_LOVEFIST: + text = TheText.Get("LG_19"); + break; + case RADAR_SPRITE_PRINTWORKS: + text = TheText.Get("LG_20"); + break; + case RADAR_SPRITE_PROPERTY: + text = TheText.Get("LG_21"); + break; + case RADAR_SPRITE_SUNYARD: + text = TheText.Get("LG_36"); + break; + case RADAR_SPRITE_SPRAY: + text = TheText.Get("LG_22"); + break; + case RADAR_SPRITE_TSHIRT: + text = TheText.Get("LG_23"); + break; + case RADAR_SPRITE_TOMMY: + text = TheText.Get("LG_24"); + break; + case RADAR_SPRITE_PHONE: + text = TheText.Get("LG_25"); + break; + case RADAR_SPRITE_RADIO_WILDSTYLE: + text = TheText.Get("LG_26"); + break; + case RADAR_SPRITE_RADIO_FLASH: + text = TheText.Get("LG_27"); + break; + case RADAR_SPRITE_RADIO_KCHAT: + text = TheText.Get("LG_28"); + break; + case RADAR_SPRITE_RADIO_FEVER: + text = TheText.Get("LG_29"); + break; + case RADAR_SPRITE_RADIO_VROCK: + text = TheText.Get("LG_30"); + break; + case RADAR_SPRITE_RADIO_VCPR: + text = TheText.Get("LG_31"); + break; + case RADAR_SPRITE_RADIO_ESPANTOSO: + text = TheText.Get("LG_32"); + break; + case RADAR_SPRITE_RADIO_EMOTION: + text = TheText.Get("LG_33"); + break; + case RADAR_SPRITE_RADIO_WAVE: + text = TheText.Get("LG_34"); + break; + default: + break; + } + CFont::PrintString(SCREEN_SCALE_X(20.f) + x, SCREEN_SCALE_Y(3.0f) + y, text); +} diff --git a/src/core/Radar.h b/src/core/Radar.h index 100da8f3..b5f34f1f 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -96,6 +96,17 @@ enum eRadarSprite RADAR_SPRITE_COUNT }; +enum +{ + RADAR_TRACE_RED, + RADAR_TRACE_GREEN, + RADAR_TRACE_LIGHT_BLUE, + RADAR_TRACE_GRAY, + RADAR_TRACE_YELLOW, + RADAR_TRACE_MAGENTA, + RADAR_TRACE_CYAN +}; + enum { BLIP_MODE_TRIANGULAR_UP = 0, @@ -104,6 +115,26 @@ enum }; struct sRadarTrace +{ + uint32 m_nColor; + uint32 m_eBlipType; // eBlipType + int32 m_nEntityHandle; + CVector m_vec2DPos; + CVector m_vecPos; + uint16 m_BlipIndex; + bool m_bDim; + bool m_bInUse; + bool m_bShortRange; + bool m_unused; + float m_Radius; + int16 m_wScale; + uint16 m_eBlipDisplay; // eBlipDisplay + uint16 m_eRadarSprite; // eRadarSprite +}; + +// Either that was a thing while saving/loading blips, or they added sizes of each field one by one. I want to do the former. +#pragma pack(push,1) +struct sRadarTraceSave { uint32 m_nColor; uint32 m_eBlipType; // eBlipType @@ -114,11 +145,13 @@ struct sRadarTrace bool m_bDim; bool m_bInUse; bool m_bShortRange; + bool m_unused; float m_Radius; int16 m_wScale; uint16 m_eBlipDisplay; // eBlipDisplay uint16 m_eRadarSprite; // eRadarSprite }; +#pragma pack(pop) // Values for screen space #define RADAR_LEFT (40.0f) @@ -176,7 +209,7 @@ public: static CRGBA ArrowBlipColour1; static CRGBA ArrowBlipColour2; static int16 MapLegendList[NUM_MAP_LEGENDS]; - static uint16 MapLegendCounter; + static int16 MapLegendCounter; #ifdef MAP_ENHANCEMENTS static int TargetMarkerId; @@ -215,9 +248,9 @@ public: static void RemoveRadarSections(); static void SaveAllRadarBlips(uint8*, uint32*); static void SetBlipSprite(int32 i, int32 icon); - static int32 SetCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay); - static int32 SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay); - static int32 SetShortRangeCoordBlip(eBlipType type, CVector pos, int32, eBlipDisplay); + static int32 SetCoordBlip(eBlipType type, CVector pos, uint32, eBlipDisplay); + static int32 SetEntityBlip(eBlipType type, int32, uint32, eBlipDisplay); + static int32 SetShortRangeCoordBlip(eBlipType type, CVector pos, uint32, eBlipDisplay); static void SetRadarMarkerState(int32 i, bool flag); static void ShowRadarMarker(CVector pos, uint32 color, float radius); static void ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha); @@ -229,7 +262,8 @@ public: static void TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D &in); static void TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in); static void TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in); - - // no in CRadar in the game: static void CalculateCachedSinCos(); + static void DrawEntityBlip(int32 blipId); + static void DrawCoordBlip(int32 blipId); + static void DrawLegend(int32, int32, int32); }; diff --git a/src/core/config.h b/src/core/config.h index e2123597..770a7c2e 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -172,7 +172,6 @@ enum Config { # define RANDOMSPLASH # define VU_COLLISION #elif defined GTA_PC -# define GTA3_1_1_PATCH //# define GTA3_STEAM_PATCH //# define GTAVC_JP_PATCH # ifdef GTA_PS2_STUFF @@ -263,7 +262,6 @@ enum Config { // Hud, frontend and radar //#define BETA_SLIDING_TEXT -#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC #define PC_MENU #ifndef PC_MENU -- cgit v1.2.3 From 588fb26728c9a8ac287c216464c52a6eeb9781e7 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 17 Oct 2020 18:26:48 +0300 Subject: Fix player model not changing in cutscenes --- src/core/Streaming.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index ddde4664..40d4acee 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -903,7 +903,7 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag int i, n; mi = CModelInfo::GetModelInfo(modelId); - if(!CGeneral::faststrcmp("CSPlay", modelName)){ + if(strncasecmp("CSPlay", modelName, 6) == 0){ char *curname = CModelInfo::GetModelInfo(MI_PLAYER)->GetName(); for(int i = 0; CSnames[i][0]; i++){ if(strcasecmp(curname, IGnames[i]) == 0){ -- cgit v1.2.3 From 1195f3db7beb1b79f0c25aad69a11b58d59363f2 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 17 Oct 2020 18:50:16 +0300 Subject: saves part 1 --- src/core/Pools.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'src/core') diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index fe2cf7ad..e0c45982 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -2,6 +2,7 @@ #include "Pools.h" +#include "Bike.h" #include "Boat.h" #include "CarCtrl.h" #ifdef MISSION_REPLAY @@ -13,6 +14,8 @@ #include "Wanted.h" #include "World.h" +//--MIAMI: file done + CCPtrNodePool *CPools::ms_pPtrNodePool; CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool; CPedPool *CPools::ms_pPedPool; @@ -24,7 +27,6 @@ CDummyPool *CPools::ms_pDummyPool; CAudioScriptObjectPool *CPools::ms_pAudioScriptObjectPool; CColModelPool *CPools::ms_pColModelPool; -//--MIAMI: done void CPools::Initialise(void) { @@ -40,7 +42,6 @@ CPools::Initialise(void) ms_pColModelPool = new CColModelPool(NUMCOLMODELS, "ColModel"); } -//--MIAMI: done void CPools::ShutDown(void) { @@ -119,7 +120,8 @@ void CPools::LoadVehiclePool(uint8* buf, uint32 size) INITSAVEBUF int nNumCars = ReadSaveBuf(buf); int nNumBoats = ReadSaveBuf(buf); - for (int i = 0; i < nNumCars + nNumBoats; i++) { + int nNumBikes = ReadSaveBuf(buf); + for (int i = 0; i < nNumCars + nNumBoats + nNumBikes; i++) { uint32 type = ReadSaveBuf(buf); int16 model = ReadSaveBuf(buf); CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY); @@ -131,13 +133,15 @@ INITSAVEBUF pVehicle = new(slot) CBoat(model, RANDOM_VEHICLE); else if (type == VEHICLE_TYPE_CAR) pVehicle = new(slot) CAutomobile(model, RANDOM_VEHICLE); + else if (type == VEHICLE_TYPE_BIKE) + pVehicle = new(slot) CBike(model, RANDOM_VEHICLE); else assert(0); --CCarCtrl::NumRandomCars; pVehicle->Load(buf); CWorld::Add(pVehicle); #else - char* vbuf = new char[Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize)]; + char* vbuf = new char[Max(CBike::nSaveStructSize, Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize))]; if (type == VEHICLE_TYPE_BOAT) { memcpy(vbuf, buf, sizeof(CBoat)); SkipSaveBuf(buf, sizeof(CBoat)); @@ -156,6 +160,17 @@ INITSAVEBUF pAutomobile->Damage = ((CAutomobile*)vbuf)->Damage; pAutomobile->SetupDamageAfterLoad(); } + else if (type == VEHICLE_TYPE_BIKE) { +#ifdef FIX_BUGS + memcpy(vbuf, buf, sizeof(CBike)); +#else + memcpy(vbuf, buf, sizeof(CAutomobile)); +#endif + SkipSaveBuf(buf, sizeof(CBike)); + CBike* pBike = new(slot) CBike(model, RANDOM_VEHICLE); + pVehicle = pBike; + --CCarCtrl::NumRandomCars; + } else assert(0); CVehicle* pBufferVehicle = (CVehicle*)vbuf; @@ -193,6 +208,7 @@ INITSAVEBUF (pVehicle->GetAddressOfEntityProperties())[0] = (pBufferVehicle->GetAddressOfEntityProperties())[0]; (pVehicle->GetAddressOfEntityProperties())[1] = (pBufferVehicle->GetAddressOfEntityProperties())[1]; pVehicle->AutoPilot = pBufferVehicle->AutoPilot; + CCarCtrl::UpdateCarCount(pVehicle, false); CWorld::Add(pVehicle); delete[] vbuf; #endif @@ -205,6 +221,7 @@ void CPools::SaveVehiclePool(uint8* buf, uint32* size) INITSAVEBUF int nNumCars = 0; int nNumBoats = 0; + int nNumBikes = 0; int nPoolSize = GetVehiclePool()->GetSize(); for (int i = 0; i < nPoolSize; i++) { CVehicle* pVehicle = GetVehiclePool()->GetSlot(i); @@ -226,19 +243,25 @@ INITSAVEBUF ++nNumCars; if (pVehicle->IsBoat() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) ++nNumBoats; + if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) + ++nNumBoats; #else if (!pVehicle->pDriver && !bHasPassenger) { if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) ++nNumCars; if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) ++nNumBoats; + if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) + ++nNumBoats; #endif } } *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CAutomobile::nSaveStructSize) + sizeof(int) + - nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int); + nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int) + + nNumBikes * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBike::nSaveStructSize) + sizeof(int); WriteSaveBuf(buf, nNumCars); WriteSaveBuf(buf, nNumBoats); + WriteSaveBuf(buf, nNumBikes); for (int i = 0; i < nPoolSize; i++) { CVehicle* pVehicle = GetVehiclePool()->GetSlot(i); if (!pVehicle) @@ -258,9 +281,9 @@ INITSAVEBUF #endif #ifdef COMPATIBLE_SAVES #ifdef MISSION_REPLAY - if ((pVehicle->IsCar() || pVehicle->IsBoat()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { + if ((pVehicle->IsCar() || pVehicle->IsBoat() || pVehicle->IsBike()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { #else - if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { + if ((pVehicle->IsCar() || pVehicle->IsBoat() || pVehicle->IsBike()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { #endif WriteSaveBuf(buf, pVehicle->m_vehType); WriteSaveBuf(buf, pVehicle->GetModelIndex()); @@ -290,6 +313,17 @@ INITSAVEBUF memcpy(buf, pVehicle, sizeof(CBoat)); SkipSaveBuf(buf, sizeof(CBoat)); } +#ifdef MISSION_REPLAY + if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { +#else + if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { +#endif + WriteSaveBuf(buf, (uint32)pVehicle->m_vehType); + WriteSaveBuf(buf, pVehicle->GetModelIndex()); + WriteSaveBuf(buf, GetVehicleRef(pVehicle)); + memcpy(buf, pVehicle, sizeof(CBike)); + SkipSaveBuf(buf, sizeof(CBike)); + } #endif } } @@ -336,6 +370,7 @@ INITSAVEBUF tmp.CompressFromFullMatrix(pObject->m_objectMatrix); CopyToBuf(buf, tmp); CopyToBuf(buf, pObject->ObjectCreatedBy); + SkipSaveBuf(buf, 1); CopyToBuf(buf, bIsPickup); CopyToBuf(buf, bPickupObjWithMessage); CopyToBuf(buf, bOutOfStock); @@ -343,6 +378,8 @@ INITSAVEBUF CopyToBuf(buf, bGlassBroken); CopyToBuf(buf, bHasBeenDamaged); CopyToBuf(buf, bUseVehicleColours); + CopyToBuf(buf, pObject->m_unk); + CopyToBuf(buf, pObject->m_nBonusValue); CopyToBuf(buf, pObject->m_fCollisionDamageMultiplier); CopyToBuf(buf, pObject->m_nCollisionDamageEffect); CopyToBuf(buf, pObject->m_nSpecialCollisionResponseCases); @@ -392,6 +429,9 @@ INITSAVEBUF pBufferObject->bHasBeenDamaged = bitFlag; CopyFromBuf(buf, bitFlag); pBufferObject->bUseVehicleColours = bitFlag; + CopyFromBuf(buf, pBufferObject->m_unk); + CopyFromBuf(buf, pBufferObject->m_nBonusValue); + SkipSaveBuf(buf, 1); CopyFromBuf(buf, pBufferObject->m_fCollisionDamageMultiplier); CopyFromBuf(buf, pBufferObject->m_nCollisionDamageEffect); CopyFromBuf(buf, pBufferObject->m_nSpecialCollisionResponseCases); @@ -426,6 +466,8 @@ INITSAVEBUF (pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1]; #endif pObject->bHasCollided = false; + pObject->m_unk = pBufferObject->m_unk; + pObject->m_nBonusValue = pBufferObject->m_nBonusValue; CWorld::Add(pObject); delete[] obuf; } -- cgit v1.2.3 From 720abca8269dfeb725c58d016eb88f2c124170b9 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 17 Oct 2020 20:45:07 +0300 Subject: finished save/load --- src/core/Pools.cpp | 7 ++++--- src/core/Radar.cpp | 4 ++-- src/core/Radar.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index e0c45982..774f406d 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -345,8 +345,9 @@ INITSAVEBUF ++nObjects; } *size = nObjects * (sizeof(int16) + sizeof(int) + sizeof(CCompressedMatrix) + - sizeof(float) + sizeof(CCompressedMatrix) + sizeof(int8) + 7 * sizeof(bool) + sizeof(float) + - sizeof(int8) + sizeof(int8) + sizeof(uint32) + 2 * sizeof(uint32)) + sizeof(int); + sizeof(float) + sizeof(CCompressedMatrix) + sizeof(int8) + 7 * sizeof(bool) + sizeof(int16) + + + sizeof(int8) * 2 + sizeof(float) + sizeof(int8) + sizeof(int8) + + sizeof(uint32) + 2 * sizeof(uint32)) + sizeof(int); CopyToBuf(buf, nObjects); for (int i = 0; i < nPoolSize; i++) { CObject* pObject = GetObjectPool()->GetSlot(i); @@ -370,7 +371,6 @@ INITSAVEBUF tmp.CompressFromFullMatrix(pObject->m_objectMatrix); CopyToBuf(buf, tmp); CopyToBuf(buf, pObject->ObjectCreatedBy); - SkipSaveBuf(buf, 1); CopyToBuf(buf, bIsPickup); CopyToBuf(buf, bPickupObjWithMessage); CopyToBuf(buf, bOutOfStock); @@ -380,6 +380,7 @@ INITSAVEBUF CopyToBuf(buf, bUseVehicleColours); CopyToBuf(buf, pObject->m_unk); CopyToBuf(buf, pObject->m_nBonusValue); + SkipSaveBuf(buf, 1); CopyToBuf(buf, pObject->m_fCollisionDamageMultiplier); CopyToBuf(buf, pObject->m_nCollisionDamageEffect); CopyToBuf(buf, pObject->m_nSpecialCollisionResponseCases); diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 78166252..3ddf8337 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -924,6 +924,7 @@ INITSAVEBUF for (int i = 0; i < NUMRADARBLIPS; i++) { ms_RadarTrace[i].m_nColor = ReadSaveBuf(buf); + ms_RadarTrace[i].m_Radius = ReadSaveBuf(buf); ms_RadarTrace[i].m_eBlipType = ReadSaveBuf(buf); ms_RadarTrace[i].m_nEntityHandle = ReadSaveBuf(buf); ms_RadarTrace[i].m_vec2DPos.x = ReadSaveBuf(buf); // CVector2D @@ -934,7 +935,6 @@ INITSAVEBUF ms_RadarTrace[i].m_bInUse = ReadSaveBuf(buf); ms_RadarTrace[i].m_bShortRange = ReadSaveBuf(buf); ms_RadarTrace[i].m_unused = ReadSaveBuf(buf); - ms_RadarTrace[i].m_Radius = ReadSaveBuf(buf); ms_RadarTrace[i].m_wScale = ReadSaveBuf(buf); ms_RadarTrace[i].m_eBlipDisplay = ReadSaveBuf(buf); ms_RadarTrace[i].m_eRadarSprite = ReadSaveBuf(buf); @@ -961,6 +961,7 @@ INITSAVEBUF sRadarTraceSave *saveStruct = (sRadarTraceSave*) buf; saveStruct->m_nColor = ms_RadarTrace[i].m_nColor; + saveStruct->m_Radius = ms_RadarTrace[i].m_Radius; saveStruct->m_eBlipType = ms_RadarTrace[i].m_eBlipType; saveStruct->m_nEntityHandle = ms_RadarTrace[i].m_nEntityHandle; saveStruct->m_vec2DPos = ms_RadarTrace[i].m_vec2DPos; @@ -970,7 +971,6 @@ INITSAVEBUF saveStruct->m_bInUse = ms_RadarTrace[i].m_bInUse; saveStruct->m_bShortRange = ms_RadarTrace[i].m_bShortRange; saveStruct->m_unused = ms_RadarTrace[i].m_unused; - saveStruct->m_Radius = ms_RadarTrace[i].m_Radius; saveStruct->m_wScale = ms_RadarTrace[i].m_wScale; saveStruct->m_eBlipDisplay = ms_RadarTrace[i].m_eBlipDisplay; saveStruct->m_eRadarSprite = ms_RadarTrace[i].m_eRadarSprite; diff --git a/src/core/Radar.h b/src/core/Radar.h index b5f34f1f..8f2e7069 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -137,6 +137,7 @@ struct sRadarTrace struct sRadarTraceSave { uint32 m_nColor; + float m_Radius; uint32 m_eBlipType; // eBlipType int32 m_nEntityHandle; CVector2D m_vec2DPos; @@ -146,7 +147,6 @@ struct sRadarTraceSave bool m_bInUse; bool m_bShortRange; bool m_unused; - float m_Radius; int16 m_wScale; uint16 m_eBlipDisplay; // eBlipDisplay uint16 m_eRadarSprite; // eRadarSprite -- cgit v1.2.3 From c856d88691be1f40b454ac499305503d51c2d792 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 18 Oct 2020 12:34:34 +0300 Subject: object field renamed --- src/core/Pools.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index 774f406d..b25fa4e1 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -378,7 +378,7 @@ INITSAVEBUF CopyToBuf(buf, bGlassBroken); CopyToBuf(buf, bHasBeenDamaged); CopyToBuf(buf, bUseVehicleColours); - CopyToBuf(buf, pObject->m_unk); + CopyToBuf(buf, pObject->m_nCostValue); CopyToBuf(buf, pObject->m_nBonusValue); SkipSaveBuf(buf, 1); CopyToBuf(buf, pObject->m_fCollisionDamageMultiplier); @@ -430,7 +430,7 @@ INITSAVEBUF pBufferObject->bHasBeenDamaged = bitFlag; CopyFromBuf(buf, bitFlag); pBufferObject->bUseVehicleColours = bitFlag; - CopyFromBuf(buf, pBufferObject->m_unk); + CopyFromBuf(buf, pBufferObject->m_nCostValue); CopyFromBuf(buf, pBufferObject->m_nBonusValue); SkipSaveBuf(buf, 1); CopyFromBuf(buf, pBufferObject->m_fCollisionDamageMultiplier); @@ -467,7 +467,7 @@ INITSAVEBUF (pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1]; #endif pObject->bHasCollided = false; - pObject->m_unk = pBufferObject->m_unk; + pObject->m_nCostValue = pBufferObject->m_nCostValue; pObject->m_nBonusValue = pBufferObject->m_nBonusValue; CWorld::Add(pObject); delete[] obuf; -- cgit v1.2.3 From f60e3d667ae9be4d05b57afa676e5ef466ec352d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 18 Oct 2020 13:53:17 +0300 Subject: Minor things --- src/core/Radar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 78166252..4556e3b4 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -272,7 +272,7 @@ uint8 CRadar::CalculateBlipAlpha(float dist) return 255; if (dist <= 10.0f) - return (128.0f * ((dist - 1.0f) / 4.0f)) + ((1.0f - (dist - 1.0f) / 4.0f) * 255.0f); + return (128.0f * ((dist - 1.0f) / 9.0f)) + ((1.0f - (dist - 1.0f) / 9.0f) * 255.0f); return 128; } -- cgit v1.2.3 From b91f6a45501634b55f6ef2c08d57c5293d5fd3a0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 18 Oct 2020 16:40:06 +0300 Subject: Setter for bIsStatic (became virtual in SA) --- src/core/World.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 7f8d8994..d65d57dd 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -75,7 +75,7 @@ CWorld::Add(CEntity *ent) if(ent->IsBuilding() || ent->IsDummy()) return; - if(!ent->IsStatic()) ((CPhysical *)ent)->AddToMovingList(); + if(!ent->GetIsStatic()) ((CPhysical *)ent)->AddToMovingList(); } void @@ -90,7 +90,7 @@ CWorld::Remove(CEntity *ent) if(ent->IsBuilding() || ent->IsDummy()) return; - if(!ent->IsStatic()) ((CPhysical *)ent)->RemoveFromMovingList(); + if(!ent->GetIsStatic()) ((CPhysical *)ent)->RemoveFromMovingList(); } void @@ -1960,7 +1960,7 @@ CWorld::Process(void) RemoveEntityInsteadOfProcessingIt(movingEnt); } else { movingEnt->ProcessControl(); - if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); } + if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); } } } bForceProcessControl = true; @@ -1971,7 +1971,7 @@ CWorld::Process(void) RemoveEntityInsteadOfProcessingIt(movingEnt); } else { movingEnt->ProcessControl(); - if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); } + if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); } } } } @@ -2124,13 +2124,13 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa CObject *pObject = (CObject *)pEntity; CVehicle *pVehicle = (CVehicle *)pEntity; if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { - if(pEntity->IsStatic()) { + if(pEntity->GetIsStatic()) { if(pEntity->IsObject()) { if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) { if (IsGlass(pObject->GetModelIndex())) { CGlass::WindowRespondsToExplosion(pObject, position); } else { - pObject->bIsStatic = false; + pObject->SetIsStatic(false); pObject->AddToMovingList(); int16 modelId = pEntity->GetModelIndex(); if(modelId != MI_FIRE_HYDRANT || @@ -2148,18 +2148,18 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa } } } - if(pEntity->IsStatic()) { + if(pEntity->GetIsStatic()) { float fDamageMultiplier = (fRadius - fMagnitude) * 2.0f / fRadius; float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f); pObject->ObjectDamage(fDamage); } } else { - pEntity->bIsStatic = false; + pEntity->SetIsStatic(false); pEntity->AddToMovingList(); } } - if(!pEntity->IsStatic()) { + if(!pEntity->GetIsStatic()) { float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); CVector vecForceDir = vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / -- cgit v1.2.3