From 7e4c68382416229cf0a58637bd9f308a6def1caa Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 20 Apr 2020 01:04:57 +0300 Subject: fixes --- src/control/Pickups.cpp | 2 +- src/control/Script.cpp | 6 ------ src/core/Frontend.h | 2 +- src/core/templates.h | 4 ++++ 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index f9605ca6..1bf6d9ce 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -491,7 +491,7 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan int32 slot = 0; if (type == PICKUP_FLOATINGPACKAGE || type == PICKUP_NAUTICAL_MINE_INACTIVE) { - for (slot = NUMPICKUPS; slot >= 0; slot--) { + for (slot = NUMPICKUPS-1; slot >= 0; slot--) { if (aPickUps[slot].m_eType == PICKUP_NONE) { bFreeFound = true; break; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index bfe2de34..4707042d 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1675,13 +1675,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) return 0; } case COMMAND_GENERATE_RANDOM_INT: -#ifdef FIX_BUGS - // Not a very good fix but before switching to PS2 rand, it sort of works - *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) = CGeneral::GetRandomNumberInRange(0, 65535); -#else - /* On PC between 0 and 32767, even though script expects values between 0 and 65536 */ *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) = CGeneral::GetRandomNumber(); -#endif return 0; case COMMAND_CREATE_CHAR: { diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 9fb0756f..ce9861c8 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -644,4 +644,4 @@ public: static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error"); extern CMenuManager FrontEndMenuManager; -extern DWORD _dwOperatingSystemVersion; \ No newline at end of file +extern unsigned long _dwOperatingSystemVersion; \ No newline at end of file diff --git a/src/core/templates.h b/src/core/templates.h index a1627357..51a24e4c 100644 --- a/src/core/templates.h +++ b/src/core/templates.h @@ -104,6 +104,10 @@ public: return m_flags[i].free ? nil : (T*)&m_entries[i]; } T *GetAt(int handle){ +#ifdef FIX_BUGS + if (handle == -1) + return nil; +#endif return m_flags[handle>>8].u == (handle & 0xFF) ? (T*)&m_entries[handle >> 8] : nil; } -- cgit v1.2.3