summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build-cmake-conan.yml9
-rw-r--r--.github/workflows/re3_msvc_amd64.yml2
-rw-r--r--.github/workflows/re3_msvc_x86.yml2
-rw-r--r--README.md12
-rw-r--r--premake5.lua55
-rw-r--r--src/audio/AudioManager.cpp2
-rw-r--r--src/audio/sampman_oal.cpp12
-rw-r--r--src/control/OnscreenTimer.cpp122
-rw-r--r--src/core/Crime.h2
-rw-r--r--src/core/config.h10
-rw-r--r--src/peds/Ped.cpp53
-rw-r--r--src/peds/Ped.h2
-rw-r--r--src/peds/PedFight.cpp2
-rw-r--r--src/peds/PedIK.cpp4
-rw-r--r--src/peds/PedIK.h2
-rw-r--r--src/peds/PlayerPed.cpp4
-rw-r--r--src/save/SaveBuf.h18
-rw-r--r--src/weapons/Weapon.cpp4
m---------vendor/librw0
19 files changed, 200 insertions, 117 deletions
diff --git a/.github/workflows/build-cmake-conan.yml b/.github/workflows/build-cmake-conan.yml
index d8636175..5e8dad94 100644
--- a/.github/workflows/build-cmake-conan.yml
+++ b/.github/workflows/build-cmake-conan.yml
@@ -27,7 +27,7 @@ jobs:
platform: 'gl3'
gl3_gfxlib: 'glfw'
audio: 'openal'
-# - os: 'ubuntu-latest'
+# - os: 'ubuntu-18.04'
# platform: 'gl3'
# gl3_gfxlib: 'sdl2'
# audio: 'openal'
@@ -63,8 +63,9 @@ jobs:
python -m pip install conan
conan config init
conan config set log.print_run_commands=True
- conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
- conan remote add madebr_ps2dev https://api.bintray.com/conan/madebr/ps2dev
+ conan config set general.revisions_enabled=1
+ conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan
+# conan remote add madebr_ps2dev https://api.bintray.com/conan/madebr/ps2dev
- name: "Add os=playstation2 + gcc.version=3.2 to .conan/settings.yml"
shell: python
run: |
@@ -85,7 +86,7 @@ jobs:
fi
- name: "Export Playstation 2 CMake toolchain conan recipe"
run: |
- conan export vendor/librw/cmake/ps2toolchain ps2dev-cmaketoolchain/master@
+ conan export vendor/librw/cmake/ps2/cmaketoolchain ps2dev-cmaketoolchain/master@
- name: "Export librw conan recipe"
run: |
conan export vendor/librw librw/master@
diff --git a/.github/workflows/re3_msvc_amd64.yml b/.github/workflows/re3_msvc_amd64.yml
index 29ad024c..428da540 100644
--- a/.github/workflows/re3_msvc_amd64.yml
+++ b/.github/workflows/re3_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/re3.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=${{matrix.platform}}
diff --git a/.github/workflows/re3_msvc_x86.yml b/.github/workflows/re3_msvc_x86.yml
index 087b0d19..87f0e430 100644
--- a/.github/workflows/re3_msvc_x86.yml
+++ b/.github/workflows/re3_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/re3.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=${{matrix.platform}}
diff --git a/README.md b/README.md
index d49258eb..53b5a761 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
In this repository you'll find the fully reversed source code for GTA III ([master](https://github.com/GTAmodding/re3/tree/master/) branch) and GTA VC ([miami](https://github.com/GTAmodding/re3/tree/miami/) branch).
-It has been tested and works on Windows, Linux and FreeBSD, on x86, amd64, arm and arm64.\
+It has been tested and works on Windows, Linux, MacOS and FreeBSD, on x86, amd64, arm and arm64.\
Rendering is handled either by original RenderWare (D3D8)
or the reimplementation [librw](https://github.com/aap/librw) (D3D9, OpenGL 2.1 or above, OpenGL ES 2.0 or above).\
Audio is done with MSS (using dlls from original GTA) or OpenAL.
@@ -26,8 +26,8 @@ We cannot build for PS2 or Xbox yet. If you're interested in doing so, get in to
- [Windows D3D9 64bit](https://nightly.link/GTAmodding/re3/workflows/re3_msvc_amd64/master/re3_Release_win-amd64-librw_d3d9-oal.zip)
- [Windows OpenGL 64bit](https://nightly.link/GTAmodding/re3/workflows/re3_msvc_amd64/master/re3_Release_win-amd64-librw_gl3_glfw-oal.zip)
- [Linux 64bit](https://nightly.link/GTAmodding/re3/workflows/build-cmake-conan/master/ubuntu-18.04-gl3.zip)
- - [MacOS 64bit](https://nightly.link/GTAmodding/re3/workflows/build-cmake-conan/master/macos-latest-gl3.zip)
-- Extract the downloaded zip over your GTA 3 directory and run re3. The zip includes the gamefiles and in case of OpenAL the required dlls.
+ - [MacOS 64bit x86-64](https://nightly.link/GTAmodding/re3/workflows/build-cmake-conan/master/macos-latest-gl3.zip)
+- Extract the downloaded zip over your GTA 3 directory and run re3. The zip includes the binary, updated and additional gamefiles and in case of OpenAL the required dlls.
## Screenshots
@@ -115,6 +115,12 @@ conan build .. -if build -bf build -pf package
```
</details>
+<details><summary>MacOS Premake</summary>
+
+For MacOS using premake, proceed: [Building on MacOS](https://github.com/GTAmodding/re3/wiki/Building-on-MacOS)
+
+</details>
+
<details><summary>FreeBSD</summary>
For FreeBSD using premake, proceed: [Building on FreeBSD](https://github.com/GTAmodding/re3/wiki/Building-on-FreeBSD)
diff --git a/premake5.lua b/premake5.lua
index 7fc21907..72ff4d09 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -28,13 +28,18 @@ newoption {
}
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 "re3"
filter "configurations:not Debug"
defines { "NDEBUG" }
optimize "Speed"
- if(_OPTIONS["lto"]) then
+ if(_OPTIONS["with-lto"]) then
flags { "LinkTimeOptimization" }
end
@@ -142,12 +147,18 @@ workspace "re3"
filter { "platforms:*arm*" }
architecture "ARM"
- filter { "platforms:macosx-arm64-*" }
+ filter { "platforms:macosx-arm64-*", "files:**.cpp"}
buildoptions { "-target", "arm64-apple-macos11", "-std=gnu++14" }
- filter { "platforms:macosx-amd64-*" }
+ filter { "platforms:macosx-arm64-*", "files:**.c"}
+ buildoptions { "-target", "arm64-apple-macos11" }
+
+ filter { "platforms:macosx-amd64-*", "files:**.cpp"}
buildoptions { "-target", "x86_64-apple-macos10.12", "-std=gnu++14" }
+ filter { "platforms:macosx-amd64-*", "files:**.c"}
+ buildoptions { "-target", "x86_64-apple-macos10.12" }
+
filter { "platforms:*librw_d3d9*" }
defines { "RW_D3D9" }
if(not _OPTIONS["with-librw"]) then
@@ -207,13 +218,19 @@ project "librw"
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
- filter "platforms:macosx*"
- -- Support MacPorts and Homebrew
+ -- Support MacPorts and Homebrew
+ filter "platforms:macosx-arm64-*"
+ includedirs { "/opt/local/include" }
+ includedirs {"/opt/homebrew/include" }
+ libdirs { "/opt/local/lib" }
+ libdirs { "/opt/homebrew/lib" }
+
+ filter "platforms:macosx-amd64-*"
includedirs { "/opt/local/include" }
includedirs {"/usr/local/include" }
libdirs { "/opt/local/lib" }
libdirs { "/usr/local/lib" }
-
+
filter "platforms:*gl3_glfw*"
staticruntime "off"
@@ -327,6 +344,10 @@ project "re3"
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"
@@ -366,6 +387,12 @@ project "re3"
filter "platforms:macosx*oal"
links { "openal", "mpg123", "sndfile", "pthread" }
+
+ filter "platforms:macosx-arm64-*oal"
+ includedirs { "/opt/homebrew/opt/openal-soft/include" }
+ libdirs { "/opt/homebrew/opt/openal-soft/lib" }
+
+ filter "platforms:macosx-amd64-*oal"
includedirs { "/usr/local/opt/openal-soft/include" }
libdirs { "/usr/local/opt/openal-soft/lib" }
@@ -417,10 +444,18 @@ project "re3"
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
- filter "platforms:macosx*gl3_glfw*"
+ filter "platforms:macosx-arm64-*gl3_glfw*"
links { "glfw" }
linkoptions { "-framework OpenGL" }
includedirs { "/opt/local/include" }
- includedirs { "/usr/local/include" }
+ includedirs {"/opt/homebrew/include" }
+ libdirs { "/opt/local/lib" }
+ libdirs { "/opt/homebrew/lib" }
+
+ filter "platforms:macosx-amd64-*gl3_glfw*"
+ links { "glfw" }
+ linkoptions { "-framework OpenGL" }
+ includedirs { "/opt/local/include" }
+ includedirs {"/usr/local/include" }
libdirs { "/opt/local/lib" }
libdirs { "/usr/local/lib" }
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index a3bc6a01..2e391349 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -977,7 +977,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);
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index c566893a..7fb84965 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -1214,14 +1214,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
- int8 slot;
-
for ( int32 i = 0; i < _TODOCONST(3); i++ )
{
- slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
+ int8 slot = (int8)nCurrentPedSlot - i - 1;
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
+#else
+ uint8 slot = nCurrentPedSlot - i - 1;
#endif
if ( nComment == nPedSlotSfx[slot] )
return TRUE;
@@ -1234,14 +1234,14 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
int32
cSampleManager::_GetPedCommentSlot(uint32 nComment)
{
- int8 slot;
-
for (int32 i = 0; i < _TODOCONST(3); i++)
{
- slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
+ int8 slot = (int8)nCurrentPedSlot - i - 1;
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
+#else
+ uint8 slot = nCurrentPedSlot - i - 1;
#endif
if (nComment == nPedSlotSfx[slot])
return slot;
diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp
index 8cc1ae69..08c68cb5 100644
--- a/src/control/OnscreenTimer.cpp
+++ b/src/control/OnscreenTimer.cpp
@@ -8,112 +8,111 @@
#include "Script.h"
#include "OnscreenTimer.h"
-void COnscreenTimer::Init() {
+void
+COnscreenTimer::Init()
+{
m_bDisabled = false;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
m_sEntries[i].m_nTimerOffset = 0;
m_sEntries[i].m_nCounterOffset = 0;
for(uint32 j = 0; j < 10; j++) {
- m_sEntries[i].m_aTimerText[j] = 0;
- m_sEntries[i].m_aCounterText[j] = 0;
+ m_sEntries[i].m_aTimerText[j] = '\0';
+ m_sEntries[i].m_aCounterText[j] = '\0';
}
m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
- m_sEntries[i].m_bTimerProcessed = 0;
- m_sEntries[i].m_bCounterProcessed = 0;
+ m_sEntries[i].m_bTimerProcessed = false;
+ m_sEntries[i].m_bCounterProcessed = false;
}
}
-void COnscreenTimer::Process() {
- if(!CReplay::IsPlayingBack() && !m_bDisabled) {
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::Process()
+{
+ if(!CReplay::IsPlayingBack() && !m_bDisabled)
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
m_sEntries[i].Process();
- }
- }
}
-void COnscreenTimer::ProcessForDisplay() {
+void
+COnscreenTimer::ProcessForDisplay()
+{
if(CHud::m_Wants_To_Draw_Hud) {
m_bProcessed = false;
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
- if(m_sEntries[i].ProcessForDisplay()) {
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
+ if(m_sEntries[i].ProcessForDisplay())
m_bProcessed = true;
- }
- }
}
}
-void COnscreenTimer::ClearCounter(uint32 offset) {
+void
+COnscreenTimer::ClearCounter(uint32 offset)
+{
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
if(offset == m_sEntries[i].m_nCounterOffset) {
m_sEntries[i].m_nCounterOffset = 0;
- m_sEntries[i].m_aCounterText[0] = 0;
+ m_sEntries[i].m_aCounterText[0] = '\0';
m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
- m_sEntries[i].m_bCounterProcessed = 0;
+ m_sEntries[i].m_bCounterProcessed = false;
}
}
}
-void COnscreenTimer::ClearClock(uint32 offset) {
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::ClearClock(uint32 offset)
+{
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
if(offset == m_sEntries[i].m_nTimerOffset) {
m_sEntries[i].m_nTimerOffset = 0;
- m_sEntries[i].m_aTimerText[0] = 0;
- m_sEntries[i].m_bTimerProcessed = 0;
+ m_sEntries[i].m_aTimerText[0] = '\0';
+ m_sEntries[i].m_bTimerProcessed = false;
}
- }
}
-void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text) {
- uint32 i = 0;
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text)
+{
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
if(m_sEntries[i].m_nCounterOffset == 0) {
+ m_sEntries[i].m_nCounterOffset = offset;
+ if (text)
+ strncpy(m_sEntries[i].m_aCounterText, text, 10);
+ else
+ m_sEntries[i].m_aCounterText[0] = '\0';
+ m_sEntries[i].m_nType = type;
break;
}
- return;
- }
-
- m_sEntries[i].m_nCounterOffset = offset;
- if(text) {
- strncpy(m_sEntries[i].m_aCounterText, text, 10);
- } else {
- m_sEntries[i].m_aCounterText[0] = 0;
- }
-
- m_sEntries[i].m_nType = type;
}
-void COnscreenTimer::AddClock(uint32 offset, char* text) {
- uint32 i = 0;
- for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
+void
+COnscreenTimer::AddClock(uint32 offset, char* text)
+{
+ for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++)
if(m_sEntries[i].m_nTimerOffset == 0) {
+ m_sEntries[i].m_nTimerOffset = offset;
+ if (text)
+ strncpy(m_sEntries[i].m_aTimerText, text, 10);
+ else
+ m_sEntries[i].m_aTimerText[0] = '\0';
break;
}
- return;
- }
-
- m_sEntries[i].m_nTimerOffset = offset;
- if(text) {
- strncpy(m_sEntries[i].m_aTimerText, text, 10);
- } else {
- m_sEntries[i].m_aTimerText[0] = 0;
- }
}
-void COnscreenTimerEntry::Process() {
- if(m_nTimerOffset == 0) {
+void
+COnscreenTimerEntry::Process()
+{
+ if(m_nTimerOffset == 0)
return;
- }
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
int32 oldTime = *timerPtr;
int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds());
if(newTime < 0) {
*timerPtr = 0;
- m_bTimerProcessed = 0;
+ m_bTimerProcessed = false;
m_nTimerOffset = 0;
- m_aTimerText[0] = 0;
+ m_aTimerText[0] = '\0';
} else {
*timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000;
@@ -123,13 +122,14 @@ void COnscreenTimerEntry::Process() {
}
}
-bool COnscreenTimerEntry::ProcessForDisplay() {
+bool
+COnscreenTimerEntry::ProcessForDisplay()
+{
m_bTimerProcessed = false;
m_bCounterProcessed = false;
- if(m_nTimerOffset == 0 && m_nCounterOffset == 0) {
+ if(m_nTimerOffset == 0 && m_nCounterOffset == 0)
return false;
- }
if(m_nTimerOffset != 0) {
m_bTimerProcessed = true;
@@ -143,13 +143,17 @@ bool COnscreenTimerEntry::ProcessForDisplay() {
return true;
}
-void COnscreenTimerEntry::ProcessForDisplayClock() {
+void
+COnscreenTimerEntry::ProcessForDisplayClock()
+{
uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
sprintf(m_bTimerBuffer, "%02d:%02d", time / 1000 / 60,
time / 1000 % 60);
}
-void COnscreenTimerEntry::ProcessForDisplayCounter() {
+void
+COnscreenTimerEntry::ProcessForDisplayCounter()
+{
uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset);
sprintf(m_bCounterBuffer, "%d", counter);
}
diff --git a/src/core/Crime.h b/src/core/Crime.h
index 8dfae5b8..05829040 100644
--- a/src/core/Crime.h
+++ b/src/core/Crime.h
@@ -25,7 +25,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/core/config.h b/src/core/config.h
index a78aee22..2d1b75ae 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -380,12 +380,12 @@ enum Config {
#define CAMERA_PICKUP
// Peds
-#define PED_SKIN // support for skinned geometry on peds
+#define PED_SKIN // support for skinned geometry on peds, requires COMPATIBLE_SAVES
#define ANIMATE_PED_COL_MODEL
// #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle
// #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward
#define CANCELLABLE_CAR_ENTER
-//#define PEDS_REPORT_CRIMES_ON_PHONE
+//#define PEDS_REPORT_CRIMES_ON_PHONE, requires COMPATIBLE_SAVES
// Camera
//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes
@@ -430,6 +430,12 @@ enum Config {
#define VC_RAIN_NERF // Reduces number of rain particles
#endif
+// if these defines are enabled saves are not vanilla compatible without COMPATIBLE_SAVES
+#ifndef COMPATIBLE_SAVES
+#undef PED_SKIN
+#undef PEDS_REPORT_CRIMES_ON_PHONE
+#endif
+
// -------
#if defined __MWERKS__ || defined VANILLA_DEFINES
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 04e13c33..4d80cac2 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -308,6 +308,30 @@ CPed::~CPed(void)
m_pFire->Extinguish();
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
@@ -398,13 +422,15 @@ CPed::BuildPedLists(void)
} else
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
@@ -3023,7 +3049,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CColModel *hisCol = CModelInfo::GetModelInfo(collidingEnt->GetModelIndex())->GetColModel();
if (!bUsesCollision)
- return false;
+ return 0;
if (collidingEnt->IsVehicle() && ((CVehicle*)collidingEnt)->IsBoat())
collidedWithBoat = true;
@@ -6068,7 +6094,7 @@ CPed::FollowPath(void)
}
void
-CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
+CPed::SetEvasiveStep(CPhysical *reason, uint8 animType)
{
AnimationId stepAnim;
@@ -6086,22 +6112,23 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
if (neededTurn > PI)
neededTurn = TWOPI - neededTurn;
- CVehicle *veh = (CVehicle*)reason;
- if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR) {
+ 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"
@@ -6111,14 +6138,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 6d32b65e..33839aa7 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -625,7 +625,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*);
diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp
index c03d492a..46ac369c 100644
--- a/src/peds/PedFight.cpp
+++ b/src/peds/PedFight.cpp
@@ -1044,7 +1044,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
if (IsPlayer())
moveAssoc->speed = 1.3f;
- m_takeAStepAfterAttack = 0;
+ m_takeAStepAfterAttack = false;
m_fightButtonPressure = 0;
} else if (IsPlayer() && m_currentWeapon != WEAPONTYPE_UNARMED) {
CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f);
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index de2c23ce..8358a196 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 4eeef6f0..9077fbea 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;
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index a67e2abc..93a403bd 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -682,8 +682,8 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed)
if (padMove > 0.0f) {
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
- m_takeAStepAfterAttack = padMove > 2 * PAD_MOVE_TO_GAME_WORLD_MOVE;
- if (padUsed->GetSprint() && padMove > 1 * PAD_MOVE_TO_GAME_WORLD_MOVE)
+ m_takeAStepAfterAttack = padMove > (2 * PAD_MOVE_TO_GAME_WORLD_MOVE);
+ if (padUsed->GetSprint() && padMove > (1 * PAD_MOVE_TO_GAME_WORLD_MOVE))
bIsAttacking = false;
}
diff --git a/src/save/SaveBuf.h b/src/save/SaveBuf.h
index 1b79c956..98fe888b 100644
--- a/src/save/SaveBuf.h
+++ b/src/save/SaveBuf.h
@@ -47,15 +47,15 @@ WriteSaveBuf(uint8 *&buf, 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)
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index 5704c111..43a85db8 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -2266,7 +2266,11 @@ CWeapon::HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo)
void
CWeapon::BlowUpExplosiveThings(CEntity *thing)
{
+#ifdef FIX_BUGS
+ if ( thing && thing->IsObject() )
+#else
if ( thing )
+#endif
{
CObject *object = (CObject*)thing;
int32 mi = object->GetModelIndex();
diff --git a/vendor/librw b/vendor/librw
-Subproject af20de45226f5152a035866da32517466e81142
+Subproject a5bc97232293250ae1bbd6ef6642532a541034c