From 2d38eb923dc7e584fa12a628d9152901b8604092 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 1 Jul 2021 18:09:32 +0200 Subject: zero out work_buff before writing padding in save --- src/save/GenericGameStorage.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 84ab118c..a56ff2c3 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -251,6 +251,11 @@ GenericSave(int file) WriteSaveDataBlock(CStreaming::MemoryCardSave, "StreamingSize"); WriteSaveDataBlock(CPedType::Save, "PedTypeSize"); + // sure just write garbage data repeatedly ... +#ifndef THIS_IS_STUPID + memset(work_buff, 0, sizeof(work_buff)); +#endif + // Write padding for (int i = 0; i < 4; i++) { size = align4bytes(SIZE_OF_ONE_GAME_IN_BYTES - totalSize - 4); -- cgit v1.2.3 From 3988fec6e72a7ac7172cc5b709bd84ca963c17ba Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 1 Jul 2021 21:39:15 +0300 Subject: Fix sound of water when changing MSAA or windowed/fullscreen mode --- src/core/MenuScreensCustom.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 0534e34a..49bb33f8 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -26,6 +26,7 @@ #include "ModelInfo.h" #include "Pad.h" #include "ControllerConfig.h" +#include "DMAudio.h" // Menu screens array is at the bottom of the file. @@ -194,6 +195,8 @@ void MultiSamplingButtonPress(int8 action) { if (FrontEndMenuManager.m_nDisplayMSAALevel != FrontEndMenuManager.m_nPrefsMSAALevel) { FrontEndMenuManager.m_nPrefsMSAALevel = FrontEndMenuManager.m_nDisplayMSAALevel; _psSelectScreenVM(FrontEndMenuManager.m_nPrefsVideoMode); + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); + DMAudio.Service(); FrontEndMenuManager.SetHelperText(0); FrontEndMenuManager.SaveSettings(); } @@ -255,6 +258,8 @@ const char* screenModes[] = { "FED_FLS", "FED_WND" }; void ScreenModeAfterChange(int8 before, int8 after) { _psSelectScreenVM(FrontEndMenuManager.m_nPrefsVideoMode); // apply same resolution + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); + DMAudio.Service(); FrontEndMenuManager.SetHelperText(0); } -- cgit v1.2.3 From 65219365db5129d37bdd3be95e45ef5d4db8bc51 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 1 Jul 2021 21:51:52 +0200 Subject: fix compilation when ctype.h is included --- src/save/SaveBuf.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/save/SaveBuf.h b/src/save/SaveBuf.h index de27017e..6e9b3ae9 100644 --- a/src/save/SaveBuf.h +++ b/src/save/SaveBuf.h @@ -83,29 +83,29 @@ WriteSaveBuf(uint8 *&buf, uint32 &length, const T &value) #ifdef VALIDATE_SAVE_SIZE #define CheckSaveHeader(buf, a, b, c, d, size) do { \ - char _C; uint32 _size;\ - ReadSaveBuf(&_C, buf);\ - assert(_C == a);\ - ReadSaveBuf(&_C, buf);\ - assert(_C == b);\ - ReadSaveBuf(&_C, buf);\ - assert(_C == c);\ - ReadSaveBuf(&_C, buf);\ - assert(_C == d);\ + char _c; uint32 _size;\ + ReadSaveBuf(&_c, buf);\ + assert(_c == a);\ + ReadSaveBuf(&_c, buf);\ + assert(_c == b);\ + ReadSaveBuf(&_c, buf);\ + assert(_c == c);\ + ReadSaveBuf(&_c, buf);\ + assert(_c == d);\ ReadSaveBuf(&_size, buf);\ assert(_size == size);\ } while(0) #define CheckSaveHeaderWithLength(buf,len,a,b,c,d,size) do { \ - char _C; uint32 _size;\ - ReadSaveBuf(&_C, buf, len);\ - assert(_C == a);\ - ReadSaveBuf(&_C, buf, len);\ - assert(_C == b);\ - ReadSaveBuf(&_C, buf, len);\ - assert(_C == c);\ - ReadSaveBuf(&_C, buf, len);\ - assert(_C == d);\ + char _c; uint32 _size;\ + ReadSaveBuf(&_c, buf, len);\ + assert(_c == a);\ + ReadSaveBuf(&_c, buf, len);\ + assert(_c == b);\ + ReadSaveBuf(&_c, buf, len);\ + assert(_c == c);\ + ReadSaveBuf(&_c, buf, len);\ + assert(_c == d);\ ReadSaveBuf(&_size, buf, len);\ assert(_size == size);\ } while(0) -- cgit v1.2.3 From 8e6e46a919579b98962c2a0c770bda4f98323f46 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 2 Jul 2021 00:18:38 +0300 Subject: Fix collision loading for mission entities --- src/collision/ColStore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collision/ColStore.cpp b/src/collision/ColStore.cpp index f1e695fe..c74bf5ba 100644 --- a/src/collision/ColStore.cpp +++ b/src/collision/ColStore.cpp @@ -186,7 +186,7 @@ CColStore::LoadCollision(const CVector2D &pos) }else{ for (int j = 0; j < MAX_CLEANUP; j++) { CPhysical* pEntity = nil; - cleanup_entity_struct* pCleanup = &CTheScripts::MissionCleanUp.m_sEntities[i]; + cleanup_entity_struct* pCleanup = &CTheScripts::MissionCleanUp.m_sEntities[j]; if (pCleanup->type == CLEANUP_CAR) { pEntity = CPools::GetVehiclePool()->GetAt(pCleanup->id); if (!pEntity || pEntity->GetStatus() == STATUS_WRECKED) -- cgit v1.2.3 From ae4bfef5900bff2694403ee9a0e7401bf3502bd3 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 2 Jul 2021 10:22:34 +0300 Subject: Refactor OnscreenTimer --- src/control/OnscreenTimer.cpp | 98 +++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp index 53ed14c7..5045c1e0 100644 --- a/src/control/OnscreenTimer.cpp +++ b/src/control/OnscreenTimer.cpp @@ -9,14 +9,15 @@ #include "OnscreenTimer.h" #include "Camera.h" -void COnscreenTimer::Init() { +void +COnscreenTimer::Init() +{ m_bDisabled = false; for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) { m_sCounters[i].m_nCounterOffset = 0; - for(uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText); j++) { - m_sCounters[i].m_aCounterText[j] = 0; - } + for(uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText); j++) + m_sCounters[i].m_aCounterText[j] = '\0'; m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER; m_sCounters[i].m_bCounterProcessed = false; @@ -24,24 +25,25 @@ void COnscreenTimer::Init() { for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { m_sClocks[i].m_nClockOffset = 0; - for(uint32 j = 0; j < ARRAY_SIZE(m_sClocks[0].m_aClockText); j++) { - m_sClocks[i].m_aClockText[j] = 0; - } + for(uint32 j = 0; j < ARRAY_SIZE(m_sClocks[0].m_aClockText); j++) + m_sClocks[i].m_aClockText[j] = '\0'; m_sClocks[i].m_bClockProcessed = false; m_sClocks[i].m_bClockGoingDown = true; } } -void COnscreenTimer::Process() { - if(!CReplay::IsPlayingBack() && !m_bDisabled) { - for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { +void +COnscreenTimer::Process() +{ + if(!CReplay::IsPlayingBack() && !m_bDisabled) + for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) m_sClocks[i].Process(); - } - } } -void COnscreenTimer::ProcessForDisplay() { +void +COnscreenTimer::ProcessForDisplay() +{ if(CHud::m_Wants_To_Draw_Hud) { m_bProcessed = false; for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { @@ -63,67 +65,67 @@ void COnscreenTimer::ProcessForDisplay() { } } -void COnscreenTimer::ClearCounter(uint32 offset) { +void +COnscreenTimer::ClearCounter(uint32 offset) +{ for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) { if(offset == m_sCounters[i].m_nCounterOffset) { m_sCounters[i].m_nCounterOffset = 0; - m_sCounters[i].m_aCounterText[0] = 0; + m_sCounters[i].m_aCounterText[0] = '\0'; m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER; - m_sCounters[i].m_bCounterProcessed = 0; + m_sCounters[i].m_bCounterProcessed = false; } } } -void COnscreenTimer::ClearClock(uint32 offset) { - for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { +void +COnscreenTimer::ClearClock(uint32 offset) +{ + for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) if(offset == m_sClocks[i].m_nClockOffset) { m_sClocks[i].m_nClockOffset = 0; - m_sClocks[i].m_aClockText[0] = 0; - m_sClocks[i].m_bClockProcessed = 0; + m_sClocks[i].m_aClockText[0] = '\0'; + m_sClocks[i].m_bClockProcessed = false; m_sClocks[i].m_bClockGoingDown = true; } - } } -void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) { - +void +COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) +{ if (m_sCounters[pos].m_aCounterText[0] != '\0') return; m_sCounters[pos].m_nCounterOffset = offset; - if(text) { + if(text) strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(m_sCounters[0].m_aCounterText)); - } else { - m_sCounters[pos].m_aCounterText[0] = 0; - } + else + m_sCounters[pos].m_aCounterText[0] = '\0'; m_sCounters[pos].m_nType = type; } -void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) { - - // dead code in here - uint32 i; - for(i = 0; i < NUMONSCREENCLOCKS; i++) { +void +COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) +{ + for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { if(m_sClocks[i].m_nClockOffset == 0) { + m_sClocks[i].m_nClockOffset = offset; + m_sClocks[i].m_bClockGoingDown = bGoingDown; + if(text) + strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(m_sClocks[0].m_aClockText)); + else + m_sClocks[i].m_aClockText[0] = '\0'; break; } - return; - } - - m_sClocks[i].m_nClockOffset = offset; - m_sClocks[i].m_bClockGoingDown = bGoingDown; - if(text) { - strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(m_sClocks[0].m_aClockText)); - } else { - m_sClocks[i].m_aClockText[0] = 0; } } -void COnscreenTimerEntry::Process() { - if(m_nClockOffset == 0) { +void +COnscreenTimerEntry::Process() +{ + if(m_nClockOffset == 0) return; - } int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nClockOffset); int32 oldTime = *timerPtr; @@ -147,13 +149,17 @@ void COnscreenTimerEntry::Process() { *timerPtr = oldTime + int32(CTimer::GetTimeStepInMilliseconds()); } -void COnscreenTimerEntry::ProcessForDisplayClock() { +void +COnscreenTimerEntry::ProcessForDisplayClock() +{ uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nClockOffset); sprintf(m_aClockBuffer, "%02d:%02d", time / 1000 / 60 % 100, time / 1000 % 60); } -void COnscreenCounterEntry::ProcessForDisplayCounter() { +void +COnscreenCounterEntry::ProcessForDisplayCounter() +{ uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset); sprintf(m_aCounterBuffer, "%d", counter); } -- cgit v1.2.3 From 9ea3549743a1ed30b8c6a231bfcccea8c9eb969d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 2 Jul 2021 10:30:39 +0300 Subject: GameLogic - type fixes --- src/control/GameLogic.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index 17802d95..e6b47e52 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -158,7 +158,7 @@ CGameLogic::Update() #endif CMessages::ClearMessages(); CCarCtrl::ClearInterestingVehicleList(); - CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1); + CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, true); CRestart::FindClosestHospitalRestartPoint(pPlayerInfo.GetPos(), &vecRestartPos, &fRestartFloat); CRestart::OverrideHospitalLevel = LEVEL_GENERIC; CRestart::OverridePoliceStationLevel = LEVEL_GENERIC; @@ -191,7 +191,7 @@ CGameLogic::Update() } - if (!CTheScripts::IsPlayerOnAMission() && pPlayerInfo.m_nBustedAudioStatus == 0) { + if (!CTheScripts::IsPlayerOnAMission() && pPlayerInfo.m_nBustedAudioStatus == BUSTEDAUDIO_NONE) { if (CGeneral::GetRandomNumberInRange(0, 4) == 0) pPlayerInfo.m_nBustedAudioStatus = BUSTEDAUDIO_DONE; else { @@ -267,7 +267,7 @@ CGameLogic::Update() #endif CMessages::ClearMessages(); CCarCtrl::ClearInterestingVehicleList(); - CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1); + CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, true); CRestart::FindClosestPoliceRestartPoint(pPlayerInfo.GetPos(), &vecRestartPos, &fRestartFloat); CRestart::OverrideHospitalLevel = LEVEL_GENERIC; CRestart::OverridePoliceStationLevel = LEVEL_GENERIC; @@ -322,7 +322,7 @@ CGameLogic::Update() #endif CMessages::ClearMessages(); CCarCtrl::ClearInterestingVehicleList(); - CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1); + CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, true); CRestart::FindClosestPoliceRestartPoint(pPlayerInfo.GetPos(), &vecRestartPos, &fRestartFloat); CRestart::OverridePoliceStationLevel = LEVEL_GENERIC; CRestart::OverrideHospitalLevel = LEVEL_GENERIC; @@ -379,7 +379,7 @@ CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed *pPlayerPed, CVector pPlayerPed->m_fRotationDest = pPlayerPed->m_fRotationCur; pPlayerPed->SetHeading(pPlayerPed->m_fRotationCur); CTheScripts::ClearSpaceForMissionEntity(pos, pPlayerPed); - CWorld::ClearExcitingStuffFromArea(pos, 4000.0, 1); + CWorld::ClearExcitingStuffFromArea(pos, 4000.0f, true); pPlayerPed->RestoreHeadingRate(); CGame::currArea = AREA_MAIN_MAP; CStreaming::RemoveBuildingsNotInArea(0); @@ -489,7 +489,7 @@ CGameLogic::UpdateShortCut() pShortCutTaxi->AutoPilot.m_nTempAction = TEMPACT_GOFORWARD; pShortCutTaxi->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2500; TheCamera.SetFadeColour(0, 0, 0); - TheCamera.Fade(2.5f, 0); + TheCamera.Fade(2.5f, FADE_OUT); ShortCutState = SHORTCUT_TRANSITION; ShortCutTimer = CTimer::GetTimeInMilliseconds() + 3000; CMessages::AddBigMessage(TheText.Get("TAXI"), 4500, 1); @@ -509,7 +509,7 @@ CGameLogic::UpdateShortCut() pShortCutTaxi->SetMoveSpeed(pShortCutTaxi->GetForward() * 0.4f); ShortCutTimer = CTimer::GetTimeInMilliseconds() + 1500; TheCamera.SetFadeColour(0, 0, 0); - TheCamera.Fade(1.0f, 1); + TheCamera.Fade(1.0f, FADE_IN); ShortCutState = SHORTCUT_ARRIVING; CTimer::Resume(); } -- cgit v1.2.3 From 987e09515b214558435331ee220af68f5562f7a8 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 2 Jul 2021 10:33:45 +0300 Subject: Fix use of integer in RemoveBuildingsNotInArea call --- src/control/GameLogic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index e6b47e52..11df7b43 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -382,7 +382,7 @@ CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed *pPlayerPed, CVector CWorld::ClearExcitingStuffFromArea(pos, 4000.0f, true); pPlayerPed->RestoreHeadingRate(); CGame::currArea = AREA_MAIN_MAP; - CStreaming::RemoveBuildingsNotInArea(0); + CStreaming::RemoveBuildingsNotInArea(AREA_MAIN_MAP); TheCamera.SetCameraDirectlyInFrontForFollowPed_CamOnAString(); TheCamera.Restore(); CReferences::RemoveReferencesToPlayer(); -- cgit v1.2.3 From 4eea98c66b86f444eb07e730ce7a3118dfd092c1 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 2 Jul 2021 23:56:31 +0300 Subject: Peds: Efforts to find the reason of crashes on GCC 7.5.0 * Prevent deleted peds to be in nearPeds list (was always needed, might be unrelated to crashes) * Add asserts to nearPeds and PedIK ctor (crash reasons) * Shouldn't fix reported crashes since they were caused by null peds. --- src/peds/CopPed.cpp | 3 --- src/peds/Ped.cpp | 28 +++++++++++++++++++++++++++- src/peds/PedIK.cpp | 4 ++-- src/peds/PedIK.h | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index fbfa7249..1efd7733 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -644,9 +644,6 @@ CCopPed::ProcessControl(void) int numCopsNear = 0; for (int i = 0; i < player->m_numNearPeds; ++i) { CPed *nearPed = player->m_nearPeds[i]; -#ifdef FIX_BUGS - if (nearPed) -#endif if (nearPed->m_nPedType == PEDTYPE_COP && nearPed->m_nPedState != PED_DEAD) ++numCopsNear; } diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index e07b5dd4..96f3479c 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -403,6 +403,30 @@ CPed::~CPed(void) CPopulation::NumMiamiViceCops--; CPopulation::UpdatePedCount((ePedType)m_nPedType, true); DMAudio.DestroyEntity(m_audioEntityId); + + // Because of the nature of ped lists in GTA, it can sometimes be outdated. + // Remove ourself from nearPeds list of the Peds in our nearPeds list. +#ifdef FIX_BUGS + for(int i = 0; i < m_numNearPeds; i++) { + CPed *nearPed = m_nearPeds[i]; + assert(nearPed != nil); + if (!nearPed->IsPointerValid()) + continue; + + for(int j = 0; j < nearPed->m_numNearPeds;) { + assert(j == ARRAY_SIZE(m_nearPeds) - 1 || nearPed->m_nearPeds[j] || !nearPed->m_nearPeds[j+1]); // ensure nil comes after nil + + if (nearPed->m_nearPeds[j] == this) { + for (int k = j; k < ARRAY_SIZE(m_nearPeds) - 1; k++) { + nearPed->m_nearPeds[k] = nearPed->m_nearPeds[k + 1]; + nearPed->m_nearPeds[k + 1] = nil; + } + nearPed->m_numNearPeds--; + } else + j++; + } + } +#endif } void @@ -519,13 +543,15 @@ CPed::BuildPedLists(void) removePed = true; } } + + assert(i == ARRAY_SIZE(m_nearPeds) - 1 || m_nearPeds[i] || !m_nearPeds[i+1]); // ensure nil comes after nil + if (removePed) { // If we arrive here, the ped we're checking isn't "near", so we should remove it. for (int j = i; j < ARRAY_SIZE(m_nearPeds) - 1; j++) { m_nearPeds[j] = m_nearPeds[j + 1]; m_nearPeds[j + 1] = nil; } - // Above loop won't work on last slot, so we need to empty it. m_nearPeds[ARRAY_SIZE(m_nearPeds) - 1] = nil; m_numNearPeds--; } else diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index 6730d731..cf2e4ed5 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -17,9 +17,9 @@ const RwV3d XaxisIK = { 1.0f, 0.0f, 0.0f}; const RwV3d YaxisIK = { 0.0f, 1.0f, 0.0f}; const RwV3d ZaxisIK = { 0.0f, 0.0f, 1.0f}; -CPedIK::CPedIK(CPed *ped) +CPedIK::CPedIK(CPed *ped) : m_ped(ped) { - m_ped = ped; + assert(ped != nil); m_flags = 0; m_headOrient.yaw = 0.0f; m_headOrient.pitch = 0.0f; diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h index ee719fea..8be04365 100644 --- a/src/peds/PedIK.h +++ b/src/peds/PedIK.h @@ -34,7 +34,7 @@ public: AIMS_WITH_ARM = 4, }; - CPed *m_ped; + CPed *Const m_ped; LimbOrientation m_headOrient; LimbOrientation m_torsoOrient; LimbOrientation m_upperArmOrient; -- cgit v1.2.3 From f9f854c4a8dad22bc515c3c6af6d3fec73cdede5 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 3 Jul 2021 01:36:44 +0200 Subject: smol fix --- src/skel/win/win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index acaea28d..d3dc2623 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1541,7 +1541,7 @@ psSelectDevice() } if(bestFsMode < 0){ - MessageBox(nil, "Cannot find desired video mode", "GTA3", MB_OK); + MessageBox(nil, "Cannot find desired video mode", "GTA: Vice City", MB_OK); return FALSE; } GcurSelVM = bestFsMode; -- cgit v1.2.3 From 43631ba2036492821ecaa0f3c5d56795a310bfd2 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 3 Jul 2021 01:40:26 +0200 Subject: smol fix 2 --- src/skel/glfw/glfw.cpp | 2 +- src/skel/win/win.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index f5195b83..0928229f 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -919,7 +919,7 @@ void _InputInitialiseJoys() free(db); fclose(f); } else - printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from re3/gamefiles to GTA3 directory. Some gamepads may not be recognized.\n"); + printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from reVC/gamefiles to GTA: Vice City directory. Some gamepads may not be recognized.\n"); #undef SDL_GAMEPAD_DB_PATH diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index d3dc2623..f251f58d 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1498,7 +1498,7 @@ psSelectDevice() #ifdef DEFAULT_NATIVE_RESOLUTION GcurSelVM = 1; #else - MessageBox(nil, "Cannot find 640x480 video mode", "GTA3", MB_OK); + MessageBox(nil, "Cannot find 640x480 video mode", "GTA: Vice City", MB_OK); return FALSE; #endif } -- cgit v1.2.3 From 1c0878f65b8a554bdea9183fdc4b76645e530ccb Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 3 Jul 2021 01:32:47 +0300 Subject: Sanitizer fixes 2 --- src/core/Crime.h | 2 +- src/peds/Ped.cpp | 25 +++++++++++++------------ src/peds/Ped.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/core/Crime.h b/src/core/Crime.h index 3c3e2b26..4c7ea315 100644 --- a/src/core/Crime.h +++ b/src/core/Crime.h @@ -28,7 +28,7 @@ class CCrimeBeingQd { public: eCrimeType m_nType; - uint32 m_nId; + int32 m_nId; uint32 m_nTime; CVector m_vecPosn; bool m_bReported; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 96f3479c..44712fa0 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2887,7 +2887,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) CColModel *hisCol = CModelInfo::GetModelInfo(collidingEnt->GetModelIndex())->GetColModel(); if (!bUsesCollision && !bJustCheckCollision) - return false; + return 0; if (collidingEnt->IsVehicle() && ((CVehicle*)collidingEnt)->IsBoat()) collidedWithBoat = true; @@ -6775,7 +6775,7 @@ CPed::FollowPath(void) } void -CPed::SetEvasiveStep(CEntity *reason, uint8 animType) +CPed::SetEvasiveStep(CPhysical *reason, uint8 animType) { AnimationId stepAnim; @@ -6793,22 +6793,23 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) if (neededTurn > PI) neededTurn = TWOPI - neededTurn; - CVehicle *veh = (CVehicle*)reason; - if (reason->IsVehicle() && veh->IsCar()) { + if (reason->IsVehicle() && ((CVehicle*)reason)->IsCar()) { + CVehicle *veh = (CVehicle*)reason; if (veh->m_nCarHornTimer != 0) { vehPressedHorn = true; if (!IsPlayer()) animType = 1; } } - if (neededTurn <= DEGTORAD(90.0f) || veh->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) { - SetLookFlag(veh, true); - if ((CGeneral::GetRandomNumber() & 1) && veh->GetModelIndex() != MI_RCBANDIT && animType == 0) { + + if (neededTurn <= DEGTORAD(90.0f) || reason->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) { + SetLookFlag(reason, true); + if ((CGeneral::GetRandomNumber() & 1) && reason->GetModelIndex() != MI_RCBANDIT && animType == 0) { stepAnim = ANIM_STD_HAILTAXI; } else { - float vehDirection = CGeneral::GetRadianAngleBetweenPoints( - veh->m_vecMoveSpeed.x, veh->m_vecMoveSpeed.y, + float dangerDirection = CGeneral::GetRadianAngleBetweenPoints( + reason->m_vecMoveSpeed.x, reason->m_vecMoveSpeed.y, 0.0f, 0.0f); // Let's turn our back to the "reason" @@ -6818,14 +6819,14 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) angleToFace -= TWOPI; // We don't want to run towards car's direction - float dangerZone = angleToFace - vehDirection; + float dangerZone = angleToFace - dangerDirection; dangerZone = CGeneral::LimitRadianAngle(dangerZone); // So, add or subtract 90deg (jump to left/right) according to that if (dangerZone > 0.0f) - angleToFace = vehDirection - HALFPI; + angleToFace = dangerDirection - HALFPI; else - angleToFace = vehDirection + HALFPI; + angleToFace = dangerDirection + HALFPI; stepAnim = ANIM_STD_NUM; if (animType == 0 || animType == 1) diff --git a/src/peds/Ped.h b/src/peds/Ped.h index c5c6cf49..f5a7d7dc 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -762,7 +762,7 @@ public: void SetAimFlag(CEntity* to); void SetAimFlag(float angle); void SetAmmo(eWeaponType weaponType, uint32 ammo); - void SetEvasiveStep(CEntity*, uint8); + void SetEvasiveStep(CPhysical*, uint8); void GrantAmmo(eWeaponType, uint32); void SetEvasiveDive(CPhysical*, uint8); void SetAttack(CEntity*); -- cgit v1.2.3 From a92dcaa0b115e61b18aae5a8f368a5d92614db21 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 3 Jul 2021 03:00:02 +0200 Subject: premake: add no-full-paths option for CI builds, rename lto to with-lto --- .github/workflows/reVC_msvc_amd64.yml | 2 +- .github/workflows/reVC_msvc_x86.yml | 2 +- premake5.lua | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reVC_msvc_amd64.yml b/.github/workflows/reVC_msvc_amd64.yml index 9cd83ee7..ad883d32 100644 --- a/.github/workflows/reVC_msvc_amd64.yml +++ b/.github/workflows/reVC_msvc_amd64.yml @@ -34,7 +34,7 @@ jobs: 7z x ${{env.GLFW_FILE}} - name: Configure build run: | - ./premake5 vs2019 --with-librw --glfwdir64=${{env.GLFW_BASE}} + ./premake5 vs2019 --with-librw --no-full-paths --glfwdir64=${{env.GLFW_BASE}} - name: Build run: | msbuild -m build/reVC.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=${{matrix.platform}} diff --git a/.github/workflows/reVC_msvc_x86.yml b/.github/workflows/reVC_msvc_x86.yml index dc5eaed2..1407aeae 100644 --- a/.github/workflows/reVC_msvc_x86.yml +++ b/.github/workflows/reVC_msvc_x86.yml @@ -34,7 +34,7 @@ jobs: 7z x ${{env.GLFW_FILE}} - name: Configure build run: | - ./premake5 vs2019 --with-librw --glfwdir32=${{env.GLFW_BASE}} + ./premake5 vs2019 --with-librw --no-full-paths --glfwdir32=${{env.GLFW_BASE}} - name: Build run: | msbuild -m build/reVC.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=${{matrix.platform}} diff --git a/premake5.lua b/premake5.lua index da41eb1c..af41a5a3 100644 --- a/premake5.lua +++ b/premake5.lua @@ -27,14 +27,19 @@ newoption { description = "Build with opus" } +newoption { + trigger = "with-lto", + description = "Build with link time optimization" +} + newoption { trigger = "no-git-hash", description = "Don't print git commit hash into binary" } newoption { - trigger = "lto", - description = "Use link time optimization" + trigger = "no-full-paths", + description = "Don't print full paths into binary" } if(_OPTIONS["with-librw"]) then @@ -114,7 +119,7 @@ workspace "reVC" filter "configurations:not Debug" defines { "NDEBUG" } optimize "Speed" - if(_OPTIONS["lto"]) then + if(_OPTIONS["with-lto"]) then flags { "LinkTimeOptimization" } end @@ -327,6 +332,10 @@ project "reVC" linkoptions "/SAFESEH:NO" characterset ("MBCS") targetextension ".exe" + if(_OPTIONS["no-full-paths"]) then + usefullpaths "off" + linkoptions "/PDBALTPATH:%_PDB%" + end if(_OPTIONS["with-librw"]) then -- external librw is dynamic staticruntime "on" -- cgit v1.2.3 From 3ed4cdf10944d8836b5005b552fafcc94f942d12 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 3 Jul 2021 15:57:08 +0300 Subject: Fix overflow in audio code --- src/audio/AudioManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 360a2275..131704dc 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -1076,7 +1076,7 @@ void cAudioManager::AdjustSamplesVolume() { for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { - tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] + 1]; + tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; if (!pSample->m_bIs2D) pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_fSoundIntensity, pSample->m_fDistance); -- cgit v1.2.3