From 04c9affe2e97697346c431b773230332e7bcebfb Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 12 Apr 2020 12:06:33 +0300 Subject: scene init --- src/core/Game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index daac3ec5..fe747ac1 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -350,7 +350,7 @@ bool CGame::Initialise(const char* datFile) CAntennas::Init(); CGlass::Init(); gPhoneInfo.Initialise(); - CSceneEdit::Init(); + CSceneEdit::Initialise(); LoadingScreen("Loading the Game", "Load scripts", nil); CTheScripts::Init(); CGangs::Initialise(); -- cgit v1.2.3 From cb85091d34dd92695a075a13ff129ae568c0acda Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 13 Apr 2020 21:50:56 +0300 Subject: scene edit --- src/core/Pad.cpp | 4 ++-- src/core/main.cpp | 3 +-- src/core/re3.cpp | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index f83998b8..aa840541 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -931,8 +931,8 @@ void CPad::UpdatePads(void) GetPad(0)->UpdateMouse(); #ifdef XINPUT - GetPad(0)->AffectFromXinput(0); - GetPad(1)->AffectFromXinput(1); + GetPad(0)->AffectFromXinput(1); + GetPad(1)->AffectFromXinput(0); #else CapturePad(0); #endif diff --git a/src/core/main.cpp b/src/core/main.cpp index f09c2e0a..2bfe8290 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -58,6 +58,7 @@ #include "Console.h" #include "timebars.h" #include "GenericGameStorage.h" +#include "SceneEdit.h" GlobalScene &Scene = *(GlobalScene*)0x726768; @@ -863,11 +864,9 @@ Render2dStuff(void) MusicManager.DisplayRadioStationName(); TheConsole.Display(); -/* if(CSceneEdit::m_bEditOn) CSceneEdit::Draw(); else -*/ CHud::Draw(); CUserDisplay::OnscnTimer.ProcessForDisplay(); CMessages::Display(); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 00674b19..475176b6 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -22,6 +22,8 @@ #include "Console.h" #include "Debug.h" #include "Hud.h" +#include "SceneEdit.h" +#include "Pad.h" #include @@ -344,6 +346,8 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); }); DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil); + DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, nil); + DebugMenuAddVarBool8("Debug", "MapPadOneToPadTwo", (int8*)&CPad::m_bMapPadOneToPadTwo, nil); DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Fix Car", FixCar); -- cgit v1.2.3 From fbed2c4530a88c0a9cf92bd8bf135125f54a577e Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 14 Apr 2020 20:12:26 +0300 Subject: fix debug stuff --- src/core/Pad.cpp | 4 ++-- src/core/re3.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index aa840541..f83998b8 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -931,8 +931,8 @@ void CPad::UpdatePads(void) GetPad(0)->UpdateMouse(); #ifdef XINPUT - GetPad(0)->AffectFromXinput(1); - GetPad(1)->AffectFromXinput(0); + GetPad(0)->AffectFromXinput(0); + GetPad(1)->AffectFromXinput(1); #else CapturePad(0); #endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 096b9d9e..5d76d642 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -335,7 +335,6 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil); DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, nil); - DebugMenuAddVarBool8("Debug", "MapPadOneToPadTwo", (int8*)&CPad::m_bMapPadOneToPadTwo, nil); DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Fix Car", FixCar); -- cgit v1.2.3 From daed13485ef47d9c8992e53e1a976fba237fca50 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Wed, 15 Apr 2020 08:03:53 +0300 Subject: CWeapon done, ps2 cheats fix --- src/core/General.h | 5 +++++ src/core/Pad.cpp | 2 ++ src/core/World.cpp | 1 + src/core/World.h | 2 ++ src/core/main.cpp | 3 ++- 5 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/General.h b/src/core/General.h index f32846eb..77828854 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -90,6 +90,11 @@ public: return -Atan2(x / y, 1.0f); } } + + static float GetAngleBetweenPoints(float x1, float y1, float x2, float y2) + { + return RADTODEG(GetRadianAngleBetweenPoints(x1, y1, x2, y2)); + } // should return direction in 0-8 range. fits perfectly to peds' path directions. static int GetNodeHeadingFromVector(float x, float y) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 6efbeb8e..9d00cef7 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -642,6 +642,8 @@ void CPad::AddToCheatString(char c) { for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- ) CheatString[i + 1] = CheatString[i]; + + CheatString[0] = c; #define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1) // "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP diff --git a/src/core/World.cpp b/src/core/World.cpp index d64569b3..b4ae9346 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -58,6 +58,7 @@ WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float) WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); } WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); } WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); } +WRAPPER void CWorld::UseDetonator(CEntity *) { EAXJMP(0x4B4650); } void CWorld::Initialise() diff --git a/src/core/World.h b/src/core/World.h index 07e7889f..0ee3fdda 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -142,6 +142,8 @@ public: static void RemoveStaticObjects(); static void Process(); static void TriggerExplosion(const CVector &, float, float, CEntity*, bool); + + static void UseDetonator(CEntity *); }; extern CColPoint *gaTempSphereColPoints; diff --git a/src/core/main.cpp b/src/core/main.cpp index 93e4c71c..02f7d523 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1557,8 +1557,9 @@ void SystemInit() // #endif - +#ifdef GTA_PS2_STUFF CPad::Initialise(); +#endif CPad::GetPad(0)->Mode = 0; CGame::frenchGame = false; -- cgit v1.2.3 From 90be379bede299aa53bca5027ecc19c356e50f86 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 15 Apr 2020 14:05:24 +0200 Subject: implemented most of librw wrapper --- src/core/TempColModels.cpp | 42 +++++++++++++++++++++--------------------- src/core/common.h | 14 +++++++++++--- 2 files changed, 32 insertions(+), 24 deletions(-) (limited to 'src/core') diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp index f7cf035e..22ef31bd 100644 --- a/src/core/TempColModels.cpp +++ b/src/core/TempColModels.cpp @@ -34,7 +34,7 @@ void CTempColModels::Initialise(void) { #define SET_COLMODEL_SPHERES(colmodel, sphrs)\ - colmodel.numSpheres = ARRAYSIZE(sphrs);\ + colmodel.numSpheres = ARRAY_SIZE(sphrs);\ colmodel.spheres = sphrs;\ colmodel.level = LEVEL_NONE;\ colmodel.ownsCollisionVolumes = false;\ @@ -45,7 +45,7 @@ CTempColModels::Initialise(void) ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f), SURFACE_DEFAULT, 0); ms_colModelBBox.level = LEVEL_NONE; - for (i = 0; i < ARRAYSIZE(ms_colModelCutObj); i++) { + for (i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++) { ms_colModelCutObj[i].boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); ms_colModelCutObj[i].boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f), SURFACE_DEFAULT, 0); ms_colModelCutObj[i].level = LEVEL_NONE; @@ -53,7 +53,7 @@ CTempColModels::Initialise(void) // Ped Spheres - for (i = 0; i < ARRAYSIZE(s_aPedSpheres); i++) + for (i = 0; i < ARRAY_SIZE(s_aPedSpheres); i++) s_aPedSpheres[i].radius = 0.35f; s_aPedSpheres[0].center = CVector(0.0f, 0.0f, -0.25f); @@ -61,9 +61,9 @@ CTempColModels::Initialise(void) s_aPedSpheres[2].center = CVector(0.0f, 0.0f, 0.55f); #ifdef FIX_BUGS - for (i = 0; i < ARRAYSIZE(s_aPedSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aPedSpheres); i++) { #else - for (i = 0; i < ARRAYSIZE(s_aPedGSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aPedGSpheres); i++) { #endif s_aPedSpheres[i].surface = SURFACE_FLESH; s_aPedSpheres[i].piece = 0; @@ -83,7 +83,7 @@ CTempColModels::Initialise(void) s_aPed2Spheres[1].center = CVector(0.0f, 0.0f, -0.9f); s_aPed2Spheres[2].center = CVector(0.0f, -0.35f, -0.9f); - for (i = 0; i < ARRAYSIZE(s_aPed2Spheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aPed2Spheres); i++) { s_aPed2Spheres[i].surface = SURFACE_FLESH; s_aPed2Spheres[i].piece = 0; } @@ -129,7 +129,7 @@ CTempColModels::Initialise(void) s_aDoorSpheres[1].center = CVector(0.0f, -0.95f, -0.35f); s_aDoorSpheres[2].center = CVector(0.0f, -0.6f, 0.25f); - for (i = 0; i < ARRAYSIZE(s_aDoorSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aDoorSpheres); i++) { s_aDoorSpheres[i].surface = SURFACE_BILLBOARD; s_aDoorSpheres[i].piece = 0; } @@ -141,7 +141,7 @@ CTempColModels::Initialise(void) // Bumper Spheres - for (i = 0; i < ARRAYSIZE(s_aBumperSpheres); i++) + for (i = 0; i < ARRAY_SIZE(s_aBumperSpheres); i++) s_aBumperSpheres[i].radius = 0.15f; s_aBumperSpheres[0].center = CVector(0.85f, -0.05f, 0.0f); @@ -149,7 +149,7 @@ CTempColModels::Initialise(void) s_aBumperSpheres[2].center = CVector(-0.4f, 0.05f, 0.0f); s_aBumperSpheres[3].center = CVector(-0.85f, -0.05f, 0.0f); - for (i = 0; i < ARRAYSIZE(s_aBumperSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBumperSpheres); i++) { s_aBumperSpheres[i].surface = SURFACE_BILLBOARD; s_aBumperSpheres[i].piece = 0; } @@ -161,7 +161,7 @@ CTempColModels::Initialise(void) // Panel Spheres - for (i = 0; i < ARRAYSIZE(s_aPanelSpheres); i++) + for (i = 0; i < ARRAY_SIZE(s_aPanelSpheres); i++) s_aPanelSpheres[i].radius = 0.15f; s_aPanelSpheres[0].center = CVector(0.15f, 0.45f, 0.0f); @@ -169,7 +169,7 @@ CTempColModels::Initialise(void) s_aPanelSpheres[2].center = CVector(-0.15f, -0.45f, 0.0f); s_aPanelSpheres[3].center = CVector(-0.15f, 0.45f, 0.0f); - for (i = 0; i < ARRAYSIZE(s_aPanelSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aPanelSpheres); i++) { s_aPanelSpheres[i].surface = SURFACE_BILLBOARD; s_aPanelSpheres[i].piece = 0; } @@ -181,7 +181,7 @@ CTempColModels::Initialise(void) // Bonnet Spheres - for (i = 0; i < ARRAYSIZE(s_aBonnetSpheres); i++) + for (i = 0; i < ARRAY_SIZE(s_aBonnetSpheres); i++) s_aBonnetSpheres[i].radius = 0.2f; s_aBonnetSpheres[0].center = CVector(-0.4f, 0.1f, 0.0f); @@ -189,7 +189,7 @@ CTempColModels::Initialise(void) s_aBonnetSpheres[2].center = CVector(0.4f, 0.1f, 0.0f); s_aBonnetSpheres[3].center = CVector(0.4f, 0.9f, 0.0f); - for (i = 0; i < ARRAYSIZE(s_aBonnetSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBonnetSpheres); i++) { s_aBonnetSpheres[i].surface = SURFACE_BILLBOARD; s_aBonnetSpheres[i].piece = 0; } @@ -201,7 +201,7 @@ CTempColModels::Initialise(void) // Boot Spheres - for (i = 0; i < ARRAYSIZE(s_aBootSpheres); i++) + for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) s_aBootSpheres[i].radius = 0.2f; s_aBootSpheres[0].center = CVector(-0.4f, -0.1f, 0.0f); @@ -209,7 +209,7 @@ CTempColModels::Initialise(void) s_aBootSpheres[2].center = CVector(0.4f, -0.1f, 0.0f); s_aBootSpheres[3].center = CVector(0.4f, -0.6f, 0.0f); - for (i = 0; i < ARRAYSIZE(s_aBootSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { s_aBootSpheres[i].surface = SURFACE_BILLBOARD; s_aBootSpheres[i].piece = 0; } @@ -228,9 +228,9 @@ CTempColModels::Initialise(void) s_aWheelSpheres[1].center = CVector(0.3f, 0.0f, 0.0f); #ifdef FIX_BUGS - for (i = 0; i < ARRAYSIZE(s_aWheelSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aWheelSpheres); i++) { #else - for (i = 0; i < ARRAYSIZE(s_aBootSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { #endif s_aWheelSpheres[i].surface = SURFACE_RUBBER29; s_aWheelSpheres[i].piece = 0; @@ -250,9 +250,9 @@ CTempColModels::Initialise(void) s_aBodyPartSpheres1[1].center = CVector(0.8f, 0.0f, 0.0f); #ifdef FIX_BUGS - for (i = 0; i < ARRAYSIZE(s_aBodyPartSpheres1); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBodyPartSpheres1); i++) { #else - for (i = 0; i < ARRAYSIZE(s_aBootSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { #endif s_aBodyPartSpheres1[i].surface = SURFACE_FLESH; s_aBodyPartSpheres1[i].piece = 0; @@ -272,9 +272,9 @@ CTempColModels::Initialise(void) s_aBodyPartSpheres2[1].center = CVector(0.5f, 0.0f, 0.0f); #ifdef FIX_BUGS - for (i = 0; i < ARRAYSIZE(s_aBodyPartSpheres2); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBodyPartSpheres2); i++) { #else - for (i = 0; i < ARRAYSIZE(s_aBootSpheres); i++) { + for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { #endif s_aBodyPartSpheres2[i].surface = SURFACE_FLESH; s_aBodyPartSpheres2[i].piece = 0; diff --git a/src/core/common.h b/src/core/common.h index 7688b182..454b848a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -23,6 +23,15 @@ #include #include +// gotta put this somewhere +#ifdef LIBRW +#define STREAMPOS(str) ((str)->tell()) +#define STREAMFILE(str) (((rw::StreamFile*)(str))->file) +#else +#define STREAMPOS(str) ((str)->Type.memory.position) +#define STREAMFILE(str) ((str)->Type.file.fpFile) +#endif + #define rwVENDORID_ROCKSTAR 0x0253F2 // Get rid of bullshit windows definitions, we're not running on an 8086 @@ -39,9 +48,6 @@ #ifndef min #define min(a,b) ((a) < (b) ? (a) : (b)) #endif -#ifndef ARRAYSIZE -#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a))) -#endif typedef uint8_t uint8; typedef int8_t int8; @@ -55,7 +61,9 @@ typedef int64_t int64; // hardcode ucs-2 typedef uint16_t wchar; +#ifndef nil #define nil nullptr +#endif #include "config.h" -- cgit v1.2.3 From 4da1879975ef28cb7f406166d62d154d03ef47d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 15 Apr 2020 19:19:45 +0300 Subject: Many fixes and cleanup --- src/core/Collision.cpp | 5 +- src/core/Collision.h | 11 ++++- src/core/Frontend.cpp | 127 +++++++++++++++++++++++++------------------------ src/core/Frontend.h | 8 +++- src/core/World.cpp | 4 +- src/core/World.h | 4 +- src/core/main.cpp | 5 +- 7 files changed, 90 insertions(+), 74 deletions(-) (limited to 'src/core') diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index c884f751..85145e86 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -31,8 +31,8 @@ enum Direction DIR_Z_NEG, }; -eLevelName &CCollision::ms_collisionInMemory = *(eLevelName*)0x8F6250; -CLinkList &CCollision::ms_colModelCache = *(CLinkList*)0x95CB58; +eLevelName CCollision::ms_collisionInMemory; +CLinkList CCollision::ms_colModelCache; void CCollision::Init(void) @@ -1355,6 +1355,7 @@ CCollision::ProcessColModels(const CMatrix &matrixA, CColModel &modelA, modelB.triangles[aTriangleIndicesB[j]], modelB.trianglePlanes[aTriangleIndicesB[j]], spherepoints[numCollisions], coldist); + if(hasCollided) numCollisions++; } diff --git a/src/core/Collision.h b/src/core/Collision.h index 1cbd1690..bdf51eb8 100644 --- a/src/core/Collision.h +++ b/src/core/Collision.h @@ -3,6 +3,13 @@ #include "templates.h" #include "Game.h" // for eLevelName +// If you spawn many tanks at once, you will see that collisions of two entity exceeds 32. +#ifdef FIX_BUGS +#define MAX_COLLISION_POINTS 64 +#else +#define MAX_COLLISION_POINTS 32 +#endif + struct CColSphere { CVector center; @@ -110,8 +117,8 @@ struct CColModel class CCollision { public: - static eLevelName &ms_collisionInMemory; - static CLinkList &ms_colModelCache; + static eLevelName ms_collisionInMemory; + static CLinkList ms_colModelCache; static void Init(void); static void Shutdown(void); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 48683abc..166ecb35 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -82,34 +82,34 @@ int curBottomBarOption = -1; int hoveredBottomBarOption = -1; #endif -int32 CMenuManager::OS_Language = LANG_ENGLISH; // *(int32*)0x5F2F78; -int8 CMenuManager::m_PrefsUseVibration; // = *(int8*)0x95CD92; -int8 CMenuManager::m_DisplayControllerOnFoot; // = *(int8*)0x95CD8D; -int8 CMenuManager::m_PrefsVsync = 1; // *(int8*)0x5F2E58; -int8 CMenuManager::m_PrefsVsyncDisp = 1; // *(int8*)0x5F2E5C; -int8 CMenuManager::m_PrefsFrameLimiter = 1; // *(int8*)0x5F2E60; -int8 CMenuManager::m_PrefsShowSubtitles = 1; // *(int8*)0x5F2E54; -int8 CMenuManager::m_PrefsSpeakers; // = *(int8*)0x95CD7E; -int32 CMenuManager::m_ControlMethod; // = *(int32*)0x8F5F7C; -int8 CMenuManager::m_PrefsDMA = 1; // *(int8*)0x5F2F74; -int32 CMenuManager::m_PrefsLanguage; // = *(int32*)0x941238; +int32 CMenuManager::OS_Language = LANG_ENGLISH; +int8 CMenuManager::m_PrefsUseVibration; +int8 CMenuManager::m_DisplayControllerOnFoot; +int8 CMenuManager::m_PrefsVsync = 1; +int8 CMenuManager::m_PrefsVsyncDisp = 1; +int8 CMenuManager::m_PrefsFrameLimiter = 1; +int8 CMenuManager::m_PrefsShowSubtitles = 1; +int8 CMenuManager::m_PrefsSpeakers; +int32 CMenuManager::m_ControlMethod; +int8 CMenuManager::m_PrefsDMA = 1; +int32 CMenuManager::m_PrefsLanguage; uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings -bool CMenuManager::m_PrefsAllowNastyGame = true; // *(bool*)0x5F2E64; -bool CMenuManager::m_bStartUpFrontEndRequested; // = *(bool*)0x95CCF4; -bool CMenuManager::m_bShutDownFrontEndRequested; // = *(bool*)0x95CD6A; +bool CMenuManager::m_PrefsAllowNastyGame = true; +bool CMenuManager::m_bStartUpFrontEndRequested; +bool CMenuManager::m_bShutDownFrontEndRequested; -int8 CMenuManager::m_PrefsUseWideScreen; // = *(int8*)0x95CD23; -int8 CMenuManager::m_PrefsRadioStation; // = *(int8*)0x95CDA4; -int32 CMenuManager::m_PrefsBrightness = 256; // = *(int32*)0x5F2E50; -float CMenuManager::m_PrefsLOD; // = *(float*)0x8F42C4; -int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt; // = *(int8*)0x628CFC; -int32 CMenuManager::m_PrefsMusicVolume = 102; // = *(int32*)0x5F2E4C; -int32 CMenuManager::m_PrefsSfxVolume = 102; // = *(int32*)0x5F2E48; +int8 CMenuManager::m_PrefsUseWideScreen; +int8 CMenuManager::m_PrefsRadioStation; +int32 CMenuManager::m_PrefsBrightness = 256; +float CMenuManager::m_PrefsLOD = CRenderer::ms_lodDistScale; +int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt; +int32 CMenuManager::m_PrefsMusicVolume = 102; +int32 CMenuManager::m_PrefsSfxVolume = 102; -char CMenuManager::m_PrefsSkinFile[256] = "$$\"\""; // = (char*)0x5F2E74; +char CMenuManager::m_PrefsSkinFile[256] = "$$\"\""; -int32 CMenuManager::m_KeyPressedCode = -1; // = *(int32*)0x5F2E70; +int32 CMenuManager::m_KeyPressedCode = -1; // Originally that was PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway) #ifdef PS2_LIKE_MENU @@ -119,29 +119,26 @@ const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color #endif const float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // not original name -float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; //*(float*)0x5F2E40; -float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; //*(float*)0x5F2E44; +float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; +float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; bool holdingScrollBar; // *(bool*)0x628D59; // not original name -int32 CMenuManager::m_SelectedMap; // *(int32*)0x8E2880; -int32 CMenuManager::m_SelectedGameType; // *(int32*)0x942F88; +int32 CMenuManager::m_SelectedMap; +int32 CMenuManager::m_SelectedGameType; // Used in a hidden menu uint8 CMenuManager::m_PrefsPlayerRed = 255; uint8 CMenuManager::m_PrefsPlayerGreen = 128; uint8 CMenuManager::m_PrefsPlayerBlue; // why?? -CMenuManager FrontEndMenuManager; // = *(CMenuManager*)0x8F59D8; +CMenuManager FrontEndMenuManager; -// Move this somewhere else. -float CRenderer::ms_lodDistScale = 1.2f; // *(float*)0x5F726C; - -uint32 TimeToStopPadShaking; // = *(uint32*)0x628CF8; -char *pEditString; // = *(char**)0x628D00; -int32 *pControlEdit; // = *(int32**)0x628D08; -bool DisplayComboButtonErrMsg; // = *(bool*)0x628D14; -int32 MouseButtonJustClicked; // = *(int32*)0x628D0C; -int32 JoyButtonJustClicked; // = *(int32*)0x628D10; +uint32 TimeToStopPadShaking; +char *pEditString; +int32 *pControlEdit; +bool DisplayComboButtonErrMsg; +int32 MouseButtonJustClicked; +int32 JoyButtonJustClicked; //int32 *pControlTemp = 0; #ifndef MASTER @@ -283,6 +280,12 @@ ScaleAndCenterX(float x) } while(0) #endif +#define PREPARE_MENU_HEADER \ + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); \ + CFont::SetRightJustifyOn(); \ + CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \ + CFont::SetFontStyle(FONT_HEADING); + #define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \ do { \ lastActiveBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ @@ -447,8 +450,8 @@ CMenuManager::CheckCodesForControls(int typeOfControl) if (typeOfControl == KEYBOARD) { if (*pControlEdit == rsESC) { escPressed = true; - } else if (*pControlEdit > rsF3 && *pControlEdit != rsF9 && *pControlEdit != rsLWIN && - *pControlEdit != rsRWIN && *pControlEdit != rsRALT) { + } else if (*pControlEdit != rsF1 && *pControlEdit != rsF2 && *pControlEdit != rsF3 && *pControlEdit != rsF9 && + *pControlEdit != rsLWIN && *pControlEdit != rsRWIN && *pControlEdit != rsRALT) { typeToSave = KEYBOARD; if (ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD) != rsNULL && *pControlEdit != ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD)) { @@ -465,7 +468,10 @@ CMenuManager::CheckCodesForControls(int typeOfControl) DisplayComboButtonErrMsg = true; } - ControlsManager.ClearSettingsAssociatedWithAction(action, typeToSave); +#ifdef FIX_BUGS + if(!escPressed && !invalidKey) +#endif + ControlsManager.ClearSettingsAssociatedWithAction(action, typeToSave); if (!DisplayComboButtonErrMsg && !escPressed && !invalidKey) { if (typeOfControl == KEYBOARD) { ControlsManager.DeleteMatchingActionInitiators(action, *pControlEdit, KEYBOARD); @@ -670,6 +676,17 @@ CMenuManager::Draw() CFont::SetCentreOff(); CFont::SetJustifyOn(); CFont::SetBackGroundOnlyTextOn(); +#ifdef GTA3_1_1_PATCH + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + CFont::SetRightJustifyOn(); + CFont::SetFontStyle(FONT_HEADING); + CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f)); + CFont::SetWrapx(SCREEN_WIDTH); + CFont::SetRightJustifyWrap(0.0f); + strcpy(gString, "V1.1"); + AsciiToUnicode(gString, gUString); + CFont::PrintString(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 45, gUString); +#endif CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); @@ -696,17 +713,9 @@ CMenuManager::Draw() #endif if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') { - CFont::SetRightJustifyOn(); - CFont::SetFontStyle(FONT_HEADING); -#ifdef PS2_LIKE_MENU - CFont::SetColor(CRGBA(0, 0, 0, 255)); - CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(1.3f)); - CFont::PrintString(MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(75.0f), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); -#else - CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); - CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); + PREPARE_MENU_HEADER CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); -#endif + // Weird place to put that. nextYToUse += 24.0f + 10.0f; } @@ -1735,11 +1744,8 @@ CMenuManager::DrawControllerSetupScreen() CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); - // Page header - CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); - CFont::SetRightJustifyOn(); - CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); - CFont::SetFontStyle(FONT_HEADING); + PREPARE_MENU_HEADER + switch (m_ControlMethod) { case CONTROL_STANDARD: CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), @@ -2417,10 +2423,8 @@ CMenuManager::DrawPlayerSetupScreen() CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); - CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); - CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); - CFont::SetRightJustifyOn(); - CFont::SetFontStyle(FONT_HEADING); + PREPARE_MENU_HEADER + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS")); // lstrcpy's changed with strcpy @@ -3314,10 +3318,7 @@ CMenuManager::PrintStats() // ::Draw already does that. /* - CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); - CFont::SetRightJustifyOn(); - CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); + PREPARE_MENU_HEADER CFont::PrintString(MENU_X_RIGHT_ALIGNED(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); */ CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y)); diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 9064cf4e..8fe61a36 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -2,10 +2,16 @@ #include "Sprite2d.h" +#ifdef PS2_LIKE_MENU +#define MENUHEADER_POS_X 50.0f +#define MENUHEADER_POS_Y 75.0f +#define MENUHEADER_HEIGHT 1.3f +#else #define MENUHEADER_POS_X 35.0f #define MENUHEADER_POS_Y 93.0f -#define MENUHEADER_WIDTH 0.84f #define MENUHEADER_HEIGHT 1.6f +#endif +#define MENUHEADER_WIDTH 0.84f #define MENU_X_MARGIN 40.0f #define MENUACTION_POS_Y 60.0f diff --git a/src/core/World.cpp b/src/core/World.cpp index d64569b3..289be256 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -21,7 +21,7 @@ #include "Population.h" #include "Fire.h" -CColPoint *gaTempSphereColPoints = (CColPoint*)0x6E64C0; // [32] +CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; CPtrList *CWorld::ms_bigBuildingsList = (CPtrList*)0x6FAB60; CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList*)0x8F433C; @@ -29,7 +29,7 @@ CSector (*CWorld::ms_aSectors)[NUMSECTORS_X] = (CSector (*)[NUMSECTORS_Y])0x6656 uint16 &CWorld::ms_nCurrentScanCode = *(uint16*)0x95CC64; uint8 &CWorld::PlayerInFocus = *(uint8 *)0x95CD61; -CPlayerInfo (&CWorld::Players)[NUMPLAYERS] = *(CPlayerInfo (*)[NUMPLAYERS])*(uintptr*)0x9412F0; +CPlayerInfo CWorld::Players[NUMPLAYERS]; bool &CWorld::bNoMoreCollisionTorque = *(bool*)0x95CDCC; CEntity *&CWorld::pIgnoreEntity = *(CEntity**)0x8F6494; bool &CWorld::bIncludeDeadPeds = *(bool*)0x95CD8F; diff --git a/src/core/World.h b/src/core/World.h index 07e7889f..62fdc3b3 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -61,7 +61,7 @@ class CWorld public: static uint8 &PlayerInFocus; - static CPlayerInfo (&Players)[NUMPLAYERS]; + static CPlayerInfo Players[NUMPLAYERS]; static CEntity *&pIgnoreEntity; static bool &bIncludeDeadPeds; static bool &bNoMoreCollisionTorque; @@ -144,7 +144,7 @@ public: static void TriggerExplosion(const CVector &, float, float, CEntity*, bool); }; -extern CColPoint *gaTempSphereColPoints; +extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; class CPlayerPed; class CVehicle; diff --git a/src/core/main.cpp b/src/core/main.cpp index f09c2e0a..2d452f9c 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -690,14 +690,14 @@ DisplayGameDebugText() CFont::SetPropOn(); CFont::SetBackgroundOff(); CFont::SetFontStyle(FONT_BANK); - CFont::SetScale(SCREEN_STRETCH_X(0.5f), SCREEN_STRETCH_Y(0.5f)); + CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.5f)); CFont::SetCentreOff(); CFont::SetRightJustifyOff(); CFont::SetWrapx(SCREEN_WIDTH); CFont::SetJustifyOff(); CFont::SetBackGroundOnlyTextOff(); CFont::SetColor(CRGBA(255, 108, 0, 255)); - CFont::PrintString(10.0f, 10.0f, ver); + CFont::PrintString(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(10.0f), ver); FrameSamples++; FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f); @@ -748,6 +748,7 @@ DisplayGameDebugText() AsciiToUnicode(str, ustr); + // Let's not scale those numbers, they look better that way :eyes: CFont::SetPropOff(); CFont::SetBackgroundOff(); CFont::SetScale(0.7f, 1.5f); -- cgit v1.2.3 From d455cd8a62639145d7b5c03ada6fc84d2ad8ac36 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 16 Apr 2020 00:44:25 +0300 Subject: Default native resolution mode and small camera fixes --- src/core/Camera.cpp | 8 ++++++++ src/core/Camera.h | 4 ++-- src/core/config.h | 1 + src/core/main.cpp | 5 +++++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 91dd6573..c7fa41e4 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -2183,13 +2183,21 @@ CCamera::DrawBordersForWideScreen(void) SetMotionBlurAlpha(80); CSprite2d::DrawRect( +#ifdef FIX_BUGS + CRect(0.0f, (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - SCREEN_SCALE_Y(8.0f), +#else CRect(0.0f, (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f, +#endif SCREEN_WIDTH, 0.0f), CRGBA(0, 0, 0, 255)); CSprite2d::DrawRect( CRect(0.0f, SCREEN_HEIGHT, +#ifdef FIX_BUGS + SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - SCREEN_SCALE_Y(8.0f)), +#else SCREEN_WIDTH, SCREEN_HEIGHT - (SCREEN_HEIGHT/2) * m_ScreenReductionPercentage/100.0f - 8.0f), +#endif CRGBA(0, 0, 0, 255)); } diff --git a/src/core/Camera.h b/src/core/Camera.h index eca4518a..09a8d603 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -415,7 +415,7 @@ uint32 unknown; // some counter having to do with music float CamFrontXNorm; float CamFrontYNorm; -#if 0 // TODO: FIX_BUGS once GenericLoad is done +#ifdef FIX_BUGS int32 CarZoomIndicator; #else float CarZoomIndicator; @@ -455,7 +455,7 @@ uint32 unknown; // some counter having to do with music float m_ScreenReductionSpeed; float m_AlphaForPlayerAnim1rstPerson; float Orientation; -#if 0 // TODO: FIX_BUGS once GenericLoad is done +#ifdef FIX_BUGS int32 PedZoomIndicator; #else float PedZoomIndicator; diff --git a/src/core/config.h b/src/core/config.h index f7fde579..38e7679f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -189,6 +189,7 @@ enum Config { #define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more #define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things #define MORE_LANGUAGES // Add more translations to the game +#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) // Pad #define XINPUT diff --git a/src/core/main.cpp b/src/core/main.cpp index b028b5fb..08463df9 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -240,8 +240,13 @@ DoFade(void) float y = SCREEN_HEIGHT/2 * TheCamera.m_ScreenReductionPercentage/100.0f; rect.left = 0.0f; rect.right = SCREEN_WIDTH; +#ifdef FIX_BUGS + rect.top = y - SCREEN_SCALE_Y(8.0f); + rect.bottom = SCREEN_HEIGHT - y - SCREEN_SCALE_Y(8.0f); +#else rect.top = y - 8.0f; rect.bottom = SCREEN_HEIGHT - y - 8.0f; +#endif // FIX_BUGS }else{ rect.left = 0.0f; rect.right = SCREEN_WIDTH; -- cgit v1.2.3 From c22e59abab331376cdc8557a863eb2584b4bef4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 16 Apr 2020 05:07:32 +0300 Subject: Various fixes --- src/core/Frontend.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 166ecb35..a01689e4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5246,6 +5246,7 @@ CMenuManager::PrintController(void) void CMenuManager::PrintMap(void) { + CFont::SetJustifyOn(); bMenuMapActive = true; CRadar::InitFrontEndMap(); -- cgit v1.2.3 From 4b602940eb79c637f70a22046d414a0b1358eea8 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 16 Apr 2020 10:26:16 +0200 Subject: first fake RW implementation working --- src/core/Game.cpp | 4 ++++ src/core/config.h | 1 + 2 files changed, 5 insertions(+) (limited to 'src/core') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index fe747ac1..8699ffeb 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -307,6 +307,7 @@ bool CGame::Initialise(const char* datFile) CDraw::SetFOV(120.0f); CDraw::ms_fLODDistance = 500.0f; LoadingScreen("Loading the Game", "Setup streaming", nil); +#ifdef USE_TXD_CDIMAGE int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r"); if (txdHandle) CFileMgr::CloseFile(txdHandle); @@ -321,6 +322,9 @@ bool CGame::Initialise(const char* datFile) CStreaming::Init(); } } +#else + CStreaming::Init(); +#endif CStreaming::LoadInitialVehicles(); CStreaming::LoadInitialPeds(); CStreaming::RequestBigBuildings(LEVEL_NONE); diff --git a/src/core/config.h b/src/core/config.h index 38e7679f..f684ed3c 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -190,6 +190,7 @@ enum Config { #define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things #define MORE_LANGUAGES // Add more translations to the game #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) +//#define USE_TXD_CDIMAGE // generate and load textures from txd.img // Pad #define XINPUT -- cgit v1.2.3 From b1fc7bc533dc7d603daafbf8a158a92f710c1e60 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 16 Apr 2020 11:50:45 +0300 Subject: More refs removed --- src/core/Camera.cpp | 1 + src/core/main.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index c7fa41e4..c2392d3b 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -29,6 +29,7 @@ #include "SceneEdit.h" #include "Pools.h" #include "Debug.h" +#include "GenericGameStorage.h" #include "Camera.h" enum diff --git a/src/core/main.h b/src/core/main.h index 5e9401b9..5ee758a4 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -16,11 +16,8 @@ extern char *gString; extern char *gString2; extern wchar *gUString; extern wchar *gUString2; -extern bool &b_FoundRecentSavedGameWantToLoad; extern bool gbPrintShite; extern bool &gbModelViewer; -extern bool &StillToFadeOut; -extern bool &JustLoadedDontFadeInYet; class CSprite2d; -- cgit v1.2.3 From 69c32376fe6ff99c17662533e9e6999fb24708b0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 16 Apr 2020 12:44:04 +0300 Subject: Increase alpha entity list capacity for wide screen --- src/core/config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index f684ed3c..f9edb74a 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -47,7 +47,8 @@ enum Config { NUM_PATHCONNECTIONS = 10260, // Link list lengths - // TODO: alpha list + NUMALPHALIST = 20, + NUMALPHAENTITYLIST = 150, NUMCOLCACHELINKS = 200, NUMREFERENCES = 800, -- cgit v1.2.3 From 83cbe4e39ede4853e0d352e55aeddbd481b39948 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 16 Apr 2020 15:30:47 +0300 Subject: More refs removed --- src/core/IniFile.cpp | 4 ++-- src/core/IniFile.h | 4 ++-- src/core/Instance.cpp | 20 -------------------- src/core/Instance.h | 14 -------------- 4 files changed, 4 insertions(+), 38 deletions(-) delete mode 100644 src/core/Instance.cpp delete mode 100644 src/core/Instance.h (limited to 'src/core') diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index 08b30876..744f4bd0 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -7,8 +7,8 @@ #include "main.h" #include "Population.h" -float &CIniFile::PedNumberMultiplier = *(float*)0x6182F4; -float &CIniFile::CarNumberMultiplier = *(float*)0x6182F8; +float CIniFile::PedNumberMultiplier = 1.0f;// = *(float*)0x6182F4; +float CIniFile::CarNumberMultiplier = 1.0f;// = *(float*)0x6182F8; void CIniFile::LoadIniFile() { diff --git a/src/core/IniFile.h b/src/core/IniFile.h index 9a98151b..1e30c4de 100644 --- a/src/core/IniFile.h +++ b/src/core/IniFile.h @@ -5,6 +5,6 @@ class CIniFile public: static void LoadIniFile(); - static float& PedNumberMultiplier; - static float& CarNumberMultiplier; + static float PedNumberMultiplier; + static float CarNumberMultiplier; }; diff --git a/src/core/Instance.cpp b/src/core/Instance.cpp deleted file mode 100644 index 775341be..00000000 --- a/src/core/Instance.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "Instance.h" - -void -CInstance::Shutdown() -{ - GetMatrix().Detach(); -} - -class CInstance_ : public CInstance -{ -public: - void dtor() { CInstance::~CInstance(); } -}; - -STARTPATCHES - InjectHook(0x50BE90, &CInstance_::dtor, PATCH_JUMP); - InjectHook(0x50B850, &CInstance::Shutdown, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Instance.h b/src/core/Instance.h deleted file mode 100644 index 01dfb6a2..00000000 --- a/src/core/Instance.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Placeable.h" - -// unused - -class CInstance : public CPlaceable -{ -public: - int m_modelIndex; -public: - ~CInstance() = default; - void Shutdown(); -}; -- cgit v1.2.3 From 52d0d811b79f810aae9d10beb671f9889b8e4330 Mon Sep 17 00:00:00 2001 From: saml1er Date: Thu, 16 Apr 2020 23:46:08 +0500 Subject: Reverse CWorld --- src/core/World.cpp | 846 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/core/World.h | 33 ++- 2 files changed, 849 insertions(+), 30 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index d64569b3..7f18abbf 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -20,6 +20,14 @@ #include "Replay.h" #include "Population.h" #include "Fire.h" +#include "ProjectileInfo.h" +#include "WaterLevel.h" +#include "CopPed.h" +#include "Object.h" +#include "Shadows.h" +#include "Explosion.h" + +#define OBJECT_REPOSITION_OFFSET_Z 0.2f CColPoint *gaTempSphereColPoints = (CColPoint*)0x6E64C0; // [32] @@ -40,24 +48,24 @@ bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B; bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C; bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA; -WRAPPER void CWorld::ClearForRestart(void) { EAXJMP(0x4AE850); } -WRAPPER void CWorld::AddParticles(void) { EAXJMP(0x4B4010); } -WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); } -WRAPPER void CWorld::RepositionCertainDynamicObjects() { EAXJMP(0x4B42B0); } -WRAPPER void CWorld::RemoveStaticObjects() { EAXJMP(0x4B4D50); } -WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); } -WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); } -WRAPPER void CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, uint8) { EAXJMP(0x4B4E70) }; -WRAPPER void CWorld::FindObjectsIntersectingCube(const CVector &, const CVector &, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B2E70); } -WRAPPER void CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B3280); } -WRAPPER void CWorld::FindObjectsOfTypeInRange(uint32, CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool) { EAXJMP(0x4B2600); } -WRAPPER void CWorld::FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVector&, float, bool, short*, short, CEntity**) { EAXJMP(0x4B2960); } -WRAPPER void CWorld::FindMissionEntitiesIntersectingCube(const CVector&, const CVector&, int16*, int16, CEntity**, bool, bool, bool) { EAXJMP(0x4B3680); } -WRAPPER void CWorld::ClearCarsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B50E0); } -WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B52B0); } -WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); } -WRAPPER void CWorld::TriggerExplosion(const CVector& a1, float a2, float a3, CEntity *a4, bool a5) { EAXJMP(0x4B1140); } -WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); } +//WRAPPER void CWorld::ClearForRestart(void) { EAXJMP(0x4AE850); } +//WRAPPER void CWorld::AddParticles(void) { EAXJMP(0x4B4010); } +//WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); } +//WRAPPER void CWorld::RepositionCertainDynamicObjects() { EAXJMP(0x4B42B0); } +//WRAPPER void CWorld::RemoveStaticObjects() { EAXJMP(0x4B4D50); } +//WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); } +//WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); } +//WRAPPER void CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, uint8 unused) { EAXJMP(0x4B4E70) }; +//WRAPPER void CWorld::FindObjectsIntersectingCube(const CVector &, const CVector &, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B2E70); } +//WRAPPER void CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B3280); } +//WRAPPER void CWorld::FindObjectsOfTypeInRange(uint32, CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool) { EAXJMP(0x4B2600); } +//WRAPPER void CWorld::FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVector&, float, bool, short*, short, CEntity**) { EAXJMP(0x4B2960); } +//WRAPPER void CWorld::FindMissionEntitiesIntersectingCube(const CVector&, const CVector&, int16*, int16, CEntity**, bool, bool, bool) { EAXJMP(0x4B3680); } +//WRAPPER void CWorld::ClearCarsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B50E0); } +//WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B52B0); } +//WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); } +WRAPPER void CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity *pCreator, bool bProcessVehicleBombTimer) { EAXJMP(0x4B1140); } +//WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); } void CWorld::Initialise() @@ -128,6 +136,48 @@ CWorld::ClearScanCodes(void) } } +void +CWorld::ClearExcitingStuffFromArea(const CVector& pos, float radius, bool bRemoveProjectilesAndTidyUpShadows) +{ + CPedPool* pedPool = CPools::GetPedPool(); + for (int32 i = 0; i < pedPool->GetSize(); i++) { + CPed* pPed = pedPool->GetSlot(i); + if (pPed && !pPed->IsPlayer() && pPed->CanBeDeleted() && + CVector2D(pPed->GetPosition() - pos).MagnitudeSqr() < radius) { + CPopulation::RemovePed(pPed); + } + } + CVehiclePool* VehiclePool = CPools::GetVehiclePool(); + for (int32 i = 0; i < VehiclePool->GetSize(); i++) { + CVehicle* pVehicle = VehiclePool->GetSlot(i); + if (pVehicle && CVector2D(pVehicle->GetPosition() - pos).MagnitudeSqr() < radius && + !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { + if (pVehicle->pDriver) { + CPopulation::RemovePed(pVehicle->pDriver); + pVehicle->pDriver = nil; + } + for (int32 j = 0; j < pVehicle->m_nNumMaxPassengers; ++j) { + if (pVehicle->pPassengers[j]) { + CPopulation::RemovePed(pVehicle->pPassengers[j]); + pVehicle->pPassengers[j] = nil; + --pVehicle->m_nNumPassengers; + } + } + CCarCtrl::RemoveFromInterestingVehicleList(pVehicle); + CWorld::Remove(pVehicle); + delete pVehicle; + } + } + CObject::DeleteAllTempObjectsInArea(pos, radius); + gFireManager.ExtinguishPoint(pos, radius); + CWorld::ExtinguishAllCarFiresInArea(pos, radius); + CExplosion::RemoveAllExplosionsInArea(pos, radius); + if (bRemoveProjectilesAndTidyUpShadows) { + CProjectileInfo::RemoveAllProjectiles(); + CShadows::TidyUpShadows(); + } +} + bool CWorld::CameraToIgnoreThisObject(CEntity *ent) { @@ -694,6 +744,67 @@ CWorld::FindObjectsInRange(CVector ¢re, float radius, bool ignoreZ, short *n } } +void +CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity->m_scanCode != ms_nCurrentScanCode) { + pEntity->m_scanCode = ms_nCurrentScanCode; + float fMagnitude = 0.0f; + if (bCheck2DOnly) + fMagnitude = CVector2D(position - pEntity->GetPosition()).Magnitude(); + else + fMagnitude = CVector(position - pEntity->GetPosition()).Magnitude(); + if (fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) { + if (aEntities) + aEntities[*nEntitiesFound] = pEntity; + ++*nEntitiesFound; + } + } + pNode = pNode->next; + } +} + +void +CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) +{ + CWorld::AdvanceCurrentScanCode(); + *nEntitiesFound = 0; + const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); + const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); + const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + if (bBuildings) { + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bVehicles) { + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bPeds) { + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bObjects) { + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bDummies) { + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + } + } +} + CEntity* CWorld::TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects) { @@ -872,6 +983,273 @@ CWorld::FindRoofZFor3DCoord(float x, float y, float z, bool *found) } } +void +CWorld::RemoveReferencesToDeletedObject(CEntity* pDeletedObject) +{ + int32 i = CPools::GetPedPool()->GetSize(); + while (--i >= 0) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + if (pPed && pPed != pDeletedObject) { + pPed->RemoveRefsToEntity(pDeletedObject); + if (pPed->m_pCurrentPhysSurface == pDeletedObject) + pPed->m_pCurrentPhysSurface = nil; + } + } + i = CPools::GetVehiclePool()->GetSize(); + while (--i >= 0) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (pVehicle && pVehicle != pDeletedObject) { + pVehicle->RemoveRefsToEntity(pDeletedObject); + pVehicle->RemoveRefsToVehicle(pDeletedObject); + } + } + i = CPools::GetObjectPool()->GetSize(); + while (--i >= 0) { + CObject* pObject = CPools::GetObjectPool()->GetSlot(i); + if (pObject && pObject != pDeletedObject) { + pObject->RemoveRefsToEntity(pDeletedObject); + } + } +} + +void +CWorld::FindObjectsKindaColliding(const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) +{ + CWorld::AdvanceCurrentScanCode(); + *nCollidingEntities = 0; + const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); + const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); + const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + if (bBuildings) { + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + } + if (bVehicles) { + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + } + if (bPeds) { + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + } + if (bObjects) { + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + } + if (bDummies) { + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + } + } + } +} + +void +CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity->m_scanCode != ms_nCurrentScanCode) { + pEntity->m_scanCode = ms_nCurrentScanCode; + float fMagnitude = 0.0f; + if (bCheck2DOnly) + fMagnitude = CVector2D(position - pEntity->GetPosition()).Magnitude(); + else + fMagnitude = CVector(position - pEntity->GetPosition()).Magnitude(); + if (pEntity->GetBoundRadius() + radius > fMagnitude && *nCollidingEntities < maxEntitiesToFind) { + if (aEntities) + aEntities[*nCollidingEntities] = pEntity; + ++*nCollidingEntities; + } + } + pNode = pNode->next; + } +} + +void +CWorld::FindObjectsIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) +{ + CWorld::AdvanceCurrentScanCode(); + *nIntersecting = 0; + const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + if (bBuildings) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + } + if (bVehicles) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + } + if (bPeds) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + } + if (bObjects) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + } + if (bDummies) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + } + } + } + +} + +void +CWorld::FindObjectsIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { + pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; + float fRadius = pEntity->GetBoundRadius(); + const CVector& entityPos = pEntity->GetPosition(); + if (fRadius + entityPos.x >= vecStartPos.x && entityPos.x - fRadius <= vecEndPos.x && + fRadius + entityPos.y >= vecStartPos.y && entityPos.y - fRadius <= vecEndPos.y && + fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z && + *nIntersecting < maxEntitiesToFind) { + if (aEntities) + aEntities[*nIntersecting] = pEntity; + ++*nIntersecting; + } + } + pNode = pNode->next; + } +} + +void +CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox& boundingBox, const CMatrix& matrix, const CVector& position, float fStartX, float fStartY, float fEndX, float fEndY, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) +{ + CWorld::AdvanceCurrentScanCode(); + *nEntitiesFound = 0; + const int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + if (bBuildings) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bVehicles) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bPeds) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_PEDS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bObjects) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if (bDummies) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + } + } + } +} + +void +CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, const CColBox& boundingBox, const CMatrix& matrix, const CVector& position, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { + pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; + CColSphere sphere; + CVector vecDistance = pEntity->m_matrix.GetPosition() - position; + sphere.radius = pEntity->GetBoundRadius(); + sphere.center = Multiply3x3(vecDistance, matrix); + if (CCollision::TestSphereBox(sphere, boundingBox) && *nEntitiesFound < maxEntitiesToFind) { + if (aEntities) + aEntities[*nEntitiesFound] = pEntity; + ++*nEntitiesFound; + } + } + pNode = pNode->next; + } +} + +void +CWorld::FindMissionEntitiesIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bVehicles, bool bPeds, bool bObjects) +{ + CWorld::AdvanceCurrentScanCode(); + *nIntersecting = 0; + const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + if (bVehicles) { + CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, true, false); + CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, true, false); + } + if (bPeds) { + CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, true); + CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, true); + } + if (bObjects) { + CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, false); + CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, false); + } + } + } +} + +void +CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bIsVehicleList, bool bIsPedList) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { + pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; + bool bIsMissionEntity = false; + if (bIsVehicleList) + bIsMissionEntity = ((CVehicle*)pEntity)->VehicleCreatedBy == MISSION_VEHICLE; + else if (bIsPedList) + bIsMissionEntity = ((CPed*)pEntity)->CharCreatedBy == MISSION_CHAR; + else + bIsMissionEntity = ((CObject*)pEntity)->ObjectCreatedBy == MISSION_OBJECT; + float fRadius = pEntity->GetBoundRadius(); + const CVector& entityPos = pEntity->GetPosition(); + if (bIsMissionEntity && + fRadius + entityPos.x >= vecStartPos.x && entityPos.x - fRadius <= vecEndPos.x && + fRadius + entityPos.y >= vecStartPos.y && entityPos.y - fRadius <= vecEndPos.y && + fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z && + *nIntersecting < maxEntitiesToFind) { + if (aEntities) + aEntities[*nIntersecting] = (CEntity*)pEntity; + ++*nIntersecting; + } + } + pNode = pNode->next; + } +} + CPlayerPed* FindPlayerPed(void) { @@ -960,6 +1338,155 @@ FindPlayerHeading(void) return FindPlayerPed()->GetForward().Heading(); } + +void CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2) +{ + CVehiclePool *pVehiclePool = CPools::GetVehiclePool(); + for (int32 i = 0; i < pVehiclePool->GetSize(); i++) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (pVehicle) { + const CVector& position = pVehicle->GetPosition(); + if (position.x >= x1 && position.x <= x2 && + position.y >= y1 && position.y <= y2 && + position.z >= z1 && position.z <= z2 && + !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { + if (pVehicle->pDriver) { + CPopulation::RemovePed(pVehicle->pDriver); + pVehicle->pDriver = nil; + } + for (int32 j = 0; j < pVehicle->m_nNumMaxPassengers; ++j) { + if (pVehicle->pPassengers[j]) { + CPopulation::RemovePed(pVehicle->pPassengers[j]); + pVehicle->pPassengers[j] = nil; + --pVehicle->m_nNumPassengers; + } + } + CCarCtrl::RemoveFromInterestingVehicleList(pVehicle); + CWorld::Remove(pVehicle); + delete pVehicle; + } + } + } +} + +void +CWorld::ClearPedsFromArea(float x1, float y1, float z1, float x2, float y2, float z2) +{ + CPedPool* pPedPool = CPools::GetPedPool(); + for (int32 i = 0; i < pPedPool->GetSize(); i++) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + if (pPed) { + const CVector& position = pPed->GetPosition(); + if (!pPed->IsPlayer() && pPed->CanBeDeleted() && + position.x >= x1 && position.x <= x2 && + position.y >= y1 && position.y <= y2 && + position.z >= z1 && position.z <= z2) { + CPopulation::RemovePed(pPed); + } + } + } +} + +void +CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) +{ + CWorld::AdvanceCurrentScanCode(); + float fStartX = x1 - 10.0f; + float fStartY = y1 - 10.0f; + float fEndX = x2 + 10.0f; + float fEndY = y2 + 10.0f; + const int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); + CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); + CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS], x1, y1, x2, y2); + CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], x1, y1, x2, y2); + } + } +} + +void +CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CVehicle *pVehicle = (CVehicle*)pNode->item; + if (pVehicle->m_scanCode != CWorld::ms_nCurrentScanCode) { + pVehicle->m_scanCode = CWorld::ms_nCurrentScanCode; + const CVector& vehiclePos = pVehicle->m_matrix.GetPosition(); + eCarMission carMission = pVehicle->AutoPilot.m_nCarMission; + if (pVehicle != FindPlayerVehicle() && + vehiclePos.x > fStartX && vehiclePos.x < fEndX && + vehiclePos.y > fStartY && vehiclePos.y < fEndY && + pVehicle->bIsLawEnforcer && + (carMission == MISSION_RAMPLAYER_FARAWAY || carMission == MISSION_RAMPLAYER_CLOSE || + carMission == MISSION_BLOCKPLAYER_FARAWAY || carMission == MISSION_BLOCKPLAYER_CLOSE) + ) { + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000; + CColModel* pColModel = pVehicle->GetColModel(); + bool bInsideSphere = false; + for (int32 i = 0; i < pColModel->numSpheres; i++) { + CVector pos = pVehicle->m_matrix * pColModel->spheres[i].center; + float fRadius = pColModel->spheres[i].radius; + if (pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 && pos.y - fRadius < y2) + bInsideSphere = true; + // Maybe break the loop when bInsideSphere is set to true? + } + if (bInsideSphere) { + if (pVehicle->m_matrix.GetPosition().x <= (x1 + x2) * 0.5f) + pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f); + else + pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f); + if (pVehicle->m_matrix.GetPosition().y <= (y1 + y2) * 0.5f) + pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f); + else + pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f); + } + } + } + pNode = pNode->next; + } +} + +void +CWorld::CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CPed* pPed = (CPed*)pNode->item; + const CVector& pedPos = pPed->GetPosition(); + if (pPed->m_scanCode != CWorld::ms_nCurrentScanCode) + { + pPed->m_scanCode = CWorld::ms_nCurrentScanCode; + if (pPed != FindPlayerPed() && pPed->m_leader != FindPlayerPed() && + pedPos.x > x1 && pedPos.x < x2 && + pedPos.y > y1 && pedPos.y < y2 && + (pPed->m_pedInObjective == FindPlayerPed() || pPed->m_carInObjective && pPed->m_carInObjective == FindPlayerVehicle()) && + pPed->m_nPedState != PED_DEAD && pPed->m_nPedState != PED_DIE && + (pPed->m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || + pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || + pPed->m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS)) { + if (pPed->IsPedInControl()) { + if (pPed->m_nPedType == PEDTYPE_COP) + ((CCopPed*)pPed)->ClearPursuit(); + else + pPed->SetIdle(); + pPed->SetObjective(OBJECTIVE_NONE); + } + else { + pPed->m_prevObjective = OBJECTIVE_NONE; + pPed->m_nLastPedState = PED_IDLE; + } + } + } + } +} + void CWorld::RemoveEntityInsteadOfProcessingIt(CEntity* ent) { @@ -1056,6 +1583,214 @@ CWorld::ExtinguishAllCarFiresInArea(CVector point, float range) } } +void +CWorld::AddParticles(void) +{ + for (int32 y = 0; y < NUMSECTORS_Y; y++) { + for (int32 x = 0; x < NUMSECTORS_X; x++) { + CSector* pSector = GetSector(x, y); + CEntity::AddSteamsFromGround1(pSector->m_lists[ENTITYLIST_BUILDINGS]); + CEntity::AddSteamsFromGround1(pSector->m_lists[ENTITYLIST_DUMMIES]); + } + } +} + +void +CWorld::ShutDown(void) +{ + for (int32 y = 0; y < NUMSECTORS_Y; y++) { + for (int32 x = 0; x < NUMSECTORS_X; x++) { + CSector *pSector = GetSector(x, y); + CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_PEDS].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); + } + } + for (int32 i = 0; i < 4; i ++) { + CPtrNode* pNode = GetBigBuildingList((eLevelName)i).first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + // Maybe remove from world here? + delete pEntity; + } + pNode = pNode->next; + } + GetBigBuildingList((eLevelName)i).Flush(); + } + for (int32 y = 0; y < NUMSECTORS_Y; y++) { + for (int32 x = 0; x < NUMSECTORS_X; x++) { + CSector* pSector = GetSector(x, y); + if (pSector->m_lists[ENTITYLIST_BUILDINGS].first) { + sprintf(gString, "Building list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); + } + if (pSector->m_lists[ENTITYLIST_DUMMIES].first) { + sprintf(gString, "Dummy list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); + } + if (pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first) { + sprintf(gString, "Building overlap list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].first) { + sprintf(gString, "Vehicle overlap list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].first) { + sprintf(gString, "Ped overlap list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].first) { + sprintf(gString, "Object overlap list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first) { + sprintf(gString, "Dummy overlap list %d,%d not empty\n", x, y); + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); + } + } + } + ms_listMovingEntityPtrs.Flush(); +} + +void +CWorld::ClearForRestart(void) +{ + if (CCutsceneMgr::HasLoaded()) + CCutsceneMgr::DeleteCutsceneData(); + CProjectileInfo::RemoveAllProjectiles(); + CObject::DeleteAllTempObjects(); + CObject::DeleteAllMissionObjects(); + CPopulation::ConvertAllObjectsToDummyObjects(); + for (int32 y = 0; y < NUMSECTORS_Y; y++) { + for (int32 x = 0; x < NUMSECTORS_X; x++) { + CSector *pSector = GetSector(x, y); + CPtrNode *pNode = pSector->m_lists[ENTITYLIST_PEDS].first; + while (pNode) { + CEntity *pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = GetBigBuildingList(LEVEL_NONE).first; + while (pNode) { + CVehicle *pVehicle = (CVehicle*)pNode->item; + if (pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { + CWorld::Remove(pVehicle); + delete pVehicle; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + } + } + CPools::CheckPoolsEmpty(); +} + +void +CWorld::RepositionCertainDynamicObjects() +{ + int32 i = CPools::GetDummyPool()->GetSize(); + while (--i >= 0) { + CDummy* dummy = CPools::GetDummyPool()->GetSlot(i); + if (dummy) { + RepositionOneObject(dummy); + } + } +} + +void +CWorld::RepositionOneObject(CEntity* pEntity) +{ + int16 modeId = pEntity->m_modelIndex; + if (MI_SINGLESTREETLIGHTS1 == modeId || MI_SINGLESTREETLIGHTS2 == modeId || MI_SINGLESTREETLIGHTS3 == modeId + || MI_DOUBLESTREETLIGHTS == modeId || MI_TREE1 == modeId || MI_TREE2 == modeId || MI_TREE3 == modeId + || MI_TREE4 == modeId || MI_TREE5 == modeId || MI_TREE6 == modeId || MI_TREE7 == modeId + || MI_TREE8 == modeId || MI_TREE9 == modeId || MI_TREE10 == modeId || MI_TREE11 == modeId + || MI_TREE12 == modeId || MI_TREE13 == modeId || MI_TREE14 == modeId || MI_TRAFFICLIGHTS == modeId + || MI_PARKINGMETER == modeId || MI_PHONEBOOTH1 == modeId || MI_WASTEBIN == modeId || MI_BIN == modeId + || MI_POSTBOX1 == modeId || MI_NEWSSTAND == modeId || MI_TRAFFICCONE == modeId || MI_DUMP1 == modeId + || MI_ROADWORKBARRIER1 == modeId || MI_BUSSIGN1 == modeId || MI_NOPARKINGSIGN1 == modeId + || MI_PHONESIGN == modeId || MI_TAXISIGN == modeId || MI_FISHSTALL01 == modeId || MI_FISHSTALL02 == modeId + || MI_FISHSTALL03 == modeId || MI_FISHSTALL04 == modeId || MI_BAGELSTAND2 == modeId || MI_FIRE_HYDRANT == modeId + || MI_BOLLARDLIGHT == modeId || MI_PARKTABLE == modeId) { + CVector& position = pEntity->m_matrix.GetPosition(); + float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; + position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ; + pEntity->m_matrix.UpdateRW(); + pEntity->UpdateRwFrame(); + } else if (MI_BUOY == modeId) { + float fWaterLevel = 0.0f; + bool found = true; + const CVector& position = pEntity->m_matrix.GetPosition(); + float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &found); + if (CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) { + if (!found || fWaterLevel > fGroundZ) { + CColModel* pColModel = pEntity->GetColModel(); + float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; + pEntity->m_matrix.GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; + } + } + } +} + void CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason) { @@ -1069,6 +1804,60 @@ CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason) } } +void +CWorld::SetPedsOnFire(float x, float y, float z, float radius, CEntity* reason) +{ + int32 poolSize = CPools::GetPedPool()->GetSize(); + for (int32 i = poolSize - 1; i >= 0; i--) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + if (pPed && pPed->m_nPedState != PED_DEAD && !pPed->bInVehicle && !pPed->m_pFire && !pPed->bFireProof) { + if (Abs(pPed->GetPosition().z - z) < 5.0f && Abs(pPed->GetPosition().x - x) < radius && Abs(pPed->GetPosition().y - y) < radius) + gFireManager.StartFire(pPed, reason, 0.8f, true); + } + } +} + +void +CWorld::RemoveStaticObjects() +{ + for (int32 y = 0; y < NUMSECTORS_Y; y++) { + for (int32 x = 0; x < NUMSECTORS_X; x++) { + CSector* pSector = GetSector(x, y); + CPtrNode* pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; + while (pNode) { + CEntity* pEntity = (CEntity*)pNode->item; + if (pEntity) { + CWorld::Remove(pEntity); + delete pEntity; + } + pNode = pNode->next; + } + pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); + } + } +} + void CWorld::Process(void) { @@ -1246,6 +2035,27 @@ CWorld::Process(void) } } } +/* +void +CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer) +{ + CVector2D vecStartPos(position.x - fRadius, position.y - fRadius); + CVector2D vecEndPos(position.x + fRadius, position.y + fRadius); + const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + for (int32 y = nStartY; y <= nEndY; y++) { + for (int32 x = nStartX; x <= nEndX; x++) { + CSector* pSector = CWorld::GetSector(x, y); + CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, fRadius, fPower, pCreator, bDrecementBombTimer); + CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, fRadius, fPower, pCreator, bDrecementBombTimer); + CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, fRadius, fPower, pCreator, bDrecementBombTimer); + } + } + +} +*/ STARTPATCHES InjectHook(0x4AE930, CWorld::Add, PATCH_JUMP); diff --git a/src/core/World.h b/src/core/World.h index 07e7889f..bcb9ca27 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -85,7 +85,7 @@ public: } } static void ClearScanCodes(void); - static void ClearExcitingStuffFromArea(const CVector &pos, float radius, uint8); + static void ClearExcitingStuffFromArea(const CVector &pos, float radius, bool bRemoveProjectilesAndTidyUpShadows); static bool CameraToIgnoreThisObject(CEntity *ent); @@ -103,19 +103,26 @@ public: static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool); static void FindObjectsInRangeSectorList(CPtrList&, CVector&, float, bool, short*, short, CEntity**); static void FindObjectsInRange(CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool); - static void FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVector&, float, bool, short*, short, CEntity**); - static void FindObjectsOfTypeInRange(uint32, CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool); + static void FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities); + static void FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies); static float FindGroundZForCoord(float x, float y); static float FindGroundZFor3DCoord(float x, float y, float z, bool *found); static float FindRoofZFor3DCoord(float x, float y, float z, bool *found); static void RemoveReferencesToDeletedObject(CEntity*); - static void FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool); - static void FindObjectsIntersectingCube(const CVector &, const CVector &, int16*, int16, CEntity **, bool, bool, bool, bool, bool); + static void FindObjectsKindaColliding(const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies); + static void FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities); + static void FindObjectsIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies); + static void FindObjectsIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities); static void FindObjectsIntersectingAngledCollisionBox(const CColBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool); - static void FindMissionEntitiesIntersectingCube(const CVector&, const CVector&, int16*, int16, CEntity**, bool, bool, bool); - static void ClearCarsFromArea(float, float, float, float, float, float); - static void ClearPedsFromArea(float, float, float, float, float, float); - static void CallOffChaseForArea(float, float, float, float); + static void FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, const CColBox& boundingBox, const CMatrix& matrix, const CVector& position, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities); + static void FindMissionEntitiesIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bVehicles, bool bPeds, bool bObjects); + static void FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bIsVehicleList, bool bIsPedList); + + static void ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2); + static void ClearPedsFromArea(float x1, float y1, float z1, float x2, float y2, float z2); + static void CallOffChaseForArea(float x1, float y1, float x2, float y2); + static void CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY); + static void CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2); static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); } static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); } @@ -131,17 +138,19 @@ public: static void StopAllLawEnforcersInTheirTracks(); static void SetAllCarsCanBeDamaged(bool); static void ExtinguishAllCarFiresInArea(CVector, float); - static void SetCarsOnFire(float, float, float, float, CEntity*); - static void SetPedsOnFire(float, float, float, float, CEntity*); + static void SetCarsOnFire(float x, float y, float z, float radius, CEntity* reason); + static void SetPedsOnFire(float x, float y, float z, float radius, CEntity* reason); static void Initialise(); static void AddParticles(); static void ShutDown(); static void ClearForRestart(void); static void RepositionCertainDynamicObjects(); + static void RepositionOneObject(CEntity* pEntity); static void RemoveStaticObjects(); static void Process(); - static void TriggerExplosion(const CVector &, float, float, CEntity*, bool); + static void TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer); + static void TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer); }; extern CColPoint *gaTempSphereColPoints; -- cgit v1.2.3 From 2c2da558cac7e235d1dc89264aa78695aae32394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 16 Apr 2020 22:19:56 +0300 Subject: Some refs removed, little fixes and teleport --- src/core/MenuScreens.h | 2 +- src/core/Radar.cpp | 8 +++++--- src/core/Radar.h | 5 +++-- src/core/re3.cpp | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index e1b1bac6..8692d4dc 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -32,7 +32,7 @@ const CMenuScreen aScreens[] = { MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, - // MENU_CONTROLLER_SETTINGS = 4 + // MENUPAGE_CONTROLLER_SETTINGS = 4 { "FET_CON", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, MENUACTION_CTRLCONFIG, "FEC_CCF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, MENUACTION_CTRLDISPLAY, "FEC_CDP", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 154e7e9a..ed24814d 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -16,9 +16,9 @@ #include "Streaming.h" #include "SpecialFX.h" -float &CRadar::m_radarRange = *(float*)0x8E281C; -sRadarTrace (&CRadar::ms_RadarTrace)[NUMRADARBLIPS] = *(sRadarTrace(*)[NUMRADARBLIPS]) * (uintptr*)0x6ED5E0; -CVector2D &vec2DRadarOrigin = *(CVector2D*)0x6299B8; +float CRadar::m_radarRange; +sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS]; +CVector2D vec2DRadarOrigin; int32 gRadarTxdIds[64];// = (int*)0x6299C0; CSprite2d CRadar::AsukaSprite;// = *(CSprite2d*)0x8F1A40; @@ -81,6 +81,7 @@ CRGBA CRadar::ArrowBlipColour2; uint16 CRadar::MapLegendCounter; uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS]; int CRadar::TargetMarkerId = -1; +CVector CRadar::TargetMarkerPos; #endif // taken from VC @@ -1442,6 +1443,7 @@ CRadar::ToggleTargetMarker(float x, float y) ms_RadarTrace[nextBlip].m_bInUse = 1; ms_RadarTrace[nextBlip].m_Radius = 1.0f; CVector pos(x, y, CWorld::FindGroundZForCoord(x,y)); + TargetMarkerPos = pos; ms_RadarTrace[nextBlip].m_vec2DPos = pos; ms_RadarTrace[nextBlip].m_vecPos = pos; ms_RadarTrace[nextBlip].m_nEntityHandle = 0; diff --git a/src/core/Radar.h b/src/core/Radar.h index 27f3a6f0..e39a17f0 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -82,8 +82,8 @@ static_assert(sizeof(sRadarTrace) == 0x30, "sRadarTrace: error"); class CRadar { public: - static float &m_radarRange; - static sRadarTrace (&ms_RadarTrace)[NUMRADARBLIPS]; + static float m_radarRange; + static sRadarTrace ms_RadarTrace[NUMRADARBLIPS]; static CSprite2d AsukaSprite; static CSprite2d BombSprite; static CSprite2d CatSprite; @@ -114,6 +114,7 @@ public: static uint16 MapLegendList[NUM_MAP_LEGENDS]; static uint16 MapLegendCounter; static int TargetMarkerId; + static CVector TargetMarkerPos; static void InitFrontEndMap(); static void DrawYouAreHereSprite(float, float); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 5d76d642..ecf02f39 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -24,6 +24,8 @@ #include "Hud.h" #include "SceneEdit.h" #include "Pad.h" +#include "PlayerPed.h" +#include "Radar.h" #include @@ -164,6 +166,19 @@ FixCar(void) ((CAutomobile*)veh)->Fix(); } +#ifdef MENU_MAP +static void +TeleportToWaypoint(void) +{ + if (FindPlayerVehicle()) { + if (CRadar::TargetMarkerId != -1) + FindPlayerVehicle()->Teleport(CRadar::TargetMarkerPos + CVector(0.0f, 0.0f, FindPlayerVehicle()->GetColModel()->boundingSphere.center.z)); + } else + if(CRadar::TargetMarkerId != -1) + FindPlayerPed()->Teleport(CRadar::TargetMarkerPos + CVector(0.0f, 0.0f, FEET_OFFSET)); +} +#endif + static int engineStatus; static void SetEngineStatus(void) @@ -359,6 +374,9 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil); DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil); +#ifdef MENU_MAP + DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); +#endif #ifdef TOGGLEABLE_BETA_FEATURES DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil); DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, nil); -- cgit v1.2.3 From 6b1093f1c8f2a2c59383c2d8f2223b22e2f6cb42 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 17 Apr 2020 03:20:34 +0500 Subject: CWorld complete --- src/core/World.cpp | 147 +++++++++++++++++++++++++++++++++++++++++++++-------- src/core/World.h | 2 +- 2 files changed, 126 insertions(+), 23 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 324be962..131625a5 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -26,6 +26,9 @@ #include "Object.h" #include "Shadows.h" #include "Explosion.h" +#include "Glass.h" +#include "ParticleObject.h" +#include "EventList.h" #define OBJECT_REPOSITION_OFFSET_Z 0.2f @@ -48,26 +51,6 @@ bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B; bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C; bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA; -//WRAPPER void CWorld::ClearForRestart(void) { EAXJMP(0x4AE850); } -//WRAPPER void CWorld::AddParticles(void) { EAXJMP(0x4B4010); } -//WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); } -//WRAPPER void CWorld::RepositionCertainDynamicObjects() { EAXJMP(0x4B42B0); } -//WRAPPER void CWorld::RemoveStaticObjects() { EAXJMP(0x4B4D50); } -//WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); } -//WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); } -//WRAPPER void CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, uint8 unused) { EAXJMP(0x4B4E70) }; -//WRAPPER void CWorld::FindObjectsIntersectingCube(const CVector &, const CVector &, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B2E70); } -//WRAPPER void CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &, const CMatrix &, const CVector &, float, float, float, float, int16*, int16, CEntity **, bool, bool, bool, bool, bool) { EAXJMP(0x4B3280); } -//WRAPPER void CWorld::FindObjectsOfTypeInRange(uint32, CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool) { EAXJMP(0x4B2600); } -//WRAPPER void CWorld::FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVector&, float, bool, short*, short, CEntity**) { EAXJMP(0x4B2960); } -//WRAPPER void CWorld::FindMissionEntitiesIntersectingCube(const CVector&, const CVector&, int16*, int16, CEntity**, bool, bool, bool) { EAXJMP(0x4B3680); } -//WRAPPER void CWorld::ClearCarsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B50E0); } -//WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B52B0); } -//WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); } -WRAPPER void CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity *pCreator, bool bProcessVehicleBombTimer) { EAXJMP(0x4B1140); } -//WRAPPER void CWorld::SetPedsOnFire(float, float, float, float, CEntity*) { EAXJMP(0x4B3D30); } -WRAPPER void CWorld::UseDetonator(CEntity *) { EAXJMP(0x4B4650); } - void CWorld::Initialise() { @@ -2037,7 +2020,6 @@ CWorld::Process(void) } } -/* void CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer) { @@ -2057,7 +2039,128 @@ CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, C } } -*/ + +void +CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer) +{ + CPtrNode* pNode = list.first; + while (pNode) { + CPhysical* pEntity = (CPhysical*)pNode->item; + CVector vecDistance = pEntity->m_matrix.GetPosition() - position; + float fMagnitude = vecDistance.Magnitude(); + if (fRadius > fMagnitude) { + CWeapon::BlowUpExplosiveThings(pEntity); + CPed* pPed = (CPed*)pEntity; + CObject* pObject = (CObject*)pEntity; + CVehicle* pVehicle = (CVehicle*)pEntity; + if (!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { + if (pEntity->bIsStatic) { + if (pEntity->IsObject()) { + if (fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) { + if (IsGlass(pObject->m_modelIndex)) { + CGlass::WindowRespondsToExplosion(pObject, position); + } else { + pObject->bIsStatic = false; + pObject->AddToMovingList(); + int16 modelId = pEntity->m_modelIndex; + if (modelId != MI_FIRE_HYDRANT || pObject->bHasBeenDamaged) { + if (pEntity->IsObject() && modelId != MI_EXPLODINGBARREL && modelId != MI_PETROLPUMP) + pObject->bHasBeenDamaged = true; + } else { + CVector pos = pEntity->m_matrix.GetPosition(); + pos.z -= 0.5f; + CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, pos, true); + pObject->bHasBeenDamaged = true; + } + } + } + if (pEntity->bIsStatic) { + float fDamageMultiplier = (fRadius - fMagnitude) * 2.0f / fRadius; + float fDamage = 300.0f * min(fDamageMultiplier, 1.0f); + pObject->ObjectDamage(fDamage); + } + } else { + pEntity->bIsStatic = false; + pEntity->AddToMovingList(); + } + } + if (!pEntity->bIsStatic) { + float fDamageMultiplier = min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); + CVector vecForceDir = vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / max(fMagnitude, 0.01f)); + vecForceDir.z = max(vecForceDir.z, 0.0f); + if (pEntity == FindPlayerPed()) + vecForceDir.z = min(vecForceDir.z, 1.0f); + pEntity->ApplyMoveForce(vecForceDir); + if (!pEntity->bPedPhysics) { + float fBoundRadius = pEntity->GetBoundRadius(); + float fDistanceZ = position.z - pEntity->m_matrix.GetPosition().z; + float fPointZ = fBoundRadius; + if (max(fDistanceZ, -fBoundRadius) < fBoundRadius) + { + if (fDistanceZ <= -fBoundRadius) + fPointZ = -fBoundRadius; + else + fPointZ = fDistanceZ; + } + pEntity->ApplyTurnForce(vecForceDir.x, vecForceDir.y, vecForceDir.z, 0.0f, 0.0f, fPointZ); + } + switch (pEntity->m_type) + { + case ENTITY_TYPE_VEHICLE: + if (pEntity->m_status == STATUS_SIMPLE) { + pEntity->m_status = STATUS_PHYSICS; + CCarCtrl::SwitchVehicleToRealPhysics(pVehicle); + } + pVehicle->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION, 1100.0f * fDamageMultiplier); + if (bProcessVehicleBombTimer) { + if (pVehicle->m_nBombTimer) + pVehicle->m_nBombTimer /= 10; + } + break; + case ENTITY_TYPE_PED: { + int8 direction = pPed->GetLocalDirection(-vecForceDir); + pPed->bIsStanding = false; + pPed->ApplyMoveForce(0.0, 0.0, 2.0f); + float fDamage = 250.0f * fDamageMultiplier; + pPed->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION, fDamage, PEDPIECE_TORSO, direction); + if (pPed->m_nPedState!= PED_DIE) + pPed->SetFall(2000, (AnimationId)(direction + ANIM_KO_SKID_FRONT), 0); + if (pCreator && pCreator->IsPed()) { + eEventType eventType = EVENT_SHOOT_PED; + if (pPed->m_nPedType == PEDTYPE_COP) + eventType = EVENT_SHOOT_COP; + CEventList::RegisterEvent(eventType, EVENT_ENTITY_PED, pEntity, (CPed*)pCreator, 10000); + pPed->RegisterThreatWithGangPeds(pCreator); + } + break; + } + case ENTITY_TYPE_OBJECT: + pObject->ObjectDamage(300.0f * fDamageMultiplier); + break; + } + } + } + } + pNode = pNode->next; + } +} + +void +CWorld::UseDetonator(CEntity* pEntity) +{ + int32 i = CPools::GetVehiclePool()->GetSize(); + while (--i >= 0) { + CAutomobile* pVehicle = (CAutomobile*)CPools::GetVehiclePool()->GetSlot(i); + if (pVehicle && !pVehicle->m_vehType && pVehicle->m_bombType == CARBOMB_REMOTE && pVehicle->m_pBombRigger == pEntity) { + pVehicle->m_bombType = CARBOMB_NONE; + pVehicle->m_nBombTimer = 500; + pVehicle->m_pBlowUpEntity = pVehicle->m_pBombRigger; + if (pVehicle->m_pBlowUpEntity) + pVehicle->m_pBlowUpEntity->RegisterReference(&pVehicle->m_pBlowUpEntity); + } + } +} + STARTPATCHES InjectHook(0x4AE930, CWorld::Add, PATCH_JUMP); InjectHook(0x4AE9D0, CWorld::Remove, PATCH_JUMP); diff --git a/src/core/World.h b/src/core/World.h index fcf7b7cb..a1e2acfd 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -151,7 +151,7 @@ public: static void Process(); static void TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer); static void TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer); - static void UseDetonator(CEntity *); + static void UseDetonator(CEntity *pEntity); }; extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; -- cgit v1.2.3 From 03247ce98f9f6b9f09861e50c8903ec6221e42fa Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 17 Apr 2020 03:54:22 +0500 Subject: Fix CWorld::RepositionOneObject bugs --- src/core/World.cpp | 61 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 131625a5..a9571c8b 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1743,30 +1743,59 @@ CWorld::RepositionCertainDynamicObjects() void CWorld::RepositionOneObject(CEntity* pEntity) { - int16 modeId = pEntity->m_modelIndex; - if (MI_SINGLESTREETLIGHTS1 == modeId || MI_SINGLESTREETLIGHTS2 == modeId || MI_SINGLESTREETLIGHTS3 == modeId - || MI_DOUBLESTREETLIGHTS == modeId || MI_TREE1 == modeId || MI_TREE2 == modeId || MI_TREE3 == modeId - || MI_TREE4 == modeId || MI_TREE5 == modeId || MI_TREE6 == modeId || MI_TREE7 == modeId - || MI_TREE8 == modeId || MI_TREE9 == modeId || MI_TREE10 == modeId || MI_TREE11 == modeId - || MI_TREE12 == modeId || MI_TREE13 == modeId || MI_TREE14 == modeId || MI_TRAFFICLIGHTS == modeId - || MI_PARKINGMETER == modeId || MI_PHONEBOOTH1 == modeId || MI_WASTEBIN == modeId || MI_BIN == modeId - || MI_POSTBOX1 == modeId || MI_NEWSSTAND == modeId || MI_TRAFFICCONE == modeId || MI_DUMP1 == modeId - || MI_ROADWORKBARRIER1 == modeId || MI_BUSSIGN1 == modeId || MI_NOPARKINGSIGN1 == modeId - || MI_PHONESIGN == modeId || MI_TAXISIGN == modeId || MI_FISHSTALL01 == modeId || MI_FISHSTALL02 == modeId - || MI_FISHSTALL03 == modeId || MI_FISHSTALL04 == modeId || MI_BAGELSTAND2 == modeId || MI_FIRE_HYDRANT == modeId - || MI_BOLLARDLIGHT == modeId || MI_PARKTABLE == modeId) { + int16 modelId = pEntity->m_modelIndex; + if (modelId == MI_SINGLESTREETLIGHTS1 + || modelId == MI_SINGLESTREETLIGHTS2 + || modelId == MI_SINGLESTREETLIGHTS3 + || modelId == MI_DOUBLESTREETLIGHTS + || modelId == MI_TREE1 + || modelId == MI_TREE2 + || modelId == MI_TREE3 + || modelId == MI_TREE4 + || modelId == MI_TREE5 + || modelId == MI_TREE6 + || modelId == MI_TREE7 + || modelId == MI_TREE8 + || modelId == MI_TREE9 + || modelId == MI_TREE10 + || modelId == MI_TREE11 + || modelId == MI_TREE12 + || modelId == MI_TREE13 + || modelId == MI_TREE14 + || modelId == MI_TRAFFICLIGHTS + || modelId == MI_PARKINGMETER + || modelId == MI_PHONEBOOTH1 + || modelId == MI_WASTEBIN + || modelId == MI_BIN + || modelId == MI_POSTBOX1 + || modelId == MI_NEWSSTAND + || modelId == MI_TRAFFICCONE + || modelId == MI_DUMP1 + || modelId == MI_ROADWORKBARRIER1 + || modelId == MI_BUSSIGN1 + || modelId == MI_NOPARKINGSIGN1 + || modelId == MI_PHONESIGN + || modelId == MI_TAXISIGN + || modelId == MI_FISHSTALL01 + || modelId == MI_FISHSTALL02 + || modelId == MI_FISHSTALL03 + || modelId == MI_FISHSTALL04 + || modelId == MI_BAGELSTAND2 + || modelId == MI_FIRE_HYDRANT + || modelId == MI_BOLLARDLIGHT + || modelId == MI_PARKTABLE) { CVector& position = pEntity->m_matrix.GetPosition(); float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ; pEntity->m_matrix.UpdateRW(); pEntity->UpdateRwFrame(); - } else if (MI_BUOY == modeId) { + } else if (modelId == MI_BUOY) { float fWaterLevel = 0.0f; - bool found = true; + bool bFound = true; const CVector& position = pEntity->m_matrix.GetPosition(); - float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &found); + float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); if (CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) { - if (!found || fWaterLevel > fGroundZ) { + if (!bFound || fWaterLevel > fGroundZ) { CColModel* pColModel = pEntity->GetColModel(); float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; pEntity->m_matrix.GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; -- cgit v1.2.3 From e777f240642a6f287d08d7c536e878cae372fdfa Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 17 Apr 2020 05:38:05 +0500 Subject: More CWorld fixes --- src/core/World.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index a9571c8b..02c0e2f6 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -30,7 +30,7 @@ #include "ParticleObject.h" #include "EventList.h" -#define OBJECT_REPOSITION_OFFSET_Z 0.2f +#define OBJECT_REPOSITION_OFFSET_Z 2.0f CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; @@ -738,9 +738,9 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const pEntity->m_scanCode = ms_nCurrentScanCode; float fMagnitude = 0.0f; if (bCheck2DOnly) - fMagnitude = CVector2D(position - pEntity->GetPosition()).Magnitude(); + fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D(); else - fMagnitude = CVector(position - pEntity->GetPosition()).Magnitude(); + fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr(); if (fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) { if (aEntities) aEntities[*nEntitiesFound] = pEntity; @@ -1044,9 +1044,9 @@ CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& posit pEntity->m_scanCode = ms_nCurrentScanCode; float fMagnitude = 0.0f; if (bCheck2DOnly) - fMagnitude = CVector2D(position - pEntity->GetPosition()).Magnitude(); + fMagnitude = (position - pEntity->GetPosition()).Magnitude2D(); else - fMagnitude = CVector(position - pEntity->GetPosition()).Magnitude(); + fMagnitude = (position - pEntity->GetPosition()).Magnitude(); if (pEntity->GetBoundRadius() + radius > fMagnitude && *nCollidingEntities < maxEntitiesToFind) { if (aEntities) aEntities[*nCollidingEntities] = pEntity; @@ -1162,7 +1162,7 @@ CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, cons if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; CColSphere sphere; - CVector vecDistance = pEntity->m_matrix.GetPosition() - position; + CVector vecDistance = pEntity->GetPosition() - position; sphere.radius = pEntity->GetBoundRadius(); sphere.center = Multiply3x3(vecDistance, matrix); if (CCollision::TestSphereBox(sphere, boundingBox) && *nEntitiesFound < maxEntitiesToFind) { @@ -1226,7 +1226,7 @@ CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVec fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z && *nIntersecting < maxEntitiesToFind) { if (aEntities) - aEntities[*nIntersecting] = (CEntity*)pEntity; + aEntities[*nIntersecting] = pEntity; ++*nIntersecting; } } @@ -1402,7 +1402,7 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1 CVehicle *pVehicle = (CVehicle*)pNode->item; if (pVehicle->m_scanCode != CWorld::ms_nCurrentScanCode) { pVehicle->m_scanCode = CWorld::ms_nCurrentScanCode; - const CVector& vehiclePos = pVehicle->m_matrix.GetPosition(); + const CVector& vehiclePos = pVehicle->GetPosition(); eCarMission carMission = pVehicle->AutoPilot.m_nCarMission; if (pVehicle != FindPlayerVehicle() && vehiclePos.x > fStartX && vehiclePos.x < fEndX && @@ -1422,11 +1422,11 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1 // Maybe break the loop when bInsideSphere is set to true? } if (bInsideSphere) { - if (pVehicle->m_matrix.GetPosition().x <= (x1 + x2) * 0.5f) + if (pVehicle->GetPosition().x <= (x1 + x2) * 0.5f) pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f); else pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f); - if (pVehicle->m_matrix.GetPosition().y <= (y1 + y2) * 0.5f) + if (pVehicle->GetPosition().y <= (y1 + y2) * 0.5f) pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f); else pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f); @@ -1573,8 +1573,8 @@ CWorld::AddParticles(void) for (int32 y = 0; y < NUMSECTORS_Y; y++) { for (int32 x = 0; x < NUMSECTORS_X; x++) { CSector* pSector = GetSector(x, y); - CEntity::AddSteamsFromGround1(pSector->m_lists[ENTITYLIST_BUILDINGS]); - CEntity::AddSteamsFromGround1(pSector->m_lists[ENTITYLIST_DUMMIES]); + CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]); + CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]); } } } @@ -1605,7 +1605,7 @@ CWorld::ShutDown(void) } pNode = pSector->m_lists[ENTITYLIST_PEDS].first; while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; + CEntity *pEntity = (CEntity*)pNode->item; if (pEntity) { CWorld::Remove(pEntity); delete pEntity; @@ -1614,7 +1614,7 @@ CWorld::ShutDown(void) } pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; + CEntity *pEntity = (CEntity*)pNode->item; if (pEntity) { CWorld::Remove(pEntity); delete pEntity; @@ -1623,7 +1623,7 @@ CWorld::ShutDown(void) } pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; + CEntity *pEntity = (CEntity*)pNode->item; if (pEntity) { CWorld::Remove(pEntity); delete pEntity; @@ -1637,9 +1637,9 @@ CWorld::ShutDown(void) } } for (int32 i = 0; i < 4; i ++) { - CPtrNode* pNode = GetBigBuildingList((eLevelName)i).first; + CPtrNode *pNode = GetBigBuildingList((eLevelName)i).first; while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; + CEntity *pEntity = (CEntity*)pNode->item; if (pEntity) { // Maybe remove from world here? delete pEntity; @@ -1650,7 +1650,7 @@ CWorld::ShutDown(void) } for (int32 y = 0; y < NUMSECTORS_Y; y++) { for (int32 x = 0; x < NUMSECTORS_X; x++) { - CSector* pSector = GetSector(x, y); + CSector *pSector = GetSector(x, y); if (pSector->m_lists[ENTITYLIST_BUILDINGS].first) { sprintf(gString, "Building list %d,%d not empty\n", x, y); pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); @@ -1784,7 +1784,7 @@ CWorld::RepositionOneObject(CEntity* pEntity) || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || modelId == MI_PARKTABLE) { - CVector& position = pEntity->m_matrix.GetPosition(); + CVector& position = pEntity->GetPosition(); float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ; pEntity->m_matrix.UpdateRW(); @@ -1792,13 +1792,13 @@ CWorld::RepositionOneObject(CEntity* pEntity) } else if (modelId == MI_BUOY) { float fWaterLevel = 0.0f; bool bFound = true; - const CVector& position = pEntity->m_matrix.GetPosition(); + const CVector& position = pEntity->GetPosition(); float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); if (CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) { if (!bFound || fWaterLevel > fGroundZ) { CColModel* pColModel = pEntity->GetColModel(); float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; - pEntity->m_matrix.GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; + pEntity->GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; } } } @@ -2075,7 +2075,7 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa CPtrNode* pNode = list.first; while (pNode) { CPhysical* pEntity = (CPhysical*)pNode->item; - CVector vecDistance = pEntity->m_matrix.GetPosition() - position; + CVector vecDistance = pEntity->GetPosition() - position; float fMagnitude = vecDistance.Magnitude(); if (fRadius > fMagnitude) { CWeapon::BlowUpExplosiveThings(pEntity); @@ -2096,7 +2096,7 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa if (pEntity->IsObject() && modelId != MI_EXPLODINGBARREL && modelId != MI_PETROLPUMP) pObject->bHasBeenDamaged = true; } else { - CVector pos = pEntity->m_matrix.GetPosition(); + CVector pos = pEntity->GetPosition(); pos.z -= 0.5f; CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, pos, true); pObject->bHasBeenDamaged = true; @@ -2122,7 +2122,7 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa pEntity->ApplyMoveForce(vecForceDir); if (!pEntity->bPedPhysics) { float fBoundRadius = pEntity->GetBoundRadius(); - float fDistanceZ = position.z - pEntity->m_matrix.GetPosition().z; + float fDistanceZ = position.z - pEntity->GetPosition().z; float fPointZ = fBoundRadius; if (max(fDistanceZ, -fBoundRadius) < fBoundRadius) { -- cgit v1.2.3 From 425395ad2547e262c5c6f62b4c3fd95dd79ee679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 17 Apr 2020 07:01:54 +0300 Subject: Ped fixes and ref removal --- src/core/re3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index ecf02f39..2046a7f9 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -350,6 +350,9 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil); DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, nil); +#ifdef MENU_MAP + DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); +#endif DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Fix Car", FixCar); @@ -374,9 +377,6 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil); DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil); -#ifdef MENU_MAP - DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); -#endif #ifdef TOGGLEABLE_BETA_FEATURES DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil); DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, nil); -- cgit v1.2.3 From a4922d5cb77e31657768d5da4b286a2e67ee0e6f Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Fri, 17 Apr 2020 08:54:14 +0300 Subject: rem refs --- src/core/Accident.cpp | 2 +- src/core/Accident.h | 2 +- src/core/Cam.cpp | 2 +- src/core/Camera.cpp | 6 +-- src/core/Camera.h | 6 +-- src/core/Clock.cpp | 20 ++++---- src/core/Clock.h | 18 +++---- src/core/ControllerConfig.cpp | 2 +- src/core/ControllerConfig.h | 2 +- src/core/EventList.cpp | 1 - src/core/FileMgr.cpp | 4 +- src/core/FileMgr.h | 4 +- src/core/Fire.cpp | 2 +- src/core/Fire.h | 2 +- src/core/Frontend.cpp | 2 +- src/core/Game.cpp | 22 +++++---- src/core/Game.h | 16 +++---- src/core/IniFile.cpp | 4 +- src/core/Pad.cpp | 24 +++++----- src/core/Pad.h | 22 ++++----- src/core/Pools.cpp | 18 +++---- src/core/Pools.h | 18 +++---- src/core/Radar.cpp | 44 +++++++++--------- src/core/References.cpp | 4 +- src/core/References.h | 4 +- src/core/Stats.cpp | 106 +++++++++++++++++++++--------------------- src/core/Stats.h | 106 +++++++++++++++++++++--------------------- src/core/Streaming.cpp | 84 ++++++++++++++++----------------- src/core/Streaming.h | 56 +++++++++++----------- src/core/SurfaceTable.cpp | 2 +- src/core/SurfaceTable.h | 3 +- src/core/TempColModels.cpp | 26 +++++------ src/core/TempColModels.h | 26 +++++------ src/core/TimeStep.cpp | 6 +-- src/core/TimeStep.h | 6 +-- src/core/Timer.cpp | 50 +++++++++----------- src/core/Timer.h | 20 ++++---- src/core/User.cpp | 8 ++-- src/core/User.h | 8 ++-- src/core/Wanted.cpp | 4 +- src/core/Wanted.h | 4 +- src/core/ZoneCull.cpp | 30 ++++++------ src/core/ZoneCull.h | 28 +++++------ src/core/Zones.cpp | 24 +++++----- src/core/Zones.h | 22 ++++----- src/core/config.h | 1 + src/core/main.cpp | 17 +++---- src/core/main.h | 16 +++---- 48 files changed, 446 insertions(+), 458 deletions(-) (limited to 'src/core') diff --git a/src/core/Accident.cpp b/src/core/Accident.cpp index d8313ddc..3c39b11d 100644 --- a/src/core/Accident.cpp +++ b/src/core/Accident.cpp @@ -6,7 +6,7 @@ #include "Pools.h" #include "World.h" -CAccidentManager& gAccidentManager = *(CAccidentManager*)0x87FD10; +CAccidentManager gAccidentManager; CAccident* CAccidentManager::GetNextFreeAccident() diff --git a/src/core/Accident.h b/src/core/Accident.h index 69889645..949d5fb9 100644 --- a/src/core/Accident.h +++ b/src/core/Accident.h @@ -29,4 +29,4 @@ public: bool WorkToDoForMedics(); }; -extern CAccidentManager& gAccidentManager; \ No newline at end of file +extern CAccidentManager gAccidentManager; \ No newline at end of file diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index cfdea46a..4d954ccd 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -28,7 +28,7 @@ const float DefaultFOV = 70.0f; // beta: 80.0f bool PrintDebugCode = false; -int16 &DebugCamMode = *(int16*)0x95CCF2; +int16 DebugCamMode; #ifdef FREE_CAM bool CCamera::bFreeCam = false; diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index c2392d3b..a1f36d93 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -58,9 +58,9 @@ enum #define PLAYER (CWorld::Players[CWorld::PlayerInFocus].m_pPed) // NB: removed explicit TheCamera from all functions -CCamera &TheCamera = *(CCamera*)0x6FACF8; -bool &CCamera::m_bUseMouse3rdPerson = *(bool *)0x5F03D8; -bool &bDidWeProcessAnyCinemaCam = *(bool*)0x95CD46; +CCamera TheCamera; +bool CCamera::m_bUseMouse3rdPerson = true; +bool bDidWeProcessAnyCinemaCam; #ifdef IMPROVED_CAMERA #define KEYJUSTDOWN(k) ControlsManager.GetIsKeyboardKeyJustDown((RsKeyCodes)k) diff --git a/src/core/Camera.h b/src/core/Camera.h index 09a8d603..d1c8ec03 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -6,7 +6,7 @@ class CPed; class CAutomobile; class CGarage; -extern int16 &DebugCamMode; +extern int16 DebugCamMode; enum { @@ -540,7 +540,7 @@ uint32 unknown; // some counter having to do with music uint32 m_uiFadeTimeStarted; uint32 m_uiFadeTimeStartedMusic; - static bool &m_bUseMouse3rdPerson; + static bool m_bUseMouse3rdPerson; #ifdef FREE_CAM static bool bFreeCam; #endif @@ -647,7 +647,7 @@ static_assert(offsetof(CCamera, m_vecCutSceneOffset) == 0x6F8, "CCamera: error") static_assert(offsetof(CCamera, m_arrPathArray) == 0x7a8, "CCamera: error"); static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size"); -extern CCamera &TheCamera; +extern CCamera TheCamera; void CamShakeNoPos(CCamera*, float); void MakeAngleLessThan180(float &Angle); diff --git a/src/core/Clock.cpp b/src/core/Clock.cpp index a97dcb5f..69fdd682 100644 --- a/src/core/Clock.cpp +++ b/src/core/Clock.cpp @@ -6,17 +6,17 @@ #include "Stats.h" _TODO("gbFastTime"); -bool &gbFastTime = *(bool*)0x95CDBB; +bool gbFastTime; -uint8 &CClock::ms_nGameClockHours = *(uint8*)0x95CDA6; -uint8 &CClock::ms_nGameClockMinutes = *(uint8*)0x95CDC8; -uint16 &CClock::ms_nGameClockSeconds = *(uint16*)0x95CC7C; -uint8 &CClock::ms_Stored_nGameClockHours = *(uint8*)0x95CD7B; -uint8 &CClock::ms_Stored_nGameClockMinutes = *(uint8*)0x95CD9B; -uint16 &CClock::ms_Stored_nGameClockSeconds = *(uint16*)0x95CC9C; -uint32 &CClock::ms_nMillisecondsPerGameMinute = *(uint32*)0x8F2C64; -uint32 &CClock::ms_nLastClockTick = *(uint32*)0x9430E4; -bool &CClock::ms_bClockHasBeenStored = *(bool*)0x95CD82; +uint8 CClock::ms_nGameClockHours; +uint8 CClock::ms_nGameClockMinutes; +uint16 CClock::ms_nGameClockSeconds; +uint8 CClock::ms_Stored_nGameClockHours; +uint8 CClock::ms_Stored_nGameClockMinutes; +uint16 CClock::ms_Stored_nGameClockSeconds; +uint32 CClock::ms_nMillisecondsPerGameMinute; +uint32 CClock::ms_nLastClockTick; +bool CClock::ms_bClockHasBeenStored; void CClock::Initialise(uint32 scale) diff --git a/src/core/Clock.h b/src/core/Clock.h index 6b9908ba..a611cd50 100644 --- a/src/core/Clock.h +++ b/src/core/Clock.h @@ -3,15 +3,15 @@ class CClock { public: - static uint8 &ms_nGameClockHours; - static uint8 &ms_nGameClockMinutes; - static uint16 &ms_nGameClockSeconds; - static uint8 &ms_Stored_nGameClockHours; - static uint8 &ms_Stored_nGameClockMinutes; - static uint16 &ms_Stored_nGameClockSeconds; - static uint32 &ms_nMillisecondsPerGameMinute; - static uint32 &ms_nLastClockTick; - static bool &ms_bClockHasBeenStored; + static uint8 ms_nGameClockHours; + static uint8 ms_nGameClockMinutes; + static uint16 ms_nGameClockSeconds; + static uint8 ms_Stored_nGameClockHours; + static uint8 ms_Stored_nGameClockMinutes; + static uint16 ms_Stored_nGameClockSeconds; + static uint32 ms_nMillisecondsPerGameMinute; + static uint32 ms_nLastClockTick; + static bool ms_bClockHasBeenStored; static void Initialise(uint32 scale); static void Update(void); diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 541257c6..ce8674d7 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -18,7 +18,7 @@ #include "win.h" #include "GenericGameStorage.h" -CControllerConfigManager &ControlsManager = *(CControllerConfigManager*)0x8F43A4; +CControllerConfigManager ControlsManager; CControllerConfigManager::CControllerConfigManager() { diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 458e457c..c328594e 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -198,4 +198,4 @@ public: VALIDATE_SIZE(CControllerConfigManager, 0x143C); -extern CControllerConfigManager &ControlsManager; \ No newline at end of file +extern CControllerConfigManager ControlsManager; \ No newline at end of file diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp index d1c76f33..5ca4cdb0 100644 --- a/src/core/EventList.cpp +++ b/src/core/EventList.cpp @@ -11,7 +11,6 @@ int32 CEventList::ms_nFirstFreeSlotIndex; CEvent gaEvent[NUMEVENTS]; -//CEvent *gaEvent = (CEvent*)0x6EF830; enum { diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 2a8628b0..382316bb 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -168,8 +168,8 @@ myfeof(int fd) } -char *CFileMgr::ms_rootDirName = (char*)0x5F18F8; -char *CFileMgr::ms_dirName = (char*)0x713CA8; +char CFileMgr::ms_rootDirName[128] = {'\0'}; +char CFileMgr::ms_dirName[128]; void CFileMgr::Initialise(void) diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h index 3df0c7d8..a6e4b6e5 100644 --- a/src/core/FileMgr.h +++ b/src/core/FileMgr.h @@ -2,8 +2,8 @@ class CFileMgr { - static char *ms_rootDirName; //[128]; - static char *ms_dirName; //[128]; + static char ms_rootDirName[128]; + static char ms_dirName[128]; public: static void Initialise(void); static void ChangeDir(const char *dir); diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index cfa849e9..f900091e 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -16,7 +16,7 @@ #include "Ped.h" #include "Fire.h" -CFireManager &gFireManager = *(CFireManager*)0x8F31D0; +CFireManager gFireManager; CFire::CFire() { diff --git a/src/core/Fire.h b/src/core/Fire.h index a4599d11..85e53f61 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -48,4 +48,4 @@ public: void RemoveScriptFire(int16 index); void SetScriptFireAudio(int16 index, bool state); }; -extern CFireManager &gFireManager; +extern CFireManager gFireManager; diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index a01689e4..b2ecdac5 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -93,7 +93,7 @@ int8 CMenuManager::m_PrefsSpeakers; int32 CMenuManager::m_ControlMethod; int8 CMenuManager::m_PrefsDMA = 1; int32 CMenuManager::m_PrefsLanguage; -uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings +uint8 CMenuManager::m_PrefsStereoMono; // unused except restore settings bool CMenuManager::m_PrefsAllowNastyGame = true; bool CMenuManager::m_bStartUpFrontEndRequested; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8699ffeb..f115d52f 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -89,19 +89,19 @@ -eLevelName &CGame::currLevel = *(eLevelName*)0x941514; -bool &CGame::bDemoMode = *(bool*)0x5F4DD0; -bool &CGame::nastyGame = *(bool*)0x5F4DD4; -bool &CGame::frenchGame = *(bool*)0x95CDCB; -bool &CGame::germanGame = *(bool*)0x95CD1E; -bool &CGame::noProstitutes = *(bool*)0x95CDCF; -bool &CGame::playingIntro = *(bool*)0x95CDC2; -char *CGame::aDatFile = (char*)0x773A48; +eLevelName CGame::currLevel; +bool CGame::bDemoMode = true; +bool CGame::nastyGame = true; +bool CGame::frenchGame; +bool CGame::germanGame; +bool CGame::noProstitutes; +bool CGame::playingIntro; +char CGame::aDatFile[32]; #ifdef MORE_LANGUAGES bool CGame::russianGame = false; #endif -int &gameTxdSlot = *(int*)0x628D88; +int gameTxdSlot; bool CGame::InitialiseOnceBeforeRW(void) @@ -115,7 +115,9 @@ CGame::InitialiseOnceBeforeRW(void) bool CGame::InitialiseRenderWare(void) { +#ifdef USE_TEXTURE_POOL _TexturePoolsInitialise(); +#endif CTxdStore::Initialise(); CVisibilityPlugins::Initialise(); @@ -188,7 +190,9 @@ void CGame::ShutdownRenderWare(void) CVisibilityPlugins::Shutdown(); +#ifdef USE_TEXTURE_POOL _TexturePoolsShutdown(); +#endif } bool CGame::InitialiseOnceAfterRW(void) diff --git a/src/core/Game.h b/src/core/Game.h index 30581893..8dc73e8a 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -11,17 +11,17 @@ enum eLevelName class CGame { public: - static eLevelName &currLevel; - static bool &bDemoMode; - static bool &nastyGame; - static bool &frenchGame; - static bool &germanGame; + static eLevelName currLevel; + static bool bDemoMode; + static bool nastyGame; + static bool frenchGame; + static bool germanGame; #ifdef MORE_LANGUAGES static bool russianGame; #endif - static bool &noProstitutes; - static bool &playingIntro; - static char *aDatFile; //[32]; + static bool noProstitutes; + static bool playingIntro; + static char aDatFile[32]; static bool InitialiseOnceBeforeRW(void); static bool InitialiseRenderWare(void); diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index 744f4bd0..d8e91c98 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -7,8 +7,8 @@ #include "main.h" #include "Population.h" -float CIniFile::PedNumberMultiplier = 1.0f;// = *(float*)0x6182F4; -float CIniFile::CarNumberMultiplier = 1.0f;// = *(float*)0x6182F8; +float CIniFile::PedNumberMultiplier = 1.0f; +float CIniFile::CarNumberMultiplier = 1.0f; void CIniFile::LoadIniFile() { diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 201dc5b6..2db375b2 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -35,26 +35,26 @@ #include "Wanted.h" #include "General.h" -CPad *Pads = (CPad*)0x6F0360; // [2] -CMousePointerStateHelper &MousePointerStateHelper = *(CMousePointerStateHelper*)0x95CC8C; +CPad Pads[MAX_PADS]; +CMousePointerStateHelper MousePointerStateHelper; -bool &CPad::bDisplayNoControllerMessage = *(bool *)0x95CD52; -bool &CPad::bObsoleteControllerMessage = *(bool *)0x95CDB8; +bool CPad::bDisplayNoControllerMessage; +bool CPad::bObsoleteControllerMessage; bool CPad::bOldDisplayNoControllerMessage; -bool &CPad::m_bMapPadOneToPadTwo = *(bool *)0x95CD48; +bool CPad::m_bMapPadOneToPadTwo; -CKeyboardState &CPad::OldKeyState = *(CKeyboardState*)0x6F1E70; -CKeyboardState &CPad::NewKeyState = *(CKeyboardState*)0x6E60D0; -CKeyboardState &CPad::TempKeyState = *(CKeyboardState*)0x774DE8; +CKeyboardState CPad::OldKeyState; +CKeyboardState CPad::NewKeyState; +CKeyboardState CPad::TempKeyState; char CPad::KeyBoardCheatString[20]; -CMouseControllerState &CPad::OldMouseControllerState = *(CMouseControllerState*)0x8472A0; -CMouseControllerState &CPad::NewMouseControllerState = *(CMouseControllerState*)0x8809F0; -CMouseControllerState &CPad::PCTempMouseControllerState = *(CMouseControllerState*)0x6F1E60; +CMouseControllerState CPad::OldMouseControllerState; +CMouseControllerState CPad::NewMouseControllerState; +CMouseControllerState CPad::PCTempMouseControllerState; _TODO("gbFastTime"); -extern bool &gbFastTime; +extern bool gbFastTime; void WeaponCheat() { diff --git a/src/core/Pad.h b/src/core/Pad.h index cb705c6b..9ebd6396 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -66,7 +66,7 @@ public: VALIDATE_SIZE(CMousePointerStateHelper, 0x2); -extern CMousePointerStateHelper &MousePointerStateHelper; +extern CMousePointerStateHelper MousePointerStateHelper; class CKeyboardState @@ -163,18 +163,18 @@ public: CPad() { } ~CPad() { } - static bool &bDisplayNoControllerMessage; - static bool &bObsoleteControllerMessage; + static bool bDisplayNoControllerMessage; + static bool bObsoleteControllerMessage; static bool bOldDisplayNoControllerMessage; - static bool &m_bMapPadOneToPadTwo; + static bool m_bMapPadOneToPadTwo; - static CKeyboardState &OldKeyState; - static CKeyboardState &NewKeyState; - static CKeyboardState &TempKeyState; + static CKeyboardState OldKeyState; + static CKeyboardState NewKeyState; + static CKeyboardState TempKeyState; static char KeyBoardCheatString[20]; - static CMouseControllerState &OldMouseControllerState; - static CMouseControllerState &NewMouseControllerState; - static CMouseControllerState &PCTempMouseControllerState; + static CMouseControllerState OldMouseControllerState; + static CMouseControllerState NewMouseControllerState; + static CMouseControllerState PCTempMouseControllerState; #ifdef GTA_PS2_STUFF @@ -450,4 +450,4 @@ public: }; VALIDATE_SIZE(CPad, 0xFC); -extern CPad *Pads; //[2] +extern CPad Pads[MAX_PADS]; diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index 6add9e0c..65294368 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -10,15 +10,15 @@ #include "Wanted.h" #include "World.h" -CCPtrNodePool *&CPools::ms_pPtrNodePool = *(CCPtrNodePool**)0x943044; -CEntryInfoNodePool *&CPools::ms_pEntryInfoNodePool = *(CEntryInfoNodePool**)0x941448; -CPedPool *&CPools::ms_pPedPool = *(CPedPool**)0x8F2C60; -CVehiclePool *&CPools::ms_pVehiclePool = *(CVehiclePool**)0x9430DC; -CBuildingPool *&CPools::ms_pBuildingPool = *(CBuildingPool**)0x8F2C04; -CTreadablePool *&CPools::ms_pTreadablePool = *(CTreadablePool**)0x8F2568; -CObjectPool *&CPools::ms_pObjectPool = *(CObjectPool**)0x880E28; -CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18; -CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C; +CCPtrNodePool *CPools::ms_pPtrNodePool; +CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool; +CPedPool *CPools::ms_pPedPool; +CVehiclePool *CPools::ms_pVehiclePool; +CBuildingPool *CPools::ms_pBuildingPool; +CTreadablePool *CPools::ms_pTreadablePool; +CObjectPool *CPools::ms_pObjectPool; +CDummyPool *CPools::ms_pDummyPool; +CAudioScriptObjectPool *CPools::ms_pAudioScriptObjectPool; void CPools::Initialise(void) diff --git a/src/core/Pools.h b/src/core/Pools.h index 74b87585..b0ba6598 100644 --- a/src/core/Pools.h +++ b/src/core/Pools.h @@ -22,15 +22,15 @@ typedef CPool CAudioScriptObjectPool; class CPools { - static CCPtrNodePool *&ms_pPtrNodePool; - static CEntryInfoNodePool *&ms_pEntryInfoNodePool; - static CPedPool *&ms_pPedPool; - static CVehiclePool *&ms_pVehiclePool; - static CBuildingPool *&ms_pBuildingPool; - static CTreadablePool *&ms_pTreadablePool; - static CObjectPool *&ms_pObjectPool; - static CDummyPool *&ms_pDummyPool; - static CAudioScriptObjectPool *&ms_pAudioScriptObjectPool; + static CCPtrNodePool *ms_pPtrNodePool; + static CEntryInfoNodePool *ms_pEntryInfoNodePool; + static CPedPool *ms_pPedPool; + static CVehiclePool *ms_pVehiclePool; + static CBuildingPool *ms_pBuildingPool; + static CTreadablePool *ms_pTreadablePool; + static CObjectPool *ms_pObjectPool; + static CDummyPool *ms_pDummyPool; + static CAudioScriptObjectPool *ms_pAudioScriptObjectPool; public: static CCPtrNodePool *GetPtrNodePool(void) { return ms_pPtrNodePool; } static CEntryInfoNodePool *GetEntryInfoNodePool(void) { return ms_pEntryInfoNodePool; } diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index ed24814d..48b97832 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -19,28 +19,28 @@ float CRadar::m_radarRange; sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS]; CVector2D vec2DRadarOrigin; -int32 gRadarTxdIds[64];// = (int*)0x6299C0; - -CSprite2d CRadar::AsukaSprite;// = *(CSprite2d*)0x8F1A40; -CSprite2d CRadar::BombSprite;// = (CSprite2d*)0x8F5FB4; -CSprite2d CRadar::CatSprite;// = (CSprite2d*)0x885B24; -CSprite2d CRadar::CentreSprite;// = (CSprite2d*)0x8F6268; -CSprite2d CRadar::CopcarSprite;// = (CSprite2d*)0x8F1A2C; -CSprite2d CRadar::DonSprite;// = (CSprite2d*)0x8F2BE0; -CSprite2d CRadar::EightSprite;// = (CSprite2d*)0x8F2BCC; -CSprite2d CRadar::ElSprite;// = (CSprite2d*)0x8F1B80; -CSprite2d CRadar::IceSprite;// = (CSprite2d*)0x9415FC; -CSprite2d CRadar::JoeySprite;// = (CSprite2d*)0x8F2C00; -CSprite2d CRadar::KenjiSprite;// = (CSprite2d*)0x8F2C68; -CSprite2d CRadar::LizSprite;// = (CSprite2d*)0x8F5830; -CSprite2d CRadar::LuigiSprite;// = (CSprite2d*)0x8F1A3C; -CSprite2d CRadar::NorthSprite;// = (CSprite2d*)0x8F6274; -CSprite2d CRadar::RaySprite;// = (CSprite2d*)0x8E2A7C; -CSprite2d CRadar::SalSprite;// = (CSprite2d*)0x8F29EC; -CSprite2d CRadar::SaveSprite;// = (CSprite2d*)0x8F5F74; -CSprite2d CRadar::SpraySprite;// = (CSprite2d*)0x94307C; -CSprite2d CRadar::TonySprite;// = (CSprite2d*)0x885B58; -CSprite2d CRadar::WeaponSprite;// = (CSprite2d*)0x941534; +int32 gRadarTxdIds[64]; + +CSprite2d CRadar::AsukaSprite; +CSprite2d CRadar::BombSprite; +CSprite2d CRadar::CatSprite; +CSprite2d CRadar::CentreSprite; +CSprite2d CRadar::CopcarSprite; +CSprite2d CRadar::DonSprite; +CSprite2d CRadar::EightSprite; +CSprite2d CRadar::ElSprite; +CSprite2d CRadar::IceSprite; +CSprite2d CRadar::JoeySprite; +CSprite2d CRadar::KenjiSprite; +CSprite2d CRadar::LizSprite; +CSprite2d CRadar::LuigiSprite; +CSprite2d CRadar::NorthSprite; +CSprite2d CRadar::RaySprite; +CSprite2d CRadar::SalSprite; +CSprite2d CRadar::SaveSprite; +CSprite2d CRadar::SpraySprite; +CSprite2d CRadar::TonySprite; +CSprite2d CRadar::WeaponSprite; CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = { nil, diff --git a/src/core/References.cpp b/src/core/References.cpp index e87f0fd5..668ea9f1 100644 --- a/src/core/References.cpp +++ b/src/core/References.cpp @@ -6,8 +6,8 @@ #include "Pools.h" #include "References.h" -CReference *CReferences::aRefs = (CReference*)0x70BBE0; //[NUMREFERENCES]; -CReference *&CReferences::pEmptyList = *(CReference**)0x8F1AF8; +CReference CReferences::aRefs[NUMREFERENCES]; +CReference *CReferences::pEmptyList; void CReferences::Init(void) diff --git a/src/core/References.h b/src/core/References.h index 6476e243..e7a64de7 100644 --- a/src/core/References.h +++ b/src/core/References.h @@ -11,8 +11,8 @@ struct CReference class CReferences { public: - static CReference *aRefs; //[NUMREFERENCES]; - static CReference *&pEmptyList; + static CReference aRefs[NUMREFERENCES]; + static CReference *pEmptyList; static void Init(void); static void RemoveReferencesToPlayer(void); diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index 02092a30..8d7a3048 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -4,59 +4,59 @@ #include "Text.h" #include "World.h" -int32 &CStats::DaysPassed = *(int32*)0x8F2BB8; -int32 &CStats::HeadsPopped = *(int32*)0x8F647C; -int32& CStats::CommercialPassed = *(int32*)0x8F4334; -int32& CStats::IndustrialPassed = *(int32*)0x8E2A68; -int32& CStats::SuburbanPassed = *(int32*)0x8F2740; -int32 &CStats::NumberKillFrenziesPassed = *(int32*)0x8E287C; -int32 &CStats::PeopleKilledByOthers = *(int32*)0x8E2C50; -int32 &CStats::HelisDestroyed = *(int32*)0x8E2A64; -int32(&CStats::PedsKilledOfThisType)[NUM_PEDTYPES] = *(int32(*)[NUM_PEDTYPES]) * (uintptr*)0x880DBC; -int32 &CStats::TimesDied = *(int32*)0x8E2BDC; -int32 &CStats::TimesArrested = *(int32*)0x8E2BEC; -int32 &CStats::KillsSinceLastCheckpoint = *(int32*)0x8F2C8C; -int32& CStats::DistanceTravelledInVehicle = *(int32*)0x940574; -int32& CStats::DistanceTravelledOnFoot = *(int32*)0x941518; -int32 &CStats::ProgressMade = *(int32*)0x8F6224; -int32 &CStats::TotalProgressInGame = *(int32*)0x885B2C; -int32& CStats::CarsExploded = *(int32*)0x941288; -int32& CStats::PeopleKilledByPlayer = *(int32*)0x8F1B7C; -float &CStats::MaximumJumpDistance = *(float*)0x8F2BDC; -float &CStats::MaximumJumpHeight = *(float*)0x940564; -int32 &CStats::MaximumJumpFlips = *(int32*)0x8F2524; -int32 &CStats::MaximumJumpSpins = *(int32*)0x8F29B0; -int32 &CStats::BestStuntJump = *(int32*)0x885B50; -int32 &CStats::NumberOfUniqueJumpsFound = *(int32*)0x885B74; -int32 &CStats::TotalNumberOfUniqueJumps = *(int32*)0x8E2DC0; -int32 &CStats::PassengersDroppedOffWithTaxi = *(int32*)0x940724; -int32 &CStats::MoneyMadeWithTaxi = *(int32*)0x941544; -int32 &CStats::MissionsGiven = *(int32*)0x9430E8; -int32 &CStats::MissionsPassed = *(int32*)0x940768; -char(&CStats::LastMissionPassedName)[8] = *(char(*)[8])*(uintptr*)0x70D828; -int32 &CStats::TotalLegitimateKills = *(int32*)0x8F6004; -int32 &CStats::ElBurroTime = *(int32*)0x8E2A6C; -int32& CStats::Record4x4One = *(int32*)0x940570; -int32& CStats::Record4x4Two = *(int32*)0x94058C; -int32& CStats::Record4x4Three = *(int32*)0x880FA8; -int32& CStats::Record4x4Mayhem = *(int32*)0x885B70; -int32& CStats::LivesSavedWithAmbulance = *(int32*)0x8F57E0; -int32& CStats::CriminalsCaught = *(int32*)0x8F2518; -int32& CStats::HighestLevelAmbulanceMission = *(int32*)0x8F2A04; -int32& CStats::FiresExtinguished = *(int32*)0x8F5FEC; -int32& CStats::LongestFlightInDodo = *(int32*)0x8F5FE4; -int32& CStats::TimeTakenDefuseMission = *(int32*)0x880E24; -int32& CStats::TotalNumberKillFrenzies = *(int32*)0x8E2884; -int32& CStats::TotalNumberMissions = *(int32*)0x8E2820; -int32& CStats::RoundsFiredByPlayer = *(int32*)0x8E2BE8; -int32& CStats::KgsOfExplosivesUsed = *(int32*)0x8F2510; -int32& CStats::InstantHitsFiredByPlayer = *(int32*)0x943070; -int32& CStats::InstantHitsHitByPlayer = *(int32*)0x95CB8C; -int32& CStats::BestTimeBombDefusal = *(int32*)0x880E24; -int32& CStats::mmRain = *(int32*)0x8F2C98; -int32& CStats::CarsCrushed = *(int32*)0x943050; -int32(&CStats::FastestTimes)[CStats::TOTAL_FASTEST_TIMES] = *(int32(*)[CStats::TOTAL_FASTEST_TIMES])*(uintptr*)0x6E9128; -int32(&CStats::HighestScores)[CStats::TOTAL_HIGHEST_SCORES] = *(int32(*)[CStats::TOTAL_HIGHEST_SCORES]) * (uintptr*)0x8622B0; +int32 CStats::DaysPassed; +int32 CStats::HeadsPopped; +int32 CStats::CommercialPassed; +int32 CStats::IndustrialPassed; +int32 CStats::SuburbanPassed; +int32 CStats::NumberKillFrenziesPassed; +int32 CStats::PeopleKilledByOthers; +int32 CStats::HelisDestroyed; +int32 CStats::PedsKilledOfThisType[NUM_PEDTYPES]; +int32 CStats::TimesDied; +int32 CStats::TimesArrested; +int32 CStats::KillsSinceLastCheckpoint; +int32 CStats::DistanceTravelledInVehicle; +int32 CStats::DistanceTravelledOnFoot; +int32 CStats::ProgressMade; +int32 CStats::TotalProgressInGame; +int32 CStats::CarsExploded; +int32 CStats::PeopleKilledByPlayer; +float CStats::MaximumJumpDistance; +float CStats::MaximumJumpHeight; +int32 CStats::MaximumJumpFlips; +int32 CStats::MaximumJumpSpins; +int32 CStats::BestStuntJump; +int32 CStats::NumberOfUniqueJumpsFound; +int32 CStats::TotalNumberOfUniqueJumps; +int32 CStats::PassengersDroppedOffWithTaxi; +int32 CStats::MoneyMadeWithTaxi; +int32 CStats::MissionsGiven; +int32 CStats::MissionsPassed; +char CStats::LastMissionPassedName[8]; +int32 CStats::TotalLegitimateKills; +int32 CStats::ElBurroTime; +int32 CStats::Record4x4One; +int32 CStats::Record4x4Two; +int32 CStats::Record4x4Three; +int32 CStats::Record4x4Mayhem; +int32 CStats::LivesSavedWithAmbulance; +int32 CStats::CriminalsCaught; +int32 CStats::HighestLevelAmbulanceMission; +int32 CStats::FiresExtinguished; +int32 CStats::LongestFlightInDodo; +int32 CStats::TimeTakenDefuseMission; +int32 CStats::TotalNumberKillFrenzies; +int32 CStats::TotalNumberMissions; +int32 CStats::RoundsFiredByPlayer; +int32 CStats::KgsOfExplosivesUsed; +int32 CStats::InstantHitsFiredByPlayer; +int32 CStats::InstantHitsHitByPlayer; +int32 CStats::BestTimeBombDefusal; +int32 CStats::mmRain; +int32 CStats::CarsCrushed; +int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES]; +int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES]; void CStats::Init() { diff --git a/src/core/Stats.h b/src/core/Stats.h index ac3259f9..4445ecf4 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -9,59 +9,59 @@ public: TOTAL_FASTEST_TIMES = 16, TOTAL_HIGHEST_SCORES = 16 }; - static int32 &DaysPassed; - static int32 &HeadsPopped; - static int32& CommercialPassed; - static int32& IndustrialPassed; - static int32& SuburbanPassed; - static int32 &NumberKillFrenziesPassed; - static int32 &PeopleKilledByOthers; - static int32 &HelisDestroyed; - static int32(&PedsKilledOfThisType)[ePedType::NUM_PEDTYPES]; - static int32 &TimesDied; - static int32 &TimesArrested; - static int32 &KillsSinceLastCheckpoint; - static int32 &DistanceTravelledInVehicle; - static int32 &DistanceTravelledOnFoot; - static int32 &CarsExploded; - static int32 &PeopleKilledByPlayer; - static int32 &ProgressMade; - static int32 &TotalProgressInGame; - static float &MaximumJumpDistance; - static float &MaximumJumpHeight; - static int32 &MaximumJumpFlips; - static int32 &MaximumJumpSpins; - static int32 &BestStuntJump; - static int32 &NumberOfUniqueJumpsFound; - static int32 &TotalNumberOfUniqueJumps; - static int32 &PassengersDroppedOffWithTaxi; - static int32 &MoneyMadeWithTaxi; - static int32 &MissionsGiven; - static int32 &MissionsPassed; - static char (&LastMissionPassedName)[8]; - static int32 &TotalLegitimateKills; - static int32 &ElBurroTime; - static int32 &Record4x4One; - static int32 &Record4x4Two; - static int32 &Record4x4Three; - static int32 &Record4x4Mayhem; - static int32 &LivesSavedWithAmbulance; - static int32 &CriminalsCaught; - static int32 &HighestLevelAmbulanceMission; - static int32 &FiresExtinguished; - static int32 &LongestFlightInDodo; - static int32 &TimeTakenDefuseMission; - static int32 &TotalNumberKillFrenzies; - static int32 &TotalNumberMissions; - static int32 &RoundsFiredByPlayer; - static int32 &KgsOfExplosivesUsed; - static int32 &InstantHitsFiredByPlayer; - static int32 &InstantHitsHitByPlayer; - static int32 &BestTimeBombDefusal; - static int32 &mmRain; - static int32 &CarsCrushed; - static int32(&FastestTimes)[TOTAL_FASTEST_TIMES]; - static int32(&HighestScores)[TOTAL_HIGHEST_SCORES]; + static int32 DaysPassed; + static int32 HeadsPopped; + static int32 CommercialPassed; + static int32 IndustrialPassed; + static int32 SuburbanPassed; + static int32 NumberKillFrenziesPassed; + static int32 PeopleKilledByOthers; + static int32 HelisDestroyed; + static int32 PedsKilledOfThisType[ePedType::NUM_PEDTYPES]; + static int32 TimesDied; + static int32 TimesArrested; + static int32 KillsSinceLastCheckpoint; + static int32 DistanceTravelledInVehicle; + static int32 DistanceTravelledOnFoot; + static int32 CarsExploded; + static int32 PeopleKilledByPlayer; + static int32 ProgressMade; + static int32 TotalProgressInGame; + static float MaximumJumpDistance; + static float MaximumJumpHeight; + static int32 MaximumJumpFlips; + static int32 MaximumJumpSpins; + static int32 BestStuntJump; + static int32 NumberOfUniqueJumpsFound; + static int32 TotalNumberOfUniqueJumps; + static int32 PassengersDroppedOffWithTaxi; + static int32 MoneyMadeWithTaxi; + static int32 MissionsGiven; + static int32 MissionsPassed; + static char LastMissionPassedName[8]; + static int32 TotalLegitimateKills; + static int32 ElBurroTime; + static int32 Record4x4One; + static int32 Record4x4Two; + static int32 Record4x4Three; + static int32 Record4x4Mayhem; + static int32 LivesSavedWithAmbulance; + static int32 CriminalsCaught; + static int32 HighestLevelAmbulanceMission; + static int32 FiresExtinguished; + static int32 LongestFlightInDodo; + static int32 TimeTakenDefuseMission; + static int32 TotalNumberKillFrenzies; + static int32 TotalNumberMissions; + static int32 RoundsFiredByPlayer; + static int32 KgsOfExplosivesUsed; + static int32 InstantHitsFiredByPlayer; + static int32 InstantHitsHitByPlayer; + static int32 BestTimeBombDefusal; + static int32 mmRain; + static int32 CarsCrushed; + static int32 FastestTimes[TOTAL_FASTEST_TIMES]; + static int32 HighestScores[TOTAL_HIGHEST_SCORES]; public: static void Init(void); diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index d00edf51..56f4a862 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -30,49 +30,49 @@ #include "Streaming.h" #include "main.h" -bool &CStreaming::ms_disableStreaming = *(bool*)0x95CD6E; -bool &CStreaming::ms_bLoadingBigModel = *(bool*)0x95CDB0; -int32 &CStreaming::ms_numModelsRequested = *(int32*)0x8E2C10; -CStreamingInfo *CStreaming::ms_aInfoForModel = (CStreamingInfo*)0x6C7088; -CStreamingInfo &CStreaming::ms_startLoadedList = *(CStreamingInfo*)0x942F60; -CStreamingInfo &CStreaming::ms_endLoadedList = *(CStreamingInfo*)0x8F1AC0; -CStreamingInfo &CStreaming::ms_startRequestedList = *(CStreamingInfo*)0x8F1B3C; -CStreamingInfo &CStreaming::ms_endRequestedList = *(CStreamingInfo*)0x940738; -int32 &CStreaming::ms_oldSectorX = *(int32*)0x8F2C84; -int32 &CStreaming::ms_oldSectorY = *(int32*)0x8F2C88; -int32 &CStreaming::ms_streamingBufferSize = *(int32*)0x942FB0; -int8 **CStreaming::ms_pStreamingBuffer = (int8**)0x87F818; -int32 &CStreaming::ms_memoryUsed = *(int32*)0x940568; -CStreamingChannel *CStreaming::ms_channel = (CStreamingChannel*)0x727EE0; -int32 &CStreaming::ms_channelError = *(int32*)0x880DB8; -int32 &CStreaming::ms_numVehiclesLoaded = *(int32*)0x8F2C80; -int32 *CStreaming::ms_vehiclesLoaded = (int32*)0x773560; -int32 &CStreaming::ms_lastVehicleDeleted = *(int32*)0x95CBF8; -CDirectory *&CStreaming::ms_pExtraObjectsDir = *(CDirectory**)0x95CB90; -int32 &CStreaming::ms_numPriorityRequests = *(int32*)0x8F31C4; -bool &CStreaming::ms_hasLoadedLODs = *(bool*)0x95CD47; -int32 &CStreaming::ms_currentPedGrp = *(int32*)0x8F2BBC; +bool CStreaming::ms_disableStreaming; +bool CStreaming::ms_bLoadingBigModel; +int32 CStreaming::ms_numModelsRequested; +CStreamingInfo CStreaming::ms_aInfoForModel[NUMSTREAMINFO]; +CStreamingInfo CStreaming::ms_startLoadedList; +CStreamingInfo CStreaming::ms_endLoadedList; +CStreamingInfo CStreaming::ms_startRequestedList; +CStreamingInfo CStreaming::ms_endRequestedList; +int32 CStreaming::ms_oldSectorX; +int32 CStreaming::ms_oldSectorY; +int32 CStreaming::ms_streamingBufferSize; +int8 *CStreaming::ms_pStreamingBuffer[2]; +int32 CStreaming::ms_memoryUsed; +CStreamingChannel CStreaming::ms_channel[2]; +int32 CStreaming::ms_channelError; +int32 CStreaming::ms_numVehiclesLoaded; +int32 CStreaming::ms_vehiclesLoaded[MAXVEHICLESLOADED]; +int32 CStreaming::ms_lastVehicleDeleted; +CDirectory *CStreaming::ms_pExtraObjectsDir; +int32 CStreaming::ms_numPriorityRequests; +bool CStreaming::ms_hasLoadedLODs; +int32 CStreaming::ms_currentPedGrp; int32 CStreaming::ms_currentPedLoading; int32 CStreaming::ms_lastCullZone; -uint16 &CStreaming::ms_loadedGangs = *(uint16*)0x95CC60; -uint16 &CStreaming::ms_loadedGangCars = *(uint16*)0x95CC2E; -int32 *CStreaming::ms_imageOffsets = (int32*)0x6E60A0; -int32 &CStreaming::ms_lastImageRead = *(int32*)0x880E2C; -int32 &CStreaming::ms_imageSize = *(int32*)0x8F1A34; -uint32 &CStreaming::ms_memoryAvailable = *(uint32*)0x880F8C; - -int32 &desiredNumVehiclesLoaded = *(int32*)0x5EC194; - -CEntity *&pIslandLODindustEntity = *(CEntity**)0x6212DC; -CEntity *&pIslandLODcomIndEntity = *(CEntity**)0x6212E0; -CEntity *&pIslandLODcomSubEntity = *(CEntity**)0x6212E4; -CEntity *&pIslandLODsubIndEntity = *(CEntity**)0x6212E8; -CEntity *&pIslandLODsubComEntity = *(CEntity**)0x6212EC; -int32 &islandLODindust = *(int32*)0x6212C8; -int32 &islandLODcomInd = *(int32*)0x6212CC; -int32 &islandLODcomSub = *(int32*)0x6212D0; -int32 &islandLODsubInd = *(int32*)0x6212D4; -int32 &islandLODsubCom = *(int32*)0x6212D8; +uint16 CStreaming::ms_loadedGangs; +uint16 CStreaming::ms_loadedGangCars; +int32 CStreaming::ms_imageOffsets[NUMCDIMAGES]; +int32 CStreaming::ms_lastImageRead; +int32 CStreaming::ms_imageSize; +uint32 CStreaming::ms_memoryAvailable; + +int32 desiredNumVehiclesLoaded = 12; + +CEntity *pIslandLODindustEntity; +CEntity *pIslandLODcomIndEntity; +CEntity *pIslandLODcomSubEntity; +CEntity *pIslandLODsubIndEntity; +CEntity *pIslandLODsubComEntity; +int32 islandLODindust; +int32 islandLODcomInd; +int32 islandLODcomSub; +int32 islandLODsubInd; +int32 islandLODsubCom; bool CStreamingInfo::GetCdPosnAndSize(uint32 &posn, uint32 &size) @@ -199,7 +199,7 @@ CStreaming::Init(void) // PC only, figure out how much memory we got #ifdef GTA_PC #define MB (1024*1024) - extern unsigned long &_dwMemAvailPhys; + extern unsigned long _dwMemAvailPhys; ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2; if(ms_memoryAvailable < 50*MB) ms_memoryAvailable = 50*MB; diff --git a/src/core/Streaming.h b/src/core/Streaming.h index 1100fd1b..c910c068 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -77,36 +77,36 @@ class CPtrList; class CStreaming { public: - static bool &ms_disableStreaming; - static bool &ms_bLoadingBigModel; - static int32 &ms_numModelsRequested; - static CStreamingInfo *ms_aInfoForModel; //[NUMSTREAMINFO] - static CStreamingInfo &ms_startLoadedList; - static CStreamingInfo &ms_endLoadedList; - static CStreamingInfo &ms_startRequestedList; - static CStreamingInfo &ms_endRequestedList; - static int32 &ms_oldSectorX; - static int32 &ms_oldSectorY; - static int32 &ms_streamingBufferSize; - static int8 **ms_pStreamingBuffer; //[2] - static int32 &ms_memoryUsed; - static CStreamingChannel *ms_channel; //[2] - static int32 &ms_channelError; - static int32 &ms_numVehiclesLoaded; - static int32 *ms_vehiclesLoaded; //[MAXVEHICLESLOADED] - static int32 &ms_lastVehicleDeleted; - static CDirectory *&ms_pExtraObjectsDir; - static int32 &ms_numPriorityRequests; - static bool &ms_hasLoadedLODs; - static int32 &ms_currentPedGrp; + static bool ms_disableStreaming; + static bool ms_bLoadingBigModel; + static int32 ms_numModelsRequested; + static CStreamingInfo ms_aInfoForModel[NUMSTREAMINFO]; + static CStreamingInfo ms_startLoadedList; + static CStreamingInfo ms_endLoadedList; + static CStreamingInfo ms_startRequestedList; + static CStreamingInfo ms_endRequestedList; + static int32 ms_oldSectorX; + static int32 ms_oldSectorY; + static int32 ms_streamingBufferSize; + static int8 *ms_pStreamingBuffer[2]; + static int32 ms_memoryUsed; + static CStreamingChannel ms_channel[2]; + static int32 ms_channelError; + static int32 ms_numVehiclesLoaded; + static int32 ms_vehiclesLoaded[MAXVEHICLESLOADED]; + static int32 ms_lastVehicleDeleted; + static CDirectory *ms_pExtraObjectsDir; + static int32 ms_numPriorityRequests; + static bool ms_hasLoadedLODs; + static int32 ms_currentPedGrp; static int32 ms_lastCullZone; - static uint16 &ms_loadedGangs; - static uint16 &ms_loadedGangCars; + static uint16 ms_loadedGangs; + static uint16 ms_loadedGangCars; static int32 ms_currentPedLoading; - static int32 *ms_imageOffsets; //[NUMCDIMAGES] - static int32 &ms_lastImageRead; - static int32 &ms_imageSize; - static uint32 &ms_memoryAvailable; + static int32 ms_imageOffsets[NUMCDIMAGES]; + static int32 ms_lastImageRead; + static int32 ms_imageSize; + static uint32 ms_memoryAvailable; static void Init(void); static void Shutdown(void); diff --git a/src/core/SurfaceTable.cpp b/src/core/SurfaceTable.cpp index 2ba884b1..85572fbd 100644 --- a/src/core/SurfaceTable.cpp +++ b/src/core/SurfaceTable.cpp @@ -6,7 +6,7 @@ #include "Collision.h" #include "SurfaceTable.h" -float (*CSurfaceTable::ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS] = (float (*)[NUMADHESIVEGROUPS])0x8E29D4; +float CSurfaceTable::ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; void CSurfaceTable::Initialise(char *filename) diff --git a/src/core/SurfaceTable.h b/src/core/SurfaceTable.h index 27f4ecca..4af6a265 100644 --- a/src/core/SurfaceTable.h +++ b/src/core/SurfaceTable.h @@ -98,8 +98,7 @@ struct CColPoint; class CSurfaceTable { -// static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; - static float (*ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS]; + static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; public: static void Initialise(char *filename); static int GetAdhesionGroup(uint8 surfaceType); diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp index 22ef31bd..05b272ab 100644 --- a/src/core/TempColModels.cpp +++ b/src/core/TempColModels.cpp @@ -3,19 +3,19 @@ #include "TempColModels.h" #include "SurfaceTable.h" -CColModel &CTempColModels::ms_colModelPed1 = *(CColModel*)0x726CB0; -CColModel &CTempColModels::ms_colModelPed2 = *(CColModel*)0x726D08; -CColModel &CTempColModels::ms_colModelBBox = *(CColModel*)0x727FE0; -CColModel &CTempColModels::ms_colModelBumper1 = *(CColModel*)0x86BE88; -CColModel &CTempColModels::ms_colModelWheel1 = *(CColModel*)0x878C40; -CColModel &CTempColModels::ms_colModelPanel1 = *(CColModel*)0x87BDD8; -CColModel &CTempColModels::ms_colModelBodyPart2 = *(CColModel*)0x87BE30; -CColModel &CTempColModels::ms_colModelBodyPart1 = *(CColModel*)0x87BE88; -CColModel (&CTempColModels::ms_colModelCutObj)[5] = *(CColModel(*)[5]) *(uintptr*)0x87C960; -CColModel &CTempColModels::ms_colModelPedGroundHit = *(CColModel*)0x880480; -CColModel &CTempColModels::ms_colModelBoot1 = *(CColModel*)0x880670; -CColModel &CTempColModels::ms_colModelDoor1 = *(CColModel*)0x880850; -CColModel &CTempColModels::ms_colModelBonnet1 = *(CColModel*)0x8808A8; +CColModel CTempColModels::ms_colModelPed1; +CColModel CTempColModels::ms_colModelPed2; +CColModel CTempColModels::ms_colModelBBox; +CColModel CTempColModels::ms_colModelBumper1; +CColModel CTempColModels::ms_colModelWheel1; +CColModel CTempColModels::ms_colModelPanel1; +CColModel CTempColModels::ms_colModelBodyPart2; +CColModel CTempColModels::ms_colModelBodyPart1; +CColModel CTempColModels::ms_colModelCutObj[5]; +CColModel CTempColModels::ms_colModelPedGroundHit; +CColModel CTempColModels::ms_colModelBoot1; +CColModel CTempColModels::ms_colModelDoor1; +CColModel CTempColModels::ms_colModelBonnet1; CColSphere s_aPedSpheres[3]; diff --git a/src/core/TempColModels.h b/src/core/TempColModels.h index 263904d3..3e1dd5e1 100644 --- a/src/core/TempColModels.h +++ b/src/core/TempColModels.h @@ -5,19 +5,19 @@ class CTempColModels { public: - static CColModel &ms_colModelPed1; - static CColModel &ms_colModelPed2; - static CColModel &ms_colModelBBox; - static CColModel &ms_colModelBumper1; - static CColModel &ms_colModelWheel1; - static CColModel &ms_colModelPanel1; - static CColModel &ms_colModelBodyPart2; - static CColModel &ms_colModelBodyPart1; - static CColModel (&ms_colModelCutObj)[5]; - static CColModel &ms_colModelPedGroundHit; - static CColModel &ms_colModelBoot1; - static CColModel &ms_colModelDoor1; - static CColModel &ms_colModelBonnet1; + static CColModel ms_colModelPed1; + static CColModel ms_colModelPed2; + static CColModel ms_colModelBBox; + static CColModel ms_colModelBumper1; + static CColModel ms_colModelWheel1; + static CColModel ms_colModelPanel1; + static CColModel ms_colModelBodyPart2; + static CColModel ms_colModelBodyPart1; + static CColModel ms_colModelCutObj[5]; + static CColModel ms_colModelPedGroundHit; + static CColModel ms_colModelBoot1; + static CColModel ms_colModelDoor1; + static CColModel ms_colModelBonnet1; static void Initialise(void); }; diff --git a/src/core/TimeStep.cpp b/src/core/TimeStep.cpp index 9ccf7200..09dae911 100644 --- a/src/core/TimeStep.cpp +++ b/src/core/TimeStep.cpp @@ -1,5 +1,5 @@ #include "TimeStep.h" -float &CTimeStep::ms_fTimeScale = *(float*)0x5F76C8; -float &CTimeStep::ms_fFramesPerUpdate = *(float*)0x5F76CC; -float &CTimeStep::ms_fTimeStep = *(float*)0x5F76D0; +float CTimeStep::ms_fTimeScale = 1.0f; +float CTimeStep::ms_fFramesPerUpdate = 1.0f; +float CTimeStep::ms_fTimeStep = 1.0f; diff --git a/src/core/TimeStep.h b/src/core/TimeStep.h index c74df02a..6101b4c2 100644 --- a/src/core/TimeStep.h +++ b/src/core/TimeStep.h @@ -4,7 +4,7 @@ class CTimeStep { public: - static float &ms_fTimeScale; - static float &ms_fFramesPerUpdate; - static float &ms_fTimeStep; + static float ms_fTimeScale; + static float ms_fFramesPerUpdate; + static float ms_fTimeStep; }; diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index fda862f1..68b31e6f 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -5,34 +5,28 @@ #include "Record.h" #include "Timer.h" -uint32 &CTimer::m_snTimeInMilliseconds = *(uint32*)0x885B48; -uint32 &CTimer::m_snTimeInMillisecondsPauseMode = *(uint32*)0x5F7614; -uint32 &CTimer::m_snTimeInMillisecondsNonClipped = *(uint32*)0x9412E8; -uint32 &CTimer::m_snPreviousTimeInMilliseconds = *(uint32*)0x8F29E4; -uint32 &CTimer::m_FrameCounter = *(uint32*)0x9412EC; -float &CTimer::ms_fTimeScale = *(float*)0x8F2C20; -float &CTimer::ms_fTimeStep = *(float*)0x8E2CB4; -float &CTimer::ms_fTimeStepNonClipped = *(float*)0x8E2C4C; -bool &CTimer::m_UserPause = *(bool*)0x95CD7C; -bool &CTimer::m_CodePause = *(bool*)0x95CDB1; - -//UInt32 oldPcTimer; -uint32 &oldPcTimer = *(uint32*)0x9434F4; - -//UInt32 suspendPcTimer; -uint32 &suspendPcTimer = *(uint32*)0x62A308; - -//UInt32 _nCyclesPerMS = 1; -uint32 &_nCyclesPerMS = *(uint32*)0x5F7610; - -//LARGE_INTEGER _oldPerfCounter; -LARGE_INTEGER &_oldPerfCounter = *(LARGE_INTEGER*)0x62A310; - -//LARGE_INTEGER perfSuspendCounter; -LARGE_INTEGER &perfSuspendCounter = *(LARGE_INTEGER*)0x62A318; - -//UInt32 suspendDepth; -uint32 &suspendDepth = *(uint32*)0x62A320; +uint32 CTimer::m_snTimeInMilliseconds; +uint32 CTimer::m_snTimeInMillisecondsPauseMode = 1; +uint32 CTimer::m_snTimeInMillisecondsNonClipped; +uint32 CTimer::m_snPreviousTimeInMilliseconds; +uint32 CTimer::m_FrameCounter; +float CTimer::ms_fTimeScale; +float CTimer::ms_fTimeStep; +float CTimer::ms_fTimeStepNonClipped; +bool CTimer::m_UserPause; +bool CTimer::m_CodePause; + +uint32 oldPcTimer; + +uint32 suspendPcTimer; + +uint32 _nCyclesPerMS = 1; + +LARGE_INTEGER _oldPerfCounter; + +LARGE_INTEGER perfSuspendCounter; + +uint32 suspendDepth; #ifdef FIX_BUGS double frameTime; diff --git a/src/core/Timer.h b/src/core/Timer.h index a4d674da..00a11409 100644 --- a/src/core/Timer.h +++ b/src/core/Timer.h @@ -3,17 +3,17 @@ class CTimer { - static uint32 &m_snTimeInMilliseconds; - static uint32 &m_snTimeInMillisecondsPauseMode; - static uint32 &m_snTimeInMillisecondsNonClipped; - static uint32 &m_snPreviousTimeInMilliseconds; - static uint32 &m_FrameCounter; - static float &ms_fTimeScale; - static float &ms_fTimeStep; - static float &ms_fTimeStepNonClipped; + static uint32 m_snTimeInMilliseconds; + static uint32 m_snTimeInMillisecondsPauseMode; + static uint32 m_snTimeInMillisecondsNonClipped; + static uint32 m_snPreviousTimeInMilliseconds; + static uint32 m_FrameCounter; + static float ms_fTimeScale; + static float ms_fTimeStep; + static float ms_fTimeStepNonClipped; public: - static bool &m_UserPause; - static bool &m_CodePause; + static bool m_UserPause; + static bool m_CodePause; static const float &GetTimeStep(void) { return ms_fTimeStep; } static void SetTimeStep(float ts) { ms_fTimeStep = ts; } diff --git a/src/core/User.cpp b/src/core/User.cpp index d89d1cec..a1a69b2d 100644 --- a/src/core/User.cpp +++ b/src/core/User.cpp @@ -9,10 +9,10 @@ #include "World.h" #include "Zones.h" -CPlaceName& CUserDisplay::PlaceName = *(CPlaceName*)0x8F29BC; -COnscreenTimer& CUserDisplay::OnscnTimer = *(COnscreenTimer*)0x862238; -CPager& CUserDisplay::Pager = *(CPager*)0x8F2744; -CCurrentVehicle& CUserDisplay::CurrentVehicle = *(CCurrentVehicle*)0x8F5FE8; +CPlaceName CUserDisplay::PlaceName; +COnscreenTimer CUserDisplay::OnscnTimer; +CPager CUserDisplay::Pager; +CCurrentVehicle CUserDisplay::CurrentVehicle; CPlaceName::CPlaceName() { diff --git a/src/core/User.h b/src/core/User.h index 02d5f613..153ef57b 100644 --- a/src/core/User.h +++ b/src/core/User.h @@ -31,10 +31,10 @@ public: class CUserDisplay { public: - static CPlaceName &PlaceName; - static COnscreenTimer &OnscnTimer; - static CPager &Pager; - static CCurrentVehicle &CurrentVehicle; + static CPlaceName PlaceName; + static COnscreenTimer OnscnTimer; + static CPager Pager; + static CCurrentVehicle CurrentVehicle; static void Init(); static void Process(); diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index 29294a2b..1911ae59 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -11,8 +11,8 @@ #include "Wanted.h" #include "General.h" -int32 &CWanted::MaximumWantedLevel = *(int32*)0x5F7714; // 6 -int32 &CWanted::nMaximumWantedLevel = *(int32*)0x5F7718; // 6400 +int32 CWanted::MaximumWantedLevel = 6; +int32 CWanted::nMaximumWantedLevel = 6400; void CWanted::Initialise() diff --git a/src/core/Wanted.h b/src/core/Wanted.h index 9823529c..afeec8b0 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -60,8 +60,8 @@ public: CCrimeBeingQd m_aCrimes[16]; CCopPed *m_pCops[10]; - static int32 &MaximumWantedLevel; - static int32 &nMaximumWantedLevel; + static int32 MaximumWantedLevel; + static int32 nMaximumWantedLevel; public: void Initialise(); diff --git a/src/core/ZoneCull.cpp b/src/core/ZoneCull.cpp index 4a2bea4f..4cdd283e 100644 --- a/src/core/ZoneCull.cpp +++ b/src/core/ZoneCull.cpp @@ -11,21 +11,21 @@ #include "ZoneCull.h" #include "Zones.h" -int32 &CCullZones::NumCullZones = *(int*)0x8F2564; -CCullZone(&CCullZones::aZones)[NUMCULLZONES] = *(CCullZone(*)[NUMCULLZONES])*(uintptr*)0x864750; -int32 &CCullZones::NumAttributeZones = *(int*)0x8E29D0; -CAttributeZone (&CCullZones::aAttributeZones)[NUMATTRIBZONES] = *(CAttributeZone(*)[NUMATTRIBZONES])*(uintptr*)0x709C60; -uint16 (&CCullZones::aIndices)[NUMZONEINDICES] = *(uint16(*)[NUMZONEINDICES])*(uintptr*)0x847330; -int16 (&CCullZones::aPointersToBigBuildingsForBuildings)[NUMBUILDINGS] = *(int16(*)[NUMBUILDINGS])*(uintptr*)0x86C9D0; -int16 (&CCullZones::aPointersToBigBuildingsForTreadables)[NUMTREADABLES] = *(int16(*)[NUMTREADABLES])*(uintptr*)0x8F1B8C; - -int32 &CCullZones::CurrentWantedLevelDrop_Player = *(int32*)0x880DA8; -int32 &CCullZones::CurrentFlags_Camera = *(int32*)0x940718; -int32 &CCullZones::CurrentFlags_Player = *(int32*)0x9415F0; -int32 &CCullZones::OldCullZone = *(int32*)0x8E2C90; -int32 &CCullZones::EntityIndicesUsed = *(int32*)0x8F2508; -bool &CCullZones::bCurrentSubwayIsInvisible = *(bool*)0x95CDA5; -bool &CCullZones::bCullZonesDisabled = *(bool*)0x95CD4A; +int32 CCullZones::NumCullZones; +CCullZone CCullZones::aZones[NUMCULLZONES]; +int32 CCullZones::NumAttributeZones; +CAttributeZone CCullZones::aAttributeZones[NUMATTRIBZONES]; +uint16 CCullZones::aIndices[NUMZONEINDICES]; +int16 CCullZones::aPointersToBigBuildingsForBuildings[NUMBUILDINGS]; +int16 CCullZones::aPointersToBigBuildingsForTreadables[NUMTREADABLES]; + +int32 CCullZones::CurrentWantedLevelDrop_Player; +int32 CCullZones::CurrentFlags_Camera; +int32 CCullZones::CurrentFlags_Player; +int32 CCullZones::OldCullZone; +int32 CCullZones::EntityIndicesUsed; +bool CCullZones::bCurrentSubwayIsInvisible; +bool CCullZones::bCullZonesDisabled; void diff --git a/src/core/ZoneCull.h b/src/core/ZoneCull.h index edaa7c4b..9bc07b8c 100644 --- a/src/core/ZoneCull.h +++ b/src/core/ZoneCull.h @@ -79,21 +79,21 @@ struct CAttributeZone class CCullZones { public: - static int32 &NumCullZones; - static CCullZone (&aZones)[NUMCULLZONES]; - static int32 &NumAttributeZones; - static CAttributeZone(&aAttributeZones)[NUMATTRIBZONES]; - static uint16 (&aIndices)[NUMZONEINDICES]; - static int16 (&aPointersToBigBuildingsForBuildings)[NUMBUILDINGS]; - static int16 (&aPointersToBigBuildingsForTreadables)[NUMTREADABLES]; + static int32 NumCullZones; + static CCullZone aZones[NUMCULLZONES]; + static int32 NumAttributeZones; + static CAttributeZone aAttributeZones[NUMATTRIBZONES]; + static uint16 aIndices[NUMZONEINDICES]; + static int16 aPointersToBigBuildingsForBuildings[NUMBUILDINGS]; + static int16 aPointersToBigBuildingsForTreadables[NUMTREADABLES]; - static int32 &CurrentWantedLevelDrop_Player; - static int32 &CurrentFlags_Camera; - static int32 &CurrentFlags_Player; - static int32 &OldCullZone; - static int32 &EntityIndicesUsed; - static bool &bCurrentSubwayIsInvisible; - static bool &bCullZonesDisabled; + static int32 CurrentWantedLevelDrop_Player; + static int32 CurrentFlags_Camera; + static int32 CurrentFlags_Player; + static int32 OldCullZone; + static int32 EntityIndicesUsed; + static bool bCurrentSubwayIsInvisible; + static bool bCullZonesDisabled; static void Init(void); static void ResolveVisibilities(void); diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 4bce3e79..39d4c3b5 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -8,18 +8,18 @@ #include "Text.h" #include "World.h" -eLevelName &CTheZones::m_CurrLevel = *(eLevelName*)0x8F2BC8; -CZone *&CTheZones::m_pPlayersZone = *(CZone**)0x8F254C; -int16 &CTheZones::FindIndex = *(int16*)0x95CC40; - -uint16 &CTheZones::NumberOfAudioZones = *(uint16*)0x95CC84; -int16 *CTheZones::AudioZoneArray = (int16*)0x713BC0; -uint16 &CTheZones::TotalNumberOfMapZones = *(uint16*)0x95CC74; -uint16 &CTheZones::TotalNumberOfZones = *(uint16*)0x95CC36; -CZone *CTheZones::ZoneArray = (CZone*)0x86BEE0; -CZone *CTheZones::MapZoneArray = (CZone*)0x663EC0; -uint16 &CTheZones::TotalNumberOfZoneInfos = *(uint16*)0x95CC3C; -CZoneInfo *CTheZones::ZoneInfoArray = (CZoneInfo*)0x714400; +eLevelName CTheZones::m_CurrLevel; +CZone *CTheZones::m_pPlayersZone; +int16 CTheZones::FindIndex; + +uint16 CTheZones::NumberOfAudioZones; +int16 CTheZones::AudioZoneArray[NUMAUDIOZONES]; +uint16 CTheZones::TotalNumberOfMapZones; +uint16 CTheZones::TotalNumberOfZones; +CZone CTheZones::ZoneArray[NUMZONES]; +CZone CTheZones::MapZoneArray[NUMMAPZONES]; +uint16 CTheZones::TotalNumberOfZoneInfos; +CZoneInfo CTheZones::ZoneInfoArray[2*NUMZONES]; #define SWAPF(a, b) { float t; t = a; a = b; b = t; } diff --git a/src/core/Zones.h b/src/core/Zones.h index 76855e8b..bb1585dc 100644 --- a/src/core/Zones.h +++ b/src/core/Zones.h @@ -52,18 +52,18 @@ public: class CTheZones { public: - static eLevelName &m_CurrLevel; - static CZone *&m_pPlayersZone; - static int16 &FindIndex; + static eLevelName m_CurrLevel; + static CZone *m_pPlayersZone; + static int16 FindIndex; - static uint16 &NumberOfAudioZones; - static int16 *AudioZoneArray; //[NUMAUDIOZONES]; - static uint16 &TotalNumberOfMapZones; - static uint16 &TotalNumberOfZones; - static CZone *ZoneArray; //[NUMZONES]; - static CZone *MapZoneArray; //[NUMMAPZONES]; - static uint16 &TotalNumberOfZoneInfos; - static CZoneInfo *ZoneInfoArray; //[2*NUMZONES]; + static uint16 NumberOfAudioZones; + static int16 AudioZoneArray[NUMAUDIOZONES]; + static uint16 TotalNumberOfMapZones; + static uint16 TotalNumberOfZones; + static CZone ZoneArray[NUMZONES]; + static CZone MapZoneArray[NUMMAPZONES]; + static uint16 TotalNumberOfZoneInfos; + static CZoneInfo ZoneInfoArray[2*NUMZONES]; static void Init(void); static void Update(void); diff --git a/src/core/config.h b/src/core/config.h index f9edb74a..ba684092 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -192,6 +192,7 @@ enum Config { #define MORE_LANGUAGES // Add more translations to the game #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) //#define USE_TXD_CDIMAGE // generate and load textures from txd.img +//#define USE_TEXTURE_POOL // Pad #define XINPUT diff --git a/src/core/main.cpp b/src/core/main.cpp index 08463df9..1b46d453 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -60,23 +60,18 @@ #include "GenericGameStorage.h" #include "SceneEdit.h" -GlobalScene &Scene = *(GlobalScene*)0x726768; +GlobalScene Scene; uint8 work_buff[55000]; -//char gString[256]; -//char gString2[512]; -//wchar gUString[256]; -//wchar gUString2[256]; -char *gString = (char*)0x711B40; -char *gString2 = (char*)0x878A40; -wchar *gUString = (wchar*)0x74B018; -wchar *gUString2 = (wchar*)0x6EDD70; - +char gString[256]; +char gString2[512]; +wchar gUString[256]; +wchar gUString2[256]; float FramesPerSecond = 30.0f; bool gbPrintShite = false; -bool &gbModelViewer = *(bool*)0x95CD93; +bool gbModelViewer; int32 frameCount; diff --git a/src/core/main.h b/src/core/main.h index 5ee758a4..90b13fbb 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -5,19 +5,15 @@ struct GlobalScene RpWorld *world; RwCamera *camera; }; -extern GlobalScene &Scene; +extern GlobalScene Scene; extern uint8 work_buff[55000]; -//extern char gString[256]; -//extern char gString2[512]; -//extern wchar gUString[256]; -//extern wchar gUString2[256]; -extern char *gString; -extern char *gString2; -extern wchar *gUString; -extern wchar *gUString2; +extern char gString[256]; +extern char gString2[512]; +extern wchar gUString[256]; +extern wchar gUString2[256]; extern bool gbPrintShite; -extern bool &gbModelViewer; +extern bool gbModelViewer; class CSprite2d; -- cgit v1.2.3 From ce7d6848ba0ffabb6616502c1a18ec2fb2af4259 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 17 Apr 2020 16:13:55 +0500 Subject: CWorld fixes --- src/core/World.cpp | 371 ++++++++++++++++++++++------------------------------- 1 file changed, 151 insertions(+), 220 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 02c0e2f6..f0b290a3 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -731,11 +731,10 @@ CWorld::FindObjectsInRange(CVector ¢re, float radius, bool ignoreZ, short *n void CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != ms_nCurrentScanCode) { - pEntity->m_scanCode = ms_nCurrentScanCode; + if (pEntity->m_scanCode != GetCurrentScanCode()) { + pEntity->m_scanCode = GetCurrentScanCode(); float fMagnitude = 0.0f; if (bCheck2DOnly) fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D(); @@ -747,7 +746,6 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const ++*nEntitiesFound; } } - pNode = pNode->next; } } @@ -1037,11 +1035,10 @@ CWorld::FindObjectsKindaColliding(const CVector& position, float radius, bool bC void CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != ms_nCurrentScanCode) { - pEntity->m_scanCode = ms_nCurrentScanCode; + if (pEntity->m_scanCode != GetCurrentScanCode()) { + pEntity->m_scanCode = GetCurrentScanCode(); float fMagnitude = 0.0f; if (bCheck2DOnly) fMagnitude = (position - pEntity->GetPosition()).Magnitude2D(); @@ -1053,7 +1050,6 @@ CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& posit ++*nCollidingEntities; } } - pNode = pNode->next; } } @@ -1097,11 +1093,10 @@ CWorld::FindObjectsIntersectingCube(const CVector& vecStartPos, const CVector& v void CWorld::FindObjectsIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { - pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; + if (pEntity->m_scanCode != GetCurrentScanCode()) { + pEntity->m_scanCode = GetCurrentScanCode(); float fRadius = pEntity->GetBoundRadius(); const CVector& entityPos = pEntity->GetPosition(); if (fRadius + entityPos.x >= vecStartPos.x && entityPos.x - fRadius <= vecEndPos.x && @@ -1113,7 +1108,6 @@ CWorld::FindObjectsIntersectingCubeSectorList(CPtrList& list, const CVector& vec ++*nIntersecting; } } - pNode = pNode->next; } } @@ -1156,11 +1150,10 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox& boundingBox, co void CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, const CColBox& boundingBox, const CMatrix& matrix, const CVector& position, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { - pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; + if (pEntity->m_scanCode != GetCurrentScanCode()) { + pEntity->m_scanCode = GetCurrentScanCode(); CColSphere sphere; CVector vecDistance = pEntity->GetPosition() - position; sphere.radius = pEntity->GetBoundRadius(); @@ -1171,7 +1164,6 @@ CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, cons ++*nEntitiesFound; } } - pNode = pNode->next; } } @@ -1206,11 +1198,10 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector& vecStartPos, const CV void CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bIsVehicleList, bool bIsPedList) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) { - pEntity->m_scanCode = CWorld::ms_nCurrentScanCode; + if (pEntity->m_scanCode != GetCurrentScanCode()) { + pEntity->m_scanCode = GetCurrentScanCode(); bool bIsMissionEntity = false; if (bIsVehicleList) bIsMissionEntity = ((CVehicle*)pEntity)->VehicleCreatedBy == MISSION_VEHICLE; @@ -1230,7 +1221,6 @@ CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVec ++*nIntersecting; } } - pNode = pNode->next; } } @@ -1397,11 +1387,10 @@ CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) void CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CVehicle *pVehicle = (CVehicle*)pNode->item; - if (pVehicle->m_scanCode != CWorld::ms_nCurrentScanCode) { - pVehicle->m_scanCode = CWorld::ms_nCurrentScanCode; + if (pVehicle->m_scanCode != GetCurrentScanCode()) { + pVehicle->m_scanCode = GetCurrentScanCode(); const CVector& vehiclePos = pVehicle->GetPosition(); eCarMission carMission = pVehicle->AutoPilot.m_nCarMission; if (pVehicle != FindPlayerVehicle() && @@ -1411,42 +1400,40 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1 (carMission == MISSION_RAMPLAYER_FARAWAY || carMission == MISSION_RAMPLAYER_CLOSE || carMission == MISSION_BLOCKPLAYER_FARAWAY || carMission == MISSION_BLOCKPLAYER_CLOSE) ) { - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000; - CColModel* pColModel = pVehicle->GetColModel(); - bool bInsideSphere = false; - for (int32 i = 0; i < pColModel->numSpheres; i++) { - CVector pos = pVehicle->m_matrix * pColModel->spheres[i].center; - float fRadius = pColModel->spheres[i].radius; - if (pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 && pos.y - fRadius < y2) - bInsideSphere = true; - // Maybe break the loop when bInsideSphere is set to true? - } - if (bInsideSphere) { - if (pVehicle->GetPosition().x <= (x1 + x2) * 0.5f) - pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f); - else - pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f); - if (pVehicle->GetPosition().y <= (y1 + y2) * 0.5f) - pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f); - else - pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f); - } + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000; + CColModel* pColModel = pVehicle->GetColModel(); + bool bInsideSphere = false; + for (int32 i = 0; i < pColModel->numSpheres; i++) { + CVector pos = pVehicle->m_matrix * pColModel->spheres[i].center; + float fRadius = pColModel->spheres[i].radius; + if (pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 && pos.y - fRadius < y2) + bInsideSphere = true; + // Maybe break the loop when bInsideSphere is set to true? + } + if (bInsideSphere) { + if (pVehicle->GetPosition().x <= (x1 + x2) * 0.5f) + pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f); + else + pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f); + if (pVehicle->GetPosition().y <= (y1 + y2) * 0.5f) + pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f); + else + pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f); } } - pNode = pNode->next; + } } } void CWorld::CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2) { - CPtrNode* pNode = list.first; - while (pNode) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { CPed* pPed = (CPed*)pNode->item; const CVector& pedPos = pPed->GetPosition(); - if (pPed->m_scanCode != CWorld::ms_nCurrentScanCode) + if (pPed->m_scanCode != GetCurrentScanCode()) { - pPed->m_scanCode = CWorld::ms_nCurrentScanCode; + pPed->m_scanCode = GetCurrentScanCode(); if (pPed != FindPlayerPed() && pPed->m_leader != FindPlayerPed() && pedPos.x > x1 && pedPos.x < x2 && pedPos.y > y1 && pedPos.y < y2 && @@ -1582,103 +1569,75 @@ CWorld::AddParticles(void) void CWorld::ShutDown(void) { - for (int32 y = 0; y < NUMSECTORS_Y; y++) { - for (int32 x = 0; x < NUMSECTORS_X; x++) { - CSector *pSector = GetSector(x, y); - CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; - while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; - while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_PEDS].first; - while (pNode) { - CEntity *pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; - while (pNode) { - CEntity *pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; - while (pNode) { - CEntity *pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); - pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); - pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); - pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); + for (int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); + for (CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); } for (int32 i = 0; i < 4; i ++) { - CPtrNode *pNode = GetBigBuildingList((eLevelName)i).first; - while (pNode) { + for (CPtrNode* pNode = GetBigBuildingList((eLevelName)i).first; pNode; pNode = pNode->next) { CEntity *pEntity = (CEntity*)pNode->item; - if (pEntity) { - // Maybe remove from world here? - delete pEntity; - } - pNode = pNode->next; + // Maybe remove from world here? + delete pEntity; } GetBigBuildingList((eLevelName)i).Flush(); } - for (int32 y = 0; y < NUMSECTORS_Y; y++) { - for (int32 x = 0; x < NUMSECTORS_X; x++) { - CSector *pSector = GetSector(x, y); - if (pSector->m_lists[ENTITYLIST_BUILDINGS].first) { - sprintf(gString, "Building list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); - } - if (pSector->m_lists[ENTITYLIST_DUMMIES].first) { - sprintf(gString, "Dummy list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); - } - if (pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first) { - sprintf(gString, "Building overlap list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); - } - if (pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].first) { - sprintf(gString, "Vehicle overlap list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].Flush(); - } - if (pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].first) { - sprintf(gString, "Ped overlap list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].Flush(); - } - if (pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].first) { - sprintf(gString, "Object overlap list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].Flush(); - } - if (pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first) { - sprintf(gString, "Dummy overlap list %d,%d not empty\n", x, y); - pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); - } + for (int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); + if (pSector->m_lists[ENTITYLIST_BUILDINGS].first) { + sprintf(gString, "Building list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); + } + if (pSector->m_lists[ENTITYLIST_DUMMIES].first) { + sprintf(gString, "Dummy list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); + } + if (pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first) { + sprintf(gString, "Building overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].first) { + sprintf(gString, "Vehicle overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].first) { + sprintf(gString, "Ped overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].first) { + sprintf(gString, "Object overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].Flush(); + } + if (pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first) { + sprintf(gString, "Dummy overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); } } ms_listMovingEntityPtrs.Flush(); @@ -1693,37 +1652,25 @@ CWorld::ClearForRestart(void) CObject::DeleteAllTempObjects(); CObject::DeleteAllMissionObjects(); CPopulation::ConvertAllObjectsToDummyObjects(); - for (int32 y = 0; y < NUMSECTORS_Y; y++) { - for (int32 x = 0; x < NUMSECTORS_X; x++) { - CSector *pSector = GetSector(x, y); - CPtrNode *pNode = pSector->m_lists[ENTITYLIST_PEDS].first; - while (pNode) { - CEntity *pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = GetBigBuildingList(LEVEL_NONE).first; - while (pNode) { - CVehicle *pVehicle = (CVehicle*)pNode->item; - if (pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { - CWorld::Remove(pVehicle); - delete pVehicle; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; - while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; + for (int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + CSector* pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + for (CPtrNode* pNode = GetBigBuildingList(LEVEL_NONE).first; pNode; pNode = pNode->next) { + CVehicle *pVehicle = (CVehicle*)pNode->item; + if (pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { + CWorld::Remove(pVehicle); + delete pVehicle; } } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } } CPools::CheckPoolsEmpty(); } @@ -1833,41 +1780,27 @@ CWorld::SetPedsOnFire(float x, float y, float z, float radius, CEntity* reason) void CWorld::RemoveStaticObjects() { - for (int32 y = 0; y < NUMSECTORS_Y; y++) { - for (int32 x = 0; x < NUMSECTORS_X; x++) { - CSector* pSector = GetSector(x, y); - CPtrNode* pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; - while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; - while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; - while (pNode) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity) { - CWorld::Remove(pEntity); - delete pEntity; - } - pNode = pNode->next; - } - pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); - pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); - pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); - pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); + for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; + } + for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { + CEntity* pEntity = (CEntity*)pNode->item; + CWorld::Remove(pEntity); + delete pEntity; } + pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); } } @@ -2072,18 +2005,17 @@ CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, C void CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer) { - CPtrNode* pNode = list.first; - while (pNode) { - CPhysical* pEntity = (CPhysical*)pNode->item; - CVector vecDistance = pEntity->GetPosition() - position; - float fMagnitude = vecDistance.Magnitude(); - if (fRadius > fMagnitude) { - CWeapon::BlowUpExplosiveThings(pEntity); - CPed* pPed = (CPed*)pEntity; - CObject* pObject = (CObject*)pEntity; - CVehicle* pVehicle = (CVehicle*)pEntity; - if (!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { - if (pEntity->bIsStatic) { + for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { + CPhysical* pEntity = (CPhysical*)pNode->item; + CVector vecDistance = pEntity->GetPosition() - position; + float fMagnitude = vecDistance.Magnitude(); + if(fRadius > fMagnitude) { + CWeapon::BlowUpExplosiveThings(pEntity); + CPed *pPed = (CPed *)pEntity; + CObject *pObject = (CObject *)pEntity; + CVehicle *pVehicle = (CVehicle *)pEntity; + if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { + if(pEntity->bIsStatic) { if (pEntity->IsObject()) { if (fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) { if (IsGlass(pObject->m_modelIndex)) { @@ -2170,7 +2102,6 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa } } } - pNode = pNode->next; } } -- cgit v1.2.3 From 2a4717fa41c332add177d18ef99bcddff9fece93 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 17 Apr 2020 16:14:59 +0500 Subject: Apply clang format to CWorld --- src/core/World.cpp | 1969 +++++++++++++++++++++++++++------------------------- 1 file changed, 1031 insertions(+), 938 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index f0b290a3..358e1823 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1,55 +1,54 @@ -#include "common.h" -#include "patcher.h" -#include "Entity.h" -#include "Ped.h" -#include "PlayerPed.h" -#include "Vehicle.h" -#include "Object.h" +#include "World.h" #include "Camera.h" -#include "DMAudio.h" #include "CarCtrl.h" -#include "Garages.h" -#include "TempColModels.h" -#include "World.h" -#include "ModelIndices.h" -#include "References.h" +#include "CopPed.h" #include "CutsceneMgr.h" -#include "Record.h" -#include "RpAnimBlend.h" +#include "DMAudio.h" +#include "Entity.h" +#include "EventList.h" +#include "Explosion.h" +#include "Fire.h" +#include "Garages.h" +#include "Glass.h" #include "Messages.h" -#include "Replay.h" +#include "ModelIndices.h" +#include "Object.h" +#include "ParticleObject.h" +#include "Ped.h" +#include "PlayerPed.h" #include "Population.h" -#include "Fire.h" #include "ProjectileInfo.h" -#include "WaterLevel.h" -#include "CopPed.h" -#include "Object.h" +#include "Record.h" +#include "References.h" +#include "Replay.h" +#include "RpAnimBlend.h" #include "Shadows.h" -#include "Explosion.h" -#include "Glass.h" -#include "ParticleObject.h" -#include "EventList.h" +#include "TempColModels.h" +#include "Vehicle.h" +#include "WaterLevel.h" +#include "common.h" +#include "patcher.h" #define OBJECT_REPOSITION_OFFSET_Z 2.0f CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; -CPtrList *CWorld::ms_bigBuildingsList = (CPtrList*)0x6FAB60; -CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList*)0x8F433C; -CSector (*CWorld::ms_aSectors)[NUMSECTORS_X] = (CSector (*)[NUMSECTORS_Y])0x665608; -uint16 &CWorld::ms_nCurrentScanCode = *(uint16*)0x95CC64; +CPtrList *CWorld::ms_bigBuildingsList = (CPtrList *)0x6FAB60; +CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList *)0x8F433C; +CSector (*CWorld::ms_aSectors)[NUMSECTORS_X] = (CSector(*)[NUMSECTORS_Y])0x665608; +uint16 &CWorld::ms_nCurrentScanCode = *(uint16 *)0x95CC64; uint8 &CWorld::PlayerInFocus = *(uint8 *)0x95CD61; CPlayerInfo CWorld::Players[NUMPLAYERS]; -bool &CWorld::bNoMoreCollisionTorque = *(bool*)0x95CDCC; -CEntity *&CWorld::pIgnoreEntity = *(CEntity**)0x8F6494; -bool &CWorld::bIncludeDeadPeds = *(bool*)0x95CD8F; -bool &CWorld::bSecondShift = *(bool*)0x95CD54; -bool &CWorld::bForceProcessControl = *(bool*)0x95CD6C; -bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B; +bool &CWorld::bNoMoreCollisionTorque = *(bool *)0x95CDCC; +CEntity *&CWorld::pIgnoreEntity = *(CEntity **)0x8F6494; +bool &CWorld::bIncludeDeadPeds = *(bool *)0x95CD8F; +bool &CWorld::bSecondShift = *(bool *)0x95CD54; +bool &CWorld::bForceProcessControl = *(bool *)0x95CD6C; +bool &CWorld::bProcessCutsceneOnly = *(bool *)0x95CD8B; -bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C; -bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA; +bool &CWorld::bDoingCarCollisions = *(bool *)0x95CD8C; +bool &CWorld::bIncludeCarTyres = *(bool *)0x95CDAA; void CWorld::Initialise() @@ -67,37 +66,31 @@ CWorld::Initialise() void CWorld::Add(CEntity *ent) { - if(ent->IsVehicle() || ent->IsPed()) - DMAudio.SetEntityStatus(((CPhysical*)ent)->m_audioEntityId, true); + if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, true); if(ent->bIsBIGBuilding) ms_bigBuildingsList[ent->m_level].InsertItem(ent); else ent->Add(); - if(ent->IsBuilding() || ent->IsDummy()) - return; + if(ent->IsBuilding() || ent->IsDummy()) return; - if(!ent->bIsStatic) - ((CPhysical*)ent)->AddToMovingList(); + if(!ent->bIsStatic) ((CPhysical *)ent)->AddToMovingList(); } void CWorld::Remove(CEntity *ent) { - if(ent->IsVehicle() || ent->IsPed()) - DMAudio.SetEntityStatus(((CPhysical*)ent)->m_audioEntityId, false); + if(ent->IsVehicle() || ent->IsPed()) DMAudio.SetEntityStatus(((CPhysical *)ent)->m_audioEntityId, false); if(ent->bIsBIGBuilding) ms_bigBuildingsList[ent->m_level].RemoveItem(ent); else ent->Remove(); - if(ent->IsBuilding() || ent->IsDummy()) - return; + if(ent->IsBuilding() || ent->IsDummy()) return; - if(!ent->bIsStatic) - ((CPhysical*)ent)->RemoveFromMovingList(); + if(!ent->bIsStatic) ((CPhysical *)ent)->RemoveFromMovingList(); } void @@ -105,43 +98,43 @@ CWorld::ClearScanCodes(void) { CPtrNode *node; for(int i = 0; i < NUMSECTORS_Y; i++) - for(int j = 0; j < NUMSECTORS_X; j++){ - CSector *s = &ms_aSectors[i][j]; - for(node = s->m_lists[ENTITYLIST_BUILDINGS].first; node; node = node->next) - ((CEntity*)node->item)->m_scanCode = 0; - for(node = s->m_lists[ENTITYLIST_VEHICLES].first; node; node = node->next) - ((CEntity*)node->item)->m_scanCode = 0; - for(node = s->m_lists[ENTITYLIST_PEDS].first; node; node = node->next) - ((CEntity*)node->item)->m_scanCode = 0; - for(node = s->m_lists[ENTITYLIST_OBJECTS].first; node; node = node->next) - ((CEntity*)node->item)->m_scanCode = 0; - for(node = s->m_lists[ENTITYLIST_DUMMIES].first; node; node = node->next) - ((CEntity*)node->item)->m_scanCode = 0; - } + for(int j = 0; j < NUMSECTORS_X; j++) { + CSector *s = &ms_aSectors[i][j]; + for(node = s->m_lists[ENTITYLIST_BUILDINGS].first; node; node = node->next) + ((CEntity *)node->item)->m_scanCode = 0; + for(node = s->m_lists[ENTITYLIST_VEHICLES].first; node; node = node->next) + ((CEntity *)node->item)->m_scanCode = 0; + for(node = s->m_lists[ENTITYLIST_PEDS].first; node; node = node->next) + ((CEntity *)node->item)->m_scanCode = 0; + for(node = s->m_lists[ENTITYLIST_OBJECTS].first; node; node = node->next) + ((CEntity *)node->item)->m_scanCode = 0; + for(node = s->m_lists[ENTITYLIST_DUMMIES].first; node; node = node->next) + ((CEntity *)node->item)->m_scanCode = 0; + } } void -CWorld::ClearExcitingStuffFromArea(const CVector& pos, float radius, bool bRemoveProjectilesAndTidyUpShadows) +CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, bool bRemoveProjectilesAndTidyUpShadows) { - CPedPool* pedPool = CPools::GetPedPool(); - for (int32 i = 0; i < pedPool->GetSize(); i++) { - CPed* pPed = pedPool->GetSlot(i); - if (pPed && !pPed->IsPlayer() && pPed->CanBeDeleted() && - CVector2D(pPed->GetPosition() - pos).MagnitudeSqr() < radius) { + CPedPool *pedPool = CPools::GetPedPool(); + for(int32 i = 0; i < pedPool->GetSize(); i++) { + CPed *pPed = pedPool->GetSlot(i); + if(pPed && !pPed->IsPlayer() && pPed->CanBeDeleted() && + CVector2D(pPed->GetPosition() - pos).MagnitudeSqr() < radius) { CPopulation::RemovePed(pPed); } } - CVehiclePool* VehiclePool = CPools::GetVehiclePool(); - for (int32 i = 0; i < VehiclePool->GetSize(); i++) { - CVehicle* pVehicle = VehiclePool->GetSlot(i); - if (pVehicle && CVector2D(pVehicle->GetPosition() - pos).MagnitudeSqr() < radius && - !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { - if (pVehicle->pDriver) { + CVehiclePool *VehiclePool = CPools::GetVehiclePool(); + for(int32 i = 0; i < VehiclePool->GetSize(); i++) { + CVehicle *pVehicle = VehiclePool->GetSlot(i); + if(pVehicle && CVector2D(pVehicle->GetPosition() - pos).MagnitudeSqr() < radius && + !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { + if(pVehicle->pDriver) { CPopulation::RemovePed(pVehicle->pDriver); pVehicle->pDriver = nil; } - for (int32 j = 0; j < pVehicle->m_nNumMaxPassengers; ++j) { - if (pVehicle->pPassengers[j]) { + for(int32 j = 0; j < pVehicle->m_nNumMaxPassengers; ++j) { + if(pVehicle->pPassengers[j]) { CPopulation::RemovePed(pVehicle->pPassengers[j]); pVehicle->pPassengers[j] = nil; --pVehicle->m_nNumPassengers; @@ -156,7 +149,7 @@ CWorld::ClearExcitingStuffFromArea(const CVector& pos, float radius, bool bRemov gFireManager.ExtinguishPoint(pos, radius); CWorld::ExtinguishAllCarFiresInArea(pos, radius); CExplosion::RemoveAllExplosionsInArea(pos, radius); - if (bRemoveProjectilesAndTidyUpShadows) { + if(bRemoveProjectilesAndTidyUpShadows) { CProjectileInfo::RemoveAllProjectiles(); CShadows::TidyUpShadows(); } @@ -165,13 +158,14 @@ CWorld::ClearExcitingStuffFromArea(const CVector& pos, float radius, bool bRemov bool CWorld::CameraToIgnoreThisObject(CEntity *ent) { - if(CGarages::IsModelIndexADoor(ent->GetModelIndex())) - return false; - return ((CObject*)ent)->m_bCameraToAvoidThisObject != 1; + if(CGarages::IsModelIndexADoor(ent->GetModelIndex())) return false; + return ((CObject *)ent)->m_bCameraToAvoidThisObject != 1; } bool -CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) +CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoint &point, CEntity *&entity, + bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, + bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) { int x, xstart, xend; int y, ystart, yend; @@ -188,94 +182,80 @@ CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoi xend = GetSectorIndexX(point2.x); yend = GetSectorIndexY(point2.y); -#define LOSARGS CColLine(point1, point2), point, dist, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, ignoreSomeObjects +#define LOSARGS \ + CColLine(point1, point2), point, dist, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, \ + checkDummies, ignoreSeeThrough, ignoreSomeObjects - if(xstart == xend && ystart == yend){ + if(xstart == xend && ystart == yend) { // Only one sector return ProcessLineOfSightSector(*GetSector(xstart, ystart), LOSARGS); - }else if(xstart == xend){ + } else if(xstart == xend) { // Only step in y if(ystart < yend) - for(y = ystart; y <= yend; y++) - ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); + for(y = ystart; y <= yend; y++) ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); else - for(y = ystart; y >= yend; y--) - ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); + for(y = ystart; y >= yend; y--) ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); return dist < 1.0f; - }else if(ystart == yend){ + } else if(ystart == yend) { // Only step in x if(xstart < xend) - for(x = xstart; x <= xend; x++) - ProcessLineOfSightSector(*GetSector(x, ystart), LOSARGS); + for(x = xstart; x <= xend; x++) ProcessLineOfSightSector(*GetSector(x, ystart), LOSARGS); else - for(x = xstart; x >= xend; x--) - ProcessLineOfSightSector(*GetSector(x, ystart), LOSARGS); + for(x = xstart; x >= xend; x--) ProcessLineOfSightSector(*GetSector(x, ystart), LOSARGS); return dist < 1.0f; - }else{ - if(point1.x < point2.x){ + } else { + if(point1.x < point2.x) { // Step from left to right float m = (point2.y - point1.y) / (point2.x - point1.x); y1 = ystart; - y2 = GetSectorIndexY((GetWorldX(xstart+1) - point1.x)*m + point1.y); + y2 = GetSectorIndexY((GetWorldX(xstart + 1) - point1.x) * m + point1.y); if(y1 < y2) - for(y = y1; y <= y2; y++) - ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); + for(y = y1; y <= y2; y++) ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); else - for(y = y1; y >= y2; y--) - ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); + for(y = y1; y >= y2; y--) ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); - for(x = xstart+1; x < xend; x++){ + for(x = xstart + 1; x < xend; x++) { y1 = y2; - y2 = GetSectorIndexY((GetWorldX(x+1) - point1.x)*m + point1.y); + y2 = GetSectorIndexY((GetWorldX(x + 1) - point1.x) * m + point1.y); if(y1 < y2) - for(y = y1; y <= y2; y++) - ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); + for(y = y1; y <= y2; y++) ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); else - for(y = y1; y >= y2; y--) - ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); + for(y = y1; y >= y2; y--) ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); } y1 = y2; y2 = yend; if(y1 < y2) - for(y = y1; y <= y2; y++) - ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); + for(y = y1; y <= y2; y++) ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); else - for(y = y1; y >= y2; y--) - ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); - }else{ + for(y = y1; y >= y2; y--) ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); + } else { // Step from right to left float m = (point2.y - point1.y) / (point2.x - point1.x); y1 = ystart; - y2 = GetSectorIndexY((GetWorldX(xstart) - point1.x)*m + point1.y); + y2 = GetSectorIndexY((GetWorldX(xstart) - point1.x) * m + point1.y); if(y1 < y2) - for(y = y1; y <= y2; y++) - ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); + for(y = y1; y <= y2; y++) ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); else - for(y = y1; y >= y2; y--) - ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); + for(y = y1; y >= y2; y--) ProcessLineOfSightSector(*GetSector(xstart, y), LOSARGS); - for(x = xstart-1; x > xend; x--){ + for(x = xstart - 1; x > xend; x--) { y1 = y2; - y2 = GetSectorIndexY((GetWorldX(x) - point1.x)*m + point1.y); + y2 = GetSectorIndexY((GetWorldX(x) - point1.x) * m + point1.y); if(y1 < y2) - for(y = y1; y <= y2; y++) - ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); + for(y = y1; y <= y2; y++) ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); else - for(y = y1; y >= y2; y--) - ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); + for(y = y1; y >= y2; y--) ProcessLineOfSightSector(*GetSector(x, y), LOSARGS); } y1 = y2; y2 = yend; if(y1 < y2) - for(y = y1; y <= y2; y++) - ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); + for(y = y1; y <= y2; y++) ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); else - for(y = y1; y >= y2; y--) - ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); + for(y = y1; y >= y2; y--) ProcessLineOfSightSector(*GetSector(xend, y), LOSARGS); } return dist < 1.0f; } @@ -284,51 +264,63 @@ CWorld::ProcessLineOfSight(const CVector &point1, const CVector &point2, CColPoi } bool -CWorld::ProcessLineOfSightSector(CSector §or, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) +CWorld::ProcessLineOfSightSector(CSector §or, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, + bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, + bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) { float mindist = dist; bool deadPeds = !!bIncludeDeadPeds; bIncludeDeadPeds = false; - if(checkBuildings){ - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS], line, point, mindist, entity, ignoreSeeThrough); - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, point, mindist, entity, ignoreSeeThrough); + if(checkBuildings) { + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS], line, point, mindist, entity, + ignoreSeeThrough); + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough); } - if(checkVehicles){ - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES], line, point, mindist, entity, ignoreSeeThrough); - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, point, mindist, entity, ignoreSeeThrough); + if(checkVehicles) { + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES], line, point, mindist, entity, + ignoreSeeThrough); + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough); } - if(checkPeds){ - if(deadPeds) - bIncludeDeadPeds = true; - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS], line, point, mindist, entity, ignoreSeeThrough); - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, point, mindist, entity, ignoreSeeThrough); + if(checkPeds) { + if(deadPeds) bIncludeDeadPeds = true; + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS], line, point, mindist, entity, + ignoreSeeThrough); + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough); bIncludeDeadPeds = false; } - if(checkObjects){ - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS], line, point, mindist, entity, ignoreSeeThrough, ignoreSomeObjects); - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, point, mindist, entity, ignoreSeeThrough, ignoreSomeObjects); + if(checkObjects) { + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS], line, point, mindist, entity, + ignoreSeeThrough, ignoreSomeObjects); + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough, ignoreSomeObjects); } - if(checkDummies){ - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES], line, point, mindist, entity, ignoreSeeThrough); - ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, point, mindist, entity, ignoreSeeThrough); + if(checkDummies) { + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES], line, point, mindist, entity, + ignoreSeeThrough); + ProcessLineOfSightSectorList(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough); } bIncludeDeadPeds = deadPeds; - if(mindist < dist){ + if(mindist < dist) { dist = mindist; return true; - }else + } else return false; } bool -CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects) +CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, + CEntity *&entity, bool ignoreSeeThrough, bool ignoreSomeObjects) { bool deadPeds = false; float mindist = dist; @@ -336,119 +328,137 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP CEntity *e; CColModel *colmodel; - if(list.first && bIncludeDeadPeds && ((CEntity*)list.first->item)->IsPed()) - deadPeds = true; + if(list.first && bIncludeDeadPeds && ((CEntity *)list.first->item)->IsPed()) deadPeds = true; - for(node = list.first; node; node = node->next){ - e = (CEntity*)node->item; - if(e->m_scanCode != GetCurrentScanCode() && - e != pIgnoreEntity && - (e->bUsesCollision || deadPeds) && - !(ignoreSomeObjects && CameraToIgnoreThisObject(e))){ + for(node = list.first; node; node = node->next) { + e = (CEntity *)node->item; + if(e->m_scanCode != GetCurrentScanCode() && e != pIgnoreEntity && (e->bUsesCollision || deadPeds) && + !(ignoreSomeObjects && CameraToIgnoreThisObject(e))) { colmodel = nil; e->m_scanCode = GetCurrentScanCode(); - if(e->IsPed()){ - if(e->bUsesCollision || - deadPeds && ((CPed*)e)->m_nPedState == PED_DEAD){ - if (((CPed*)e)->UseGroundColModel()) + if(e->IsPed()) { + if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD) { + if(((CPed *)e)->UseGroundColModel()) colmodel = &CTempColModels::ms_colModelPedGroundHit; else #ifdef ANIMATE_PED_COL_MODEL - colmodel = CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()))->GetHitColModel(), RpClumpGetFrame(e->GetClump())); + colmodel = CPedModelInfo::AnimatePedColModel( + ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex())) + ->GetHitColModel(), + RpClumpGetFrame(e->GetClump())); #else - colmodel = ((CPedModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()))->GetHitColModel(); + colmodel = + ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex())) + ->GetHitColModel(); #endif - }else + } else colmodel = nil; - }else if(e->bUsesCollision) + } else if(e->bUsesCollision) colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(); - if(colmodel && - CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, dist, ignoreSeeThrough)) + if(colmodel && CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, dist, + ignoreSeeThrough)) entity = e; } } - if(mindist < dist){ + if(mindist < dist) { dist = mindist; return true; - }else + } else return false; } -bool -CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly) +bool +CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, CEntity *&entity, bool checkBuildings, + bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, + bool ignoreSeeThrough, CStoredCollPoly *poly) { AdvanceCurrentScanCode(); CVector point2(point1.x, point1.y, z2); return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexX(point1.y)), - CColLine(point1, point2), point, entity, - checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly); + CColLine(point1, point2), point, entity, checkBuildings, checkVehicles, + checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly); } bool -CWorld::ProcessVerticalLineSector(CSector §or, const CColLine &line, CColPoint &point, CEntity *&entity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly) +CWorld::ProcessVerticalLineSector(CSector §or, const CColLine &line, CColPoint &point, CEntity *&entity, + bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, + bool checkDummies, bool ignoreSeeThrough, CStoredCollPoly *poly) { float mindist = 1.0f; - if(checkBuildings){ - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_BUILDINGS], line, point, mindist, entity, ignoreSeeThrough, poly); - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, point, mindist, entity, ignoreSeeThrough, poly); + if(checkBuildings) { + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_BUILDINGS], line, point, mindist, entity, + ignoreSeeThrough, poly); + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, point, mindist, + entity, ignoreSeeThrough, poly); } - if(checkVehicles){ - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_VEHICLES], line, point, mindist, entity, ignoreSeeThrough, poly); - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, point, mindist, entity, ignoreSeeThrough, poly); + if(checkVehicles) { + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_VEHICLES], line, point, mindist, entity, + ignoreSeeThrough, poly); + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough, poly); } - if(checkPeds){ - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_PEDS], line, point, mindist, entity, ignoreSeeThrough, poly); - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, point, mindist, entity, ignoreSeeThrough, poly); + if(checkPeds) { + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_PEDS], line, point, mindist, entity, + ignoreSeeThrough, poly); + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough, poly); } - if(checkObjects){ - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_OBJECTS], line, point, mindist, entity, ignoreSeeThrough, poly); - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, point, mindist, entity, ignoreSeeThrough, poly); + if(checkObjects) { + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_OBJECTS], line, point, mindist, entity, + ignoreSeeThrough, poly); + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough, poly); } - if(checkDummies){ - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_DUMMIES], line, point, mindist, entity, ignoreSeeThrough, poly); - ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, point, mindist, entity, ignoreSeeThrough, poly); + if(checkDummies) { + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_DUMMIES], line, point, mindist, entity, + ignoreSeeThrough, poly); + ProcessVerticalLineSectorList(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, point, mindist, entity, + ignoreSeeThrough, poly); } return mindist < 1.0f; } bool -CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly) +CWorld::ProcessVerticalLineSectorList(CPtrList &list, const CColLine &line, CColPoint &point, float &dist, + CEntity *&entity, bool ignoreSeeThrough, CStoredCollPoly *poly) { float mindist = dist; CPtrNode *node; CEntity *e; CColModel *colmodel; - for(node = list.first; node; node = node->next){ - e = (CEntity*)node->item; - if(e->m_scanCode != GetCurrentScanCode() && - e->bUsesCollision){ + for(node = list.first; node; node = node->next) { + e = (CEntity *)node->item; + if(e->m_scanCode != GetCurrentScanCode() && e->bUsesCollision) { e->m_scanCode = GetCurrentScanCode(); colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(); - if(CCollision::ProcessVerticalLine(line, e->GetMatrix(), *colmodel, point, dist, ignoreSeeThrough, poly)) + if(CCollision::ProcessVerticalLine(line, e->GetMatrix(), *colmodel, point, dist, + ignoreSeeThrough, poly)) entity = e; } } - if(mindist < dist){ + if(mindist < dist) { dist = mindist; return true; - }else + } else return false; } bool -CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) +CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool checkBuildings, bool checkVehicles, + bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, + bool ignoreSomeObjects) { int x, xstart, xend; int y, ystart, yend; @@ -461,58 +471,54 @@ CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool xend = GetSectorIndexX(point2.x); yend = GetSectorIndexY(point2.y); -#define LOSARGS CColLine(point1, point2), checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, ignoreSomeObjects +#define LOSARGS \ + CColLine(point1, point2), checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, \ + ignoreSeeThrough, ignoreSomeObjects - if(xstart == xend && ystart == yend){ + if(xstart == xend && ystart == yend) { // Only one sector return GetIsLineOfSightSectorClear(*GetSector(xstart, ystart), LOSARGS); - }else if(xstart == xend){ + } else if(xstart == xend) { // Only step in y - if(ystart < yend){ + if(ystart < yend) { for(y = ystart; y <= yend; y++) - if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) - return false; - }else{ + if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) return false; + } else { for(y = ystart; y >= yend; y--) - if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) - return false; + if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) return false; } - }else if(ystart == yend){ + } else if(ystart == yend) { // Only step in x - if(xstart < xend){ + if(xstart < xend) { for(x = xstart; x <= xend; x++) - if(!GetIsLineOfSightSectorClear(*GetSector(x, ystart), LOSARGS)) - return false; - }else{ + if(!GetIsLineOfSightSectorClear(*GetSector(x, ystart), LOSARGS)) return false; + } else { for(x = xstart; x >= xend; x--) - if(!GetIsLineOfSightSectorClear(*GetSector(x, ystart), LOSARGS)) - return false; + if(!GetIsLineOfSightSectorClear(*GetSector(x, ystart), LOSARGS)) return false; } - }else{ - if(point1.x < point2.x){ + } else { + if(point1.x < point2.x) { // Step from left to right float m = (point2.y - point1.y) / (point2.x - point1.x); y1 = ystart; - y2 = GetSectorIndexY((GetWorldX(xstart+1) - point1.x)*m + point1.y); - if(y1 < y2){ + y2 = GetSectorIndexY((GetWorldX(xstart + 1) - point1.x) * m + point1.y); + if(y1 < y2) { for(y = y1; y <= y2; y++) - if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) - return false; - }else{ + if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) return false; + } else { for(y = y1; y >= y2; y--) - if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) - return false; + if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) return false; } - for(x = xstart+1; x < xend; x++){ + for(x = xstart + 1; x < xend; x++) { y1 = y2; - y2 = GetSectorIndexY((GetWorldX(x+1) - point1.x)*m + point1.y); - if(y1 < y2){ + y2 = GetSectorIndexY((GetWorldX(x + 1) - point1.x) * m + point1.y); + if(y1 < y2) { for(y = y1; y <= y2; y++) if(!GetIsLineOfSightSectorClear(*GetSector(x, y), LOSARGS)) return false; - }else{ + } else { for(y = y1; y >= y2; y--) if(!GetIsLineOfSightSectorClear(*GetSector(x, y), LOSARGS)) return false; @@ -521,39 +527,35 @@ CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool y1 = y2; y2 = yend; - if(y1 < y2){ + if(y1 < y2) { for(y = y1; y <= y2; y++) - if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) - return false; - }else{ + if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) return false; + } else { for(y = y1; y >= y2; y--) - if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) - return false; + if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) return false; } - }else{ + } else { // Step from right to left float m = (point2.y - point1.y) / (point2.x - point1.x); y1 = ystart; - y2 = GetSectorIndexY((GetWorldX(xstart) - point1.x)*m + point1.y); - if(y1 < y2){ + y2 = GetSectorIndexY((GetWorldX(xstart) - point1.x) * m + point1.y); + if(y1 < y2) { for(y = y1; y <= y2; y++) - if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) - return false; - }else{ + if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) return false; + } else { for(y = y1; y >= y2; y--) - if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) - return false; + if(!GetIsLineOfSightSectorClear(*GetSector(xstart, y), LOSARGS)) return false; } - for(x = xstart-1; x > xend; x--){ + for(x = xstart - 1; x > xend; x--) { y1 = y2; - y2 = GetSectorIndexY((GetWorldX(x) - point1.x)*m + point1.y); - if(y1 < y2){ + y2 = GetSectorIndexY((GetWorldX(x) - point1.x) * m + point1.y); + if(y1 < y2) { for(y = y1; y <= y2; y++) if(!GetIsLineOfSightSectorClear(*GetSector(x, y), LOSARGS)) return false; - }else{ + } else { for(y = y1; y >= y2; y--) if(!GetIsLineOfSightSectorClear(*GetSector(x, y), LOSARGS)) return false; @@ -562,14 +564,12 @@ CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool y1 = y2; y2 = yend; - if(y1 < y2){ + if(y1 < y2) { for(y = y1; y <= y2; y++) - if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) - return false; - }else{ + if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) return false; + } else { for(y = y1; y >= y2; y--) - if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) - return false; + if(!GetIsLineOfSightSectorClear(*GetSector(xend, y), LOSARGS)) return false; } } } @@ -580,37 +580,43 @@ CWorld::GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool } bool -CWorld::GetIsLineOfSightSectorClear(CSector §or, const CColLine &line, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) +CWorld::GetIsLineOfSightSectorClear(CSector §or, const CColLine &line, bool checkBuildings, bool checkVehicles, + bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, + bool ignoreSomeObjects) { - if(checkBuildings){ + if(checkBuildings) { if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_BUILDINGS], line, ignoreSeeThrough)) return false; - if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, ignoreSeeThrough)) + if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_BUILDINGS_OVERLAP], line, + ignoreSeeThrough)) return false; } - if(checkVehicles){ + if(checkVehicles) { if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_VEHICLES], line, ignoreSeeThrough)) return false; - if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, ignoreSeeThrough)) + if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_VEHICLES_OVERLAP], line, + ignoreSeeThrough)) return false; } - if(checkPeds){ + if(checkPeds) { if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_PEDS], line, ignoreSeeThrough)) return false; if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_PEDS_OVERLAP], line, ignoreSeeThrough)) return false; } - if(checkObjects){ - if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_OBJECTS], line, ignoreSeeThrough, ignoreSomeObjects)) + if(checkObjects) { + if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_OBJECTS], line, ignoreSeeThrough, + ignoreSomeObjects)) return false; - if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, ignoreSeeThrough, ignoreSomeObjects)) + if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_OBJECTS_OVERLAP], line, ignoreSeeThrough, + ignoreSomeObjects)) return false; } - if(checkDummies){ + if(checkDummies) { if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_DUMMIES], line, ignoreSeeThrough)) return false; if(!GetIsLineOfSightSectorListClear(sector.m_lists[ENTITYLIST_DUMMIES_OVERLAP], line, ignoreSeeThrough)) @@ -621,21 +627,20 @@ CWorld::GetIsLineOfSightSectorClear(CSector §or, const CColLine &line, bool } bool -CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bool ignoreSeeThrough, bool ignoreSomeObjects) +CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bool ignoreSeeThrough, + bool ignoreSomeObjects) { CPtrNode *node; CEntity *e; CColModel *colmodel; - for(node = list.first; node; node = node->next){ - e = (CEntity*)node->item; - if(e->m_scanCode != GetCurrentScanCode() && - e->bUsesCollision){ + for(node = list.first; node; node = node->next) { + e = (CEntity *)node->item; + if(e->m_scanCode != GetCurrentScanCode() && e->bUsesCollision) { e->m_scanCode = GetCurrentScanCode(); - if(e != pIgnoreEntity && - !(ignoreSomeObjects && CameraToIgnoreThisObject(e))){ + if(e != pIgnoreEntity && !(ignoreSomeObjects && CameraToIgnoreThisObject(e))) { colmodel = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel(); @@ -649,26 +654,25 @@ CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bo } void -CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector ¢re, float radius, bool ignoreZ, short *nextObject, short lastObject, CEntity **objects) +CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector ¢re, float radius, bool ignoreZ, short *nextObject, + short lastObject, CEntity **objects) { float radiusSqr = radius * radius; float objDistSqr; - for (CPtrNode *node = list.first; node; node = node->next) { - CEntity *object = (CEntity*)node->item; - if (object->m_scanCode != GetCurrentScanCode()) { + for(CPtrNode *node = list.first; node; node = node->next) { + CEntity *object = (CEntity *)node->item; + if(object->m_scanCode != GetCurrentScanCode()) { object->m_scanCode = GetCurrentScanCode(); CVector diff = centre - object->GetPosition(); - if (ignoreZ) + if(ignoreZ) objDistSqr = diff.MagnitudeSqr2D(); else objDistSqr = diff.MagnitudeSqr(); - if (objDistSqr < radiusSqr && *nextObject < lastObject) { - if (objects) { - objects[*nextObject] = object; - } + if(objDistSqr < radiusSqr && *nextObject < lastObject) { + if(objects) { objects[*nextObject] = object; } (*nextObject)++; } } @@ -676,81 +680,96 @@ CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector ¢re, float radi } void -CWorld::FindObjectsInRange(CVector ¢re, float radius, bool ignoreZ, short *nextObject, short lastObject, CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies) +CWorld::FindObjectsInRange(CVector ¢re, float radius, bool ignoreZ, short *nextObject, short lastObject, + CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds, + bool checkObjects, bool checkDummies) { int minX = GetSectorIndexX(centre.x - radius); - if (minX <= 0) minX = 0; + if(minX <= 0) minX = 0; int minY = GetSectorIndexY(centre.y - radius); - if (minY <= 0) minY = 0; + if(minY <= 0) minY = 0; int maxX = GetSectorIndexX(centre.x + radius); #ifdef FIX_BUGS - if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1; + if(maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1; #else - if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X; + if(maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X; #endif int maxY = GetSectorIndexY(centre.y + radius); #ifdef FIX_BUGS - if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1; + if(maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1; #else - if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y; + if(maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y; #endif - + AdvanceCurrentScanCode(); *nextObject = 0; for(int curY = minY; curY <= maxY; curY++) { for(int curX = minX; curX <= maxX; curX++) { CSector *sector = GetSector(curX, curY); - if (checkBuildings) { - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS], centre, radius, ignoreZ, nextObject, lastObject, objects); - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], centre, radius, ignoreZ, nextObject, lastObject, objects); + if(checkBuildings) { + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS], centre, radius, + ignoreZ, nextObject, lastObject, objects); + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], centre, + radius, ignoreZ, nextObject, lastObject, objects); } - if (checkVehicles) { - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES], centre, radius, ignoreZ, nextObject, lastObject, objects); - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], centre, radius, ignoreZ, nextObject, lastObject, objects); + if(checkVehicles) { + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES], centre, radius, + ignoreZ, nextObject, lastObject, objects); + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], centre, + radius, ignoreZ, nextObject, lastObject, objects); } - if (checkPeds) { - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS], centre, radius, ignoreZ, nextObject, lastObject, objects); - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS_OVERLAP], centre, radius, ignoreZ, nextObject, lastObject, objects); + if(checkPeds) { + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS], centre, radius, ignoreZ, + nextObject, lastObject, objects); + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS_OVERLAP], centre, radius, + ignoreZ, nextObject, lastObject, objects); } - if (checkObjects) { - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS], centre, radius, ignoreZ, nextObject, lastObject, objects); - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], centre, radius, ignoreZ, nextObject, lastObject, objects); + if(checkObjects) { + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS], centre, radius, + ignoreZ, nextObject, lastObject, objects); + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], centre, + radius, ignoreZ, nextObject, lastObject, objects); } - if (checkDummies) { - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES], centre, radius, ignoreZ, nextObject, lastObject, objects); - FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], centre, radius, ignoreZ, nextObject, lastObject, objects); + if(checkDummies) { + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES], centre, radius, + ignoreZ, nextObject, lastObject, objects); + FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], centre, + radius, ignoreZ, nextObject, lastObject, objects); } } } } -void -CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities) +void +CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList &list, const CVector &position, float radius, + bool bCheck2DOnly, int16 *nEntitiesFound, int16 maxEntitiesToFind, + CEntity **aEntities) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != GetCurrentScanCode()) { + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; + if(pEntity->m_scanCode != GetCurrentScanCode()) { pEntity->m_scanCode = GetCurrentScanCode(); float fMagnitude = 0.0f; - if (bCheck2DOnly) + if(bCheck2DOnly) fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D(); else fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr(); - if (fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) { - if (aEntities) - aEntities[*nEntitiesFound] = pEntity; + if(fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) { + if(aEntities) aEntities[*nEntitiesFound] = pEntity; ++*nEntitiesFound; } } } } -void -CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) +void +CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector &position, float radius, bool bCheck2DOnly, + int16 *nEntitiesFound, int16 maxEntitiesToFind, CEntity **aEntities, bool bBuildings, + bool bVehicles, bool bPeds, bool bObjects, bool bDummies) { CWorld::AdvanceCurrentScanCode(); *nEntitiesFound = 0; @@ -760,115 +779,138 @@ CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - if (bBuildings) { - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bVehicles) { - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bPeds) { - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bObjects) { - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bDummies) { - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsOfTypeInRangeSectorList(modelId, pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); - } - } - } -} - -CEntity* -CWorld::TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects) + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + if(bBuildings) { + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, + bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bVehicles) { + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, + bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bPeds) { + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, + nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bObjects) { + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, + bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bDummies) { + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsOfTypeInRangeSectorList( + modelId, pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, + bCheck2DOnly, nEntitiesFound, maxEntitiesToFind, aEntities); + } + } + } +} + +CEntity * +CWorld::TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, + bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, + bool ignoreSomeObjects) { - CEntity* foundE = nil; + CEntity *foundE = nil; int minX = GetSectorIndexX(centre.x - radius); - if (minX <= 0) minX = 0; + if(minX <= 0) minX = 0; int minY = GetSectorIndexY(centre.y - radius); - if (minY <= 0) minY = 0; + if(minY <= 0) minY = 0; int maxX = GetSectorIndexX(centre.x + radius); #ifdef FIX_BUGS - if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1; + if(maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1; #else - if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X; + if(maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X; #endif int maxY = GetSectorIndexY(centre.y + radius); #ifdef FIX_BUGS - if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1; + if(maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1; #else - if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y; + if(maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y; #endif AdvanceCurrentScanCode(); - for (int curY = minY; curY <= maxY; curY++) { - for (int curX = minX; curX <= maxX; curX++) { - CSector* sector = GetSector(curX, curY); - if (checkBuildings) { - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_BUILDINGS], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + for(int curY = minY; curY <= maxY; curY++) { + for(int curX = minX; curX <= maxX; curX++) { + CSector *sector = GetSector(curX, curY); + if(checkBuildings) { + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_BUILDINGS], centre, + radius, entityToIgnore, false); + if(foundE) return foundE; - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], + centre, radius, entityToIgnore, false); + if(foundE) return foundE; } - if (checkVehicles) { - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_VEHICLES], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + if(checkVehicles) { + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_VEHICLES], centre, + radius, entityToIgnore, false); + if(foundE) return foundE; - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], + centre, radius, entityToIgnore, false); + if(foundE) return foundE; } - if (checkPeds) { - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_PEDS], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + if(checkPeds) { + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_PEDS], centre, radius, + entityToIgnore, false); + if(foundE) return foundE; - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_PEDS_OVERLAP], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_PEDS_OVERLAP], centre, + radius, entityToIgnore, false); + if(foundE) return foundE; } - if (checkObjects) { - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_OBJECTS], centre, radius, entityToIgnore, ignoreSomeObjects); - if (foundE) - return foundE; + if(checkObjects) { + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_OBJECTS], centre, + radius, entityToIgnore, ignoreSomeObjects); + if(foundE) return foundE; - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], centre, radius, entityToIgnore, ignoreSomeObjects); - if (foundE) - return foundE; + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], + centre, radius, entityToIgnore, ignoreSomeObjects); + if(foundE) return foundE; } - if (checkDummies) { - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_DUMMIES], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + if(checkDummies) { + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_DUMMIES], centre, + radius, entityToIgnore, false); + if(foundE) return foundE; - foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], centre, radius, entityToIgnore, false); - if (foundE) - return foundE; + foundE = TestSphereAgainstSectorList(sector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], + centre, radius, entityToIgnore, false); + if(foundE) return foundE; } } } return foundE; } -CEntity* -CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float radius, CEntity *entityToIgnore, bool ignoreSomeObjects) +CEntity * +CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float radius, CEntity *entityToIgnore, + bool ignoreSomeObjects) { static CColModel sphereCol; @@ -892,24 +934,27 @@ CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float rad CMatrix sphereMat; sphereMat.SetTranslate(spherePos); - for(CPtrNode *node=list.first; node; node = node->next) { - CEntity *e = (CEntity*)node->item; + for(CPtrNode *node = list.first; node; node = node->next) { + CEntity *e = (CEntity *)node->item; - if (e->m_scanCode != GetCurrentScanCode()) { + if(e->m_scanCode != GetCurrentScanCode()) { e->m_scanCode = GetCurrentScanCode(); - if (e != entityToIgnore && e->bUsesCollision && !(ignoreSomeObjects && CameraToIgnoreThisObject(e))) { + if(e != entityToIgnore && e->bUsesCollision && + !(ignoreSomeObjects && CameraToIgnoreThisObject(e))) { CVector diff = spherePos - e->GetPosition(); float distance = diff.Magnitude(); - if (e->GetBoundRadius() + radius > distance) { + if(e->GetBoundRadius() + radius > distance) { CColModel *eCol = CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel(); - int collidedSpheres = CCollision::ProcessColModels(sphereMat, sphereCol, e->GetMatrix(), - *eCol, gaTempSphereColPoints, nil, nil); - - if (collidedSpheres != 0 || - (e->IsVehicle() && ((CVehicle*)e)->m_vehType == VEHICLE_TYPE_CAR && - e->m_modelIndex != MI_DODO && radius + eCol->boundingBox.max.x > distance)) { + int collidedSpheres = + CCollision::ProcessColModels(sphereMat, sphereCol, e->GetMatrix(), *eCol, + gaTempSphereColPoints, nil, nil); + + if(collidedSpheres != 0 || + (e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR && + e->m_modelIndex != MI_DODO && + radius + eCol->boundingBox.max.x > distance)) { return e; } } @@ -925,7 +970,8 @@ CWorld::FindGroundZForCoord(float x, float y) { CColPoint point; CEntity *ent; - if(ProcessVerticalLine(CVector(x, y, 1000.0f), -1000.0f, point, ent, true, false, false, false, true, false, nil)) + if(ProcessVerticalLine(CVector(x, y, 1000.0f), -1000.0f, point, ent, true, false, false, false, true, false, + nil)) return point.point.z; else return 20.0f; @@ -936,13 +982,11 @@ CWorld::FindGroundZFor3DCoord(float x, float y, float z, bool *found) { CColPoint point; CEntity *ent; - if(ProcessVerticalLine(CVector(x, y, z), -1000.0f, point, ent, true, false, false, false, false, false, nil)){ - if(found) - *found = true; + if(ProcessVerticalLine(CVector(x, y, z), -1000.0f, point, ent, true, false, false, false, false, false, nil)) { + if(found) *found = true; return point.point.z; - }else{ - if(found) - *found = false; + } else { + if(found) *found = false; return 0.0f; } } @@ -952,51 +996,49 @@ CWorld::FindRoofZFor3DCoord(float x, float y, float z, bool *found) { CColPoint point; CEntity *ent; - if(ProcessVerticalLine(CVector(x, y, z), 1000.0f, point, ent, true, false, false, false, true, false, nil)){ - if(found) - *found = true; + if(ProcessVerticalLine(CVector(x, y, z), 1000.0f, point, ent, true, false, false, false, true, false, nil)) { + if(found) *found = true; return point.point.z; - }else{ + } else { if(found == nil) - printf("THERE IS NO MAP BELOW THE FOLLOWING COORS:%f %f %f. (FindGroundZFor3DCoord)\n", x, y, z); - if(found) - *found = false; + printf("THERE IS NO MAP BELOW THE FOLLOWING COORS:%f %f %f. (FindGroundZFor3DCoord)\n", x, y, + z); + if(found) *found = false; return 20.0f; } } -void -CWorld::RemoveReferencesToDeletedObject(CEntity* pDeletedObject) -{ +void +CWorld::RemoveReferencesToDeletedObject(CEntity *pDeletedObject) +{ int32 i = CPools::GetPedPool()->GetSize(); - while (--i >= 0) { - CPed* pPed = CPools::GetPedPool()->GetSlot(i); - if (pPed && pPed != pDeletedObject) { + while(--i >= 0) { + CPed *pPed = CPools::GetPedPool()->GetSlot(i); + if(pPed && pPed != pDeletedObject) { pPed->RemoveRefsToEntity(pDeletedObject); - if (pPed->m_pCurrentPhysSurface == pDeletedObject) - pPed->m_pCurrentPhysSurface = nil; + if(pPed->m_pCurrentPhysSurface == pDeletedObject) pPed->m_pCurrentPhysSurface = nil; } } i = CPools::GetVehiclePool()->GetSize(); - while (--i >= 0) { - CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); - if (pVehicle && pVehicle != pDeletedObject) { + while(--i >= 0) { + CVehicle *pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if(pVehicle && pVehicle != pDeletedObject) { pVehicle->RemoveRefsToEntity(pDeletedObject); pVehicle->RemoveRefsToVehicle(pDeletedObject); } } i = CPools::GetObjectPool()->GetSize(); - while (--i >= 0) { - CObject* pObject = CPools::GetObjectPool()->GetSlot(i); - if (pObject && pObject != pDeletedObject) { - pObject->RemoveRefsToEntity(pDeletedObject); - } + while(--i >= 0) { + CObject *pObject = CPools::GetObjectPool()->GetSlot(i); + if(pObject && pObject != pDeletedObject) { pObject->RemoveRefsToEntity(pDeletedObject); } } } -void -CWorld::FindObjectsKindaColliding(const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) -{ +void +CWorld::FindObjectsKindaColliding(const CVector &position, float radius, bool bCheck2DOnly, int16 *nCollidingEntities, + int16 maxEntitiesToFind, CEntity **aEntities, bool bBuildings, bool bVehicles, + bool bPeds, bool bObjects, bool bDummies) +{ CWorld::AdvanceCurrentScanCode(); *nCollidingEntities = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); @@ -1005,48 +1047,68 @@ CWorld::FindObjectsKindaColliding(const CVector& position, float radius, bool bC const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - if (bBuildings) { - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - } - if (bVehicles) { - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - } - if (bPeds) { - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - } - if (bObjects) { - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - } - if (bDummies) { - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); - CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, nCollidingEntities, maxEntitiesToFind, aEntities); + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + if(bBuildings) { + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + } + if(bVehicles) { + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + } + if(bPeds) { + CWorld::FindObjectsKindaCollidingSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, + radius, bCheck2DOnly, nCollidingEntities, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + } + if(bObjects) { + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + } + if(bDummies) { + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_DUMMIES], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); + CWorld::FindObjectsKindaCollidingSectorList( + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], position, radius, bCheck2DOnly, + nCollidingEntities, maxEntitiesToFind, aEntities); } } } } -void -CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nCollidingEntities, int16 maxEntitiesToFind, CEntity** aEntities) +void +CWorld::FindObjectsKindaCollidingSectorList(CPtrList &list, const CVector &position, float radius, bool bCheck2DOnly, + int16 *nCollidingEntities, int16 maxEntitiesToFind, CEntity **aEntities) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != GetCurrentScanCode()) { + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; + if(pEntity->m_scanCode != GetCurrentScanCode()) { pEntity->m_scanCode = GetCurrentScanCode(); float fMagnitude = 0.0f; - if (bCheck2DOnly) + if(bCheck2DOnly) fMagnitude = (position - pEntity->GetPosition()).Magnitude2D(); else fMagnitude = (position - pEntity->GetPosition()).Magnitude(); - if (pEntity->GetBoundRadius() + radius > fMagnitude && *nCollidingEntities < maxEntitiesToFind) { - if (aEntities) - aEntities[*nCollidingEntities] = pEntity; + if(pEntity->GetBoundRadius() + radius > fMagnitude && *nCollidingEntities < maxEntitiesToFind) { + if(aEntities) aEntities[*nCollidingEntities] = pEntity; ++*nCollidingEntities; } } @@ -1054,65 +1116,90 @@ CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& posit } void -CWorld::FindObjectsIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) -{ +CWorld::FindObjectsIntersectingCube(const CVector &vecStartPos, const CVector &vecEndPos, int16 *nIntersecting, + int16 maxEntitiesToFind, CEntity **aEntities, bool bBuildings, bool bVehicles, + bool bPeds, bool bObjects, bool bDummies) +{ CWorld::AdvanceCurrentScanCode(); *nIntersecting = 0; const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - if (bBuildings) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - } - if (bVehicles) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - } - if (bPeds) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - } - if (bObjects) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - } - if (bDummies) { - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities); + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + if(bBuildings) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], + vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], vecStartPos, vecEndPos, + nIntersecting, maxEntitiesToFind, aEntities); + } + if(bVehicles) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], + vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, + nIntersecting, maxEntitiesToFind, aEntities); + } + if(bPeds) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], + vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], + vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + } + if(bObjects) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], + vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + } + if(bDummies) { + CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], + vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities); } } } - } -void -CWorld::FindObjectsIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities) +void +CWorld::FindObjectsIntersectingCubeSectorList(CPtrList &list, const CVector &vecStartPos, const CVector &vecEndPos, + int16 *nIntersecting, int16 maxEntitiesToFind, CEntity **aEntities) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != GetCurrentScanCode()) { - pEntity->m_scanCode = GetCurrentScanCode(); - float fRadius = pEntity->GetBoundRadius(); - const CVector& entityPos = pEntity->GetPosition(); - if (fRadius + entityPos.x >= vecStartPos.x && entityPos.x - fRadius <= vecEndPos.x && - fRadius + entityPos.y >= vecStartPos.y && entityPos.y - fRadius <= vecEndPos.y && - fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z && - *nIntersecting < maxEntitiesToFind) { - if (aEntities) - aEntities[*nIntersecting] = pEntity; - ++*nIntersecting; - } + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; + if(pEntity->m_scanCode != GetCurrentScanCode()) { + pEntity->m_scanCode = GetCurrentScanCode(); + float fRadius = pEntity->GetBoundRadius(); + const CVector &entityPos = pEntity->GetPosition(); + if(fRadius + entityPos.x >= vecStartPos.x && entityPos.x - fRadius <= vecEndPos.x && + fRadius + entityPos.y >= vecStartPos.y && entityPos.y - fRadius <= vecEndPos.y && + fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z && + *nIntersecting < maxEntitiesToFind) { + if(aEntities) aEntities[*nIntersecting] = pEntity; + ++*nIntersecting; } + } } } -void -CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox& boundingBox, const CMatrix& matrix, const CVector& position, float fStartX, float fStartY, float fEndX, float fEndY, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies) +void +CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &boundingBox, const CMatrix &matrix, + const CVector &position, float fStartX, float fStartY, float fEndX, + float fEndY, int16 *nEntitiesFound, int16 maxEntitiesToFind, + CEntity **aEntities, bool bBuildings, bool bVehicles, bool bPeds, + bool bObjects, bool bDummies) { CWorld::AdvanceCurrentScanCode(); *nEntitiesFound = 0; @@ -1120,47 +1207,69 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox& boundingBox, co const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - if (bBuildings) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bVehicles) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bPeds) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_PEDS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bObjects) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - } - if (bDummies) { - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_DUMMIES], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); - CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], boundingBox, matrix, position, nEntitiesFound, maxEntitiesToFind, aEntities); + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + if(bBuildings) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_BUILDINGS], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bVehicles) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bPeds) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_PEDS], boundingBox, matrix, position, nEntitiesFound, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bObjects) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS], boundingBox, matrix, position, nEntitiesFound, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); + } + if(bDummies) { + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_DUMMIES], boundingBox, matrix, position, nEntitiesFound, + maxEntitiesToFind, aEntities); + CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( + pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], boundingBox, matrix, position, + nEntitiesFound, maxEntitiesToFind, aEntities); } } } } -void -CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, const CColBox& boundingBox, const CMatrix& matrix, const CVector& position, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities) +void +CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList &list, const CColBox &boundingBox, + const CMatrix &matrix, const CVector &position, + int16 *nEntitiesFound, int16 maxEntitiesToFind, + CEntity **aEntities) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != GetCurrentScanCode()) { + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; + if(pEntity->m_scanCode != GetCurrentScanCode()) { pEntity->m_scanCode = GetCurrentScanCode(); CColSphere sphere; CVector vecDistance = pEntity->GetPosition() - position; sphere.radius = pEntity->GetBoundRadius(); sphere.center = Multiply3x3(vecDistance, matrix); - if (CCollision::TestSphereBox(sphere, boundingBox) && *nEntitiesFound < maxEntitiesToFind) { - if (aEntities) - aEntities[*nEntitiesFound] = pEntity; + if(CCollision::TestSphereBox(sphere, boundingBox) && *nEntitiesFound < maxEntitiesToFind) { + if(aEntities) aEntities[*nEntitiesFound] = pEntity; ++*nEntitiesFound; } } @@ -1168,7 +1277,9 @@ CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, cons } void -CWorld::FindMissionEntitiesIntersectingCube(const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bVehicles, bool bPeds, bool bObjects) +CWorld::FindMissionEntitiesIntersectingCube(const CVector &vecStartPos, const CVector &vecEndPos, int16 *nIntersecting, + int16 maxEntitiesToFind, CEntity **aEntities, bool bVehicles, bool bPeds, + bool bObjects) { CWorld::AdvanceCurrentScanCode(); *nIntersecting = 0; @@ -1176,70 +1287,82 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector& vecStartPos, const CV const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - if (bVehicles) { - CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, true, false); - CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, true, false); + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + if(bVehicles) { + CWorld::FindMissionEntitiesIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities, true, false); + CWorld::FindMissionEntitiesIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], vecStartPos, vecEndPos, + nIntersecting, maxEntitiesToFind, aEntities, true, false); } - if (bPeds) { - CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, true); - CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, true); + if(bPeds) { + CWorld::FindMissionEntitiesIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_PEDS], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities, false, true); + CWorld::FindMissionEntitiesIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities, false, true); } - if (bObjects) { - CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, false); - CWorld::FindMissionEntitiesIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, maxEntitiesToFind, aEntities, false, false); + if(bObjects) { + CWorld::FindMissionEntitiesIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities, false, false); + CWorld::FindMissionEntitiesIntersectingCubeSectorList( + pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], vecStartPos, vecEndPos, nIntersecting, + maxEntitiesToFind, aEntities, false, false); } } } } void -CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVector& vecStartPos, const CVector& vecEndPos, int16* nIntersecting, int16 maxEntitiesToFind, CEntity** aEntities, bool bIsVehicleList, bool bIsPedList) +CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList &list, const CVector &vecStartPos, + const CVector &vecEndPos, int16 *nIntersecting, + int16 maxEntitiesToFind, CEntity **aEntities, bool bIsVehicleList, + bool bIsPedList) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; - if (pEntity->m_scanCode != GetCurrentScanCode()) { + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; + if(pEntity->m_scanCode != GetCurrentScanCode()) { pEntity->m_scanCode = GetCurrentScanCode(); bool bIsMissionEntity = false; - if (bIsVehicleList) - bIsMissionEntity = ((CVehicle*)pEntity)->VehicleCreatedBy == MISSION_VEHICLE; - else if (bIsPedList) - bIsMissionEntity = ((CPed*)pEntity)->CharCreatedBy == MISSION_CHAR; + if(bIsVehicleList) + bIsMissionEntity = ((CVehicle *)pEntity)->VehicleCreatedBy == MISSION_VEHICLE; + else if(bIsPedList) + bIsMissionEntity = ((CPed *)pEntity)->CharCreatedBy == MISSION_CHAR; else - bIsMissionEntity = ((CObject*)pEntity)->ObjectCreatedBy == MISSION_OBJECT; + bIsMissionEntity = ((CObject *)pEntity)->ObjectCreatedBy == MISSION_OBJECT; float fRadius = pEntity->GetBoundRadius(); - const CVector& entityPos = pEntity->GetPosition(); - if (bIsMissionEntity && - fRadius + entityPos.x >= vecStartPos.x && entityPos.x - fRadius <= vecEndPos.x && - fRadius + entityPos.y >= vecStartPos.y && entityPos.y - fRadius <= vecEndPos.y && - fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z && - *nIntersecting < maxEntitiesToFind) { - if (aEntities) - aEntities[*nIntersecting] = pEntity; + const CVector &entityPos = pEntity->GetPosition(); + if(bIsMissionEntity && fRadius + entityPos.x >= vecStartPos.x && + entityPos.x - fRadius <= vecEndPos.x && fRadius + entityPos.y >= vecStartPos.y && + entityPos.y - fRadius <= vecEndPos.y && fRadius + entityPos.z >= vecStartPos.z && + entityPos.z - fRadius <= vecEndPos.z && *nIntersecting < maxEntitiesToFind) { + if(aEntities) aEntities[*nIntersecting] = pEntity; ++*nIntersecting; } } } } -CPlayerPed* +CPlayerPed * FindPlayerPed(void) { return CWorld::Players[CWorld::PlayerInFocus].m_pPed; } -CVehicle* +CVehicle * FindPlayerVehicle(void) { CPlayerPed *ped = FindPlayerPed(); - if(ped && ped->InVehicle()) - return ped->m_pMyVehicle; + if(ped && ped->InVehicle()) return ped->m_pMyVehicle; return nil; } -CVehicle* +CVehicle * FindPlayerTrain(void) { if(FindPlayerVehicle() && FindPlayerVehicle()->IsTrain()) @@ -1248,7 +1371,7 @@ FindPlayerTrain(void) return nil; } -CEntity* +CEntity * FindPlayerEntity(void) { CPlayerPed *ped = FindPlayerPed(); @@ -1268,7 +1391,7 @@ FindPlayerCoors(void) return ped->GetPosition(); } -CVector& +CVector & FindPlayerSpeed(void) { CPlayerPed *ped = FindPlayerPed(); @@ -1278,27 +1401,22 @@ FindPlayerSpeed(void) return ped->m_vecMoveSpeed; } -CVector& +CVector & FindPlayerCentreOfWorld(int32 player) { - if(CCarCtrl::bCarsGeneratedAroundCamera) - return TheCamera.GetPosition(); - if(CWorld::Players[player].m_pRemoteVehicle) - return CWorld::Players[player].m_pRemoteVehicle->GetPosition(); - if(FindPlayerVehicle()) - return FindPlayerVehicle()->GetPosition(); + if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition(); + if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition(); + if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition(); return CWorld::Players[player].m_pPed->GetPosition(); } -CVector& +CVector & FindPlayerCentreOfWorld_NoSniperShift(void) { - if(CCarCtrl::bCarsGeneratedAroundCamera) - return TheCamera.GetPosition(); + if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition(); if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle) return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition(); - if(FindPlayerVehicle()) - return FindPlayerVehicle()->GetPosition(); + if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition(); return FindPlayerPed()->GetPosition(); } @@ -1307,29 +1425,26 @@ FindPlayerHeading(void) { if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle) return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetForward().Heading(); - if(FindPlayerVehicle()) - return FindPlayerVehicle()->GetForward().Heading(); + if(FindPlayerVehicle()) return FindPlayerVehicle()->GetForward().Heading(); return FindPlayerPed()->GetForward().Heading(); } - -void CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2) +void +CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2) { CVehiclePool *pVehiclePool = CPools::GetVehiclePool(); - for (int32 i = 0; i < pVehiclePool->GetSize(); i++) { - CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); - if (pVehicle) { - const CVector& position = pVehicle->GetPosition(); - if (position.x >= x1 && position.x <= x2 && - position.y >= y1 && position.y <= y2 && - position.z >= z1 && position.z <= z2 && - !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { - if (pVehicle->pDriver) { + for(int32 i = 0; i < pVehiclePool->GetSize(); i++) { + CVehicle *pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if(pVehicle) { + const CVector &position = pVehicle->GetPosition(); + if(position.x >= x1 && position.x <= x2 && position.y >= y1 && position.y <= y2 && + position.z >= z1 && position.z <= z2 && !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { + if(pVehicle->pDriver) { CPopulation::RemovePed(pVehicle->pDriver); pVehicle->pDriver = nil; } - for (int32 j = 0; j < pVehicle->m_nNumMaxPassengers; ++j) { - if (pVehicle->pPassengers[j]) { + for(int32 j = 0; j < pVehicle->m_nNumMaxPassengers; ++j) { + if(pVehicle->pPassengers[j]) { CPopulation::RemovePed(pVehicle->pPassengers[j]); pVehicle->pPassengers[j] = nil; --pVehicle->m_nNumPassengers; @@ -1343,25 +1458,23 @@ void CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, } } -void +void CWorld::ClearPedsFromArea(float x1, float y1, float z1, float x2, float y2, float z2) { - CPedPool* pPedPool = CPools::GetPedPool(); - for (int32 i = 0; i < pPedPool->GetSize(); i++) { - CPed* pPed = CPools::GetPedPool()->GetSlot(i); - if (pPed) { - const CVector& position = pPed->GetPosition(); - if (!pPed->IsPlayer() && pPed->CanBeDeleted() && - position.x >= x1 && position.x <= x2 && - position.y >= y1 && position.y <= y2 && - position.z >= z1 && position.z <= z2) { + CPedPool *pPedPool = CPools::GetPedPool(); + for(int32 i = 0; i < pPedPool->GetSize(); i++) { + CPed *pPed = CPools::GetPedPool()->GetSlot(i); + if(pPed) { + const CVector &position = pPed->GetPosition(); + if(!pPed->IsPlayer() && pPed->CanBeDeleted() && position.x >= x1 && position.x <= x2 && + position.y >= y1 && position.y <= y2 && position.z >= z1 && position.z <= z2) { CPopulation::RemovePed(pPed); } } } } -void +void CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) { CWorld::AdvanceCurrentScanCode(); @@ -1373,49 +1486,51 @@ CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); - CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES], x1, y1, x2, + y2, fStartX, fStartY, fEndX, fEndY); + CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], x1, + y1, x2, y2, fStartX, fStartY, fEndX, fEndY); CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS], x1, y1, x2, y2); - CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], x1, y1, x2, y2); + CWorld::CallOffChaseForAreaSectorListPeds(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP], x1, y1, x2, + y2); } } } -void -CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1, float x2, float y2, float fStartX, float fStartY, float fEndX, float fEndY) +void +CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1, float x2, float y2, float fStartX, + float fStartY, float fEndX, float fEndY) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CVehicle *pVehicle = (CVehicle*)pNode->item; - if (pVehicle->m_scanCode != GetCurrentScanCode()) { + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CVehicle *pVehicle = (CVehicle *)pNode->item; + if(pVehicle->m_scanCode != GetCurrentScanCode()) { pVehicle->m_scanCode = GetCurrentScanCode(); - const CVector& vehiclePos = pVehicle->GetPosition(); + const CVector &vehiclePos = pVehicle->GetPosition(); eCarMission carMission = pVehicle->AutoPilot.m_nCarMission; - if (pVehicle != FindPlayerVehicle() && - vehiclePos.x > fStartX && vehiclePos.x < fEndX && - vehiclePos.y > fStartY && vehiclePos.y < fEndY && - pVehicle->bIsLawEnforcer && - (carMission == MISSION_RAMPLAYER_FARAWAY || carMission == MISSION_RAMPLAYER_CLOSE || - carMission == MISSION_BLOCKPLAYER_FARAWAY || carMission == MISSION_BLOCKPLAYER_CLOSE) - ) { + if(pVehicle != FindPlayerVehicle() && vehiclePos.x > fStartX && vehiclePos.x < fEndX && + vehiclePos.y > fStartY && vehiclePos.y < fEndY && pVehicle->bIsLawEnforcer && + (carMission == MISSION_RAMPLAYER_FARAWAY || carMission == MISSION_RAMPLAYER_CLOSE || + carMission == MISSION_BLOCKPLAYER_FARAWAY || carMission == MISSION_BLOCKPLAYER_CLOSE)) { pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 2000; - CColModel* pColModel = pVehicle->GetColModel(); + CColModel *pColModel = pVehicle->GetColModel(); bool bInsideSphere = false; - for (int32 i = 0; i < pColModel->numSpheres; i++) { + for(int32 i = 0; i < pColModel->numSpheres; i++) { CVector pos = pVehicle->m_matrix * pColModel->spheres[i].center; float fRadius = pColModel->spheres[i].radius; - if (pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 && pos.y - fRadius < y2) + if(pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 && + pos.y - fRadius < y2) bInsideSphere = true; // Maybe break the loop when bInsideSphere is set to true? } - if (bInsideSphere) { - if (pVehicle->GetPosition().x <= (x1 + x2) * 0.5f) + if(bInsideSphere) { + if(pVehicle->GetPosition().x <= (x1 + x2) * 0.5f) pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f); else pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f); - if (pVehicle->GetPosition().y <= (y1 + y2) * 0.5f) + if(pVehicle->GetPosition().y <= (y1 + y2) * 0.5f) pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f); else pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f); @@ -1425,31 +1540,29 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1 } } -void -CWorld::CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, float x2, float y2) +void +CWorld::CallOffChaseForAreaSectorListPeds(CPtrList &list, float x1, float y1, float x2, float y2) { - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CPed* pPed = (CPed*)pNode->item; - const CVector& pedPos = pPed->GetPosition(); - if (pPed->m_scanCode != GetCurrentScanCode()) - { + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CPed *pPed = (CPed *)pNode->item; + const CVector &pedPos = pPed->GetPosition(); + if(pPed->m_scanCode != GetCurrentScanCode()) { pPed->m_scanCode = GetCurrentScanCode(); - if (pPed != FindPlayerPed() && pPed->m_leader != FindPlayerPed() && - pedPos.x > x1 && pedPos.x < x2 && - pedPos.y > y1 && pedPos.y < y2 && - (pPed->m_pedInObjective == FindPlayerPed() || pPed->m_carInObjective && pPed->m_carInObjective == FindPlayerVehicle()) && - pPed->m_nPedState != PED_DEAD && pPed->m_nPedState != PED_DIE && - (pPed->m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || - pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || - pPed->m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS)) { - if (pPed->IsPedInControl()) { - if (pPed->m_nPedType == PEDTYPE_COP) - ((CCopPed*)pPed)->ClearPursuit(); + if(pPed != FindPlayerPed() && pPed->m_leader != FindPlayerPed() && pedPos.x > x1 && + pedPos.x < x2 && pedPos.y > y1 && pedPos.y < y2 && + (pPed->m_pedInObjective == FindPlayerPed() || + pPed->m_carInObjective && pPed->m_carInObjective == FindPlayerVehicle()) && + pPed->m_nPedState != PED_DEAD && pPed->m_nPedState != PED_DIE && + (pPed->m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || + pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || + pPed->m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS)) { + if(pPed->IsPedInControl()) { + if(pPed->m_nPedType == PEDTYPE_COP) + ((CCopPed *)pPed)->ClearPursuit(); else pPed->SetIdle(); pPed->SetObjective(OBJECTIVE_NONE); - } - else { + } else { pPed->m_prevObjective = OBJECTIVE_NONE; pPed->m_nLastPedState = PED_IDLE; } @@ -1459,13 +1572,13 @@ CWorld::CallOffChaseForAreaSectorListPeds(CPtrList& list, float x1, float y1, fl } void -CWorld::RemoveEntityInsteadOfProcessingIt(CEntity* ent) +CWorld::RemoveEntityInsteadOfProcessingIt(CEntity *ent) { - if (ent->IsPed()) { - if (FindPlayerPed() == ent) + if(ent->IsPed()) { + if(FindPlayerPed() == ent) Remove(ent); else - CPopulation::RemovePed((CPed*)ent); + CPopulation::RemovePed((CPed *)ent); } else { Remove(ent); delete ent; @@ -1476,12 +1589,13 @@ void CWorld::RemoveFallenPeds(void) { int poolSize = CPools::GetPedPool()->GetSize(); - for(int poolIndex = poolSize-1; poolIndex >= 0; poolIndex--) { + for(int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex); - if (ped) { - if (ped->GetPosition().z < MAP_Z_LOW_LIMIT) { - if (ped->CharCreatedBy != RANDOM_CHAR || ped->IsPlayer()) { - int closestNode = ThePaths.FindNodeClosestToCoors(ped->GetPosition(), PATH_PED, 999999.9f, false, false); + if(ped) { + if(ped->GetPosition().z < MAP_Z_LOW_LIMIT) { + if(ped->CharCreatedBy != RANDOM_CHAR || ped->IsPlayer()) { + int closestNode = ThePaths.FindNodeClosestToCoors(ped->GetPosition(), PATH_PED, + 999999.9f, false, false); CVector newPos = ThePaths.m_pathNodes[closestNode].pos; newPos.z += 2.0f; ped->Teleport(newPos); @@ -1498,17 +1612,20 @@ void CWorld::RemoveFallenCars(void) { int poolSize = CPools::GetVehiclePool()->GetSize(); - for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { - CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh) { - if (veh->GetPosition().z < MAP_Z_LOW_LIMIT) { - if (veh->VehicleCreatedBy == MISSION_VEHICLE || veh == FindPlayerVehicle() || (veh->pDriver && veh->pDriver->IsPlayer())) { - int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR, 999999.9f, false, false); + for(int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { + CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex); + if(veh) { + if(veh->GetPosition().z < MAP_Z_LOW_LIMIT) { + if(veh->VehicleCreatedBy == MISSION_VEHICLE || veh == FindPlayerVehicle() || + (veh->pDriver && veh->pDriver->IsPlayer())) { + int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR, + 999999.9f, false, false); CVector newPos = ThePaths.m_pathNodes[closestNode].pos; newPos.z += 3.0f; veh->Teleport(newPos); veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - } else if (veh->VehicleCreatedBy == RANDOM_VEHICLE || veh->VehicleCreatedBy == PARKED_VEHICLE) { + } else if(veh->VehicleCreatedBy == RANDOM_VEHICLE || + veh->VehicleCreatedBy == PARKED_VEHICLE) { Remove(veh); delete veh; } @@ -1521,11 +1638,10 @@ void CWorld::StopAllLawEnforcersInTheirTracks(void) { int poolSize = CPools::GetVehiclePool()->GetSize(); - for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { - CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh) { - if (veh->bIsLawEnforcer) - veh->SetMoveSpeed(0.0f, 0.0f, 0.0f); + for(int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { + CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex); + if(veh) { + if(veh->bIsLawEnforcer) veh->SetMoveSpeed(0.0f, 0.0f, 0.0f); } } } @@ -1534,10 +1650,9 @@ void CWorld::SetAllCarsCanBeDamaged(bool toggle) { int poolSize = CPools::GetVehiclePool()->GetSize(); - for (int poolIndex = 0; poolIndex < poolSize; poolIndex++) { + for(int poolIndex = 0; poolIndex < poolSize; poolIndex++) { CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh) - veh->bCanBeDamaged = toggle; + if(veh) veh->bCanBeDamaged = toggle; } } @@ -1545,54 +1660,53 @@ void CWorld::ExtinguishAllCarFiresInArea(CVector point, float range) { int poolSize = CPools::GetVehiclePool()->GetSize(); - for (int poolIndex = 0; poolIndex < poolSize; poolIndex++) { - CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh) { - if ((point - veh->GetPosition()).MagnitudeSqr() < sq(range)) - veh->ExtinguishCarFire(); + for(int poolIndex = 0; poolIndex < poolSize; poolIndex++) { + CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex); + if(veh) { + if((point - veh->GetPosition()).MagnitudeSqr() < sq(range)) veh->ExtinguishCarFire(); } } } -void -CWorld::AddParticles(void) +void +CWorld::AddParticles(void) { - for (int32 y = 0; y < NUMSECTORS_Y; y++) { - for (int32 x = 0; x < NUMSECTORS_X; x++) { - CSector* pSector = GetSector(x, y); + for(int32 y = 0; y < NUMSECTORS_Y; y++) { + for(int32 x = 0; x < NUMSECTORS_X; x++) { + CSector *pSector = GetSector(x, y); CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]); CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]); } } } -void +void CWorld::ShutDown(void) { - for (int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); - for (CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { - CEntity *pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { - CEntity *pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { - CEntity *pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } @@ -1601,41 +1715,41 @@ CWorld::ShutDown(void) pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); } - for (int32 i = 0; i < 4; i ++) { - for (CPtrNode* pNode = GetBigBuildingList((eLevelName)i).first; pNode; pNode = pNode->next) { - CEntity *pEntity = (CEntity*)pNode->item; + for(int32 i = 0; i < 4; i++) { + for(CPtrNode *pNode = GetBigBuildingList((eLevelName)i).first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; // Maybe remove from world here? delete pEntity; } GetBigBuildingList((eLevelName)i).Flush(); } - for (int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); - if (pSector->m_lists[ENTITYLIST_BUILDINGS].first) { + if(pSector->m_lists[ENTITYLIST_BUILDINGS].first) { sprintf(gString, "Building list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_BUILDINGS].Flush(); } - if (pSector->m_lists[ENTITYLIST_DUMMIES].first) { + if(pSector->m_lists[ENTITYLIST_DUMMIES].first) { sprintf(gString, "Dummy list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_DUMMIES].Flush(); } - if (pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first) { + if(pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first) { sprintf(gString, "Building overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush(); } - if (pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].first) { + if(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].first) { sprintf(gString, "Vehicle overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP].Flush(); } - if (pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].first) { + if(pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].first) { sprintf(gString, "Ped overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_PEDS_OVERLAP].Flush(); } - if (pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].first) { + if(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].first) { sprintf(gString, "Object overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP].Flush(); } - if (pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first) { + if(pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].first) { sprintf(gString, "Dummy overlap list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y); pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush(); } @@ -1643,31 +1757,30 @@ CWorld::ShutDown(void) ms_listMovingEntityPtrs.Flush(); } -void -CWorld::ClearForRestart(void) +void +CWorld::ClearForRestart(void) { - if (CCutsceneMgr::HasLoaded()) - CCutsceneMgr::DeleteCutsceneData(); + if(CCutsceneMgr::HasLoaded()) CCutsceneMgr::DeleteCutsceneData(); CProjectileInfo::RemoveAllProjectiles(); CObject::DeleteAllTempObjects(); CObject::DeleteAllMissionObjects(); CPopulation::ConvertAllObjectsToDummyObjects(); - for (int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { - CSector* pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { - CEntity *pEntity = (CEntity*)pNode->item; + for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { + CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_PEDS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = GetBigBuildingList(LEVEL_NONE).first; pNode; pNode = pNode->next) { - CVehicle *pVehicle = (CVehicle*)pNode->item; - if (pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { + for(CPtrNode *pNode = GetBigBuildingList(LEVEL_NONE).first; pNode; pNode = pNode->next) { + CVehicle *pVehicle = (CVehicle *)pNode->item; + if(pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { CWorld::Remove(pVehicle); delete pVehicle; } } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_VEHICLES].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } @@ -1675,75 +1788,50 @@ CWorld::ClearForRestart(void) CPools::CheckPoolsEmpty(); } -void -CWorld::RepositionCertainDynamicObjects() -{ +void +CWorld::RepositionCertainDynamicObjects() +{ int32 i = CPools::GetDummyPool()->GetSize(); - while (--i >= 0) { - CDummy* dummy = CPools::GetDummyPool()->GetSlot(i); - if (dummy) { - RepositionOneObject(dummy); - } + while(--i >= 0) { + CDummy *dummy = CPools::GetDummyPool()->GetSlot(i); + if(dummy) { RepositionOneObject(dummy); } } } void -CWorld::RepositionOneObject(CEntity* pEntity) +CWorld::RepositionOneObject(CEntity *pEntity) { int16 modelId = pEntity->m_modelIndex; - if (modelId == MI_SINGLESTREETLIGHTS1 - || modelId == MI_SINGLESTREETLIGHTS2 - || modelId == MI_SINGLESTREETLIGHTS3 - || modelId == MI_DOUBLESTREETLIGHTS - || modelId == MI_TREE1 - || modelId == MI_TREE2 - || modelId == MI_TREE3 - || modelId == MI_TREE4 - || modelId == MI_TREE5 - || modelId == MI_TREE6 - || modelId == MI_TREE7 - || modelId == MI_TREE8 - || modelId == MI_TREE9 - || modelId == MI_TREE10 - || modelId == MI_TREE11 - || modelId == MI_TREE12 - || modelId == MI_TREE13 - || modelId == MI_TREE14 - || modelId == MI_TRAFFICLIGHTS - || modelId == MI_PARKINGMETER - || modelId == MI_PHONEBOOTH1 - || modelId == MI_WASTEBIN - || modelId == MI_BIN - || modelId == MI_POSTBOX1 - || modelId == MI_NEWSSTAND - || modelId == MI_TRAFFICCONE - || modelId == MI_DUMP1 - || modelId == MI_ROADWORKBARRIER1 - || modelId == MI_BUSSIGN1 - || modelId == MI_NOPARKINGSIGN1 - || modelId == MI_PHONESIGN - || modelId == MI_TAXISIGN - || modelId == MI_FISHSTALL01 - || modelId == MI_FISHSTALL02 - || modelId == MI_FISHSTALL03 - || modelId == MI_FISHSTALL04 - || modelId == MI_BAGELSTAND2 - || modelId == MI_FIRE_HYDRANT - || modelId == MI_BOLLARDLIGHT - || modelId == MI_PARKTABLE) { - CVector& position = pEntity->GetPosition(); + if(modelId == MI_SINGLESTREETLIGHTS1 || modelId == MI_SINGLESTREETLIGHTS2 || + modelId == MI_SINGLESTREETLIGHTS3 || modelId == MI_DOUBLESTREETLIGHTS || modelId == MI_TREE1 || + modelId == MI_TREE2 || modelId == MI_TREE3 || modelId == MI_TREE4 || modelId == MI_TREE5 || + modelId == MI_TREE6 || modelId == MI_TREE7 || modelId == MI_TREE8 || modelId == MI_TREE9 || + modelId == MI_TREE10 || modelId == MI_TREE11 || modelId == MI_TREE12 || modelId == MI_TREE13 || + modelId == MI_TREE14 || modelId == MI_TRAFFICLIGHTS || modelId == MI_PARKINGMETER || + modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || modelId == MI_BIN || modelId == MI_POSTBOX1 || + modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || modelId == MI_DUMP1 || + modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 || + modelId == MI_PHONESIGN || modelId == MI_TAXISIGN || modelId == MI_FISHSTALL01 || + modelId == MI_FISHSTALL02 || modelId == MI_FISHSTALL03 || modelId == MI_FISHSTALL04 || + modelId == MI_BAGELSTAND2 || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || + modelId == MI_PARKTABLE) { + CVector &position = pEntity->GetPosition(); float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z; - position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ; + position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, + position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - + fBoundingBoxMinZ; pEntity->m_matrix.UpdateRW(); pEntity->UpdateRwFrame(); - } else if (modelId == MI_BUOY) { + } else if(modelId == MI_BUOY) { float fWaterLevel = 0.0f; bool bFound = true; - const CVector& position = pEntity->GetPosition(); - float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); - if (CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) { - if (!bFound || fWaterLevel > fGroundZ) { - CColModel* pColModel = pEntity->GetColModel(); + const CVector &position = pEntity->GetPosition(); + float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, + position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); + if(CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, + &fWaterLevel)) { + if(!bFound || fWaterLevel > fGroundZ) { + CColModel *pColModel = pEntity->GetColModel(); float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; pEntity->GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; } @@ -1755,45 +1843,47 @@ void CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason) { int poolSize = CPools::GetVehiclePool()->GetSize(); - for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { + for(int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh && veh->m_status != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) { - if (Abs(veh->GetPosition().z - z) < 5.0f && Abs(veh->GetPosition().x - x) < radius && Abs(veh->GetPosition().y - y) < radius) - gFireManager.StartFire(veh, reason, 0.8f, true); + if(veh && veh->m_status != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) { + if(Abs(veh->GetPosition().z - z) < 5.0f && Abs(veh->GetPosition().x - x) < radius && + Abs(veh->GetPosition().y - y) < radius) + gFireManager.StartFire(veh, reason, 0.8f, true); } } } -void -CWorld::SetPedsOnFire(float x, float y, float z, float radius, CEntity* reason) +void +CWorld::SetPedsOnFire(float x, float y, float z, float radius, CEntity *reason) { int32 poolSize = CPools::GetPedPool()->GetSize(); - for (int32 i = poolSize - 1; i >= 0; i--) { - CPed* pPed = CPools::GetPedPool()->GetSlot(i); - if (pPed && pPed->m_nPedState != PED_DEAD && !pPed->bInVehicle && !pPed->m_pFire && !pPed->bFireProof) { - if (Abs(pPed->GetPosition().z - z) < 5.0f && Abs(pPed->GetPosition().x - x) < radius && Abs(pPed->GetPosition().y - y) < radius) + for(int32 i = poolSize - 1; i >= 0; i--) { + CPed *pPed = CPools::GetPedPool()->GetSlot(i); + if(pPed && pPed->m_nPedState != PED_DEAD && !pPed->bInVehicle && !pPed->m_pFire && !pPed->bFireProof) { + if(Abs(pPed->GetPosition().z - z) < 5.0f && Abs(pPed->GetPosition().x - x) < radius && + Abs(pPed->GetPosition().y - y) < radius) gFireManager.StartFire(pPed, reason, 0.8f, true); } } } -void -CWorld::RemoveStaticObjects() +void +CWorld::RemoveStaticObjects() { for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) { CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y); - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_BUILDINGS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_OBJECTS].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } - for (CPtrNode* pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { - CEntity* pEntity = (CEntity*)pNode->item; + for(CPtrNode *pNode = pSector->m_lists[ENTITYLIST_DUMMIES].first; pNode; pNode = pNode->next) { + CEntity *pEntity = (CEntity *)pNode->item; CWorld::Remove(pEntity); delete pEntity; } @@ -1807,16 +1897,18 @@ CWorld::RemoveStaticObjects() void CWorld::Process(void) { - if (!(CTimer::GetFrameCounter() & 63)) - CReferences::PruneAllReferencesInWorld(); + if(!(CTimer::GetFrameCounter() & 63)) CReferences::PruneAllReferencesInWorld(); - if (bProcessCutsceneOnly) { - for (int i = 0; i < NUMCUTSCENEOBJECTS; i++) { + if(bProcessCutsceneOnly) { + for(int i = 0; i < NUMCUTSCENEOBJECTS; i++) { CCutsceneObject *csObj = CCutsceneMgr::GetCutsceneObject(i); - if (csObj && csObj->m_entryInfoList.first) { - if (csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP - && RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) { - RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * (csObj->m_type == ENTITY_TYPE_OBJECT ? CTimer::GetTimeStepNonClipped() : CTimer::GetTimeStep())); + if(csObj && csObj->m_entryInfoList.first) { + if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP && + RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) { + RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), + 0.02f * (csObj->m_type == ENTITY_TYPE_OBJECT + ? CTimer::GetTimeStepNonClipped() + : CTimer::GetTimeStep())); } csObj->ProcessControl(); csObj->ProcessCollision(); @@ -1827,102 +1919,98 @@ CWorld::Process(void) CRecordDataForChase::ProcessControlCars(); CRecordDataForChase::SaveOrRetrieveCarPositions(); } else { - for (CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CEntity *movingEnt = (CEntity*)node->item; - if (movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP - && RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { - RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * (movingEnt->m_type == ENTITY_TYPE_OBJECT ? CTimer::GetTimeStepNonClipped() : CTimer::GetTimeStep())); - } - } - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CPhysical* movingEnt = (CPhysical*)node->item; - if (movingEnt->bRemoveFromWorld) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CEntity *movingEnt = (CEntity *)node->item; + if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP && + RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { + RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), + 0.02f * (movingEnt->m_type == ENTITY_TYPE_OBJECT + ? CTimer::GetTimeStepNonClipped() + : CTimer::GetTimeStep())); + } + } + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CPhysical *movingEnt = (CPhysical *)node->item; + if(movingEnt->bRemoveFromWorld) { RemoveEntityInsteadOfProcessingIt(movingEnt); } else { movingEnt->ProcessControl(); - if (movingEnt->bIsStatic) { - movingEnt->RemoveFromMovingList(); - } + if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); } } } bForceProcessControl = true; - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CPhysical* movingEnt = (CPhysical*)node->item; - if (movingEnt->bWasPostponed) { - if (movingEnt->bRemoveFromWorld) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CPhysical *movingEnt = (CPhysical *)node->item; + if(movingEnt->bWasPostponed) { + if(movingEnt->bRemoveFromWorld) { RemoveEntityInsteadOfProcessingIt(movingEnt); } else { movingEnt->ProcessControl(); - if (movingEnt->bIsStatic) { - movingEnt->RemoveFromMovingList(); - } + if(movingEnt->bIsStatic) { movingEnt->RemoveFromMovingList(); } } } } bForceProcessControl = false; - if (CReplay::IsPlayingBack()) { - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CEntity* movingEnt = (CEntity*)node->item; + if(CReplay::IsPlayingBack()) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CEntity *movingEnt = (CEntity *)node->item; movingEnt->bIsInSafePosition = true; movingEnt->GetMatrix().UpdateRW(); movingEnt->UpdateRwFrame(); } } else { bNoMoreCollisionTorque = false; - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CEntity* movingEnt = (CEntity*)node->item; - if (!movingEnt->bIsInSafePosition) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CEntity *movingEnt = (CEntity *)node->item; + if(!movingEnt->bIsInSafePosition) { movingEnt->ProcessCollision(); movingEnt->GetMatrix().UpdateRW(); movingEnt->UpdateRwFrame(); } } bNoMoreCollisionTorque = true; - for (int i = 0; i < 4; i++) { - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CEntity* movingEnt = (CEntity*)node->item; - if (!movingEnt->bIsInSafePosition) { + for(int i = 0; i < 4; i++) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CEntity *movingEnt = (CEntity *)node->item; + if(!movingEnt->bIsInSafePosition) { movingEnt->ProcessCollision(); movingEnt->GetMatrix().UpdateRW(); movingEnt->UpdateRwFrame(); } } } - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CEntity* movingEnt = (CEntity*)node->item; - if (!movingEnt->bIsInSafePosition) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CEntity *movingEnt = (CEntity *)node->item; + if(!movingEnt->bIsInSafePosition) { movingEnt->bIsStuck = true; movingEnt->ProcessCollision(); movingEnt->GetMatrix().UpdateRW(); movingEnt->UpdateRwFrame(); - if (!movingEnt->bIsInSafePosition) { - movingEnt->bIsStuck = true; - } + if(!movingEnt->bIsInSafePosition) { movingEnt->bIsStuck = true; } } } bSecondShift = false; - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CEntity* movingEnt = (CEntity*)node->item; - if (!movingEnt->bIsInSafePosition) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CEntity *movingEnt = (CEntity *)node->item; + if(!movingEnt->bIsInSafePosition) { movingEnt->ProcessShift(); movingEnt->GetMatrix().UpdateRW(); movingEnt->UpdateRwFrame(); - if (!movingEnt->bIsInSafePosition) { - movingEnt->bIsStuck = true; - } + if(!movingEnt->bIsInSafePosition) { movingEnt->bIsStuck = true; } } } bSecondShift = true; - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CPhysical* movingEnt = (CPhysical*)node->item; - if (!movingEnt->bIsInSafePosition) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CPhysical *movingEnt = (CPhysical *)node->item; + if(!movingEnt->bIsInSafePosition) { movingEnt->ProcessShift(); movingEnt->GetMatrix().UpdateRW(); movingEnt->UpdateRwFrame(); - if (!movingEnt->bIsInSafePosition) { + if(!movingEnt->bIsInSafePosition) { movingEnt->bIsStuck = true; - if (movingEnt->m_status == STATUS_PLAYER) { - printf("STUCK: Final Step: Player Entity %d Is Stuck\n", movingEnt->m_modelIndex); + if(movingEnt->m_status == STATUS_PLAYER) { + printf("STUCK: Final Step: Player Entity %d Is Stuck\n", + movingEnt->m_modelIndex); movingEnt->m_vecMoveSpeed *= 0.3f; movingEnt->ApplyMoveSpeed(); movingEnt->ApplyTurnSpeed(); @@ -1931,35 +2019,28 @@ CWorld::Process(void) } } } - for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) { - CPed* movingPed = (CPed*)node->item; - if (movingPed->IsPed()) { - if (movingPed->bInVehicle && movingPed->m_nPedState != PED_EXIT_TRAIN || movingPed->EnteringCar()) { + for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { + CPed *movingPed = (CPed *)node->item; + if(movingPed->IsPed()) { + if(movingPed->bInVehicle && movingPed->m_nPedState != PED_EXIT_TRAIN || + movingPed->EnteringCar()) { CVehicle *movingCar = movingPed->m_pMyVehicle; - if (movingCar) { - if (movingCar->IsTrain()) { + if(movingCar) { + if(movingCar->IsTrain()) { movingPed->SetPedPositionInTrain(); } else { - switch (movingPed->m_nPedState) { - case PED_ENTER_CAR: - case PED_CARJACK: - movingPed->EnterCar(); - break; - case PED_DRAG_FROM_CAR: + switch(movingPed->m_nPedState) { + case PED_ENTER_CAR: + case PED_CARJACK: movingPed->EnterCar(); break; + case PED_DRAG_FROM_CAR: movingPed->BeingDraggedFromCar(); break; + case PED_EXIT_CAR: movingPed->ExitCar(); break; + case PED_ARRESTED: + if(movingPed->m_nLastPedState == PED_DRAG_FROM_CAR) { movingPed->BeingDraggedFromCar(); break; - case PED_EXIT_CAR: - movingPed->ExitCar(); - break; - case PED_ARRESTED: - if (movingPed->m_nLastPedState == PED_DRAG_FROM_CAR) { - movingPed->BeingDraggedFromCar(); - break; - } - // fall through - default: - movingPed->SetPedPositionInCar(); - break; + } + // fall through + default: movingPed->SetPedPositionInCar(); break; } } movingPed->GetMatrix().UpdateRW(); @@ -1974,16 +2055,17 @@ CWorld::Process(void) CMessages::Process(); Players[PlayerInFocus].Process(); CRecordDataForChase::SaveOrRetrieveCarPositions(); - if ((CTimer::GetFrameCounter() & 7) == 1) { + if((CTimer::GetFrameCounter() & 7) == 1) { RemoveFallenPeds(); - } else if ((CTimer::GetFrameCounter() & 7) == 5) { + } else if((CTimer::GetFrameCounter() & 7) == 5) { RemoveFallenCars(); } } } -void -CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer) +void +CWorld::TriggerExplosion(const CVector &position, float fRadius, float fPower, CEntity *pCreator, + bool bProcessVehicleBombTimer) { CVector2D vecStartPos(position.x - fRadius, position.y - fRadius); CVector2D vecEndPos(position.x + fRadius, position.y + fRadius); @@ -1991,52 +2073,60 @@ CWorld::TriggerExplosion(const CVector& position, float fRadius, float fPower, C const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); - for (int32 y = nStartY; y <= nEndY; y++) { - for (int32 x = nStartX; x <= nEndX; x++) { - CSector* pSector = CWorld::GetSector(x, y); - CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); - CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); - CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); + for(int32 y = nStartY; y <= nEndY; y++) { + for(int32 x = nStartX; x <= nEndX; x++) { + CSector *pSector = CWorld::GetSector(x, y); + CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, fRadius, + fPower, pCreator, bProcessVehicleBombTimer); + CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, fRadius, fPower, + pCreator, bProcessVehicleBombTimer); + CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], position, fRadius, + fPower, pCreator, bProcessVehicleBombTimer); } } - } void -CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer) -{ - for (CPtrNode* pNode = list.first; pNode; pNode = pNode->next) { - CPhysical* pEntity = (CPhysical*)pNode->item; - CVector vecDistance = pEntity->GetPosition() - position; - float fMagnitude = vecDistance.Magnitude(); - if(fRadius > fMagnitude) { - CWeapon::BlowUpExplosiveThings(pEntity); - CPed *pPed = (CPed *)pEntity; - CObject *pObject = (CObject *)pEntity; - CVehicle *pVehicle = (CVehicle *)pEntity; - if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { - if(pEntity->bIsStatic) { - if (pEntity->IsObject()) { - if (fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) { - if (IsGlass(pObject->m_modelIndex)) { +CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, float fRadius, float fPower, + CEntity *pCreator, bool bProcessVehicleBombTimer) +{ + for(CPtrNode *pNode = list.first; pNode; pNode = pNode->next) { + CPhysical *pEntity = (CPhysical *)pNode->item; + CVector vecDistance = pEntity->GetPosition() - position; + float fMagnitude = vecDistance.Magnitude(); + if(fRadius > fMagnitude) { + CWeapon::BlowUpExplosiveThings(pEntity); + CPed *pPed = (CPed *)pEntity; + CObject *pObject = (CObject *)pEntity; + CVehicle *pVehicle = (CVehicle *)pEntity; + if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { + if(pEntity->bIsStatic) { + if(pEntity->IsObject()) { + if(fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) { + if(IsGlass(pObject->m_modelIndex)) { CGlass::WindowRespondsToExplosion(pObject, position); } else { pObject->bIsStatic = false; pObject->AddToMovingList(); int16 modelId = pEntity->m_modelIndex; - if (modelId != MI_FIRE_HYDRANT || pObject->bHasBeenDamaged) { - if (pEntity->IsObject() && modelId != MI_EXPLODINGBARREL && modelId != MI_PETROLPUMP) + if(modelId != MI_FIRE_HYDRANT || + pObject->bHasBeenDamaged) { + if(pEntity->IsObject() && + modelId != MI_EXPLODINGBARREL && + modelId != MI_PETROLPUMP) pObject->bHasBeenDamaged = true; } else { CVector pos = pEntity->GetPosition(); pos.z -= 0.5f; - CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, pos, true); + CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, + pos, true); pObject->bHasBeenDamaged = true; } } } - if (pEntity->bIsStatic) { - float fDamageMultiplier = (fRadius - fMagnitude) * 2.0f / fRadius; + if(pEntity->bIsStatic) { + float fDamageMultiplier = + (fRadius - fMagnitude) * 2.0f / fRadius; float fDamage = 300.0f * min(fDamageMultiplier, 1.0f); pObject->ObjectDamage(fDamage); } @@ -2045,37 +2135,37 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa pEntity->AddToMovingList(); } } - if (!pEntity->bIsStatic) { + if(!pEntity->bIsStatic) { float fDamageMultiplier = min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); - CVector vecForceDir = vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / max(fMagnitude, 0.01f)); + CVector vecForceDir = + vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / + max(fMagnitude, 0.01f)); vecForceDir.z = max(vecForceDir.z, 0.0f); - if (pEntity == FindPlayerPed()) - vecForceDir.z = min(vecForceDir.z, 1.0f); + if(pEntity == FindPlayerPed()) vecForceDir.z = min(vecForceDir.z, 1.0f); pEntity->ApplyMoveForce(vecForceDir); - if (!pEntity->bPedPhysics) { + if(!pEntity->bPedPhysics) { float fBoundRadius = pEntity->GetBoundRadius(); float fDistanceZ = position.z - pEntity->GetPosition().z; float fPointZ = fBoundRadius; - if (max(fDistanceZ, -fBoundRadius) < fBoundRadius) - { - if (fDistanceZ <= -fBoundRadius) + if(max(fDistanceZ, -fBoundRadius) < fBoundRadius) { + if(fDistanceZ <= -fBoundRadius) fPointZ = -fBoundRadius; else fPointZ = fDistanceZ; } - pEntity->ApplyTurnForce(vecForceDir.x, vecForceDir.y, vecForceDir.z, 0.0f, 0.0f, fPointZ); + pEntity->ApplyTurnForce(vecForceDir.x, vecForceDir.y, vecForceDir.z, + 0.0f, 0.0f, fPointZ); } - switch (pEntity->m_type) - { + switch(pEntity->m_type) { case ENTITY_TYPE_VEHICLE: - if (pEntity->m_status == STATUS_SIMPLE) { + if(pEntity->m_status == STATUS_SIMPLE) { pEntity->m_status = STATUS_PHYSICS; CCarCtrl::SwitchVehicleToRealPhysics(pVehicle); } - pVehicle->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION, 1100.0f * fDamageMultiplier); - if (bProcessVehicleBombTimer) { - if (pVehicle->m_nBombTimer) - pVehicle->m_nBombTimer /= 10; + pVehicle->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION, + 1100.0f * fDamageMultiplier); + if(bProcessVehicleBombTimer) { + if(pVehicle->m_nBombTimer) pVehicle->m_nBombTimer /= 10; } break; case ENTITY_TYPE_PED: { @@ -2083,14 +2173,16 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa pPed->bIsStanding = false; pPed->ApplyMoveForce(0.0, 0.0, 2.0f); float fDamage = 250.0f * fDamageMultiplier; - pPed->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION, fDamage, PEDPIECE_TORSO, direction); - if (pPed->m_nPedState!= PED_DIE) - pPed->SetFall(2000, (AnimationId)(direction + ANIM_KO_SKID_FRONT), 0); - if (pCreator && pCreator->IsPed()) { + pPed->InflictDamage(pCreator, WEAPONTYPE_EXPLOSION, fDamage, + PEDPIECE_TORSO, direction); + if(pPed->m_nPedState != PED_DIE) + pPed->SetFall(2000, + (AnimationId)(direction + ANIM_KO_SKID_FRONT), 0); + if(pCreator && pCreator->IsPed()) { eEventType eventType = EVENT_SHOOT_PED; - if (pPed->m_nPedType == PEDTYPE_COP) - eventType = EVENT_SHOOT_COP; - CEventList::RegisterEvent(eventType, EVENT_ENTITY_PED, pEntity, (CPed*)pCreator, 10000); + if(pPed->m_nPedType == PEDTYPE_COP) eventType = EVENT_SHOOT_COP; + CEventList::RegisterEvent(eventType, EVENT_ENTITY_PED, pEntity, + (CPed *)pCreator, 10000); pPed->RegisterThreatWithGangPeds(pCreator); } break; @@ -2105,17 +2197,18 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa } } -void -CWorld::UseDetonator(CEntity* pEntity) +void +CWorld::UseDetonator(CEntity *pEntity) { int32 i = CPools::GetVehiclePool()->GetSize(); - while (--i >= 0) { - CAutomobile* pVehicle = (CAutomobile*)CPools::GetVehiclePool()->GetSlot(i); - if (pVehicle && !pVehicle->m_vehType && pVehicle->m_bombType == CARBOMB_REMOTE && pVehicle->m_pBombRigger == pEntity) { + while(--i >= 0) { + CAutomobile *pVehicle = (CAutomobile *)CPools::GetVehiclePool()->GetSlot(i); + if(pVehicle && !pVehicle->m_vehType && pVehicle->m_bombType == CARBOMB_REMOTE && + pVehicle->m_pBombRigger == pEntity) { pVehicle->m_bombType = CARBOMB_NONE; pVehicle->m_nBombTimer = 500; pVehicle->m_pBlowUpEntity = pVehicle->m_pBombRigger; - if (pVehicle->m_pBlowUpEntity) + if(pVehicle->m_pBlowUpEntity) pVehicle->m_pBlowUpEntity->RegisterReference(&pVehicle->m_pBlowUpEntity); } } -- cgit v1.2.3 From ac61da3febc557c16e54bbe8cc946b023e434dc5 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 17 Apr 2020 17:04:09 +0500 Subject: Fix CWorld::FindObjectsOfTypeInRangeSectorList bug --- src/core/World.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 358e1823..c9e3c11f 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -753,14 +753,16 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList &list, const CEntity *pEntity = (CEntity *)pNode->item; if(pEntity->m_scanCode != GetCurrentScanCode()) { pEntity->m_scanCode = GetCurrentScanCode(); - float fMagnitude = 0.0f; - if(bCheck2DOnly) - fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D(); - else - fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr(); - if(fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) { - if(aEntities) aEntities[*nEntitiesFound] = pEntity; - ++*nEntitiesFound; + if(modelId == pEntity->m_modelIndex) { + float fMagnitude = 0.0f; + if(bCheck2DOnly) + fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D(); + else + fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr(); + if(fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) { + if(aEntities) aEntities[*nEntitiesFound] = pEntity; + ++*nEntitiesFound; + } } } } -- cgit v1.2.3 From 599164006a9e7eb7328fc194c9bae1acbb2c887d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 17 Apr 2020 16:31:11 +0300 Subject: Remove patches --- src/core/Accident.cpp | 12 +---- src/core/AnimViewer.cpp | 2 +- src/core/Cam.cpp | 54 +------------------ src/core/Camera.cpp | 57 +------------------- src/core/CdStream.cpp | 23 +------- src/core/Clock.cpp | 13 +---- src/core/Collision.cpp | 69 +----------------------- src/core/ControllerConfig.cpp | 56 +------------------- src/core/Directory.cpp | 9 +--- src/core/EventList.cpp | 13 +---- src/core/FileLoader.cpp | 42 +-------------- src/core/FileMgr.cpp | 18 +------ src/core/Fire.cpp | 20 +------ src/core/Frontend.cpp | 20 +------ src/core/Game.cpp | 19 +------ src/core/IniFile.cpp | 2 +- src/core/Pad.cpp | 120 +++--------------------------------------- src/core/Placeable.cpp | 20 +------ src/core/PlayerInfo.cpp | 19 +------ src/core/Pools.cpp | 18 +------ src/core/Radar.cpp | 50 +----------------- src/core/References.cpp | 8 +-- src/core/Stats.cpp | 10 +--- src/core/Streaming.cpp | 81 +--------------------------- src/core/SurfaceTable.cpp | 9 +--- src/core/TempColModels.cpp | 6 +-- src/core/Timer.cpp | 17 +----- src/core/User.cpp | 15 +----- src/core/Wanted.cpp | 24 +-------- src/core/World.cpp | 57 +++++--------------- src/core/World.h | 26 ++++----- src/core/ZoneCull.cpp | 16 +----- src/core/Zones.cpp | 35 +----------- src/core/main.cpp | 27 +--------- src/core/re3.cpp | 44 +--------------- 35 files changed, 66 insertions(+), 965 deletions(-) (limited to 'src/core') diff --git a/src/core/Accident.cpp b/src/core/Accident.cpp index 3c39b11d..1fd6c123 100644 --- a/src/core/Accident.cpp +++ b/src/core/Accident.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Accident.h" #include "Ped.h" @@ -122,13 +122,3 @@ CAccidentManager::UnattendedAccidents() } return false; } - -STARTPATCHES - InjectHook(0x4565A0, &CAccidentManager::GetNextFreeAccident, PATCH_JUMP); - InjectHook(0x4565D0, &CAccidentManager::ReportAccident, PATCH_JUMP); - InjectHook(0x456710, &CAccidentManager::Update, PATCH_JUMP); - InjectHook(0x456760, &CAccidentManager::FindNearestAccident, PATCH_JUMP); - InjectHook(0x456880, &CAccidentManager::CountActiveAccidents, PATCH_JUMP); - InjectHook(0x4568A0, &CAccidentManager::WorkToDoForMedics, PATCH_JUMP); - InjectHook(0x4568D0, &CAccidentManager::UnattendedAccidents, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index 1086db20..20e94bf4 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Font.h" #include "Pad.h" #include "Text.h" diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 4d954ccd..07dc2051 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "main.h" #include "Draw.h" #include "World.h" @@ -5236,55 +5236,3 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, } } #endif - -STARTPATCHES - InjectHook(0x456F40, WellBufferMe, PATCH_JUMP); - InjectHook(0x458410, &CCam::Init, PATCH_JUMP); - InjectHook(0x4582F0, &CCam::GetVectorsReadyForRW, PATCH_JUMP); - InjectHook(0x457710, &CCam::DoAverageOnVector, PATCH_JUMP); - InjectHook(0x458060, &CCam::GetPedBetaAngleForClearView, PATCH_JUMP); - InjectHook(0x457210, &CCam::Cam_On_A_String_Unobscured, PATCH_JUMP); - InjectHook(0x457A80, &CCam::FixCamWhenObscuredByVehicle, PATCH_JUMP); - InjectHook(0x457B90, &CCam::FixCamIfObscured, PATCH_JUMP); - InjectHook(0x465DA0, &CCam::RotCamIfInFrontCar, PATCH_JUMP); - InjectHook(0x4662D0, &CCam::WorkOutCamHeightWeeCar, PATCH_JUMP); - InjectHook(0x466650, &CCam::WorkOutCamHeight, PATCH_JUMP); - InjectHook(0x458600, &CCam::LookBehind, PATCH_JUMP); - InjectHook(0x458C40, &CCam::LookLeft, PATCH_JUMP); - InjectHook(0x458FB0, &CCam::LookRight, PATCH_JUMP); - InjectHook(0x4574C0, &CCam::ClipIfPedInFrontOfPlayer, PATCH_JUMP); - InjectHook(0x459300, &CCam::KeepTrackOfTheSpeed, PATCH_JUMP); - InjectHook(0x458580, &CCam::IsTargetInWater, PATCH_JUMP); - InjectHook(0x4570C0, &CCam::AvoidWallsTopDownPed, PATCH_JUMP); - InjectHook(0x4595B0, &CCam::PrintMode, PATCH_JUMP); - - InjectHook(0x467400, &CCam::ProcessSpecialHeightRoutines, PATCH_JUMP); - InjectHook(0x4596A0, &CCam::Process, PATCH_JUMP); - InjectHook(0x45E3A0, &CCam::Process_FollowPed, PATCH_JUMP); - InjectHook(0x45FF70, &CCam::Process_FollowPedWithMouse, PATCH_JUMP); - InjectHook(0x45BE60, &CCam::Process_BehindCar, PATCH_JUMP); - InjectHook(0x45C090, &CCam::Process_Cam_On_A_String, PATCH_JUMP); - InjectHook(0x463EB0, &CCam::Process_TopDown, PATCH_JUMP); - InjectHook(0x464390, &CCam::Process_TopDownPed, PATCH_JUMP); - InjectHook(0x461AF0, &CCam::Process_Rocket, PATCH_JUMP); - InjectHook(0x460E00, &CCam::Process_M16_1stPerson, PATCH_JUMP); - InjectHook(0x459FA0, &CCam::Process_1stPerson, PATCH_JUMP); - InjectHook(0x462420, &CCam::Process_Sniper, PATCH_JUMP); - InjectHook(0x463130, &CCam::Process_Syphon, PATCH_JUMP); - InjectHook(0x463A70, &CCam::Process_Syphon_Crim_In_Front, PATCH_JUMP); - InjectHook(0x45B470, &CCam::Process_BehindBoat, PATCH_JUMP); - InjectHook(0x45D2F0, &CCam::Process_Fight_Cam, PATCH_JUMP); - InjectHook(0x45DC20, &CCam::Process_FlyBy, PATCH_JUMP); - InjectHook(0x464D10, &CCam::Process_WheelCam, PATCH_JUMP); - InjectHook(0x45DA20, &CCam::Process_Fixed, PATCH_JUMP); - InjectHook(0x461940, &CCam::Process_Player_Fallen_Water, PATCH_JUMP); - InjectHook(0x45C400, &CCam::Process_Circle, PATCH_JUMP); - InjectHook(0x462FC0, &CCam::Process_SpecialFixedForSyphon, PATCH_JUMP); - InjectHook(0x45CCC0, &CCam::Process_Debug, PATCH_JUMP); - InjectHook(0x4656C0, &CCam::ProcessPedsDeadBaby, PATCH_JUMP); - InjectHook(0x465000, &CCam::ProcessArrestCamOne, PATCH_JUMP); - InjectHook(0x4653C0, &CCam::ProcessArrestCamTwo, PATCH_JUMP); - - InjectHook(0x456CE0, &FindSplinePathPositionFloat, PATCH_JUMP); - InjectHook(0x4569A0, &FindSplinePathPositionVector, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index a1f36d93..f1445d2e 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "main.h" #include "Draw.h" #include "World.h" @@ -3386,58 +3386,3 @@ CCamPathSplines::CCamPathSplines(void) for(i = 0; i < MAXPATHLENGTH; i++) m_arr_PathData[i] = 0.0f; } - - -STARTPATCHES - InjectHook(0x42C760, (bool (CCamera::*)(const CVector ¢er, float radius, const CMatrix *mat))&CCamera::IsSphereVisible, PATCH_JUMP); - InjectHook(0x46FD00, &CCamera::SetFadeColour, PATCH_JUMP); - - InjectHook(0x46FD40, &CCamera::SetMotionBlur, PATCH_JUMP); - InjectHook(0x46FD80, &CCamera::SetMotionBlurAlpha, PATCH_JUMP); - InjectHook(0x46F940, &CCamera::RenderMotionBlur, PATCH_JUMP); - - InjectHook(0x46FC90, &CCamera::SetCameraDirectlyInFrontForFollowPed_CamOnAString, PATCH_JUMP); - - InjectHook(0x46FF00, &CCamera::SetWideScreenOn, PATCH_JUMP); - InjectHook(0x46FF10, &CCamera::SetWideScreenOff, PATCH_JUMP); - - InjectHook(0x46FCC0, &CCamera::SetCamPositionForFixedMode, PATCH_JUMP); - InjectHook(0x46FEC0, &CCamera::SetRwCamera, PATCH_JUMP); - InjectHook(0x46B920, &CCamera::GetCutSceneFinishTime, PATCH_JUMP); - InjectHook(0x46B560, &CCamera::FinishCutscene, PATCH_JUMP); - InjectHook(0x46FF30, &CCamera::SetZoomValueFollowPedScript, PATCH_JUMP); - InjectHook(0x46FF90, &CCamera::SetZoomValueCamStringScript, PATCH_JUMP); - - - InjectHook(0x46F8E0, &CCamera::ProcessWideScreenOn, PATCH_JUMP); - InjectHook(0x46FDE0, &CCamera::SetParametersForScriptInterpolation, PATCH_JUMP); - InjectHook(0x46BA20, &CCamera::GetLookingLRBFirstPerson, PATCH_JUMP); - InjectHook(0x470D80, &CCamera::StartTransitionWhenNotFinishedInter, PATCH_JUMP); - InjectHook(0x46FFF0, &CCamera::StartTransition, PATCH_JUMP); - InjectHook(0x46BEB0, &CCamera::InitialiseCameraForDebugMode, PATCH_JUMP); - InjectHook(0x471500, &CCamera::TakeControl, PATCH_JUMP); - InjectHook(0x4715B0, &CCamera::TakeControlNoEntity, PATCH_JUMP); - InjectHook(0x46B3A0, &CCamera::Fade, PATCH_JUMP); - InjectHook(0x46FE20, &CCamera::SetPercentAlongCutScene, PATCH_JUMP); - InjectHook(0x46B100, &CamShakeNoPos, PATCH_JUMP); - InjectHook(0x46B200, &CCamera::CamShake, PATCH_JUMP); - InjectHook(0x46F520, &CCamera::ProcessObbeCinemaCameraPed, PATCH_JUMP); - InjectHook(0x46F3E0, &CCamera::ProcessObbeCinemaCameraCar, PATCH_JUMP); - InjectHook(0x470DA0, &CCamera::StoreValuesDuringInterPol, PATCH_JUMP); - InjectHook(0x46B430, &CCamera::DrawBordersForWideScreen, PATCH_JUMP); - InjectHook(0x46F990, &CCamera::Restore, PATCH_JUMP); - InjectHook(0x46FAE0, &CCamera::RestoreWithJumpCut, PATCH_JUMP); - InjectHook(0x46F080, &CCamera::ProcessFade, PATCH_JUMP); - InjectHook(0x46EEA0, &CCamera::CalculateDerivedValues, PATCH_JUMP); - InjectHook(0x46F1E0, &CCamera::ProcessMusicFade, PATCH_JUMP); - InjectHook(0x46D1D0, &CCamera::LoadPathSplines, PATCH_JUMP); - InjectHook(0x4712A0, &CCamera::UpdateTargetEntity, PATCH_JUMP); - InjectHook(0x46B580, &CCamera::Find3rdPersonCamTargetVector, PATCH_JUMP); - InjectHook(0x46BAD0, &CCamera::Init, PATCH_JUMP); - InjectHook(0x46C9E0, &CCamera::LoadTrainCamNodes, PATCH_JUMP); - InjectHook(0x46F600, &CCamera::Process_Train_Camera_Control, PATCH_JUMP); - InjectHook(0x470EA0, &CCamera::UpdateSoundDistances, PATCH_JUMP); - InjectHook(0x46BF10, &CCamera::IsItTimeForNewcam, PATCH_JUMP); - InjectHook(0x471650, &CCamera::TryToStartNewCamMode, PATCH_JUMP); -// InjectHook(0x46D3F0, &CCamera::Process, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index a400c039..1ab1c8b0 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -1,6 +1,6 @@ #include #include "common.h" -#include "patcher.h" + #include "CdStream.h" #include "rwcore.h" #include "RwHelper.h" @@ -507,24 +507,3 @@ CdStreamGetNumImages(void) { return gNumImages; } - - -STARTPATCHES - InjectHook(0x405B50, CdStreamInitThread, PATCH_JUMP); - InjectHook(0x405C80, CdStreamInit, PATCH_JUMP); - //InjectHook(0x405DB0, debug, PATCH_JUMP); - InjectHook(0x405DC0, GetGTA3ImgSize, PATCH_JUMP); - InjectHook(0x405DD0, CdStreamShutdown, PATCH_JUMP); - InjectHook(0x405E40, CdStreamRead, PATCH_JUMP); - InjectHook(0x405F90, CdStreamGetStatus, PATCH_JUMP); - InjectHook(0x406000, CdStreamGetLastPosn, PATCH_JUMP); - InjectHook(0x406010, CdStreamSync, PATCH_JUMP); - InjectHook(0x4060B0, AddToQueue, PATCH_JUMP); - InjectHook(0x4060F0, GetFirstInQueue, PATCH_JUMP); - InjectHook(0x406110, RemoveFirstInQueue, PATCH_JUMP); - InjectHook(0x406140, CdStreamThread, PATCH_JUMP); - InjectHook(0x406270, CdStreamAddImage, PATCH_JUMP); - InjectHook(0x4062E0, CdStreamGetImageName, PATCH_JUMP); - InjectHook(0x406300, CdStreamRemoveImages, PATCH_JUMP); - InjectHook(0x406370, CdStreamGetNumImages, PATCH_JUMP); -ENDPATCHES \ No newline at end of file diff --git a/src/core/Clock.cpp b/src/core/Clock.cpp index 69fdd682..e4b908e0 100644 --- a/src/core/Clock.cpp +++ b/src/core/Clock.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Timer.h" #include "Pad.h" #include "Clock.h" @@ -115,14 +115,3 @@ CClock::RestoreClock(void) ms_nGameClockMinutes = ms_Stored_nGameClockMinutes; ms_nGameClockSeconds = ms_Stored_nGameClockSeconds; } - - -STARTPATCHES - InjectHook(0x473370, CClock::Initialise, PATCH_JUMP); - InjectHook(0x473460, CClock::Update, PATCH_JUMP); - InjectHook(0x4733C0, CClock::SetGameClock, PATCH_JUMP); - InjectHook(0x4733F0, CClock::GetGameClockMinutesUntil, PATCH_JUMP); - InjectHook(0x473420, CClock::GetIsTimeInRange, PATCH_JUMP); - InjectHook(0x473540, CClock::StoreClock, PATCH_JUMP); - InjectHook(0x473570, CClock::RestoreClock, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 85145e86..5bdb32dc 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "main.h" #include "Lists.h" #include "Game.h" @@ -2140,70 +2140,3 @@ CColModel::operator=(const CColModel &other) } return *this; } - -#include -struct CColLine_ : public CColLine -{ - CColLine *ctor(CVector *p0, CVector *p1) { return ::new (this) CColLine(*p0, *p1); } -}; - -struct CColModel_ : public CColModel -{ - CColModel *ctor(void) { return ::new (this) CColModel(); } - void dtor(void) { this->CColModel::~CColModel(); } -}; - - -STARTPATCHES - InjectHook(0x4B9C30, (CMatrix& (*)(const CMatrix &src, CMatrix &dst))Invert, PATCH_JUMP); - - InjectHook(0x40B380, CCollision::Init, PATCH_JUMP); - InjectHook(0x40B3A0, CCollision::Shutdown, PATCH_JUMP); - InjectHook(0x40B3B0, CCollision::Update, PATCH_JUMP); - InjectHook(0x40B5B0, CCollision::LoadCollisionWhenINeedIt, PATCH_JUMP); - InjectHook(0x40B900, CCollision::SortOutCollisionAfterLoad, PATCH_JUMP); - - InjectHook(0x40BB70, CCollision::TestSphereBox, PATCH_JUMP); - InjectHook(0x40E130, CCollision::TestLineBox, PATCH_JUMP); - InjectHook(0x40E5C0, CCollision::TestVerticalLineBox, PATCH_JUMP); - InjectHook(0x40EC10, CCollision::TestLineTriangle, PATCH_JUMP); - InjectHook(0x40DAA0, CCollision::TestLineSphere, PATCH_JUMP); - InjectHook(0x40C580, CCollision::TestSphereTriangle, PATCH_JUMP); - InjectHook(0x40F720, CCollision::TestLineOfSight, PATCH_JUMP); - - InjectHook(0x40B9F0, CCollision::ProcessSphereSphere, PATCH_JUMP); - InjectHook(0x40BC00, CCollision::ProcessSphereBox, PATCH_JUMP); - InjectHook(0x40E670, CCollision::ProcessLineBox, PATCH_JUMP); - InjectHook(0x40DE80, CCollision::ProcessLineSphere, PATCH_JUMP); - InjectHook(0x40FB50, CCollision::ProcessVerticalLineTriangle, PATCH_JUMP); - InjectHook(0x40F140, CCollision::ProcessLineTriangle, PATCH_JUMP); - InjectHook(0x40CE30, CCollision::ProcessSphereTriangle, PATCH_JUMP); - - InjectHook(0x40F910, CCollision::ProcessLineOfSight, PATCH_JUMP); - InjectHook(0x410120, CCollision::ProcessVerticalLine, PATCH_JUMP); - InjectHook(0x410BE0, CCollision::ProcessColModels, PATCH_JUMP); - - InjectHook(0x40B960, CCollision::CalculateTrianglePlanes, PATCH_JUMP); - InjectHook(0x411640, &CLink::Remove, PATCH_JUMP); - InjectHook(0x411620, &CLink::Insert, PATCH_JUMP); - InjectHook(0x4115C0, &CLinkList::Insert, PATCH_JUMP); - InjectHook(0x411600, &CLinkList::Remove, PATCH_JUMP); -// InjectHook(0x411530, &CLinkList::Init, PATCH_JUMP); - - InjectHook(0x411E40, (void (CColSphere::*)(float, const CVector&, uint8, uint8))&CColSphere::Set, PATCH_JUMP); - InjectHook(0x40B2A0, &CColBox::Set, PATCH_JUMP); - InjectHook(0x40B320, &CColLine_::ctor, PATCH_JUMP); - InjectHook(0x40B350, &CColLine::Set, PATCH_JUMP); - InjectHook(0x411E70, &CColTriangle::Set, PATCH_JUMP); - - InjectHook(0x411EA0, &CColTrianglePlane::Set, PATCH_JUMP); - InjectHook(0x412140, &CColTrianglePlane::GetNormal, PATCH_JUMP); - - InjectHook(0x411680, &CColModel_::ctor, PATCH_JUMP); - InjectHook(0x4116E0, &CColModel_::dtor, PATCH_JUMP); - InjectHook(0x411D80, &CColModel::RemoveCollisionVolumes, PATCH_JUMP); - InjectHook(0x411CB0, &CColModel::CalculateTrianglePlanes, PATCH_JUMP); - InjectHook(0x411D10, &CColModel::RemoveTrianglePlanes, PATCH_JUMP); - InjectHook(0x411D40, &CColModel::SetLinkPtr, PATCH_JUMP); - InjectHook(0x411D60, &CColModel::GetLinkPtr, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index ce8674d7..a2382c12 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -1,7 +1,7 @@ #define DIRECTINPUT_VERSION 0x0800 #include #include "common.h" -#include "patcher.h" + #include "ControllerConfig.h" #include "Pad.h" #include "FileMgr.h" @@ -2362,57 +2362,3 @@ void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action) } } } - - -STARTPATCHES - InjectHook(0x58B7A0, &CControllerConfigManager::MakeControllerActionsBlank, PATCH_JUMP); - InjectHook(0x58B7D0, &CControllerConfigManager::GetJoyButtonJustDown, PATCH_JUMP); - InjectHook(0x58B800, &CControllerConfigManager::SaveSettings, PATCH_JUMP); - InjectHook(0x58B870, &CControllerConfigManager::LoadSettings, PATCH_JUMP); - InjectHook(0x58B930, &CControllerConfigManager::InitDefaultControlConfiguration, PATCH_JUMP); - InjectHook(0x58BD00, &CControllerConfigManager::InitDefaultControlConfigMouse, PATCH_JUMP); - InjectHook(0x58BD90, &CControllerConfigManager::InitDefaultControlConfigJoyPad, PATCH_JUMP); - InjectHook(0x58C060, &CControllerConfigManager::InitialiseControllerActionNameArray, PATCH_JUMP); - InjectHook(0x58C5E0, &CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown, PATCH_JUMP); - InjectHook(0x58C730, &CControllerConfigManager::AffectControllerStateOn_ButtonDown, PATCH_JUMP); - InjectHook(0x58C880, &CControllerConfigManager::AffectControllerStateOn_ButtonDown_Driving, PATCH_JUMP); - InjectHook(0x58CAD0, &CControllerConfigManager::AffectControllerStateOn_ButtonDown_FirstPersonOnly, PATCH_JUMP); - InjectHook(0x58CB10, &CControllerConfigManager::AffectControllerStateOn_ButtonDown_ThirdPersonOnly, PATCH_JUMP); - InjectHook(0x58CBD0, &CControllerConfigManager::AffectControllerStateOn_ButtonDown_FirstAndThirdPersonOnly, PATCH_JUMP); - InjectHook(0x58CD70, &CControllerConfigManager::AffectControllerStateOn_ButtonDown_AllStates, PATCH_JUMP); - InjectHook(0x58CE50, &CControllerConfigManager::AffectControllerStateOn_ButtonDown_VehicleAndThirdPersonOnly, PATCH_JUMP); - InjectHook(0x58CE80, &CControllerConfigManager::UpdateJoyInConfigMenus_ButtonUp, PATCH_JUMP); - InjectHook(0x58CFD0, &CControllerConfigManager::AffectControllerStateOn_ButtonUp, PATCH_JUMP); - InjectHook(0x58D090, &CControllerConfigManager::AffectControllerStateOn_ButtonUp_All_Player_States, PATCH_JUMP); - InjectHook(0x58D0C0, &CControllerConfigManager::AffectPadFromKeyBoard, PATCH_JUMP); - InjectHook(0x58D1A0, &CControllerConfigManager::AffectPadFromMouse, PATCH_JUMP); - InjectHook(0x58D220, &CControllerConfigManager::ClearSimButtonPressCheckers, PATCH_JUMP); - InjectHook(0x58D2A0, &CControllerConfigManager::GetIsKeyboardKeyDown, PATCH_JUMP); - InjectHook(0x58D8A0, &CControllerConfigManager::GetIsKeyboardKeyJustDown, PATCH_JUMP); - InjectHook(0x58E280, &CControllerConfigManager::GetIsMouseButtonDown, PATCH_JUMP); - InjectHook(0x58E360, &CControllerConfigManager::GetIsMouseButtonUp, PATCH_JUMP); - InjectHook(0x58E440, &CControllerConfigManager::DeleteMatchingCommonControls, PATCH_JUMP); - InjectHook(0x58E540, &CControllerConfigManager::DeleteMatching3rdPersonControls, PATCH_JUMP); - InjectHook(0x58E630, &CControllerConfigManager::DeleteMatching1rst3rdPersonControls, PATCH_JUMP); - InjectHook(0x58E710, &CControllerConfigManager::DeleteMatchingVehicleControls, PATCH_JUMP); - InjectHook(0x58E890, &CControllerConfigManager::DeleteMatchingVehicle_3rdPersonControls, PATCH_JUMP); - InjectHook(0x58E8D0, &CControllerConfigManager::DeleteMatching1rstPersonControls, PATCH_JUMP); - InjectHook(0x58E920, &CControllerConfigManager::DeleteMatchingActionInitiators, PATCH_JUMP); - InjectHook(0x58EA70, &CControllerConfigManager::GetIsKeyBlank, PATCH_JUMP); - InjectHook(0x58EAD0, &CControllerConfigManager::GetActionType, PATCH_JUMP); - InjectHook(0x58EB40, &CControllerConfigManager::ClearSettingsAssociatedWithAction, PATCH_JUMP); - InjectHook(0x58EBF0, &CControllerConfigManager::GetControllerSettingTextWithOrderNumber, PATCH_JUMP); - InjectHook(0x58EC50, &CControllerConfigManager::GetControllerSettingTextKeyBoard, PATCH_JUMP); - InjectHook(0x58F320, &CControllerConfigManager::GetControllerSettingTextMouse, PATCH_JUMP); - InjectHook(0x58F3D0, &CControllerConfigManager::GetControllerSettingTextJoystick, PATCH_JUMP); - InjectHook(0x58F420, &CControllerConfigManager::GetNumOfSettingsForAction, PATCH_JUMP); - InjectHook(0x58F460, &CControllerConfigManager::GetWideStringOfCommandKeys, PATCH_JUMP); - InjectHook(0x58F590, &CControllerConfigManager::GetControllerKeyAssociatedWithAction, PATCH_JUMP); - InjectHook(0x58F5B0, &CControllerConfigManager::UpdateJoyButtonState, PATCH_JUMP); - InjectHook(0x58F660, &CControllerConfigManager::GetIsActionAButtonCombo, PATCH_JUMP); - InjectHook(0x58F690, &CControllerConfigManager::GetButtonComboText, PATCH_JUMP); - InjectHook(0x58F700, &CControllerConfigManager::SetControllerKeyAssociatedWithAction, PATCH_JUMP); - InjectHook(0x58F740, &CControllerConfigManager::GetMouseButtonAssociatedWithAction, PATCH_JUMP); - InjectHook(0x58F760, &CControllerConfigManager::SetMouseButtonAssociatedWithAction, PATCH_JUMP); - InjectHook(0x58F790, &CControllerConfigManager::ResetSettingOrder, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp index d4b4279d..27539824 100644 --- a/src/core/Directory.cpp +++ b/src/core/Directory.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "General.h" #include "FileMgr.h" #include "Directory.h" @@ -57,10 +57,3 @@ CDirectory::FindItem(const char *name, uint32 &offset, uint32 &size) } return false; } - -STARTPATCHES - InjectHook(0x473630, &CDirectory::ReadDirFile, PATCH_JUMP); - InjectHook(0x473690, &CDirectory::WriteDirFile, PATCH_JUMP); - InjectHook(0x473600, &CDirectory::AddItem, PATCH_JUMP); - InjectHook(0x4736E0, &CDirectory::FindItem, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp index 5ca4cdb0..675040ea 100644 --- a/src/core/EventList.cpp +++ b/src/core/EventList.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Pools.h" #include "ModelIndices.h" #include "World.h" @@ -227,14 +227,3 @@ CEventList::ReportCrimeForEvent(eEventType type, int32 crimeId, bool copsDontCar FindPlayerPed()->SetWantedLevelNoDrop(2); } - -STARTPATCHES - InjectHook(0x475B60, CEventList::Initialise, PATCH_JUMP); - InjectHook(0x475BE0, CEventList::Update, PATCH_JUMP); - InjectHook(0x475C50, (void (*)(eEventType,eEventEntity,CEntity *,CPed *,int32))CEventList::RegisterEvent, PATCH_JUMP); - InjectHook(0x475E10, (void (*)(eEventType,CVector,int32))CEventList::RegisterEvent, PATCH_JUMP); - InjectHook(0x475F40, CEventList::GetEvent, PATCH_JUMP); - InjectHook(0x475F70, CEventList::ClearEvent, PATCH_JUMP); - InjectHook(0x475F90, CEventList::FindClosestEvent, PATCH_JUMP); - InjectHook(0x476070, CEventList::ReportCrimeForEvent, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index e0a0fafc..b7d82089 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -1,6 +1,6 @@ #include "common.h" #include "main.h" -#include "patcher.h" + #include "Quaternion.h" #include "ModelInfo.h" #include "ModelIndices.h" @@ -1355,43 +1355,3 @@ CFileLoader::ReLoadScene(const char *filename) } CFileMgr::CloseFile(fd); } - -STARTPATCHES - InjectHook(0x476290, CFileLoader::LoadLevel, PATCH_JUMP); - - InjectHook(0x476520, CFileLoader::LoadCollisionFromDatFile, PATCH_JUMP); - InjectHook(0x4761D0, CFileLoader::LoadLine, PATCH_JUMP); - InjectHook(0x4765B0, CFileLoader::LoadTexDictionary, PATCH_JUMP); - InjectHook(0x478B20, CFileLoader::LoadCollisionFile, PATCH_JUMP); - InjectHook(0x478C20, CFileLoader::LoadCollisionModel, PATCH_JUMP); - InjectHook(0x476750, CFileLoader::LoadModelFile, PATCH_JUMP); - InjectHook(0x476810, (void (*)(const char*))CFileLoader::LoadClumpFile, PATCH_JUMP); - InjectHook(0x476990, (bool (*)(RwStream*,uint32))CFileLoader::LoadClumpFile, PATCH_JUMP); - InjectHook(0x476A20, CFileLoader::StartLoadClumpFile, PATCH_JUMP); - InjectHook(0x476A70, CFileLoader::FinishLoadClumpFile, PATCH_JUMP); - InjectHook(0x476930, CFileLoader::LoadAtomicFile, PATCH_JUMP); - InjectHook(0x4767C0, CFileLoader::LoadAtomicFile2Return, PATCH_JUMP); - InjectHook(0x476630, CFileLoader::AddTexDictionaries, PATCH_JUMP); - - InjectHook(0x476AC0, CFileLoader::LoadObjectTypes, PATCH_JUMP); - InjectHook(0x477040, CFileLoader::LoadObject, PATCH_JUMP); - InjectHook(0x4774B0, CFileLoader::LoadTimeObject, PATCH_JUMP); - InjectHook(0x477920, CFileLoader::LoadClumpObject, PATCH_JUMP); - InjectHook(0x477990, CFileLoader::LoadVehicleObject, PATCH_JUMP); - InjectHook(0x477DE0, CFileLoader::LoadPedObject, PATCH_JUMP); - InjectHook(0x477ED0, CFileLoader::LoadPathHeader, PATCH_JUMP); - InjectHook(0x477FF0, CFileLoader::LoadCarPathNode, PATCH_JUMP); - InjectHook(0x477F00, CFileLoader::LoadPedPathNode, PATCH_JUMP); - InjectHook(0x4780E0, CFileLoader::Load2dEffect, PATCH_JUMP); - - InjectHook(0x478370, CFileLoader::LoadScene, PATCH_JUMP); - InjectHook(0x4786B0, CFileLoader::LoadObjectInstance, PATCH_JUMP); - InjectHook(0x478A00, CFileLoader::LoadZone, PATCH_JUMP); - InjectHook(0x478A90, CFileLoader::LoadCullZone, PATCH_JUMP); - - InjectHook(0x478550, CFileLoader::LoadMapZones, PATCH_JUMP); - - InjectHook(0x476DB0, CFileLoader::ReloadPaths, PATCH_JUMP); - InjectHook(0x476F30, CFileLoader::ReloadObjectTypes, PATCH_JUMP); - InjectHook(0x4772B0, CFileLoader::ReloadObject, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 382316bb..46d725cd 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -2,7 +2,7 @@ #include #include #include "common.h" -#include "patcher.h" + #include "FileMgr.h" const char *_psGetUserFilesFolder(); @@ -282,19 +282,3 @@ CFileMgr::GetErrorReadWrite(int fd) { return myfeof(fd); } - -STARTPATCHES - InjectHook(0x478F80, CFileMgr::Initialise, PATCH_JUMP); - InjectHook(0x478FB0, CFileMgr::ChangeDir, PATCH_JUMP); - InjectHook(0x479020, CFileMgr::SetDir, PATCH_JUMP); - InjectHook(0x479080, CFileMgr::SetDirMyDocuments, PATCH_JUMP); - InjectHook(0x479090, CFileMgr::LoadFile, PATCH_JUMP); - InjectHook(0x479100, CFileMgr::OpenFile, PATCH_JUMP); - InjectHook(0x479120, CFileMgr::OpenFileForWriting, PATCH_JUMP); - InjectHook(0x479140, CFileMgr::Read, PATCH_JUMP); - InjectHook(0x479160, CFileMgr::Write, PATCH_JUMP); - InjectHook(0x479180, CFileMgr::Seek, PATCH_JUMP); - InjectHook(0x4791D0, CFileMgr::ReadLine, PATCH_JUMP); - InjectHook(0x479200, CFileMgr::CloseFile, PATCH_JUMP); - InjectHook(0x479210, CFileMgr::GetErrorReadWrite, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index f900091e..65b6deb2 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Vector.h" #include "PlayerPed.h" #include "Entity.h" @@ -438,21 +438,3 @@ CFireManager::SetScriptFireAudio(int16 index, bool state) { m_aFires[index].m_bAudioSet = state; } - -STARTPATCHES - InjectHook(0x4798D0, &CFire::ProcessFire, PATCH_JUMP); - InjectHook(0x4798B0, &CFire::ReportThisFire, PATCH_JUMP); - InjectHook(0x479D40, &CFire::Extinguish, PATCH_JUMP); - InjectHook(0x479500, (void(CFireManager::*)(CVector pos, float size, bool propagation))&CFireManager::StartFire, PATCH_JUMP); - InjectHook(0x479590, (CFire *(CFireManager::*)(CEntity *, CEntity *, float, bool))&CFireManager::StartFire, PATCH_JUMP); - InjectHook(0x479310, &CFireManager::Update, PATCH_JUMP); - InjectHook(0x479430, &CFireManager::FindFurthestFire_NeverMindFireMen, PATCH_JUMP); - InjectHook(0x479340, &CFireManager::FindNearestFire, PATCH_JUMP); - InjectHook(0x4792E0, &CFireManager::GetNextFreeFire, PATCH_JUMP); - InjectHook(0x479DB0, &CFireManager::ExtinguishPoint, PATCH_JUMP); - InjectHook(0x479E60, &CFireManager::StartScriptFire, PATCH_JUMP); - InjectHook(0x479FC0, &CFireManager::IsScriptFireExtinguish, PATCH_JUMP); - InjectHook(0x47A000, &CFireManager::RemoveAllScriptFires, PATCH_JUMP); - InjectHook(0x479FE0, &CFireManager::RemoveScriptFire, PATCH_JUMP); - InjectHook(0x47A040, &CFireManager::SetScriptFireAudio, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index b2ecdac5..790de046 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1,7 +1,7 @@ #define DIRECTINPUT_VERSION 0x0800 #include #include "common.h" -#include "patcher.h" + #include "win.h" #include "Frontend.h" #include "Font.h" @@ -5624,21 +5624,3 @@ uint8 CMenuManager::GetNumberOfMenuOptions() #undef GetBackJustUp #undef GetBackJustDown - -STARTPATCHES - for (int i = 1; i < ARRAY_SIZE(aScreens); i++) - Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); - InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); - InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); - InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); - InjectHook(0x47A540, &CMenuManager::DrawFrontEnd, PATCH_JUMP); - - InjectHook(0x48ABE0, &CMenuManager::StretchX, PATCH_JUMP); - InjectHook(0x48AC20, &CMenuManager::StretchY, PATCH_JUMP); - InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); - InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); - InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); - InjectHook(0x48AB40, &CMenuManager::DoSettingsBeforeStartingAGame, PATCH_JUMP); - InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP); - InjectHook(0x489710, &CMenuManager::DrawControllerBound, PATCH_JUMP); -ENDPATCHES \ No newline at end of file diff --git a/src/core/Game.cpp b/src/core/Game.cpp index f115d52f..7ccf78d0 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -5,7 +5,7 @@ #pragma warning( pop ) #include "common.h" #include "win.h" -#include "patcher.h" + #include "Game.h" #include "main.h" #include "RwHelper.h" @@ -710,20 +710,3 @@ void CGame::ProcessTidyUpMemory(void) // meow #endif } - -STARTPATCHES - InjectHook(0x48BB80, CGame::InitialiseOnceBeforeRW, PATCH_JUMP); - InjectHook(0x48BBA0, CGame::InitialiseRenderWare, PATCH_JUMP); - InjectHook(0x48BCB0, CGame::ShutdownRenderWare, PATCH_JUMP); - InjectHook(0x48BD50, CGame::InitialiseOnceAfterRW, PATCH_JUMP); - InjectHook(0x48BEC0, CGame::FinalShutdown, PATCH_JUMP); - InjectHook(0x48BED0, CGame::Initialise, PATCH_JUMP); - InjectHook(0x48C3A0, CGame::ShutDown, PATCH_JUMP); - InjectHook(0x48C4B0, CGame::ReInitGameObjectVariables, PATCH_JUMP); - InjectHook(0x48C620, CGame::ReloadIPLs, PATCH_JUMP); - InjectHook(0x48C6B0, CGame::ShutDownForRestart, PATCH_JUMP); - InjectHook(0x48C740, CGame::InitialiseWhenRestarting, PATCH_JUMP); - InjectHook(0x48C850, CGame::Process, PATCH_JUMP); - InjectHook(0x48CA10, CGame::DrasticTidyUpMemory, PATCH_JUMP); - InjectHook(0x48CA20, CGame::TidyUpMemory, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index d8e91c98..16e35633 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "IniFile.h" #include "CarCtrl.h" diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 2db375b2..86aff05e 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -9,7 +9,7 @@ #include #pragma comment( lib, "Xinput9_1_0.lib" ) #endif -#include "patcher.h" + #include "Pad.h" #include "ControllerConfig.h" #include "Timer.h" @@ -1285,7 +1285,7 @@ bool CPad::GetLookRight(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.RightShoulder2 && !NewState.LeftShoulder2); } @@ -1294,7 +1294,7 @@ bool CPad::GetLookBehindForCar(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.RightShoulder2 && NewState.LeftShoulder2); } @@ -1768,7 +1768,7 @@ bool CPad::CycleWeaponRightJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } @@ -1865,7 +1865,7 @@ bool CPad::ShiftTargetLeftJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); } @@ -1873,7 +1873,7 @@ bool CPad::ShiftTargetRightJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } @@ -2404,111 +2404,3 @@ int32 *CPad::EditCodesForControls(int32 *pRsKeys, int32 nSize) return pRsKeys; } - -STARTPATCHES - InjectHook(0x490D90, &WeaponCheat, PATCH_JUMP); - InjectHook(0x490E70, &HealthCheat, PATCH_JUMP); - InjectHook(0x490EE0, &TankCheat, PATCH_JUMP); - InjectHook(0x491040, &BlowUpCarsCheat, PATCH_JUMP); - InjectHook(0x4910B0, &ChangePlayerCheat, PATCH_JUMP); - InjectHook(0x4911C0, &MayhemCheat, PATCH_JUMP); - InjectHook(0x491270, &EverybodyAttacksPlayerCheat, PATCH_JUMP); - InjectHook(0x491370, &WeaponsForAllCheat, PATCH_JUMP); - InjectHook(0x4913A0, &FastTimeCheat, PATCH_JUMP); - InjectHook(0x4913F0, &SlowTimeCheat, PATCH_JUMP); - InjectHook(0x491430, &MoneyCheat, PATCH_JUMP); - InjectHook(0x491460, &ArmourCheat, PATCH_JUMP); - InjectHook(0x491490, &WantedLevelUpCheat, PATCH_JUMP); - InjectHook(0x4914F0, &WantedLevelDownCheat, PATCH_JUMP); - InjectHook(0x491520, &SunnyWeatherCheat, PATCH_JUMP); - InjectHook(0x491550, &CloudyWeatherCheat, PATCH_JUMP); - InjectHook(0x491580, &RainyWeatherCheat, PATCH_JUMP); - InjectHook(0x4915B0, &FoggyWeatherCheat, PATCH_JUMP); - InjectHook(0x4915E0, &FastWeatherCheat, PATCH_JUMP); - InjectHook(0x491610, &OnlyRenderWheelsCheat, PATCH_JUMP); - InjectHook(0x491640, &ChittyChittyBangBangCheat, PATCH_JUMP); - InjectHook(0x491670, &StrongGripCheat, PATCH_JUMP); - InjectHook(0x4916A0, &NastyLimbsCheat, PATCH_JUMP); - - InjectHook(0x4916C0, &CControllerState::Clear, PATCH_JUMP); - InjectHook(0x491760, &CKeyboardState::Clear, PATCH_JUMP); - InjectHook(0x491A10, &CPad::Clear, PATCH_JUMP); - InjectHook(0x491B50, &CPad::ClearMouseHistory, PATCH_JUMP); - //InjectHook(0x491B80, &CMouseControllerState::CMouseControllerState, PATCH_JUMP); - InjectHook(0x491BB0, &CMouseControllerState::Clear, PATCH_JUMP); - InjectHook(0x491BD0, &CMousePointerStateHelper::GetMouseSetUp, PATCH_JUMP); - InjectHook(0x491CA0, &CPad::UpdateMouse, PATCH_JUMP); - InjectHook(0x491E60, &CPad::ReconcileTwoControllersInput, PATCH_JUMP); - InjectHook(0x492230, &CPad::StartShake, PATCH_JUMP); - InjectHook(0x492290, &CPad::StartShake_Distance, PATCH_JUMP); - InjectHook(0x492360, &CPad::StartShake_Train, PATCH_JUMP); - InjectHook(0x492450, &CPad::AddToPCCheatString, PATCH_JUMP); - InjectHook(0x492720, CPad::UpdatePads, PATCH_JUMP); - InjectHook(0x492C60, &CPad::ProcessPCSpecificStuff, PATCH_JUMP); - InjectHook(0x492C70, &CPad::Update, PATCH_JUMP); -#pragma warning( push ) -#pragma warning( disable : 4573) - InjectHook(0x492F00, (void (*)())CPad::DoCheats, PATCH_JUMP); -#pragma warning( pop ) - InjectHook(0x492F20, (void (CPad::*)(int16))&CPad::DoCheats, PATCH_JUMP); - InjectHook(0x492F30, CPad::StopPadsShaking, PATCH_JUMP); - InjectHook(0x492F50, &CPad::StopShaking, PATCH_JUMP); - InjectHook(0x492F60, CPad::GetPad, PATCH_JUMP); - InjectHook(0x492F70, &CPad::GetSteeringLeftRight, PATCH_JUMP); - InjectHook(0x492FF0, &CPad::GetSteeringUpDown, PATCH_JUMP); - InjectHook(0x493070, &CPad::GetCarGunUpDown, PATCH_JUMP); - InjectHook(0x4930C0, &CPad::GetCarGunLeftRight, PATCH_JUMP); - InjectHook(0x493110, &CPad::GetPedWalkLeftRight, PATCH_JUMP); - InjectHook(0x493190, &CPad::GetPedWalkUpDown, PATCH_JUMP); - InjectHook(0x493210, &CPad::GetAnalogueUpDown, PATCH_JUMP); - InjectHook(0x493290, &CPad::GetLookLeft, PATCH_JUMP); - InjectHook(0x4932C0, &CPad::GetLookRight, PATCH_JUMP); - InjectHook(0x4932F0, &CPad::GetLookBehindForCar, PATCH_JUMP); - InjectHook(0x493320, &CPad::GetLookBehindForPed, PATCH_JUMP); - InjectHook(0x493350, &CPad::GetHorn, PATCH_JUMP); - InjectHook(0x4933F0, &CPad::HornJustDown, PATCH_JUMP); - InjectHook(0x493490, &CPad::GetCarGunFired, PATCH_JUMP); - InjectHook(0x4934F0, &CPad::CarGunJustDown, PATCH_JUMP); - InjectHook(0x493560, &CPad::GetHandBrake, PATCH_JUMP); - InjectHook(0x4935A0, &CPad::GetBrake, PATCH_JUMP); - InjectHook(0x4935F0, &CPad::GetExitVehicle, PATCH_JUMP); - InjectHook(0x493650, &CPad::ExitVehicleJustDown, PATCH_JUMP); - InjectHook(0x4936C0, &CPad::GetWeapon, PATCH_JUMP); - InjectHook(0x493700, &CPad::WeaponJustDown, PATCH_JUMP); - InjectHook(0x493780, &CPad::GetAccelerate, PATCH_JUMP); - InjectHook(0x4937D0, &CPad::CycleCameraModeUpJustDown, PATCH_JUMP); - InjectHook(0x493830, &CPad::CycleCameraModeDownJustDown, PATCH_JUMP); - InjectHook(0x493870, &CPad::ChangeStationJustDown, PATCH_JUMP); - InjectHook(0x493910, &CPad::CycleWeaponLeftJustDown, PATCH_JUMP); - InjectHook(0x493940, &CPad::CycleWeaponRightJustDown, PATCH_JUMP); - InjectHook(0x493970, &CPad::GetTarget, PATCH_JUMP); - InjectHook(0x4939D0, &CPad::TargetJustDown, PATCH_JUMP); - InjectHook(0x493A40, &CPad::JumpJustDown, PATCH_JUMP); - InjectHook(0x493A70, &CPad::GetSprint, PATCH_JUMP); - InjectHook(0x493AE0, &CPad::ShiftTargetLeftJustDown, PATCH_JUMP); - InjectHook(0x493B10, &CPad::ShiftTargetRightJustDown, PATCH_JUMP); - InjectHook(0x493B40, &CPad::GetAnaloguePadUp, PATCH_JUMP); - InjectHook(0x493BA0, &CPad::GetAnaloguePadDown, PATCH_JUMP); - InjectHook(0x493C00, &CPad::GetAnaloguePadLeft, PATCH_JUMP); - InjectHook(0x493C60, &CPad::GetAnaloguePadRight, PATCH_JUMP); - InjectHook(0x493CC0, &CPad::GetAnaloguePadLeftJustUp, PATCH_JUMP); - InjectHook(0x493D20, &CPad::GetAnaloguePadRightJustUp, PATCH_JUMP); - InjectHook(0x493D80, &CPad::ForceCameraBehindPlayer, PATCH_JUMP); - InjectHook(0x493E00, &CPad::SniperZoomIn, PATCH_JUMP); - InjectHook(0x493E70, &CPad::SniperZoomOut, PATCH_JUMP); - InjectHook(0x493EE0, &CPad::SniperModeLookLeftRight, PATCH_JUMP); - InjectHook(0x493F30, &CPad::SniperModeLookUpDown, PATCH_JUMP); - InjectHook(0x493F80, &CPad::LookAroundLeftRight, PATCH_JUMP); - InjectHook(0x494130, &CPad::LookAroundUpDown, PATCH_JUMP); - InjectHook(0x494290, &CPad::ResetAverageWeapon, PATCH_JUMP); - InjectHook(0x4942B0, CPad::PrintErrorMessage, PATCH_JUMP); - InjectHook(0x494420, LittleTest, PATCH_JUMP); - InjectHook(0x494450, CPad::ResetCheats, PATCH_JUMP); - InjectHook(0x4944B0, CPad::EditString, PATCH_JUMP); - InjectHook(0x494690, CPad::EditCodesForControls, PATCH_JUMP); - - //InjectHook(0x494E50, `global constructor keyed to'Pad.cpp, PATCH_JUMP); - //InjectHook(0x494EB0, sub_494EB0, PATCH_JUMP); - //InjectHook(0x494ED0, &CPad::~CPad, PATCH_JUMP); - //InjectHook(0x494EE0, &CPad::CPad, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp index c882fc27..99ca5659 100644 --- a/src/core/Placeable.cpp +++ b/src/core/Placeable.cpp @@ -1,6 +1,6 @@ #include "common.h" #include "Placeable.h" -#include "patcher.h" + CPlaceable::CPlaceable(void) { @@ -62,21 +62,3 @@ CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float y1 <= GetPosition().y && GetPosition().y <= y2 && z1 <= GetPosition().z && GetPosition().z <= z2; } - -#include - -class CPlaceable_ : public CPlaceable -{ -public: - CPlaceable *ctor(void) { return ::new (this) CPlaceable(); } - void dtor(void) { CPlaceable::~CPlaceable(); } -}; - -STARTPATCHES - InjectHook(0x49F9A0, &CPlaceable_::ctor, PATCH_JUMP); - InjectHook(0x49F9E0, &CPlaceable_::dtor, PATCH_JUMP); - - InjectHook(0x49FA00, &CPlaceable::SetHeading, PATCH_JUMP); - InjectHook(0x49FA50, (bool (CPlaceable::*)(float, float, float, float))&CPlaceable::IsWithinArea, PATCH_JUMP); - InjectHook(0x49FAF0, (bool (CPlaceable::*)(float, float, float, float, float, float))&CPlaceable::IsWithinArea, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 0043c2f4..cfa0cea4 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "main.h" #include "PlayerPed.h" #include "Wanted.h" @@ -558,20 +558,3 @@ CPlayerInfo::Process(void) CStats::DistanceTravelledOnFoot += FindPlayerPed()->m_fDistanceTravelled; } } - -STARTPATCHES - InjectHook(0x4B5DC0, &CPlayerInfo::dtor, PATCH_JUMP); - InjectHook(0x4A1700, &CPlayerInfo::LoadPlayerSkin, PATCH_JUMP); - InjectHook(0x4A1750, &CPlayerInfo::DeletePlayerSkin, PATCH_JUMP); - InjectHook(0x4A12E0, &CPlayerInfo::KillPlayer, PATCH_JUMP); - InjectHook(0x4A1330, &CPlayerInfo::ArrestPlayer, PATCH_JUMP); - InjectHook(0x49FC10, &CPlayerInfo::Clear, PATCH_JUMP); - InjectHook(0x4A15C0, &CPlayerInfo::BlowUpRCBuggy, PATCH_JUMP); - InjectHook(0x4A13B0, &CPlayerInfo::CancelPlayerEnteringCars, PATCH_JUMP); - InjectHook(0x4A1400, &CPlayerInfo::MakePlayerSafe, PATCH_JUMP); - InjectHook(0x4A0EC0, &CPlayerInfo::EvaluateCarPosition, PATCH_JUMP); - InjectHook(0x4A15F0, &CPlayerInfo::AwardMoneyForExplosion, PATCH_JUMP); - InjectHook(0x4A0B20, &CPlayerInfo::LoadPlayerInfo, PATCH_JUMP); - InjectHook(0x4A0960, &CPlayerInfo::SavePlayerInfo, PATCH_JUMP); - InjectHook(0x49FD30, &CPlayerInfo::Process, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index 65294368..dfc6974a 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Pools.h" #include "Boat.h" @@ -425,19 +425,3 @@ INITSAVEBUF } VALIDATESAVEBUF(size) } - -STARTPATCHES - InjectHook(0x4A1770, CPools::Initialise, PATCH_JUMP); - InjectHook(0x4A1880, CPools::ShutDown, PATCH_JUMP); - InjectHook(0x4A1A50, CPools::CheckPoolsEmpty, PATCH_JUMP); - InjectHook(0x4A1A80, CPools::GetPedRef, PATCH_JUMP); - InjectHook(0x4A1AA0, CPools::GetPed, PATCH_JUMP); - InjectHook(0x4A1AC0, CPools::GetVehicleRef, PATCH_JUMP); - InjectHook(0x4A1AE0, CPools::GetVehicle, PATCH_JUMP); - InjectHook(0x4A1B00, CPools::GetObjectRef, PATCH_JUMP); - InjectHook(0x4A1B20, CPools::GetObject, PATCH_JUMP); - InjectHook(0x4A2DB0, CPools::MakeSureSlotInObjectPoolIsEmpty, PATCH_JUMP); - InjectHook(0x4A1B40, CPools::LoadVehiclePool, PATCH_JUMP); - InjectHook(0x4A2550, CPools::LoadObjectPool, PATCH_JUMP); - InjectHook(0x4A2B50, CPools::LoadPedPool, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 48b97832..2b3e6f1e 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1,6 +1,6 @@ #include "config.h" #include "common.h" -#include "patcher.h" + #include "RwHelper.h" #include "Radar.h" #include "Camera.h" @@ -1458,51 +1458,3 @@ CRadar::ToggleTargetMarker(float x, float y) } #endif -STARTPATCHES - InjectHook(0x4A3EF0, CRadar::Initialise, PATCH_JUMP); - InjectHook(0x4A3F60, CRadar::Shutdown, PATCH_JUMP); - InjectHook(0x4A4030, CRadar::LoadTextures, PATCH_JUMP); - InjectHook(0x4A4180, CRadar::GetNewUniqueBlipIndex, PATCH_JUMP); - InjectHook(0x4A41C0, CRadar::GetActualBlipArrayIndex, PATCH_JUMP); - InjectHook(0x4A4200, CRadar::DrawMap, PATCH_JUMP); - InjectHook(0x4A42F0, CRadar::DrawBlips, PATCH_JUMP); - InjectHook(0x4A4C70, CRadar::Draw3dMarkers, PATCH_JUMP); - InjectHook(0x4A4F30, CRadar::LimitRadarPoint, PATCH_JUMP); - InjectHook(0x4A4F90, CRadar::CalculateBlipAlpha, PATCH_JUMP); - InjectHook(0x4A5040, CRadar::TransformRadarPointToScreenSpace, PATCH_JUMP); - InjectHook(0x4A50D0, CRadar::TransformRealWorldPointToRadarSpace, PATCH_JUMP); - InjectHook(0x4A5300, CRadar::TransformRadarPointToRealWorldSpace, PATCH_JUMP); - InjectHook(0x4A5530, CRadar::TransformRealWorldToTexCoordSpace, PATCH_JUMP); - InjectHook(0x4A5590, CRadar::SetCoordBlip, PATCH_JUMP); - InjectHook(0x4A5640, CRadar::SetEntityBlip, PATCH_JUMP); - InjectHook(0x4A56C0, CRadar::ClearBlipForEntity, PATCH_JUMP); - InjectHook(0x4A5720, CRadar::ClearBlip, PATCH_JUMP); - InjectHook(0x4A5770, CRadar::ChangeBlipColour, PATCH_JUMP); - InjectHook(0x4A57A0, CRadar::ChangeBlipBrightness, PATCH_JUMP); - InjectHook(0x4A57E0, CRadar::ChangeBlipScale, PATCH_JUMP); - InjectHook(0x4A5810, CRadar::ChangeBlipDisplay, PATCH_JUMP); - InjectHook(0x4A5840, CRadar::SetBlipSprite, PATCH_JUMP); - InjectHook(0x4A5870, CRadar::ShowRadarTrace, PATCH_JUMP); - InjectHook(0x4A59C0, CRadar::ShowRadarMarker, PATCH_JUMP); - InjectHook(0x4A5BB0, CRadar::GetRadarTraceColour, PATCH_JUMP); - InjectHook(0x4A5C60, CRadar::SetRadarMarkerState, PATCH_JUMP); - InjectHook(0x4A5D10, CRadar::DrawRotatingRadarSprite, PATCH_JUMP); - InjectHook(0x4A5EF0, CRadar::DrawRadarSprite, PATCH_JUMP); - InjectHook(0x4A6020, ClipRadarTileCoords, PATCH_JUMP); - InjectHook(0x4A6060, RequestMapSection, PATCH_JUMP); - InjectHook(0x4A60A0, RemoveMapSection, PATCH_JUMP); - InjectHook(0x4A60E0, CRadar::RemoveRadarSections, PATCH_JUMP); - InjectHook(0x4A6100, (void (*)(int32, int32))&CRadar::StreamRadarSections, PATCH_JUMP); - InjectHook(0x4A6160, IsPointInsideRadar, PATCH_JUMP); - InjectHook(0x4A61C0, GetTextureCorners, PATCH_JUMP); - InjectHook(0x4A6250, LineRadarBoxCollision, PATCH_JUMP); - InjectHook(0x4A64A0, CRadar::ClipRadarPoly, PATCH_JUMP); - InjectHook(0x4A67E0, CRadar::DrawRadarSection, PATCH_JUMP); - InjectHook(0x4A69C0, CRadar::DrawRadarMask, PATCH_JUMP); - InjectHook(0x4A6B60, (void (*)(const CVector&))&CRadar::StreamRadarSections, PATCH_JUMP); - InjectHook(0x4A6C20, CRadar::DrawRadarMap, PATCH_JUMP); - InjectHook(0x4A6E30, CRadar::SaveAllRadarBlips, PATCH_JUMP); - InjectHook(0x4A6F30, CRadar::LoadAllRadarBlips, PATCH_JUMP); - //InjectHook(0x4A7000, `global constructor keyed to'Radar.cpp, PATCH_JUMP); - //InjectHook(0x4A7260, sRadarTrace::sRadarTrace, PATCH_JUMP); -ENDPATCHES \ No newline at end of file diff --git a/src/core/References.cpp b/src/core/References.cpp index 668ea9f1..3eb2eaf3 100644 --- a/src/core/References.cpp +++ b/src/core/References.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "World.h" #include "Vehicle.h" #include "PlayerPed.h" @@ -57,9 +57,3 @@ CReferences::PruneAllReferencesInWorld(void) e->PruneReferences(); } } - -STARTPATCHES - InjectHook(0x4A7350, CReferences::Init, PATCH_JUMP); - InjectHook(0x4A7570, CReferences::RemoveReferencesToPlayer, PATCH_JUMP); - InjectHook(0x4A75A0, CReferences::PruneAllReferencesInWorld, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index 8d7a3048..ef3c0ab6 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Stats.h" #include "Text.h" #include "World.h" @@ -418,11 +418,3 @@ void CStats::LoadStats(uint8 *buf, uint32 size) assert(buf - buf_start == size); #undef CopyFromBuf } - -STARTPATCHES - InjectHook(0x48C5A3, CStats::Init, PATCH_JUMP); // CGame::ReInitGameObjectVariables - InjectHook(0x4AB3E0, CStats::SaveStats, PATCH_JUMP); - InjectHook(0x4AB670, CStats::LoadStats, PATCH_JUMP); - InjectHook(0x4AB090, CStats::FindCriminalRatingString, PATCH_JUMP); - InjectHook(0x4AB2A0, CStats::FindCriminalRatingNumber, PATCH_JUMP); -ENDPATCHES \ No newline at end of file diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 56f4a862..039377f4 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "General.h" #include "Pad.h" #include "Hud.h" @@ -2439,82 +2439,3 @@ CStreaming::UpdateForAnimViewer(void) CStreaming::RetryLoadFile(CStreaming::ms_channelError); } } - -STARTPATCHES - InjectHook(0x406430, CStreaming::Init, PATCH_JUMP); - InjectHook(0x406C80, CStreaming::Shutdown, PATCH_JUMP); - InjectHook(0x4076C0, CStreaming::Update, PATCH_JUMP); - InjectHook(0x406CC0, (void (*)(void))CStreaming::LoadCdDirectory, PATCH_JUMP); - InjectHook(0x406DA0, (void (*)(const char*, int))CStreaming::LoadCdDirectory, PATCH_JUMP); - InjectHook(0x409740, CStreaming::ConvertBufferToObject, PATCH_JUMP); - InjectHook(0x409580, CStreaming::FinishLoadingLargeFile, PATCH_JUMP); - InjectHook(0x407EA0, CStreaming::RequestModel, PATCH_JUMP); - InjectHook(0x407FD0, CStreaming::RequestSubway, PATCH_JUMP); - InjectHook(0x408190, CStreaming::RequestBigBuildings, PATCH_JUMP); - InjectHook(0x408210, CStreaming::RequestIslands, PATCH_JUMP); - InjectHook(0x40A890, CStreaming::RequestSpecialModel, PATCH_JUMP); - InjectHook(0x40ADA0, CStreaming::RequestSpecialChar, PATCH_JUMP); - InjectHook(0x54A5F0, CStreaming::HasModelLoaded, PATCH_JUMP); - InjectHook(0x40ADC0, CStreaming::HasSpecialCharLoaded, PATCH_JUMP); - InjectHook(0x40ADE0, CStreaming::SetMissionDoesntRequireSpecialChar, PATCH_JUMP); - - InjectHook(0x408830, CStreaming::RemoveModel, PATCH_JUMP); - InjectHook(0x4083A0, CStreaming::RemoveUnusedBuildings, PATCH_JUMP); - InjectHook(0x4083D0, CStreaming::RemoveBuildings, PATCH_JUMP); - InjectHook(0x408640, CStreaming::RemoveUnusedBigBuildings, PATCH_JUMP); - InjectHook(0x408680, CStreaming::RemoveBigBuildings, PATCH_JUMP); - InjectHook(0x408780, CStreaming::RemoveIslandsNotUsed, PATCH_JUMP); - InjectHook(0x40B180, CStreaming::RemoveLoadedVehicle, PATCH_JUMP); - InjectHook(0x4089B0, CStreaming::RemoveLeastUsedModel, PATCH_JUMP); - InjectHook(0x408940, CStreaming::RemoveAllUnusedModels, PATCH_JUMP); - InjectHook(0x409450, CStreaming::RemoveReferencedTxds, PATCH_JUMP); - - InjectHook(0x40B160, CStreaming::GetAvailableVehicleSlot, PATCH_JUMP); - InjectHook(0x40B060, CStreaming::AddToLoadedVehiclesList, PATCH_JUMP); - InjectHook(0x4094C0, CStreaming::IsTxdUsedByRequestedModels, PATCH_JUMP); - InjectHook(0x407E70, CStreaming::IsObjectInCdImage, PATCH_JUMP); - InjectHook(0x408280, CStreaming::HaveAllBigBuildingsLoaded, PATCH_JUMP); - InjectHook(0x40A790, CStreaming::SetModelIsDeletable, PATCH_JUMP); - InjectHook(0x40A800, CStreaming::SetModelTxdIsDeletable, PATCH_JUMP); - InjectHook(0x40A820, CStreaming::SetMissionDoesntRequireModel, PATCH_JUMP); - - InjectHook(0x40AA00, CStreaming::LoadInitialPeds, PATCH_JUMP); - InjectHook(0x40ADF0, CStreaming::LoadInitialVehicles, PATCH_JUMP); - InjectHook(0x40AE60, CStreaming::StreamVehiclesAndPeds, PATCH_JUMP); - InjectHook(0x40AA30, CStreaming::StreamZoneModels, PATCH_JUMP); - InjectHook(0x40AD00, CStreaming::RemoveCurrentZonesModels, PATCH_JUMP); - - InjectHook(0x409BE0, CStreaming::ProcessLoadingChannel, PATCH_JUMP); - InjectHook(0x40A610, CStreaming::FlushChannels, PATCH_JUMP); - InjectHook(0x40A680, CStreaming::FlushRequestList, PATCH_JUMP); - InjectHook(0x409FF0, CStreaming::GetCdImageOffset, PATCH_JUMP); - InjectHook(0x409E50, CStreaming::GetNextFileOnCd, PATCH_JUMP); - InjectHook(0x40A060, CStreaming::RequestModelStream, PATCH_JUMP); - InjectHook(0x4077F0, CStreaming::RetryLoadFile, PATCH_JUMP); - InjectHook(0x40A390, CStreaming::LoadRequestedModels, PATCH_JUMP); - InjectHook(0x40A440, CStreaming::LoadAllRequestedModels, PATCH_JUMP); - - InjectHook(0x4078F0, CStreaming::AddModelsToRequestList, PATCH_JUMP); - InjectHook(0x407C50, (void (*)(CPtrList&,float,float,float,float,float,float))CStreaming::ProcessEntitiesInSectorList, PATCH_JUMP); - InjectHook(0x407DD0, (void (*)(CPtrList&))CStreaming::ProcessEntitiesInSectorList, PATCH_JUMP); - - InjectHook(0x407070, CStreaming::DeleteFarAwayRwObjects, PATCH_JUMP); - InjectHook(0x407390, CStreaming::DeleteAllRwObjects, PATCH_JUMP); - InjectHook(0x407400, CStreaming::DeleteRwObjectsAfterDeath, PATCH_JUMP); - InjectHook(0x408A60, CStreaming::DeleteRwObjectsBehindCamera, PATCH_JUMP); - InjectHook(0x407560, CStreaming::DeleteRwObjectsInSectorList, PATCH_JUMP); - InjectHook(0x4075A0, CStreaming::DeleteRwObjectsInOverlapSectorList, PATCH_JUMP); - InjectHook(0x409340, CStreaming::DeleteRwObjectsBehindCameraInSectorList, PATCH_JUMP); - InjectHook(0x4093C0, CStreaming::DeleteRwObjectsNotInFrustumInSectorList, PATCH_JUMP); - InjectHook(0x409B70, CStreaming::MakeSpaceFor, PATCH_JUMP); - InjectHook(0x40A6D0, CStreaming::LoadScene, PATCH_JUMP); - - InjectHook(0x40B210, CStreaming::MemoryCardSave, PATCH_JUMP); - InjectHook(0x40B250, CStreaming::MemoryCardLoad, PATCH_JUMP); - - InjectHook(0x4063E0, &CStreamingInfo::GetCdPosnAndSize, PATCH_JUMP); - InjectHook(0x406410, &CStreamingInfo::SetCdPosnAndSize, PATCH_JUMP); - InjectHook(0x4063D0, &CStreamingInfo::GetCdSize, PATCH_JUMP); - InjectHook(0x406380, &CStreamingInfo::AddToList, PATCH_JUMP); - InjectHook(0x4063A0, &CStreamingInfo::RemoveFromList, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/SurfaceTable.cpp b/src/core/SurfaceTable.cpp index 85572fbd..7212fc65 100644 --- a/src/core/SurfaceTable.cpp +++ b/src/core/SurfaceTable.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "main.h" #include "FileMgr.h" #include "Weather.h" @@ -141,10 +141,3 @@ CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint) { return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)]; } - -STARTPATCHES - InjectHook(0x4AB8F0, CSurfaceTable::Initialise, PATCH_JUMP); - InjectHook(0x4ABA60, CSurfaceTable::GetAdhesionGroup, PATCH_JUMP); - InjectHook(0x4ABAA0, CSurfaceTable::GetWetMultiplier, PATCH_JUMP); - InjectHook(0x4ABA30, CSurfaceTable::GetAdhesiveLimit, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp index 05b272ab..79d6252b 100644 --- a/src/core/TempColModels.cpp +++ b/src/core/TempColModels.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "TempColModels.h" #include "SurfaceTable.h" @@ -287,7 +287,3 @@ CTempColModels::Initialise(void) #undef SET_COLMODEL_SPHERES } - -STARTPATCHES - InjectHook(0x412160, CTempColModels::Initialise, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index 68b31e6f..ebd79695 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -1,6 +1,6 @@ #include #include "common.h" -#include "patcher.h" + #include "DMAudio.h" #include "Record.h" #include "Timer.h" @@ -225,18 +225,3 @@ uint32 CTimer::GetCyclesPerFrame() return 20; } -#if 1 -STARTPATCHES - InjectHook(0x4ACE60, CTimer::Initialise, PATCH_JUMP); - InjectHook(0x4ACF60, CTimer::Shutdown, PATCH_JUMP); - InjectHook(0x4ACF70, CTimer::Update, PATCH_JUMP); - InjectHook(0x4AD310, CTimer::Suspend, PATCH_JUMP); - InjectHook(0x4AD370, CTimer::Resume, PATCH_JUMP); - InjectHook(0x4AD3F0, CTimer::GetCyclesPerMillisecond, PATCH_JUMP); - InjectHook(0x4AD410, CTimer::GetCurrentTimeInCycles, PATCH_JUMP); - InjectHook(0x4AD450, CTimer::GetIsSlowMotionActive, PATCH_JUMP); - InjectHook(0x4AD480, CTimer::Stop, PATCH_JUMP); - InjectHook(0x4AD490, CTimer::StartUserPause, PATCH_JUMP); - InjectHook(0x4AD4A0, CTimer::EndUserPause, PATCH_JUMP); -ENDPATCHES -#endif diff --git a/src/core/User.cpp b/src/core/User.cpp index a1a69b2d..36f07cbd 100644 --- a/src/core/User.cpp +++ b/src/core/User.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Hud.h" #include "PlayerPed.h" @@ -120,16 +120,3 @@ CUserDisplay::Process() Pager.Process(); CurrentVehicle.Process(); } - -STARTPATCHES - InjectHook(0x4AD4C0, &CPlaceName::Init, PATCH_JUMP); - InjectHook(0x4AD4E0, &CPlaceName::Process, PATCH_JUMP); - InjectHook(0x4AD5B0, &CPlaceName::Display, PATCH_JUMP); - - InjectHook(0x4AD5F0, &CCurrentVehicle::Init, PATCH_JUMP); - InjectHook(0x4AD600, &CCurrentVehicle::Process, PATCH_JUMP); - InjectHook(0x4AD630, &CCurrentVehicle::Display, PATCH_JUMP); - - InjectHook(0x4AD660, &CUserDisplay::Init, PATCH_JUMP); - InjectHook(0x4AD690, &CUserDisplay::Process, PATCH_JUMP); -ENDPATCHES \ No newline at end of file diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index 1911ae59..ce7d217e 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Pools.h" #include "ModelIndices.h" #include "Timer.h" @@ -456,25 +456,3 @@ CWanted::UpdateCrimesQ(void) } } } - -STARTPATCHES - InjectHook(0x4AD6E0, &CWanted::Initialise, PATCH_JUMP); - InjectHook(0x4AD790, &CWanted::Reset, PATCH_JUMP); - InjectHook(0x4AD7B0, &CWanted::Update, PATCH_JUMP); - InjectHook(0x4AD900, &CWanted::UpdateWantedLevel, PATCH_JUMP); - InjectHook(0x4AD9F0, &CWanted::RegisterCrime, PATCH_JUMP); - InjectHook(0x4ADA10, &CWanted::RegisterCrime_Immediately, PATCH_JUMP); - InjectHook(0x4ADA50, &CWanted::SetWantedLevel, PATCH_JUMP); - InjectHook(0x4ADAC0, &CWanted::SetWantedLevelNoDrop, PATCH_JUMP); - InjectHook(0x4ADAE0, &CWanted::SetMaximumWantedLevel, PATCH_JUMP); - InjectHook(0x4ADBA0, &CWanted::AreSwatRequired, PATCH_JUMP); - InjectHook(0x4ADBC0, &CWanted::AreFbiRequired, PATCH_JUMP); - InjectHook(0x4ADBE0, &CWanted::AreArmyRequired, PATCH_JUMP); - InjectHook(0x4ADC00, &CWanted::NumOfHelisRequired, PATCH_JUMP); - InjectHook(0x4ADC40, &CWanted::ResetPolicePursuit, PATCH_JUMP); - InjectHook(0x4ADD00, &CWanted::WorkOutPolicePresence, PATCH_JUMP); - InjectHook(0x4ADF20, &CWanted::ClearQdCrimes, PATCH_JUMP); - InjectHook(0x4ADFD0, &CWanted::AddCrimeToQ, PATCH_JUMP); - InjectHook(0x4AE090, &CWanted::UpdateCrimesQ, PATCH_JUMP); - InjectHook(0x4AE110, &CWanted::ReportCrimeNow, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/World.cpp b/src/core/World.cpp index c9e3c11f..eacb3404 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -27,28 +27,28 @@ #include "Vehicle.h" #include "WaterLevel.h" #include "common.h" -#include "patcher.h" + #define OBJECT_REPOSITION_OFFSET_Z 2.0f CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; -CPtrList *CWorld::ms_bigBuildingsList = (CPtrList *)0x6FAB60; -CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList *)0x8F433C; -CSector (*CWorld::ms_aSectors)[NUMSECTORS_X] = (CSector(*)[NUMSECTORS_Y])0x665608; -uint16 &CWorld::ms_nCurrentScanCode = *(uint16 *)0x95CC64; +CPtrList CWorld::ms_bigBuildingsList[4];// = (CPtrList*)0x6FAB60; +CPtrList CWorld::ms_listMovingEntityPtrs;// = *(CPtrList*)0x8F433C; +CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];// = (CSector (*)[NUMSECTORS_Y])0x665608; +uint16 CWorld::ms_nCurrentScanCode;// = *(uint16*)0x95CC64; -uint8 &CWorld::PlayerInFocus = *(uint8 *)0x95CD61; +uint8 CWorld::PlayerInFocus;// = *(uint8 *)0x95CD61; CPlayerInfo CWorld::Players[NUMPLAYERS]; -bool &CWorld::bNoMoreCollisionTorque = *(bool *)0x95CDCC; -CEntity *&CWorld::pIgnoreEntity = *(CEntity **)0x8F6494; -bool &CWorld::bIncludeDeadPeds = *(bool *)0x95CD8F; -bool &CWorld::bSecondShift = *(bool *)0x95CD54; -bool &CWorld::bForceProcessControl = *(bool *)0x95CD6C; -bool &CWorld::bProcessCutsceneOnly = *(bool *)0x95CD8B; +bool CWorld::bNoMoreCollisionTorque;// = *(bool*)0x95CDCC; +CEntity *CWorld::pIgnoreEntity;// = *(CEntity**)0x8F6494; +bool CWorld::bIncludeDeadPeds;// = *(bool*)0x95CD8F; +bool CWorld::bSecondShift;// = *(bool*)0x95CD54; +bool CWorld::bForceProcessControl;// = *(bool*)0x95CD6C; +bool CWorld::bProcessCutsceneOnly;// = *(bool*)0x95CD8B; -bool &CWorld::bDoingCarCollisions = *(bool *)0x95CD8C; -bool &CWorld::bIncludeCarTyres = *(bool *)0x95CDAA; +bool CWorld::bDoingCarCollisions;// = *(bool*)0x95CD8C; +bool CWorld::bIncludeCarTyres;// = *(bool*)0x95CDAA; void CWorld::Initialise() @@ -2215,32 +2215,3 @@ CWorld::UseDetonator(CEntity *pEntity) } } } - -STARTPATCHES - InjectHook(0x4AE930, CWorld::Add, PATCH_JUMP); - InjectHook(0x4AE9D0, CWorld::Remove, PATCH_JUMP); - InjectHook(0x4B1F60, CWorld::ClearScanCodes, PATCH_JUMP); - InjectHook(0x4AF970, CWorld::ProcessLineOfSight, PATCH_JUMP); - InjectHook(0x4B0A80, CWorld::ProcessLineOfSightSector, PATCH_JUMP); - InjectHook(0x4B0C70, CWorld::ProcessLineOfSightSectorList, PATCH_JUMP); - InjectHook(0x4B0DE0, CWorld::ProcessVerticalLine, PATCH_JUMP); - InjectHook(0x4B0EF0, CWorld::ProcessVerticalLineSector, PATCH_JUMP); - InjectHook(0x4B1090, CWorld::ProcessVerticalLineSectorList, PATCH_JUMP); - InjectHook(0x4AEAA0, CWorld::GetIsLineOfSightClear, PATCH_JUMP); - InjectHook(0x4B2000, CWorld::GetIsLineOfSightSectorClear, PATCH_JUMP); - InjectHook(0x4B2160, CWorld::GetIsLineOfSightSectorListClear, PATCH_JUMP); - - InjectHook(0x4B2200, CWorld::FindObjectsInRange, PATCH_JUMP); - InjectHook(0x4B2540, CWorld::FindObjectsInRangeSectorList, PATCH_JUMP); - InjectHook(0x4B4AC0, CWorld::TestSphereAgainstSectorList, PATCH_JUMP); - InjectHook(0x4B4710, CWorld::TestSphereAgainstWorld, PATCH_JUMP); - InjectHook(0x4B3A80, CWorld::FindGroundZForCoord, PATCH_JUMP); - InjectHook(0x4B3AE0, CWorld::FindGroundZFor3DCoord, PATCH_JUMP); - InjectHook(0x4B3B50, CWorld::FindRoofZFor3DCoord, PATCH_JUMP); - - InjectHook(0x4B5BC0, CWorld::StopAllLawEnforcersInTheirTracks, PATCH_JUMP); - InjectHook(0x4B53F0, CWorld::SetAllCarsCanBeDamaged, PATCH_JUMP); - InjectHook(0x4B5460, CWorld::ExtinguishAllCarFiresInArea, PATCH_JUMP); - - InjectHook(0x4B1A60, CWorld::Process, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/World.h b/src/core/World.h index a1e2acfd..25c76531 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -54,22 +54,22 @@ struct CStoredCollPoly; class CWorld { - static CPtrList *ms_bigBuildingsList; // [4]; - static CPtrList &ms_listMovingEntityPtrs; - static CSector (*ms_aSectors)[NUMSECTORS_X]; // [NUMSECTORS_Y][NUMSECTORS_X]; - static uint16 &ms_nCurrentScanCode; + static CPtrList ms_bigBuildingsList[4]; + static CPtrList ms_listMovingEntityPtrs; + static CSector ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X]; + static uint16 ms_nCurrentScanCode; public: - static uint8 &PlayerInFocus; + static uint8 PlayerInFocus; static CPlayerInfo Players[NUMPLAYERS]; - static CEntity *&pIgnoreEntity; - static bool &bIncludeDeadPeds; - static bool &bNoMoreCollisionTorque; - static bool &bSecondShift; - static bool &bForceProcessControl; - static bool &bProcessCutsceneOnly; - static bool &bDoingCarCollisions; - static bool &bIncludeCarTyres; + static CEntity *pIgnoreEntity; + static bool bIncludeDeadPeds; + static bool bNoMoreCollisionTorque; + static bool bSecondShift; + static bool bForceProcessControl; + static bool bProcessCutsceneOnly; + static bool bDoingCarCollisions; + static bool bIncludeCarTyres; static void Remove(CEntity *entity); static void Add(CEntity *entity); diff --git a/src/core/ZoneCull.cpp b/src/core/ZoneCull.cpp index 4cdd283e..d17a33d4 100644 --- a/src/core/ZoneCull.cpp +++ b/src/core/ZoneCull.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Building.h" #include "Treadable.h" #include "Train.h" @@ -562,17 +562,3 @@ CCullZones::DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set) } return false; } - -STARTPATCHES - InjectHook(0x524BC0, &CCullZones::Init, PATCH_JUMP); - InjectHook(0x524EC0, &CCullZones::ResolveVisibilities, PATCH_JUMP); - InjectHook(0x524F80, &CCullZones::Update, PATCH_JUMP); - InjectHook(0x525370, &CCullZones::AddCullZone, PATCH_JUMP); - InjectHook(0x5250D0, &CCullZones::ForceCullZoneCoors, PATCH_JUMP); - InjectHook(0x525130, &CCullZones::FindCullZoneForCoors, PATCH_JUMP); - InjectHook(0x5251C0, &CCullZones::FindAttributesForCoors, PATCH_JUMP); - InjectHook(0x525290, &CCullZones::FindZoneWithStairsAttributeForPlayer, PATCH_JUMP); - - InjectHook(0x525610, &CCullZone::DoStuffLeavingZone, PATCH_JUMP); - InjectHook(0x525810, &CCullZone::DoStuffEnteringZone, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 39d4c3b5..6375de1c 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include #include "Zones.h" @@ -840,36 +840,3 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 length) TotalNumberOfMapZones = *(uint16*)(buffer); NumberOfAudioZones = *(uint16*)(buffer+2); } - - -STARTPATCHES - InjectHook(0x4B5DD0, &CZone::GetTranslatedName, PATCH_JUMP); - InjectHook(0x4B5DE0, CTheZones::Init, PATCH_JUMP); - InjectHook(0x4B61D0, CTheZones::Update, PATCH_JUMP); - InjectHook(0x4B6210, CTheZones::CreateZone, PATCH_JUMP); - InjectHook(0x4B6380, CTheZones::CreateMapZone, PATCH_JUMP); - InjectHook(0x4B64C0, CTheZones::PostZoneCreation, PATCH_JUMP); - InjectHook(0x4B6500, CTheZones::InsertZoneIntoZoneHierarchy, PATCH_JUMP); - InjectHook(0x4B6530, CTheZones::InsertZoneIntoZoneHierRecursive, PATCH_JUMP); - InjectHook(0x4B65F0, CTheZones::ZoneIsEntirelyContainedWithinOtherZone, PATCH_JUMP); - InjectHook(0x4B6710, CTheZones::PointLiesWithinZone, PATCH_JUMP); - InjectHook(0x4B6910, CTheZones::GetLevelFromPosition, PATCH_JUMP); - InjectHook(0x4B69B0, CTheZones::FindSmallestZonePosition, PATCH_JUMP); - InjectHook(0x4B6790, CTheZones::FindSmallestZonePositionType, PATCH_JUMP); - InjectHook(0x4B6890, CTheZones::FindSmallestZonePositionILN, PATCH_JUMP); - InjectHook(0x4B6800, CTheZones::FindZoneByLabelAndReturnIndex, PATCH_JUMP); - InjectHook(0x4B6FA0, CTheZones::GetZone, PATCH_JUMP); - InjectHook(0x4B84F0, CTheZones::GetPointerForZoneIndex, PATCH_JUMP); - InjectHook(0x4B6A10, CTheZones::GetZoneInfo, PATCH_JUMP); - InjectHook(0x4B6FB0, CTheZones::GetZoneInfoForTimeOfDay, PATCH_JUMP); - InjectHook(0x4B6A50, CTheZones::SetZoneCarInfo, PATCH_JUMP); - InjectHook(0x4B6DC0, CTheZones::SetZonePedInfo, PATCH_JUMP); - InjectHook(0x4B6EB0, CTheZones::SetCarDensity, PATCH_JUMP); - InjectHook(0x4B6F00, CTheZones::SetPedDensity, PATCH_JUMP); - InjectHook(0x4B6F50, CTheZones::SetPedGroup, PATCH_JUMP); - InjectHook(0x4B83E0, CTheZones::FindAudioZone, PATCH_JUMP); - InjectHook(0x4B8430, CTheZones::FindZoneForPoint, PATCH_JUMP); - InjectHook(0x4B8340, CTheZones::AddZoneToAudioZoneArray, PATCH_JUMP); - InjectHook(0x4B8510, CTheZones::SaveAllZones, PATCH_JUMP); - InjectHook(0x4B8950, CTheZones::LoadAllZones, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/main.cpp b/src/core/main.cpp index 1b46d453..d5d4065d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -2,7 +2,7 @@ #include "rpmatfx.h" #include "rphanim.h" #include "rpskin.h" -#include "patcher.h" + #include "main.h" #include "CdStream.h" #include "General.h" @@ -1838,28 +1838,3 @@ main(int argc, char *argv[]) return 0; } - -STARTPATCHES - InjectHook(0x48E480, Idle, PATCH_JUMP); - InjectHook(0x48E700, FrontendIdle, PATCH_JUMP); - - InjectHook(0x48CF10, DoRWStuffStartOfFrame, PATCH_JUMP); - InjectHook(0x48D040, DoRWStuffStartOfFrame_Horizon, PATCH_JUMP); - InjectHook(0x48E030, RenderScene, PATCH_JUMP); - InjectHook(0x48E080, RenderDebugShit, PATCH_JUMP); - InjectHook(0x48E090, RenderEffects, PATCH_JUMP); - InjectHook(0x48E0E0, Render2dStuff, PATCH_JUMP); - InjectHook(0x48E450, RenderMenus, PATCH_JUMP); - InjectHook(0x48D120, DoFade, PATCH_JUMP); - InjectHook(0x48E470, Render2dStuffAfterFade, PATCH_JUMP); - - InjectHook(0x48D550, LoadSplash, PATCH_JUMP); - InjectHook(0x48D670, DestroySplashScreen, PATCH_JUMP); - InjectHook(0x48D770, LoadingScreen, PATCH_JUMP); - InjectHook(0x48D760, ResetLoadingScreenBar, PATCH_JUMP); - - InjectHook(0x48D470, PluginAttach, PATCH_JUMP); - InjectHook(0x48D520, Initialise3D, PATCH_JUMP); - InjectHook(0x48D540, Terminate3D, PATCH_JUMP); - InjectHook(0x48E800, AppEventHandler, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 2046a7f9..e5f42696 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -29,18 +29,12 @@ #include -#ifndef RWLIBS -void **rwengine = *(void***)0x5A10E1; -#else +#ifdef RWLIBS extern "C" int vsprintf(char* const _Buffer, char const* const _Format, va_list _ArgList); #endif DebugMenuAPI gDebugMenuAPI; -STARTPATCHES - InjectHook(0x5A07E0, (void (*)(void*)) &operator delete, PATCH_JUMP); - InjectHook(0x5A0690, (void* (*)(size_t)) &operator new, PATCH_JUMP); -ENDPATCHES #ifdef USE_PS2_RAND unsigned __int64 myrand_seed = 1; @@ -387,7 +381,7 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); extern bool PrintDebugCode; - extern int16 &DebugCamMode; + extern int16 DebugCamMode; DebugMenuAddVarBool8("Cam", "Use mouse Cam", (int8*)&CCamera::m_bUseMouse3rdPerson, nil); #ifdef FREE_CAM DebugMenuAddVarBool8("Cam", "Free Cam", (int8*)&CCamera::bFreeCam, nil); @@ -494,37 +488,3 @@ void re3_trace(const char *filename, unsigned int lineno, const char *func, cons #ifdef VALIDATE_SAVE_SIZE int32 _saveBufCount; #endif - -void -patch() -{ - StaticPatcher::Apply(); - -// Patch(0x46BC61+6, 1.0f); // car distance - InjectHook(0x59E460, printf, PATCH_JUMP); - InjectHook(0x475E00, printf, PATCH_JUMP); // _Error - - -// InterceptCall(&open_script_orig, open_script, 0x438869); - -// InterceptCall(&RsEventHandler_orig, delayedPatches10, 0x58275E); -} - -BOOL WINAPI -DllMain(HINSTANCE hInst, DWORD reason, LPVOID) -{ - if(reason == DLL_PROCESS_ATTACH){ - - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - - if (*(DWORD*)0x5C1E75 == 0xB85548EC) // 1.0 - patch(); - else - return FALSE; - } - - return TRUE; -} -- cgit v1.2.3 From 63951d9b957b30a110f42a03edb4833cbbaf380e Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 17 Apr 2020 19:30:57 +0200 Subject: Part one --- src/core/CrimeType.h | 23 +++++++++++++++++++++++ src/core/Game.cpp | 2 +- src/core/General.h | 2 +- src/core/Pad.cpp | 2 +- src/core/PlayerInfo.cpp | 2 +- src/core/Wanted.h | 22 +--------------------- src/core/common.h | 4 ++-- 7 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 src/core/CrimeType.h (limited to 'src/core') diff --git a/src/core/CrimeType.h b/src/core/CrimeType.h new file mode 100644 index 00000000..23f609eb --- /dev/null +++ b/src/core/CrimeType.h @@ -0,0 +1,23 @@ +#pragma once + +enum eCrimeType +{ + CRIME_NONE, + CRIME_POSSESSION_GUN, + CRIME_HIT_PED, + CRIME_HIT_COP, + CRIME_SHOOT_PED, + CRIME_SHOOT_COP, + CRIME_STEAL_CAR, + CRIME_RUN_REDLIGHT, + CRIME_RECKLESS_DRIVING, + CRIME_SPEEDING, + CRIME_RUNOVER_PED, + CRIME_RUNOVER_COP, + CRIME_SHOOT_HELI, + CRIME_PED_BURNED, + CRIME_COP_BURNED, + CRIME_VEHICLE_BURNED, + CRIME_DESTROYED_CESSNA, + NUM_CRIME_TYPES +}; \ No newline at end of file diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 7ccf78d0..8b2f8604 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -72,7 +72,7 @@ #include "Streaming.h" #include "SurfaceTable.h" #include "TempColModels.h" -#include "TimeCycle.h" +#include "Timecycle.h" #include "TrafficLights.h" #include "Train.h" #include "TxdStore.h" diff --git a/src/core/General.h b/src/core/General.h index 77828854..103bafde 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -124,7 +124,7 @@ public: static bool faststricmp(const char *str1, const char *str2) { for (; *str1; str1++, str2++) { -#if MUCH_SLOWER +#if 1 if (toupper(*str1) != toupper(*str2)) #else if (__ascii_toupper(*str1) != __ascii_toupper(*str2)) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 86aff05e..49affbbe 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -6,7 +6,7 @@ #include "common.h" #ifdef XINPUT -#include +#include #pragma comment( lib, "Xinput9_1_0.lib" ) #endif diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index cfa0cea4..3852f540 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -180,7 +180,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle) m_pPed->bExplosionProof = true; m_pPed->m_bCanBeDamaged = false; ((CPlayerPed*)m_pPed)->ClearAdrenaline(); - CancelPlayerEnteringCars(false); + CancelPlayerEnteringCars(nil); gFireManager.ExtinguishPoint(GetPos(), 4000.0f); CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f); CProjectileInfo::RemoveAllProjectiles(); diff --git a/src/core/Wanted.h b/src/core/Wanted.h index afeec8b0..c5e9d388 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -3,27 +3,7 @@ class CEntity; class CCopPed; -enum eCrimeType -{ - CRIME_NONE, - CRIME_POSSESSION_GUN, - CRIME_HIT_PED, - CRIME_HIT_COP, - CRIME_SHOOT_PED, - CRIME_SHOOT_COP, - CRIME_STEAL_CAR, - CRIME_RUN_REDLIGHT, - CRIME_RECKLESS_DRIVING, - CRIME_SPEEDING, - CRIME_RUNOVER_PED, - CRIME_RUNOVER_COP, - CRIME_SHOOT_HELI, - CRIME_PED_BURNED, - CRIME_COP_BURNED, - CRIME_VEHICLE_BURNED, - CRIME_DESTROYED_CESSNA, - NUM_CRIME_TYPES -}; +#include "CrimeType.h" class CCrimeBeingQd { diff --git a/src/core/common.h b/src/core/common.h index 454b848a..e10b222c 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -12,7 +12,7 @@ #include #ifdef WITHWINDOWS -#include +#include #endif #ifdef WITHD3D @@ -62,7 +62,7 @@ typedef int64_t int64; typedef uint16_t wchar; #ifndef nil -#define nil nullptr +#define nil NULL #endif #include "config.h" -- cgit v1.2.3 From 812b9e7edab26cc04d28931b0e89ed9317b818c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 18 Apr 2020 05:58:43 +0300 Subject: Various fixes --- src/core/Frontend.cpp | 15 +++++++++------ src/core/Frontend.h | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 790de046..e9282c44 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -118,7 +118,7 @@ const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255); const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color #endif -const float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // not original name +const float menuXYpadding = MENUACTION_POS_Y; // TODO this is non-existant, remove it float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; @@ -754,9 +754,9 @@ CMenuManager::Draw() #ifdef FIX_BUGS // Label is wrapped from right by StretchX(40)px, but wrapped from left by 40px. And this is only place R* didn't use StretchX in here. - CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(menuXYpadding), str); + CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(MENUACTION_POS_Y), str); #else - CFont::PrintString(MENU_X_MARGIN, menuXYpadding, str); + CFont::PrintString(MENU_X_MARGIN, MENUACTION_POS_Y, str); #endif } @@ -3181,7 +3181,7 @@ CMenuManager::PrintBriefs() CFont::SetRightJustifyOff(); CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why - float nextY = 40.0f; + float nextY = BRIEFS_TOP_MARGIN; CRGBA newColor; for (int i = 4; i >= 0; i--) { tPreviousBrief &brief = CMessages::PreviousBriefs[i]; @@ -3214,8 +3214,8 @@ CMenuManager::PrintBriefs() newColor.a = FadeIn(255); CFont::SetColor(newColor); #endif - CFont::PrintString(MENU_X_LEFT_ALIGNED(50.0f), nextY, gUString); - nextY += MENU_Y(menuXYpadding); + CFont::PrintString(MENU_X_LEFT_ALIGNED(BRIEFS_LINE_X), nextY, gUString); + nextY += MENU_Y(BRIEFS_LINE_HEIGHT); } } @@ -3252,6 +3252,9 @@ void CMenuManager::PrintStats() { int rowNum = ConstructStatLine(99999); +#ifdef GTA3_1_1_PATCH + CFont::SetFontStyle(FONT_BANK); +#endif CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why float nextYChange, y, alphaMult; diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 8fe61a36..41c12122 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -68,6 +68,10 @@ #define STATS_RATING_X 24.0f #define STATS_RATING_Y 20.0f +#define BRIEFS_TOP_MARGIN 40.0f +#define BRIEFS_LINE_X 50.0f +#define BRIEFS_LINE_HEIGHT 60.0f + #define CONTSETUP_STANDARD_ROW_HEIGHT 10.7f #define CONTSETUP_CLASSIC_ROW_HEIGHT 9.0f #define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10 -- cgit v1.2.3 From e41c32df431a5cf5df8740c43766d6fcd9200d77 Mon Sep 17 00:00:00 2001 From: gennariarmando Date: Fri, 17 Apr 2020 20:22:33 +0200 Subject: Fixed menu radio icons. --- src/core/Frontend.cpp | 75 ++++++++++++++++++++++++++------------------------- src/core/Frontend.h | 13 ++++----- 2 files changed, 44 insertions(+), 44 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 790de046..20b13820 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -118,7 +118,7 @@ const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255); const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color #endif -const float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // not original name +const float menuXYpadding = MENUACTION_POS_Y; // TODO this is non-existant, remove it float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; @@ -167,15 +167,15 @@ const char* FrontendFilenames[][2] = { {"fe_arrows2", "" }, {"fe_arrows3", "" }, {"fe_arrows4", "" }, - {"fe_radio1", "" }, // HEAD_RADIO - {"fe_radio2", "" }, // DOUBLE_CLEF - {"fe_radio3", "" }, // JAH_RADIO - {"fe_radio4", "" }, // RISE_FM - {"fe_radio5", "" }, // LIPS_106 - {"fe_radio6", "" }, // GAME_FM - {"fe_radio7", "" }, // MSX_FM - {"fe_radio8", "" }, // FLASHBACK - {"fe_radio9", "" }, // CHATTERBOX + {"fe_radio1", "" }, + {"fe_radio2", "" }, + {"fe_radio3", "" }, + {"fe_radio4", "" }, + {"fe_radio5", "" }, + {"fe_radio6", "" }, + {"fe_radio7", "" }, + {"fe_radio8", "" }, + {"fe_radio9", "" }, }; #ifdef MENU_MAP @@ -231,7 +231,8 @@ ScaleAndCenterX(float x) else { if (x > DEFAULT_SCREEN_WIDTH / 2) { return SCREEN_WIDTH / 2 + SCREEN_SCALE_X(x - DEFAULT_SCREEN_WIDTH / 2); - } else { + } + else { return SCREEN_WIDTH / 2 - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH / 2 - x); } } @@ -303,6 +304,11 @@ ScaleAndCenterX(float x) m_nHoverOption = HOVEROPTION_NOT_HOVERING; \ } while(0) +#define ProcessRadioIcon(sprite, x, y, radioId, hoverOpt) \ + sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); \ + if (CheckHover(x, x + MENU_X(MENURADIO_ICON_SCALE), y, y + MENU_Y(MENURADIO_ICON_SCALE))) \ + m_nHoverOption = hoverOpt; + // --- Functions not in the game/inlined starts inline void @@ -754,9 +760,9 @@ CMenuManager::Draw() #ifdef FIX_BUGS // Label is wrapped from right by StretchX(40)px, but wrapped from left by 40px. And this is only place R* didn't use StretchX in here. - CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(menuXYpadding), str); + CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(MENUACTION_POS_Y), str); #else - CFont::PrintString(MENU_X_MARGIN, menuXYpadding, str); + CFont::PrintString(MENU_X_MARGIN, MENUACTION_POS_Y, str); #endif } @@ -1253,27 +1259,21 @@ CMenuManager::Draw() nextYToUse += lineHeight * CFont::GetNumberLines(menuXYpadding, nextYToUse, leftText); - // TODO: This should be rewritten as multiple macro calls instead of loop, radio order is wrong. - // And hover detection is missing. - float fIconSpacing = 59.52f; + // Radio icons if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_RADIO) { - for (int i = 0; i < POLICE_RADIO; i++) { -#ifndef ASPECT_RATIO_SCALE - if (i < USERTRACK) - m_aFrontEndSprites[i + FE_RADIO1].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); - if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) - m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw(SCREEN_STRETCH_X(MENURADIO_ICON_X + fIconSpacing * i), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENURADIO_ICON_Y), SCREEN_SCALE_X(MENURADIO_ICON_W), SCREEN_SCALE_Y(MENURADIO_ICON_H), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); -#else - float fMp3Pos = 0.0f; - if (DMAudio.IsMP3RadioChannelAvailable()) - fMp3Pos = 34.0f; - - if (i < USERTRACK) - m_aFrontEndSprites[i + FE_RADIO1].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), MENU_Y(nextYToUse), MENU_X(menuXYpadding), MENU_Y(menuXYpadding), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); - if (i > CHATTERBOX && DMAudio.IsMP3RadioChannelAvailable()) - m_aMenuSprites[MENUSPRITE_MP3LOGO].Draw((SCREEN_WIDTH * 0.5) + SCREEN_SCALE_X(-fMp3Pos + MENURADIO_ICON_X + (fIconSpacing * i)), MENU_Y(nextYToUse), MENU_X(menuXYpadding), MENU_Y(menuXYpadding), i == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); -#endif - } + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO1], MENU_X_LEFT_ALIGNED(30.0f), MENU_Y(nextYToUse), 0, HOVEROPTION_RADIO_0); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO2], MENU_X_LEFT_ALIGNED(90.0f), MENU_Y(nextYToUse), 1, HOVEROPTION_RADIO_1); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO5], MENU_X_LEFT_ALIGNED(150.0f), MENU_Y(nextYToUse), 2, HOVEROPTION_RADIO_2); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO7], MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(nextYToUse), 3, HOVEROPTION_RADIO_3); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO8], MENU_X_LEFT_ALIGNED(270.0f), MENU_Y(nextYToUse), 4, HOVEROPTION_RADIO_4); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO3], MENU_X_LEFT_ALIGNED(320.0f), MENU_Y(nextYToUse), 5, HOVEROPTION_RADIO_5); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO4], MENU_X_LEFT_ALIGNED(360.0f), MENU_Y(nextYToUse), 6, HOVEROPTION_RADIO_6); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO6], MENU_X_LEFT_ALIGNED(420.0f), MENU_Y(nextYToUse), 7, HOVEROPTION_RADIO_7); + ProcessRadioIcon(m_aFrontEndSprites[FE_RADIO9], MENU_X_LEFT_ALIGNED(480.0f), MENU_Y(nextYToUse), 8, HOVEROPTION_RADIO_8); + + if (DMAudio.IsMP3RadioChannelAvailable()) + ProcessRadioIcon(m_aMenuSprites[MENUSPRITE_MP3LOGO], MENU_X_LEFT_ALIGNED(540.0f), MENU_Y(nextYToUse), 9, HOVEROPTION_RADIO_9); + nextYToUse += 70.0f; } } @@ -3181,7 +3181,7 @@ CMenuManager::PrintBriefs() CFont::SetRightJustifyOff(); CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why - float nextY = 40.0f; + float nextY = BRIEFS_TOP_MARGIN; CRGBA newColor; for (int i = 4; i >= 0; i--) { tPreviousBrief &brief = CMessages::PreviousBriefs[i]; @@ -3214,8 +3214,8 @@ CMenuManager::PrintBriefs() newColor.a = FadeIn(255); CFont::SetColor(newColor); #endif - CFont::PrintString(MENU_X_LEFT_ALIGNED(50.0f), nextY, gUString); - nextY += MENU_Y(menuXYpadding); + CFont::PrintString(MENU_X_LEFT_ALIGNED(BRIEFS_LINE_X), nextY, gUString); + nextY += MENU_Y(BRIEFS_LINE_HEIGHT); } } @@ -3252,6 +3252,9 @@ void CMenuManager::PrintStats() { int rowNum = ConstructStatLine(99999); +#ifdef GTA3_1_1_PATCH + CFont::SetFontStyle(FONT_BANK); +#endif CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why float nextYChange, y, alphaMult; diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 8fe61a36..71aac605 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -18,14 +18,7 @@ #define MENUACTION_WIDTH 38.0f #define MENUACTION_SCALE_MULT 0.9f -#ifndef ASPECT_RATIO_SCALE -#define MENURADIO_ICON_X 31.5f -#else -#define MENURADIO_ICON_X -262.0f -#endif -#define MENURADIO_ICON_Y 29.5f -#define MENURADIO_ICON_W 60.0f -#define MENURADIO_ICON_H 60.0f +#define MENURADIO_ICON_SCALE 60.0f #define MENUSLIDER_X 256.0f #define MENUSLIDER_UNK 256.0f @@ -68,6 +61,10 @@ #define STATS_RATING_X 24.0f #define STATS_RATING_Y 20.0f +#define BRIEFS_TOP_MARGIN 40.0f +#define BRIEFS_LINE_X 50.0f +#define BRIEFS_LINE_HEIGHT 60.0f + #define CONTSETUP_STANDARD_ROW_HEIGHT 10.7f #define CONTSETUP_CLASSIC_ROW_HEIGHT 9.0f #define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10 -- cgit v1.2.3 From 555f933780653012e7c2c664f91f88914a42e05e Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 18 Apr 2020 11:31:53 +0300 Subject: Remove padding fields --- src/core/ControllerConfig.h | 5 +---- src/core/Pad.h | 1 - src/core/PlayerInfo.h | 12 ------------ src/core/timebars.cpp | 2 +- 4 files changed, 2 insertions(+), 18 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index c328594e..82174343 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -112,20 +112,17 @@ public: }; bool m_bFirstCapture; - char _pad0[3]; #ifdef __DINPUT_INCLUDED__ DIJOYSTATE2 m_OldState; DIJOYSTATE2 m_NewState; #else - uint8 ___padd[0x110 * 2]; + uint32 ___padd[0x110 / 4 * 2]; #endif wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH]; bool m_aButtonStates[MAX_BUTTONS]; - char _pad1[3]; tControllerConfigBind m_aSettings[MAX_CONTROLLERACTIONS][MAX_CONTROLLERTYPES]; bool m_aSimCheckers[MAX_SIMS][MAX_CONTROLLERTYPES]; bool m_bMouseAssociated; - char _pad2[3]; CControllerConfigManager(); diff --git a/src/core/Pad.h b/src/core/Pad.h index 9ebd6396..b3b0849b 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -155,7 +155,6 @@ public: uint8 DisablePlayerControls; int8 bApplyBrakes; char CheatString[12]; - char _pad0[3]; int32 LastTimeTouched; int32 AverageWeapon; int32 AverageEntries; diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index 19c5ce23..ff31418c 100644 --- a/src/core/PlayerInfo.h +++ b/src/core/PlayerInfo.h @@ -31,22 +31,13 @@ public: uint32 m_nLastBumpPlayerCarTimer; uint32 m_nUnusedTaxiTimer; bool m_bUnusedTaxiThing; - int8 field_197; - int8 field_198; - int8 field_199; uint32 m_nNextSexFrequencyUpdateTime; uint32 m_nNextSexMoneyUpdateTime; int32 m_nSexFrequency; CCivilianPed *m_pHooker; int8 m_WBState; // eWastedBustedState - int8 field_217; - int8 field_218; - int8 field_219; uint32 m_nWBTime; bool m_bInRemoteMode; - int8 field_225; - int8 field_226; - int8 field_227; uint32 m_nTimeLostRemoteCar; uint32 m_nTimeLastHealthLoss; uint32 m_nTimeLastArmourLoss; @@ -54,8 +45,6 @@ public: int32 m_nUpsideDownCounter; int32 field_248; int16 m_nTrafficMultiplier; - int8 field_254; - int8 field_255; float m_fRoadDensity; uint32 m_nPreviousTimeRewardedForExplosion; int32 m_nExplosionsSinceLastReward; @@ -90,7 +79,6 @@ public: void FindClosestCarSectorList(CPtrList&, CPed*, float, float, float, float, float*, CVehicle**); ~CPlayerInfo() { }; - void dtor(void) { this->CPlayerInfo::~CPlayerInfo(); } }; static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error"); diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index 93d85f8d..5c2dbe3a 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -1,5 +1,5 @@ -#ifndef MASTER #include "common.h" +#ifndef MASTER #include "Font.h" #include "Frontend.h" #include "Timer.h" -- cgit v1.2.3 From eadb5a16aa36a5187e7bc244577451607069d016 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 18 Apr 2020 12:23:20 +0300 Subject: Zones save/load --- src/core/Zones.cpp | 279 +++++++++++++++++------------------------------------ 1 file changed, 87 insertions(+), 192 deletions(-) (limited to 'src/core') diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 6375de1c..804708b4 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -625,218 +625,113 @@ CTheZones::InitialiseAudioZoneArray(void) } void -CTheZones::SaveAllZones(uint8 *buffer, uint32 *length) +CTheZones::SaveAllZones(uint8 *buffer, uint32 *size) { + INITSAVEBUF int i; - *length = 8 + 12 + - NUMZONES*56 + 2*NUMZONES*58 + 4 + - NUMMAPZONES*56 + NUMAUDIOZONES*2 + 4; - - buffer[0] = 'Z'; - buffer[1] = 'N'; - buffer[2] = 'S'; - buffer[3] = '\0'; - *(uint32*)(buffer+4) = *length - 8; - buffer += 8; - - *(int32*)(buffer) = GetIndexForZonePointer(m_pPlayersZone); - *(int32*)(buffer+4) = m_CurrLevel; - *(int16*)(buffer+8) = FindIndex; - *(int16*)(buffer+10) = 0; - buffer += 12; - - for(i = 0; i < NUMZONES; i++){ - memcpy(buffer, ZoneArray[i].name, 8); - *(float*)(buffer+8) = ZoneArray[i].minx; - *(float*)(buffer+12) = ZoneArray[i].miny; - *(float*)(buffer+16) = ZoneArray[i].minz; - *(float*)(buffer+20) = ZoneArray[i].maxx; - *(float*)(buffer+24) = ZoneArray[i].maxy; - *(float*)(buffer+28) = ZoneArray[i].maxz; - *(int32*)(buffer+32) = ZoneArray[i].type; - *(int32*)(buffer+36) = ZoneArray[i].level; - *(int16*)(buffer+40) = ZoneArray[i].zoneinfoDay; - *(int16*)(buffer+42) = ZoneArray[i].zoneinfoNight; - *(int32*)(buffer+44) = GetIndexForZonePointer(ZoneArray[i].child); - *(int32*)(buffer+48) = GetIndexForZonePointer(ZoneArray[i].parent); - *(int32*)(buffer+52) = GetIndexForZonePointer(ZoneArray[i].next); - buffer += 56; + *size = SAVE_HEADER_SIZE + + sizeof(int32) // GetIndexForZonePointer + + sizeof(m_CurrLevel) + sizeof(FindIndex) + + sizeof(int16) // padding + + sizeof(ZoneArray) + sizeof(ZoneInfoArray) + + sizeof(TotalNumberOfZones) + sizeof(TotalNumberOfZoneInfos) + + sizeof(MapZoneArray) + sizeof(AudioZoneArray) + + sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones); + + WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE); + + WriteSaveBuf(buffer, GetIndexForZonePointer(m_pPlayersZone)); + WriteSaveBuf(buffer, m_CurrLevel); + WriteSaveBuf(buffer, FindIndex); + WriteSaveBuf(buffer, (int16)0); // padding + + for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){ + CZone *zone = WriteSaveBuf(buffer, ZoneArray[i]); + zone->child = (CZone*)GetIndexForZonePointer(ZoneArray[i].child); + zone->parent = (CZone*)GetIndexForZonePointer(ZoneArray[i].parent); + zone->next = (CZone*)GetIndexForZonePointer(ZoneArray[i].next); } - for(i = 0; i < 2*NUMZONES; i++){ - *(int16*)(buffer) = ZoneInfoArray[i].carDensity; - *(int16*)(buffer+2) = ZoneInfoArray[i].carThreshold[0]; - *(int16*)(buffer+4) = ZoneInfoArray[i].carThreshold[1]; - *(int16*)(buffer+6) = ZoneInfoArray[i].carThreshold[2]; - *(int16*)(buffer+8) = ZoneInfoArray[i].carThreshold[3]; - *(int16*)(buffer+10) = ZoneInfoArray[i].carThreshold[4]; - *(int16*)(buffer+12) = ZoneInfoArray[i].carThreshold[5]; - *(int16*)(buffer+14) = ZoneInfoArray[i].copThreshold; - *(int16*)(buffer+16) = ZoneInfoArray[i].gangThreshold[0]; - *(int16*)(buffer+18) = ZoneInfoArray[i].gangThreshold[1]; - *(int16*)(buffer+20) = ZoneInfoArray[i].gangThreshold[2]; - *(int16*)(buffer+22) = ZoneInfoArray[i].gangThreshold[3]; - *(int16*)(buffer+24) = ZoneInfoArray[i].gangThreshold[4]; - *(int16*)(buffer+26) = ZoneInfoArray[i].gangThreshold[5]; - *(int16*)(buffer+28) = ZoneInfoArray[i].gangThreshold[6]; - *(int16*)(buffer+30) = ZoneInfoArray[i].gangThreshold[7]; - *(int16*)(buffer+32) = ZoneInfoArray[i].gangThreshold[8]; - *(uint16*)(buffer+34) = ZoneInfoArray[i].pedDensity; - *(uint16*)(buffer+36) = ZoneInfoArray[i].copDensity; - *(uint16*)(buffer+38) = ZoneInfoArray[i].gangDensity[0]; - *(uint16*)(buffer+40) = ZoneInfoArray[i].gangDensity[1]; - *(uint16*)(buffer+42) = ZoneInfoArray[i].gangDensity[2]; - *(uint16*)(buffer+44) = ZoneInfoArray[i].gangDensity[3]; - *(uint16*)(buffer+46) = ZoneInfoArray[i].gangDensity[4]; - *(uint16*)(buffer+48) = ZoneInfoArray[i].gangDensity[5]; - *(uint16*)(buffer+50) = ZoneInfoArray[i].gangDensity[6]; - *(uint16*)(buffer+52) = ZoneInfoArray[i].gangDensity[7]; - *(uint16*)(buffer+54) = ZoneInfoArray[i].gangDensity[8]; - *(uint16*)(buffer+56) = ZoneInfoArray[i].pedGroup; - buffer += 58; + for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) + WriteSaveBuf(buffer, ZoneInfoArray[i]); + + WriteSaveBuf(buffer, TotalNumberOfZones); + WriteSaveBuf(buffer, TotalNumberOfZoneInfos); + + for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++) { + CZone* zone = WriteSaveBuf(buffer, MapZoneArray[i]); + + /* + The call of GetIndexForZonePointer is wrong, as it is + meant for a different array, but the game doesn't brake + if those fields are nil. Let's make sure they are. + */ + assert(MapZoneArray[i].child == nil); + assert(MapZoneArray[i].parent == nil); + assert(MapZoneArray[i].next == nil); + zone->child = (CZone*)GetIndexForZonePointer(MapZoneArray[i].child); + zone->parent = (CZone*)GetIndexForZonePointer(MapZoneArray[i].parent); + zone->next = (CZone*)GetIndexForZonePointer(MapZoneArray[i].next); } - *(uint16*)(buffer) = TotalNumberOfZones; - *(uint16*)(buffer+2) = TotalNumberOfZoneInfos; - buffer += 4; - - for(i = 0; i < NUMMAPZONES; i++){ - memcpy(buffer, MapZoneArray[i].name, 8); - *(float*)(buffer+8) = MapZoneArray[i].minx; - *(float*)(buffer+12) = MapZoneArray[i].miny; - *(float*)(buffer+16) = MapZoneArray[i].minz; - *(float*)(buffer+20) = MapZoneArray[i].maxx; - *(float*)(buffer+24) = MapZoneArray[i].maxy; - *(float*)(buffer+28) = MapZoneArray[i].maxz; - *(int32*)(buffer+32) = MapZoneArray[i].type; - *(int32*)(buffer+36) = MapZoneArray[i].level; - *(int16*)(buffer+40) = MapZoneArray[i].zoneinfoDay; - *(int16*)(buffer+42) = MapZoneArray[i].zoneinfoNight; -#ifdef STANDALONE - // BUG: GetIndexForZonePointer uses ZoneArray - // so indices will be unpredictable with different memory layout - assert(0); -#endif - *(int32*)(buffer+44) = GetIndexForZonePointer(MapZoneArray[i].child); - *(int32*)(buffer+48) = GetIndexForZonePointer(MapZoneArray[i].parent); - *(int32*)(buffer+52) = GetIndexForZonePointer(MapZoneArray[i].next); - buffer += 56; - } + for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++) + WriteSaveBuf(buffer, AudioZoneArray[i]); - for(i = 0; i < NUMAUDIOZONES; i++){ - *(int16*)buffer = AudioZoneArray[i]; - buffer += 2; - } + WriteSaveBuf(buffer, TotalNumberOfMapZones); + WriteSaveBuf(buffer, NumberOfAudioZones); - *(uint16*)(buffer) = TotalNumberOfMapZones; - *(uint16*)(buffer+2) = NumberOfAudioZones; + VALIDATESAVEBUF(*size) } void -CTheZones::LoadAllZones(uint8 *buffer, uint32 length) +CTheZones::LoadAllZones(uint8 *buffer, uint32 size) { + INITSAVEBUF int i; - assert(length == 8 + 12 + - NUMZONES*56 + 2*NUMZONES*58 + 4 + - NUMMAPZONES*56 + NUMAUDIOZONES*2 + 4); - assert(buffer[0] == 'Z'); - assert(buffer[1] == 'N'); - assert(buffer[2] == 'S'); - assert(buffer[3] == '\0'); - assert(*(uint32*)(buffer+4) == length - 8); - buffer += 8; - - m_pPlayersZone = GetPointerForZoneIndex(*(int32*)(buffer)); - m_CurrLevel = (eLevelName)*(int32*)(buffer+4); - FindIndex = *(int16*)(buffer+8); - assert(*(int16*)(buffer+10) == 0); - buffer += 12; - - for(i = 0; i < NUMZONES; i++){ - memcpy(ZoneArray[i].name, buffer, 8); - ZoneArray[i].minx = *(float*)(buffer+8); - ZoneArray[i].miny = *(float*)(buffer+12); - ZoneArray[i].minz = *(float*)(buffer+16); - ZoneArray[i].maxx = *(float*)(buffer+20); - ZoneArray[i].maxy = *(float*)(buffer+24); - ZoneArray[i].maxz = *(float*)(buffer+28); - ZoneArray[i].type = (eZoneType)*(int32*)(buffer+32); - ZoneArray[i].level = (eLevelName)*(int32*)(buffer+36); - ZoneArray[i].zoneinfoDay = *(int16*)(buffer+40); - ZoneArray[i].zoneinfoNight = *(int16*)(buffer+42); - ZoneArray[i].child = GetPointerForZoneIndex(*(int32*)(buffer+44)); - ZoneArray[i].parent = GetPointerForZoneIndex(*(int32*)(buffer+48)); - ZoneArray[i].next = GetPointerForZoneIndex(*(int32*)(buffer+52)); - buffer += 56; - } + CheckSaveHeader(buffer, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE); - for(i = 0; i < 2*NUMZONES; i++){ - ZoneInfoArray[i].carDensity = *(int16*)(buffer); - ZoneInfoArray[i].carThreshold[0] = *(int16*)(buffer+2); - ZoneInfoArray[i].carThreshold[1] = *(int16*)(buffer+4); - ZoneInfoArray[i].carThreshold[2] = *(int16*)(buffer+6); - ZoneInfoArray[i].carThreshold[3] = *(int16*)(buffer+8); - ZoneInfoArray[i].carThreshold[4] = *(int16*)(buffer+10); - ZoneInfoArray[i].carThreshold[5] = *(int16*)(buffer+12); - ZoneInfoArray[i].copThreshold = *(int16*)(buffer+14); - ZoneInfoArray[i].gangThreshold[0] = *(int16*)(buffer+16); - ZoneInfoArray[i].gangThreshold[1] = *(int16*)(buffer+18); - ZoneInfoArray[i].gangThreshold[2] = *(int16*)(buffer+20); - ZoneInfoArray[i].gangThreshold[3] = *(int16*)(buffer+22); - ZoneInfoArray[i].gangThreshold[4] = *(int16*)(buffer+24); - ZoneInfoArray[i].gangThreshold[5] = *(int16*)(buffer+26); - ZoneInfoArray[i].gangThreshold[6] = *(int16*)(buffer+28); - ZoneInfoArray[i].gangThreshold[7] = *(int16*)(buffer+30); - ZoneInfoArray[i].gangThreshold[8] = *(int16*)(buffer+32); - ZoneInfoArray[i].pedDensity = *(uint16*)(buffer+34); - ZoneInfoArray[i].copDensity = *(uint16*)(buffer+36); - ZoneInfoArray[i].gangDensity[0] = *(uint16*)(buffer+38); - ZoneInfoArray[i].gangDensity[1] = *(uint16*)(buffer+40); - ZoneInfoArray[i].gangDensity[2] = *(uint16*)(buffer+42); - ZoneInfoArray[i].gangDensity[3] = *(uint16*)(buffer+44); - ZoneInfoArray[i].gangDensity[4] = *(uint16*)(buffer+46); - ZoneInfoArray[i].gangDensity[5] = *(uint16*)(buffer+48); - ZoneInfoArray[i].gangDensity[6] = *(uint16*)(buffer+50); - ZoneInfoArray[i].gangDensity[7] = *(uint16*)(buffer+52); - ZoneInfoArray[i].gangDensity[8] = *(uint16*)(buffer+54); - ZoneInfoArray[i].pedGroup = *(uint16*)(buffer+56); - buffer += 58; - } + m_pPlayersZone = GetPointerForZoneIndex(ReadSaveBuf(buffer)); + m_CurrLevel = ReadSaveBuf(buffer); + FindIndex = ReadSaveBuf(buffer); + ReadSaveBuf(buffer); - TotalNumberOfZones = *(uint16*)(buffer); - TotalNumberOfZoneInfos = *(uint16*)(buffer+2); - buffer += 4; + for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){ + ZoneArray[i] = ReadSaveBuf(buffer); - for(i = 0; i < NUMMAPZONES; i++){ - memcpy(MapZoneArray[i].name, buffer, 8); - MapZoneArray[i].minx = *(float*)(buffer+8); - MapZoneArray[i].miny = *(float*)(buffer+12); - MapZoneArray[i].minz = *(float*)(buffer+16); - MapZoneArray[i].maxx = *(float*)(buffer+20); - MapZoneArray[i].maxy = *(float*)(buffer+24); - MapZoneArray[i].maxz = *(float*)(buffer+28); - MapZoneArray[i].type = (eZoneType)*(int32*)(buffer+32); - MapZoneArray[i].level = (eLevelName)*(int32*)(buffer+36); - MapZoneArray[i].zoneinfoDay = *(int16*)(buffer+40); - MapZoneArray[i].zoneinfoNight = *(int16*)(buffer+42); -#ifdef STANDALONE - // BUG: GetPointerForZoneIndex uses ZoneArray - // so pointers will be unpredictable with different memory layout - assert(0); -#endif - MapZoneArray[i].child = GetPointerForZoneIndex(*(int32*)(buffer+44)); - MapZoneArray[i].parent = GetPointerForZoneIndex(*(int32*)(buffer+48)); - MapZoneArray[i].next = GetPointerForZoneIndex(*(int32*)(buffer+52)); - buffer += 56; + ZoneArray[i].child = GetPointerForZoneIndex((int32)ZoneArray[i].child); + ZoneArray[i].parent = GetPointerForZoneIndex((int32)ZoneArray[i].parent); + ZoneArray[i].next = GetPointerForZoneIndex((int32)ZoneArray[i].next); } - for(i = 0; i < NUMAUDIOZONES; i++){ - AudioZoneArray[i] = *(int16*)buffer; - buffer += 2; + for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) + ZoneInfoArray[i] = ReadSaveBuf(buffer); + + TotalNumberOfZones = ReadSaveBuf(buffer); + TotalNumberOfZoneInfos = ReadSaveBuf(buffer); + + for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){ + MapZoneArray[i] = ReadSaveBuf(buffer); + + /* + The call of GetPointerForZoneIndex is wrong, as it is + meant for a different array, but the game doesn't brake + if save data stored is -1. + */ + MapZoneArray[i].child = GetPointerForZoneIndex((int32)MapZoneArray[i].child); + MapZoneArray[i].parent = GetPointerForZoneIndex((int32)MapZoneArray[i].parent); + MapZoneArray[i].next = GetPointerForZoneIndex((int32)MapZoneArray[i].next); + assert(MapZoneArray[i].child == nil); + assert(MapZoneArray[i].parent == nil); + assert(MapZoneArray[i].next == nil); } - TotalNumberOfMapZones = *(uint16*)(buffer); - NumberOfAudioZones = *(uint16*)(buffer+2); + for(i = 0; i < ARRAY_SIZE(AudioZoneArray); i++) + AudioZoneArray[i] = ReadSaveBuf(buffer); + + TotalNumberOfMapZones = ReadSaveBuf(buffer); + NumberOfAudioZones = ReadSaveBuf(buffer); + + VALIDATESAVEBUF(size) } -- cgit v1.2.3 From d6314f9564912393134d832b8cc268dd3dbfcbaa Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sat, 18 Apr 2020 12:29:28 +0200 Subject: Revert "Part one" This reverts commit 63951d9b957b30a110f42a03edb4833cbbaf380e. --- src/core/CrimeType.h | 23 ----------------------- src/core/Game.cpp | 2 +- src/core/General.h | 2 +- src/core/Pad.cpp | 2 +- src/core/PlayerInfo.cpp | 2 +- src/core/Wanted.h | 22 +++++++++++++++++++++- src/core/common.h | 4 ++-- 7 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 src/core/CrimeType.h (limited to 'src/core') diff --git a/src/core/CrimeType.h b/src/core/CrimeType.h deleted file mode 100644 index 23f609eb..00000000 --- a/src/core/CrimeType.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -enum eCrimeType -{ - CRIME_NONE, - CRIME_POSSESSION_GUN, - CRIME_HIT_PED, - CRIME_HIT_COP, - CRIME_SHOOT_PED, - CRIME_SHOOT_COP, - CRIME_STEAL_CAR, - CRIME_RUN_REDLIGHT, - CRIME_RECKLESS_DRIVING, - CRIME_SPEEDING, - CRIME_RUNOVER_PED, - CRIME_RUNOVER_COP, - CRIME_SHOOT_HELI, - CRIME_PED_BURNED, - CRIME_COP_BURNED, - CRIME_VEHICLE_BURNED, - CRIME_DESTROYED_CESSNA, - NUM_CRIME_TYPES -}; \ No newline at end of file diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8b2f8604..7ccf78d0 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -72,7 +72,7 @@ #include "Streaming.h" #include "SurfaceTable.h" #include "TempColModels.h" -#include "Timecycle.h" +#include "TimeCycle.h" #include "TrafficLights.h" #include "Train.h" #include "TxdStore.h" diff --git a/src/core/General.h b/src/core/General.h index 103bafde..77828854 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -124,7 +124,7 @@ public: static bool faststricmp(const char *str1, const char *str2) { for (; *str1; str1++, str2++) { -#if 1 +#if MUCH_SLOWER if (toupper(*str1) != toupper(*str2)) #else if (__ascii_toupper(*str1) != __ascii_toupper(*str2)) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 49affbbe..86aff05e 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -6,7 +6,7 @@ #include "common.h" #ifdef XINPUT -#include +#include #pragma comment( lib, "Xinput9_1_0.lib" ) #endif diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 3852f540..cfa0cea4 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -180,7 +180,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle) m_pPed->bExplosionProof = true; m_pPed->m_bCanBeDamaged = false; ((CPlayerPed*)m_pPed)->ClearAdrenaline(); - CancelPlayerEnteringCars(nil); + CancelPlayerEnteringCars(false); gFireManager.ExtinguishPoint(GetPos(), 4000.0f); CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f); CProjectileInfo::RemoveAllProjectiles(); diff --git a/src/core/Wanted.h b/src/core/Wanted.h index c5e9d388..afeec8b0 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -3,7 +3,27 @@ class CEntity; class CCopPed; -#include "CrimeType.h" +enum eCrimeType +{ + CRIME_NONE, + CRIME_POSSESSION_GUN, + CRIME_HIT_PED, + CRIME_HIT_COP, + CRIME_SHOOT_PED, + CRIME_SHOOT_COP, + CRIME_STEAL_CAR, + CRIME_RUN_REDLIGHT, + CRIME_RECKLESS_DRIVING, + CRIME_SPEEDING, + CRIME_RUNOVER_PED, + CRIME_RUNOVER_COP, + CRIME_SHOOT_HELI, + CRIME_PED_BURNED, + CRIME_COP_BURNED, + CRIME_VEHICLE_BURNED, + CRIME_DESTROYED_CESSNA, + NUM_CRIME_TYPES +}; class CCrimeBeingQd { diff --git a/src/core/common.h b/src/core/common.h index e10b222c..454b848a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -12,7 +12,7 @@ #include #ifdef WITHWINDOWS -#include +#include #endif #ifdef WITHD3D @@ -62,7 +62,7 @@ typedef int64_t int64; typedef uint16_t wchar; #ifndef nil -#define nil NULL +#define nil nullptr #endif #include "config.h" -- cgit v1.2.3 From 89688843ece0f6c9968f0f8b9b644d707b96d34a Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 18 Apr 2020 13:56:21 +0300 Subject: bug fixes --- src/core/Frontend.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index e9282c44..4dab8ae4 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5470,7 +5470,8 @@ CMenuManager::ConstructStatLine(int rowIdx) if (player.m_nTotalPackages != 0) packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages; - STAT_LINE("PERPIC", &packagesPercent, 0, &(nTemp = 100)); + int nPackagesPercent = packagesPercent; + STAT_LINE("PERPIC", &nPackagesPercent, 0, &(nTemp = 100)); STAT_LINE("NOUNIF", &CStats::TotalNumberOfUniqueJumps, 0, &CStats::NumberOfUniqueJumpsFound); STAT_LINE("DAYSPS", &CStats::DaysPassed, false, nil); if (CGame::nastyGame) { -- cgit v1.2.3 From 522d14814f58e8a8ed9445c9c1a213aa9ca2cad2 Mon Sep 17 00:00:00 2001 From: gennariarmando Date: Sat, 18 Apr 2020 15:05:06 +0200 Subject: Changed extraOffset value. --- src/core/Frontend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index f4e0996b..a900d696 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1127,7 +1127,7 @@ CMenuManager::Draw() int extraOffset = 0; if (aScreens[m_nCurrScreen].m_aEntries[rowToCheck].m_Action == MENUACTION_RADIO) - extraOffset = (int) 60.0f; + extraOffset = MENURADIO_ICON_SCALE; // There were many unused codes in here to calculate how much space will texts gonna take. -- cgit v1.2.3 From ffe5dce7f58b6eae5b2bcb6cb9e4d4c0d8a8f426 Mon Sep 17 00:00:00 2001 From: gennariarmando Date: Sat, 18 Apr 2020 18:13:47 +0200 Subject: Hide Vehicle/Zone name during Wasted/Busted... Fixed little mistake in my latest commit. --- src/core/Frontend.cpp | 8 +++++--- src/core/config.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index a900d696..eec143c3 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -305,9 +305,11 @@ ScaleAndCenterX(float x) } while(0) #define ProcessRadioIcon(sprite, x, y, radioId, hoverOpt) \ - sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); \ - if (CheckHover(x, x + MENU_X(MENURADIO_ICON_SCALE), y, y + MENU_Y(MENURADIO_ICON_SCALE))) \ - m_nHoverOption = hoverOpt; + do { \ + sprite.Draw(x, y, MENU_X(MENURADIO_ICON_SCALE), MENU_Y(MENURADIO_ICON_SCALE), radioId == m_PrefsRadioStation ? CRGBA(255, 255, 255, 255) : CRGBA(225, 0, 0, 170)); \ + if (CheckHover(x, x + MENU_X(MENURADIO_ICON_SCALE), y, y + MENU_Y(MENURADIO_ICON_SCALE))) \ + m_nHoverOption = hoverOpt; \ + } while (0) // --- Functions not in the game/inlined starts diff --git a/src/core/config.h b/src/core/config.h index ba684092..12e6ed69 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -208,6 +208,7 @@ enum Config { #define SCROLLABLE_STATS_PAGE // only draggable by mouse atm #define TRIANGLE_BACK_BUTTON // #define CIRCLE_BACK_BUTTON +#define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. // Script #define USE_DEBUG_SCRIPT_LOADER // makes game load main_freeroam.scm by default -- cgit v1.2.3 From 2f63e5e751dc268a6778e076098320dac9a03699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 18 Apr 2020 21:28:49 +0300 Subject: Vc ped ports and Frontend fixes --- src/core/Frontend.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index a900d696..e4f8ac96 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -118,7 +118,6 @@ const CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255); const CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color #endif -const float menuXYpadding = MENUACTION_POS_Y; // TODO this is non-existant, remove it float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; @@ -231,8 +230,7 @@ ScaleAndCenterX(float x) else { if (x > DEFAULT_SCREEN_WIDTH / 2) { return SCREEN_WIDTH / 2 + SCREEN_SCALE_X(x - DEFAULT_SCREEN_WIDTH / 2); - } - else { + } else { return SCREEN_WIDTH / 2 - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH / 2 - x); } } @@ -1257,7 +1255,8 @@ CMenuManager::Draw() break; } - nextYToUse += lineHeight * CFont::GetNumberLines(menuXYpadding, nextYToUse, leftText); + // 60.0 is silly + nextYToUse += lineHeight * CFont::GetNumberLines(MENU_X_LEFT_ALIGNED(60.0f), MENU_Y(nextYToUse), leftText); // Radio icons if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_RADIO) { @@ -3385,8 +3384,7 @@ CMenuManager::Process(void) DMAudio.SetEffectsFadeVol(0); DMAudio.SetMusicFadeVol(0); DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); - } - else + } else SaveLoadFileError_SetUpErrorScreen(); } -- cgit v1.2.3 From 9bfcaff84976b2af7242f846c782287e9bacf851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 18 Apr 2020 22:56:49 +0300 Subject: slider fix --- src/core/Frontend.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 0966b2a2..6fe06d96 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -287,7 +287,7 @@ ScaleAndCenterX(float x) #define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \ do { \ - lastActiveBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ + lastActiveBarX = DisplaySlider(MENU_X_RIGHT_ALIGNED(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ if (i != m_nCurrOption || !itemsAreSelectable) \ break; \ \ @@ -298,7 +298,7 @@ ScaleAndCenterX(float x) break; \ \ m_nHoverOption = increaseAction; \ - if (m_nMousePosX < SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth)) \ + if (m_nMousePosX < MENU_X_RIGHT_ALIGNED(MENUSLIDER_X + columnWidth)) \ m_nHoverOption = HOVEROPTION_NOT_HOVERING; \ } while(0) @@ -1237,7 +1237,6 @@ CMenuManager::Draw() } // Sliders - // We stretch slider start X here(like original code), because it will always be center of screen int lastActiveBarX; switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { case MENUACTION_BRIGHTNESS: -- cgit v1.2.3 From c4cd45d47c01d89bab28f196f03ed9cb1978005b Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 18 Apr 2020 23:50:37 +0300 Subject: replays bug fix --- src/core/Camera.cpp | 8 ++++++++ src/core/PlayerInfo.cpp | 8 ++++++++ src/core/References.cpp | 9 +++++++++ src/core/Streaming.cpp | 15 +++++++++++++-- src/core/User.cpp | 5 +++++ src/core/World.cpp | 15 +++++++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index f1445d2e..6747ebf5 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -2490,6 +2490,10 @@ CCamera::TryToStartNewCamMode(int obbeMode) TakeControl(FindPlayerEntity(), CCam::MODE_CAM_ON_A_STRING, JUMP_CUT, CAMCONTROL_OBBE); return true; case OBBE_COPCAR: +#ifdef FIX_BUGS + if (CReplay::IsPlayingBack()) + return false; +#endif if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1) return false; if(FindPlayerVehicle() == nil) @@ -2514,6 +2518,10 @@ CCamera::TryToStartNewCamMode(int obbeMode) } return false; case OBBE_COPCAR_WHEEL: +#ifdef FIX_BUGS + if (CReplay::IsPlayingBack()) + return false; +#endif if(FindPlayerPed()->m_pWanted->m_nWantedLevel < 1) return false; if(FindPlayerVehicle() == nil) diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index cfa0cea4..1c641be3 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -41,6 +41,10 @@ CPlayerInfo::SetPlayerSkin(char *skin) CVector& CPlayerInfo::GetPos() { +#ifdef FIX_BUGS + if (!m_pPed) + return TheCamera.GetPosition(); +#endif if (m_pPed->InVehicle()) return m_pPed->m_pMyVehicle->GetPosition(); return m_pPed->GetPosition(); @@ -342,6 +346,10 @@ CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, void CPlayerInfo::Process(void) { +#ifdef FIX_BUGS + if (CReplay::IsPlayingBack()) + return; +#endif // Unused taxi feature. Gives you a dollar for every second with a passenger. Can be toggled via 0x29A opcode. bool startTaxiTimer = true; if (m_bUnusedTaxiThing && m_pPed->bInVehicle) { diff --git a/src/core/References.cpp b/src/core/References.cpp index 3eb2eaf3..52abbc3e 100644 --- a/src/core/References.cpp +++ b/src/core/References.cpp @@ -26,8 +26,17 @@ CReferences::RemoveReferencesToPlayer(void) { if(FindPlayerVehicle()) FindPlayerVehicle()->ResolveReferences(); +#ifdef FIX_BUGS + if (FindPlayerPed()) { + CPlayerPed* pPlayerPed = FindPlayerPed(); + FindPlayerPed()->ResolveReferences(); + CWorld::Players[CWorld::PlayerInFocus].m_pPed = pPlayerPed; + pPlayerPed->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pPed); + } +#else if(FindPlayerPed()) FindPlayerPed()->ResolveReferences(); +#endif } void diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 039377f4..dae83d89 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -28,6 +28,9 @@ #include "CutsceneMgr.h" #include "CdStream.h" #include "Streaming.h" +#ifdef FIX_BUGS +#include "Replay.h" +#endif #include "main.h" bool CStreaming::ms_disableStreaming; @@ -280,7 +283,11 @@ CStreaming::Update(void) !requestedSubway && !CGame::playingIntro && ms_numModelsRequested < 5 && - !CRenderer::m_loadingPriority){ + !CRenderer::m_loadingPriority +#ifdef FIX_BUGS + && !CReplay::IsPlayingBack() +#endif + ){ StreamVehiclesAndPeds(); StreamZoneModels(FindPlayerCoors()); } @@ -1248,7 +1255,11 @@ CStreaming::StreamVehiclesAndPeds(void) static int modelQualityClass = 0; if(CRecordDataForGame::IsRecording() || - CRecordDataForGame::IsPlayingBack()) + CRecordDataForGame::IsPlayingBack() +#ifdef FIX_BUGS + || CReplay::IsPlayingBack() +#endif + ) return; if(FindPlayerPed()->m_pWanted->AreSwatRequired()){ diff --git a/src/core/User.cpp b/src/core/User.cpp index 36f07cbd..50eb7d9d 100644 --- a/src/core/User.cpp +++ b/src/core/User.cpp @@ -3,6 +3,7 @@ #include "Hud.h" #include "PlayerPed.h" +#include "Replay.h" #include "Text.h" #include "User.h" #include "Vehicle.h" @@ -115,6 +116,10 @@ CUserDisplay::Init() void CUserDisplay::Process() { +#ifdef FIX_BUGS + if (CReplay::IsPlayingBack()) + return; +#endif PlaceName.Process(); OnscnTimer.Process(); Pager.Process(); diff --git a/src/core/World.cpp b/src/core/World.cpp index eacb3404..7ef43593 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1386,6 +1386,10 @@ FindPlayerEntity(void) CVector FindPlayerCoors(void) { +#ifdef FIX_BUGS + if (CReplay::IsPlayingBack()) + return TheCamera.GetPosition(); +#endif CPlayerPed *ped = FindPlayerPed(); if(ped->InVehicle()) return ped->m_pMyVehicle->GetPosition(); @@ -1396,6 +1400,11 @@ FindPlayerCoors(void) CVector & FindPlayerSpeed(void) { +#ifdef FIX_BUGS + static CVector vecTmpVector(0.0f, 0.0f, 0.0f); + if (CReplay::IsPlayingBack()) + return vecTmpVector; +#endif CPlayerPed *ped = FindPlayerPed(); if(ped->InVehicle()) return ped->m_pMyVehicle->m_vecMoveSpeed; @@ -1406,6 +1415,9 @@ FindPlayerSpeed(void) CVector & FindPlayerCentreOfWorld(int32 player) { +#ifdef FIX_BUGS + if(CReplay::IsPlayingBack()) return TheCamera.GetPosition(); +#endif if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition(); if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition(); if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition(); @@ -1415,6 +1427,9 @@ FindPlayerCentreOfWorld(int32 player) CVector & FindPlayerCentreOfWorld_NoSniperShift(void) { +#ifdef FIX_BUGS + if (CReplay::IsPlayingBack()) return TheCamera.GetPosition(); +#endif if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition(); if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle) return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition(); -- cgit v1.2.3 From 1ffc37735ed247eef1f20997a0136ef8d866ebad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 19 Apr 2020 07:14:13 +0300 Subject: Struct cleanup, various fixes, enable PS2 rand --- src/core/EventList.h | 3 +-- src/core/Game.h | 1 + src/core/PlayerInfo.cpp | 4 ++-- src/core/Pools.cpp | 8 ++++---- src/core/config.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/EventList.h b/src/core/EventList.h index 1c03c9d6..8840afc4 100644 --- a/src/core/EventList.h +++ b/src/core/EventList.h @@ -26,8 +26,7 @@ enum eEventType EVENT_ICECREAM, EVENT_ATM, EVENT_SHOPSTALL, // used on graffitis - EVENT_SHOPWINDOW, - EVENT_LAST_EVENT // may be above one + EVENT_LAST_EVENT }; enum eEventEntity diff --git a/src/core/Game.h b/src/core/Game.h index 8dc73e8a..e3f0f616 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -2,6 +2,7 @@ enum eLevelName { + LEVEL_IGNORE = -1, // beware, this is only used in CPhysical's m_nZoneLevel LEVEL_NONE = 0, LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index cfa0cea4..6209e5ab 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -548,10 +548,10 @@ CPlayerInfo::Process(void) } if (FindPlayerVehicle()) { CVehicle *veh = FindPlayerVehicle(); - veh->m_nZoneLevel = -1; + veh->m_nZoneLevel = LEVEL_IGNORE; for (int i = 0; i < ARRAY_SIZE(veh->pPassengers); i++) { if (veh->pPassengers[i]) - veh->pPassengers[i]->m_nZoneLevel = 0; + veh->pPassengers[i]->m_nZoneLevel = LEVEL_NONE; } CStats::DistanceTravelledInVehicle += veh->m_fDistanceTravelled; } else { diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index dfc6974a..fb64c551 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -251,7 +251,7 @@ INITSAVEBUF continue; if (pObject->ObjectCreatedBy == MISSION_OBJECT) { bool bIsPickup = pObject->bIsPickup; - bool bFlag2 = pObject->m_obj_flag2; + bool bPickupObjWithMessage = pObject->bPickupObjWithMessage; bool bOutOfStock = pObject->bOutOfStock; bool bGlassCracked = pObject->bGlassCracked; bool bGlassBroken = pObject->bGlassBroken; @@ -269,7 +269,7 @@ INITSAVEBUF WriteSaveBuf(buf, (uint32)0); // same WriteSaveBuf(buf, pObject->ObjectCreatedBy); WriteSaveBuf(buf, bIsPickup); - WriteSaveBuf(buf, bFlag2); + WriteSaveBuf(buf, bPickupObjWithMessage); WriteSaveBuf(buf, bOutOfStock); WriteSaveBuf(buf, bGlassCracked); WriteSaveBuf(buf, bGlassBroken); @@ -305,7 +305,7 @@ INITSAVEBUF ReadSaveBuf(buf); pBufferObject->ObjectCreatedBy = ReadSaveBuf(buf); pBufferObject->bIsPickup = ReadSaveBuf(buf); - pBufferObject->m_flagE2 = ReadSaveBuf(buf); + pBufferObject->bPickupObjWithMessage = ReadSaveBuf(buf); pBufferObject->bOutOfStock = ReadSaveBuf(buf); pBufferObject->bGlassCracked = ReadSaveBuf(buf); pBufferObject->bGlassBroken = ReadSaveBuf(buf); @@ -325,7 +325,7 @@ INITSAVEBUF pObject->m_objectMatrix = pBufferObject->m_objectMatrix; pObject->ObjectCreatedBy = pBufferObject->ObjectCreatedBy; pObject->bIsPickup = pBufferObject->bIsPickup; - pObject->m_flagE2 = pBufferObject->m_flagE2; + pObject->bPickupObjWithMessage = pBufferObject->bPickupObjWithMessage; pObject->bOutOfStock = pBufferObject->bOutOfStock; pObject->bGlassCracked = pBufferObject->bGlassCracked; pObject->bGlassBroken = pBufferObject->bGlassBroken; diff --git a/src/core/config.h b/src/core/config.h index 12e6ed69..4ca79cb5 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -161,7 +161,7 @@ enum Config { # define GTA3_1_1_PATCH //# define GTA3_STEAM_PATCH # ifdef GTA_PS2_STUFF -//# define USE_PS2_RAND // this is unsafe until we have the game reversed +# define USE_PS2_RAND # define RANDOMSPLASH // use random splash as on PS2 # define PS2_MATFX # endif -- cgit v1.2.3 From 2308321805b97105cf03e8a38d44c90d9f652cd1 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sun, 19 Apr 2020 22:32:59 +0300 Subject: Add polish lang support --- src/core/Frontend.cpp | 13 +++++++++++++ src/core/Frontend.h | 2 ++ src/core/Game.cpp | 1 + src/core/Game.h | 1 + src/core/MenuScreens.h | 1 + 5 files changed, 18 insertions(+) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 6fe06d96..6bfde701 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -2893,6 +2893,9 @@ CMenuManager::InitialiseChangedLanguageSettings() CGame::germanGame = false; #ifdef MORE_LANGUAGES switch (m_PrefsLanguage) { + case LANGUAGE_POLISH: + CFont::ReloadFonts(FONT_LANGSET_POLISH); + break; case LANGUAGE_RUSSIAN: CFont::ReloadFonts(FONT_LANGSET_RUSSIAN); break; @@ -2910,6 +2913,9 @@ CMenuManager::InitialiseChangedLanguageSettings() CGame::germanGame = true; break; #ifdef MORE_LANGUAGES + case LANGUAGE_POLISH: + CGame::polishGame = true; + break; case LANGUAGE_RUSSIAN: CGame::russianGame = true; break; @@ -4254,6 +4260,12 @@ CMenuManager::ProcessButtonPresses(void) SaveSettings(); break; #ifdef MORE_LANGUAGES + case MENUACTION_LANG_PL: + m_PrefsLanguage = LANGUAGE_POLISH; + m_bFrontEnd_ReloadObrTxtGxt = true; + InitialiseChangedLanguageSettings(); + SaveSettings(); + break; case MENUACTION_LANG_RUS: m_PrefsLanguage = LANGUAGE_RUSSIAN; m_bFrontEnd_ReloadObrTxtGxt = true; @@ -5550,6 +5562,7 @@ CMenuManager::ConstructStatLine(int rowIdx) case LANGUAGE_ITALIAN: case LANGUAGE_SPANISH: #ifdef MORE_LANGUAGES + case LANGUAGE_POLISH: case LANGUAGE_RUSSIAN: #endif STAT_LINE("FESTDFM", &CStats::DistanceTravelledOnFoot, true, nil); diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 71aac605..7877d6f1 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -89,6 +89,7 @@ enum eLanguages LANGUAGE_ITALIAN, LANGUAGE_SPANISH, #ifdef MORE_LANGUAGES + LANGUAGE_POLISH, LANGUAGE_RUSSIAN, #endif }; @@ -365,6 +366,7 @@ enum eMenuAction MENUACTION_UNK109, MENUACTION_UNK110, #ifdef MORE_LANGUAGES + MENUACTION_LANG_PL, MENUACTION_LANG_RUS, #endif }; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 7ccf78d0..b1d29161 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -98,6 +98,7 @@ bool CGame::noProstitutes; bool CGame::playingIntro; char CGame::aDatFile[32]; #ifdef MORE_LANGUAGES +bool CGame::polishGame = false; bool CGame::russianGame = false; #endif diff --git a/src/core/Game.h b/src/core/Game.h index e3f0f616..3b8a856d 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -18,6 +18,7 @@ public: static bool frenchGame; static bool germanGame; #ifdef MORE_LANGUAGES + static bool polishGame; static bool russianGame; #endif static bool noProstitutes; diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 8692d4dc..48e2173e 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -74,6 +74,7 @@ const CMenuScreen aScreens[] = { MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, #ifdef MORE_LANGUAGES + MENUACTION_LANG_PL, "FEL_POL", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE, #endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, -- cgit v1.2.3 From 4c5edda82e45918bf4665bd0f5720907c87e15a9 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sun, 19 Apr 2020 22:37:20 +0300 Subject: MenuScreens.h fix --- src/core/MenuScreens.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 48e2173e..957b2d53 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -72,7 +72,7 @@ const CMenuScreen aScreens[] = { MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, #ifdef MORE_LANGUAGES MENUACTION_LANG_PL, "FEL_POL", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE, -- cgit v1.2.3 From 36f08269a5da1dbb234b443d01ddb0795186579e Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sun, 19 Apr 2020 22:38:02 +0300 Subject: MenuScreens.h fix --- src/core/MenuScreens.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 957b2d53..e55ec49f 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -75,7 +75,7 @@ const CMenuScreen aScreens[] = { MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, #ifdef MORE_LANGUAGES MENUACTION_LANG_PL, "FEL_POL", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE, #endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, -- cgit v1.2.3 From 83810168ee59bc58b141f77edfae65ffc7adb0b1 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 20 Apr 2020 07:45:17 +0300 Subject: beta OddJob(unique jump etc) sliding text --- src/core/config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 4ca79cb5..9f5bfeb6 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -209,6 +209,7 @@ enum Config { #define TRIANGLE_BACK_BUTTON // #define CIRCLE_BACK_BUTTON #define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. +#define BETA_SLIDING_TEXT // Script #define USE_DEBUG_SCRIPT_LOADER // makes game load main_freeroam.scm by default -- cgit v1.2.3 From 556a6df4017eb26a4912e62097de3c0033b58a25 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 20 Apr 2020 08:17:08 +0300 Subject: camerapickup ps2 code --- src/core/config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 9f5bfeb6..b5022b9f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -226,6 +226,7 @@ enum Config { // Pickups //#define MONEY_MESSAGES +#define CAMERA_PICKUP // Peds #define ANIMATE_PED_COL_MODEL -- cgit v1.2.3 From 98fc8ecef09ba9c50a511c3bcfaca3cffe2fed0b Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 20 Apr 2020 16:05:39 +0200 Subject: update librw (matfx) --- src/core/Game.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/core') diff --git a/src/core/Game.cpp b/src/core/Game.cpp index b1d29161..94c775ae 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -156,6 +156,14 @@ CGame::InitialiseRenderWare(void) LightsCreate(Scene.world); CreateDebugFont(); + +#ifdef LIBRW +#ifdef PS2_MATFX + rw::MatFX::modulateEnvMap = true; +#else + rw::MatFX::modulateEnvMap = false; +#endif +#endif CFont::Initialise(); CHud::Initialise(); -- cgit v1.2.3 From 370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 19 Apr 2020 18:34:08 +0200 Subject: Try to build with mingw --- src/core/Cam.cpp | 64 ++++++++++++++++++++--------------------- src/core/Camera.cpp | 44 ++++++++++++++-------------- src/core/Collision.cpp | 8 +++--- src/core/Crime.h | 36 +++++++++++++++++++++++ src/core/Frontend.cpp | 18 ++++++------ src/core/Frontend.h | 2 +- src/core/Game.cpp | 2 +- src/core/Game.h | 3 +- src/core/General.h | 2 +- src/core/IniFile.cpp | 4 +-- src/core/Pad.cpp | 8 +++--- src/core/PlayerInfo.cpp | 44 ++++++++++++++-------------- src/core/Pools.cpp | 2 +- src/core/Profile.cpp | 28 +++++++++--------- src/core/Stats.cpp | 8 +++--- src/core/Streaming.cpp | 42 +++++++++++++-------------- src/core/Streaming.h | 1 - src/core/Timer.cpp | 2 +- src/core/Wanted.cpp | 4 +-- src/core/Wanted.h | 38 ++----------------------- src/core/World.cpp | 76 ++++++++++++++++++++++++------------------------- src/core/ZoneCull.cpp | 2 +- src/core/common.h | 57 ++++++++++++++++++------------------- src/core/main.cpp | 2 +- src/core/patcher.cpp | 2 +- src/core/timebars.cpp | 4 +-- 26 files changed, 251 insertions(+), 252 deletions(-) create mode 100644 src/core/Crime.h (limited to 'src/core') diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 07dc2051..f0a60093 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -117,9 +117,9 @@ CCam::Process(void) float FwdSpeedX = ((CVehicle*)CamTargetEntity)->GetMoveSpeed().x * Fwd.x; float FwdSpeedY = ((CVehicle*)CamTargetEntity)->GetMoveSpeed().y * Fwd.y; if(FwdSpeedX + FwdSpeedY > 0.0f) - TargetSpeedVar = min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/0.9f, 1.0f); + TargetSpeedVar = Min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/0.9f, 1.0f); else - TargetSpeedVar = -min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/1.8f, 0.5f); + TargetSpeedVar = -Min(Sqrt(SQR(FwdSpeedX) + SQR(FwdSpeedY))/1.8f, 0.5f); SpeedVar = 0.895f*SpeedVar + 0.105*TargetSpeedVar; }else{ CameraTarget = CamTargetEntity->GetPosition(); @@ -341,7 +341,7 @@ WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSp else if(TargetSpeed > 0.0f && *CurrentSpeed > TargetSpeed) *CurrentSpeed = TargetSpeed; - *CurrentValue += *CurrentSpeed * min(10.0f, CTimer::GetTimeStep()); + *CurrentValue += *CurrentSpeed * Min(10.0f, CTimer::GetTimeStep()); } void @@ -467,7 +467,7 @@ CCam::ProcessSpecialHeightRoutines(void) vehicle->IsVehicle()){ float height = vehicle->GetColModel()->boundingBox.GetSize().z; if(FoundCar){ - HighestCar = max(HighestCar, height); + HighestCar = Max(HighestCar, height); }else{ FoundCar = true; HighestCar = height; @@ -481,7 +481,7 @@ CCam::ProcessSpecialHeightRoutines(void) vehicle->IsVehicle()){ float height = vehicle->GetColModel()->boundingBox.GetSize().z; if(FoundCar){ - HighestCar = max(HighestCar, height); + HighestCar = Max(HighestCar, height); }else{ FoundCar = true; HighestCar = height; @@ -1323,7 +1323,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl else if(ReqSpeed > 0.0f && BetaSpeed > ReqSpeed) BetaSpeed = ReqSpeed; - Beta += BetaSpeed * min(10.0f, CTimer::GetTimeStep()); + Beta += BetaSpeed * Min(10.0f, CTimer::GetTimeStep()); */ WellBufferMe(FixedTargetOrientation, &Beta, &BetaSpeed, MaxSpeed, Acceleration, true); @@ -1398,7 +1398,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl // Process height offset to avoid peds and cars float TargetZOffSet = m_fRoadOffSet + m_fDimensionOfHighestNearCar; - TargetZOffSet = max(TargetZOffSet, m_fPedBetweenCameraHeightOffset); + TargetZOffSet = Max(TargetZOffSet, m_fPedBetweenCameraHeightOffset); float TargetHeight = CameraTarget.z + TargetZOffSet - Source.z; if(TargetHeight > m_fCamBufferedHeight){ @@ -1454,7 +1454,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl } } - TargetCoors.z += min(1.0f, m_fCamBufferedHeight/2.0f); + TargetCoors.z += Min(1.0f, m_fCamBufferedHeight/2.0f); m_cvecTargetCoorsForFudgeInter = TargetCoors; Front = TargetCoors - Source; @@ -1553,7 +1553,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient #else if(Alpha > fBaseDist) // comparing an angle against a distance? #endif - CamDist = fBaseDist + Cos(min(Alpha*fFalloff, HALFPI))*fAngleDist; + CamDist = fBaseDist + Cos(Min(Alpha*fFalloff, HALFPI))*fAngleDist; else CamDist = fBaseDist + Cos(Alpha)*fAngleDist; @@ -1585,14 +1585,14 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient PedColDist = (TargetCoors - colPoint.point).Magnitude(); Source = colPoint.point; if(PedColDist < DEFAULT_NEAR + 0.3f) - RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); + RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f)); }else{ - RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, DEFAULT_NEAR)); + RwCameraSetNearClipPlane(Scene.camera, Min(ColCamDist-0.35f, DEFAULT_NEAR)); } }else{ Source = colPoint.point; if(PedColDist < DEFAULT_NEAR + 0.3f) - RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); + RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f)); } } CWorld::pIgnoreEntity = nil; @@ -1609,7 +1609,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth; // Try to decrease near clip - dist = max(min(Near, dist), 0.1f); + dist = Max(Min(Near, dist), 0.1f); if(dist < Near) RwCameraSetNearClipPlane(Scene.camera, dist); @@ -1639,7 +1639,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient float PlayerDist = (Source - player->GetPosition()).Magnitude(); if(PlayerDist < 2.75f) Near = PlayerDist/2.75f * DEFAULT_NEAR - 0.3f; - RwCameraSetNearClipPlane(Scene.camera, max(Near, 0.1f)); + RwCameraSetNearClipPlane(Scene.camera, Max(Near, 0.1f)); } } @@ -1881,7 +1881,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa } if(FoundCamRoof){ // Camera is under something - float roof = FoundRoofCenter ? min(CamRoof, CarRoof) : CamRoof; + float roof = FoundRoofCenter ? Min(CamRoof, CarRoof) : CamRoof; // Same weirdness again? TargetAlpha = CGeneral::GetATanOfXY(CA_MAX_DISTANCE, roof - CamTargetZ - 1.5f); CamClear = false; @@ -2139,7 +2139,7 @@ void CCam::Cam_On_A_String_Unobscured(const CVector &TargetCoors, float BaseDist) { CA_MAX_DISTANCE = BaseDist + 0.1f + TheCamera.CarZoomValueSmooth; - CA_MIN_DISTANCE = min(BaseDist*0.6f, 3.5f); + CA_MIN_DISTANCE = Min(BaseDist*0.6f, 3.5f); CVector Dist = Source - TargetCoors; @@ -2361,7 +2361,7 @@ CCam::Process_TopDownPed(const CVector &CameraTarget, float TargetOrientation, f if(FindPlayerPed()->m_pPointGunAt){ Dist = (FindPlayerPed()->m_pPointGunAt->GetPosition() - CameraTarget).Magnitude2D(); if(Dist > 6.0f) - HeightTarget = max(HeightTarget, Dist/22.0f*37.0f); + HeightTarget = Max(HeightTarget, Dist/22.0f*37.0f); } Source = TargetCoors + CVector(0.0f, -1.0f, 9.0f); @@ -2813,13 +2813,13 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, m_vecBufferedPlayerBodyOffset.z = TheCamera.m_fGaitSwayBuffer * m_vecBufferedPlayerBodyOffset.z + (1.0f-TheCamera.m_fGaitSwayBuffer) * HeadPos.z; - HeadPos = RwV3d(CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset); + HeadPos = (CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset).toRwV3d(); }else{ float HeadDelta = (HeadPos - InitialHeadPos).Magnitude2D(); CVector Fwd = CamTargetEntity->GetForward(); Fwd.z = 0.0f; Fwd.Normalise(); - HeadPos = RwV3d(HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition()); + HeadPos = (HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition()).toRwV3d(); HeadPos.z += 0.59f; } Source = HeadPos; @@ -3125,7 +3125,7 @@ CCam::Process_Syphon(const CVector &CameraTarget, float, float, float) Front = TargetCoors - Source; m_fMinDistAwayFromCamWhenInterPolating = Front.Magnitude2D(); if(m_fMinDistAwayFromCamWhenInterPolating < 1.1f) - RwCameraSetNearClipPlane(Scene.camera, max(m_fMinDistAwayFromCamWhenInterPolating - 0.35f, 0.05f)); + RwCameraSetNearClipPlane(Scene.camera, Max(m_fMinDistAwayFromCamWhenInterPolating - 0.35f, 0.05f)); Front.Normalise(); GetVectorsReadyForRW(); } @@ -3382,7 +3382,7 @@ CCam::Process_Fight_Cam(const CVector &CameraTarget, float TargetOrientation, fl WellBufferMe(TargetOrientation, &m_fBufferedTargetOrientation, &m_fBufferedTargetOrientationSpeed, 0.07f, 0.004f, true); TargetCoors = CameraTarget + 0.5f*CVector(Cos(m_fBufferedTargetOrientation), Sin(m_fBufferedTargetOrientation), 0.0f); - TargetCamHeight = CameraTarget.z - Source.z + max(m_fPedBetweenCameraHeightOffset, m_fRoadOffSet + m_fDimensionOfHighestNearCar) - 0.5f; + TargetCamHeight = CameraTarget.z - Source.z + Max(m_fPedBetweenCameraHeightOffset, m_fRoadOffSet + m_fDimensionOfHighestNearCar) - 0.5f; if(TargetCamHeight > m_fCamBufferedHeight) WellBufferMe(TargetCamHeight, &m_fCamBufferedHeight, &m_fCamBufferedHeightSpeed, 0.15f, 0.04f, false); else @@ -4556,14 +4556,14 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient PedColDist = (TargetCoors - colPoint.point).Magnitude(); Source = colPoint.point; if(PedColDist < DEFAULT_NEAR + 0.3f) - RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); + RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f)); }else{ - RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, DEFAULT_NEAR)); + RwCameraSetNearClipPlane(Scene.camera, Min(ColCamDist-0.35f, DEFAULT_NEAR)); } }else{ Source = colPoint.point; if(PedColDist < DEFAULT_NEAR + 0.3f) - RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); + RwCameraSetNearClipPlane(Scene.camera, Max(PedColDist-0.3f, 0.05f)); } } CWorld::pIgnoreEntity = nil; @@ -4580,7 +4580,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth; // Try to decrease near clip - dist = max(min(Near, dist), 0.1f); + dist = Max(Min(Near, dist), 0.1f); if(dist < Near) RwCameraSetNearClipPlane(Scene.camera, dist); @@ -4714,7 +4714,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, minDistForVehType = minDistForVehType * 0.65f; } - float nextDistance = max(newDistance, minDistForVehType); + float nextDistance = Max(newDistance, minDistForVehType); CA_MAX_DISTANCE = newDistance; CA_MIN_DISTANCE = 3.5f; @@ -4811,7 +4811,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, float betaChangeMult2 = (car->m_vecMoveSpeed - DotProduct(car->m_vecMoveSpeed, Front) * Front).Magnitude(); - float betaChange = min(1.0f, betaChangeMult1 * betaChangeMult2) * (velocityRightHeading - camRightHeading); + float betaChange = Min(1.0f, betaChangeMult1 * betaChangeMult2) * (velocityRightHeading - camRightHeading); if (betaChange <= betaChangeLimit) { if (betaChange < -betaChangeLimit) betaChange = -betaChangeLimit; @@ -4827,7 +4827,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, float carPosChange = (TargetCoors - m_aTargetHistoryPosTwo).Magnitude(); if (carPosChange < newDistance && newDistance > minDistForThisCar) { - newDistance = max(minDistForThisCar, carPosChange); + newDistance = Max(minDistForThisCar, carPosChange); } float maxAlphaAllowed = CARCAM_SET[camSetArrPos][13]; @@ -4851,7 +4851,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, v200 = (1.5f - carCol->boundingBox.min.y) / Cos(v88); } else { float a6g = 1.2f + carCol->boundingBox.max.x; - v200 = a6g / Cos(max(0.0f, HALFPI - v88)); + v200 = a6g / Cos(Max(0.0f, HALFPI - v88)); } maxAlphaAllowed = Cos(Beta - (car->GetForward().Heading() - HALFPI)) * Atan2(car->GetForward().z, car->GetForward().Magnitude2D()) + Atan2(TargetCoors.z - car->GetPosition().z + car->GetHeightAboveRoad(), v200 * 1.2f); @@ -4944,7 +4944,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, yMovement = 0.0; xMovement = 0.0; targetAlpha = Alpha; - stepsLeftToChangeBetaByMouse = max(0.0f, stepsLeftToChangeBetaByMouse - CTimer::GetTimeStep()); + stepsLeftToChangeBetaByMouse = Max(0.0f, stepsLeftToChangeBetaByMouse - CTimer::GetTimeStep()); mouseChangesBeta = true; } } @@ -4963,7 +4963,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, float newAngleSpeedMaxBlendAmount = CARCAM_SET[camSetArrPos][9]; float angleChangeStep = pow(CARCAM_SET[camSetArrPos][8], CTimer::GetTimeStep()); - float targetBetaWithStickBlendAmount = betaSpeedFromStickX + (targetBeta - Beta) / max(CTimer::GetTimeStep(), 1.0f); + float targetBetaWithStickBlendAmount = betaSpeedFromStickX + (targetBeta - Beta) / Max(CTimer::GetTimeStep(), 1.0f); if (targetBetaWithStickBlendAmount < -newAngleSpeedMaxBlendAmount) targetBetaWithStickBlendAmount = -newAngleSpeedMaxBlendAmount; @@ -5088,7 +5088,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) { Source = foundCol.point; if (obstacleTargetDist < 1.2f) { - RwCameraSetNearClipPlane(Scene.camera, max(0.05f, obstacleTargetDist - 0.3f)); + RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f)); } } else { if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false)) { diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 6747ebf5..c8eaaa56 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -467,7 +467,7 @@ CCamera::Process(void) GetPosition().z += shakeOffset*(((shakeRand&0xF00)>>8)-7); if(shakeOffset > 0.0f && m_BlurType != MBLUR_SNIPER) - SetMotionBlurAlpha(min((int)(shakeStrength*255.0f) + 25, 150)); + SetMotionBlurAlpha(Min((int)(shakeStrength*255.0f) + 25, 150)); if(Cams[ActiveCam].Mode == CCam::MODE_1STPERSON && FindPlayerVehicle() && FindPlayerVehicle()->GetUp().z < 0.2f) SetMotionBlur(230, 230, 230, 215, MBLUR_NORMAL); @@ -489,19 +489,19 @@ CCamera::Process(void) CDraw::SetFOV(Cams[2].FOV); m_vecGameCamPos = Cams[ActiveCam].Source; - *RwMatrixGetPos(RwFrameGetMatrix(frame)) = (RwV3d)GetPosition(); - *RwMatrixGetAt(RwFrameGetMatrix(frame)) = (RwV3d)GetForward(); - *RwMatrixGetUp(RwFrameGetMatrix(frame)) = (RwV3d)GetUp(); - *RwMatrixGetRight(RwFrameGetMatrix(frame)) = (RwV3d)GetRight(); + *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d(); + *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d(); + *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d(); + *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d(); RwMatrixUpdate(RwFrameGetMatrix(frame)); RwFrameUpdateObjects(frame); }else{ RwFrame *frame = RwCameraGetFrame(m_pRwCamera); m_vecGameCamPos = GetPosition(); - *RwMatrixGetPos(RwFrameGetMatrix(frame)) = (RwV3d)GetPosition(); - *RwMatrixGetAt(RwFrameGetMatrix(frame)) = (RwV3d)GetForward(); - *RwMatrixGetUp(RwFrameGetMatrix(frame)) = (RwV3d)GetUp(); - *RwMatrixGetRight(RwFrameGetMatrix(frame)) = (RwV3d)GetRight(); + *RwMatrixGetPos(RwFrameGetMatrix(frame)) = GetPosition().toRwV3d(); + *RwMatrixGetAt(RwFrameGetMatrix(frame)) = GetForward().toRwV3d(); + *RwMatrixGetUp(RwFrameGetMatrix(frame)) = GetUp().toRwV3d(); + *RwMatrixGetRight(RwFrameGetMatrix(frame)) = GetRight().toRwV3d(); RwMatrixUpdate(RwFrameGetMatrix(frame)); RwFrameUpdateObjects(frame); } @@ -768,27 +768,27 @@ CCamera::CamControl(void) if(m_bUseScriptZoomValueCar){ if(CarZoomValueSmooth < m_fCarZoomValueScript){ CarZoomValueSmooth += 0.12f * CTimer::GetTimeStep(); - CarZoomValueSmooth = min(CarZoomValueSmooth, m_fCarZoomValueScript); + CarZoomValueSmooth = Min(CarZoomValueSmooth, m_fCarZoomValueScript); }else{ CarZoomValueSmooth -= 0.12f * CTimer::GetTimeStep(); - CarZoomValueSmooth = max(CarZoomValueSmooth, m_fCarZoomValueScript); + CarZoomValueSmooth = Max(CarZoomValueSmooth, m_fCarZoomValueScript); } }else if(m_bFailedCullZoneTestPreviously){ CloseInCarHeightTarget = 0.65f; if(CarZoomValueSmooth < -0.65f){ CarZoomValueSmooth += 0.12f * CTimer::GetTimeStep(); - CarZoomValueSmooth = min(CarZoomValueSmooth, -0.65f); + CarZoomValueSmooth = Min(CarZoomValueSmooth, -0.65f); }else{ CarZoomValueSmooth -= 0.12f * CTimer::GetTimeStep(); - CarZoomValueSmooth = max(CarZoomValueSmooth, -0.65f); + CarZoomValueSmooth = Max(CarZoomValueSmooth, -0.65f); } }else{ if(CarZoomValueSmooth < CarZoomValue){ CarZoomValueSmooth += 0.12f * CTimer::GetTimeStep(); - CarZoomValueSmooth = min(CarZoomValueSmooth, CarZoomValue); + CarZoomValueSmooth = Min(CarZoomValueSmooth, CarZoomValue); }else{ CarZoomValueSmooth -= 0.12f * CTimer::GetTimeStep(); - CarZoomValueSmooth = max(CarZoomValueSmooth, CarZoomValue); + CarZoomValueSmooth = Max(CarZoomValueSmooth, CarZoomValue); } } @@ -872,28 +872,28 @@ CCamera::CamControl(void) if(m_bUseScriptZoomValuePed){ if(m_fPedZoomValueSmooth < m_fPedZoomValueScript){ m_fPedZoomValueSmooth += 0.12f * CTimer::GetTimeStep(); - m_fPedZoomValueSmooth = min(m_fPedZoomValueSmooth, m_fPedZoomValueScript); + m_fPedZoomValueSmooth = Min(m_fPedZoomValueSmooth, m_fPedZoomValueScript); }else{ m_fPedZoomValueSmooth -= 0.12f * CTimer::GetTimeStep(); - m_fPedZoomValueSmooth = max(m_fPedZoomValueSmooth, m_fPedZoomValueScript); + m_fPedZoomValueSmooth = Max(m_fPedZoomValueSmooth, m_fPedZoomValueScript); } }else if(m_bFailedCullZoneTestPreviously){ static float PedZoomedInVal = 0.5f; CloseInPedHeightTarget = 0.7f; if(m_fPedZoomValueSmooth < PedZoomedInVal){ m_fPedZoomValueSmooth += 0.12f * CTimer::GetTimeStep(); - m_fPedZoomValueSmooth = min(m_fPedZoomValueSmooth, PedZoomedInVal); + m_fPedZoomValueSmooth = Min(m_fPedZoomValueSmooth, PedZoomedInVal); }else{ m_fPedZoomValueSmooth -= 0.12f * CTimer::GetTimeStep(); - m_fPedZoomValueSmooth = max(m_fPedZoomValueSmooth, PedZoomedInVal); + m_fPedZoomValueSmooth = Max(m_fPedZoomValueSmooth, PedZoomedInVal); } }else{ if(m_fPedZoomValueSmooth < m_fPedZoomValue){ m_fPedZoomValueSmooth += 0.12f * CTimer::GetTimeStep(); - m_fPedZoomValueSmooth = min(m_fPedZoomValueSmooth, m_fPedZoomValue); + m_fPedZoomValueSmooth = Min(m_fPedZoomValueSmooth, m_fPedZoomValue); }else{ m_fPedZoomValueSmooth -= 0.12f * CTimer::GetTimeStep(); - m_fPedZoomValueSmooth = max(m_fPedZoomValueSmooth, m_fPedZoomValue); + m_fPedZoomValueSmooth = Max(m_fPedZoomValueSmooth, m_fPedZoomValue); } } @@ -2256,7 +2256,7 @@ CCamera::IsItTimeForNewcam(int32 obbeMode, int32 time) if(fwd.Magnitude() < 2.0f) // very close, fix near clip - SetNearClipScript(max(fwd.Magnitude()*0.5f, 0.05f)); + SetNearClipScript(Max(fwd.Magnitude()*0.5f, 0.05f)); // too far and driving away from cam if(fwd.Magnitude() > 19.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) return true; diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 5bdb32dc..7dfe3651 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -153,10 +153,10 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) // on water we expect to be between levels multipleLevels = true; }else{ - xmin = max(sx - 1, 0); - xmax = min(sx + 1, NUMSECTORS_X-1); - ymin = max(sy - 1, 0); - ymax = min(sy + 1, NUMSECTORS_Y-1); + xmin = Max(sx - 1, 0); + xmax = Min(sx + 1, NUMSECTORS_X-1); + ymin = Max(sy - 1, 0); + ymax = Min(sy + 1, NUMSECTORS_Y-1); for(x = xmin; x <= xmax; x++) for(y = ymin; y <= ymax; y++){ diff --git a/src/core/Crime.h b/src/core/Crime.h new file mode 100644 index 00000000..8dfae5b8 --- /dev/null +++ b/src/core/Crime.h @@ -0,0 +1,36 @@ +#pragma once + +enum eCrimeType { + CRIME_NONE, + CRIME_POSSESSION_GUN, + CRIME_HIT_PED, + CRIME_HIT_COP, + CRIME_SHOOT_PED, + CRIME_SHOOT_COP, + CRIME_STEAL_CAR, + CRIME_RUN_REDLIGHT, + CRIME_RECKLESS_DRIVING, + CRIME_SPEEDING, + CRIME_RUNOVER_PED, + CRIME_RUNOVER_COP, + CRIME_SHOOT_HELI, + CRIME_PED_BURNED, + CRIME_COP_BURNED, + CRIME_VEHICLE_BURNED, + CRIME_DESTROYED_CESSNA, + NUM_CRIME_TYPES +}; + +class CCrimeBeingQd +{ +public: + eCrimeType m_nType; + uint32 m_nId; + uint32 m_nTime; + CVector m_vecPosn; + bool m_bReported; + bool m_bPoliceDoesntCare; + + CCrimeBeingQd() { }; + ~CCrimeBeingQd() { }; +}; diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 6fe06d96..db6073a6 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -349,8 +349,8 @@ CMenuManager::PageUpList(bool playSoundOnSuccess) if(playSoundOnSuccess) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - m_nFirstVisibleRowOnList = max(0, m_nFirstVisibleRowOnList - MAX_VISIBLE_LIST_ROW); - m_nSelectedListRow = min(m_nSelectedListRow, m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1); + m_nFirstVisibleRowOnList = Max(0, m_nFirstVisibleRowOnList - MAX_VISIBLE_LIST_ROW); + m_nSelectedListRow = Min(m_nSelectedListRow, m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1); } else { m_nFirstVisibleRowOnList = 0; m_nSelectedListRow = 0; @@ -367,8 +367,8 @@ CMenuManager::PageDownList(bool playSoundOnSuccess) if(playSoundOnSuccess) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - m_nFirstVisibleRowOnList = min(m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW, m_nTotalListRow - MAX_VISIBLE_LIST_ROW); - m_nSelectedListRow = max(m_nSelectedListRow, m_nFirstVisibleRowOnList); + m_nFirstVisibleRowOnList = Min(m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW, m_nTotalListRow - MAX_VISIBLE_LIST_ROW); + m_nSelectedListRow = Max(m_nSelectedListRow, m_nFirstVisibleRowOnList); } else { m_nFirstVisibleRowOnList = m_nTotalListRow - MAX_VISIBLE_LIST_ROW; m_nSelectedListRow = m_nTotalListRow - 1; @@ -643,7 +643,7 @@ CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostR } else color = CRGBA(185, 120, 0, FadeIn(255)); - maxBarHeight = max(mostLeftBarSize, mostRightBarSize); + maxBarHeight = Max(mostLeftBarSize, mostRightBarSize); float curBarFreeSpace = ((16 - i) * mostLeftBarSize + i * mostRightBarSize) / 16.0f; float left = curBarX; @@ -2492,7 +2492,7 @@ CMenuManager::DrawPlayerSetupScreen() strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "(", 1); if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "}", 1)) strncpy(&m_pSelectedSkin->skinNameDisplayed[k], ")", 1); - if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "£", 1)) + if (!strncmp(&m_pSelectedSkin->skinNameDisplayed[k], "�", 1)) strncpy(&m_pSelectedSkin->skinNameDisplayed[k], "$", 1); } @@ -2829,7 +2829,7 @@ CMenuManager::FadeIn(int alpha) m_nCurrScreen == MENUPAGE_DELETING) return alpha; - return min(m_nMenuFadeAlpha, alpha); + return Min(m_nMenuFadeAlpha, alpha); } void @@ -5393,7 +5393,7 @@ CMenuManager::PrintMap(void) if (fMapCenterY + fMapSize < SCREEN_HEIGHT - MENU_Y(60.0f)) fMapCenterY = SCREEN_HEIGHT - MENU_Y(60.0f) - fMapSize; - fMapCenterY = min(fMapCenterY, fMapSize); // To not show beyond north border + fMapCenterY = Min(fMapCenterY, fMapSize); // To not show beyond north border bMenuMapActive = false; @@ -5455,7 +5455,7 @@ CMenuManager::ConstructStatLine(int rowIdx) int percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 : CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1)); - percentCompleted = min(percentCompleted, 100); + percentCompleted = Min(percentCompleted, 100); STAT_LINE("PER_COM", &percentCompleted, false, nil); STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil); diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 71aac605..db54d2a5 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -1,4 +1,4 @@ -#pragma +#pragma once #include "Sprite2d.h" diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 7ccf78d0..8b2f8604 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -72,7 +72,7 @@ #include "Streaming.h" #include "SurfaceTable.h" #include "TempColModels.h" -#include "TimeCycle.h" +#include "Timecycle.h" #include "TrafficLights.h" #include "Train.h" #include "TxdStore.h" diff --git a/src/core/Game.h b/src/core/Game.h index e3f0f616..acfeff0f 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -1,7 +1,6 @@ #pragma once -enum eLevelName -{ +enum eLevelName { LEVEL_IGNORE = -1, // beware, this is only used in CPhysical's m_nZoneLevel LEVEL_NONE = 0, LEVEL_INDUSTRIAL, diff --git a/src/core/General.h b/src/core/General.h index 77828854..7ffa99de 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -124,7 +124,7 @@ public: static bool faststricmp(const char *str1, const char *str2) { for (; *str1; str1++, str2++) { -#if MUCH_SLOWER +#if MUCH_SLOWER || !defined _WIN32 || defined __MINGW32__ if (toupper(*str1) != toupper(*str2)) #else if (__ascii_toupper(*str1) != __ascii_toupper(*str2)) diff --git a/src/core/IniFile.cpp b/src/core/IniFile.cpp index 16e35633..df01b440 100644 --- a/src/core/IniFile.cpp +++ b/src/core/IniFile.cpp @@ -17,10 +17,10 @@ void CIniFile::LoadIniFile() if (f){ CFileMgr::ReadLine(f, gString, 200); sscanf(gString, "%f", &PedNumberMultiplier); - PedNumberMultiplier = min(3.0f, max(0.5f, PedNumberMultiplier)); + PedNumberMultiplier = Min(3.0f, Max(0.5f, PedNumberMultiplier)); CFileMgr::ReadLine(f, gString, 200); sscanf(gString, "%f", &CarNumberMultiplier); - CarNumberMultiplier = min(3.0f, max(0.5f, CarNumberMultiplier)); + CarNumberMultiplier = Min(3.0f, Max(0.5f, CarNumberMultiplier)); CFileMgr::CloseFile(f); } CPopulation::MaxNumberOfPedsInUse = 25.0f * PedNumberMultiplier; diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 86aff05e..8a3fc7cb 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -6,7 +6,7 @@ #include "common.h" #ifdef XINPUT -#include +#include #pragma comment( lib, "Xinput9_1_0.lib" ) #endif @@ -205,7 +205,7 @@ void ArmourCheat() void WantedLevelUpCheat() { CHud::SetHelpMessage(TheText.Get("CHEAT5"), true); - FindPlayerPed()->SetWantedLevel(min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6)); + FindPlayerPed()->SetWantedLevel(Min(FindPlayerPed()->m_pWanted->m_nWantedLevel + 2, 6)); } void WantedLevelDownCheat() @@ -513,10 +513,10 @@ CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &Stat { if ( State1.button || State2.button ) ReconState.button = 255; } #define _RECONCILE_AXIS_POSITIVE(axis) \ - { if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = max(State1.axis, State2.axis); } + { if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = Max(State1.axis, State2.axis); } #define _RECONCILE_AXIS_NEGATIVE(axis) \ - { if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = min(State1.axis, State2.axis); } + { if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = Min(State1.axis, State2.axis); } #define _RECONCILE_AXIS(axis) \ { _RECONCILE_AXIS_POSITIVE(axis); _RECONCILE_AXIS_NEGATIVE(axis); } diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 69b8b7bf..e92f7568 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -1,35 +1,35 @@ #include "common.h" -#include "main.h" -#include "PlayerPed.h" -#include "Wanted.h" -#include "PlayerInfo.h" +#include "Automobile.h" +#include "Bridge.h" +#include "Camera.h" +#include "Cranes.h" +#include "Darkel.h" +#include "Explosion.h" #include "Fire.h" #include "Frontend.h" -#include "PlayerSkin.h" -#include "Darkel.h" +#include "General.h" +#include "HandlingMgr.h" #include "Messages.h" -#include "Text.h" -#include "Stats.h" -#include "Remote.h" -#include "World.h" -#include "Replay.h" -#include "Camera.h" #include "Pad.h" +#include "PathFind.h" +#include "PlayerInfo.h" +#include "PlayerPed.h" +#include "PlayerSkin.h" #include "ProjectileInfo.h" -#include "Explosion.h" +#include "Remote.h" +#include "Renderer.h" +#include "Replay.h" #include "Script.h" -#include "Automobile.h" -#include "HandlingMgr.h" -#include "General.h" #include "SpecialFX.h" -#include "Cranes.h" -#include "Bridge.h" +#include "Stats.h" +#include "Streaming.h" +#include "Text.h" +#include "Wanted.h" #include "WaterLevel.h" -#include "PathFind.h" +#include "World.h" #include "ZoneCull.h" -#include "Renderer.h" -#include "Streaming.h" +#include "main.h" void CPlayerInfo::SetPlayerSkin(char *skin) @@ -184,7 +184,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle) m_pPed->bExplosionProof = true; m_pPed->m_bCanBeDamaged = false; ((CPlayerPed*)m_pPed)->ClearAdrenaline(); - CancelPlayerEnteringCars(false); + CancelPlayerEnteringCars(nil); gFireManager.ExtinguishPoint(GetPos(), 4000.0f); CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f); CProjectileInfo::RemoveAllProjectiles(); diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index fb64c551..4f4588da 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -110,7 +110,7 @@ INITSAVEBUF CStreaming::LoadAllRequestedModels(false); int32 slot = ReadSaveBuf(buf); CVehicle* pVehicle; - char* vbuf = new char[max(sizeof(CAutomobile), sizeof(CBoat))]; + char* vbuf = new char[Max(sizeof(CAutomobile), sizeof(CBoat))]; if (type == VEHICLE_TYPE_BOAT) { memcpy(vbuf, buf, sizeof(CBoat)); SkipSaveBuf(buf, sizeof(CBoat)); diff --git a/src/core/Profile.cpp b/src/core/Profile.cpp index 56584d12..05d54133 100644 --- a/src/core/Profile.cpp +++ b/src/core/Profile.cpp @@ -52,20 +52,20 @@ void CProfile::SuspendProfile(eProfile profile) void CProfile::ShowResults() { - ms_afMaxEndTime[PROFILE_FRAME_RATE] = max(ms_afMaxEndTime[PROFILE_FRAME_RATE], ms_afEndTime[PROFILE_FRAME_RATE]); - ms_afMaxEndTime[PROFILE_PHYSICS] = max(ms_afMaxEndTime[PROFILE_PHYSICS], ms_afEndTime[PROFILE_PHYSICS]); - ms_afMaxEndTime[PROFILE_COLLISION] = max(ms_afMaxEndTime[PROFILE_COLLISION], ms_afEndTime[PROFILE_COLLISION]); - ms_afMaxEndTime[PROFILE_PED_AI] = max(ms_afMaxEndTime[PROFILE_PED_AI], ms_afEndTime[PROFILE_PED_AI]); - ms_afMaxEndTime[PROFILE_PROCESSING_TIME] = max(ms_afMaxEndTime[PROFILE_PROCESSING_TIME], ms_afEndTime[PROFILE_PROCESSING_TIME]); - ms_afMaxEndTime[PROFILE_RENDERING_TIME] = max(ms_afMaxEndTime[PROFILE_RENDERING_TIME], ms_afEndTime[PROFILE_RENDERING_TIME]); - ms_afMaxEndTime[PROFILE_TOTAL] = max(ms_afMaxEndTime[PROFILE_TOTAL], ms_afEndTime[PROFILE_TOTAL]); + ms_afMaxEndTime[PROFILE_FRAME_RATE] = Max(ms_afMaxEndTime[PROFILE_FRAME_RATE], ms_afEndTime[PROFILE_FRAME_RATE]); + ms_afMaxEndTime[PROFILE_PHYSICS] = Max(ms_afMaxEndTime[PROFILE_PHYSICS], ms_afEndTime[PROFILE_PHYSICS]); + ms_afMaxEndTime[PROFILE_COLLISION] = Max(ms_afMaxEndTime[PROFILE_COLLISION], ms_afEndTime[PROFILE_COLLISION]); + ms_afMaxEndTime[PROFILE_PED_AI] = Max(ms_afMaxEndTime[PROFILE_PED_AI], ms_afEndTime[PROFILE_PED_AI]); + ms_afMaxEndTime[PROFILE_PROCESSING_TIME] = Max(ms_afMaxEndTime[PROFILE_PROCESSING_TIME], ms_afEndTime[PROFILE_PROCESSING_TIME]); + ms_afMaxEndTime[PROFILE_RENDERING_TIME] = Max(ms_afMaxEndTime[PROFILE_RENDERING_TIME], ms_afEndTime[PROFILE_RENDERING_TIME]); + ms_afMaxEndTime[PROFILE_TOTAL] = Max(ms_afMaxEndTime[PROFILE_TOTAL], ms_afEndTime[PROFILE_TOTAL]); - ms_afMaxCumulativeTime[PROFILE_FRAME_RATE] = max(ms_afMaxCumulativeTime[PROFILE_FRAME_RATE], ms_afCumulativeTime[PROFILE_FRAME_RATE]); - ms_afMaxCumulativeTime[PROFILE_PHYSICS] = max(ms_afMaxCumulativeTime[PROFILE_PHYSICS], ms_afCumulativeTime[PROFILE_PHYSICS]); - ms_afMaxCumulativeTime[PROFILE_COLLISION] = max(ms_afMaxCumulativeTime[PROFILE_COLLISION], ms_afCumulativeTime[PROFILE_COLLISION]); - ms_afMaxCumulativeTime[PROFILE_PED_AI] = max(ms_afMaxCumulativeTime[PROFILE_PED_AI], ms_afCumulativeTime[PROFILE_PED_AI]); - ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME] = max(ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME], ms_afCumulativeTime[PROFILE_PROCESSING_TIME]); - ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME] = max(ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME], ms_afCumulativeTime[PROFILE_RENDERING_TIME]); - ms_afMaxCumulativeTime[PROFILE_TOTAL] = max(ms_afMaxCumulativeTime[PROFILE_TOTAL], ms_afCumulativeTime[PROFILE_TOTAL]); + ms_afMaxCumulativeTime[PROFILE_FRAME_RATE] = Max(ms_afMaxCumulativeTime[PROFILE_FRAME_RATE], ms_afCumulativeTime[PROFILE_FRAME_RATE]); + ms_afMaxCumulativeTime[PROFILE_PHYSICS] = Max(ms_afMaxCumulativeTime[PROFILE_PHYSICS], ms_afCumulativeTime[PROFILE_PHYSICS]); + ms_afMaxCumulativeTime[PROFILE_COLLISION] = Max(ms_afMaxCumulativeTime[PROFILE_COLLISION], ms_afCumulativeTime[PROFILE_COLLISION]); + ms_afMaxCumulativeTime[PROFILE_PED_AI] = Max(ms_afMaxCumulativeTime[PROFILE_PED_AI], ms_afCumulativeTime[PROFILE_PED_AI]); + ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME] = Max(ms_afMaxCumulativeTime[PROFILE_PROCESSING_TIME], ms_afCumulativeTime[PROFILE_PROCESSING_TIME]); + ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME] = Max(ms_afMaxCumulativeTime[PROFILE_RENDERING_TIME], ms_afCumulativeTime[PROFILE_RENDERING_TIME]); + ms_afMaxCumulativeTime[PROFILE_TOTAL] = Max(ms_afMaxCumulativeTime[PROFILE_TOTAL], ms_afCumulativeTime[PROFILE_TOTAL]); } #endif \ No newline at end of file diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index ef3c0ab6..99274e04 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -121,13 +121,13 @@ void CStats::RegisterFastestTime(int32 index, int32 time) if (FastestTimes[index] == 0) FastestTimes[index] = time; else - FastestTimes[index] = min(FastestTimes[index], time); + FastestTimes[index] = Min(FastestTimes[index], time); } void CStats::RegisterHighestScore(int32 index, int32 score) { assert(index >= 0 && index < TOTAL_HIGHEST_SCORES); - HighestScores[index] = max(HighestScores[index], score); + HighestScores[index] = Max(HighestScores[index], score); } void CStats::RegisterElBurroTime(int32 time) @@ -167,7 +167,7 @@ void CStats::AnotherCriminalCaught() void CStats::RegisterLevelAmbulanceMission(int32 level) { - HighestLevelAmbulanceMission = max(HighestLevelAmbulanceMission, level); + HighestLevelAmbulanceMission = Max(HighestLevelAmbulanceMission, level); } void CStats::AnotherFireExtinguished() @@ -177,7 +177,7 @@ void CStats::AnotherFireExtinguished() void CStats::RegisterLongestFlightInDodo(int32 time) { - LongestFlightInDodo = max(LongestFlightInDodo, time); + LongestFlightInDodo = Max(LongestFlightInDodo, time); } void CStats::RegisterTimeTakenDefuseMission(int32 time) diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index dae83d89..15fe60e2 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1950,7 +1950,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())){ lodDistSq = sq(mi->GetLargestLodDistance()); - lodDistSq = min(lodDistSq, sq(STREAM_DIST)); + lodDistSq = Min(lodDistSq, sq(STREAM_DIST)); pos = CVector2D(e->GetPosition()); if(xmin < pos.x && pos.x < xmax && ymin < pos.y && pos.y < ymax && @@ -2170,20 +2170,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) if(Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y)){ // looking west/east - ymin = max(iy - 10, 0); - ymax = min(iy + 10, NUMSECTORS_Y - 1); + ymin = Max(iy - 10, 0); + ymax = Min(iy + 10, NUMSECTORS_Y - 1); assert(ymin <= ymax); // Delete a block of sectors that we know is behind the camera if(TheCamera.GetForward().x > 0){ // looking east - xmax = max(ix - 2, 0); - xmin = max(ix - 10, 0); + xmax = Max(ix - 2, 0); + xmin = Max(ix - 10, 0); inc = 1; }else{ // looking west - xmax = min(ix + 2, NUMSECTORS_X - 1); - xmin = min(ix + 10, NUMSECTORS_X - 1); + xmax = Min(ix + 2, NUMSECTORS_X - 1); + xmin = Min(ix + 10, NUMSECTORS_X - 1); inc = -1; } for(y = ymin; y <= ymax; y++){ @@ -2199,13 +2199,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) // Now a block that intersects with the camera's frustum if(TheCamera.GetForward().x > 0){ // looking east - xmax = max(ix + 10, 0); - xmin = max(ix - 2, 0); + xmax = Max(ix + 10, 0); + xmin = Max(ix - 2, 0); inc = 1; }else{ // looking west - xmax = min(ix - 10, NUMSECTORS_X - 1); - xmin = min(ix + 2, NUMSECTORS_X - 1); + xmax = Min(ix - 10, NUMSECTORS_X - 1); + xmin = Min(ix + 2, NUMSECTORS_X - 1); inc = -1; } for(y = ymin; y <= ymax; y++){ @@ -2234,20 +2234,20 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) }else{ // looking north/south - xmin = max(ix - 10, 0); - xmax = min(ix + 10, NUMSECTORS_X - 1); + xmin = Max(ix - 10, 0); + xmax = Min(ix + 10, NUMSECTORS_X - 1); assert(xmin <= xmax); // Delete a block of sectors that we know is behind the camera if(TheCamera.GetForward().y > 0){ // looking north - ymax = max(iy - 2, 0); - ymin = max(iy - 10, 0); + ymax = Max(iy - 2, 0); + ymin = Max(iy - 10, 0); inc = 1; }else{ // looking south - ymax = min(iy + 2, NUMSECTORS_Y - 1); - ymin = min(iy + 10, NUMSECTORS_Y - 1); + ymax = Min(iy + 2, NUMSECTORS_Y - 1); + ymin = Min(iy + 10, NUMSECTORS_Y - 1); inc = -1; } for(x = xmin; x <= xmax; x++){ @@ -2263,13 +2263,13 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) // Now a block that intersects with the camera's frustum if(TheCamera.GetForward().y > 0){ // looking north - ymax = max(iy + 10, 0); - ymin = max(iy - 2, 0); + ymax = Max(iy + 10, 0); + ymin = Max(iy - 2, 0); inc = 1; }else{ // looking south - ymax = min(iy - 10, NUMSECTORS_Y - 1); - ymin = min(iy + 2, NUMSECTORS_Y - 1); + ymax = Min(iy - 10, NUMSECTORS_Y - 1); + ymin = Min(iy + 2, NUMSECTORS_Y - 1); inc = -1; } for(x = xmin; x <= xmax; x++){ diff --git a/src/core/Streaming.h b/src/core/Streaming.h index c910c068..cf8790e9 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -71,7 +71,6 @@ struct CStreamingChannel }; class CDirectory; -enum eLevelName; class CPtrList; class CStreaming diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index ebd79695..8f8570d7 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -138,7 +138,7 @@ void CTimer::Update(void) if ( !CRecordDataForGame::IsPlayingBack() ) { - ms_fTimeStep = min(3.0f, ms_fTimeStep); + ms_fTimeStep = Min(3.0f, ms_fTimeStep); if ( (m_snTimeInMilliseconds - m_snPreviousTimeInMilliseconds) > 60 ) m_snTimeInMilliseconds = m_snPreviousTimeInMilliseconds + 60; diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index ce7d217e..6f5fdf06 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -212,7 +212,7 @@ CWanted::ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesnt else sensitivity = m_fCrimeSensitivity; - wantedLevelDrop = min(CCullZones::GetWantedLevelDrop(), 100); + wantedLevelDrop = Min(CCullZones::GetWantedLevelDrop(), 100); chaos = (1.0f - wantedLevelDrop/100.0f) * sensitivity; if (policeDoesntCare) @@ -371,7 +371,7 @@ CWanted::Update(void) CVector playerPos = FindPlayerCoors(); if (WorkOutPolicePresence(playerPos, radius) == 0) { m_nLastUpdateTime = CTimer::GetTimeInMilliseconds(); - m_nChaos = max(0, m_nChaos - 1); + m_nChaos = Max(0, m_nChaos - 1); UpdateWantedLevel(); } } diff --git a/src/core/Wanted.h b/src/core/Wanted.h index afeec8b0..e3e407b0 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -1,44 +1,10 @@ #pragma once +#include "Crime.h" + class CEntity; class CCopPed; -enum eCrimeType -{ - CRIME_NONE, - CRIME_POSSESSION_GUN, - CRIME_HIT_PED, - CRIME_HIT_COP, - CRIME_SHOOT_PED, - CRIME_SHOOT_COP, - CRIME_STEAL_CAR, - CRIME_RUN_REDLIGHT, - CRIME_RECKLESS_DRIVING, - CRIME_SPEEDING, - CRIME_RUNOVER_PED, - CRIME_RUNOVER_COP, - CRIME_SHOOT_HELI, - CRIME_PED_BURNED, - CRIME_COP_BURNED, - CRIME_VEHICLE_BURNED, - CRIME_DESTROYED_CESSNA, - NUM_CRIME_TYPES -}; - -class CCrimeBeingQd -{ -public: - eCrimeType m_nType; - uint32 m_nId; - uint32 m_nTime; - CVector m_vecPosn; - bool m_bReported; - bool m_bPoliceDoesntCare; - - CCrimeBeingQd() { }; - ~CCrimeBeingQd() { }; -}; - class CWanted { public: diff --git a/src/core/World.cpp b/src/core/World.cpp index 7ef43593..404b92c0 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -777,10 +777,10 @@ CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector &position, float *nEntitiesFound = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); - const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -1045,10 +1045,10 @@ CWorld::FindObjectsKindaColliding(const CVector &position, float radius, bool bC *nCollidingEntities = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); - const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -1124,10 +1124,10 @@ CWorld::FindObjectsIntersectingCube(const CVector &vecStartPos, const CVector &v { CWorld::AdvanceCurrentScanCode(); *nIntersecting = 0; - const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -1205,10 +1205,10 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CColBox &boundingBox, co { CWorld::AdvanceCurrentScanCode(); *nEntitiesFound = 0; - const int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -1285,10 +1285,10 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector &vecStartPos, const CV { CWorld::AdvanceCurrentScanCode(); *nIntersecting = 0; - const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -1499,10 +1499,10 @@ CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) float fStartY = y1 - 10.0f; float fEndX = x2 + 10.0f; float fEndY = y2 + 10.0f; - const int32 nStartX = max(CWorld::GetSectorIndexX(fStartX), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(fStartY), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -1544,13 +1544,13 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1 } if(bInsideSphere) { if(pVehicle->GetPosition().x <= (x1 + x2) * 0.5f) - pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f); + pVehicle->m_vecMoveSpeed.x = Min(pVehicle->m_vecMoveSpeed.x, 0.0f); else - pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f); + pVehicle->m_vecMoveSpeed.x = Max(pVehicle->m_vecMoveSpeed.x, 0.0f); if(pVehicle->GetPosition().y <= (y1 + y2) * 0.5f) - pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f); + pVehicle->m_vecMoveSpeed.y = Min(pVehicle->m_vecMoveSpeed.y, 0.0f); else - pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f); + pVehicle->m_vecMoveSpeed.y = Max(pVehicle->m_vecMoveSpeed.y, 0.0f); } } } @@ -2086,10 +2086,10 @@ CWorld::TriggerExplosion(const CVector &position, float fRadius, float fPower, C { CVector2D vecStartPos(position.x - fRadius, position.y - fRadius); CVector2D vecEndPos(position.x + fRadius, position.y + fRadius); - const int32 nStartX = max(CWorld::GetSectorIndexX(vecStartPos.x), 0); - const int32 nStartY = max(CWorld::GetSectorIndexY(vecStartPos.y), 0); - const int32 nEndX = min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { CSector *pSector = CWorld::GetSector(x, y); @@ -2144,7 +2144,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa if(pEntity->bIsStatic) { float fDamageMultiplier = (fRadius - fMagnitude) * 2.0f / fRadius; - float fDamage = 300.0f * min(fDamageMultiplier, 1.0f); + float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f); pObject->ObjectDamage(fDamage); } } else { @@ -2153,18 +2153,18 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa } } if(!pEntity->bIsStatic) { - float fDamageMultiplier = min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); + float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); CVector vecForceDir = vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / - max(fMagnitude, 0.01f)); - vecForceDir.z = max(vecForceDir.z, 0.0f); - if(pEntity == FindPlayerPed()) vecForceDir.z = min(vecForceDir.z, 1.0f); + Max(fMagnitude, 0.01f)); + vecForceDir.z = Max(vecForceDir.z, 0.0f); + if(pEntity == FindPlayerPed()) vecForceDir.z = Min(vecForceDir.z, 1.0f); pEntity->ApplyMoveForce(vecForceDir); if(!pEntity->bPedPhysics) { float fBoundRadius = pEntity->GetBoundRadius(); float fDistanceZ = position.z - pEntity->GetPosition().z; float fPointZ = fBoundRadius; - if(max(fDistanceZ, -fBoundRadius) < fBoundRadius) { + if(Max(fDistanceZ, -fBoundRadius) < fBoundRadius) { if(fDistanceZ <= -fBoundRadius) fPointZ = -fBoundRadius; else diff --git a/src/core/ZoneCull.cpp b/src/core/ZoneCull.cpp index d17a33d4..7a221f39 100644 --- a/src/core/ZoneCull.cpp +++ b/src/core/ZoneCull.cpp @@ -289,7 +289,7 @@ CCullZones::FindAttributesForCoors(CVector coors, int32 *wantedLevel) coors.z >= aAttributeZones[i].minz && coors.z <= aAttributeZones[i].maxz){ attribs |= aAttributeZones[i].attributes; if(wantedLevel) - *wantedLevel = max(*wantedLevel, aAttributeZones[i].wantedLevel); + *wantedLevel = Max(*wantedLevel, aAttributeZones[i].wantedLevel); } return attribs; } diff --git a/src/core/common.h b/src/core/common.h index 454b848a..46b4d03a 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -12,7 +12,7 @@ #include #ifdef WITHWINDOWS -#include +#include #endif #ifdef WITHD3D @@ -42,12 +42,8 @@ #undef near #endif -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif +#define Max(a,b) ((a) > (b) ? (a) : (b)) +#define Min(a,b) ((a) < (b) ? (a) : (b)) typedef uint8_t uint8; typedef int8_t int8; @@ -62,7 +58,7 @@ typedef int64_t int64; typedef uint16_t wchar; #ifndef nil -#define nil nullptr +#define nil NULL #endif #include "config.h" @@ -276,7 +272,7 @@ class CTweakFunc : public CTweakVar void (*m_pFunc)(); public: CTweakFunc(void (*pFunc)(), const char *strName, const char *strPath) : - m_pFunc(pFunc), m_pVarName(strName), m_pPath(strPath) + m_pPath(strPath), m_pVarName(strName), m_pFunc(pFunc) { CTweakVars::Add(this); } @@ -290,7 +286,7 @@ class CTweakBool : public CTweakVar bool *m_pBoolVar; public: CTweakBool(bool *pBool, const char *strName, const char *strPath) : - m_pBoolVar(pBool), m_pVarName(strName), m_pPath(strPath) + m_pPath(strPath), m_pVarName(strName), m_pBoolVar(pBool) { CTweakVars::Add(this); } @@ -306,9 +302,10 @@ class CTweakSwitch : public CTweakVar const char **m_aStr; void (*m_pFunc)(); public: - CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr, void (*pFunc)(), const char *strPath) : - m_pVarName(strName), m_pPath(strPath), - m_aStr(aStr), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax) + CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr, + void (*pFunc)(), const char *strPath) + : m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax), + m_aStr(aStr) { CTweakVars::Add(this); } @@ -316,22 +313,24 @@ public: void AddDBG(const char *path); }; -#define _TWEEKCLASS(name, type) \ -class name : public CTweakVar \ -{ \ -public: \ - const char *m_pPath, *m_pVarName; \ - type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \ - \ - name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, const char *strPath) : \ - m_pIntVar(pInt), m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep), \ - m_pVarName(strName), m_pPath(strPath) \ - { \ - CTweakVars::Add(this); \ - } \ - \ - void AddDBG(const char *path); \ -}; +#define _TWEEKCLASS(name, type) \ + class name : public CTweakVar \ + { \ + public: \ + const char *m_pPath, *m_pVarName; \ + type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \ + \ + name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, \ + const char *strPath) \ + : m_pPath(strPath), m_pVarName(strName), m_pIntVar(pInt), \ + m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep) \ + \ + { \ + CTweakVars::Add(this); \ + } \ + \ + void AddDBG(const char *path); \ + }; _TWEEKCLASS(CTweakInt8, int8); _TWEEKCLASS(CTweakUInt8, uint8); diff --git a/src/core/main.cpp b/src/core/main.cpp index d5d4065d..77daaa01 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -205,7 +205,7 @@ DoFade(void) CRGBA fadeColor; CRect rect; int fadeValue = CDraw::FadeValue; - float brightness = min(CMenuManager::m_PrefsBrightness, 256); + float brightness = Min(CMenuManager::m_PrefsBrightness, 256); if(brightness <= 50) brightness = 50; if(FrontEndMenuManager.m_bMenuActive) diff --git a/src/core/patcher.cpp b/src/core/patcher.cpp index 19ca5f07..58f19767 100644 --- a/src/core/patcher.cpp +++ b/src/core/patcher.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include StaticPatcher *StaticPatcher::ms_head; diff --git a/src/core/timebars.cpp b/src/core/timebars.cpp index 5c2dbe3a..6b841a5c 100644 --- a/src/core/timebars.cpp +++ b/src/core/timebars.cpp @@ -102,14 +102,14 @@ void tbDisplay() #ifndef FINAL // Timers output (my own implementation) for (uint32 i = 0; i < TimerBar.count; i++) { - MaxTimes[i] = max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime); + MaxTimes[i] = Max(MaxTimes[i], TimerBar.Timers[i].endTime - TimerBar.Timers[i].startTime); sprintf(temp, "%s: %.2f", &TimerBar.Timers[i].name[0], MaxTimes[i]); AsciiToUnicode(temp, wtemp); CFont::PrintString(RsGlobal.maximumWidth * (4.0f / DEFAULT_SCREEN_WIDTH), RsGlobal.maximumHeight * ((8.0f * (i + 2)) / DEFAULT_SCREEN_HEIGHT), wtemp); } #ifdef FRAMETIME - MaxFrameTime = max(MaxFrameTime, FrameEndTime - FrameInitTime); + MaxFrameTime = Max(MaxFrameTime, FrameEndTime - FrameInitTime); sprintf(temp, "Frame Time: %.2f", MaxFrameTime); AsciiToUnicode(temp, wtemp); -- cgit v1.2.3 From 959f84ff9566297701064e30b46fd292e7e840a1 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 21 Apr 2020 13:56:33 +0200 Subject: fixed extra directory issues --- src/core/Directory.cpp | 14 ++++++++++++++ src/core/Directory.h | 1 + src/core/Streaming.cpp | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp index 27539824..cc4d65d8 100644 --- a/src/core/Directory.cpp +++ b/src/core/Directory.cpp @@ -41,9 +41,23 @@ void CDirectory::AddItem(const DirectoryInfo &dirinfo) { assert(numEntries < maxEntries); +#ifdef FIX_BUGS + // don't add if already exists + uint32 offset, size; + if(FindItem(dirinfo.name, offset, size)) + return; +#endif entries[numEntries++] = dirinfo; } +void +CDirectory::AddItem(const DirectoryInfo &dirinfo, int32 imgId) +{ + DirectoryInfo di = dirinfo; + di.offset |= imgId<<24; + AddItem(di); +} + bool CDirectory::FindItem(const char *name, uint32 &offset, uint32 &size) { diff --git a/src/core/Directory.h b/src/core/Directory.h index 06e6bba4..0fef080f 100644 --- a/src/core/Directory.h +++ b/src/core/Directory.h @@ -18,5 +18,6 @@ public: void ReadDirFile(const char *filename); bool WriteDirFile(const char *filename); void AddItem(const DirectoryInfo &dirinfo); + void AddItem(const DirectoryInfo &dirinfo, int32 imgId); bool FindItem(const char *name, uint32 &offset, uint32 &size); }; diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 15fe60e2..8124d11c 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -369,8 +369,12 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) lastID = modelId; } }else{ - // BUG: doesn't remember which cdimage this was in +#ifdef FIX_BUGS + // remember which cdimage this came from + ms_pExtraObjectsDir->AddItem(direntry, n); +#else ms_pExtraObjectsDir->AddItem(direntry); +#endif lastID = -1; } }else if(!CGeneral::faststrcmp(dot+1, "TXD") || !CGeneral::faststrcmp(dot+1, "txd")){ -- cgit v1.2.3 From c80403a2e0aa337968d77f5d4bcc33cdc91eeac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Tue, 21 Apr 2020 13:28:06 +0300 Subject: Crossplatform work continues --- src/core/CdStream.cpp | 2 +- src/core/Game.cpp | 2 -- src/core/Timer.cpp | 2 +- src/core/re3.cpp | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index 1ab1c8b0..ea79fb9a 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -1,4 +1,4 @@ -#include +#define WITHWINDOWS #include "common.h" #include "CdStream.h" diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 6f3eee29..bfe6eee3 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -1,7 +1,5 @@ #pragma warning( push ) #pragma warning( disable : 4005) -#define DIRECTINPUT_VERSION 0x0800 -#include #pragma warning( pop ) #include "common.h" #include "win.h" diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index 8f8570d7..aca7c1dc 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -1,4 +1,4 @@ -#include +#define WITHWINDOWS #include "common.h" #include "DMAudio.h" diff --git a/src/core/re3.cpp b/src/core/re3.cpp index e5f42696..0c96b262 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,6 +1,6 @@ #include #include -#include +#define WITHWINDOWS #include "common.h" #include "patcher.h" #include "Renderer.h" -- cgit v1.2.3 From 75acd781909378ba0395b0c52acee464c8221e72 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Thu, 23 Apr 2020 11:24:03 +0300 Subject: ps2 particles, sampman oal started --- src/core/config.h | 5 +++++ src/core/re3.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index b5022b9f..c52a708d 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -193,6 +193,11 @@ enum Config { #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) //#define USE_TXD_CDIMAGE // generate and load textures from txd.img //#define USE_TEXTURE_POOL +//#define OPENAL + +// Particle +//#define PC_PARTICLE +//#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2 // Pad #define XINPUT diff --git a/src/core/re3.cpp b/src/core/re3.cpp index e5f42696..3c2bc31f 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -372,7 +372,6 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil); #ifdef TOGGLEABLE_BETA_FEATURES - DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil); DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, nil); DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", (int8*)&CPed::bMakePedsRunToPhonesToReportCrimes, nil); #endif -- cgit v1.2.3 From f03b4eec4c37eab75a5bd639279cfcc615105b01 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 23 Apr 2020 22:25:18 +0200 Subject: implemented skinned peds, no cutscene hands yet --- src/core/AnimViewer.cpp | 7 ++++++- src/core/Cam.cpp | 13 ++++++++----- src/core/Debug.cpp | 37 +++++++++++++++++++++++++++++++++++-- src/core/Debug.h | 11 +++++++++++ src/core/World.cpp | 5 +++++ src/core/common.h | 11 +++++++++++ src/core/config.h | 1 + src/core/main.cpp | 1 + 8 files changed, 78 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index 20e94bf4..cf3ec5bf 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -367,7 +367,12 @@ CAnimViewer::Update(void) } else { // Originally it was GetPad(1)->LeftShoulder2 if (pad->NewState.Triangle) { - CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->GetHitColModel(), RpClumpGetFrame(pTarget->GetClump())); +#ifdef PED_SKIN + if(IsClumpSkinned(pTarget->GetClump())) + ((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->AnimatePedColModelSkinned(pTarget->GetClump()); + else +#endif + CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->GetHitColModel(), RpClumpGetFrame(pTarget->GetClump())); AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString); CMessages::AddMessage(gUString, 100, 0); } diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index f0a60093..5cf1c8f3 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -2776,17 +2776,20 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, if(CamTargetEntity->IsPed()){ // static bool FailedTestTwelveFramesAgo = false; // unused - RwV3d HeadPos = vecHeadCamOffset; + CVector HeadPos = vecHeadCamOffset; CVector TargetCoors; - // needs fix for SKINNING - RwFrame *frm = ((CPed*)CamTargetEntity)->GetNodeFrame(PED_HEAD); + ((CPed*)CamTargetEntity)->TransformToNode(HeadPos, PED_HEAD); + // This is done on PC, but checking for the clump frame is not necessary apparently +/* + RwFrame *frm = ((CPed*)CamTargetEntity)->m_pFrames[PED_HEAD]->frame; while(frm){ RwV3dTransformPoints(&HeadPos, &HeadPos, 1, RwFrameGetMatrix(frm)); frm = RwFrameGetParent(frm); if(frm == RpClumpGetFrame(CamTargetEntity->GetClump())) frm = nil; } +*/ if(ResetStatics){ Beta = TargetOrientation; @@ -2813,13 +2816,13 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, m_vecBufferedPlayerBodyOffset.z = TheCamera.m_fGaitSwayBuffer * m_vecBufferedPlayerBodyOffset.z + (1.0f-TheCamera.m_fGaitSwayBuffer) * HeadPos.z; - HeadPos = (CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset).toRwV3d(); + HeadPos = (CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset); }else{ float HeadDelta = (HeadPos - InitialHeadPos).Magnitude2D(); CVector Fwd = CamTargetEntity->GetForward(); Fwd.z = 0.0f; Fwd.Normalise(); - HeadPos = (HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition()).toRwV3d(); + HeadPos = (HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition()); HeadPos.z += 0.59f; } Source = HeadPos; diff --git a/src/core/Debug.cpp b/src/core/Debug.cpp index 917c99ab..e794dcaf 100644 --- a/src/core/Debug.cpp +++ b/src/core/Debug.cpp @@ -1,5 +1,7 @@ #include "common.h" +#include "RwHelper.h" #include "Debug.h" +#include "Lines.h" #include "Font.h" #include "main.h" #include "Text.h" @@ -114,11 +116,14 @@ CDebug::DisplayScreenStrings() CFont::SetFontStyle(FONT_BANK); for(i = 0; i < ms_nScreenStrs; i++){ +/* AsciiToUnicode(ms_aScreenStrs[i].str, gUString); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(ms_aScreenStrs[i].x, ms_aScreenStrs[i].y, gUString); CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::PrintString(ms_aScreenStrs[i].x+1, ms_aScreenStrs[i].y+1, gUString); +*/ + ObrsPrintfString(ms_aScreenStrs[i].str, ms_aScreenStrs[i].x, ms_aScreenStrs[i].y); } CFont::DrawFonts(); @@ -131,7 +136,35 @@ CDebug::PrintAt(const char *str, int x, int y) if(ms_nScreenStrs >= MAX_SCREEN_STRS) return; strncpy(ms_aScreenStrs[ms_nScreenStrs].str, str, 256); - ms_aScreenStrs[ms_nScreenStrs].x = x*12; - ms_aScreenStrs[ms_nScreenStrs].y = y*22; + ms_aScreenStrs[ms_nScreenStrs].x = x;//*12; + ms_aScreenStrs[ms_nScreenStrs].y = y;//*22; ms_nScreenStrs++; } + +CDebug::Line CDebug::ms_aLines[MAX_DEBUG_LINES]; +int CDebug::ms_nLines; + +void +CDebug::AddLine(CVector p1, CVector p2, uint32 c1, uint32 c2) +{ + if(ms_nLines >= MAX_DEBUG_LINES) + return; + ms_aLines[ms_nLines].p1 = p1; + ms_aLines[ms_nLines].p2 = p2; + ms_aLines[ms_nLines].c1 = c1; + ms_aLines[ms_nLines].c2 = c2; + ms_nLines++; +} + +void +CDebug::DrawLines(void) +{ + int i; + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, nil); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); + for(i = 0; i < ms_nLines; i++){ + Line *l = &ms_aLines[i]; + CLines::RenderLineWithClipping(l->p1.x, l->p1.y, l->p1.z, l->p2.x, l->p2.y, l->p2.z, l->c1, l->c2); + } + ms_nLines = 0; +} diff --git a/src/core/Debug.h b/src/core/Debug.h index d169a0b4..4a25bf41 100644 --- a/src/core/Debug.h +++ b/src/core/Debug.h @@ -8,6 +8,7 @@ class CDebug MAX_STR_LEN = 80, MAX_SCREEN_STRS = 100, + MAX_DEBUG_LINES = 100, }; static int16 ms_nCurrentTextLine; @@ -21,6 +22,13 @@ class CDebug static ScreenStr ms_aScreenStrs[MAX_SCREEN_STRS]; static int ms_nScreenStrs; + struct Line { + CVector p1, p2; + uint32 c1, c2; + }; + static Line ms_aLines[MAX_DEBUG_LINES]; + static int ms_nLines; + public: static void DebugInitTextBuffer(); static void DebugDisplayTextBuffer(); @@ -29,6 +37,9 @@ public: // custom static void PrintAt(const char *str, int x, int y); static void DisplayScreenStrings(); + + static void AddLine(CVector p1, CVector p2, uint32 c1, uint32 c2); + static void DrawLines(void); }; extern bool gbDebugStuffInRelease; diff --git a/src/core/World.cpp b/src/core/World.cpp index 404b92c0..b2a01b80 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -339,6 +339,11 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP if(e->IsPed()) { if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD) { +#ifdef PED_SKIN + if(IsClumpSkinned(e->GetClump())) + colmodel = ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))->AnimatePedColModelSkinned(e->GetClump()); + else +#endif if(((CPed *)e)->UseGroundColModel()) colmodel = &CTempColModels::ms_colModelPedGroundHit; else diff --git a/src/core/common.h b/src/core/common.h index 46b4d03a..8b057efa 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -27,9 +27,15 @@ #ifdef LIBRW #define STREAMPOS(str) ((str)->tell()) #define STREAMFILE(str) (((rw::StreamFile*)(str))->file) +#define HIERNODEINFO(hier) ((hier)->nodeInfo) +#define HIERNODEID(hier, i) ((hier)->nodeInfo[i].id) +#define HANIMFRAMES(anim) ((anim)->keyframes) #else #define STREAMPOS(str) ((str)->Type.memory.position) #define STREAMFILE(str) ((str)->Type.file.fpFile) +#define HIERNODEINFO(hier) ((hier)->pNodeInfo) +#define HIERNODEID(hier, i) ((hier)->pNodeInfo[i].nodeID) +#define HANIMFRAMES(anim) ((anim)->pFrames) #endif #define rwVENDORID_ROCKSTAR 0x0253F2 @@ -63,6 +69,11 @@ typedef uint16_t wchar; #include "config.h" +#ifdef PED_SKIN +#include +#include +#endif + #define ALIGNPTR(p) (void*)((((uintptr)(void*)p) + sizeof(void*)-1) & ~(sizeof(void*)-1)) // PDP-10 like byte functions diff --git a/src/core/config.h b/src/core/config.h index c52a708d..84712af3 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -234,6 +234,7 @@ enum Config { #define CAMERA_PICKUP // Peds +#define PED_SKIN // support for skinned geometry on peds #define ANIMATE_PED_COL_MODEL #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle // #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward diff --git a/src/core/main.cpp b/src/core/main.cpp index 77daaa01..7013b10f 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -794,6 +794,7 @@ RenderDebugShit(void) if(gbShowCollisionLines) CRenderer::RenderCollisionLines(); ThePaths.DisplayPathData(); + CDebug::DrawLines(); #endif } -- cgit v1.2.3 From 5bb4e9992679c9e8767d4eb6de54da1892ec13c6 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 24 Apr 2020 13:27:02 +0200 Subject: implemented debugmenu --- src/core/AnimViewer.cpp | 2 +- src/core/Game.cpp | 2 +- src/core/debugmenu_public.h | 154 -------------------------------------------- src/core/main.cpp | 5 +- src/core/re3.cpp | 40 ++---------- 5 files changed, 8 insertions(+), 195 deletions(-) delete mode 100644 src/core/debugmenu_public.h (limited to 'src/core') diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index cf3ec5bf..36ea20b7 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -37,6 +37,7 @@ #include "Shadows.h" #include "Radar.h" #include "Hud.h" +#include "debugmenu.h" int CAnimViewer::animTxdSlot = 0; CEntity *CAnimViewer::pTarget = nil; @@ -208,7 +209,6 @@ PlayAnimation(RpClump *clump, AssocGroupId animGroup, AnimationId anim) animAssoc->SetRun(); } -extern void (*DebugMenuProcess)(void); void CAnimViewer::Update(void) { diff --git a/src/core/Game.cpp b/src/core/Game.cpp index bfe6eee3..f72d342f 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -84,6 +84,7 @@ #include "World.h" #include "ZoneCull.h" #include "Zones.h" +#include "debugmenu.h" @@ -618,7 +619,6 @@ void CGame::InitialiseWhenRestarting(void) DMAudio.ChangeMusicMode(MUSICMODE_GAME); } -extern void (*DebugMenuProcess)(void); void CGame::Process(void) { CPad::UpdatePads(); diff --git a/src/core/debugmenu_public.h b/src/core/debugmenu_public.h deleted file mode 100644 index 778e7afe..00000000 --- a/src/core/debugmenu_public.h +++ /dev/null @@ -1,154 +0,0 @@ - -extern "C" { - -typedef void (*TriggerFunc)(void); - -struct DebugMenuEntry; - -typedef DebugMenuEntry *(*DebugMenuAddInt8_TYPE)(const char *path, const char *name, int8_t *ptr, TriggerFunc triggerFunc, int8_t step, int8_t lowerBound, int8_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddInt16_TYPE)(const char *path, const char *name, int16_t *ptr, TriggerFunc triggerFunc, int16_t step, int16_t lowerBound, int16_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddInt32_TYPE)(const char *path, const char *name, int32_t *ptr, TriggerFunc triggerFunc, int32_t step, int32_t lowerBound, int32_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddInt64_TYPE)(const char *path, const char *name, int64_t *ptr, TriggerFunc triggerFunc, int64_t step, int64_t lowerBound, int64_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddUInt8_TYPE)(const char *path, const char *name, uint8_t *ptr, TriggerFunc triggerFunc, uint8_t step, uint8_t lowerBound, uint8_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddUInt16_TYPE)(const char *path, const char *name, uint16_t *ptr, TriggerFunc triggerFunc, uint16_t step, uint16_t lowerBound, uint16_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddUInt32_TYPE)(const char *path, const char *name, uint32_t *ptr, TriggerFunc triggerFunc, uint32_t step, uint32_t lowerBound, uint32_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddUInt64_TYPE)(const char *path, const char *name, uint64_t *ptr, TriggerFunc triggerFunc, uint64_t step, uint64_t lowerBound, uint64_t upperBound, const char **strings); -typedef DebugMenuEntry *(*DebugMenuAddFloat32_TYPE)(const char *path, const char *name, float *ptr, TriggerFunc triggerFunc, float step, float lowerBound, float upperBound); -typedef DebugMenuEntry *(*DebugMenuAddFloat64_TYPE)(const char *path, const char *name, double *ptr, TriggerFunc triggerFunc, double step, double lowerBound, double upperBound); -typedef DebugMenuEntry *(*DebugMenuAddCmd_TYPE)(const char *path, const char *name, TriggerFunc triggerFunc); -typedef void (*DebugMenuEntrySetWrap_TYPE)(DebugMenuEntry *e, bool wrap); -typedef void (*DebugMenuEntrySetStrings_TYPE)(DebugMenuEntry *e, const char **strings); -typedef void (*DebugMenuEntrySetAddress_TYPE)(DebugMenuEntry *e, void *addr); - -struct DebugMenuAPI -{ - bool isLoaded; - HMODULE module; - DebugMenuAddInt8_TYPE addint8; - DebugMenuAddInt16_TYPE addint16; - DebugMenuAddInt32_TYPE addint32; - DebugMenuAddInt64_TYPE addint64; - DebugMenuAddUInt8_TYPE adduint8; - DebugMenuAddUInt16_TYPE adduint16; - DebugMenuAddUInt32_TYPE adduint32; - DebugMenuAddUInt64_TYPE adduint64; - DebugMenuAddFloat32_TYPE addfloat32; - DebugMenuAddFloat64_TYPE addfloat64; - DebugMenuAddCmd_TYPE addcmd; - DebugMenuEntrySetWrap_TYPE setwrap; - DebugMenuEntrySetStrings_TYPE setstrings; - DebugMenuEntrySetAddress_TYPE setaddress; -}; -extern DebugMenuAPI gDebugMenuAPI; - -inline DebugMenuEntry *DebugMenuAddInt8(const char *path, const char *name, int8_t *ptr, TriggerFunc triggerFunc, int8_t step, int8_t lowerBound, int8_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint8(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddInt16(const char *path, const char *name, int16_t *ptr, TriggerFunc triggerFunc, int16_t step, int16_t lowerBound, int16_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint16(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddInt32(const char *path, const char *name, int32_t *ptr, TriggerFunc triggerFunc, int32_t step, int32_t lowerBound, int32_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint32(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddInt64(const char *path, const char *name, int64_t *ptr, TriggerFunc triggerFunc, int64_t step, int64_t lowerBound, int64_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint64(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddUInt8(const char *path, const char *name, uint8_t *ptr, TriggerFunc triggerFunc, uint8_t step, uint8_t lowerBound, uint8_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint8(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddUInt16(const char *path, const char *name, uint16_t *ptr, TriggerFunc triggerFunc, uint16_t step, uint16_t lowerBound, uint16_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint16(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddUInt32(const char *path, const char *name, uint32_t *ptr, TriggerFunc triggerFunc, uint32_t step, uint32_t lowerBound, uint32_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint32(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddUInt64(const char *path, const char *name, uint64_t *ptr, TriggerFunc triggerFunc, uint64_t step, uint64_t lowerBound, uint64_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint64(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddFloat32(const char *path, const char *name, float *ptr, TriggerFunc triggerFunc, float step, float lowerBound, float upperBound) -{ return gDebugMenuAPI.addfloat32(path, name, ptr, triggerFunc, step, lowerBound, upperBound); } -inline DebugMenuEntry *DebugMenuAddFloat64(const char *path, const char *name, double *ptr, TriggerFunc triggerFunc, double step, double lowerBound, double upperBound) -{ return gDebugMenuAPI.addfloat64(path, name, ptr, triggerFunc, step, lowerBound, upperBound); } -inline DebugMenuEntry *DebugMenuAddCmd(const char *path, const char *name, TriggerFunc triggerFunc) -{ return gDebugMenuAPI.addcmd(path, name, triggerFunc); } -inline void DebugMenuEntrySetWrap(DebugMenuEntry *e, bool wrap) -{ gDebugMenuAPI.setwrap(e, wrap); } -inline void DebugMenuEntrySetStrings(DebugMenuEntry *e, const char **strings) -{ gDebugMenuAPI.setstrings(e, strings); } -inline void DebugMenuEntrySetAddress(DebugMenuEntry *e, void *addr) -{ gDebugMenuAPI.setaddress(e, addr); } - -inline bool DebugMenuLoad(void) -{ - if(gDebugMenuAPI.isLoaded) - return true; - HMODULE mod = LoadLibraryA("debugmenu"); - if(mod == nil){ - char modulePath[MAX_PATH]; - HMODULE dllModule; - GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)&gDebugMenuAPI, &dllModule); - GetModuleFileNameA(dllModule, modulePath, MAX_PATH); - char *p = strchr(modulePath, '\\'); - if(p) p[1] = '\0'; - strcat(modulePath, "debugmenu"); - mod = LoadLibraryA(modulePath); - } - if(mod == nil) - return false; - gDebugMenuAPI.addint8 = (DebugMenuAddInt8_TYPE)GetProcAddress(mod, "DebugMenuAddInt8"); - gDebugMenuAPI.addint16 = (DebugMenuAddInt16_TYPE)GetProcAddress(mod, "DebugMenuAddInt16"); - gDebugMenuAPI.addint32 = (DebugMenuAddInt32_TYPE)GetProcAddress(mod, "DebugMenuAddInt32"); - gDebugMenuAPI.addint64 = (DebugMenuAddInt64_TYPE)GetProcAddress(mod, "DebugMenuAddInt64"); - gDebugMenuAPI.adduint8 = (DebugMenuAddUInt8_TYPE)GetProcAddress(mod, "DebugMenuAddUInt8"); - gDebugMenuAPI.adduint16 = (DebugMenuAddUInt16_TYPE)GetProcAddress(mod, "DebugMenuAddUInt16"); - gDebugMenuAPI.adduint32 = (DebugMenuAddUInt32_TYPE)GetProcAddress(mod, "DebugMenuAddUInt32"); - gDebugMenuAPI.adduint64 = (DebugMenuAddUInt64_TYPE)GetProcAddress(mod, "DebugMenuAddUInt64"); - gDebugMenuAPI.addfloat32 = (DebugMenuAddFloat32_TYPE)GetProcAddress(mod, "DebugMenuAddFloat32"); - gDebugMenuAPI.addfloat64 = (DebugMenuAddFloat64_TYPE)GetProcAddress(mod, "DebugMenuAddFloat64"); - gDebugMenuAPI.addcmd = (DebugMenuAddCmd_TYPE)GetProcAddress(mod, "DebugMenuAddCmd"); - gDebugMenuAPI.setwrap = (DebugMenuEntrySetWrap_TYPE)GetProcAddress(mod, "DebugMenuEntrySetWrap"); - gDebugMenuAPI.setstrings = (DebugMenuEntrySetStrings_TYPE)GetProcAddress(mod, "DebugMenuEntrySetStrings"); - gDebugMenuAPI.setaddress = (DebugMenuEntrySetAddress_TYPE)GetProcAddress(mod, "DebugMenuEntrySetAddress"); - gDebugMenuAPI.isLoaded = true; - gDebugMenuAPI.module = mod; - return true; -} - -} - -// Also overload them for simplicity - -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, int8_t *ptr, TriggerFunc triggerFunc, int8_t step, int8_t lowerBound, int8_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint8(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, int16_t *ptr, TriggerFunc triggerFunc, int16_t step, int16_t lowerBound, int16_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint16(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, int32_t *ptr, TriggerFunc triggerFunc, int32_t step, int32_t lowerBound, int32_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint32(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, int64_t *ptr, TriggerFunc triggerFunc, int64_t step, int64_t lowerBound, int64_t upperBound, const char **strings) -{ return gDebugMenuAPI.addint64(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, uint8_t *ptr, TriggerFunc triggerFunc, uint8_t step, uint8_t lowerBound, uint8_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint8(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, uint16_t *ptr, TriggerFunc triggerFunc, uint16_t step, uint16_t lowerBound, uint16_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint16(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, uint32_t *ptr, TriggerFunc triggerFunc, uint32_t step, uint32_t lowerBound, uint32_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint32(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, uint64_t *ptr, TriggerFunc triggerFunc, uint64_t step, uint64_t lowerBound, uint64_t upperBound, const char **strings) -{ return gDebugMenuAPI.adduint64(path, name, ptr, triggerFunc, step, lowerBound, upperBound, strings); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, float *ptr, TriggerFunc triggerFunc, float step, float lowerBound, float upperBound) -{ return gDebugMenuAPI.addfloat32(path, name, ptr, triggerFunc, step, lowerBound, upperBound); } -inline DebugMenuEntry *DebugMenuAddVar(const char *path, const char *name, double *ptr, TriggerFunc triggerFunc, double step, double lowerBound, double upperBound) -{ return gDebugMenuAPI.addfloat64(path, name, ptr, triggerFunc, step, lowerBound, upperBound); } - -inline DebugMenuEntry *DebugMenuAddVarBool32(const char *path, const char *name, int32_t *ptr, TriggerFunc triggerFunc) -{ - static const char *boolstr[] = { "Off", "On" }; - DebugMenuEntry *e = DebugMenuAddVar(path, name, ptr, triggerFunc, 1, 0, 1, boolstr); - DebugMenuEntrySetWrap(e, true); - return e; -} -inline DebugMenuEntry *DebugMenuAddVarBool16(const char *path, const char *name, int16_t *ptr, TriggerFunc triggerFunc) -{ - static const char *boolstr[] = { "Off", "On" }; - DebugMenuEntry *e = DebugMenuAddVar(path, name, ptr, triggerFunc, 1, 0, 1, boolstr); - DebugMenuEntrySetWrap(e, true); - return e; -} -inline DebugMenuEntry *DebugMenuAddVarBool8(const char *path, const char *name, int8_t *ptr, TriggerFunc triggerFunc) -{ - static const char *boolstr[] = { "Off", "On" }; - DebugMenuEntry *e = DebugMenuAddVar(path, name, ptr, triggerFunc, 1, 0, 1, boolstr); - DebugMenuEntrySetWrap(e, true); - return e; -} diff --git a/src/core/main.cpp b/src/core/main.cpp index 7013b10f..7c1f7938 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -59,6 +59,7 @@ #include "timebars.h" #include "GenericGameStorage.h" #include "SceneEdit.h" +#include "debugmenu.h" GlobalScene Scene; @@ -90,9 +91,7 @@ void GameInit(void); void SystemInit(void); void TheGame(void); -extern void (*DebugMenuProcess)(void); -extern void (*DebugMenuRender)(void); -void DebugMenuInit(void); +void DebugMenuInit(void) {} void DebugMenuPopulate(void); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 4cec5773..d4d2c208 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -17,7 +17,6 @@ #include "Heli.h" #include "Automobile.h" #include "Ped.h" -#include "debugmenu_public.h" #include "Particle.h" #include "Console.h" #include "Debug.h" @@ -26,6 +25,7 @@ #include "Pad.h" #include "PlayerPed.h" #include "Radar.h" +#include "debugmenu.h" #include @@ -33,8 +33,6 @@ extern "C" int vsprintf(char* const _Buffer, char const* const _Format, va_list _ArgList); #endif -DebugMenuAPI gDebugMenuAPI; - #ifdef USE_PS2_RAND unsigned __int64 myrand_seed = 1; @@ -62,24 +60,6 @@ mysrand(unsigned int seed) myrand_seed = seed; } -void (*DebugMenuProcess)(void); -void (*DebugMenuRender)(void); -static void stub(void) { } - -void -DebugMenuInit(void) -{ - if(DebugMenuLoad()){ - DebugMenuProcess = (void(*)(void))GetProcAddress(gDebugMenuAPI.module, "DebugMenuProcess"); - DebugMenuRender = (void(*)(void))GetProcAddress(gDebugMenuAPI.module, "DebugMenuRender"); - } - if(DebugMenuProcess == nil || DebugMenuRender == nil){ - DebugMenuProcess = stub; - DebugMenuRender = stub; - } - -} - void WeaponCheat(); void HealthCheat(); void TankCheat(); @@ -269,7 +249,7 @@ TWEAKSWITCH(CWeather::NewWeatherType, 0, 3, wt, NULL); void DebugMenuPopulate(void) { - if(DebugMenuLoad()){ + if(1){ static const char *weathers[] = { "Sunny", "Cloudy", "Rainy", "Foggy" }; @@ -284,7 +264,7 @@ DebugMenuPopulate(void) e = DebugMenuAddVar("Time & Weather", "New Weather", (int16*)&CWeather::NewWeatherType, nil, 1, 0, 3, weathers); DebugMenuEntrySetWrap(e, true); DebugMenuAddVar("Time & Weather", "Wind", (float*)&CWeather::Wind, nil, 0.1f, 0.0f, 1.0f); - DebugMenuAddVar("Time & Weather", "Time scale", (float*)0x8F2C20, nil, 0.1f, 0.0f, 10.0f); + DebugMenuAddVar("Time & Weather", "Time scale", (float*)&CTimer::GetTimeScale(), nil, 0.1f, 0.0f, 10.0f); DebugMenuAddCmd("Cheats", "Weapons", WeaponCheat); DebugMenuAddCmd("Cheats", "Money", MoneyCheat); @@ -357,7 +337,7 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Debug", "Catalina Fly By", CHeli::StartCatalinaFlyBy); DebugMenuAddCmd("Debug", "Catalina Take Off", CHeli::CatalinaTakeOff); DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway); - DebugMenuAddVarBool8("Debug", "Script Heli On", (int8*)0x95CD43, nil); + DebugMenuAddVarBool8("Debug", "Script Heli On", (int8*)&CHeli::ScriptHeliOn, nil); DebugMenuAddVarBool8("Debug", "Show Ped Paths", (int8*)&gbShowPedPaths, nil); DebugMenuAddVarBool8("Debug", "Show Car Paths", (int8*)&gbShowCarPaths, nil); @@ -397,18 +377,6 @@ DebugMenuPopulate(void) } } -/* -int (*RsEventHandler_orig)(int a, int b); -int -delayedPatches10(int a, int b) -{ - DebugMenuInit(); - DebugMenuPopulate(); - - return RsEventHandler_orig(a, b); -} -*/ - const int re3_buffsize = 1024; static char re3_buff[re3_buffsize]; -- cgit v1.2.3 From ac19de45b88123b2284ecc3ab44cedcaa7ca496d Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 25 Apr 2020 00:40:14 +0200 Subject: few fixes --- src/core/Streaming.cpp | 3 ++- src/core/main.cpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 8124d11c..a76e9038 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -754,7 +754,8 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag }else RemoveModel(modelId); - ms_pExtraObjectsDir->FindItem(modelName, pos, size); + bool found = ms_pExtraObjectsDir->FindItem(modelName, pos, size); + assert(found); mi->ClearTexDictionary(); if(CTxdStore::FindTxdSlot(modelName) == -1) mi->SetTexDictionary("generic"); diff --git a/src/core/main.cpp b/src/core/main.cpp index 7c1f7938..ec37fa28 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -91,7 +91,6 @@ void GameInit(void); void SystemInit(void); void TheGame(void); -void DebugMenuInit(void) {} void DebugMenuPopulate(void); @@ -344,6 +343,8 @@ static void Terminate3D(void) { CGame::ShutdownRenderWare(); + + DebugMenuShutdown(); RsRwTerminate(); @@ -794,6 +795,7 @@ RenderDebugShit(void) CRenderer::RenderCollisionLines(); ThePaths.DisplayPathData(); CDebug::DrawLines(); + DefinedState(); #endif } -- cgit v1.2.3 From f15a5ac0f9e5b9ae4144f58f95f74c498ea9a7f3 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 25 Apr 2020 12:16:50 +0200 Subject: using librw GS alpha test emulation --- src/core/re3.cpp | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'src/core') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index d4d2c208..2a9cbc77 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -322,8 +322,12 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); }); DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); }); - DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil); - DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, nil); +#ifdef LIBRW + DebugMenuAddVarBool8("Render", "PS2 Alpha test Emu", &gPS2alphaTest, nil); +#endif + + DebugMenuAddVarBool8("Debug", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil); + DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil); #ifdef MENU_MAP DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); #endif @@ -333,27 +337,27 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Debug", "Toggle Comedy Controls", ToggleComedy); DebugMenuAddCmd("Debug", "Place Car on Road", PlaceOnRoad); - DebugMenuAddVarBool8("Debug", "Catalina Heli On", (int8*)&CHeli::CatalinaHeliOn, nil); + DebugMenuAddVarBool8("Debug", "Catalina Heli On", &CHeli::CatalinaHeliOn, nil); DebugMenuAddCmd("Debug", "Catalina Fly By", CHeli::StartCatalinaFlyBy); DebugMenuAddCmd("Debug", "Catalina Take Off", CHeli::CatalinaTakeOff); DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway); - DebugMenuAddVarBool8("Debug", "Script Heli On", (int8*)&CHeli::ScriptHeliOn, nil); - - DebugMenuAddVarBool8("Debug", "Show Ped Paths", (int8*)&gbShowPedPaths, nil); - DebugMenuAddVarBool8("Debug", "Show Car Paths", (int8*)&gbShowCarPaths, nil); - DebugMenuAddVarBool8("Debug", "Show Car Path Links", (int8*)&gbShowCarPathsLinks, nil); - DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", (int8*)&gbShowPedRoadGroups, nil); - DebugMenuAddVarBool8("Debug", "Show Car Road Groups", (int8*)&gbShowCarRoadGroups, nil); - DebugMenuAddVarBool8("Debug", "Show Collision Lines", (int8*)&gbShowCollisionLines, nil); - DebugMenuAddVarBool8("Debug", "Show Collision Polys", (int8*)&gbShowCollisionPolys, nil); - DebugMenuAddVarBool8("Debug", "Don't render Buildings", (int8*)&gbDontRenderBuildings, nil); - DebugMenuAddVarBool8("Debug", "Don't render Big Buildings", (int8*)&gbDontRenderBigBuildings, nil); - DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil); - DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); - DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil); + DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil); + + DebugMenuAddVarBool8("Debug", "Show Ped Paths", &gbShowPedPaths, nil); + DebugMenuAddVarBool8("Debug", "Show Car Paths", &gbShowCarPaths, nil); + DebugMenuAddVarBool8("Debug", "Show Car Path Links", &gbShowCarPathsLinks, nil); + DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", &gbShowPedRoadGroups, nil); + DebugMenuAddVarBool8("Debug", "Show Car Road Groups", &gbShowCarRoadGroups, nil); + DebugMenuAddVarBool8("Debug", "Show Collision Lines", &gbShowCollisionLines, nil); + DebugMenuAddVarBool8("Debug", "Show Collision Polys", &gbShowCollisionPolys, nil); + DebugMenuAddVarBool8("Debug", "Don't render Buildings", &gbDontRenderBuildings, nil); + DebugMenuAddVarBool8("Debug", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil); + DebugMenuAddVarBool8("Debug", "Don't render Peds", &gbDontRenderPeds, nil); + DebugMenuAddVarBool8("Debug", "Don't render Vehicles", &gbDontRenderVehicles, nil); + DebugMenuAddVarBool8("Debug", "Don't render Objects", &gbDontRenderObjects, nil); #ifdef TOGGLEABLE_BETA_FEATURES - DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, nil); - DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", (int8*)&CPed::bMakePedsRunToPhonesToReportCrimes, nil); + DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); + DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", &CPed::bMakePedsRunToPhonesToReportCrimes, nil); #endif DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); @@ -361,11 +365,11 @@ DebugMenuPopulate(void) extern bool PrintDebugCode; extern int16 DebugCamMode; - DebugMenuAddVarBool8("Cam", "Use mouse Cam", (int8*)&CCamera::m_bUseMouse3rdPerson, nil); + DebugMenuAddVarBool8("Cam", "Use mouse Cam", &CCamera::m_bUseMouse3rdPerson, nil); #ifdef FREE_CAM - DebugMenuAddVarBool8("Cam", "Free Cam", (int8*)&CCamera::bFreeCam, nil); + DebugMenuAddVarBool8("Cam", "Free Cam", &CCamera::bFreeCam, nil); #endif - DebugMenuAddVarBool8("Cam", "Print Debug Code", (int8*)&PrintDebugCode, nil); + DebugMenuAddVarBool8("Cam", "Print Debug Code", &PrintDebugCode, nil); DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil); DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; }); DebugMenuAddCmd("Cam", "Follow Ped With Bind", []() { DebugCamMode = CCam::MODE_FOLLOW_PED_WITH_BIND; }); -- cgit v1.2.3 From 6c1a1f7cd20a2674f33b5318e6e07a3a28d016f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 26 Apr 2020 13:25:03 +0300 Subject: Initial GLFW support --- src/core/ControllerConfig.cpp | 98 ++++++++++++++++++++++++++++++++++++++++--- src/core/ControllerConfig.h | 17 ++++++-- src/core/Frontend.cpp | 24 ++++++++--- src/core/Game.cpp | 2 +- src/core/Pad.cpp | 58 ++++++++++++++++++++++++- src/core/common.h | 4 +- src/core/config.h | 2 +- src/core/patcher.cpp | 3 +- 8 files changed, 187 insertions(+), 21 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index a2382c12..f55568be 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -1,7 +1,10 @@ +#if defined RW_D3D9 || defined RWLIBS #define DIRECTINPUT_VERSION 0x0800 #include -#include "common.h" +#endif +#include "common.h" +#include "crossplatform.h" #include "ControllerConfig.h" #include "Pad.h" #include "FileMgr.h" @@ -15,7 +18,6 @@ #include "World.h" #include "ModelIndices.h" #include "Camera.h" -#include "win.h" #include "GenericGameStorage.h" CControllerConfigManager ControlsManager; @@ -41,14 +43,72 @@ void CControllerConfigManager::MakeControllerActionsBlank() } } +#ifdef RW_GL3 +int MapIdToButtonId(int mapId) { + switch (mapId) { + case GLFW_GAMEPAD_BUTTON_A: // Cross + return 2; + case GLFW_GAMEPAD_BUTTON_B: // Circle + return 1; + case GLFW_GAMEPAD_BUTTON_X: // Square + return 3; + case GLFW_GAMEPAD_BUTTON_Y: // Triangle + return 4; + case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER: + return 7; + case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER: + return 8; + case GLFW_GAMEPAD_BUTTON_BACK: + return 9; + case GLFW_GAMEPAD_BUTTON_START: + return 12; + case GLFW_GAMEPAD_BUTTON_LEFT_THUMB: + return 10; + case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB: + return 11; + case GLFW_GAMEPAD_BUTTON_DPAD_UP: + return 13; + case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT: + return 14; + case GLFW_GAMEPAD_BUTTON_DPAD_DOWN: + return 15; + case GLFW_GAMEPAD_BUTTON_DPAD_LEFT: + return 16; + // GLFW sends those as axes, so I added them here manually. + case 15: // Left trigger + return 5; + case 16: // Right trigger + return 6; + default: + return 0; + } +} +#endif + int32 CControllerConfigManager::GetJoyButtonJustDown() { #ifdef __DINPUT_INCLUDED__ +#ifdef FIX_BUGS + for (int32 i = 0; i < MAX_BUTTONS; i++) +#else for (int32 i = 0; i < JOY_BUTTONS; i++) +#endif { if (m_NewState.rgbButtons[i] & 0x80 && !(m_OldState.rgbButtons[i] & 0x80)) return i + 1; } +#elif defined RW_GL3 + if (m_NewState.isGamepad) { + for (int32 i = 0; i < MAX_BUTTONS; i++) { + if (m_NewState.mappedButtons[i] && !(m_OldState.mappedButtons[i])) + return MapIdToButtonId(i); + } + } else { + for (int32 i = 0; i < Min(m_NewState.numButtons, MAX_BUTTONS); i++) { + if (m_NewState.buttons[i] && !(m_OldState.buttons[i])) + return i + 1; + } + } #endif return 0; } @@ -249,8 +309,13 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) if (buttons > 16) btn = 16; + // Now we use SDL Game Controller DB +#if defined RW_D3D9 || defined RWLIBS if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 && AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190) +#else + if (0) +#endif { //GIC USB Joystick, PS2 Gamepad ? @@ -445,8 +510,13 @@ void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown(int32 button, i break; } - if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 + // Now we use SDL Game Controller DB +#if defined RW_D3D9 || defined RWLIBS + if (AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 && AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190) +#else + if (0) +#endif { //GIC USB Joystick, PS2 Gamepad ? @@ -872,8 +942,13 @@ void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonUp(int32 button, int break; } - if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 + // Now we use SDL Game Controller DB +#if defined RW_D3D9 || defined RWLIBS + if (AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 && AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190) +#else + if (0) +#endif { //GIC USB Joystick, PS2 Gamepad ? @@ -1809,7 +1884,7 @@ wchar *CControllerConfigManager::GetControllerSettingTextKeyBoard(e_ControllerAc static wchar ActionText[50]; static wchar NewStringWithNumber[30]; - for (int32 i = 0; i < ARRAYSIZE(ActionText); i++) + for (int32 i = 0; i < ARRAY_SIZE(ActionText); i++) ActionText[i] = '\0'; if (GetControllerKeyAssociatedWithAction(action, type) != rsNULL) @@ -2266,6 +2341,19 @@ void CControllerConfigManager::UpdateJoyButtonState(int32 padnumber) else m_aButtonStates[i] = false; } +#elif defined RW_GL3 + if (m_NewState.isGamepad) { + for (int32 i = 0; i < MAX_BUTTONS; i++) { + if (i == GLFW_GAMEPAD_BUTTON_GUIDE) + continue; + + m_aButtonStates[MapIdToButtonId(i)-1] = m_NewState.mappedButtons[i]; + } + } else { + for (int32 i = 0; i < Min(m_NewState.numButtons, MAX_BUTTONS); i++) { + m_aButtonStates[i] = m_NewState.buttons[i]; + } + } #endif } diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 82174343..76f9882b 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -96,6 +96,16 @@ class CControllerState; #define ACTIONNAME_LENGTH 40 +#ifdef RW_GL3 +struct GlfwJoyState { + int8 id; + bool isGamepad; + uint8 numButtons; + uint8* buttons; + bool mappedButtons[17]; +}; +#endif + class CControllerConfigManager { public: @@ -115,8 +125,9 @@ public: #ifdef __DINPUT_INCLUDED__ DIJOYSTATE2 m_OldState; DIJOYSTATE2 m_NewState; -#else - uint32 ___padd[0x110 / 4 * 2]; +#elif defined RW_GL3 + GlfwJoyState m_OldState; + GlfwJoyState m_NewState; #endif wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH]; bool m_aButtonStates[MAX_BUTTONS]; @@ -193,6 +204,6 @@ public: void ResetSettingOrder (e_ControllerAction action); }; -VALIDATE_SIZE(CControllerConfigManager, 0x143C); +//VALIDATE_SIZE(CControllerConfigManager, 0x143C); extern CControllerConfigManager ControlsManager; \ No newline at end of file diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index c7e7d26e..cc076057 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1,8 +1,11 @@ +#if defined RW_D3D9 || defined RWLIBS #define DIRECTINPUT_VERSION 0x0800 #include -#include "common.h" +#endif -#include "win.h" +#define WITHWINDOWS +#include "common.h" +#include "crossplatform.h" #include "Frontend.h" #include "Font.h" #include "Pad.h" @@ -430,13 +433,16 @@ CMenuManager::BuildStatLine(char *text, void *stat, bool itsFloat, void *stat2) void CMenuManager::CentreMousePointer() { - tagPOINT Point; - if (SCREEN_WIDTH * 0.5f != 0.0f && 0.0f != SCREEN_HEIGHT * 0.5f) { +#if defined RW_D3D9 || defined RWLIBS + tagPOINT Point; Point.x = SCREEN_WIDTH / 2; Point.y = SCREEN_HEIGHT / 2; ClientToScreen(PSGLOBAL(window), &Point); SetCursorPos(Point.x, Point.y); +#elif defined RW_GL3 + glfwSetCursorPos(PSGLOBAL(window), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); +#endif PSGLOBAL(lastMousePos.x) = SCREEN_WIDTH / 2; PSGLOBAL(lastMousePos.y) = SCREEN_HEIGHT / 2; @@ -4474,12 +4480,20 @@ CMenuManager::ProcessButtonPresses(void) ControlsManager.MakeControllerActionsBlank(); ControlsManager.InitDefaultControlConfiguration(); ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp()); - if (AllValidWinJoys.m_aJoys[0].m_bInitialised) { +#if !defined RW_GL3 + if (AllValidWinJoys.m_aJoys[JOYSTICK1].m_bInitialised) { DIDEVCAPS devCaps; devCaps.dwSize = sizeof(DIDEVCAPS); PSGLOBAL(joy1)->GetCapabilities(&devCaps); ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons); } +#else + if (PSGLOBAL(joy1id) != -1 && glfwJoystickPresent(PSGLOBAL(joy1id))) { + int count; + glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); + ControlsManager.InitDefaultControlConfigJoyPad(count); + } +#endif m_ControlMethod = CONTROL_STANDARD; MousePointerStateHelper.bInvertVertically = false; TheCamera.m_fMouseAccelHorzntl = 0.0025f; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index f72d342f..8633d222 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -2,7 +2,7 @@ #pragma warning( disable : 4005) #pragma warning( pop ) #include "common.h" -#include "win.h" +#include "crossplatform.h" #include "Game.h" #include "main.h" diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 8a3fc7cb..84bb1526 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -1,10 +1,13 @@ #pragma warning( push ) #pragma warning( disable : 4005) +#if defined RW_D3D9 || defined RWLIBS #define DIRECTINPUT_VERSION 0x0800 #include +#endif #pragma warning( pop ) #include "common.h" +#include "crossplatform.h" #ifdef XINPUT #include #pragma comment( lib, "Xinput9_1_0.lib" ) @@ -29,7 +32,6 @@ #include "Record.h" #include "Replay.h" #include "Weather.h" -#include "win.h" #include "Streaming.h" #include "PathFind.h" #include "Wanted.h" @@ -423,6 +425,7 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() { CMouseControllerState state; +#if defined RW_D3D9 || defined RWLIBS if ( PSGLOBAL(mouse) == nil ) _InputInitialiseMouse(); @@ -432,7 +435,6 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() devCaps.dwSize = sizeof(DIDEVCAPS); PSGLOBAL(mouse)->GetCapabilities(&devCaps); - switch ( devCaps.dwButtons ) { case 3: @@ -456,6 +458,19 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() state.WHEELUP = true; } } +#else + // It seems there is no way to get number of buttons on mouse, so assign all buttons if we have mouse. + double xpos = 1.0f, ypos; + glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos); + + if (xpos != NULL) { + state.MMB = true; + state.RMB = true; + state.LMB = true; + state.WHEELDN = true; + state.WHEELUP = true; + } +#endif return state; } @@ -464,6 +479,7 @@ void CPad::UpdateMouse() { if ( IsForegroundApp() ) { +#if defined RW_D3D9 || defined RWLIBS if ( PSGLOBAL(mouse) == nil ) _InputInitialiseMouse(); @@ -500,6 +516,44 @@ void CPad::UpdateMouse() OldMouseControllerState = NewMouseControllerState; NewMouseControllerState = PCTempMouseControllerState; } +#else + double xpos = 1.0f, ypos; + glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos); + if (xpos == NULL) + return; + + int32 signX = 1; + int32 signy = 1; + + if (!FrontEndMenuManager.m_bMenuActive) + { + if (MousePointerStateHelper.bInvertVertically) + signy = -1; + if (MousePointerStateHelper.bInvertHorizontally) + signX = -1; + } + + PCTempMouseControllerState.Clear(); + + PCTempMouseControllerState.x = (float)(signX * (xpos - PSGLOBAL(lastMousePos.x))); + PCTempMouseControllerState.y = (float)(signy * (ypos - PSGLOBAL(lastMousePos.y))); + PCTempMouseControllerState.LMB = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_LEFT); + PCTempMouseControllerState.RMB = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_RIGHT); + PCTempMouseControllerState.MMB = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_MIDDLE); + PCTempMouseControllerState.MXB1 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_4); + PCTempMouseControllerState.MXB2 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_5); + + PSGLOBAL(lastMousePos.x) = xpos; + PSGLOBAL(lastMousePos.y) = ypos; + + if (PSGLOBAL(mouseWheel) > 0) + PCTempMouseControllerState.WHEELUP = 1; + else if (PSGLOBAL(mouseWheel) < 0) + PCTempMouseControllerState.WHEELDN = 1; + + OldMouseControllerState = NewMouseControllerState; + NewMouseControllerState = PCTempMouseControllerState; +#endif } } diff --git a/src/core/common.h b/src/core/common.h index 8b057efa..2cc3d98c 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -11,11 +11,11 @@ #include #include -#ifdef WITHWINDOWS +#if defined _WIN32 && defined WITHWINDOWS #include #endif -#ifdef WITHD3D +#if defined _WIN32 && defined WITHD3D #include #include #endif diff --git a/src/core/config.h b/src/core/config.h index 84712af3..80e2ff19 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -200,7 +200,7 @@ enum Config { //#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2 // Pad -#define XINPUT +// #define XINPUT #define KANGAROO_CHEAT #define REGISTER_START_BUTTON diff --git a/src/core/patcher.cpp b/src/core/patcher.cpp index 58f19767..e5242e9d 100644 --- a/src/core/patcher.cpp +++ b/src/core/patcher.cpp @@ -1,11 +1,10 @@ +#define WITHWINDOWS #include "common.h" #include "patcher.h" #include #include -#include - StaticPatcher *StaticPatcher::ms_head; StaticPatcher::StaticPatcher(Patcher func) -- cgit v1.2.3 From 1a44bcccd5a30306456e6abb36a9a754cee3c7f2 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 26 Apr 2020 14:18:34 +0300 Subject: A few fixes --- src/core/ControllerConfig.h | 18 +++++++++++++----- src/core/config.h | 4 +++- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 76f9882b..f117c047 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -122,12 +122,18 @@ public: }; bool m_bFirstCapture; -#ifdef __DINPUT_INCLUDED__ - DIJOYSTATE2 m_OldState; - DIJOYSTATE2 m_NewState; -#elif defined RW_GL3 +#if defined RW_GL3 GlfwJoyState m_OldState; GlfwJoyState m_NewState; +#else + #ifdef __DINPUT_INCLUDED__ + DIJOYSTATE2 m_OldState; + DIJOYSTATE2 m_NewState; + #else + // this is here to fix the size of a struct + // TODO: find a better was a remove this + uint32 ___padd[0x110 / 4 * 2]; + #endif #endif wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH]; bool m_aButtonStates[MAX_BUTTONS]; @@ -204,6 +210,8 @@ public: void ResetSettingOrder (e_ControllerAction action); }; -//VALIDATE_SIZE(CControllerConfigManager, 0x143C); +#ifndef RW_GL3 +VALIDATE_SIZE(CControllerConfigManager, 0x143C); +#endif extern CControllerConfigManager ControlsManager; \ No newline at end of file diff --git a/src/core/config.h b/src/core/config.h index 80e2ff19..2cf8ec88 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -200,7 +200,9 @@ enum Config { //#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2 // Pad -// #define XINPUT +#ifndef RW_GL3 +#define XINPUT +#endif #define KANGAROO_CHEAT #define REGISTER_START_BUTTON -- cgit v1.2.3 From b7ee3792df72826b351a6fac86d7aad9caeea632 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 26 Apr 2020 20:11:19 +0300 Subject: Remove struct workaround in CControllerConfigManager --- src/core/ControllerConfig.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index f117c047..7d0e1073 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -1,5 +1,9 @@ #pragma once +#if defined RW_D3D9 || defined RWLIBS +#define DIRECTINPUT_VERSION 0x0800 +#include +#endif // based on x-gtasa @@ -126,14 +130,8 @@ public: GlfwJoyState m_OldState; GlfwJoyState m_NewState; #else - #ifdef __DINPUT_INCLUDED__ - DIJOYSTATE2 m_OldState; - DIJOYSTATE2 m_NewState; - #else - // this is here to fix the size of a struct - // TODO: find a better was a remove this - uint32 ___padd[0x110 / 4 * 2]; - #endif + DIJOYSTATE2 m_OldState; + DIJOYSTATE2 m_NewState; #endif wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH]; bool m_aButtonStates[MAX_BUTTONS]; -- cgit v1.2.3 From 4dc2f307910c6d5dcf3c910b3da2e2d943ac1003 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 26 Apr 2020 21:58:12 +0300 Subject: Remove little hack --- src/core/common.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/core') diff --git a/src/core/common.h b/src/core/common.h index 2cc3d98c..955225cc 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -88,13 +88,6 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) return w>>p & (1<