From 497e0b801ff30cf836887b625752c1643b533a7e Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 00:19:44 +0100 Subject: m_nWantedLevel -> GetWantedLevel() --- src/control/Pickups.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 857f74ec..96a8a670 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -129,7 +129,7 @@ CPickup::CanBePickedUp(CPlayerPed *player) bool cannotBePickedUp = (m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f) || (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f) - || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0) + || (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->GetWantedLevel() == 0) || (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame)); return !cannotBePickedUp; } @@ -456,7 +456,7 @@ CPickups::GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex) DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0); return true; } else if (modelIndex == MI_PICKUP_BRIBE) { - int32 level = FindPlayerPed()->m_pWanted->m_nWantedLevel - 1; + int32 level = FindPlayerPed()->m_pWanted->GetWantedLevel() - 1; if (level < 0) level = 0; player->SetWantedLevel(level); DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0); -- cgit v1.2.3 From 7a3b80a9b7f414967fe59f89ab0fe5416735babe Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 31 Jan 2021 20:44:39 +0100 Subject: First batch of fixes (CallAndMessage) --- src/control/Pickups.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 96a8a670..8318bc1a 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -814,6 +814,9 @@ void CPickups::RenderPickUpText() { wchar *strToPrint; +#ifdef FIX_BUGS + strToPrint = nil; +#endif for (int32 i = 0; i < NumMessages; i++) { if (aMessages[i].m_quantity <= 39) { switch (aMessages[i].m_quantity) // could use some enum maybe @@ -1285,7 +1288,11 @@ CPacManPickups::GeneratePMPickUpsForRace(int32 race) int i = 0; if (race == 0) pPos = aRacePoints1; // there's only one available - assert(pPos != nil); + + if(!pPos) { + debug("This shouldn't happen"); + return; + } while (!pPos->IsZero()) { while (aPMPickUps[i].m_eType != PACMAN_NONE) -- cgit v1.2.3 From 3d4791f2915a5b1f38c34a0cf01e0dffc588af8c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 31 Jan 2021 21:06:38 +0100 Subject: Revert "First batch of fixes (CallAndMessage)" This reverts commit 7a3b80a9b7f414967fe59f89ab0fe5416735babe. --- src/control/Pickups.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 8318bc1a..96a8a670 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -814,9 +814,6 @@ void CPickups::RenderPickUpText() { wchar *strToPrint; -#ifdef FIX_BUGS - strToPrint = nil; -#endif for (int32 i = 0; i < NumMessages; i++) { if (aMessages[i].m_quantity <= 39) { switch (aMessages[i].m_quantity) // could use some enum maybe @@ -1288,11 +1285,7 @@ CPacManPickups::GeneratePMPickUpsForRace(int32 race) int i = 0; if (race == 0) pPos = aRacePoints1; // there's only one available - - if(!pPos) { - debug("This shouldn't happen"); - return; - } + assert(pPos != nil); while (!pPos->IsZero()) { while (aPMPickUps[i].m_eType != PACMAN_NONE) -- cgit v1.2.3 From 9db87fc6365ee76f3281ca2474f92ec4f155920d Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 12:21:47 +0100 Subject: add debug render groups --- src/control/Pickups.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 96a8a670..be9f734d 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -1330,6 +1330,8 @@ CPacManPickups::Render() { if (!bPMActive) return; + PUSH_RENDERGROUP("CPacManPickups::Render"); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); @@ -1363,6 +1365,8 @@ CPacManPickups::Render() RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, FALSE); + + POP_RENDERGROUP(); } void -- cgit v1.2.3 From 6537dfe7f103161676a8850801383b0d63efd40e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 10 May 2021 02:34:21 +0300 Subject: Use some GetMatrix/SetMatrix logic based on SA + CutsceneHead fix --- src/control/Pickups.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index be9f734d..a1e2a851 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -689,8 +689,7 @@ CPickups::DoPickUpEffects(CEntity *entity) entity->bDoNotRender = CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame; if (!entity->bDoNotRender) { - float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x7FF) * DEGTORAD(360.0f / 0x800)); - float modifiedSin = 0.3f * (s + 1.0f); + float modifiedSin = 0.3f * (Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x7FF) * DEGTORAD(360.0f / 0x800)) + 1.0f); int16 colorId; @@ -749,7 +748,20 @@ CPickups::DoPickUpEffects(CEntity *entity) } } - entity->GetMatrix().SetRotateZOnlyScaled((float)(CTimer::GetTimeInMilliseconds() & 0x7FF) * DEGTORAD(360.0f / 0x800), aWeaponScale[colorId]); + float angle = (float)(CTimer::GetTimeInMilliseconds() & 0x7FF) * DEGTORAD(360.0f / 0x800); + float c = Cos(angle) * aWeaponScale[colorId]; + float s = Sin(angle) * aWeaponScale[colorId]; + + // we know from SA they were setting each field manually like this + entity->GetMatrix().rx = c; + entity->GetMatrix().ry = s; + entity->GetMatrix().rz = 0.0f; + entity->GetMatrix().fx = -s; + entity->GetMatrix().fy = c; + entity->GetMatrix().fz = 0.0f; + entity->GetMatrix().ux = 0.0f; + entity->GetMatrix().uy = 0.0f; + entity->GetMatrix().uz = aWeaponScale[colorId]; } } -- cgit v1.2.3 From 2b67aba94cb6448fb24c869559465eddf2bad069 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 25 Jun 2021 19:03:05 +0300 Subject: Redo ReadSaveBuf + common.h cleanup --- src/control/Pickups.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index a1e2a851..10175fba 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -23,6 +23,7 @@ #ifdef FIX_BUGS #include "Replay.h" #endif +#include "SaveBuf.h" #include "Script.h" #include "Shadows.h" #include "SpecialFX.h" @@ -999,18 +1000,18 @@ CPickups::Load(uint8 *buf, uint32 size) INITSAVEBUF for (int32 i = 0; i < NUMPICKUPS; i++) { - aPickUps[i] = ReadSaveBuf(buf); + ReadSaveBuf(&aPickUps[i], buf); if (aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil) aPickUps[i].m_pObject = CPools::GetObjectPool()->GetSlot((uintptr)aPickUps[i].m_pObject - 1); } - CollectedPickUpIndex = ReadSaveBuf(buf); - ReadSaveBuf(buf); + ReadSaveBuf(&CollectedPickUpIndex, buf); + SkipSaveBuf(buf, 2); NumMessages = 0; for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++) - aPickUpsCollected[i] = ReadSaveBuf(buf); + ReadSaveBuf(&aPickUpsCollected[i], buf); VALIDATESAVEBUF(size) } -- cgit v1.2.3 From af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 26 Jun 2021 00:25:59 +0300 Subject: Revert "Redo ReadSaveBuf + common.h cleanup" This reverts commit 2b67aba94cb6448fb24c869559465eddf2bad069. --- src/control/Pickups.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 10175fba..a1e2a851 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -23,7 +23,6 @@ #ifdef FIX_BUGS #include "Replay.h" #endif -#include "SaveBuf.h" #include "Script.h" #include "Shadows.h" #include "SpecialFX.h" @@ -1000,18 +999,18 @@ CPickups::Load(uint8 *buf, uint32 size) INITSAVEBUF for (int32 i = 0; i < NUMPICKUPS; i++) { - ReadSaveBuf(&aPickUps[i], buf); + aPickUps[i] = ReadSaveBuf(buf); if (aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil) aPickUps[i].m_pObject = CPools::GetObjectPool()->GetSlot((uintptr)aPickUps[i].m_pObject - 1); } - ReadSaveBuf(&CollectedPickUpIndex, buf); - SkipSaveBuf(buf, 2); + CollectedPickUpIndex = ReadSaveBuf(buf); + ReadSaveBuf(buf); NumMessages = 0; for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++) - ReadSaveBuf(&aPickUpsCollected[i], buf); + aPickUpsCollected[i] = ReadSaveBuf(buf); VALIDATESAVEBUF(size) } -- cgit v1.2.3 From f3a931e1c99372ae4bc224ef482d4052a09580cb Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 26 Jun 2021 19:14:46 +0200 Subject: Revert "Revert "Redo ReadSaveBuf + common.h cleanup"" This reverts commit af7573ddbe38e0aaa485877e7ccb2e704b0f5a7f. --- src/control/Pickups.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index a1e2a851..10175fba 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -23,6 +23,7 @@ #ifdef FIX_BUGS #include "Replay.h" #endif +#include "SaveBuf.h" #include "Script.h" #include "Shadows.h" #include "SpecialFX.h" @@ -999,18 +1000,18 @@ CPickups::Load(uint8 *buf, uint32 size) INITSAVEBUF for (int32 i = 0; i < NUMPICKUPS; i++) { - aPickUps[i] = ReadSaveBuf(buf); + ReadSaveBuf(&aPickUps[i], buf); if (aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil) aPickUps[i].m_pObject = CPools::GetObjectPool()->GetSlot((uintptr)aPickUps[i].m_pObject - 1); } - CollectedPickUpIndex = ReadSaveBuf(buf); - ReadSaveBuf(buf); + ReadSaveBuf(&CollectedPickUpIndex, buf); + SkipSaveBuf(buf, 2); NumMessages = 0; for (uint16 i = 0; i < NUMCOLLECTEDPICKUPS; i++) - aPickUpsCollected[i] = ReadSaveBuf(buf); + ReadSaveBuf(&aPickUpsCollected[i], buf); VALIDATESAVEBUF(size) } -- cgit v1.2.3 From 011aafa0435d2c60dc4e0769ed4c93ed1761e3f6 Mon Sep 17 00:00:00 2001 From: withmorten Date: Mon, 5 Jul 2021 18:07:26 +0200 Subject: finish COMPATIBLE_SAVES and FIX_INCOMPATIBLE_SAVES --- src/control/Pickups.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/control/Pickups.cpp') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 10175fba..8d3472ea 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -32,6 +32,12 @@ #include "WaterLevel.h" #include "World.h" +#ifdef COMPATIBLE_SAVES +#define PICKUPS_SAVE_SIZE 0x24C0 +#else +#define PICKUPS_SAVE_SIZE sizeof(aPickUps) +#endif + CPickup CPickups::aPickUps[NUMPICKUPS]; int16 CPickups::NumMessages; int32 CPickups::aPickUpsCollected[NUMCOLLECTEDPICKUPS]; @@ -1000,10 +1006,23 @@ CPickups::Load(uint8 *buf, uint32 size) INITSAVEBUF for (int32 i = 0; i < NUMPICKUPS; i++) { +#ifdef COMPATIBLE_SAVES + ReadSaveBuf(&aPickUps[i].m_eType, buf); + ReadSaveBuf(&aPickUps[i].m_bRemoved, buf); + ReadSaveBuf(&aPickUps[i].m_nQuantity, buf); + int32 tmp; + ReadSaveBuf(&tmp, buf); + aPickUps[i].m_pObject = aPickUps[i].m_eType != PICKUP_NONE && tmp != 0 ? CPools::GetObjectPool()->GetSlot(tmp - 1) : nil; + ReadSaveBuf(&aPickUps[i].m_nTimer, buf); + ReadSaveBuf(&aPickUps[i].m_eModelIndex, buf); + ReadSaveBuf(&aPickUps[i].m_nIndex, buf); + ReadSaveBuf(&aPickUps[i].m_vecPos, buf); +#else ReadSaveBuf(&aPickUps[i], buf); if (aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil) aPickUps[i].m_pObject = CPools::GetObjectPool()->GetSlot((uintptr)aPickUps[i].m_pObject - 1); +#endif } ReadSaveBuf(&CollectedPickUpIndex, buf); @@ -1019,14 +1038,26 @@ VALIDATESAVEBUF(size) void CPickups::Save(uint8 *buf, uint32 *size) { - *size = sizeof(aPickUps) + sizeof(uint16) + sizeof(uint16) + sizeof(aPickUpsCollected); + *size = PICKUPS_SAVE_SIZE + sizeof(uint16) + sizeof(uint16) + sizeof(aPickUpsCollected); INITSAVEBUF for (int32 i = 0; i < NUMPICKUPS; i++) { +#ifdef COMPATIBLE_SAVES + WriteSaveBuf(buf, aPickUps[i].m_eType); + WriteSaveBuf(buf, aPickUps[i].m_bRemoved); + WriteSaveBuf(buf, aPickUps[i].m_nQuantity); + int32 tmp = aPickUps[i].m_eType != PICKUP_NONE && aPickUps[i].m_pObject != nil ? CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(aPickUps[i].m_pObject) + 1 : 0; + WriteSaveBuf(buf, tmp); + WriteSaveBuf(buf, aPickUps[i].m_nTimer); + WriteSaveBuf(buf, aPickUps[i].m_eModelIndex); + WriteSaveBuf(buf, aPickUps[i].m_nIndex); + WriteSaveBuf(buf, aPickUps[i].m_vecPos); +#else CPickup *buf_pickup = WriteSaveBuf(buf, aPickUps[i]); if (buf_pickup->m_eType != PICKUP_NONE && buf_pickup->m_pObject != nil) buf_pickup->m_pObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(buf_pickup->m_pObject) + 1); +#endif } WriteSaveBuf(buf, CollectedPickUpIndex); -- cgit v1.2.3