summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2021-01-26 00:25:47 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2021-01-26 00:25:47 +0100
commit46e63da4d8e6b4c50a663e98d150bd83e0eefb83 (patch)
treee7a03e5010280216424260da796151cc8c235e15 /src
parentgarage stuff (diff)
parentMerge pull request #992 from ForeverL95/ForeverL95-patch-1 (diff)
downloadre3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.gz
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.bz2
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.lz
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.xz
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.zst
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.zip
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/animation/AnimBlendAssocGroup.cpp18
-rw-r--r--src/audio/AudioLogic.cpp6
-rw-r--r--src/audio/AudioManager.cpp2
-rw-r--r--src/audio/AudioManager.h2
-rw-r--r--src/audio/AudioSamples.h2
-rw-r--r--src/audio/MusicManager.cpp22
-rw-r--r--src/audio/PoliceRadio.cpp2
-rw-r--r--src/audio/sampman_miles.cpp3
-rw-r--r--src/audio/soundlist.h2
-rw-r--r--src/collision/ColModel.cpp11
-rw-r--r--src/collision/ColModel.h2
-rw-r--r--src/collision/Collision.cpp12
-rw-r--r--src/collision/TempColModels.cpp85
-rw-r--r--src/collision/TempColModels.h13
-rw-r--r--src/control/OnscreenTimer.cpp8
-rw-r--r--src/control/Pickups.h2
-rw-r--r--src/control/RoadBlocks.cpp4
-rw-r--r--src/control/Script.h334
-rw-r--r--src/control/Script5.cpp4
-rw-r--r--src/core/AnimViewer.cpp2
-rw-r--r--src/core/Cam.cpp4
-rw-r--r--src/core/CdStream.cpp11
-rw-r--r--src/core/ControllerConfig.cpp9
-rw-r--r--src/core/FileLoader.cpp43
-rw-r--r--src/core/Frontend.cpp2
-rw-r--r--src/core/Game.cpp5
-rw-r--r--src/core/General.h2
-rw-r--r--src/core/Leeds.cpp14
-rw-r--r--src/core/Leeds.h36
-rw-r--r--src/core/Placeable.h2
-rw-r--r--src/core/Radar.cpp11
-rw-r--r--src/core/Ropes.cpp4
-rw-r--r--src/core/Stats.h2
-rw-r--r--src/core/common.h68
-rw-r--r--src/core/config.h87
-rw-r--r--src/core/main.cpp24
-rw-r--r--src/core/main.h3
-rw-r--r--src/core/re3.cpp18
-rw-r--r--src/entities/Physical.cpp10
-rw-r--r--src/extras/custompipes.cpp2
-rw-r--r--src/extras/custompipes_d3d9.cpp3
-rw-r--r--src/fakerw/rpworld.h1
-rw-r--r--src/leeds/base/relocatableChunk.h2
-rw-r--r--src/modelinfo/BaseModelInfo.cpp82
-rw-r--r--src/modelinfo/BaseModelInfo.h22
-rw-r--r--src/modelinfo/ClumpModelInfo.cpp68
-rw-r--r--src/modelinfo/ClumpModelInfo.h9
-rw-r--r--src/modelinfo/PedModelInfo.cpp121
-rw-r--r--src/modelinfo/PedModelInfo.h10
-rw-r--r--src/modelinfo/SimpleModelInfo.cpp215
-rw-r--r--src/modelinfo/SimpleModelInfo.h37
-rw-r--r--src/modelinfo/TimeModelInfo.cpp29
-rw-r--r--src/modelinfo/TimeModelInfo.h9
-rw-r--r--src/modelinfo/VehicleModelInfo.cpp439
-rw-r--r--src/modelinfo/VehicleModelInfo.h32
-rw-r--r--src/modelinfo/WeaponModelInfo.cpp22
-rw-r--r--src/modelinfo/WeaponModelInfo.h10
-rw-r--r--src/peds/PedAI.cpp10
-rw-r--r--src/peds/PedAttractor.cpp46
-rw-r--r--src/peds/PedAttractor.h36
-rw-r--r--src/render/Draw.cpp2
-rw-r--r--src/render/Draw.h2
-rw-r--r--src/render/Font.h2
-rw-r--r--src/render/Glass.cpp2
-rw-r--r--src/render/Hud.cpp426
-rw-r--r--src/render/Hud.h14
-rw-r--r--src/render/Instance.h2
-rw-r--r--src/render/SpecialFX.cpp2
-rw-r--r--src/rw/VisibilityPlugins.cpp42
-rw-r--r--src/rw/VisibilityPlugins.h3
-rw-r--r--src/skel/crossplatform.h6
-rw-r--r--src/skel/glfw/glfw.cpp31
-rw-r--r--src/skel/win/win.cpp12
-rw-r--r--src/text/Text.cpp10
-rw-r--r--src/vehicles/Automobile.cpp4
-rw-r--r--src/vehicles/Boat.cpp2
-rw-r--r--src/vehicles/Heli.cpp2
-rw-r--r--src/vehicles/Vehicle.cpp6
-rw-r--r--src/weapons/Weapon.cpp2
-rw-r--r--src/weapons/WeaponInfo.cpp94
-rw-r--r--src/weapons/WeaponInfo.h1
82 files changed, 2091 insertions, 687 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ad72eb56..f3d51b06 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -79,6 +79,21 @@ endif()
target_compile_definitions(${EXECUTABLE} PRIVATE )
+option(${PROJECT}_WITH_SANITIZERS "Use UB sanitizers (better crash log)" OFF)
+option(${PROJECT}_WITH_ASAN "Use Address sanitizer (better crash log)" OFF)
+
+if(${PROJECT}_WITH_SANITIZERS)
+ target_compile_options(${EXECUTABLE} PUBLIC
+ -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability
+ -g3 -fno-omit-frame-pointer)
+ target_link_options(${EXECUTABLE} PUBLIC -fsanitize=undefined,float-divide-by-zero,integer,implicit-conversion,implicit-integer-truncation,implicit-integer-arithmetic-value-change,local-bounds,nullability)
+endif()
+
+if(${PROJECT}_WITH_ASAN)
+ target_compile_options(${EXECUTABLE} PUBLIC -fsanitize=address -g3 -fno-omit-frame-pointer)
+ target_link_options(${EXECUTABLE} PUBLIC -fsanitize=address)
+endif()
+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(${EXECUTABLE}
PRIVATE
diff --git a/src/animation/AnimBlendAssocGroup.cpp b/src/animation/AnimBlendAssocGroup.cpp
index 8fc2a8dc..7c0a10d4 100644
--- a/src/animation/AnimBlendAssocGroup.cpp
+++ b/src/animation/AnimBlendAssocGroup.cpp
@@ -1,7 +1,11 @@
#include "common.h"
#if defined _WIN32 && !defined __MINGW32__
+#if defined __MWERKS__
+#include <wctype.h>
+#else
#include "ctype.h"
+#endif
#else
#include <cwctype>
#endif
@@ -89,18 +93,18 @@ strcmpIgnoringDigits(const char *s1, const char *s2)
if(c1) s1++;
if(c2) s2++;
if(c1 == '\0' && c2 == '\0') return true;
-#if defined _WIN32 && !defined __MINGW32__
- if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2))
-#else
+#ifndef ASCII_STRCMP
if(iswdigit(c1) && iswdigit(c2))
+#else
+ if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2))
#endif
continue;
-#if defined _WIN32 && !defined __MINGW32__
- c1 = __ascii_toupper(c1);
- c2 = __ascii_toupper(c2);
-#else
+#ifndef ASCII_STRCMP
c1 = toupper(c1);
c2 = toupper(c2);
+#else
+ c1 = __ascii_toupper(c1);
+ c2 = __ascii_toupper(c2);
#endif
if(c1 && c2 && c1 != c2)
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 36b9eb11..457e09c0 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "AudioManager.h"
#include "audio_enums.h"
@@ -43,7 +43,7 @@
#include "Script.h"
#include "Wanted.h"
-const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
const int allChannels = channels + 2;
@@ -8115,7 +8115,7 @@ cAudioManager::ProcessWaterCannon(int32)
}
//positon of arcade machines
-CVector aVecExtraSoundPosition[] = { {-1042.546f, 88.794f, 11.324f}, {-1004.476f, 181.697f, 11.324f} };
+CVector aVecExtraSoundPosition[] = { CVector(-1042.546f, 88.794f, 11.324f), CVector(-1004.476f, 181.697f, 11.324f) };
void
cAudioManager::ProcessExtraSounds()
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 721a7acc..2304b4c4 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -14,7 +14,7 @@
cAudioManager AudioManager;
-const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
const int allChannels = channels + 2;
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index f715fb45..2eb2220b 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "audio_enums.h"
#include "AudioCollision.h"
diff --git a/src/audio/AudioSamples.h b/src/audio/AudioSamples.h
index 159809d0..403ef684 100644
--- a/src/audio/AudioSamples.h
+++ b/src/audio/AudioSamples.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "common.h"
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index 2a16dc14..0a28421d 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -1237,11 +1237,12 @@ cMusicManager::DisplayRadioStationName()
case RADIO_ESPANTOSO: string = TheText.Get("FEA_FM6"); break;
case EMOTION: string = TheText.Get("FEA_FM7"); break;
case WAVE: string = TheText.Get("FEA_FM8"); break;
- case USERTRACK:
+ case 9: string = TheText.Get("FEA_FM9"); break;
+ case 10:
if (!SampleManager.IsMP3RadioChannelAvailable())
return;
string = TheText.Get("FEA_MP3"); break;
- default: return;
+ default: string = TheText.Get("FEA_NON"); break;
};
if (pCurrentStation != string) {
@@ -1255,21 +1256,22 @@ cMusicManager::DisplayRadioStationName()
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
- CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
+ CFont::SetDropShadowPosition(2);
+ CFont::SetScale(PSP_SCREEN_SCALE_X(0.5f), PSP_SCREEN_SCALE_Y(0.88f));
CFont::SetPropOn();
- CFont::SetFontStyle(FONT_STANDARD);
+ CFont::SetFontStyle(FONT_BANK);
CFont::SetCentreOn();
- CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
- CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation);
+ CFont::SetCentreSize(PSP_SCREEN_SCALE_X(260.0f));
+ CFont::SetDropColor(CRGBA(0, 0, 0, 255));
if (gNumRetunePresses)
- CFont::SetColor(CRGBA(102, 133, 143, 255));
+ CFont::SetColor(CRGBA(77, 155, 210, 255));
else
- CFont::SetColor(CRGBA(147, 196, 211, 255));
+ CFont::SetColor(CRGBA(77, 155, 210, 255));
- CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_Y(22.0f), pCurrentStation);
+ CFont::PrintString(SCREEN_WIDTH / 2, PSP_SCREEN_SCALE_Y(7.0f), pCurrentStation);
CFont::DrawFonts();
+ CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
}
}
}
diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp
index edfb8a7c..b8f44f60 100644
--- a/src/audio/PoliceRadio.cpp
+++ b/src/audio/PoliceRadio.cpp
@@ -15,7 +15,7 @@
#include "sampman.h"
#include "Wanted.h"
-const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
+const int channels = ARRAY_SIZE(AudioManager.m_asActiveSamples);
const int policeChannel = channels + 1;
struct tPoliceRadioZone {
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index d78c6d84..bf91a874 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -1,3 +1,5 @@
+#include "common.h"
+
#ifdef AUDIO_MSS
#include <shlobj.h>
#include <shlguid.h>
@@ -8,7 +10,6 @@
#include "eax-util.h"
#include "mss.h"
-#include "common.h"
#include "sampman.h"
#include "AudioManager.h"
#include "MusicManager.h"
diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h
index 98982f61..4d88590e 100644
--- a/src/audio/soundlist.h
+++ b/src/audio/soundlist.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
enum eSound
{
diff --git a/src/collision/ColModel.cpp b/src/collision/ColModel.cpp
index 49847dbd..2de7f736 100644
--- a/src/collision/ColModel.cpp
+++ b/src/collision/ColModel.cpp
@@ -7,6 +7,8 @@
CColModel::CColModel(void)
{
+ boundingSphere.Set(0.0001f, CVector(0.0f, 0.0f, 0.0f));
+ boundingBox.Set(CVector(0.0f, 0.0f, 0.0f), CVector(0.0f, 0.0f, 0.0f));
numSpheres = 0;
spheres = nil;
numLines = 0;
@@ -18,7 +20,7 @@ CColModel::CColModel(void)
triangles = nil;
trianglePlanes = nil;
level = LEVEL_GENERIC; // generic col slot
- ownsCollisionVolumes = true;
+// ownsCollisionVolumes = true;
}
CColModel::~CColModel(void)
@@ -204,3 +206,10 @@ CColModel::operator=(const CColModel &other)
}
return *this;
}
+
+bool
+CColModel::Write(base::cRelocatableChunkWriter &writer, bool allocSpace)
+{
+ assert(0 && "TODO(LCS)");
+ return 1;
+}
diff --git a/src/collision/ColModel.h b/src/collision/ColModel.h
index cd5ae651..c58a4d9b 100644
--- a/src/collision/ColModel.h
+++ b/src/collision/ColModel.h
@@ -36,4 +36,6 @@ struct CColModel
void *operator new(size_t);
void operator delete(void *p, size_t);
CColModel& operator=(const CColModel& other);
+
+ bool Write(base::cRelocatableChunkWriter &writer, bool allocSpace);
}; \ No newline at end of file
diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp
index 45a15628..bead5183 100644
--- a/src/collision/Collision.cpp
+++ b/src/collision/Collision.cpp
@@ -2099,12 +2099,12 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin
float dot = DotProduct(*point - *l0, *l1 - *l0);
// Between 0 and len we're above the line.
// if not, calculate distance to endpoint
- if(dot <= 0.0f)
- return (*point - *l0).Magnitude();
- if(dot >= lensq)
- return (*point - *l1).Magnitude();
+ if(dot <= 0.0f) return (*point - *l0).Magnitude();
+ if(dot >= lensq) return (*point - *l1).Magnitude();
// distance to line
- return Sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq);
+ float distSqr = (*point - *l0).MagnitudeSqr() - dot * dot / lensq;
+ if(distSqr <= 0.f) return 0.f;
+ return Sqrt(distSqr);
}
// same as above but also return the point on the line
@@ -2571,4 +2571,4 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel,
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
-} \ No newline at end of file
+}
diff --git a/src/collision/TempColModels.cpp b/src/collision/TempColModels.cpp
index 32f2285c..148b86fe 100644
--- a/src/collision/TempColModels.cpp
+++ b/src/collision/TempColModels.cpp
@@ -1,11 +1,12 @@
#include "common.h"
+#include "main.h"
#include "TempColModels.h"
#include "Game.h"
-CColModel CTempColModels::ms_colModelPed1;
+// LCS: haven't yet checked the numbers but they probably haven't changed
+
CColModel CTempColModels::ms_colModelPed2;
-CColModel CTempColModels::ms_colModelBBox;
CColModel CTempColModels::ms_colModelBumper1;
CColModel CTempColModels::ms_colModelWheel1;
CColModel CTempColModels::ms_colModelPanel1;
@@ -16,7 +17,9 @@ CColModel CTempColModels::ms_colModelPedGroundHit;
CColModel CTempColModels::ms_colModelBoot1;
CColModel CTempColModels::ms_colModelDoor1;
CColModel CTempColModels::ms_colModelBonnet1;
-CColModel CTempColModels::ms_colModelWeapon;
+CColModel CTempColModels::ms_colModelFerryDocked;
+
+CTempColModels *gpTempColModels;
CColSphere s_aPedSpheres[3];
@@ -34,6 +37,7 @@ CColSphere s_aBootSpheres[4];
CColSphere s_aWheelSpheres[2];
CColSphere s_aBodyPartSpheres1[2];
CColSphere s_aBodyPartSpheres2[2];
+CColBox S_aFerryDockedBoxes[1];
void
CTempColModels::Initialise(void)
@@ -44,11 +48,26 @@ CTempColModels::Initialise(void)
colmodel.level = LEVEL_GENERIC;\
colmodel.ownsCollisionVolumes = false;
- int i;
+ if(gMakeResources){
+ if(gpTempColModels == nil){
+ gpTempColModels = new CTempColModels;
+ gpTempColModels->Initialise();
+ return;
+ }
+
+ ms_colModelBBox.boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f));
+ ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f));
+ ms_colModelBBox.level = LEVEL_GENERIC;
- ms_colModelBBox.boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f));
- ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f));
- ms_colModelBBox.level = LEVEL_GENERIC;
+ ms_colModelPed1.boundingSphere.Set(1.25f, CVector(0.0f, 0.0f, 0.0f));
+ ms_colModelPed1.boundingBox.Set(CVector(-0.35f, -0.35f, -1.0f), CVector(0.35f, 0.35f, 0.9f));
+ SET_COLMODEL_SPHERES(ms_colModelPed1, s_aPedSpheres);
+
+ ms_colModelWeapon.boundingSphere.Set(0.25f, CVector(0.0f, 0.0f, 0.0f));
+ ms_colModelWeapon.boundingBox.Set(CVector(-0.25f, -0.25f, -0.25f), CVector(0.25f, 0.25f, 0.25f));
+ }
+
+ int i;
for (i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++) {
ms_colModelCutObj[i].boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f));
@@ -74,10 +93,6 @@ CTempColModels::Initialise(void)
s_aPedSpheres[i].piece = 0;
}
- ms_colModelPed1.boundingSphere.Set(1.25f, CVector(0.0f, 0.0f, 0.0f));
- ms_colModelPed1.boundingBox.Set(CVector(-0.35f, -0.35f, -1.0f), CVector(0.35f, 0.35f, 0.9f));
- SET_COLMODEL_SPHERES(ms_colModelPed1, s_aPedSpheres);
-
// Ped 2 Spheres
s_aPed2Spheres[0].radius = 0.3f;
@@ -294,13 +309,47 @@ CTempColModels::Initialise(void)
SET_COLMODEL_SPHERES(ms_colModelBodyPart2, s_aBodyPartSpheres2);
- ms_colModelWeapon.boundingSphere.radius = 0.25f;
- ms_colModelWeapon.boundingBox.min.x = -0.25f;
- ms_colModelWeapon.boundingBox.min.y = -0.25f;
- ms_colModelWeapon.boundingBox.min.z = -0.25f;
- ms_colModelWeapon.boundingBox.max.x = 0.25f;
- ms_colModelWeapon.boundingBox.max.y = 0.25f;
- ms_colModelWeapon.boundingBox.max.z = 0.25f;
+ // Ferry Docked
+
+ S_aFerryDockedBoxes[0].Set(CVector(-6.3f, -22.78f, -2.0f), CVector(6.3f, 22.78f, 2.8f), SURFACE_THICK_METAL_PLATE, SURFACE_DEFAULT);
+
+ ms_colModelFerryDocked.boundingSphere.Set(35.0f, CVector(0.0f, -0.0f, 0.0f));
+ ms_colModelFerryDocked.boundingBox.Set(S_aFerryDockedBoxes[0].min, S_aFerryDockedBoxes[0].max);
+ ms_colModelFerryDocked.spheres = nil;
+ ms_colModelFerryDocked.numSpheres = 0;
+ ms_colModelFerryDocked.boxes = S_aFerryDockedBoxes;
+ ms_colModelFerryDocked.numBoxes = ARRAY_SIZE(S_aFerryDockedBoxes);
+ ms_colModelFerryDocked.level = LEVEL_GENERIC;
+
#undef SET_COLMODEL_SPHERES
}
+
+void
+CTempColModels::Write(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), 0x10, false, true);
+
+ ms_colModelBBox.Write(writer, false);
+ writer.AddPatch(&ms_colModelBBox);
+
+ ms_colModelPed1.Write(writer, false);
+ writer.AddPatch(&ms_colModelPed1);
+
+ ms_colModelWeapon.Write(writer, false);
+ writer.AddPatch(&ms_colModelWeapon);
+
+ for(int i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++)
+ ms_colModelCutObj[i].Write(writer, true);
+ ms_colModelPed2.Write(writer, true);
+ ms_colModelPedGroundHit.Write(writer, true);
+ ms_colModelDoor1.Write(writer, true);
+ ms_colModelBumper1.Write(writer, true);
+ ms_colModelPanel1.Write(writer, true);
+ ms_colModelBonnet1.Write(writer, true);
+ ms_colModelBoot1.Write(writer, true);
+ ms_colModelWheel1.Write(writer, true);
+ ms_colModelBodyPart1.Write(writer, true);
+ ms_colModelBodyPart2.Write(writer, true);
+ ms_colModelFerryDocked.Write(writer, true);
+}
diff --git a/src/collision/TempColModels.h b/src/collision/TempColModels.h
index e8a39695..0f1f06c3 100644
--- a/src/collision/TempColModels.h
+++ b/src/collision/TempColModels.h
@@ -5,9 +5,11 @@
class CTempColModels
{
public:
- static CColModel ms_colModelPed1;
+ CColModel ms_colModelPed1;
+ CColModel ms_colModelBBox;
+ CColModel ms_colModelWeapon;
+
static CColModel ms_colModelPed2;
- static CColModel ms_colModelBBox;
static CColModel ms_colModelBumper1;
static CColModel ms_colModelWheel1;
static CColModel ms_colModelPanel1;
@@ -18,7 +20,10 @@ public:
static CColModel ms_colModelBoot1;
static CColModel ms_colModelDoor1;
static CColModel ms_colModelBonnet1;
- static CColModel ms_colModelWeapon;
+ static CColModel ms_colModelFerryDocked;
- static void Initialise(void);
+ void Initialise(void);
+ void Write(base::cRelocatableChunkWriter &writer);
};
+
+extern CTempColModels *gpTempColModels;
diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp
index 08e6fa3f..53ed14c7 100644
--- a/src/control/OnscreenTimer.cpp
+++ b/src/control/OnscreenTimer.cpp
@@ -14,7 +14,7 @@ void COnscreenTimer::Init() {
for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) {
m_sCounters[i].m_nCounterOffset = 0;
- for(uint32 j = 0; j < ARRAY_SIZE(COnscreenCounterEntry::m_aCounterText); j++) {
+ for(uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText); j++) {
m_sCounters[i].m_aCounterText[j] = 0;
}
@@ -24,7 +24,7 @@ void COnscreenTimer::Init() {
for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) {
m_sClocks[i].m_nClockOffset = 0;
- for(uint32 j = 0; j < ARRAY_SIZE(COnscreenTimerEntry::m_aClockText); j++) {
+ for(uint32 j = 0; j < ARRAY_SIZE(m_sClocks[0].m_aClockText); j++) {
m_sClocks[i].m_aClockText[j] = 0;
}
@@ -92,7 +92,7 @@ void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 p
m_sCounters[pos].m_nCounterOffset = offset;
if(text) {
- strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(COnscreenCounterEntry::m_aCounterText));
+ strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(m_sCounters[0].m_aCounterText));
} else {
m_sCounters[pos].m_aCounterText[0] = 0;
}
@@ -114,7 +114,7 @@ void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) {
m_sClocks[i].m_nClockOffset = offset;
m_sClocks[i].m_bClockGoingDown = bGoingDown;
if(text) {
- strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(COnscreenTimerEntry::m_aClockText));
+ strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(m_sClocks[0].m_aClockText));
} else {
m_sClocks[i].m_aClockText[0] = 0;
}
diff --git a/src/control/Pickups.h b/src/control/Pickups.h
index 08fb2bc8..fd8b15cd 100644
--- a/src/control/Pickups.h
+++ b/src/control/Pickups.h
@@ -147,7 +147,7 @@ public:
class CPacManPickups
{
- friend CPacManPickup;
+ friend class CPacManPickup;
static CPacManPickup aPMPickUps[NUMPACMANPICKUPS];
static CVector LastPickUpCoors;
diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp
index f75b4f50..4f714e80 100644
--- a/src/control/RoadBlocks.cpp
+++ b/src/control/RoadBlocks.cpp
@@ -55,8 +55,8 @@ CRoadBlocks::Init(void)
void
CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType)
{
- static const CVector vecRoadBlockOffets[6] = { {-1.5, 1.8f, 0.0f}, {-1.5f, -1.8f, 0.0f}, {1.5f, 1.8f, 0.0f},
- {1.5f, -1.8f, 0.0f}, {-1.5f, 0.0f, 0.0f}, {1.5, 0.0, 0.0} };
+ static const CVector vecRoadBlockOffets[6] = { CVector(-1.5, 1.8f, 0.0f), CVector(-1.5f, -1.8f, 0.0f), CVector(1.5f, 1.8f, 0.0f),
+ CVector(1.5f, -1.8f, 0.0f), CVector(-1.5f, 0.0f, 0.0f), CVector(1.5, 0.0, 0.0) };
CEntity* pEntityToAttack = (CEntity*)FindPlayerVehicle();
if (!pEntityToAttack)
pEntityToAttack = (CEntity*)FindPlayerPed();
diff --git a/src/control/Script.h b/src/control/Script.h
index 11c1b185..8b54f28f 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -289,6 +289,173 @@ struct script_corona
int flareType;
};
+class CRunningScript
+{
+ enum {
+ ANDOR_NONE = 0,
+ ANDS_1 = 1,
+ ANDS_2,
+ ANDS_3,
+ ANDS_4,
+ ANDS_5,
+ ANDS_6,
+ ANDS_7,
+ ANDS_8,
+ ORS_1 = 21,
+ ORS_2,
+ ORS_3,
+ ORS_4,
+ ORS_5,
+ ORS_6,
+ ORS_7,
+ ORS_8
+ };
+
+ enum {
+ STACKVALUE_IP_BITS = 22,
+ STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS,
+ STACKVALUE_IS_FUNCTION_CALL_BIT,
+ STACKVALUE_IP_PARAMS_OFFSET,
+
+ STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1)
+ };
+
+public:
+ CRunningScript* next;
+ CRunningScript* prev;
+ int32 m_nId;
+ char m_abScriptName[8];
+ uint32 m_nIp;
+ uint32 m_anStack[MAX_STACK_DEPTH];
+ uint16 m_nStackPointer;
+ int32 m_anLocalVariables[NUM_LOCAL_VARS + 8 + NUM_TIMERS]; // TODO(LCS): figure out why 106
+ int32 m_nLocalsPointer;
+ bool m_bIsActive;
+ bool m_bCondResult;
+ bool m_bIsMissionScript;
+ bool m_bSkipWakeTime;
+ uint32 m_nWakeTime;
+ uint16 m_nAndOrState;
+ bool m_bNotFlag;
+ bool m_bDeatharrestEnabled;
+ bool m_bDeatharrestExecuted;
+ bool m_bMissionFlag;
+
+public:
+ void SetIP(uint32 ip) { m_nIp = ip; }
+ CRunningScript* GetNext() const { return next; }
+
+ void Save(uint8*& buf);
+ void Load(uint8*& buf);
+
+ void UpdateTimers(float timeStep) {
+ for (int i = 0; i < NUM_TIMERS; i++)
+ m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep;
+ }
+
+ void Init();
+ void Process();
+
+ void RemoveScriptFromList(CRunningScript**);
+ void AddScriptToList(CRunningScript**);
+
+ static const uint32 nSaveStructSize;
+
+ void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams);
+ int32 CollectNextParameterWithoutIncreasingPC(uint32);
+ int32* GetPointerToScriptVariable(uint32*, int16);
+ void StoreParameters(uint32*, int16);
+
+ int8 ProcessOneCommand();
+ void DoDeatharrestCheck();
+ void UpdateCompareFlag(bool flag)
+ {
+ if (m_bNotFlag)
+ flag = !flag;
+ if (m_nAndOrState == ANDOR_NONE) {
+ m_bCondResult = flag;
+ return;
+ }
+ if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) {
+ m_bCondResult &= flag;
+ if (m_nAndOrState == ANDS_1) {
+ m_nAndOrState = ANDOR_NONE;
+ return;
+ }
+ }
+ else {
+ m_bCondResult |= flag;
+ if (m_nAndOrState <= ORS_1) {
+ m_nAndOrState = ANDOR_NONE;
+ return;
+ }
+ }
+ m_nAndOrState--;
+ }
+ int16 GetPadState(uint16, uint16);
+
+ int8 ProcessCommands0To99(int32);
+ int8 ProcessCommands100To199(int32);
+ int8 ProcessCommands200To299(int32);
+ int8 ProcessCommands300To399(int32);
+ int8 ProcessCommands400To499(int32);
+ int8 ProcessCommands500To599(int32);
+ int8 ProcessCommands600To699(int32);
+ int8 ProcessCommands700To799(int32);
+ int8 ProcessCommands800To899(int32);
+ int8 ProcessCommands900To999(int32);
+ int8 ProcessCommands1000To1099(int32);
+ int8 ProcessCommands1100To1199(int32);
+ int8 ProcessCommands1200To1299(int32);
+ int8 ProcessCommands1300To1399(int32);
+ int8 ProcessCommands1400To1499(int32);
+ int8 ProcessCommands1500To1599(int32);
+ int8 ProcessCommands1600To1699(int32);
+
+ uint32 CollectLocateParameters(uint32*, bool);
+ void LocatePlayerCommand(int32, uint32*);
+ void LocatePlayerCharCommand(int32, uint32*);
+ void LocatePlayerCarCommand(int32, uint32*);
+ void LocateCharCommand(int32, uint32*);
+ void LocateCharCharCommand(int32, uint32*);
+ void LocateCharCarCommand(int32, uint32*);
+ void LocateCharObjectCommand(int32, uint32*);
+ void LocateCarCommand(int32, uint32*);
+ void LocateSniperBulletCommand(int32, uint32*);
+ void PlayerInAreaCheckCommand(int32, uint32*);
+ void PlayerInAngledAreaCheckCommand(int32, uint32*);
+ void CharInAreaCheckCommand(int32, uint32*);
+ void CarInAreaCheckCommand(int32, uint32*);
+ void LocateObjectCommand(int32, uint32*);
+ void ObjectInAreaCheckCommand(int32, uint32*);
+
+#ifdef GTA_SCRIPT_COLLECTIVE
+ void LocateCollectiveCommand(int32, uint32*);
+ void LocateCollectiveCharCommand(int32, uint32*);
+ void LocateCollectiveCarCommand(int32, uint32*);
+ void LocateCollectivePlayerCommand(int32, uint32*);
+ void CollectiveInAreaCheckCommand(int32, uint32*);
+#endif
+
+#ifdef MISSION_REPLAY
+ bool CanAllowMissionReplay();
+#endif
+
+#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+ int CollectParameterForDebug(char* buf, bool& var);
+ void GetStoredParameterForDebug(char* buf);
+#endif
+
+ float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
+
+ bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami);
+ bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal);
+ bool CheckDamagedWeaponType(int32 actual, int32 type);
+
+ void ReturnFromGosubOrFunction();
+
+};
+
enum {
VAR_LOCAL = 1,
@@ -494,173 +661,6 @@ extern int ScriptParams[32];
VALIDATE_SIZE(uStackReturnValue, 4);
-class CRunningScript
-{
- enum {
- ANDOR_NONE = 0,
- ANDS_1 = 1,
- ANDS_2,
- ANDS_3,
- ANDS_4,
- ANDS_5,
- ANDS_6,
- ANDS_7,
- ANDS_8,
- ORS_1 = 21,
- ORS_2,
- ORS_3,
- ORS_4,
- ORS_5,
- ORS_6,
- ORS_7,
- ORS_8
- };
-
- enum {
- STACKVALUE_IP_BITS = 22,
- STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS,
- STACKVALUE_IS_FUNCTION_CALL_BIT,
- STACKVALUE_IP_PARAMS_OFFSET,
-
- STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1)
- };
-
-public:
- CRunningScript* next;
- CRunningScript* prev;
- int32 m_nId;
- char m_abScriptName[8];
- uint32 m_nIp;
- uint32 m_anStack[MAX_STACK_DEPTH];
- uint16 m_nStackPointer;
- int32 m_anLocalVariables[NUM_LOCAL_VARS + 8 + NUM_TIMERS]; // TODO(LCS): figure out why 106
- int32 m_nLocalsPointer;
- bool m_bIsActive;
- bool m_bCondResult;
- bool m_bIsMissionScript;
- bool m_bSkipWakeTime;
- uint32 m_nWakeTime;
- uint16 m_nAndOrState;
- bool m_bNotFlag;
- bool m_bDeatharrestEnabled;
- bool m_bDeatharrestExecuted;
- bool m_bMissionFlag;
-
-public:
- void SetIP(uint32 ip) { m_nIp = ip; }
- CRunningScript* GetNext() const { return next; }
-
- void Save(uint8*& buf);
- void Load(uint8*& buf);
-
- void UpdateTimers(float timeStep) {
- for (int i = 0; i < NUM_TIMERS; i++)
- m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep;
- }
-
- void Init();
- void Process();
-
- void RemoveScriptFromList(CRunningScript**);
- void AddScriptToList(CRunningScript**);
-
- static const uint32 nSaveStructSize;
-
- void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams);
- int32 CollectNextParameterWithoutIncreasingPC(uint32);
- int32* GetPointerToScriptVariable(uint32*, int16);
- void StoreParameters(uint32*, int16);
-
- int8 ProcessOneCommand();
- void DoDeatharrestCheck();
- void UpdateCompareFlag(bool flag)
- {
- if (m_bNotFlag)
- flag = !flag;
- if (m_nAndOrState == ANDOR_NONE) {
- m_bCondResult = flag;
- return;
- }
- if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) {
- m_bCondResult &= flag;
- if (m_nAndOrState == ANDS_1) {
- m_nAndOrState = ANDOR_NONE;
- return;
- }
- }
- else {
- m_bCondResult |= flag;
- if (m_nAndOrState <= ORS_1) {
- m_nAndOrState = ANDOR_NONE;
- return;
- }
- }
- m_nAndOrState--;
- }
- int16 GetPadState(uint16, uint16);
-
- int8 ProcessCommands0To99(int32);
- int8 ProcessCommands100To199(int32);
- int8 ProcessCommands200To299(int32);
- int8 ProcessCommands300To399(int32);
- int8 ProcessCommands400To499(int32);
- int8 ProcessCommands500To599(int32);
- int8 ProcessCommands600To699(int32);
- int8 ProcessCommands700To799(int32);
- int8 ProcessCommands800To899(int32);
- int8 ProcessCommands900To999(int32);
- int8 ProcessCommands1000To1099(int32);
- int8 ProcessCommands1100To1199(int32);
- int8 ProcessCommands1200To1299(int32);
- int8 ProcessCommands1300To1399(int32);
- int8 ProcessCommands1400To1499(int32);
- int8 ProcessCommands1500To1599(int32);
- int8 ProcessCommands1600To1699(int32);
-
- uint32 CollectLocateParameters(uint32*, bool);
- void LocatePlayerCommand(int32, uint32*);
- void LocatePlayerCharCommand(int32, uint32*);
- void LocatePlayerCarCommand(int32, uint32*);
- void LocateCharCommand(int32, uint32*);
- void LocateCharCharCommand(int32, uint32*);
- void LocateCharCarCommand(int32, uint32*);
- void LocateCharObjectCommand(int32, uint32*);
- void LocateCarCommand(int32, uint32*);
- void LocateSniperBulletCommand(int32, uint32*);
- void PlayerInAreaCheckCommand(int32, uint32*);
- void PlayerInAngledAreaCheckCommand(int32, uint32*);
- void CharInAreaCheckCommand(int32, uint32*);
- void CarInAreaCheckCommand(int32, uint32*);
- void LocateObjectCommand(int32, uint32*);
- void ObjectInAreaCheckCommand(int32, uint32*);
-
-#ifdef GTA_SCRIPT_COLLECTIVE
- void LocateCollectiveCommand(int32, uint32*);
- void LocateCollectiveCharCommand(int32, uint32*);
- void LocateCollectiveCarCommand(int32, uint32*);
- void LocateCollectivePlayerCommand(int32, uint32*);
- void CollectiveInAreaCheckCommand(int32, uint32*);
-#endif
-
-#ifdef MISSION_REPLAY
- bool CanAllowMissionReplay();
-#endif
-
-#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
- int CollectParameterForDebug(char* buf, bool& var);
- void GetStoredParameterForDebug(char* buf);
-#endif
-
- float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
-
- bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami);
- bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal);
- bool CheckDamagedWeaponType(int32 actual, int32 type);
-
- void ReturnFromGosubOrFunction();
-
-};
-
#ifdef USE_DEBUG_SCRIPT_LOADER
extern int scriptToLoad;
#endif
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index 74d187ca..502bc005 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -2665,7 +2665,7 @@ bool CTheScripts::IsPedStopped(CPed* pPed)
{
if (pPed->InVehicle())
return IsVehicleStopped(pPed->m_pMyVehicle);
- return (pPed->m_nMoveState == eMoveState::PEDMOVE_NONE || pPed->m_nMoveState == eMoveState::PEDMOVE_STILL) &&
+ return (pPed->m_nMoveState == PEDMOVE_NONE || pPed->m_nMoveState == PEDMOVE_STILL) &&
!pPed->bIsInTheAir && !pPed->bIsLanding && pPed->bIsStanding && pPed->m_vecAnimMoveDelta.x == 0.0f && pPed->m_vecAnimMoveDelta.y == 0.0f;
}
@@ -2679,7 +2679,7 @@ bool CTheScripts::IsPlayerStopped(CPlayerInfo* pPlayer)
RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_JUMP_LAUNCH) ||
RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_JUMP_GLIDE))
return false;
- return (pPed->m_nMoveState == eMoveState::PEDMOVE_NONE || pPed->m_nMoveState == eMoveState::PEDMOVE_STILL) &&
+ return (pPed->m_nMoveState == PEDMOVE_NONE || pPed->m_nMoveState == PEDMOVE_STILL) &&
!pPed->bIsInTheAir && !pPed->bIsLanding && pPed->bIsStanding && pPed->m_vecAnimMoveDelta.x == 0.0f && pPed->m_vecAnimMoveDelta.y == 0.0f;
}
diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp
index 854ec7d4..1a7facc1 100644
--- a/src/core/AnimViewer.cpp
+++ b/src/core/AnimViewer.cpp
@@ -81,7 +81,7 @@ CAnimViewer::Initialise(void) {
CCollision::Init();
CWorld::Initialise();
mod_HandlingManager.Initialise();
- CTempColModels::Initialise();
+ gpTempColModels->Initialise();
CAnimManager::Initialise();
CModelInfo::Initialise();
CParticle::Initialise();
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 753254e0..4895ef6e 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -951,7 +951,7 @@ CVector
CCam::DoAverageOnVector(const CVector &vec)
{
int i;
- CVector Average = { 0.0f, 0.0f, 0.0f };
+ CVector Average = CVector(0.0f, 0.0f, 0.0f);
if(ResetStatics){
m_iRunningVectorArrayPos = 0;
@@ -4033,7 +4033,7 @@ CCam::Process_Debug(const CVector&, float, float, float)
if(CPad::GetPad(1)->GetLeftShockJustDown() && gbBigWhiteDebugLightSwitchedOn)
CShadows::StoreShadowToBeRendered(SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &Source,
12.0f, 0.0f, 0.0f, -12.0f,
- 128, 128, 128, 128, 1000.0f, false, 1.0f);
+ 128, 128, 128, 128, 1000.0f, false, 1.0f, nil, 1.0f);
if(CHud::m_Wants_To_Draw_Hud){
char str[256];
diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp
index 4bb31ea4..da85a238 100644
--- a/src/core/CdStream.cpp
+++ b/src/core/CdStream.cpp
@@ -7,9 +7,6 @@
#include "RwHelper.h"
#include "MemoryMgr.h"
-#define CDDEBUG(f, ...) debug ("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-#define CDTRACE(f, ...) printf("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-
struct CdReadInfo
{
uint32 nSectorOffset;
@@ -60,7 +57,7 @@ CdStreamInitThread(void)
if ( gpReadInfo[i].hSemaphore == nil )
{
- CDTRACE("failed to create sync semaphore");
+ printf("%s: failed to create sync semaphore\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -81,7 +78,7 @@ CdStreamInitThread(void)
if ( gCdStreamSema == nil )
{
- CDTRACE("failed to create stream semaphore");
+ printf("%s: failed to create stream semaphore\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -90,7 +87,7 @@ CdStreamInitThread(void)
if ( _gCdStreamThread == nil )
{
- CDTRACE("failed to create streaming thread");
+ printf("%s: failed to create streaming thread\n", "cdvd_stream");
ASSERT(0);
return;
}
@@ -138,7 +135,7 @@ CdStreamInit(int32 numChannels)
gpReadInfo = (CdReadInfo *)LocalAlloc(LMEM_ZEROINIT, sizeof(CdReadInfo) * numChannels);
ASSERT( gpReadInfo != nil );
- CDDEBUG("read info %p", gpReadInfo);
+ debug("%s: read info %p\n", "cdvd_stream", gpReadInfo);
CdStreamAddImage("MODELS\\GTA3.IMG");
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index fcc4503a..23e86a79 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -541,7 +541,7 @@ void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown(int32 button, i
break;
case 12:
#ifndef REGISTER_START_BUTTON
- if (padNumber == 1)
+ if (padnumber == 1)
#endif
pad->PCTempJoyState.Start = 255;
break;
@@ -2755,9 +2755,10 @@ wchar *CControllerConfigManager::GetButtonComboText(e_ControllerAction action)
void CControllerConfigManager::SetControllerKeyAssociatedWithAction(e_ControllerAction action, int32 key, eControllerType type)
{
ResetSettingOrder(action);
+ int numOfSettings = GetNumOfSettingsForAction(action);
m_aSettings[action][type].m_Key = key;
- m_aSettings[action][type].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+ m_aSettings[action][type].m_ContSetOrder = numOfSettings + 1;
}
int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerAction action)
@@ -2767,8 +2768,10 @@ int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerA
void CControllerConfigManager::SetMouseButtonAssociatedWithAction(e_ControllerAction action, int32 button)
{
+ int numOfSettings = GetNumOfSettingsForAction(action);
+
m_aSettings[action][MOUSE].m_Key = button;
- m_aSettings[action][MOUSE].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+ m_aSettings[action][MOUSE].m_ContSetOrder = numOfSettings + 1;
}
void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action)
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index c13252f6..2818007b 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -607,11 +607,14 @@ CFileLoader::LoadObjectTypes(const char *filename)
int section;
int pathIndex;
int id, pathType;
- int minID, maxID;
+ //int minID, maxID;
+
+ for(int i = 0; i < ARRAY_SIZE(m_sTempIdeData); i++)
+ m_sTempIdeData[i].id = -1;
section = NONE;
- minID = INT32_MAX;
- maxID = -1;
+ //minID = INT32_MAX;
+ //maxID = -1;
pathIndex = -1;
debug("Loading object types from %s...\n", filename);
@@ -635,13 +638,13 @@ CFileLoader::LoadObjectTypes(const char *filename)
}else switch(section){
case OBJS:
id = LoadObject(line);
- if(id > maxID) maxID = id;
- if(id < minID) minID = id;
+ //if(id > maxID) maxID = id;
+ //if(id < minID) minID = id;
break;
case TOBJ:
id = LoadTimeObject(line);
- if(id > maxID) maxID = id;
- if(id < minID) minID = id;
+ //if(id > maxID) maxID = id;
+ //if(id < minID) minID = id;
break;
case WEAP:
LoadWeaponObject(line);
@@ -678,10 +681,10 @@ CFileLoader::LoadObjectTypes(const char *filename)
}
CFileMgr::CloseFile(fd);
- for(id = minID; id <= maxID; id++){
+ for(id = 0; id < MODELINFOSIZE; id++){
CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id);
if(mi && mi->IsBuilding())
- mi->SetupBigBuilding(minID, maxID);
+ mi->SetupBigBuilding();
}
}
@@ -714,6 +717,13 @@ CFileLoader::LoadObject(const char *line)
if(sscanf(line, "%d %s %s %d", &id, model, txd, &numObjs) != 4)
return 0; // game returns return value
+ for(int i = 0; i < ARRAY_SIZE(m_sTempIdeData); i++)
+ if(m_sTempIdeData[i].id == -1){
+ m_sTempIdeData[i].id = id;
+ strcpy(m_sTempIdeData[i].name, model);
+ break;
+ }
+
switch(numObjs){
case 1:
sscanf(line, "%d %s %s %d %f %d",
@@ -762,6 +772,13 @@ CFileLoader::LoadTimeObject(const char *line)
if(sscanf(line, "%d %s %s %d", &id, model, txd, &numObjs) != 4)
return 0; // game returns return value
+ for(int i = 0; i < ARRAY_SIZE(m_sTempIdeData); i++)
+ if(m_sTempIdeData[i].id < 0){
+ m_sTempIdeData[i].id = id;
+ strcpy(m_sTempIdeData[i].name, model);
+ break;
+ }
+
switch(numObjs){
case 1:
sscanf(line, "%d %s %s %d %f %d %d %d",
@@ -792,7 +809,7 @@ CFileLoader::LoadTimeObject(const char *line)
mi->m_firstDamaged = damaged;
mi->SetTimes(timeOn, timeOff);
mi->SetTexDictionary(txd);
- other = mi->FindOtherTimeModel();
+ other = mi->FindOtherTimeModel(model);
if(other)
other->SetOtherTimeModel(id);
MatchModelString(model, id);
@@ -816,7 +833,7 @@ CFileLoader::LoadWeaponObject(const char *line)
mi->m_lodDistances[0] = dist;
mi->SetTexDictionary(txd);
mi->SetAnimFile(animFile);
- mi->SetColModel(&CTempColModels::ms_colModelWeapon);
+ mi->SetColModel(&gpTempColModels->ms_colModelWeapon);
MatchModelString(model, id);
return id;
}
@@ -832,7 +849,7 @@ CFileLoader::LoadClumpObject(const char *line)
mi = CModelInfo::AddClumpModel(id);
mi->SetModelName(model);
mi->SetTexDictionary(txd);
- mi->SetColModel(&CTempColModels::ms_colModelBBox);
+ mi->SetColModel(&gpTempColModels->ms_colModelBBox);
}
}
@@ -939,7 +956,7 @@ CFileLoader::LoadPedObject(const char *line)
mi->SetModelName(model);
mi->SetTexDictionary(txd);
mi->SetAnimFile(animFile);
- mi->SetColModel(&CTempColModels::ms_colModelPed1);
+ mi->SetColModel(&gpTempColModels->ms_colModelPed1);
mi->m_pedType = CPedType::FindPedType(pedType);
mi->m_pedStatType = CPedStats::GetPedStatType(pedStats);
for(animGroupId = 0; animGroupId < NUM_ANIM_ASSOC_GROUPS; animGroupId++)
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 3a2d3b59..df00efde 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -1000,7 +1000,9 @@ CMenuManager::DrawStandardMenus(bool activeScreen)
}
wchar unicodeTemp[64];
+#ifdef ASPECT_RATIO_SCALE
char asciiTemp[32];
+#endif
bool weHaveLabel = aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL;
uint8 section = 0; // 0: highlight trapezoid 1: texts
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index e0becc43..b5b4b90d 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -316,7 +316,7 @@ bool CGame::InitialiseOnceAfterRW(void)
{
TheText.Load();
CTimer::Initialise();
- CTempColModels::Initialise();
+ gpTempColModels->Initialise();
mod_HandlingManager.Initialise();
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
CPedStats::Initialise();
@@ -366,6 +366,9 @@ bool CGame::Initialise(const char* datFile)
CPools::Initialise();
+ if(gMakeResources)
+ CVehicleModelInfo::Load(nil);
+
#ifndef GTA_PS2
CIniFile::LoadIniFile();
#endif
diff --git a/src/core/General.h b/src/core/General.h
index 1ea7f2bd..2f205c39 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -133,7 +133,7 @@ public:
static bool faststricmp(const char *str1, const char *str2)
{
for (; *str1; str1++, str2++) {
-#if MUCH_SLOWER || !defined _WIN32 || defined __MINGW32__
+#ifndef ASCII_STRCMP
if (toupper(*str1) != toupper(*str2))
#else
if (__ascii_toupper(*str1) != __ascii_toupper(*str2))
diff --git a/src/core/Leeds.cpp b/src/core/Leeds.cpp
new file mode 100644
index 00000000..cda50605
--- /dev/null
+++ b/src/core/Leeds.cpp
@@ -0,0 +1,14 @@
+#include "common.h"
+#include "Leeds.h"
+
+void LoadResource(RpAtomic *atomic) {}
+void LoadResource(RpClump *clump) {}
+
+
+void SaveResource(RwTexture *tex, base::cRelocatableChunkWriter &writer) {}
+void SaveResource(RwTexDictionary *txd, base::cRelocatableChunkWriter &writer) {}
+void SaveResource(RpMaterial *mat, base::cRelocatableChunkWriter &writer) {}
+void SaveResource(RpMaterialList *matlist, base::cRelocatableChunkWriter &writer) {}
+void SaveResource(RpGeometry *geo, base::cRelocatableChunkWriter &writer) {}
+void SaveResource(RpAtomic *atomic, base::cRelocatableChunkWriter &writer) {}
+void SaveResource(RpClump *clump, base::cRelocatableChunkWriter &writer) {}
diff --git a/src/core/Leeds.h b/src/core/Leeds.h
new file mode 100644
index 00000000..bf71d7e0
--- /dev/null
+++ b/src/core/Leeds.h
@@ -0,0 +1,36 @@
+#pragma once
+
+/*
+PatchElementModelInfo(RslElement *,void *)
+ChunkName(char const*)
+DestroyAndFreeResourceImage(void)
+WriteOrder(char const*)
+UnpatchTextures(void)
+IsChunked(int)
+SaveResourceImage(void)
+LoadResourceImage(void)
+SaveResource(RslNode *,base::cRelocatableChunkWriter &)
+SaveResource(RslTAnimTree *,base::cRelocatableChunkWriter &)
+SaveResource(RslSkin *,base::cRelocatableChunkWriter &)
+SaveResource(CAnimBlendTree *,base::cRelocatableChunkWriter &)
+PatchElementTextures(RslElement *)
+PatchElementGroupTextures(RslElementGroup *)
+*/
+
+void LoadResource(RpAtomic *atomic);
+void LoadResource(RpClump *clump);
+
+/*
+cRelocatableChunkWriterGTA::Save(char const*,uint,uint,bool)
+cRelocatableChunkGTA::cRelocatableChunkGTA(char const*,uint,uint,bool)
+SaveAnimBlock(int)
+SaveModel(int,bool)
+*/
+
+void SaveResource(RwTexture *tex, base::cRelocatableChunkWriter &writer);
+void SaveResource(RwTexDictionary *txd, base::cRelocatableChunkWriter &writer);
+void SaveResource(RpMaterial *mat, base::cRelocatableChunkWriter &writer);
+void SaveResource(RpMaterialList *matlist, base::cRelocatableChunkWriter &writer);
+void SaveResource(RpGeometry *geo, base::cRelocatableChunkWriter &writer);
+void SaveResource(RpAtomic *atomic, base::cRelocatableChunkWriter &writer);
+void SaveResource(RpClump *clump, base::cRelocatableChunkWriter &writer);
diff --git a/src/core/Placeable.h b/src/core/Placeable.h
index 22f7583c..b0f9a15a 100644
--- a/src/core/Placeable.h
+++ b/src/core/Placeable.h
@@ -4,7 +4,7 @@ class CPlaceable
{
public:
// disable allocation
- static void *operator new(size_t) = delete;
+ static void *operator new(size_t);
CMatrix m_matrix;
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 96095d4f..f1bc1655 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -1,3 +1,6 @@
+#if (!defined(GTA_PS2_STUFF) && defined(RWLIBS)) || defined(__MWERKS__)
+#define WITHD3D
+#endif
#include "config.h"
#include "common.h"
@@ -387,10 +390,10 @@ void CRadar::ClearBlipForEntity(eBlipType type, int32 id)
int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
{
CVector2D corners[4] = {
- { 1.0f, -1.0f }, // top right
- { 1.0f, 1.0f }, // bottom right
- { -1.0f, 1.0f }, // bottom left
- { -1.0f, -1.0f }, // top left
+ CVector2D( 1.0f, -1.0f ), // top right
+ CVector2D( 1.0f, 1.0f ), // bottom right
+ CVector2D( -1.0f, 1.0f ), // bottom left
+ CVector2D( -1.0f, -1.0f ), // top left
};
CVector2D tmp;
int i, j, n;
diff --git a/src/core/Ropes.cpp b/src/core/Ropes.cpp
index dbae9ee3..ffce36f9 100644
--- a/src/core/Ropes.cpp
+++ b/src/core/Ropes.cpp
@@ -116,7 +116,7 @@ CRopes::RegisterRope(uintptr id, CVector pos, bool setUpdateTimer)
aRopes[i].m_unk = false;
aRopes[i].m_bWasRegistered = true;
aRopes[i].m_updateTimer = setUpdateTimer ? CTimer::GetTimeInMilliseconds() + 20000 : 0;
- for(j = 1; j < ARRAY_SIZE(CRope::m_pos); j++){
+ for(j = 1; j < ARRAY_SIZE(aRopes[0].m_pos); j++){
if(j & 1)
aRopes[i].m_pos[j] = aRopes[i].m_pos[j-1] + CVector(0.0f, 0.0f, 0.625f);
else
@@ -147,7 +147,7 @@ CRopes::FindCoorsAlongRope(uintptr id, float t, CVector *coors)
float f;
for(i = 0; i < ARRAY_SIZE(aRopes); i++)
if(aRopes[i].m_bActive && aRopes[i].m_id == id){
- t = (ARRAY_SIZE(CRope::m_pos)-1)*clamp(t, 0.0f, 0.999f);
+ t = (ARRAY_SIZE(aRopes[0].m_pos)-1)*clamp(t, 0.0f, 0.999f);
j = t;
f = t - j;
*coors = (1.0f-f)*aRopes[i].m_pos[j] + f*aRopes[i].m_pos[j+1];
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 7fa69396..243ff0ec 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -21,7 +21,7 @@ public:
static int32 NumberKillFrenziesPassed;
static int32 PeopleKilledByOthers;
static int32 HelisDestroyed;
- static int32 PedsKilledOfThisType[ePedType::NUM_PEDTYPES];
+ static int32 PedsKilledOfThisType[NUM_PEDTYPES];
static int32 TimesDied;
static int32 TimesArrested;
static int32 KillsSinceLastCheckpoint;
diff --git a/src/core/common.h b/src/core/common.h
index e1d64523..65f43aae 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -7,10 +7,19 @@
#pragma warning(disable: 4838) // narrowing conversion
#pragma warning(disable: 4996) // POSIX names
+#ifdef __MWERKS__
+#define __STDC_LIMIT_MACROS // so we get UINT32_MAX etc
+#endif
+
#include <stdint.h>
#include <string.h>
#include <math.h>
+#ifdef __MWERKS__
+#define AUDIO_MSS
+#define RWLIBS // codewarrior doesn't support project level defines - so not even this is enough, but still catches most ifdefs
+#endif
+
#if !defined RW_D3D9 && defined LIBRW
#undef WITHD3D
#undef WITHDINPUT
@@ -29,9 +38,9 @@
#define WITH_D3D // librw includes d3d9 itself via this right now
#else
#ifndef USE_D3D9
- #include <d3d8types.h>
+ #include <d3d8.h>
#else
- #include <d3d9types.h>
+ #include <d3d9.h>
#endif
#endif
#endif
@@ -79,8 +88,13 @@ typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
typedef int16_t int16;
+#ifndef __MWERKS__
typedef uint32_t uint32;
typedef int32_t int32;
+#else
+typedef unsigned int uint32;
+typedef int int32;
+#endif
typedef uintptr_t uintptr;
typedef intptr_t intptr;
typedef uint64_t uint64;
@@ -92,7 +106,7 @@ typedef uint8 bool8;
typedef uint16 bool16;
typedef uint32 bool32;
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined (__MWERKS__)
typedef ptrdiff_t ssize_t;
#endif
@@ -204,11 +218,11 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#define PSP_DEFAULT_SCREEN_WIDTH (480)
#define PSP_DEFAULT_SCREEN_HEIGHT (272)
-#define PSP_SCALE_TO_PS2_X(a) (a * ((float)DEFAULT_SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH))
-#define PSP_SCALE_TO_PS2_Y(a) (a * ((float)DEFAULT_SCREEN_HEIGHT / PSP_DEFAULT_SCREEN_HEIGHT))
+#define PSP_SCALE_TO_PS2_X(a) ((float)a * ((float)DEFAULT_SCREEN_WIDTH / (float)PSP_DEFAULT_SCREEN_WIDTH))
+#define PSP_SCALE_TO_PS2_Y(a) ((float)a * ((float)DEFAULT_SCREEN_HEIGHT / (float)PSP_DEFAULT_SCREEN_HEIGHT))
-#define PSP_SCREEN_SCALE_X(a) SCREEN_STRETCH_X(PSP_SCALE_TO_PS2_X(a))
-#define PSP_SCREEN_SCALE_Y(a) SCREEN_STRETCH_Y(PSP_SCALE_TO_PS2_Y(a))
+#define PSP_SCREEN_SCALE_X(a) ((a) * (float) SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH)
+#define PSP_SCREEN_SCALE_Y(a) ((a) * (float) SCREEN_WIDTH / PSP_DEFAULT_SCREEN_WIDTH)
#define PSP_SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - PSP_SCREEN_SCALE_X(a))
#define PSP_SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - PSP_SCREEN_SCALE_Y(a))
@@ -290,6 +304,22 @@ extern wchar *AllocUnicode(const char*src);
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
+#ifdef __MWERKS__
+#define M_E 2.71828182845904523536 // e
+#define M_LOG2E 1.44269504088896340736 // log2(e)
+#define M_LOG10E 0.434294481903251827651 // log10(e)
+#define M_LN2 0.693147180559945309417 // ln(2)
+#define M_LN10 2.30258509299404568402 // ln(10)
+#define M_PI 3.14159265358979323846 // pi
+#define M_PI_2 1.57079632679489661923 // pi/2
+#define M_PI_4 0.785398163397448309616 // pi/4
+#define M_1_PI 0.318309886183790671538 // 1/pi
+#define M_2_PI 0.636619772367581343076 // 2/pi
+#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
+#define M_SQRT2 1.41421356237309504880 // sqrt(2)
+#define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
+#endif
+
#define PI (float)M_PI
#define TWOPI (PI*2)
#define HALFPI (PI/2)
@@ -319,14 +349,34 @@ void re3_usererror(const char *format, ...);
#define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__)
#endif
+#ifdef __MWERKS__
+void debug(char *f, ...);
+void Error(char *f, ...);
+__inline__ void TRACE(char *f, ...) { } // this is re3 only, and so the function needs to be inline - this way no call actually gets placed
+// USERERROR only gets used in oal builds ... once
+#else
#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
-#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__)
+#ifndef MASTER
+#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__)
+#else
+#define TRACE(f, ...)
+#define USERERROR(f, ...)
+#endif
+#endif
+#ifndef MASTER
#define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) )
+#else
+#define assert(_Expression)
+#endif
#define ASSERT assert
+#ifdef __MWERKS__
+#define static_assert(bool_constexpr, message)
+#endif
+
#define _TODO(x)
#define _TODOCONST(x) (x)
@@ -350,6 +400,7 @@ void re3_usererror(const char *format, ...);
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
+#ifdef DEBUGMENU
// Tweaking stuff for debugmenu
#define TWEAKPATH ___tw___TWEAKPATH
#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
@@ -463,6 +514,7 @@ _TWEEKCLASS(CTweakUInt32, uint32);
_TWEEKCLASS(CTweakFloat, float);
#undef _TWEEKCLASS
+#endif
#ifdef VALIDATE_SAVE_SIZE
extern int32 _saveBufCount;
diff --git a/src/core/config.h b/src/core/config.h
index 2685c687..c5799817 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -1,5 +1,8 @@
#pragma once
+// disables (most) stuff that wasn't in original gta-vc.exe - check section at the bottom of this file
+//#define VANILLA_DEFINES
+
enum Config {
NUMPLAYERS = 1,
@@ -404,3 +407,87 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
#undef PS2_ALPHA_TEST
#undef NO_ISLAND_LOADING
#endif
+
+#if defined __MWERKS__ || defined VANILLA_DEFINES
+#define FINAL
+#undef CHATTYSPLASH
+#undef TIMEBARS
+
+#define MASTER
+#undef VALIDATE_SAVE_SIZE
+#undef NO_MOVIES
+#undef DEBUGMENU
+
+#undef DRAW_GAME_VERSION_TEXT
+
+//#undef NASTY_GAME
+//#undef NO_CDCHECK
+
+#undef GTA_PS2_STUFF
+#undef USE_PS2_RAND
+#undef RANDOMSPLASH
+#undef PS2_MATFX
+
+#undef FIX_BUGS
+#define THIS_IS_STUPID
+#undef MORE_LANGUAGES
+#undef COMPATIBLE_SAVES
+#undef LOAD_INI_SETTINGS
+#undef FIX_HIGH_FPS_BUGS_ON_FRONTEND
+
+#undef ASPECT_RATIO_SCALE
+#undef PROPER_SCALING
+//#undef DEFAULT_NATIVE_RESOLUTION
+#undef PS2_ALPHA_TEST
+#undef IMPROVED_VIDEOMODE
+#undef DISABLE_LOADING_SCREEN
+#undef DISABLE_VSYNC_ON_TEXTURE_CONVERSION
+
+#undef FIX_SPRITES
+
+#define PC_WATER
+#undef WATER_CHEATS
+
+#undef USE_CUTSCENE_SHADOW_FOR_PED
+#undef DISABLE_CUTSCENE_SHADOWS
+
+#undef XINPUT
+#undef DETECT_PAD_INPUT_SWITCH
+#undef KANGAROO_CHEAT
+#undef RESTORE_ALLCARSHELI_CHEAT
+#undef BETTER_ALLCARSAREDODO_CHEAT
+#undef WALLCLIMB_CHEAT
+#undef REGISTER_START_BUTTON
+#undef BIND_VEHICLE_FIREWEAPON
+#undef BUTTON_ICONS
+
+#undef FIX_RADAR
+
+#undef MAP_ENHANCEMENTS
+#undef MUCH_SHORTER_OUTRO_SCREEN
+#undef CUSTOM_FRONTEND_OPTIONS
+
+#undef GRAPHICS_MENU_OPTIONS
+#undef NO_ISLAND_LOADING
+#undef CUTSCENE_BORDERS_SWITCH
+#undef MULTISAMPLING
+#undef INVERT_LOOK_FOR_PAD
+
+#undef USE_DEBUG_SCRIPT_LOADER
+#undef USE_MEASUREMENTS_IN_METERS
+#undef USE_PRECISE_MEASUREMENT_CONVERTION
+#undef SUPPORT_JAPANESE_SCRIPT
+#undef MISSION_REPLAY
+#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
+
+#define DONT_FIX_REPLAY_BUGS
+
+#undef EXPLODING_AIRTRAIN
+#undef CPLANE_ROTORS
+#undef CAMERA_PICKUP
+#undef CANCELLABLE_CAR_ENTER
+#undef IMPROVED_CAMERA
+#undef FREE_CAM
+#undef BIG_IMG
+#endif
diff --git a/src/core/main.cpp b/src/core/main.cpp
index dc75daf8..c3286ea9 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -85,6 +85,9 @@ wchar gUString2[256];
// leeds
bool gMakeResources = true;
bool gUseChunkFiles = false;
+bool gSecondExportPass;
+bool gUseModelResources;
+bool gUseResources;
float FramesPerSecond = 30.0f;
@@ -141,6 +144,24 @@ bool gbNewRenderer = true;
bool bDisplayNumOfAtomicsRendered = false;
bool bDisplayPosn = false;
+#ifdef __MWERKS__
+void
+debug(char *fmt, ...)
+{
+#ifndef MASTER
+ // TODO put something here
+#endif
+}
+
+void
+Error(char *fmt, ...)
+{
+#ifndef MASTER
+ // TODO put something here
+#endif
+}
+#endif
+
void
ValidateVersion()
{
@@ -810,6 +831,7 @@ ProcessSlowMode(void)
float FramesPerSecondCounter;
int32 FrameSamples;
+#ifndef MASTER
struct tZonePrint
{
char name[11];
@@ -840,8 +862,6 @@ tZonePrint ZonePrint[] =
{ "WASHINBTM", "AC", CRect(-255.0f, -1200.0f, 500.0f, -1690.0f)}
};
-#ifndef MASTER
-
void
PrintMemoryUsage(void)
{
diff --git a/src/core/main.h b/src/core/main.h
index 38dce115..98813470 100644
--- a/src/core/main.h
+++ b/src/core/main.h
@@ -27,6 +27,9 @@ extern bool gbPrintMemoryUsage;
// leeds
extern bool gMakeResources;
extern bool gUseChunkFiles;
+extern bool gSecondExportPass;
+extern bool gUseModelResources;
+extern bool gUseResources;
class CSprite2d;
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index ace15502..4a2dfe00 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -95,14 +95,14 @@ CustomFrontendOptionsPopulate(void)
if (fd) {
#ifdef GRAPHICS_MENU_OPTIONS
FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false);
- FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline");
- FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "WorldPipeline");
+ FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline");
+ FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "Graphics", "WorldPipeline");
FrontendOptionAddSelect("FED_WLM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps");
FrontendOptionAddSelect("FED_RGL", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss");
#else
FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3, false);
- FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline");
- FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "WorldPipeline");
+ FrontendOptionAddSelect("FED_VPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline");
+ FrontendOptionAddSelect("FED_WPL", 0, 0, MENUALIGN_LEFT, pipelineNames, ARRAY_SIZE(pipelineNames), (int8*)&CustomPipes::WorldPipeSwitch, false, nil, "Graphics", "WorldPipeline");
FrontendOptionAddSelect("FED_WLM", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps");
FrontendOptionAddSelect("FED_RGL", 0, 0, MENUALIGN_LEFT, off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss");
#endif
@@ -1025,9 +1025,13 @@ extern bool gbRenderDebugEnvMap;
}
#endif
+#ifndef __MWERKS__
+#ifndef MASTER
const int re3_buffsize = 1024;
static char re3_buff[re3_buffsize];
+#endif
+#ifndef MASTER
void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func)
{
#ifdef _WIN32
@@ -1081,9 +1085,11 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
assert(false);
#endif
}
+#endif
void re3_debug(const char *format, ...)
{
+#ifndef MASTER
va_list va;
va_start(va, format);
#ifdef _WIN32
@@ -1095,8 +1101,10 @@ void re3_debug(const char *format, ...)
printf("%s", re3_buff);
CDebug::DebugAddText(re3_buff);
+#endif
}
+#ifndef MASTER
void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...)
{
char buff[re3_buffsize *2];
@@ -1136,6 +1144,8 @@ void re3_usererror(const char *format, ...)
assert(false);
#endif
}
+#endif
+#endif
#ifdef VALIDATE_SAVE_SIZE
int32 _saveBufCount;
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index de60c400..7be5df23 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -1288,7 +1288,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
int numCollisions;
int mostColliding;
CColPoint colpoints[MAX_COLLISION_POINTS];
- CVector shift = { 0.0f, 0.0f, 0.0f };
+ CVector shift = CVector(0.0f, 0.0f, 0.0f);
bool doShift = false;
CEntity *boat = nil;
@@ -1747,8 +1747,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
if(numCollisions <= 0)
continue;
- CVector moveSpeed = { 0.0f, 0.0f, 0.0f };
- CVector turnSpeed = { 0.0f, 0.0f, 0.0f };
+ CVector moveSpeed = CVector(0.0f, 0.0f, 0.0f);
+ CVector turnSpeed = CVector(0.0f, 0.0f, 0.0f);
float maxImpulseA = 0.0f;
numResponses = 0;
if(A->bHasContacted){
@@ -2232,8 +2232,8 @@ CPhysical::ProcessCollision(void)
}else if(IsObject() && ((CObject*)this)->ObjectCreatedBy != TEMP_OBJECT){
int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases;
if(responsecase == COLLRESPONSE_LAMPOST){
- CVector speedUp = { 0.0f, 0.0f, 0.0f };
- CVector speedDown = { 0.0f, 0.0f, 0.0f };
+ CVector speedUp = CVector(0.0f, 0.0f, 0.0f);
+ CVector speedDown = CVector(0.0f, 0.0f, 0.0f);
CColModel *colModel = GetColModel();
speedUp.z = colModel->boundingBox.max.z;
speedDown.z = colModel->boundingBox.min.z;
diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp
index 390ec475..a874343d 100644
--- a/src/extras/custompipes.cpp
+++ b/src/extras/custompipes.cpp
@@ -370,7 +370,7 @@ AttachVehiclePipe(rw::Clump *clump)
* Neo World pipe
*/
-int32 WorldPipeSwitch = 0;
+int32 WorldPipeSwitch = WORLDPIPE_PS2;
bool LightmapEnable;
float LightmapMult = 1.0f;
InterpolatedFloat WorldLightmapBlend(1.0f);
diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp
index 68337fb6..cb5fcadc 100644
--- a/src/extras/custompipes_d3d9.cpp
+++ b/src/extras/custompipes_d3d9.cpp
@@ -22,7 +22,8 @@
#error "Need librw for EXTENDED_PIPELINES"
#endif
-extern RwTexture *gpWhiteTexture; // from vehicle model info
+//extern RwTexture *gpWhiteTexture; // from vehicle model info
+static RwTexture *gpWhiteTexture; // nil works as white in librw currently
namespace CustomPipes {
diff --git a/src/fakerw/rpworld.h b/src/fakerw/rpworld.h
index f10a3754..8e3b09f0 100644
--- a/src/fakerw/rpworld.h
+++ b/src/fakerw/rpworld.h
@@ -13,6 +13,7 @@
//struct RpMaterial;
typedef rw::Material RpMaterial;
+typedef rw::MaterialList RpMaterialList;
typedef RpMaterial *(*RpMaterialCallBack)(RpMaterial *material, void *data);
diff --git a/src/leeds/base/relocatableChunk.h b/src/leeds/base/relocatableChunk.h
index ea910240..2658aa21 100644
--- a/src/leeds/base/relocatableChunk.h
+++ b/src/leeds/base/relocatableChunk.h
@@ -19,6 +19,8 @@ namespace base
void* Shrink(void* data);
};
+#define VTABLE_ADDR(obj) ((void*)obj) // TODO: make this portable
+
class cRelocatableChunkClassInfo
{
public:
diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp
index fd13dfb5..ffd934ba 100644
--- a/src/modelinfo/BaseModelInfo.cpp
+++ b/src/modelinfo/BaseModelInfo.cpp
@@ -7,6 +7,9 @@
#include "BaseModelInfo.h"
#include "ModelInfo.h"
#include "KeyGen.h"
+#include "Streaming.h"
+#include "smallHeap.h"
+#include "TempColModels.h"
CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
{
@@ -18,7 +21,11 @@ CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
m_type = type;
m_num2dEffects = 0;
m_bOwnsColModel = false;
+ m_nameKey = 0;
+ m_unk1 = 0;
+ m_unk2 = 0;
m_name = new char[MAX_MODEL_NAME];
+ *(int32*)m_name = 0;
}
void
@@ -26,6 +33,7 @@ CBaseModelInfo::Shutdown(void)
{
DeleteCollisionModel();
DeleteRwObject();
+ DeleteChunk();
m_2dEffectsID = -1;
m_num2dEffects = 0;
m_txdSlot = -1;
@@ -34,11 +42,11 @@ CBaseModelInfo::Shutdown(void)
void
CBaseModelInfo::DeleteCollisionModel(void)
{
- if(m_colModel && m_bOwnsColModel){
+ if(!gUseChunkFiles && m_colModel && m_bOwnsColModel){
if(m_colModel)
delete m_colModel;
- m_colModel = nil;
}
+ m_colModel = nil;
}
void
@@ -51,15 +59,17 @@ CBaseModelInfo::AddRef(void)
void
CBaseModelInfo::RemoveRef(void)
{
- m_refCount--;
- RemoveTexDictionaryRef();
+ if(m_refCount > 0){
+ m_refCount--;
+ RemoveTexDictionaryRef();
+ }
}
void
CBaseModelInfo::SetTexDictionary(const char *name)
{
int slot = CTxdStore::FindTxdSlot(name);
- if(slot < 0)
+ if(slot == -1)
slot = CTxdStore::AddTxdSlot(name);
m_txdSlot = slot;
}
@@ -71,12 +81,24 @@ CBaseModelInfo::AddTexDictionaryRef(void)
}
void
+CBaseModelInfo::AddTexDictionaryRefGu(void)
+{
+ CTxdStore::AddRefGu(m_txdSlot);
+}
+
+void
CBaseModelInfo::RemoveTexDictionaryRef(void)
{
CTxdStore::RemoveRef(m_txdSlot);
}
void
+CBaseModelInfo::RemoveTexDictionaryRefGu(void)
+{
+ CTxdStore::RemoveRefGu(m_txdSlot);
+}
+
+void
CBaseModelInfo::Init2dEffects(void)
{
m_2dEffectsID = -1;
@@ -110,4 +132,52 @@ CBaseModelInfo::SetModelName(const char *name)
m_nameKey = CKeyGen::GetUppercaseKey(name);
if (!gUseChunkFiles)
strcpy(m_name, name);
-} \ No newline at end of file
+}
+
+void
+CBaseModelInfo::DeleteChunk(void)
+{
+ // BUG? what if we're not using chunks?
+ if(m_chunk){
+ CStreaming::UnregisterPointer(&m_chunk, 2);
+ cSmallHeap::msInstance.Free(m_chunk);
+ m_chunk = nil;
+ }
+}
+
+inline int
+GetColmodelID(CColModel *model)
+{
+ int colModelid = 0;
+ if(model == &gpTempColModels->ms_colModelBBox) colModelid = 1;
+ if(model == &gpTempColModels->ms_colModelPed1) colModelid = 2;
+ if(model == &gpTempColModels->ms_colModelWeapon) colModelid = 3;
+ if(model == &CTempColModels::ms_colModelPed2) colModelid = 4;
+ if(model == &CTempColModels::ms_colModelPedGroundHit) colModelid = 5;
+ if(model == &CTempColModels::ms_colModelDoor1) colModelid = 6;
+ if(model == &CTempColModels::ms_colModelBumper1) colModelid = 7;
+ if(model == &CTempColModels::ms_colModelPanel1) colModelid = 8;
+ if(model == &CTempColModels::ms_colModelBonnet1) colModelid = 9;
+ if(model == &CTempColModels::ms_colModelBoot1) colModelid = 10;
+ if(model == &CTempColModels::ms_colModelWheel1) colModelid = 11;
+ if(model == &CTempColModels::ms_colModelBodyPart1) colModelid = 12;
+ if(model == &CTempColModels::ms_colModelBodyPart2) colModelid = 13;
+ if(model == &CTempColModels::ms_colModelCutObj[0]) colModelid = 14;
+ if(model == &CTempColModels::ms_colModelCutObj[1]) colModelid = 15;
+ if(model == &CTempColModels::ms_colModelCutObj[2]) colModelid = 16;
+ if(model == &CTempColModels::ms_colModelCutObj[3]) colModelid = 17;
+ if(model == &CTempColModels::ms_colModelCutObj[4]) colModelid = 18;
+ return colModelid;
+}
+
+void
+CBaseModelInfo::Write(base::cRelocatableChunkWriter &writer)
+{
+ m_chunk = nil;
+ RcWriteThis(writer);
+ if(m_colModel){
+ if(m_bOwnsColModel || GetColmodelID(m_colModel) != 0)
+ m_colModel->Write(writer, true);
+ writer.AddPatch(&m_colModel);
+ }
+}
diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h
index f3fddf20..c9ea13bb 100644
--- a/src/modelinfo/BaseModelInfo.h
+++ b/src/modelinfo/BaseModelInfo.h
@@ -2,7 +2,7 @@
struct CColModel;
-#define MAX_MODEL_NAME (21)
+#define MAX_MODEL_NAME (24)
enum ModelInfoType
{
@@ -23,9 +23,13 @@ class C2dEffect;
class CBaseModelInfo
{
protected:
- char *m_name;
+ uint32 m_unk1;
+ uint32 m_unk2;
uint32 m_nameKey;
- RwObject *m_object;
+ union {
+ char *m_name; // if not using chunks
+ void *m_chunk; // else
+ };
uint8 m_type;
uint8 m_num2dEffects;
bool m_bOwnsColModel;
@@ -53,6 +57,16 @@ public:
virtual void ConvertAnimFileIndex(void) {}
virtual int GetAnimFileIndex(void) { return -1; }
+ virtual void LoadModel(void *model, const void *chunk) = 0;
+ virtual void DeleteChunk(void);
+ // this writes the modelinfo struct, possibly including actual RW models
+ virtual void Write(base::cRelocatableChunkWriter &writer);
+ // this writes the RW models
+ virtual void *WriteModel(base::cRelocatableChunkWriter &writer) { return nil; } // = 0; // this is not in the vtable for some reason???
+ // these allocate the space for a modelinfo struct and patch the vtable pointer
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer) = 0;
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer) = 0;
+
// one day it becomes virtual
uint8 GetModelType() const { return m_type; }
bool IsBuilding(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; }
@@ -74,7 +88,9 @@ public:
void RemoveRef(void);
void SetTexDictionary(const char *name);
void AddTexDictionaryRef(void);
+ void AddTexDictionaryRefGu(void);
void RemoveTexDictionaryRef(void);
+ void RemoveTexDictionaryRefGu(void);
void Init2dEffects(void);
void Add2dEffect(C2dEffect *fx);
C2dEffect *Get2dEffect(int n);
diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp
index ba18bfa7..00c2c0fe 100644
--- a/src/modelinfo/ClumpModelInfo.cpp
+++ b/src/modelinfo/ClumpModelInfo.cpp
@@ -1,17 +1,30 @@
#include "common.h"
+#include "main.h"
#include "RwHelper.h"
#include "General.h"
#include "NodeName.h"
#include "VisibilityPlugins.h"
#include "ModelInfo.h"
#include "AnimManager.h"
+#include "Streaming.h"
+#include "Leeds.h"
+
+base::cRelocatableChunkClassInfo CClumpModelInfo::msClassInfo("CElementGroupModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance)); // the real name
+CClumpModelInfo CClumpModelInfo::msClassInstance;
void
CClumpModelInfo::DeleteRwObject(void)
{
if(m_clump){
- RpClumpDestroy(m_clump);
+ if(!gUseChunkFiles)
+ RpClumpDestroy(m_clump);
+ else{
+ CStreaming::UnregisterClump(m_clump);
+ CStreaming::UnregisterPointer(&m_clump, 2);
+ DeleteChunk();
+ }
+
m_clump = nil;
RemoveTexDictionaryRef();
if(GetAnimFileIndex() != -1)
@@ -52,6 +65,7 @@ CClumpModelInfo::CreateInstance(RwMatrix *m)
if(m_clump){
RpClump *clump = (RpClump*)CreateInstance();
*RwFrameGetMatrix(RpClumpGetFrame(clump)) = *m;
+ CStreaming::RegisterInstance(clump);
return (RwObject*)clump;
}
return nil;
@@ -73,14 +87,15 @@ CClumpModelInfo::SetClump(RpClump *clump)
if(GetAnimFileIndex() != -1)
CAnimManager::AddAnimBlockRef(GetAnimFileIndex());
if(IsClumpSkinned(clump)){
- int i;
+ //int i;
RpHAnimHierarchy *hier;
- RpAtomic *skinAtomic;
- RpSkin *skin;
+ //RpAtomic *skinAtomic;
+ //RpSkin *skin;
hier = GetAnimHierarchyFromClump(clump);
assert(hier);
RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
+/*
skinAtomic = GetFirstAtomic(clump);
assert(skinAtomic);
@@ -94,6 +109,7 @@ CClumpModelInfo::SetClump(RpClump *clump)
weights->w2 /= sum;
weights->w3 /= sum;
}
+*/
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
}
@@ -203,3 +219,47 @@ CClumpModelInfo::GetFrameFromId(RpClump *clump, int32 id)
RwFrameForAllChildren(RpClumpGetFrame(clump), FindFrameFromIdCB, &assoc);
return assoc.frame;
}
+
+
+void
+CClumpModelInfo::LoadModel(void *clump, const void *chunk)
+{
+ m_chunk = (void*)chunk;
+ m_clump = (RpClump*)clump;
+ LoadResource(m_clump);
+ CStreaming::RegisterPointer(&m_chunk, 2, true);
+ CStreaming::RegisterClump(m_clump);
+ CStreaming::RegisterPointer(&m_clump, 2, true);
+}
+
+void
+CClumpModelInfo::Write(base::cRelocatableChunkWriter &writer)
+{
+ CBaseModelInfo::Write(writer);
+ if(m_clump){
+ writer.AddPatch(&m_clump);
+ SaveResource(m_clump, writer);
+ }
+}
+
+void*
+CClumpModelInfo::WriteModel(base::cRelocatableChunkWriter &writer)
+{
+ if(m_clump)
+ SaveResource(m_clump, writer);
+ return m_clump;
+}
+
+void
+CClumpModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
+
+void
+CClumpModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h
index 0113d340..b8507e5f 100644
--- a/src/modelinfo/ClumpModelInfo.h
+++ b/src/modelinfo/ClumpModelInfo.h
@@ -35,6 +35,9 @@ public:
char *m_animFileName;
};
+ static base::cRelocatableChunkClassInfo msClassInfo;
+ static CClumpModelInfo msClassInstance;
+
CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; }
CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; }
~CClumpModelInfo() {}
@@ -48,6 +51,12 @@ public:
virtual void ConvertAnimFileIndex(void);
virtual int GetAnimFileIndex(void) { return m_animFileIndex; }
+ virtual void LoadModel(void *model, const void *chunk);
+ virtual void Write(base::cRelocatableChunkWriter &writer);
+ virtual void *WriteModel(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer);
+
static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data);
void SetFrameIds(RwObjectNameIdAssocation *assocs);
static RwFrame *FindFrameFromNameCB(RwFrame *frame, void *data);
diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp
index 28de2507..1d519b10 100644
--- a/src/modelinfo/PedModelInfo.cpp
+++ b/src/modelinfo/PedModelInfo.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "RwHelper.h"
#include "General.h"
#include "Bones.h"
@@ -9,12 +10,19 @@
#include "VisibilityPlugins.h"
#include "ModelInfo.h"
#include "custompipes.h"
+#include "Streaming.h"
+#include "Leeds.h"
+#include "TempColModels.h"
+
+base::cRelocatableChunkClassInfo CPedModelInfo::msClassInfo("CPedModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance));
+CPedModelInfo CPedModelInfo::msClassInstance;
void
CPedModelInfo::DeleteRwObject(void)
{
+ CStreaming::UnregisterPointer(&m_hitColModel, 2);
CClumpModelInfo::DeleteRwObject();
- if(m_hitColModel)
+ if(!gUseChunkFiles && m_hitColModel)
delete m_hitColModel;
m_hitColModel = nil;
}
@@ -41,13 +49,15 @@ CPedModelInfo::SetClump(RpClump *clump)
#ifdef EXTENDED_PIPELINES
CustomPipes::AttachRimPipe(clump);
#endif
+ if(!IsClumpSkinned(clump))
+ return;
CClumpModelInfo::SetClump(clump);
SetFrameIds(m_pPedIds); // not needed in VC actually
if(m_hitColModel == nil)
CreateHitColModelSkinned(clump);
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPedCB);
- if(strcmp(GetModelName(), "player") == 0)
- RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
+ //if(strcmp(GetModelName(), "player") == 0)
+ // RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
}
struct ColNodeInfo
@@ -73,40 +83,27 @@ ColNodeInfo m_pColNodeInfos[NUMPEDINFONODES] = {
{ nil, PED_FOOTR, PEDPIECE_RIGHTLEG, 0.0f, 0.15f, 0.15f },
};
-void
+bool
CPedModelInfo::CreateHitColModelSkinned(RpClump *clump)
{
- RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump);
CColModel *colmodel = new CColModel;
CColSphere *spheres = (CColSphere*)RwMalloc(NUMPEDINFONODES*sizeof(CColSphere));
- RwFrame *root = RpClumpGetFrame(m_clump);
- RwMatrix *invmat = RwMatrixCreate();
- RwMatrix *mat = RwMatrixCreate();
- RwMatrixInvert(invmat, RwFrameGetMatrix(RpClumpGetFrame(clump)));
for(int i = 0; i < NUMPEDINFONODES; i++){
- *mat = *invmat;
- int id = ConvertPedNode2BoneTag(m_pColNodeInfos[i].pedNode); // this is wrong, wtf R* ???
- int idx = RpHAnimIDGetIndex(hier, id);
-
- // This doesn't really work as the positions are not initialized yet
- RwMatrixTransform(mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT);
- RwV3d pos = { 0.0f, 0.0f, 0.0f };
- RwV3dTransformPoints(&pos, &pos, 1, mat);
-
- spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z);
+ spheres[i].center.x = 0.0f;
+ spheres[i].center.y = 0.0f;
+ spheres[i].center.z = 0.0f;
spheres[i].radius = m_pColNodeInfos[i].radius;
spheres[i].surface = SURFACE_PED;
spheres[i].piece = m_pColNodeInfos[i].pieceType;
}
- RwMatrixDestroy(invmat);
- RwMatrixDestroy(mat);
colmodel->spheres = spheres;
colmodel->numSpheres = NUMPEDINFONODES;
colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f));
colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f));
colmodel->level = LEVEL_GENERIC;
m_hitColModel = colmodel;
+ return true;
}
CColModel*
@@ -114,28 +111,27 @@ CPedModelInfo::AnimatePedColModelSkinned(RpClump *clump)
{
if(m_hitColModel == nil){
CreateHitColModelSkinned(clump);
+#ifndef FIX_BUGS
return m_hitColModel;
+#endif
+ // we should really animate this now
}
- RwMatrix *invmat, *mat;
+ RwMatrix invmat, mat;
CColSphere *spheres = m_hitColModel->spheres;
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump);
- invmat = RwMatrixCreate();
- mat = RwMatrixCreate();
- RwMatrixInvert(invmat, RwFrameGetMatrix(RpClumpGetFrame(clump)));
+ RwMatrixInvert(&invmat, RwFrameGetMatrix(RpClumpGetFrame(clump)));
for(int i = 0; i < NUMPEDINFONODES; i++){
- *mat = *invmat;
+ mat = invmat;
int id = ConvertPedNode2BoneTag(m_pColNodeInfos[i].pedNode);
int idx = RpHAnimIDGetIndex(hier, id);
- RwMatrixTransform(mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT);
- RwV3d pos = { 0.0f, 0.0f, 0.0f };
- RwV3dTransformPoints(&pos, &pos, 1, mat);
+ RwMatrixTransform(&mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT);
+ RwV3d pos = { 0.0f, 0.0f, 0.0f }; // actually CVector
+ RwV3dTransformPoints(&pos, &pos, 1, &mat);
spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z);
}
- RwMatrixDestroy(invmat);
- RwMatrixDestroy(mat);
return m_hitColModel;
}
@@ -153,10 +149,71 @@ CPedModelInfo::AnimatePedColModelSkinnedWorld(RpClump *clump)
int idx = RpHAnimIDGetIndex(hier, id);
mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
- RwV3d pos = { 0.0f, 0.0f, 0.0f };
+ RwV3d pos = { 0.0f, 0.0f, 0.0f }; // actually CVector
RwV3dTransformPoints(&pos, &pos, 1, mat);
spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z);
}
return m_hitColModel;
}
+
+
+struct PedChunk
+{
+ CColModel *colmodel;
+ RpClump *clump;
+};
+
+void
+CPedModelInfo::LoadModel(void *data, const void *chunk)
+{
+ PedChunk *chk = (PedChunk*)data;
+ m_hitColModel = chk->colmodel;
+ CStreaming::RegisterPointer(&m_hitColModel, 2, true);
+ CClumpModelInfo::LoadModel(chk->clump, chunk);
+}
+
+void
+CPedModelInfo::Write(base::cRelocatableChunkWriter &writer)
+{
+ SetColModel(&gpTempColModels->ms_colModelPed1);
+ CClumpModelInfo::Write(writer);
+ if(m_hitColModel){
+ writer.AddPatch(&m_hitColModel);
+ m_hitColModel->Write(writer, true);
+ }
+}
+
+void*
+CPedModelInfo::WriteModel(base::cRelocatableChunkWriter &writer)
+{
+ PedChunk *chunk = new PedChunk; // LEAK
+ chunk->colmodel = nil;
+ chunk->clump = nil;
+ writer.AllocateRaw(chunk, sizeof(*chunk), sizeof(void*), false, true);
+
+ chunk->clump = (RpClump*)CClumpModelInfo::WriteModel(writer);
+ if(chunk->clump)
+ writer.AddPatch(&chunk->clump);
+
+ chunk->colmodel = m_hitColModel;
+ if(chunk->colmodel){
+ writer.AddPatch(&chunk->colmodel);
+ chunk->colmodel->Write(writer, true);
+ }
+ return nil;
+}
+
+void
+CPedModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
+
+void
+CPedModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h
index 79bd7eaa..7baa2bd8 100644
--- a/src/modelinfo/PedModelInfo.h
+++ b/src/modelinfo/PedModelInfo.h
@@ -38,6 +38,8 @@ public:
CColModel *m_hitColModel;
int8 radio1, radio2;
+ static base::cRelocatableChunkClassInfo msClassInfo;
+ static CPedModelInfo msClassInstance;
static RwObjectNameIdAssocation m_pPedIds[PED_NODE_MAX];
CPedModelInfo(void) : CClumpModelInfo(MITYPE_PED) { m_hitColModel = nil; }
@@ -45,7 +47,13 @@ public:
void DeleteRwObject(void);
void SetClump(RpClump *);
- void CreateHitColModelSkinned(RpClump *clump);
+ virtual void LoadModel(void *model, const void *chunk);
+ virtual void Write(base::cRelocatableChunkWriter &writer);
+ virtual void *WriteModel(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer);
+
+ bool CreateHitColModelSkinned(RpClump *clump);
CColModel *GetHitColModel(void) { return m_hitColModel; }
CColModel *AnimatePedColModelSkinned(RpClump *clump);
CColModel *AnimatePedColModelSkinnedWorld(RpClump *clump);
diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp
index 9ca4d292..8d0ea677 100644
--- a/src/modelinfo/SimpleModelInfo.cpp
+++ b/src/modelinfo/SimpleModelInfo.cpp
@@ -1,38 +1,61 @@
#include "common.h"
+#include "main.h"
#include "General.h"
+#include "Renderer.h"
#include "Camera.h"
+#include "Renderer.h"
#include "ModelInfo.h"
#include "AnimManager.h"
#include "custompipes.h"
+#include "Streaming.h"
+#include "smallHeap.h"
+#include "Leeds.h"
-#define LOD_DISTANCE (300.0f)
+TempIdeData m_sTempIdeData[800];
+
+base::cRelocatableChunkClassInfo CSimpleModelInfo::msClassInfo("CSimpleModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance));
+CSimpleModelInfo CSimpleModelInfo::msClassInstance;
void
CSimpleModelInfo::DeleteRwObject(void)
{
int i;
RwFrame *f;
- for(i = 0; i < m_numAtomics; i++)
- if(m_atomics[i]){
- f = RpAtomicGetFrame(m_atomics[i]);
- RpAtomicDestroy(m_atomics[i]);
- RwFrameDestroy(f);
- m_atomics[i] = nil;
- RemoveTexDictionaryRef();
- if(GetAnimFileIndex() != -1)
- CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex());
- }
+ if(m_atomics == nil)
+ return;
+ if(!gUseChunkFiles){
+ for(i = 0; i < m_numAtomics; i++)
+ if(m_atomics[i]){
+ f = RpAtomicGetFrame(m_atomics[i]);
+ RpAtomicDestroy(m_atomics[i]);
+ RwFrameDestroy(f);
+ m_atomics[i] = nil;
+ RemoveTexDictionaryRef();
+ if(GetAnimFileIndex() != -1)
+ CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex());
+ }
+ }else if(m_chunk){
+ CStreaming::UnregisterPointer(&m_atomics, 2);
+ for(i = 0; i < m_numAtomics; i++)
+ CStreaming::UnregisterAtomic(m_atomics[i], nil);
+ DeleteChunk();
+ RemoveTexDictionaryRef();
+ if(GetAnimFileIndex() != -1)
+ CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex());
+ }
+ m_atomics = nil;
}
RwObject*
CSimpleModelInfo::CreateInstance(void)
{
RpAtomic *atomic;
- if(m_atomics[0] == nil)
+ if(m_atomics == nil || m_atomics[0] == nil)
return nil;
atomic = RpAtomicClone(m_atomics[0]);
RpAtomicSetFrame(atomic, RwFrameCreate());
+ CStreaming::RegisterInstance(atomic, nil);
return (RwObject*)atomic;
}
@@ -42,21 +65,20 @@ CSimpleModelInfo::CreateInstance(RwMatrix *matrix)
RpAtomic *atomic;
RwFrame *frame;
- if(m_atomics[0] == nil)
+ if(m_atomics == nil || m_atomics[0] == nil)
return nil;
atomic = RpAtomicClone(m_atomics[0]);
frame = RwFrameCreate();
*RwFrameGetMatrix(frame) = *matrix;
RpAtomicSetFrame(atomic, frame);
+ CStreaming::RegisterInstance(atomic, nil);
return (RwObject*)atomic;
}
void
CSimpleModelInfo::Init(void)
{
- m_atomics[0] = nil;
- m_atomics[1] = nil;
- m_atomics[2] = nil;
+ m_atomics = new RpAtomic*[3];
m_numAtomics = 0;
m_firstDamaged = 0;
m_wetRoadReflection = 0;
@@ -72,21 +94,30 @@ CSimpleModelInfo::Init(void)
m_ignoreDrawDist = 0;
m_isCodeGlass = 0;
m_isArtistGlass = 0;
+ m_relatedModel = nil;
}
void
CSimpleModelInfo::SetAtomic(int n, RpAtomic *atomic)
{
- AddTexDictionaryRef();
+ if(m_atomics == nil){
+ m_atomics = new RpAtomic*[3];
+ m_atomics[0] = nil;
+ m_atomics[1] = nil;
+ m_atomics[2] = nil;
+ }
m_atomics[n] = atomic;
+ AddTexDictionaryRef();
if(GetAnimFileIndex() != -1)
CAnimManager::AddAnimBlockRef(GetAnimFileIndex());
RpGeometry *geo = RpAtomicGetGeometry(atomic);
if(m_ignoreLight)
RpGeometrySetFlags(geo, RpGeometryGetFlags(geo) & ~rpGEOMETRYLIGHT);
+/*
if(RpGeometryGetFlags(geo) & rpGEOMETRYNORMALS &&
RpGeometryGetNumTriangles(geo) > 200)
debug("%s has %d polys\n", m_name, RpGeometryGetNumTriangles(geo));
+*/
#ifdef EXTENDED_PIPELINES
if(m_wetRoadReflection)
@@ -137,10 +168,46 @@ CSimpleModelInfo::GetLargestLodDistance(void)
}
RpAtomic*
+CSimpleModelInfo::GetLodAtomic(int n)
+{
+ if(m_atomics == nil || n >= m_numAtomics)
+ return nil;
+ return m_atomics[n];
+}
+
+RpAtomic*
+CSimpleModelInfo::GetLastAtomic(void)
+{
+ if(m_atomics == nil)
+ return nil;
+ if(m_firstDamaged == 0 || m_isDamaged)
+ return m_atomics[m_numAtomics-1];
+ else
+ return m_atomics[m_firstDamaged-1];
+}
+
+RpAtomic*
+CSimpleModelInfo::GetLastAtomic(float dist)
+{
+ int n;
+ if(m_atomics == nil)
+ return nil;
+ if(m_firstDamaged == 0 || m_isDamaged)
+ n = m_numAtomics-1;
+ else
+ n = m_firstDamaged-1;
+ if(dist < m_lodDistances[n] * TheCamera.LODDistMultiplier)
+ return m_atomics[n];
+ return nil;
+}
+
+RpAtomic*
CSimpleModelInfo::GetAtomicFromDistance(float dist)
{
int i;
i = 0;
+// HACk until we figure out what's going on
+if(m_atomics == nil) return nil;
if(m_isDamaged)
i = m_firstDamaged;
for(; i < m_numAtomics; i++)
@@ -152,20 +219,40 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist)
RpAtomic*
CSimpleModelInfo::GetFirstAtomicFromDistance(float dist)
{
+// HACk until we figure out what's going on
+if(m_atomics == nil) return nil;
if(dist < m_lodDistances[0] * TheCamera.LODDistMultiplier)
return m_atomics[0];
return nil;
}
void
-CSimpleModelInfo::FindRelatedModel(int32 minID, int32 maxID)
+CSimpleModelInfo::FindRelatedModel(void)
{
- int i;
CBaseModelInfo *mi;
- for(i = minID; i <= maxID; i++){
- mi = CModelInfo::GetModelInfo(i);
+ int thisIndex, otherIndex;
+
+ // find our own index in temp data
+ for(thisIndex = 0; thisIndex < ARRAY_SIZE(m_sTempIdeData); thisIndex++){
+ if(m_sTempIdeData[thisIndex].id == -1)
+ break;
+ if(this == CModelInfo::GetModelInfo(m_sTempIdeData[thisIndex].id))
+ goto found;
+ }
+ thisIndex = -1;
+found:
+#ifdef FIX_BUGS
+ if(thisIndex == -1)
+ return;
+#endif
+
+ for(otherIndex = 0; otherIndex < ARRAY_SIZE(m_sTempIdeData); otherIndex++){
+ if(m_sTempIdeData[otherIndex].id == -1)
+ break;
+
+ mi = CModelInfo::GetModelInfo(m_sTempIdeData[otherIndex].id);
if(mi && mi != this &&
- !CGeneral::faststrcmp(GetModelName()+3, mi->GetModelName()+3)){
+ !CGeneral::faststrcmp(m_sTempIdeData[thisIndex].name+3, m_sTempIdeData[otherIndex].name+3)){
assert(mi->IsSimple());
this->SetRelatedModel((CSimpleModelInfo*)mi);
return;
@@ -176,12 +263,14 @@ CSimpleModelInfo::FindRelatedModel(int32 minID, int32 maxID)
#define NEAR_DRAW_DIST 100.0f // 0.0f in vice city
void
-CSimpleModelInfo::SetupBigBuilding(int32 minID, int32 maxID)
+CSimpleModelInfo::SetupBigBuilding(void)
{
CSimpleModelInfo *related;
- if(m_lodDistances[0] > LOD_DISTANCE && GetRelatedModel() == nil){
+ if(m_lodDistances[0] < 0.0f)
+ m_lodDistances[0] = -m_lodDistances[0]; // what?
+ else if(m_lodDistances[0] > LOD_DISTANCE && GetRelatedModel() == nil){
m_isBigBuilding = 1;
- FindRelatedModel(minID, maxID);
+ FindRelatedModel();
related = GetRelatedModel();
if(related){
m_lodDistances[2] = related->GetLargestLodDistance()/TheCamera.LODDistMultiplier;
@@ -193,3 +282,79 @@ CSimpleModelInfo::SetupBigBuilding(int32 minID, int32 maxID)
m_lodDistances[2] = NEAR_DRAW_DIST;
}
}
+
+
+void
+CSimpleModelInfo::LoadModel(void *atomics, const void *chunk)
+{
+ int i;
+ m_chunk = (void*)chunk;
+ m_atomics = (RpAtomic**)atomics;
+ CStreaming::RegisterPointer(m_chunk, 2, true);
+ CStreaming::RegisterPointer(m_atomics, 2, true);
+ for(i = 0; i < m_numAtomics; i++){
+ LoadResource(m_atomics[i]);
+ CStreaming::RegisterAtomic(m_atomics[i], nil);
+ }
+}
+
+void
+CSimpleModelInfo::Write(base::cRelocatableChunkWriter &writer)
+{
+ CBaseModelInfo::Write(writer);
+ if(WriteModel(writer))
+ writer.AddPatch(&m_atomics);
+ else
+ m_atomics = nil;
+ if(m_isBigBuilding)
+ writer.AddPatch(&m_relatedModel);
+}
+
+void*
+CSimpleModelInfo::WriteModel(base::cRelocatableChunkWriter &writer)
+{
+ int i;
+ if(m_atomics == nil || m_atomics[0] == nil)
+ return nil;
+
+ // remove empty atomics
+ int numAtomics = 0;
+ for(i = 0; i < m_numAtomics; i++)
+ if(m_atomics[i]){
+ m_atomics[numAtomics] = m_atomics[i];
+#ifdef FIX_BUGS
+ m_lodDistances[numAtomics] = m_lodDistances[i];
+#endif
+ numAtomics++;
+ }
+ if(m_firstDamaged){
+ int firstDam = m_firstDamaged - m_numAtomics + numAtomics;
+ if(firstDam < numAtomics)
+ m_firstDamaged = firstDam;
+ else
+ m_firstDamaged = 0;
+ }
+ m_numAtomics = numAtomics;
+
+ // write the actual models
+ writer.AllocateRaw(m_atomics, m_numAtomics*sizeof(void*), sizeof(void*), false, true);
+ for(i = 0; m_numAtomics; i++){
+ writer.AddPatch(&m_atomics[i]);
+ SaveResource(m_atomics[i], writer);
+ }
+ return m_atomics;
+}
+
+void
+CSimpleModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), 0x10, false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
+
+void
+CSimpleModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), 0x10, false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h
index 986cb886..f9191944 100644
--- a/src/modelinfo/SimpleModelInfo.h
+++ b/src/modelinfo/SimpleModelInfo.h
@@ -2,11 +2,18 @@
#include "BaseModelInfo.h"
+// For linking up models by name
+struct TempIdeData
+{
+ char name[24];
+ int16 id;
+};
+extern TempIdeData m_sTempIdeData[800];
+
class CSimpleModelInfo : public CBaseModelInfo
{
public:
- // atomics[2] is often a pointer to the non-LOD modelinfo
- RpAtomic *m_atomics[3];
+ RpAtomic **m_atomics;
// m_lodDistances[2] holds the near distance for LODs
float m_lodDistances[3];
uint8 m_numAtomics;
@@ -31,15 +38,26 @@ public:
uint16 m_isCodeGlass : 1;
uint16 m_isArtistGlass : 1;
+ CSimpleModelInfo *m_relatedModel;
+
+ static base::cRelocatableChunkClassInfo msClassInfo;
+ static CSimpleModelInfo msClassInstance;
+
CSimpleModelInfo(void) : CBaseModelInfo(MITYPE_SIMPLE) {}
CSimpleModelInfo(ModelInfoType id) : CBaseModelInfo(id) {}
~CSimpleModelInfo() {}
void DeleteRwObject(void);
RwObject *CreateInstance(void);
RwObject *CreateInstance(RwMatrix *);
- RwObject *GetRwObject(void) { return (RwObject*)m_atomics[0]; }
+ RwObject *GetRwObject(void) { return m_atomics ? (RwObject*)m_atomics[0] : nil; }
+
+ virtual void LoadModel(void *atomics, const void *chunk);
+ virtual void Write(base::cRelocatableChunkWriter &writer);
+ virtual void *WriteModel(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer);
- virtual void SetAtomic(int n, RpAtomic *atomic);
+ /*virtual*/ void SetAtomic(int n, RpAtomic *atomic);
void Init(void);
void IncreaseAlpha(void);
@@ -47,15 +65,18 @@ public:
float GetLodDistance(int i);
float GetNearDistance(void);
float GetLargestLodDistance(void);
+ RpAtomic *GetLodAtomic(int n);
+ RpAtomic *GetLastAtomic(void);
+ RpAtomic *GetLastAtomic(float dist);
RpAtomic *GetAtomicFromDistance(float dist);
RpAtomic *GetFirstAtomicFromDistance(float dist);
- void FindRelatedModel(int32 minID, int32 maxID);
- void SetupBigBuilding(int32 minID, int32 maxID);
+ void FindRelatedModel(void);
+ void SetupBigBuilding(void);
void SetNumAtomics(int n) { m_numAtomics = n; }
CSimpleModelInfo *GetRelatedModel(void){
- return (CSimpleModelInfo*)m_atomics[2]; }
+ return m_relatedModel; }
void SetRelatedModel(CSimpleModelInfo *m){
- m_atomics[2] = (RpAtomic*)m; }
+ m_relatedModel = m; }
};
//static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error");
diff --git a/src/modelinfo/TimeModelInfo.cpp b/src/modelinfo/TimeModelInfo.cpp
index 0db5fb78..85b59e43 100644
--- a/src/modelinfo/TimeModelInfo.cpp
+++ b/src/modelinfo/TimeModelInfo.cpp
@@ -3,15 +3,20 @@
#include "Camera.h"
#include "ModelInfo.h"
#include "General.h"
+#include "KeyGen.h"
+
+base::cRelocatableChunkClassInfo CTimeModelInfo::msClassInfo("CTimeModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance));
+CTimeModelInfo CTimeModelInfo::msClassInstance;
+
CTimeModelInfo*
-CTimeModelInfo::FindOtherTimeModel(void)
+CTimeModelInfo::FindOtherTimeModel(const char *modelname)
{
char name[40];
char *p;
int i;
- strcpy(name, GetModelName());
+ strcpy(name, modelname);
// change _nt to _dy
if(p = strstr(name, "_nt"))
strncpy(p, "_dy", 4);
@@ -21,13 +26,29 @@ CTimeModelInfo::FindOtherTimeModel(void)
else
return nil;
+ uint32 nameKey = CKeyGen::GetUppercaseKey(name);
+
for(i = 0; i < MODELINFOSIZE; i++){
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
- if (mi && mi->GetModelType() == MITYPE_TIME &&
- !CGeneral::faststrncmp(name, mi->GetModelName(), MAX_MODEL_NAME)){
+ if (mi && mi->GetModelType() == MITYPE_TIME && nameKey == mi->GetNameHashKey()){
m_otherTimeModelID = i;
return (CTimeModelInfo*)mi;
}
}
return nil;
}
+
+
+void
+CTimeModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
+
+void
+CTimeModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
diff --git a/src/modelinfo/TimeModelInfo.h b/src/modelinfo/TimeModelInfo.h
index 6e3c64fb..67273b21 100644
--- a/src/modelinfo/TimeModelInfo.h
+++ b/src/modelinfo/TimeModelInfo.h
@@ -7,14 +7,21 @@ class CTimeModelInfo : public CSimpleModelInfo
int32 m_timeOn;
int32 m_timeOff;
int32 m_otherTimeModelID;
+
+ static base::cRelocatableChunkClassInfo msClassInfo;
+ static CTimeModelInfo msClassInstance;
+
public:
CTimeModelInfo(void) : CSimpleModelInfo(MITYPE_TIME) { m_otherTimeModelID = -1; }
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer);
+
int32 GetTimeOn(void) { return m_timeOn; }
int32 GetTimeOff(void) { return m_timeOff; }
void SetTimes(int32 on, int32 off) { m_timeOn = on; m_timeOff = off; }
int32 GetOtherTimeModel(void) { return m_otherTimeModelID; }
void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; }
- CTimeModelInfo *FindOtherTimeModel(void);
+ CTimeModelInfo *FindOtherTimeModel(const char *name);
};
//static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error");
diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp
index 4fc455de..bd3a2154 100644
--- a/src/modelinfo/VehicleModelInfo.cpp
+++ b/src/modelinfo/VehicleModelInfo.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include <rpmatfx.h>
+#include "main.h"
#include "RwHelper.h"
#include "General.h"
#include "NodeName.h"
@@ -20,14 +21,21 @@
#include "ModelIndices.h"
#include "ModelInfo.h"
#include "custompipes.h"
+#include "Streaming.h"
+#include "Leeds.h"
-int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 };
-int8 CVehicleModelInfo::ms_compsUsed[2];
-RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256];
-RwTexture *CVehicleModelInfo::ms_colourTextureTable[256];
+base::cRelocatableChunkClassInfo CVehicleModelInfo::msClassInfo("CVehicleModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance));
+CVehicleModelInfo CVehicleModelInfo::msClassInstance;
-RwTexture *gpWhiteTexture;
-RwFrame *pMatFxIdentityFrame;
+//int8 CVehicleModelInfo::ms_compsToUse[2] = { -2, -2 };
+//int8 CVehicleModelInfo::ms_compsUsed[2];
+//RwRGBA CVehicleModelInfo::ms_vehicleColourTable[256];
+CVehicleModelInfo::Statics *CVehicleModelInfo::mspInfo;
+
+//RwTexture *CVehicleModelInfo::ms_colourTextureTable[256];
+
+//RwTexture *gpWhiteTexture;
+//RwFrame *pMatFxIdentityFrame;
enum {
VEHICLE_FLAG_COLLAPSE = 0x2,
@@ -168,6 +176,29 @@ RwObjectNameIdAssocation *CVehicleModelInfo::ms_vehicleDescs[] = {
bool gbBlackCars;
bool gbPinkCars;
+void
+CVehicleModelInfo::Load(void *inst)
+{
+ if(inst)
+ mspInfo = (CVehicleModelInfo::Statics*)inst;
+ else{
+ mspInfo = new CVehicleModelInfo::Statics;
+ memset(mspInfo, 0, sizeof(*mspInfo));
+ mspInfo->ms_compsToUse[0] = -2;
+ mspInfo->ms_compsToUse[1] = -2;
+ }
+}
+
+void*
+CVehicleModelInfo::WriteStaticInfo(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(mspInfo, sizeof(*mspInfo), sizeof(void*), false, true);
+ if(mspInfo->unknown)
+ writer.AddPatch(&mspInfo->unknown);
+ return mspInfo;
+
+}
+
CVehicleModelInfo::CVehicleModelInfo(void)
: CClumpModelInfo(MITYPE_VEHICLE)
{
@@ -178,7 +209,12 @@ CVehicleModelInfo::CVehicleModelInfo(void)
m_positions[i].z = 0.0f;
}
m_numColours = 0;
+ CClumpModelInfo::m_animFileIndex = -1;
+
+ memset(m_materials1, 0, sizeof(m_materials1));
+ memset(m_materials2, 0, sizeof(m_materials2));
m_animFileIndex = -1;
+ m_normalSplay = 0.3f;
}
void
@@ -187,16 +223,78 @@ CVehicleModelInfo::DeleteRwObject(void)
int32 i;
RwFrame *f;
- for(i = 0; i < m_numComps; i++){
- f = RpAtomicGetFrame(m_comps[i]);
- RpAtomicDestroy(m_comps[i]);
- RwFrameDestroy(f);
+ if(!gUseChunkFiles){
+ for(i = 0; i < m_numComps; i++){
+ f = RpAtomicGetFrame(m_comps[i]);
+ RpAtomicDestroy(m_comps[i]);
+ RwFrameDestroy(f);
+ }
+#ifdef FIX_BUGS
+ delete[] m_comps;
+ m_comps = nil;
+#endif
+ m_numComps = 0;
}
- m_numComps = 0;
+
+ RemoveWheels();
+
+ for(i = 0; i < ARRAY_SIZE(m_materials1); i++)
+ CStreaming::UnregisterPointer(&m_materials1[i], 2);
+ for(i = 0; i < ARRAY_SIZE(m_materials2); i++)
+ CStreaming::UnregisterPointer(&m_materials2[i], 2);
+
+ if(m_numComps > 0){
+ CStreaming::UnregisterPointer(&m_comps, 2);
+ for(i = 0; i < m_numComps; i++)
+ CStreaming::UnregisterAtomic(m_comps[i], nil);
+ m_comps = nil;
+ }
+
CClumpModelInfo::DeleteRwObject();
}
RwObject*
+RemoveWheelCB(RwObject *object, void *arg)
+{
+ RpAtomic *atomic = (RpAtomic*)object;
+ if(RwObjectGetType(object) == rpATOMIC){
+ RpClumpRemoveAtomic((RpClump*)arg, atomic);
+#ifdef LIBRW
+ CStreaming::UnregisterPointer(&atomic->inClump.next, 2);
+ CStreaming::UnregisterPointer(&atomic->inClump.prev, 2);
+ CStreaming::UnregisterPointer(&atomic->object.object.parent, 2);
+ CStreaming::UnregisterPointer(&atomic->object.inFrame.next, 2);
+ CStreaming::UnregisterPointer(&atomic->object.inFrame.prev, 2);
+ CStreaming::UnregisterPointer(&atomic->clump, 2);
+#endif
+ RpAtomicDestroy(atomic);
+ }
+ return object;
+}
+
+void
+CVehicleModelInfo::RemoveWheels(void)
+{
+#ifdef FIX_BUGS
+ if(m_clump == nil)
+ return;
+#endif
+ RwObjectNameIdAssocation *desc = ms_vehicleDescs[m_vehicleType];
+ for(int i = 0; desc[i].name; i++){
+ RwObjectIdAssociation assoc;
+
+ if(desc[i].flags & (VEHICLE_FLAG_COMP|VEHICLE_FLAG_POS))
+ continue;
+ assoc.frame = nil;
+ assoc.id = desc[i].hierId;
+ RwFrameForAllChildren(RpClumpGetFrame(m_clump),
+ FindFrameFromIdCB, &assoc);
+ if(assoc.frame && desc[i].flags & VEHICLE_FLAG_ADD_WHEEL && m_wheelId != -1)
+ RwFrameForAllObjects(assoc.frame, RemoveWheelCB, m_clump);
+ }
+}
+
+RwObject*
CVehicleModelInfo::CreateInstance(void)
{
RpClump *clump;
@@ -205,7 +303,7 @@ CVehicleModelInfo::CreateInstance(void)
int32 comp1, comp2;
clump = (RpClump*)CClumpModelInfo::CreateInstance();
- if(m_numComps != 0){
+ if(clump && m_numComps != 0 && strcmp(m_gameName, "POLICAR") != 0){
clumpframe = RpClumpGetFrame(clump);
comp1 = ChooseComponent();
@@ -219,7 +317,7 @@ CVehicleModelInfo::CreateInstance(void)
RpClumpAddAtomic(clump, atomic);
RwFrameAddChild(clumpframe, f);
}
- ms_compsUsed[0] = comp1;
+ mspInfo->ms_compsUsed[0] = comp1;
comp2 = ChooseSecondComponent();
if(comp2 != -1 && m_comps[comp2]){
@@ -232,18 +330,27 @@ CVehicleModelInfo::CreateInstance(void)
RpClumpAddAtomic(clump, atomic);
RwFrameAddChild(clumpframe, f);
}
- ms_compsUsed[1] = comp2;
+ mspInfo->ms_compsUsed[1] = comp2;
}else{
- ms_compsUsed[0] = -1;
- ms_compsUsed[1] = -1;
+ mspInfo->ms_compsUsed[0] = -1;
+ mspInfo->ms_compsUsed[1] = -1;
}
+ CStreaming::RegisterInstance(clump);
return (RwObject*)clump;
}
+RpAtomic*
+SplayNormals(RpAtomic *atomic, void *arg)
+{
+ // PSP only?
+ return atomic;
+}
+
void
CVehicleModelInfo::SetClump(RpClump *clump)
{
CClumpModelInfo::SetClump(clump);
+ RpClumpForAllAtomics((RpClump*)GetRwObject(), SplayNormals, this);
SetAtomicRenderCallbacks();
SetFrameIds(ms_vehicleDescs[m_vehicleType]);
PreprocessHierarchy();
@@ -339,7 +446,7 @@ CVehicleModelInfo::SetAtomicRendererCB(RpAtomic *atomic, void *data)
}else if(strstr(name, "_lo")){
RpClumpRemoveAtomic(clump, atomic);
RpAtomicDestroy(atomic);
- return atomic; // BUG: not done by gta
+ return atomic; // BUG: nil in gta
}else if(strstr(name, "_vlo"))
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB);
else
@@ -398,6 +505,33 @@ CVehicleModelInfo::SetAtomicRendererCB_Train(RpAtomic *atomic, void *data)
}
RpAtomic*
+CVehicleModelInfo::SetAtomicRendererCB_Ferry(RpAtomic *atomic, void *data)
+{
+ char *name;
+ bool alpha;
+
+ name = GetFrameNodeName(RpAtomicGetFrame(atomic));
+ alpha = false;
+ RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), HasAlphaMaterialCB, &alpha);
+ if(strstr(name, "_hi")){
+ if(alpha)
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderTrainHiDetailAlphaCB);
+ else
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderTrainHiDetailCB);
+ }else if(strstr(name, "_lo")){
+ if(alpha)
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle);
+ else
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle);
+ }else if(strstr(name, "_vlo"))
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle);
+ else
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
+ HideDamagedAtomicCB(atomic, nil);
+ return atomic;
+}
+
+RpAtomic*
CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data)
{
RpClump *clump;
@@ -414,7 +548,31 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data)
RpAtomicDestroy(atomic);
return atomic; // BUG: not done by gta
}else if(strstr(name, "_vlo"))
- CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle);
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLoDetailCB_Boat);
+ else
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
+ HideDamagedAtomicCB(atomic, nil);
+ return atomic;
+}
+
+RpAtomic*
+CVehicleModelInfo::SetAtomicRendererCB_Boat_Far(RpAtomic *atomic, void *data)
+{
+ RpClump *clump;
+ char *name;
+
+ clump = (RpClump*)data;
+ name = GetFrameNodeName(RpAtomicGetFrame(atomic));
+ if(strcmp(name, "boat_hi") == 0 || !CGeneral::faststrncmp(name, "extra", 5))
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far);
+ else if(strstr(name, "_hi"))
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleHiDetailCB);
+ else if(strstr(name, "_lo")){
+ RpClumpRemoveAtomic(clump, atomic);
+ RpAtomicDestroy(atomic);
+ return atomic; // BUG: not done by gta
+ }else if(strstr(name, "_vlo"))
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far);
else
CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
HideDamagedAtomicCB(atomic, nil);
@@ -424,6 +582,7 @@ CVehicleModelInfo::SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data)
RpAtomic*
CVehicleModelInfo::SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data)
{
+/* // LCS: gone, may be better to keep it though
char *name;
name = GetFrameNodeName(RpAtomicGetFrame(atomic));
@@ -432,6 +591,7 @@ CVehicleModelInfo::SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data)
else if(strncmp(name, "rearrotor", 9) == 0)
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleTailRotorAlphaCB);
else
+*/
CVisibilityPlugins::SetAtomicRenderCallback(atomic, nil);
return atomic;
}
@@ -459,7 +619,7 @@ CVehicleModelInfo::SetAtomicRendererCB_RealHeli(RpAtomic *atomic, void *data)
}else if(strstr(name, "_lo")){
RpClumpRemoveAtomic(clump, atomic);
RpAtomicDestroy(atomic);
- return atomic; // BUG: not done by gta
+ return atomic; // BUG: nil in gta
}else if(strstr(name, "_vlo"))
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderVehicleReallyLowDetailCB);
else
@@ -476,13 +636,18 @@ CVehicleModelInfo::SetAtomicRenderCallbacks(void)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Train, nil);
else
#endif
- if(m_vehicleType == VEHICLE_TYPE_HELI)
+ if(m_vehicleType == VEHICLE_TYPE_FERRY)
+ RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Ferry, nil);
+ else if(m_vehicleType == VEHICLE_TYPE_HELI)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Heli, nil);
else if(m_vehicleType == VEHICLE_TYPE_PLANE)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_BigVehicle, nil);
- else if(m_vehicleType == VEHICLE_TYPE_BOAT)
- RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat, m_clump);
- else if(mod_HandlingManager.GetHandlingData((tVehicleType)m_handlingId)->Flags & HANDLING_IS_HELI)
+ else if(m_vehicleType == VEHICLE_TYPE_BOAT){
+ if(strcmp(m_gameName, "REEFER") == 0)
+ RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat_Far, m_clump);
+ else
+ RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_Boat, m_clump);
+ }else if(mod_HandlingManager.GetHandlingData((tVehicleType)m_handlingId)->Flags & HANDLING_IS_HELI)
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB_RealHeli, m_clump);
else
RpClumpForAllAtomics(m_clump, SetAtomicRendererCB, m_clump);
@@ -530,6 +695,8 @@ CVehicleModelInfo::PreprocessHierarchy(void)
m_numDoors = 0;
m_numComps = 0;
+ m_comps = new RpAtomic*[7];
+
for(i = 0; desc[i].name; i++){
RwObjectNameAssociation assoc;
@@ -587,21 +754,23 @@ CVehicleModelInfo::PreprocessHierarchy(void)
SetVehicleComponentFlags(assoc.frame, desc[i].flags);
- if(desc[i].flags & VEHICLE_FLAG_ADD_WHEEL){
- if(m_wheelId == -1)
- RwFrameDestroy(assoc.frame);
- else{
- RwV3d scale;
- atomic = (RpAtomic*)CModelInfo::GetModelInfo(m_wheelId)->CreateInstance();
- RwFrameDestroy(RpAtomicGetFrame(atomic));
- RpAtomicSetFrame(atomic, assoc.frame);
- RpClumpAddAtomic(m_clump, atomic);
- CVisibilityPlugins::SetAtomicRenderCallback(atomic,
- CVisibilityPlugins::RenderWheelAtomicCB);
- scale.x = m_wheelScale;
- scale.y = m_wheelScale;
- scale.z = m_wheelScale;
- RwFrameScale(assoc.frame, &scale, rwCOMBINEPRECONCAT);
+ if(!(gMakeResources && gUseResources)){
+ if(desc[i].flags & VEHICLE_FLAG_ADD_WHEEL){
+ if(m_wheelId == -1)
+ RwFrameDestroy(assoc.frame);
+ else{
+ RwV3d scale;
+ atomic = (RpAtomic*)CModelInfo::GetModelInfo(m_wheelId)->CreateInstance();
+ RwFrameDestroy(RpAtomicGetFrame(atomic));
+ RpAtomicSetFrame(atomic, assoc.frame);
+ RpClumpAddAtomic(m_clump, atomic);
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic,
+ CVisibilityPlugins::RenderWheelAtomicCB);
+ scale.x = m_wheelScale;
+ scale.y = m_wheelScale;
+ scale.z = m_wheelScale;
+ RwFrameScale(assoc.frame, &scale, rwCOMBINEPRECONCAT);
+ }
}
}
}
@@ -629,9 +798,9 @@ CVehicleModelInfo::SetVehicleComponentFlags(RwFrame *frame, uint32 flags)
SETFLAGS(ATOMIC_FLAG_FRONT);
else if(flags & VEHICLE_FLAG_REAR && (handling->Flags & HANDLING_IS_VAN || (flags & (VEHICLE_FLAG_LEFT|VEHICLE_FLAG_RIGHT)) == 0))
SETFLAGS(ATOMIC_FLAG_REAR);
- if(flags & VEHICLE_FLAG_LEFT)
+ else if(flags & VEHICLE_FLAG_LEFT)
SETFLAGS(ATOMIC_FLAG_LEFT);
- if(flags & VEHICLE_FLAG_RIGHT)
+ else if(flags & VEHICLE_FLAG_RIGHT)
SETFLAGS(ATOMIC_FLAG_RIGHT);
if(flags & VEHICLE_FLAG_REARDOOR)
@@ -746,7 +915,7 @@ CVehicleModelInfo::ChooseComponent(void)
int32 n;
comp = -1;
- if(ms_compsToUse[0] == -2){
+ if(mspInfo->ms_compsToUse[0] == -2){
if(COMPRULE_RULE(m_compRules) && IsValidCompRule(COMPRULE_RULE(m_compRules)))
comp = ::ChooseComponent(COMPRULE_RULE(m_compRules), COMPRULE_COMPS(m_compRules));
else if(CGeneral::GetRandomNumberInRange(0, 3) < 2){
@@ -755,8 +924,8 @@ CVehicleModelInfo::ChooseComponent(void)
comp = comps[(int)CGeneral::GetRandomNumberInRange(0, n)];
}
}else{
- comp = ms_compsToUse[0];
- ms_compsToUse[0] = -2;
+ comp = mspInfo->ms_compsToUse[0];
+ mspInfo->ms_compsToUse[0] = -2;
}
return comp;
}
@@ -769,7 +938,7 @@ CVehicleModelInfo::ChooseSecondComponent(void)
int32 n;
comp = -1;
- if(ms_compsToUse[1] == -2){
+ if(mspInfo->ms_compsToUse[1] == -2){
if(COMPRULE2_RULE(m_compRules) && IsValidCompRule(COMPRULE2_RULE(m_compRules)))
comp = ::ChooseComponent(COMPRULE2_RULE(m_compRules), COMPRULE2_COMPS(m_compRules));
else if(COMPRULE_RULE(m_compRules) && IsValidCompRule(COMPRULE_RULE(m_compRules)) &&
@@ -780,8 +949,8 @@ CVehicleModelInfo::ChooseSecondComponent(void)
comp = comps[(int)CGeneral::GetRandomNumberInRange(0, n)];
}
}else{
- comp = ms_compsToUse[1];
- ms_compsToUse[1] = -2;
+ comp = mspInfo->ms_compsToUse[1];
+ mspInfo->ms_compsToUse[1] = -2;
}
return comp;
}
@@ -796,7 +965,7 @@ struct editableMatCBData
RpMaterial*
CVehicleModelInfo::GetEditableMaterialListCB(RpMaterial *material, void *data)
{
- static RwRGBA white = { 255, 255, 255, 255 };
+ RwRGBA white = { 255, 255, 255, 255 };
const RwRGBA *col;
editableMatCBData *cbdata;
@@ -849,7 +1018,7 @@ CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2)
RpMaterial **matp;
if(c1 != m_currentColour1){
- col = ms_vehicleColourTable[c1];
+ col = mspInfo->ms_vehicleColourTable[c1];
for(matp = m_materials1; *matp; matp++){
colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const
colp->red = col.red;
@@ -860,7 +1029,7 @@ CVehicleModelInfo::SetVehicleColour(uint8 c1, uint8 c2)
}
if(c2 != m_currentColour2){
- col = ms_vehicleColourTable[c2];
+ col = mspInfo->ms_vehicleColourTable[c2];
for(matp = m_materials2; *matp; matp++){
colp = (RwRGBA*)RpMaterialGetColor(*matp); // get rid of const
colp->red = col.red;
@@ -985,8 +1154,8 @@ CVehicleModelInfo::LoadVehicleColours(void)
fd = CFileMgr::OpenFile("CARCOLS.DAT", "r");
CFileMgr::ChangeDir("\\");
- for(i = 0; i < 256; i++)
- ms_colourTextureTable[i] = nil;
+ //for(i = 0; i < 256; i++)
+ // ms_colourTextureTable[i] = nil;
section = 0;
numCols = 0;
@@ -1018,10 +1187,10 @@ CVehicleModelInfo::LoadVehicleColours(void)
}else if(section == COLOURS){
sscanf(&line[start], // BUG: games doesn't add start
"%d %d %d", &r, &g, &b);
- ms_vehicleColourTable[numCols].red = r;
- ms_vehicleColourTable[numCols].green = g;
- ms_vehicleColourTable[numCols].blue = b;
- ms_vehicleColourTable[numCols].alpha = 0xFF;
+ mspInfo->ms_vehicleColourTable[numCols].red = r;
+ mspInfo->ms_vehicleColourTable[numCols].green = g;
+ mspInfo->ms_vehicleColourTable[numCols].blue = b;
+ mspInfo->ms_vehicleColourTable[numCols].alpha = 0xFF;
numCols++;
}else if(section == CARS){
n = sscanf(&line[start], // BUG: games doesn't add start
@@ -1051,6 +1220,7 @@ CVehicleModelInfo::LoadVehicleColours(void)
void
CVehicleModelInfo::DeleteVehicleColourTextures(void)
{
+/*
int i;
for(i = 0; i < 256; i++){
@@ -1059,6 +1229,7 @@ CVehicleModelInfo::DeleteVehicleColourTextures(void)
ms_colourTextureTable[i] = nil;
}
}
+*/
}
RpMaterial*
@@ -1070,6 +1241,7 @@ CVehicleModelInfo::GetMatFXEffectMaterialCB(RpMaterial *material, void *data)
return nil;
}
+/*
RpMaterial*
CVehicleModelInfo::SetDefaultEnvironmentMapCB(RpMaterial *material, void *data)
{
@@ -1086,7 +1258,9 @@ CVehicleModelInfo::SetDefaultEnvironmentMapCB(RpMaterial *material, void *data)
}
return material;
}
+*/
+/*
RpAtomic*
CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
{
@@ -1102,6 +1276,7 @@ CVehicleModelInfo::SetEnvironmentMapCB(RpAtomic *atomic, void *data)
}
return atomic;
}
+*/
void
CVehicleModelInfo::SetEnvironmentMap(void)
@@ -1178,10 +1353,162 @@ CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(int id)
}
if(n == 0)
- return id == MI_RCBANDIT || id == MI_PIZZABOY || id == MI_BAGGAGE ? 0 : 1;
+ return id == MI_RCBANDIT /*|| id == MI_PIZZABOY || id == MI_BAGGAGE*/ ? 0 : 1;
if(id == MI_COACH)
return 8;
return n - 1;
}
+
+
+struct VehicleChunk
+{
+ RpClump *clump;
+ int32 numComps;
+ RpAtomic **comp;
+ RpMaterial *materials1[NUM_FIRST_MATERIALS];
+ RpMaterial *materials2[NUM_SECOND_MATERIALS];
+};
+
+void
+CVehicleModelInfo::LoadModel(void *data, const void *chunk)
+{
+ int i;
+ VehicleChunk *chk = (VehicleChunk*)data;
+ CClumpModelInfo::LoadModel(chk->clump, chunk);
+
+ // editable materials
+ for(i = 0; i < NUM_FIRST_MATERIALS; i++){
+ m_materials1[i] = chk->materials1[i];
+ if(m_materials1[i])
+ CStreaming::RegisterPointer(&m_materials1[i], 2, true);
+ }
+ for(i = 0; i < NUM_SECOND_MATERIALS; i++){
+ m_materials2[i] = chk->materials2[i];
+ if(m_materials2[i])
+ CStreaming::RegisterPointer(&m_materials2[i], 2, true);
+ }
+
+ // extra components
+ m_numComps = chk->numComps;
+ if(m_numComps > 0){
+ m_comps = chk->comp;
+ CStreaming::RegisterPointer(&m_comps, 2, true);
+ for(i = 0; i < m_numComps; i++){
+ LoadResource(m_comps[i]);
+ CStreaming::RegisterAtomic(m_comps[i], nil);
+ }
+ }else
+ m_comps = nil;
+
+ m_currentColour1 = -1;
+ m_currentColour2 = -1;
+
+ // add wheels
+ RwObjectNameIdAssocation *desc = ms_vehicleDescs[m_vehicleType];
+ for(i = 0; desc[i].name; i++){
+ RwObjectIdAssociation assoc;
+
+ if(desc[i].flags & (VEHICLE_FLAG_COMP|VEHICLE_FLAG_POS))
+ continue;
+ assoc.frame = nil;
+ assoc.id = desc[i].hierId;
+ RwFrameForAllChildren(RpClumpGetFrame(m_clump),
+ FindFrameFromIdCB, &assoc);
+ if(assoc.frame && desc[i].flags & VEHICLE_FLAG_ADD_WHEEL && m_wheelId != -1){
+ RwV3d scale;
+ RpAtomic *atomic = (RpAtomic*)CModelInfo::GetModelInfo(m_wheelId)->CreateInstance();
+ RwFrameDestroy(RpAtomicGetFrame(atomic));
+ RpAtomicSetFrame(atomic, assoc.frame);
+ RpClumpAddAtomic(m_clump, atomic);
+ CVisibilityPlugins::SetAtomicRenderCallback(atomic,
+ CVisibilityPlugins::RenderWheelAtomicCB);
+ scale.x = m_wheelScale;
+ scale.y = m_wheelScale;
+ scale.z = m_wheelScale;
+ RwFrameScale(assoc.frame, &scale, rwCOMBINEPRECONCAT);
+#ifdef LIBRW
+ CStreaming::RegisterPointer(&atomic->inClump.next, 2, true);
+ CStreaming::RegisterPointer(&atomic->inClump.prev, 2, true);
+ CStreaming::RegisterPointer(&atomic->object.object.parent, 2, true);
+ CStreaming::RegisterPointer(&atomic->object.inFrame.next, 2, true);
+ CStreaming::RegisterPointer(&atomic->object.inFrame.prev, 2, true);
+ CStreaming::RegisterPointer(&atomic->clump, 2, true);
+#endif
+ }
+ }
+}
+
+void
+CVehicleModelInfo::Write(base::cRelocatableChunkWriter &writer)
+{
+ CClumpModelInfo::Write(writer);
+}
+
+void*
+CVehicleModelInfo::WriteModel(base::cRelocatableChunkWriter &writer)
+{
+ if(GetRwObject() == nil)
+ return nil;
+
+ int i;
+ VehicleChunk *chk = new VehicleChunk;
+ memset(chk, 0, sizeof(*chk));
+ writer.AllocateRaw(chk, sizeof(*chk), sizeof(void*), false, true);
+
+ // clump
+ chk->clump = (RpClump*)CClumpModelInfo::WriteModel(writer);
+ if(chk->clump)
+ writer.AddPatch(&chk->clump);
+
+ // materials
+ for(i = 0; i < NUM_FIRST_MATERIALS; i++){
+ if(m_materials1[i] == nil || m_vehicleType == VEHICLE_TYPE_FERRY)
+ chk->materials1[i] = nil;
+ else{
+ SaveResource(m_materials1[i], writer);
+ chk->materials1[i] = m_materials1[i];
+ writer.AddPatch(&chk->materials1[i]);
+ }
+ }
+ for(i = 0; i < NUM_SECOND_MATERIALS; i++){
+ if(m_materials2[i] == nil || m_vehicleType == VEHICLE_TYPE_FERRY)
+ chk->materials2[i] = nil;
+ else{
+ SaveResource(m_materials2[i], writer);
+ chk->materials2[i] = m_materials2[i];
+ writer.AddPatch(&chk->materials2[i]);
+ }
+ }
+
+ // extra components
+ chk->numComps = m_numComps;
+ chk->comp = nil;
+ if(m_numComps > 0){
+ chk->comp = m_comps;
+ writer.AddPatch(&chk->comp);
+
+ writer.AllocateRaw(m_comps, m_numComps*sizeof(void*), sizeof(void*), false, true);
+ for(i = 0; i < m_numComps; i++)
+ if(m_comps[i]){
+ SaveResource(m_comps[i], writer);
+ writer.AddPatch(&m_comps[i]);
+ }
+ }
+ return chk;
+}
+
+void
+CVehicleModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
+
+void
+CVehicleModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h
index f9217a41..f979c2c0 100644
--- a/src/modelinfo/VehicleModelInfo.h
+++ b/src/modelinfo/VehicleModelInfo.h
@@ -98,19 +98,30 @@ public:
uint8 m_lastColorVariation;
uint8 m_currentColour1;
uint8 m_currentColour2;
- RpAtomic *m_comps[6]; // LCS(TODO): pointer
+ RpAtomic **m_comps;
+ float m_normalSplay;
// This is stupid, CClumpModelInfo already has it!
union {
int32 m_animFileIndex;
char *m_animFileName;
};
- static int8 ms_compsToUse[2];
- static int8 ms_compsUsed[2];
- static RwRGBA ms_vehicleColourTable[256];
- static RwTexture *ms_colourTextureTable[256];
+ static base::cRelocatableChunkClassInfo msClassInfo;
+ static CVehicleModelInfo msClassInstance;
+
+ struct Statics {
+ void *unknown; // unused too it seems
+ RwRGBA ms_vehicleColourTable[256];
+ int8 ms_compsUsed[2];
+ int8 ms_compsToUse[2];
+ };
+ //static RwTexture *ms_colourTextureTable[256];
+ static Statics *mspInfo;
static RwObjectNameIdAssocation *ms_vehicleDescs[NUM_VEHICLE_TYPES];
+ static void Load(void *inst);
+ static void *WriteStaticInfo(base::cRelocatableChunkWriter &writer);
+
CVehicleModelInfo(void);
void DeleteRwObject(void);
RwObject *CreateInstance(void);
@@ -119,6 +130,12 @@ public:
void ConvertAnimFileIndex(void);
int GetAnimFileIndex(void) { return m_animFileIndex; }
+ virtual void LoadModel(void *model, const void *chunk);
+ virtual void Write(base::cRelocatableChunkWriter &writer);
+ virtual void *WriteModel(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer);
+
static RwFrame *CollapseFramesCB(RwFrame *frame, void *data);
static RwObject *MoveObjectsCB(RwObject *object, void *data);
static RpAtomic *HideDamagedAtomicCB(RpAtomic *atomic, void *data);
@@ -128,13 +145,16 @@ public:
static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data);
static RpAtomic *SetAtomicRendererCB_BigVehicle(RpAtomic *atomic, void *data);
static RpAtomic *SetAtomicRendererCB_Train(RpAtomic *atomic, void *data);
+ static RpAtomic *SetAtomicRendererCB_Ferry(RpAtomic *atomic, void *data);
static RpAtomic *SetAtomicRendererCB_Boat(RpAtomic *atomic, void *data);
+ static RpAtomic *SetAtomicRendererCB_Boat_Far(RpAtomic *atomic, void *data);
static RpAtomic *SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data);
static RpAtomic *SetAtomicRendererCB_RealHeli(RpAtomic *atomic, void *data);
void SetAtomicRenderCallbacks(void);
static RwObject *SetAtomicFlagCB(RwObject *object, void *data);
static RwObject *ClearAtomicFlagCB(RwObject *atomic, void *data);
+ void RemoveWheels(void);
void SetVehicleComponentFlags(RwFrame *frame, uint32 flags);
void PreprocessHierarchy(void);
void GetWheelPosn(int32 n, CVector &pos);
@@ -160,7 +180,7 @@ public:
static void ShutdownEnvironmentMaps(void);
static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id);
- static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; }
+ static void SetComponentsToUse(int8 c1, int8 c2) { mspInfo->ms_compsToUse[0] = c1; mspInfo->ms_compsToUse[1] = c2; }
};
extern bool gbBlackCars;
diff --git a/src/modelinfo/WeaponModelInfo.cpp b/src/modelinfo/WeaponModelInfo.cpp
index d9294c3f..1d194ec4 100644
--- a/src/modelinfo/WeaponModelInfo.cpp
+++ b/src/modelinfo/WeaponModelInfo.cpp
@@ -4,6 +4,9 @@
#include "AnimManager.h"
#include "VisibilityPlugins.h"
+base::cRelocatableChunkClassInfo CWeaponModelInfo::msClassInfo("CWeaponModelInfo", VTABLE_ADDR(&msClassInstance), sizeof(msClassInstance));
+CWeaponModelInfo CWeaponModelInfo::msClassInstance;
+
void
CWeaponModelInfo::SetAnimFile(const char *file)
{
@@ -35,19 +38,34 @@ CWeaponModelInfo::Init(void)
void
CWeaponModelInfo::SetWeaponInfo(int32 weaponId)
{
- m_atomics[2] = (RpAtomic*)weaponId;
+ m_relatedModel = (CSimpleModelInfo*)weaponId;
}
eWeaponType
CWeaponModelInfo::GetWeaponInfo(void)
{
- return (eWeaponType)(uintptr)m_atomics[2];
+ return (eWeaponType)(uintptr)m_relatedModel;
}
+/*
void
CWeaponModelInfo::SetAtomic(int n, RpAtomic *atomic)
{
CSimpleModelInfo::SetAtomic(n, atomic);
CVisibilityPlugins::SetAtomicRenderCallback(atomic, CVisibilityPlugins::RenderWeaponCB);
}
+*/
+
+void
+CWeaponModelInfo::RcWriteThis(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
+void
+CWeaponModelInfo::RcWriteEmpty(base::cRelocatableChunkWriter &writer)
+{
+ writer.AllocateRaw(this, sizeof(*this), sizeof(void*), false, true);
+ writer.Class(VTABLE_ADDR(this), msClassInfo);
+}
diff --git a/src/modelinfo/WeaponModelInfo.h b/src/modelinfo/WeaponModelInfo.h
index 548bf8a6..8dc9baf1 100644
--- a/src/modelinfo/WeaponModelInfo.h
+++ b/src/modelinfo/WeaponModelInfo.h
@@ -9,13 +9,21 @@ class CWeaponModelInfo : public CSimpleModelInfo
int32 m_animFileIndex;
char *m_animFileName;
};
+
+ static base::cRelocatableChunkClassInfo msClassInfo;
+ static CWeaponModelInfo msClassInstance;
+
public:
CWeaponModelInfo(void) : CSimpleModelInfo(MITYPE_WEAPON) { m_animFileIndex = -1; }
virtual void SetAnimFile(const char *file);
virtual void ConvertAnimFileIndex(void);
virtual int GetAnimFileIndex(void) { return m_animFileIndex; }
- virtual void SetAtomic(int n, RpAtomic *atomic);
+
+ virtual void RcWriteThis(base::cRelocatableChunkWriter &writer);
+ virtual void RcWriteEmpty(base::cRelocatableChunkWriter &writer);
+
+ //virtual void SetAtomic(int n, RpAtomic *atomic);
void Init(void);
void SetWeaponInfo(int32 weaponId);
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index d0f155c5..cf566aba 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -3342,6 +3342,7 @@ void
CPed::LineUpPedWithCar(PedLineUpPhase phase)
{
bool vehIsUpsideDown = false;
+ bool stillGettingInOut = false;
int vehAnim;
float seatPosMult = 0.0f;
float currentZ;
@@ -3594,8 +3595,8 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_pVehicleAnim && vehAnim != ANIM_VAN_GETIN_L && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE && vehAnim != ANIM_VAN_GETIN) {
neededPos.z = autoZPos.z;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- } else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
- adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
+ } else if (neededPos.z < currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
+ adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep);
@@ -3613,7 +3614,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_pVehicleAnim &&
(vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS
|| vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) {
- adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
+ adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ;
@@ -3625,7 +3626,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
}
}
- bool stillGettingInOut = false;
if (CTimer::GetTimeInMilliseconds() < m_nPedStateTimer)
stillGettingInOut = veh->m_vehType != VEHICLE_TYPE_BOAT || bOnBoat;
@@ -4138,7 +4138,7 @@ CPed::SetExitBoat(CVehicle *boat)
RemoveInCarAnims();
CColModel* boatCol = boat->GetColModel();
if (boat->IsUpsideDown()) {
- newPos = { 0.0f, 0.0f, boatCol->boundingBox.min.z };
+ newPos = CVector(0.0f, 0.0f, boatCol->boundingBox.min.z);
newPos = boat->GetMatrix() * newPos;
newPos.z += 1.0f;
m_vehDoor = CAR_DOOR_RF;
diff --git a/src/peds/PedAttractor.cpp b/src/peds/PedAttractor.cpp
index 22e0e779..de587270 100644
--- a/src/peds/PedAttractor.cpp
+++ b/src/peds/PedAttractor.cpp
@@ -104,7 +104,7 @@ bool CVehicleToEffect::HasThisEffect(C2dEffect* pEffect) const
const C2dEffect* CPedAttractorManager::GetEffectForIceCreamVan(CVehicle* pVehicle, const CVector& pos)
{
if (!vVehicleToEffect.empty()) {
- for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend(); ++assoc) {
+ for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.begin(); assoc != vVehicleToEffect.end(); ++assoc) {
if (assoc->GetVehicle() == pVehicle)
return assoc->ChooseEffect(pos);
}
@@ -120,7 +120,7 @@ CVehicle* CPedAttractorManager::GetIceCreamVanForEffect(C2dEffect* pEffect)
{
if (vVehicleToEffect.empty())
return nil;
- for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend(); ++assoc) {
+ for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.begin(); assoc != vVehicleToEffect.end(); ++assoc) {
if (assoc->HasThisEffect(pEffect))
return assoc->GetVehicle();
}
@@ -131,7 +131,7 @@ const CPedAttractor* CPedAttractorManager::FindAssociatedAttractor(const C2dEffe
{
if (vecAttractors.empty())
return nil;
- for (std::vector<CPedAttractor*>::const_iterator attractor = vecAttractors.cbegin(); attractor != vecAttractors.cend(); ++attractor) {
+ for (std::vector<CPedAttractor*>::const_iterator attractor = vecAttractors.begin(); attractor != vecAttractors.end(); ++attractor) {
if ((*attractor)->GetEffect() == pEffect)
return *attractor;
}
@@ -145,7 +145,7 @@ void CPedAttractorManager::RemoveIceCreamVanEffects(C2dEffect* pEffect)
return;
if (vVehicleToEffect.empty())
return;
- for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend();) {
+ for (std::vector<CVehicleToEffect>::iterator assoc = vVehicleToEffect.begin(); assoc != vVehicleToEffect.end();) {
if (assoc->GetVehicle() != pVehicle) {
++assoc;
continue;
@@ -229,7 +229,7 @@ CVector CPedShelterAttractor::GetDisplacement(int32 qid) const
float fRandomOffset = CGeneral::GetRandomNumberInRange(0.0f, 2.0f);
CVector vecDisplacement(fRandomOffset * Sin(fRandomAngle), fRandomOffset * Cos(fRandomAngle), 0.0f);
bool close = false;
- for (std::vector<CVector>::const_iterator v = ms_displacements.cbegin(); v != ms_displacements.cend(); ++v) {
+ for (std::vector<CVector>::const_iterator v = ms_displacements.begin(); v != ms_displacements.end(); ++v) {
if ((*v - vecDisplacement).Magnitude() < 1.0f) {
close = true;
break;
@@ -265,7 +265,7 @@ void CPedShelterAttractor::ComputeAttractHeading(int32 qid, float& heading) cons
bool CPedAttractor::RegisterPed(CPed* pPed)
{
- for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) {
if (*pPedIt == pPed) {
vApproachingQueue.erase(pPedIt);
return false;
@@ -318,7 +318,7 @@ static bool IsPedUsingAttractorOfThisType(int8 type, CPed* pPed)
bool CPedAttractor::DeRegisterPed(CPed* pPed)
{
- for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) {
if (*pPedIt != pPed)
continue;
pPed->m_attractor = nil;
@@ -340,12 +340,12 @@ bool CPedAttractor::DeRegisterPed(CPed* pPed)
bool CPedAttractor::BroadcastArrival(CPed* pPed)
{
- for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.cbegin(); pPedIt != vWaitingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.begin(); pPedIt != vWaitingQueue.end(); ++pPedIt) {
if (*pPedIt == pPed)
return false;
}
vWaitingQueue.push_back(pPed);
- for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) {
if (*pPedIt == pPed) {
vApproachingQueue.erase(pPedIt);
break;
@@ -400,7 +400,7 @@ bool CPedAttractor::BroadcastDeparture(CPed* pPed)
pPed->SetWanderPath(CGeneral::GetNodeHeadingFromVector(-vecQueueDir.y, -vecQueueDir.x));
UpdatePedStateOnDeparture(pPed);
}
- vWaitingQueue.erase(vWaitingQueue.cbegin() + qid);
+ vWaitingQueue.erase(vWaitingQueue.begin() + qid);
for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) {
CPed* pPed = *pPedIt;
CVector pos;
@@ -441,7 +441,7 @@ bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed)
pPed->SetWanderPath(CGeneral::GetNodeHeadingFromVector(-vecQueueDir.y, -vecQueueDir.x));
UpdatePedStateOnDeparture(pPed);
}
- vWaitingQueue.erase(vWaitingQueue.cbegin() + qid);
+ vWaitingQueue.erase(vWaitingQueue.begin() + qid);
for (std::vector<CPed*>::iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) {
CPed* pPed = *pPedIt;
CVector pos;
@@ -458,11 +458,11 @@ bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed)
bool CPedAttractor::IsRegisteredWithPed(CPed* pPed) const
{
- for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.cbegin(); pPedIt != vWaitingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.begin(); pPedIt != vWaitingQueue.end(); ++pPedIt) {
if (*pPedIt == pPed)
return true;
}
- for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.cbegin(); pPedIt != vApproachingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::const_iterator pPedIt = vApproachingQueue.begin(); pPedIt != vApproachingQueue.end(); ++pPedIt) {
if (*pPedIt == pPed) {
return true;
}
@@ -472,7 +472,7 @@ bool CPedAttractor::IsRegisteredWithPed(CPed* pPed) const
bool CPedAttractor::IsInQueue(CPed* pPed) const
{
- for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.cbegin(); pPedIt != vWaitingQueue.cend(); ++pPedIt) {
+ for (std::vector<CPed*>::const_iterator pPedIt = vWaitingQueue.begin(); pPedIt != vWaitingQueue.end(); ++pPedIt) {
if (*pPedIt == pPed)
return true;
}
@@ -640,7 +640,7 @@ void CPedAttractorManager::ComputeEffectUseDir(const C2dEffect* pEffect, const C
CPedAttractor* CPedAttractorManager::RegisterPed(CPed* pPed, C2dEffect* pEffect, const CMatrix& matrix, std::vector<CPedAttractor*>& vecAttractors)
{
CPedAttractor* pRegisteredAttractor = nil;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
CPedAttractor* pAttractor = *pAttractorIt;
CVector vEffectPos;
ComputeEffectPos(pAttractor->GetEffect(), matrix, vEffectPos);
@@ -676,7 +676,7 @@ bool CPedAttractorManager::DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor,
if (!pAttractor)
return false;
CPedAttractor* pFound = nil;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
pFound = *pAttractorIt;
break;
@@ -687,7 +687,7 @@ bool CPedAttractorManager::DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor,
pFound->DeRegisterPed(pPed);
if (pFound->GetNoOfRegisteredPeds() != 0)
return true;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
vecAttractors.erase(pAttractorIt);
break;
@@ -702,7 +702,7 @@ bool CPedAttractorManager::BroadcastArrival(CPed* pPed, CPedAttractor* pAttracto
if (!pAttractor)
return false;
CPedAttractor* pFound = nil;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
pFound = *pAttractorIt;
break;
@@ -719,7 +719,7 @@ bool CPedAttractorManager::BroadcastDeparture(CPed* pPed, CPedAttractor* pAttrac
if (!pAttractor)
return false;
CPedAttractor* pFound = nil;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
pFound = *pAttractorIt;
break;
@@ -730,7 +730,7 @@ bool CPedAttractorManager::BroadcastDeparture(CPed* pPed, CPedAttractor* pAttrac
pFound->DeRegisterPed(pPed);
if (pFound->GetNoOfRegisteredPeds() != 0)
return true;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
vecAttractors.erase(pAttractorIt);
break;
@@ -744,7 +744,7 @@ bool CPedAttractorManager::IsInQueue(CPed* pPed, CPedAttractor* pAttractor, std:
{
if (!pAttractor)
return false;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
return (*pAttractorIt)->IsInQueue(pPed);
}
@@ -756,7 +756,7 @@ bool CPedAttractorManager::IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor
{
if (!pAttractor)
return false;
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if (*pAttractorIt == pAttractor) {
return (*pAttractorIt)->IsAtHeadOfQueue(pPed);
}
@@ -766,7 +766,7 @@ bool CPedAttractorManager::IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor
bool CPedAttractorManager::IsPedRegistered(CPed* pPed, std::vector<CPedAttractor*>& vecAttractors)
{
- for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.cbegin(); pAttractorIt != vecAttractors.cend(); ++pAttractorIt) {
+ for (std::vector<CPedAttractor*>::const_iterator pAttractorIt = vecAttractors.begin(); pAttractorIt != vecAttractors.end(); ++pAttractorIt) {
if ((*pAttractorIt)->IsRegisteredWithPed(pPed))
return true;
}
diff --git a/src/peds/PedAttractor.h b/src/peds/PedAttractor.h
index 85b4327b..c55e4028 100644
--- a/src/peds/PedAttractor.h
+++ b/src/peds/PedAttractor.h
@@ -126,8 +126,8 @@ public:
class CPedAtmAttractor : public CPedAttractor
{
public:
- virtual ePedAttractorType GetType() const override { return ATTRACTOR_ATM; };
- virtual void UpdatePedStateOnDeparture(CPed* pPed) const override;
+ virtual ePedAttractorType GetType() const { return ATTRACTOR_ATM; };
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const;
CPedAtmAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp)
{};
@@ -136,9 +136,9 @@ public:
class CPedIceCreamAttractor : public CPedAttractor
{
public:
- virtual ~CPedIceCreamAttractor() override { GetPedAttractorManager()->RemoveIceCreamVanEffects(p2dEffect); }
- virtual ePedAttractorType GetType() const override { return ATTRACTOR_ICECREAM; }
- virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
+ virtual ~CPedIceCreamAttractor() { GetPedAttractorManager()->RemoveIceCreamVanEffects(p2dEffect); }
+ virtual ePedAttractorType GetType() const { return ATTRACTOR_ICECREAM; }
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const {};
CPedIceCreamAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp)
{};
@@ -147,9 +147,9 @@ public:
class CPedPizzaAttractor : public CPedAttractor
{
public:
- virtual float GetHeadOfQueueWaitTime() override { return 2000.0f; }
- virtual ePedAttractorType GetType() const override { return ATTRACTOR_PIZZA; }
- virtual void UpdatePedStateOnDeparture(CPed* pPed) const override;
+ virtual float GetHeadOfQueueWaitTime() { return 2000.0f; }
+ virtual ePedAttractorType GetType() const { return ATTRACTOR_PIZZA; }
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const;
CPedPizzaAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp)
{};
@@ -158,8 +158,8 @@ public:
class CPedSeatAttractor : public CPedAttractor
{
public:
- virtual ePedAttractorType GetType() const override { return ATTRACTOR_SEAT; }
- virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
+ virtual ePedAttractorType GetType() const { return ATTRACTOR_SEAT; }
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const {};
CPedSeatAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp)
{};
@@ -169,12 +169,12 @@ class CPedShelterAttractor : public CPedAttractor
{
static std::vector<CVector> ms_displacements;
public:
- virtual ePedAttractorType GetType() const override { return ATTRACTOR_SHELTER; }
- virtual bool BroadcastDeparture(CPed*) override;
- virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
- virtual bool IsAtHeadOfQueue(CPed* pPed) const override { return true; }
- virtual void ComputeAttractPos(int qid, CVector& pos) const override;
- virtual void ComputeAttractHeading(int qid, float& heading) const override;
+ virtual ePedAttractorType GetType() const { return ATTRACTOR_SHELTER; }
+ virtual bool BroadcastDeparture(CPed*);
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const {};
+ virtual bool IsAtHeadOfQueue(CPed* pPed) const { return true; }
+ virtual void ComputeAttractPos(int qid, CVector& pos) const;
+ virtual void ComputeAttractHeading(int qid, float& heading) const;
CPedShelterAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp)
@@ -187,8 +187,8 @@ public:
class CPedStopAttractor : public CPedAttractor
{
public:
- virtual ePedAttractorType GetType() const override { return ATTRACTOR_STOP; }
- virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
+ virtual ePedAttractorType GetType() const { return ATTRACTOR_STOP; }
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const {};
CPedStopAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float distance, float headingdiff, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, distance, headingdiff, posdisp, headdisp)
diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp
index 507653f6..13cbd1b3 100644
--- a/src/render/Draw.cpp
+++ b/src/render/Draw.cpp
@@ -5,8 +5,8 @@
#include "Camera.h"
#include "CutsceneMgr.h"
-#ifdef ASPECT_RATIO_SCALE
float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO;
+#ifdef ASPECT_RATIO_SCALE
float CDraw::ms_fScaledFOV = 45.0f;
#endif
diff --git a/src/render/Draw.h b/src/render/Draw.h
index 1a63c980..e67ab42b 100644
--- a/src/render/Draw.h
+++ b/src/render/Draw.h
@@ -16,10 +16,10 @@ private:
static float ms_fNearClipZ;
static float ms_fFarClipZ;
static float ms_fFOV;
-#ifdef ASPECT_RATIO_SCALE
// we use this variable to scale a lot of 2D elements
// so better cache it
static float ms_fAspectRatio;
+#ifdef ASPECT_RATIO_SCALE
// similar thing for 3D rendering
static float ms_fScaledFOV;
#endif
diff --git a/src/render/Font.h b/src/render/Font.h
index 05c367fb..4046ebb5 100644
--- a/src/render/Font.h
+++ b/src/render/Font.h
@@ -1,5 +1,7 @@
#pragma once
+#include "Sprite2d.h"
+
void AsciiToUnicode(const char *src, wchar *dst);
void UnicodeStrcpy(wchar *dst, const wchar *src);
void UnicodeStrcat(wchar *dst, wchar *append);
diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp
index a11495a9..c6d02755 100644
--- a/src/render/Glass.cpp
+++ b/src/render/Glass.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "Glass.h"
#include "Timer.h"
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index 69e340e3..12bfd040 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -39,7 +39,7 @@
// Game has colors inlined in code.
// For easier modification we collect them here:
CRGBA MONEY_COLOR(0, 207, 133, 255);
-CRGBA AMMO_COLOR(255, 150, 225, 255);
+CRGBA AMMO_COLOR(255, 255, 255, 255);
CRGBA HEALTH_COLOR(255, 150, 225, 255);
CRGBA ARMOUR_COLOR(185, 185, 185, 255);
CRGBA NOTWANTED_COLOR(27, 89, 130, 255);
@@ -130,6 +130,8 @@ CSprite2d CHud::Sprites[NUM_HUD_SPRITES];
wchar* CHud::gLastPrintForeverString;
+uint8 CHud::m_HudAlpha = 209;
+
struct
{
const char *name;
@@ -213,6 +215,7 @@ RwTexture *gpLaserSightTex;
RwTexture *gpLaserDotTex;
RwTexture *gpViewFinderTex;
+// TODO(LCS): some things were reversed from LCS but not all
void CHud::Draw()
{
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
@@ -405,6 +408,8 @@ void CHud::Draw()
DrawMoneyCounter
*/
+ RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); // TODO(LCS): temp filtering fix for money counter, remove later
+
wchar sPrint[16];
wchar sPrintIcon[16];
char sTemp[16];
@@ -417,25 +422,8 @@ void CHud::Draw()
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
}
if (m_DisplayScoreState != FADED_OUT) {
- sprintf(sTemp, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
- AsciiToUnicode(sTemp, sPrint);
-
- CFont::SetPropOff();
- CFont::SetBackgroundOff();
- CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
- CFont::SetCentreOff();
- CFont::SetRightJustifyOn();
- CFont::SetRightJustifyWrap(0.0f);
- CFont::SetBackGroundOnlyTextOff();
- CFont::SetFontStyle(FONT_HEADING);
- CFont::SetPropOff();
- CFont::SetDropShadowPosition(2);
- CFont::SetDropColor(CRGBA(0, 0, 0, alpha));
- MONEY_COLOR.a = alpha;
- CFont::SetColor(MONEY_COLOR);
-
if (FrontEndMenuManager.m_PrefsShowHud) {
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint);
+ DrawCash();
}
}
@@ -448,46 +436,23 @@ void CHud::Draw()
alpha = CHud::DrawFadeState(HUD_WEAPON_FADING, 1);
m_LastWeapon = playerPed->GetWeapon()->m_eWeaponType;
}
+ alpha = Min(alpha, m_HudAlpha);
if (m_WeaponState != FADED_OUT) {
CWeapon *weapon = playerPed->GetWeapon();
- int32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition;
- int32 AmmoInClip = weapon->m_nAmmoInClip;
- int32 TotalAmmo = weapon->m_nAmmoTotal;
- int32 Ammo, Clip;
-
- if (AmmoAmount <= 1 || AmmoAmount >= 1000)
- sprintf(sTemp, "%d", TotalAmmo);
- else {
- if (WeaponType == WEAPONTYPE_FLAMETHROWER) {
- Clip = AmmoInClip / 10;
-
- Ammo = Min((TotalAmmo - AmmoInClip) / 10, 9999);
- } else {
- Clip = AmmoInClip;
-
- Ammo = Min(TotalAmmo - AmmoInClip, 9999);
- }
-
- sprintf(sTemp, "%d-%d", Ammo, Clip);
- }
-
- AsciiToUnicode(sTemp, sPrint);
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType);
/*
DrawWeaponIcon
*/
if (FrontEndMenuManager.m_PrefsShowHud) {
+ float right = FrontEndMenuManager.m_PrefsUseWideScreen ? 468.6f : 470.0f;
+ float left = right - (FrontEndMenuManager.m_PrefsUseWideScreen ? 48.6f : 54.0f);
if (weaponInfo->m_nModelId <= 0) {
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
if (FrontEndMenuManager.m_PrefsShowHud)
Sprites[WeaponType].Draw(
- CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)),
- CRGBA(255, 255, 255, alpha),
- 0.015f, 0.015f,
- 1.0f, 0.0f,
- 0.015f, 1.0f,
- 1.0f, 1.0f);
+ CRect(PSP_SCREEN_SCALE_X(left), PSP_SCREEN_SCALE_Y(16.0f), PSP_SCREEN_SCALE_X(right), PSP_SCREEN_SCALE_Y(60.0f)),
+ CRGBA(255, 255, 255, alpha));
} else {
CBaseModelInfo *weaponModel = CModelInfo::GetModelInfo(weaponInfo->m_nModelId);
RwTexDictionary *weaponTxd = CTxdStore::GetSlot(weaponModel->GetTxdSlot())->texDict;
@@ -507,12 +472,8 @@ void CHud::Draw()
static CSprite2d sprite;
sprite.m_pTexture = weaponIcon;
sprite.Draw(
- CRect(SCREEN_SCALE_FROM_RIGHT(99.0f), SCREEN_SCALE_Y(27.0f), SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(91.0f)),
- CRGBA(255, 255, 255, alpha),
- 0.015f, 0.015f,
- 1.0f, 0.0f,
- 0.015f, 1.0f,
- 1.0f, 1.0f);
+ CRect(PSP_SCREEN_SCALE_X(left), PSP_SCREEN_SCALE_Y(16.0f), PSP_SCREEN_SCALE_X(right), PSP_SCREEN_SCALE_Y(60.0f)),
+ CRGBA(255, 255, 255, alpha));
sprite.m_pTexture = nil;
#endif
}
@@ -520,7 +481,7 @@ void CHud::Draw()
}
CFont::SetBackgroundOff();
- CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.8f));
+ CFont::SetScale(PSP_SCREEN_SCALE_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.18f : 0.2f), PSP_SCREEN_SCALE_Y(0.44f));
CFont::SetJustifyOff();
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
@@ -528,13 +489,65 @@ void CHud::Draw()
CFont::SetDropShadowPosition(0);
CFont::SetFontStyle(FONT_STANDARD);
+ int32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition;
+ int32 AmmoInClip = weapon->m_nAmmoInClip;
+ int32 TotalAmmo = weapon->m_nAmmoTotal;
+ int32 Ammo, Clip;
+
if (Min(9999, TotalAmmo - AmmoInClip) != 9999 && !CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) {
CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, alpha));
AMMO_COLOR.a = alpha;
CFont::SetColor(AMMO_COLOR);
- if (FrontEndMenuManager.m_PrefsShowHud)
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(90.0f), sPrint);
+ if (FrontEndMenuManager.m_PrefsShowHud) {
+
+
+ if (AmmoAmount <= 1 || AmmoAmount >= 1000)
+ {
+ sprintf(sTemp, "%d", TotalAmmo);
+ AsciiToUnicode(sTemp, sPrint);
+ float pos = 435.0f;
+#ifdef FIX_BUGS
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ pos = 438.0f;
+#endif
+ CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - pos), PSP_SCREEN_SCALE_Y(42.0f), sPrint);
+ }
+ else {
+
+ if (WeaponType == WEAPONTYPE_FLAMETHROWER) {
+ Clip = AmmoInClip / 10;
+
+ Ammo = Min((TotalAmmo - AmmoInClip) / 10, 9999);
+ }
+ else {
+ Clip = AmmoInClip;
+
+ Ammo = Min(TotalAmmo - AmmoInClip, 9999);
+ }
+
+ char sMinus[10];
+ char sAmmo[20];
+ char sClip[20];
+
+ sprintf(sMinus, "-");
+ sprintf(sAmmo, "%d", Ammo);
+ sprintf(sClip, "%d", Clip);
+
+ CFont::SetCentreOff();
+ CFont::SetRightJustifyOn();
+ AsciiToUnicode(sAmmo, sPrint);
+ CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - (FrontEndMenuManager.m_PrefsUseWideScreen ? 438.0f : 435.0f)), PSP_SCREEN_SCALE_Y(42.0f), sPrint);
+
+ CFont::SetRightJustifyOff();
+ AsciiToUnicode(sMinus, sPrint);
+ CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - (FrontEndMenuManager.m_PrefsUseWideScreen ? 439.0f : 436.0f)), PSP_SCREEN_SCALE_Y(42.0f), sPrint);
+
+ AsciiToUnicode(sClip, sPrint);
+ CFont::PrintString(PSP_SCREEN_SCALE_FROM_RIGHT(PSP_DEFAULT_SCREEN_WIDTH - (FrontEndMenuManager.m_PrefsUseWideScreen ? 441.0f : 439.0f)), PSP_SCREEN_SCALE_Y(42.0f), sPrint);
+
+ }
+ }
CFont::SetDropShadowPosition(0);
}
}
@@ -568,23 +581,8 @@ void CHud::Draw()
&& CTimer::GetFrameCounter() & 8) {
if (playerPed->m_fHealth >= 10
|| playerPed->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
-
- AsciiToUnicode("{", sPrintIcon);
-#ifdef FIX_BUGS
- sprintf(sTemp, "%03d", int32(playerPed->m_fHealth + 0.5f));
-#else
- sprintf(sTemp, "%03d", (int32)playerPed->m_fHealth);
-#endif
- AsciiToUnicode(sTemp, sPrint);
-
- CFont::SetColor(HEALTH_COLOR);
if (FrontEndMenuManager.m_PrefsShowHud) {
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint);
-
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) {
- // CFont::SetColor(HEALTH_COLOR);
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 54.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
- }
+ DrawHealthBar(playerPed->m_fHealth);
}
}
}
@@ -605,13 +603,7 @@ void CHud::Draw()
CFont::SetColor(ARMOUR_COLOR);
if (FrontEndMenuManager.m_PrefsShowHud) {
-
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint);
-
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4) {
- // CFont::SetColor(ARMOUR_COLOR);
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f + 52.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
- }
+ DrawArmourBar(playerPed->m_fArmour);
}
}
}
@@ -628,36 +620,23 @@ void CHud::Draw()
}
if (m_WantedState != FADED_OUT) {
- CFont::SetBackgroundOff();
- CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
- CFont::SetJustifyOff();
- CFont::SetCentreOff();
- CFont::SetRightJustifyOn();
- CFont::SetPropOn();
- CFont::SetFontStyle(FONT_STANDARD);
-
- AsciiToUnicode(">", sPrintIcon);
-
+ char wantedStar[] = "\x16";
+ float starX = 441.0f;
for (int i = 0; i < 6; i++) {
if (FrontEndMenuManager.m_PrefsShowHud) {
if (playerPed->m_pWanted->GetWantedLevel() > i
&& (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange
+ 2000 || CTimer::GetFrameCounter() & 4)) {
- WANTED_COLOR.a = alpha;
- CFont::SetColor(WANTED_COLOR);
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon);
+ DrawTimeAndCashNumbers(wantedStar, starX, 63.0f, false);
} else if (playerPed->m_pWanted->m_nMinWantedLevel > i && CTimer::GetFrameCounter() & 4) {
- WANTED_COLOR_FLASH.a = alpha;
- CFont::SetColor(WANTED_COLOR_FLASH);
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon);
-
- } else if (playerPed->m_pWanted->GetWantedLevel() <= i) {
- NOTWANTED_COLOR.a = alpha;
- CFont::SetColor(NOTWANTED_COLOR);
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon);
+ DrawTimeAndCashNumbers(wantedStar, starX, 63.0f, true);
}
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ starX -= 11.0f;
+ else
+ starX -= 13.5f;
}
}
}
@@ -919,24 +898,8 @@ void CHud::Draw()
DrawClock
*/
if (m_ClockState) {
- CFont::SetJustifyOff();
- CFont::SetCentreOff();
- CFont::SetBackgroundOff();
- CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
- CFont::SetBackGroundOnlyTextOff();
- CFont::SetPropOff();
- CFont::SetFontStyle(FONT_HEADING);
- CFont::SetRightJustifyOn();
- CFont::SetRightJustifyWrap(0.0f);
- CFont::SetDropShadowPosition(2);
- CFont::SetDropColor(CRGBA(0, 0, 0, 255));
-
- sprintf(sTemp, "%02d:%02d", CClock::GetHours(), CClock::GetMinutes());
- AsciiToUnicode(sTemp, sPrint);
-
- CFont::SetColor(CLOCK_COLOR);
if (FrontEndMenuManager.m_PrefsShowHud)
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f), SCREEN_SCALE_Y(22.0f), sPrint);
+ DrawTime();
}
/*
@@ -1142,20 +1105,20 @@ void CHud::Draw()
// Yeah, top and bottom changed place. R* vision
if (IntroRect.m_bIsUsed && IntroRect.m_bBeforeFade) {
if (IntroRect.m_nTextureId >= 0) {
- CRect rect = {
+ CRect rect (
IntroRect.m_sRect.left,
IntroRect.m_sRect.top,
IntroRect.m_sRect.right,
- IntroRect.m_sRect.bottom };
+ IntroRect.m_sRect.bottom );
CTheScripts::ScriptSprites[IntroRect.m_nTextureId].Draw(rect, IntroRect.m_sColor);
}
else {
- CRect rect = {
+ CRect rect (
IntroRect.m_sRect.left,
IntroRect.m_sRect.top,
IntroRect.m_sRect.right,
- IntroRect.m_sRect.bottom };
+ IntroRect.m_sRect.bottom );
CSprite2d::DrawRect(rect, IntroRect.m_sColor);
}
@@ -1188,7 +1151,7 @@ void CHud::Draw()
if (FrontEndMenuManager.m_PrefsShowSubtitles || !CCutsceneMgr::IsRunning()) {
#ifdef CUTSCENE_BORDERS_SWITCH
if (!FrontEndMenuManager.m_PrefsCutsceneBorders)
- CFont::SetDropShadowPosition(2);
+ CFont::SetDropShadowPosition(0);
#endif
CFont::SetCentreSize(SCREEN_WIDTH - SCREEN_SCALE_X(60.0f));
CFont::SetScale(SCREEN_SCALE_X(0.58f), SCREEN_SCALE_Y(1.2f));
@@ -1200,7 +1163,7 @@ void CHud::Draw()
onceItWasWidescreen = false;
CFont::DrawFonts();
- CFont::SetDropShadowPosition(2);
+ CFont::SetDropShadowPosition(0);
CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(SCREEN_SCALE_X(0.58f), SCREEN_SCALE_Y(1.22f));
@@ -1426,6 +1389,221 @@ void CHud::Draw()
}
}
+int HealthFlashTimer = 50;
+
+void
+CHud::DrawHealthBar(int16 value)
+{
+ if (m_ItemToFlash == ITEM_HEALTH) {
+ if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth > 10.0f) {
+ if (HealthFlashTimer-- == 0) {
+ m_ItemToFlash = -1;
+ HealthFlashTimer = 50;
+ }
+ }
+ }
+ float fHealth = value;
+ float fMaxHealth = CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth;
+ fHealth = clamp(fHealth, 0.0f, fMaxHealth);
+ float fWidth = (fHealth / fMaxHealth) * 40.0f + 16.0f + 4.0f;
+ float u = fWidth / 64.0f;
+ if (value == 0) {
+ fWidth = 0.0f;
+ u = 0.0f;
+ } else if (value == fMaxHealth) {
+ fWidth = 64.0f;
+ u = 1.0f;
+ }
+
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ fWidth *= 0.68f;
+ else
+ fWidth *= 0.85f;
+
+ float fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f;
+ float fX2 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ CRect rect1(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(40.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(50.0f));
+ CRGBA color1(255, 255, 255, m_HudAlpha);
+ Sprites[HUD_BAR_INSIDE2].Draw(rect1, color1, 0.0f, 0.0f, u, 0.0f, 0.0f, 1.0f, u, 1.0f);
+
+ fX1 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ CRect rect2(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(40.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(50.0f));
+ CRGBA color2(255, 255, 255, m_HudAlpha);
+ Sprites[HUD_BAR_INSIDE2DARK].Draw(rect2, color2, u, 0.0f, 1.0f, 0.0f, u, 1.0f, 1.0f, 1.0f);
+
+ fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f;
+ fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ CRect rect3(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(40.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(50.0f));
+ CRGBA color3(255, 255, 255, m_HudAlpha);
+ Sprites[HUD_BAR_OUTLINE].Draw(rect3, color3, 0.01f, 0.0f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f);
+
+ if (fMaxHealth > 100.0f)
+ {
+ CFont::SetFontStyle(FONT_STANDARD);
+ CFont::SetDropShadowPosition(0);
+ CFont::SetDropColor(CRGBA(0, 0, 0, m_HudAlpha));
+ CFont::SetColor(CRGBA(255, 255, 255, m_HudAlpha));
+ CFont::SetCentreOn();
+ if (fMaxHealth > 125.0f)
+ CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.3375f : 0.45f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.75f)));
+ else
+ CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.2625f : 0.35f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.6f)));
+
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ fX1 = 375.0f + 12.0f;
+ else
+ fX1 = 360.0f + 15.0f;
+ CFont::PrintString(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(36.0f), (wchar*)L"+");
+ }
+
+}
+
+int ArmourFlashTimer = 50;
+
+void
+CHud::DrawArmourBar(int16 value)
+{
+ if (m_ItemToFlash == ITEM_ARMOUR) {
+ if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fArmour > 10.0f) {
+ if (ArmourFlashTimer-- == 0) {
+ m_ItemToFlash = -1;
+ ArmourFlashTimer = 50;
+ }
+ }
+ }
+ float fArmour = value;
+ float fMaxArmour = CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour;
+ fArmour = clamp(fArmour, 0.0f, fMaxArmour);
+ float fWidth = (fArmour / fMaxArmour) * 40.0f + 16.0f + 4.0f;
+ float u = fWidth / 64.0f;
+ if (value == 0) {
+ fWidth = 0.0f;
+ u = 0.0f;
+ } else if (value == fMaxArmour) {
+ fWidth = 64.0f;
+ u = 1.0f;
+ }
+
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ fWidth *= 0.68f;
+ else
+ fWidth *= 0.85f;
+
+ float fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f;
+ float fX2 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ CRect rect1(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(28.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(38.0f));
+ CRGBA color1(255, 255, 255, m_HudAlpha);
+ Sprites[HUD_BAR_INSIDE1].Draw(rect1, color1, 0.0f, 0.0f, u, 0.0f, 0.0f, 1.0f, u, 1.0f);
+
+ fX1 = fWidth + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ CRect rect2(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(28.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(38.0f));
+ CRGBA color2(255, 255, 255, m_HudAlpha);
+ Sprites[HUD_BAR_INSIDE1DARK].Draw(rect2, color2, u, 0.0f, 1.0f, 0.0f, u, 1.0f, 1.0f, 1.0f);
+
+ fX1 = FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f;
+ fX2 = (FrontEndMenuManager.m_PrefsUseWideScreen ? 43.52f : 54.4f) + (FrontEndMenuManager.m_PrefsUseWideScreen ? 375.0f : 360.0f);
+ CRect rect3(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(28.0f), PSP_SCREEN_SCALE_X(fX2), PSP_SCREEN_SCALE_Y(38.0f));
+ CRGBA color3(255, 255, 255, m_HudAlpha);
+ Sprites[HUD_BAR_OUTLINE].Draw(rect3, color3, 0.01f, 0.0f, 1.0f, 0.0f, 0.01f, 1.0f, 1.0f, 1.0f);
+
+ if (fMaxArmour > 100.0f) {
+ CFont::SetFontStyle(FONT_STANDARD);
+ CFont::SetDropShadowPosition(0);
+ CFont::SetDropColor(CRGBA(0, 0, 0, m_HudAlpha));
+ CFont::SetColor(CRGBA(255, 255, 255, m_HudAlpha));
+ CFont::SetCentreOn();
+ if (fMaxArmour > 125.0f)
+ CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.3375f : 0.45f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.75f)));
+ else
+ CFont::SetScale(FrontEndMenuManager.StretchX(PSP_SCALE_TO_PS2_X(FrontEndMenuManager.m_PrefsUseWideScreen ? 0.2625f : 0.35f)), FrontEndMenuManager.StretchY(PSP_SCALE_TO_PS2_Y(0.6f)));
+
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ fX1 = 375.0f + 12.0f;
+ else
+ fX1 = 360.0f + 15.0f;
+ CFont::PrintString(PSP_SCREEN_SCALE_X(fX1), PSP_SCREEN_SCALE_Y(24.0f), (wchar*)L"+");
+ }
+
+}
+
+void
+CHud::DrawTimeAndCashNumbers(char *str, float x, float y, bool secondSet)
+{
+ CRGBA color(255, 255, 255, m_HudAlpha);
+
+ float width = 11.0f;
+ if (FrontEndMenuManager.m_PrefsUseWideScreen)
+ width = 9.0f;
+
+ float height = 10.0f;
+ while (*str) {
+ uint8 c = *str;
+ if (c >= '0' && c <= ':')
+ {
+ if (secondSet) c -= '%';
+ else c -= '0';
+ } else {
+ if (c == 22) {
+ if (secondSet)
+ color = CRGBA(62, 141, 188, m_HudAlpha);
+ else
+ color = CRGBA(192, 155, 54, m_HudAlpha);
+ } else if (!secondSet)
+ c = 10;
+ else
+ c = 21;
+ }
+
+ int row = c / 8;
+ int col = c - row * 8;
+ float width2 = width;
+ if (c == 22)
+ width2 += 3.0f;
+ CRect rect(PSP_SCREEN_SCALE_X(x), PSP_SCREEN_SCALE_Y(y), PSP_SCREEN_SCALE_X(x+ width2), PSP_SCREEN_SCALE_Y(y) + PSP_SCREEN_SCALE_Y(height));
+
+ float u = col * 0.125f;
+ // TODO(LCS): some odd calculation with u going on in here if it's < 0, it might be fabs, but maybe not
+
+ float v = row * 0.265625f;
+ // TODO(LCS): same odd calculation with v as above
+
+ str++;
+ Sprites[HUD_HUDNUMBERS].Draw(rect, color, u, v, u + 0.125f, v, u, v + 0.265625f, u + 0.125f, v + 0.265625f);
+
+ x += (width - 2.0f);
+ if (c == 10)
+ x -= 4.0f;
+
+#ifdef GTA_PSP
+ x = Ceil(PSP_SCREEN_SCALE_X(x)) * ((float)PSP_DEFAULT_SCREEN_WIDTH / (float)SCREEN_WIDTH);
+#else
+ // BUG: actually above wasn't PSP only but on higher resolutions things don't look like they were meant to, so we stick with PS2 version here
+ x = Ceil(PSP_SCALE_TO_PS2_X(x)) * ((float)PSP_DEFAULT_SCREEN_WIDTH / (float)DEFAULT_SCREEN_WIDTH);
+#endif
+ }
+}
+
+void
+CHud::DrawCash()
+{
+ char str[200];
+ sprintf(str, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
+ DrawTimeAndCashNumbers(str, FrontEndMenuManager.m_PrefsUseWideScreen ? 386.0f : 373.0f, 53.0f, true);
+}
+
+void
+CHud::DrawTime()
+{
+ // TODO(LCS): a lot more code should be here
+
+ char str[24];
+ sprintf(str, "%02d:%02d", CClock::ms_nGameClockHours, CClock::ms_nGameClockMinutes);
+ DrawTimeAndCashNumbers(str, FrontEndMenuManager.m_PrefsUseWideScreen ? 386.0f : 373.0f, 17.0f, false);
+}
+
+
void CHud::DrawAfterFade()
{
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
@@ -2081,4 +2259,4 @@ CHud::ResetWastedText(void)
BigMessageInUse[0] = 0.0f;
m_BigMessage[2][0] = 0;
m_BigMessage[0][0] = 0;
-}
+} \ No newline at end of file
diff --git a/src/render/Hud.h b/src/render/Hud.h
index b81ac828..4ae36886 100644
--- a/src/render/Hud.h
+++ b/src/render/Hud.h
@@ -38,7 +38,13 @@ enum eSprites
HUD_FIST,
HUD_SITEROCKET = 41,
HUD_RADARDISC = 50,
- HUD_SITESNIPER = 63,
+ HUD_BAR_INSIDE1DARK = 57,
+ HUD_BAR_INSIDE2DARK,
+ HUD_HUDNUMBERS,
+ HUD_BAR_INSIDE1,
+ HUD_BAR_INSIDE2,
+ HUD_BAR_OUTLINE,
+ HUD_SITESNIPER,
HUD_SITEM16,
HUD_SITELASER,
HUD_LASERDOT,
@@ -119,6 +125,7 @@ public:
static uint32 m_LastTimeEnergyLost;
static wchar* gLastPrintForeverString;
+ static uint8 m_HudAlpha;
public:
static void Draw();
@@ -139,4 +146,9 @@ public:
static void Shutdown();
static float DrawFadeState(DRAW_FADE_STATE, int);
static void ResetWastedText(void);
+ static void DrawHealthBar(int16 value);
+ static void DrawArmourBar(int16 value);
+ static void DrawTimeAndCashNumbers(char *str, float x, float y, bool secondSet);
+ static void DrawCash();
+ static void DrawTime();
};
diff --git a/src/render/Instance.h b/src/render/Instance.h
index 01dfb6a2..693cfdf1 100644
--- a/src/render/Instance.h
+++ b/src/render/Instance.h
@@ -9,6 +9,6 @@ class CInstance : public CPlaceable
public:
int m_modelIndex;
public:
- ~CInstance() = default;
+ ~CInstance() { }
void Shutdown();
};
diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp
index 3387cb2e..161bf168 100644
--- a/src/render/SpecialFX.cpp
+++ b/src/render/SpecialFX.cpp
@@ -1419,7 +1419,7 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8
}
CRGBA FoamColour(255, 255, 255, 255);
-unsigned int CSpecialParticleStuff::BoatFromStart;
+uint32 CSpecialParticleStuff::BoatFromStart;
void
CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles)
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index c50531c6..754c8778 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -455,6 +455,14 @@ CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic)
RpAtomic*
CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic)
{
+ if(DistToCameraSq < ms_vehicleLod0Dist)
+ RENDERCALLBACK(atomic);
+ return atomic;
+}
+
+RpAtomic*
+CVisibilityPlugins::RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic)
+{
if(DistToCameraSq < ms_bigVehicleLod1Dist)
RENDERCALLBACK(atomic);
return atomic;
@@ -474,6 +482,40 @@ CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic)
}
RpAtomic*
+CVisibilityPlugins::RenderVehicleLoDetailCB_Boat(RpAtomic *atomic)
+{
+ RpClump *clump;
+ int32 alpha;
+
+ clump = RpAtomicGetClump(atomic);
+ if(DistToCameraSq >= ms_vehicleLod0Dist){
+ alpha = GetClumpAlpha(clump);
+ if(alpha == 255)
+ RENDERCALLBACK(atomic);
+ else
+ RenderAlphaAtomic(atomic, alpha);
+ }
+ return atomic;
+}
+
+RpAtomic*
+CVisibilityPlugins::RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic)
+{
+ RpClump *clump;
+ int32 alpha;
+
+ clump = RpAtomicGetClump(atomic);
+ if(DistToCameraSq >= ms_bigVehicleLod1Dist){
+ alpha = GetClumpAlpha(clump);
+ if(alpha == 255)
+ RENDERCALLBACK(atomic);
+ else
+ RenderAlphaAtomic(atomic, alpha);
+ }
+ return atomic;
+}
+
+RpAtomic*
CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic)
{
RwFrame *clumpframe;
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index 13365c7a..f188096c 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -61,6 +61,9 @@ public:
static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic);
static RpAtomic *RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic);
+ static RpAtomic *RenderVehicleHiDetailCB_Boat_Far(RpAtomic *atomic);
+ static RpAtomic *RenderVehicleLoDetailCB_Boat(RpAtomic *atomic);
+ static RpAtomic *RenderVehicleLoDetailCB_Boat_Far(RpAtomic *atomic);
static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic);
static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic);
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index bfc03913..009b17c7 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -21,7 +21,11 @@ char *_strdate(char *buf);
// As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, we only need type definitions so let's include <IntSafe.h>.
// NOTE: It's perfectly fine to include <Windows.h> here, but it can increase build size and time in *some* conditions, and maybe substantially in future if we'll use crossplatform.h more.
#ifndef _INC_WINDOWS
- #include <IntSafe.h>
+ #ifndef __MWERKS__
+ #include <IntSafe.h>
+ #else
+ #include <Windows.h>
+ #endif
#endif
#if defined RW_D3D9 || defined RWLIBS
#include "win.h"
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 3e7ba0ab..887ac6dc 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -2099,22 +2099,30 @@ void CapturePad(RwInt32 padID)
const float *axes = glfwGetJoystickAxes(glfwPad, &numAxes);
GLFWgamepadstate gamepadState;
- if (ControlsManager.m_bFirstCapture == false)
- {
+ if (ControlsManager.m_bFirstCapture == false) {
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
+ } else {
+ // In case connected gamepad doesn't have L-R trigger axes.
+ ControlsManager.m_NewState.mappedButtons[15] = ControlsManager.m_NewState.mappedButtons[16] = 0;
}
ControlsManager.m_NewState.buttons = (uint8*)buttons;
ControlsManager.m_NewState.numButtons = numButtons;
ControlsManager.m_NewState.id = glfwPad;
- ControlsManager.m_NewState.isGamepad = glfwJoystickIsGamepad(glfwPad);
+ ControlsManager.m_NewState.isGamepad = glfwGetGamepadState(glfwPad, &gamepadState);
if (ControlsManager.m_NewState.isGamepad) {
- glfwGetGamepadState(glfwPad, &gamepadState);
memcpy(&ControlsManager.m_NewState.mappedButtons, gamepadState.buttons, sizeof(gamepadState.buttons));
- ControlsManager.m_NewState.mappedButtons[15] = gamepadState.axes[4] > -0.8f;
- ControlsManager.m_NewState.mappedButtons[16] = gamepadState.axes[5] > -0.8f;
+ float lt = gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER], rt = gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER];
+
+ // glfw returns 0.0 for non-existent axises(which is bullocks) so we treat it as deadzone, and keep value of previous frame.
+ // otherwise if this axis is present, -1 = released, 1 = pressed
+ if (lt != 0.0f)
+ ControlsManager.m_NewState.mappedButtons[15] = lt > -0.8f;
+
+ if (rt != 0.0f)
+ ControlsManager.m_NewState.mappedButtons[16] = rt > -0.8f;
}
- // TODO I'm not sure how to find/what to do with L2-R2, if joystick isn't registered in SDL database.
+ // TODO? L2-R2 axes(not buttons-that's fine) on joysticks that don't have SDL gamepad mapping AREN'T handled, and I think it's impossible to do without mapping.
if (ControlsManager.m_bFirstCapture == true) {
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
@@ -2128,12 +2136,13 @@ void CapturePad(RwInt32 padID)
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);
// Gamepad axes are guaranteed to return 0.0f if that particular gamepad doesn't have that axis.
+ // And that's really good for sticks, because gamepads return 0.0 for them when sticks are in released state.
if ( glfwPad != -1 ) {
- leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[0] : numAxes >= 1 ? axes[0] : 0.0f;
- leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[1] : numAxes >= 2 ? axes[1] : 0.0f;
+ leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_X] : numAxes >= 1 ? axes[0] : 0.0f;
+ leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y] : numAxes >= 2 ? axes[1] : 0.0f;
- rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[2] : numAxes >= 3 ? axes[2] : 0.0f;
- rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[3] : numAxes >= 4 ? axes[3] : 0.0f;
+ rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_X] : numAxes >= 3 ? axes[2] : 0.0f;
+ rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y] : numAxes >= 4 ? axes[3] : 0.0f;
}
{
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 87c3846a..650f1648 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -1,4 +1,4 @@
-#if defined RW_D3D9 || defined RWLIBS
+#if defined RW_D3D9 || defined RWLIBS || defined __MWERKS__
#define _WIN32_WINDOWS 0x0500
#define WINVER 0x0500
@@ -19,6 +19,10 @@
#pragma warning( push )
#pragma warning( disable : 4005)
+#ifdef __MWERKS__
+#define MAPVK_VK_TO_CHAR (2) // this is missing from codewarrior win32 headers - but it gets used ... how?
+#endif
+
#include <ddraw.h>
#include <DShow.h>
#pragma warning( pop )
@@ -573,6 +577,9 @@ _RETEX:
}
}
+#ifdef __MWERKS__
+#pragma dont_inline on
+#endif
void _psPrintCpuInfo()
{
RwUInt32 features = _psGetCpuFeatures();
@@ -587,6 +594,9 @@ void _psPrintCpuInfo()
if ( FeaturesEx & 0x80000000 )
debug("with 3DNow");
}
+#ifdef __MWERKS__
+#pragma dont_inline off
+#endif
#endif
/*
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index 6385eb50..16250f79 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -205,7 +205,7 @@ CText::GetNameOfLoadedMissionText(char *outName)
void
CText::ReadChunkHeader(ChunkHeader *buf, int32 file, size_t *offset)
{
-#if THIS_IS_STUPID
+#ifdef THIS_IS_STUPID
char *_buf = (char*)buf;
for (int i = 0; i < sizeof(ChunkHeader); i++) {
CFileMgr::Read(file, &_buf[i], 1);
@@ -323,7 +323,7 @@ CKeyArray::Load(size_t length, int file, size_t* offset)
entries = new CKeyEntry[numEntries];
rawbytes = (char*)entries;
-#if THIS_IS_STUPID
+#ifdef THIS_IS_STUPID
for (uint32 i = 0; i < length; i++) {
CFileMgr::Read(file, &rawbytes[i], 1);
(*offset)++;
@@ -398,7 +398,7 @@ CKeyArray::Search(const char *key, uint8 *result)
#endif
*result = false;
#ifdef MASTER
- sprintf(errstr, "%");
+ sprintf(errstr, "");
#else
sprintf(errstr, "%s missing", key);
#endif // MASTER
@@ -417,7 +417,7 @@ CData::Load(size_t length, int file, size_t * offset)
chars = new wchar[numChars];
rawbytes = (char*)chars;
-#if THIS_IS_STUPID
+#ifdef THIS_IS_STUPID
for(uint32 i = 0; i < length; i++){
CFileMgr::Read(file, &rawbytes[i], 1);
(*offset)++;
@@ -439,7 +439,7 @@ CData::Unload(void)
void
CMissionTextOffsets::Load(size_t table_size, int file, size_t *offset, int)
{
-#if THIS_IS_STUPID
+#ifdef THIS_IS_STUPID
size_t num_of_entries = table_size / sizeof(CMissionTextOffsets::Entry);
for (size_t mi = 0; mi < num_of_entries; mi++) {
for (uint32 i = 0; i < sizeof(data[mi].szMissionName); i++) {
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index a4d9e5c3..4a7bce16 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "main.h"
#include "General.h"
@@ -4174,7 +4174,7 @@ CAutomobile::dmgDrawCarCollidingParticles(const CVector &pos, float amount)
CGeneral::GetRandomNumberInRange(0.1f, 0.25f)),
nil,
CGeneral::GetRandomNumberInRange(0.02f, 0.08f),
- CVehicleModelInfo::ms_vehicleColourTable[m_currentColour1],
+ CVehicleModelInfo::mspInfo->ms_vehicleColourTable[m_currentColour1],
CGeneral::GetRandomNumberInRange(-40.0f, 40.0f),
0,
CGeneral::GetRandomNumberInRange(0.0f, 4.0f));
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index 381d13d8..d4dfcc7c 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "common.h"
#include "main.h"
#include "General.h"
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index 38550c38..0546888a 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -756,7 +756,7 @@ CHeli::InitHelis(void)
for(i = 0; i < NUM_HELIS; i++)
pHelis[i] = nil;
- ((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_CHOPPER))->SetColModel(&CTempColModels::ms_colModelPed1);
+ ((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_CHOPPER))->SetColModel(&gpTempColModels->ms_colModelPed1);
}
CHeli*
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 54c2260b..67acf47d 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -218,8 +218,8 @@ void
CVehicle::SetModelIndex(uint32 id)
{
CEntity::SetModelIndex(id);
- m_aExtras[0] = CVehicleModelInfo::ms_compsUsed[0];
- m_aExtras[1] = CVehicleModelInfo::ms_compsUsed[1];
+ m_aExtras[0] = CVehicleModelInfo::mspInfo->ms_compsUsed[0];
+ m_aExtras[1] = CVehicleModelInfo::mspInfo->ms_compsUsed[1];
m_nNumMaxPassengers = CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(id);
}
@@ -331,7 +331,7 @@ CVehicle::FlyingControl(eFlightModel flightModel)
case FLIGHT_MODEL_PLANE:
{
float fSteerLR = CPad::GetPad(0)->GetSteeringLeftRight() / 128.0f;
- float fSteerUD = -CPad::GetPad(0)->GetSteeringUpDown() / 128.0f;
+ float fSteerUD = CPad::GetPad(0)->GetSteeringUpDown() / 128.0f;
float fGunUD = Abs(CPad::GetPad(0)->GetCarGunUpDown());
#ifdef FREE_CAM
if(!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController))
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index 1d12e548..78d21b0a 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -513,7 +513,7 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
if ( SQR(victimPedRadius) > (victimPedPos-fireSource).MagnitudeSqr() )
{
CVector collisionDist;
- CColModel* victimPedCol = &CTempColModels::ms_colModelPed1;
+ CColModel* victimPedCol = &gpTempColModels->ms_colModelPed1;
bool useLocalPos = false;
if (victimPed->m_nPedState == PED_FALL
|| victimPed->m_nPedState == PED_DIE && victimPed->bIsPedDieAnimPlaying
diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp
index acb11a88..1f78b7d4 100644
--- a/src/weapons/WeaponInfo.cpp
+++ b/src/weapons/WeaponInfo.cpp
@@ -57,7 +57,7 @@ int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] =
-1, -1, -1, -1, -1, -1, -1, -1, -1
};
-CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
+CWeaponInfo aWeaponInfo[WEAPONTYPE_TOTALWEAPONS];
char CWeaponInfo::ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32] =
{
"Unarmed",
@@ -102,7 +102,7 @@ char CWeaponInfo::ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32] =
CWeaponInfo*
CWeaponInfo::GetWeaponInfo(eWeaponType weaponType)
{
- return &ms_apWeaponInfos[weaponType];
+ return &aWeaponInfo[weaponType];
}
void
@@ -110,27 +110,27 @@ CWeaponInfo::Initialise(void)
{
debug("Initialising CWeaponInfo...\n");
for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) {
- ms_apWeaponInfos[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT;
- ms_apWeaponInfos[i].m_fRange = 0.0f;
- ms_apWeaponInfos[i].m_nFiringRate = 0;
- ms_apWeaponInfos[i].m_nReload = 0;
- ms_apWeaponInfos[i].m_nAmountofAmmunition = 0;
- ms_apWeaponInfos[i].m_nDamage = 0;
- ms_apWeaponInfos[i].m_fSpeed = 0.0f;
- ms_apWeaponInfos[i].m_fRadius = 0.0f;
- ms_apWeaponInfos[i].m_fLifespan = 0.0f;
- ms_apWeaponInfos[i].m_fSpread = 0.0f;
- ms_apWeaponInfos[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f);
- ms_apWeaponInfos[i].m_AnimToPlay = ASSOCGRP_UNARMED;
- ms_apWeaponInfos[i].m_fAnimLoopStart = 0.0f;
- ms_apWeaponInfos[i].m_fAnimLoopEnd = 0.0f;
- ms_apWeaponInfos[i].m_fAnimFrameFire = 0.0f;
- ms_apWeaponInfos[i].m_fAnim2LoopStart = 0.0f;
- ms_apWeaponInfos[i].m_fAnim2LoopEnd = 0.0f;
- ms_apWeaponInfos[i].m_fAnim2FrameFire = 0.0f;
- ms_apWeaponInfos[i].m_fAnimBreakout = 0.0f;
- ms_apWeaponInfos[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES;
- ms_apWeaponInfos[i].m_nWeaponSlot = WEAPONSLOT_UNARMED;
+ aWeaponInfo[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT;
+ aWeaponInfo[i].m_fRange = 0.0f;
+ aWeaponInfo[i].m_nFiringRate = 0;
+ aWeaponInfo[i].m_nReload = 0;
+ aWeaponInfo[i].m_nAmountofAmmunition = 0;
+ aWeaponInfo[i].m_nDamage = 0;
+ aWeaponInfo[i].m_fSpeed = 0.0f;
+ aWeaponInfo[i].m_fRadius = 0.0f;
+ aWeaponInfo[i].m_fLifespan = 0.0f;
+ aWeaponInfo[i].m_fSpread = 0.0f;
+ aWeaponInfo[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f);
+ aWeaponInfo[i].m_AnimToPlay = ASSOCGRP_UNARMED;
+ aWeaponInfo[i].m_fAnimLoopStart = 0.0f;
+ aWeaponInfo[i].m_fAnimLoopEnd = 0.0f;
+ aWeaponInfo[i].m_fAnimFrameFire = 0.0f;
+ aWeaponInfo[i].m_fAnim2LoopStart = 0.0f;
+ aWeaponInfo[i].m_fAnim2LoopEnd = 0.0f;
+ aWeaponInfo[i].m_fAnim2FrameFire = 0.0f;
+ aWeaponInfo[i].m_fAnimBreakout = 0.0f;
+ aWeaponInfo[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES;
+ aWeaponInfo[i].m_nWeaponSlot = WEAPONSLOT_UNARMED;
}
debug("Loading weapon data...\n");
LoadWeaponData();
@@ -221,31 +221,31 @@ CWeaponInfo::LoadWeaponData(void)
CVector vecFireOffset(fireOffsetX, fireOffsetY, fireOffsetZ);
- ms_apWeaponInfos[weaponType].m_eWeaponFire = FindWeaponFireType(fireType);
- ms_apWeaponInfos[weaponType].m_fRange = range;
- ms_apWeaponInfos[weaponType].m_nFiringRate = firingRate;
- ms_apWeaponInfos[weaponType].m_nReload = reload;
- ms_apWeaponInfos[weaponType].m_nAmountofAmmunition = ammoAmount;
- ms_apWeaponInfos[weaponType].m_nDamage = damage;
- ms_apWeaponInfos[weaponType].m_fSpeed = speed;
- ms_apWeaponInfos[weaponType].m_fRadius = radius;
- ms_apWeaponInfos[weaponType].m_fLifespan = lifeSpan;
- ms_apWeaponInfos[weaponType].m_fSpread = spread;
- ms_apWeaponInfos[weaponType].m_vecFireOffset = vecFireOffset;
- ms_apWeaponInfos[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnim2LoopStart = anim2LoopStart / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnim2LoopEnd = anim2LoopEnd / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f;
- ms_apWeaponInfos[weaponType].m_fAnimBreakout = animBreakout / 30.0f;
- ms_apWeaponInfos[weaponType].m_nModelId = modelId;
- ms_apWeaponInfos[weaponType].m_nModel2Id = modelId2;
- ms_apWeaponInfos[weaponType].m_Flags = flags;
- ms_apWeaponInfos[weaponType].m_nWeaponSlot = weaponSlot;
+ aWeaponInfo[weaponType].m_eWeaponFire = FindWeaponFireType(fireType);
+ aWeaponInfo[weaponType].m_fRange = range;
+ aWeaponInfo[weaponType].m_nFiringRate = firingRate;
+ aWeaponInfo[weaponType].m_nReload = reload;
+ aWeaponInfo[weaponType].m_nAmountofAmmunition = ammoAmount;
+ aWeaponInfo[weaponType].m_nDamage = damage;
+ aWeaponInfo[weaponType].m_fSpeed = speed;
+ aWeaponInfo[weaponType].m_fRadius = radius;
+ aWeaponInfo[weaponType].m_fLifespan = lifeSpan;
+ aWeaponInfo[weaponType].m_fSpread = spread;
+ aWeaponInfo[weaponType].m_vecFireOffset = vecFireOffset;
+ aWeaponInfo[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f;
+ aWeaponInfo[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f;
+ aWeaponInfo[weaponType].m_fAnim2LoopStart = anim2LoopStart / 30.0f;
+ aWeaponInfo[weaponType].m_fAnim2LoopEnd = anim2LoopEnd / 30.0f;
+ aWeaponInfo[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f;
+ aWeaponInfo[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f;
+ aWeaponInfo[weaponType].m_fAnimBreakout = animBreakout / 30.0f;
+ aWeaponInfo[weaponType].m_nModelId = modelId;
+ aWeaponInfo[weaponType].m_nModel2Id = modelId2;
+ aWeaponInfo[weaponType].m_Flags = flags;
+ aWeaponInfo[weaponType].m_nWeaponSlot = weaponSlot;
if (animLoopEnd < 98.0f && weaponType != WEAPONTYPE_FLAMETHROWER && !CWeapon::IsShotgun(weaponType))
- ms_apWeaponInfos[weaponType].m_nFiringRate = ((ms_apWeaponInfos[weaponType].m_fAnimLoopEnd - ms_apWeaponInfos[weaponType].m_fAnimLoopStart) * 900.0f);
+ aWeaponInfo[weaponType].m_nFiringRate = ((aWeaponInfo[weaponType].m_fAnimLoopEnd - aWeaponInfo[weaponType].m_fAnimLoopStart) * 900.0f);
if (weaponType == WEAPONTYPE_DETONATOR || weaponType == WEAPONTYPE_HELICANNON)
modelId = -1;
@@ -257,7 +257,7 @@ CWeaponInfo::LoadWeaponData(void)
for (int i = 0; i < NUM_ANIM_ASSOC_GROUPS; i++) {
if (!strcmp(animToPlay, CAnimManager::GetAnimGroupName((AssocGroupId)i))) {
- ms_apWeaponInfos[weaponType].m_AnimToPlay = (AssocGroupId)i;
+ aWeaponInfo[weaponType].m_AnimToPlay = (AssocGroupId)i;
break;
}
}
diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h
index 0f53dded..d7f1563d 100644
--- a/src/weapons/WeaponInfo.h
+++ b/src/weapons/WeaponInfo.h
@@ -31,7 +31,6 @@ enum
};
class CWeaponInfo {
- static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
static char ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32];
public:
static uint16 ms_aReloadSampleTime[WEAPONTYPE_TOTALWEAPONS];