From 0c34fb1bb2239b1433719bb410b71e0c28840c85 Mon Sep 17 00:00:00 2001 From: _AG Date: Sun, 7 Jul 2019 15:26:55 +0200 Subject: blah --- src/core/Stats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/Stats.h b/src/core/Stats.h index a5670020..30058a59 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -5,7 +5,7 @@ class CStats public: static int32 &DaysPassed; static int32 &HeadShots; - static bool& CommercialPassed; + static bool& CommercialPassed; static int32 &NumberKillFrenziesPassed; static int32 &PeopleKilledByOthers; -- cgit v1.2.3 From ee0494b2d86aef799177cc0b80383a29ceee441b Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 7 Jul 2019 19:00:02 +0300 Subject: IntoTheScripts! --- src/core/config.h | 1 + src/core/re3.cpp | 23 +---------------------- 2 files changed, 2 insertions(+), 22 deletions(-) (limited to 'src/core') diff --git a/src/core/config.h b/src/core/config.h index 8cb02190..c3b66ff7 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -114,3 +114,4 @@ enum Config { #define FIX_BUGS // fix bugs in the game, TODO: use this more #define KANGAROO_CHEAT #define ASPECT_RATIO_SCALE +#define USE_DEBUG_SCRIPT_LOADER \ No newline at end of file diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 9dc39d46..d6e81214 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -57,27 +57,6 @@ mysrand(unsigned int seed) myrand_seed = seed; } -int (*open_script_orig)(const char *path, const char *mode); -int -open_script(const char *path, const char *mode) -{ - static int scriptToLoad = 1; - - if(GetAsyncKeyState('G') & 0x8000) - scriptToLoad = 0; - if(GetAsyncKeyState('R') & 0x8000) - scriptToLoad = 1; - if(GetAsyncKeyState('D') & 0x8000) - scriptToLoad = 2; - - switch(scriptToLoad){ - case 0: return open_script_orig(path, mode); - case 1: return open_script_orig("main_freeroam.scm", mode); - case 2: return open_script_orig("main_d.scm", mode); - } - return open_script_orig(path, mode); -} - int gDbgSurf; void (*DebugMenuProcess)(void); @@ -356,7 +335,7 @@ patch() Patch(0x5382BF, 0x0EEB); InjectHook(0x5382EC, HeadlightsFix, PATCH_JUMP); - InterceptCall(&open_script_orig, open_script, 0x438869); +// InterceptCall(&open_script_orig, open_script, 0x438869); // InterceptCall(&RsEventHandler_orig, delayedPatches10, 0x58275E); } -- cgit v1.2.3 From 12af85ca3d29e155f40323ad07a77f96a4aececf Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 08:46:42 +0200 Subject: cleaned up patching of virtual functions; started CAutomobile --- src/core/Instance.cpp | 13 +++++++++++++ src/core/Instance.h | 10 ++++++++++ src/core/Placeable.cpp | 12 ++++++++++-- src/core/Placeable.h | 3 --- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 src/core/Instance.cpp create mode 100644 src/core/Instance.h (limited to 'src/core') diff --git a/src/core/Instance.cpp b/src/core/Instance.cpp new file mode 100644 index 00000000..5426605f --- /dev/null +++ b/src/core/Instance.cpp @@ -0,0 +1,13 @@ +#include "common.h" +#include "patcher.h" +#include "Instance.h" + +class CInstance_ : public CInstance +{ +public: + void dtor() { CInstance::~CInstance(); } +}; + +STARTPATCHES + InjectHook(0x50BE90, &CInstance_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/core/Instance.h b/src/core/Instance.h new file mode 100644 index 00000000..1038c005 --- /dev/null +++ b/src/core/Instance.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Placeable.h" + +// unused + +class CInstance : CPlaceable +{ +public: +}; diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp index b4b2a37b..c1fe705e 100644 --- a/src/core/Placeable.cpp +++ b/src/core/Placeable.cpp @@ -63,9 +63,17 @@ CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z1 <= GetPosition().z && GetPosition().z <= z2; } +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(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); diff --git a/src/core/Placeable.h b/src/core/Placeable.h index 868ca9e7..bd1d50ab 100644 --- a/src/core/Placeable.h +++ b/src/core/Placeable.h @@ -19,8 +19,5 @@ public: void SetHeading(float angle); bool IsWithinArea(float x1, float y1, float x2, float y2); bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2); - - CPlaceable *ctor(void) { return ::new (this) CPlaceable(); } - void dtor(void) { this->CPlaceable::~CPlaceable(); } }; static_assert(sizeof(CPlaceable) == 0x4C, "CPlaceable: error"); -- cgit v1.2.3 From edf5ac2626ce17b74037281aa3c9730902b4b1d4 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 17:07:34 +0200 Subject: little changes; one more function of CAutomobile --- src/core/Placeable.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Placeable.h b/src/core/Placeable.h index bd1d50ab..1dfece69 100644 --- a/src/core/Placeable.h +++ b/src/core/Placeable.h @@ -10,10 +10,10 @@ public: CPlaceable(void); virtual ~CPlaceable(void); - CVector &GetPosition(void) { return *m_matrix.GetPosition(); } - CVector &GetRight(void) { return *m_matrix.GetRight(); } - CVector &GetForward(void) { return *m_matrix.GetForward(); } - CVector &GetUp(void) { return *m_matrix.GetUp(); } + CVector &GetPosition(void) { return m_matrix.GetPosition(); } + CVector &GetRight(void) { return m_matrix.GetRight(); } + CVector &GetForward(void) { return m_matrix.GetForward(); } + CVector &GetUp(void) { return m_matrix.GetUp(); } CMatrix &GetMatrix(void) { return m_matrix; } void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); } void SetHeading(float angle); -- cgit v1.2.3 From 2ae112fdf6b90bb4435dba34bcc2a23604e1e158 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 21:37:47 +0200 Subject: more CAutomobile --- src/core/Frontend.cpp | 8 ++++---- src/core/Placeable.h | 5 +++++ src/core/config.h | 2 ++ src/core/re3.cpp | 10 ++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index fdb2420b..2fa9d8ea 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -2261,7 +2261,7 @@ bool GetPadMoveUp() return (CPad::GetPad(0)->NewState.DPadUp && !CPad::GetPad(0)->OldState.DPadUp) || (CPad::GetPad(0)->NewKeyState.UP && !CPad::GetPad(0)->OldKeyState.UP) || - (CPad::GetPad(0)->NewState.LeftStickY < 0 && !CPad::GetPad(0)->OldState.LeftStickY < 0); + (CPad::GetPad(0)->NewState.LeftStickY < 0 && !(CPad::GetPad(0)->OldState.LeftStickY < 0)); } bool GetPadMoveDown() @@ -2269,7 +2269,7 @@ bool GetPadMoveDown() return (CPad::GetPad(0)->NewState.DPadDown && !CPad::GetPad(0)->OldState.DPadDown) || (CPad::GetPad(0)->NewKeyState.DOWN && !CPad::GetPad(0)->OldKeyState.DOWN) || - (CPad::GetPad(0)->NewState.LeftStickY > 0 && !CPad::GetPad(0)->OldState.LeftStickY > 0); + (CPad::GetPad(0)->NewState.LeftStickY > 0 && !(CPad::GetPad(0)->OldState.LeftStickY > 0)); } bool GetPadMoveLeft() @@ -2277,7 +2277,7 @@ bool GetPadMoveLeft() return (CPad::GetPad(0)->NewState.DPadLeft && !CPad::GetPad(0)->OldState.DPadLeft) || (CPad::GetPad(0)->NewKeyState.LEFT && !CPad::GetPad(0)->OldKeyState.LEFT) || - (CPad::GetPad(0)->NewState.LeftStickX < 0 && !CPad::GetPad(0)->OldState.LeftStickX < 0); + (CPad::GetPad(0)->NewState.LeftStickX < 0 && !(CPad::GetPad(0)->OldState.LeftStickX < 0)); } bool GetPadMoveRight() @@ -2285,7 +2285,7 @@ bool GetPadMoveRight() return (CPad::GetPad(0)->NewState.DPadRight && !CPad::GetPad(0)->OldState.DPadRight) || (CPad::GetPad(0)->NewKeyState.RIGHT && !CPad::GetPad(0)->OldKeyState.RIGHT) || - (CPad::GetPad(0)->NewState.LeftStickX > 0 && !CPad::GetPad(0)->OldState.LeftStickX > 0); + (CPad::GetPad(0)->NewState.LeftStickX > 0 && !(CPad::GetPad(0)->OldState.LeftStickX > 0)); } bool GetMouseForward() diff --git a/src/core/Placeable.h b/src/core/Placeable.h index 1dfece69..648b315c 100644 --- a/src/core/Placeable.h +++ b/src/core/Placeable.h @@ -17,6 +17,11 @@ public: CMatrix &GetMatrix(void) { return m_matrix; } void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); } void SetHeading(float angle); + void SetOrientation(float x, float y, float z){ + CVector pos = m_matrix.GetPosition(); + m_matrix.SetRotate(x, y, z); + m_matrix.Translate(pos); + } bool IsWithinArea(float x1, float y1, float x2, float y2); bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2); }; diff --git a/src/core/config.h b/src/core/config.h index c3b66ff7..b1efd4b6 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -30,6 +30,8 @@ enum Config { NUMDUMMIES = 2802, // 2368 on PS2 NUMAUDIOSCRIPTOBJECTS = 256, + NUMTEMPOBJECTS = 30, + // Link list lengths // TODO: alpha list NUMCOLCACHELINKS = 200, diff --git a/src/core/re3.cpp b/src/core/re3.cpp index d6e81214..f266ffab 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -154,6 +154,15 @@ spawnCar(int id) } #endif +void +FixCar(void) +{ + CVehicle *veh = FindPlayerVehicle(); + if(veh == nil || !veh->IsCar()) + return; + ((CAutomobile*)veh)->Fix(); +} + void DebugMenuPopulate(void) { @@ -198,6 +207,7 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Cheats", "Strong grip", StrongGripCheat); DebugMenuAddCmd("Cheats", "Nasty limbs", NastyLimbsCheat); + DebugMenuAddCmd("Debug", "Fix Car", FixCar); DebugMenuAddVarBool8("Debug", "Show Ped Road Groups", (int8*)&gbShowPedRoadGroups, nil); DebugMenuAddVarBool8("Debug", "Show Car Road Groups", (int8*)&gbShowCarRoadGroups, nil); DebugMenuAddVarBool8("Debug", "Show Collision Polys", (int8*)&gbShowCollisionPolys, nil); -- cgit v1.2.3 From 69ee4acc97504ffedf09995e75da62417abeb231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 8 Jul 2019 23:03:50 +0300 Subject: One driver owns all the cars fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: eray orçunus --- src/core/FileLoader.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index fdc3b9d7..b949eb98 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -813,6 +813,7 @@ CFileLoader::LoadPedObject(const char *line) if(strcmp(animGroup, CAnimManager::GetAnimGroupName((AssocGroupId)animGroupId)) == 0) break; mi->m_animGroup = animGroupId; + mi->m_carsCanDrive = carsCanDrive; // ??? CModelInfo::GetModelInfo(MI_LOPOLYGUY)->SetColModel(&CTempColModels::ms_colModelPed1); -- cgit v1.2.3 From 74fcbc8c0a6bbac8e8057655c5f1133e15c63656 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 09:57:44 +0200 Subject: more CAutomobile --- src/core/Camera.cpp | 10 +++++++--- src/core/Collision.cpp | 2 +- src/core/Collision.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 58e65d24..832f9455 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -678,9 +678,13 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl else if(TargetZOffSet == m_fUnknownZOffSet && TargetZOffSet > m_fCamBufferedHeight){ // TODO: figure this out bool foo = false; - switch(((CPhysical*)CamTargetEntity)->m_nLastCollType) - case 2: case 3: case 5: - case 11: case 23: case 26: + switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched) + case SURFACE_GRASS: + case SURFACE_DIRT: + case SURFACE_PAVEMENT: + case SURFACE_STEEL: + case SURFACE_TIRE: + case SURFACE_STONE: foo = true; if(foo) WellBufferMe(TargetHeight, &m_fCamBufferedHeight, &m_fCamBufferedHeightSpeed, 0.4f, 0.05f, false); diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index d15ccca5..94da1338 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -1173,7 +1173,7 @@ enum { // This checks model A's spheres and lines against model B's spheres, boxes and triangles. // Returns the number of A's spheres that collide. // Returned ColPoints are in world space. -// NB: lines do not seem to be supported very well, use with caution +// NB: only vehicles can have col models with lines, exactly 4, one for each wheel int32 CCollision::ProcessColModels(const CMatrix &matrixA, CColModel &modelA, const CMatrix &matrixB, CColModel &modelB, diff --git a/src/core/Collision.h b/src/core/Collision.h index 5a9058d3..b2fe6564 100644 --- a/src/core/Collision.h +++ b/src/core/Collision.h @@ -147,7 +147,7 @@ public: static bool ProcessSphereTriangle(const CColSphere &sph, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq); static bool ProcessLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough); static bool ProcessVerticalLine(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough, CStoredCollPoly *poly); - static int32 ProcessColModels(const CMatrix &matrix1, CColModel &model1, const CMatrix &matrix2, CColModel &model2, CColPoint *point1, CColPoint *point2, float *linedists); + static int32 ProcessColModels(const CMatrix &matrixA, CColModel &modelA, const CMatrix &matrixB, CColModel &modelB, CColPoint *spherepoints, CColPoint *linepoints, float *linedists); // TODO: // CCollision::IsStoredPolyStillValidVerticalLine -- cgit v1.2.3 From a65dd41da736a12866526abc1405cbaa154771a8 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 18:50:35 +0200 Subject: yet more CAutomobile --- src/core/Camera.cpp | 1 + src/core/Camera.h | 2 ++ src/core/Explosion.cpp | 5 +++++ src/core/Explosion.h | 15 +++++++++++++++ src/core/Fire.cpp | 6 +++++- src/core/Fire.h | 21 ++++++++++++++------- src/core/Wanted.cpp | 10 ++++++++-- src/core/Wanted.h | 1 + 8 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 src/core/Explosion.cpp create mode 100644 src/core/Explosion.h (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 832f9455..0f4503bb 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -18,6 +18,7 @@ const float DefaultFOV = 70.0f; // beta: 80.0f CCamera &TheCamera = *(CCamera*)0x6FACF8; bool &CCamera::m_bUseMouse3rdPerson = *(bool *)0x5F03D8; +WRAPPER void CCamera::CamShake(float strength, float x, float y, float z) { EAXJMP(0x46B200); } WRAPPER void CCamera::DrawBordersForWideScreen(void) { EAXJMP(0x46B430); } WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); } WRAPPER void CCamera::Restore(void) { EAXJMP(0x46F990); } diff --git a/src/core/Camera.h b/src/core/Camera.h index db5fff46..f00a213e 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -454,6 +454,8 @@ int m_iModeObbeCamIsInForCar; void ProcessMusicFade(void); void SetFadeColour(uint8 r, uint8 g, uint8 b); + void CamShake(float strength, float x, float y, float z); + void SetMotionBlur(int r, int g, int b, int a, int type); void SetMotionBlurAlpha(int a); void RenderMotionBlur(void); diff --git a/src/core/Explosion.cpp b/src/core/Explosion.cpp new file mode 100644 index 00000000..f55cbcd6 --- /dev/null +++ b/src/core/Explosion.cpp @@ -0,0 +1,5 @@ +#include "common.h" +#include "patcher.h" +#include "Explosion.h" + +WRAPPER void CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32) { EAXJMP(0x5591C0); } diff --git a/src/core/Explosion.h b/src/core/Explosion.h new file mode 100644 index 00000000..69508490 --- /dev/null +++ b/src/core/Explosion.h @@ -0,0 +1,15 @@ +#pragma once + +class CEntity; + +enum eExplosionType +{ + EXPLOSION_3 = 3, + EXPLOSION_4 +}; + +class CExplosion +{ +public: + static void AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32); +}; diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 05d72199..bc59de2f 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -2,4 +2,8 @@ #include "patcher.h" #include "Fire.h" -WRAPPER void CFire::Extinguish(void) { EAXJMP(0x479D40); } \ No newline at end of file +CFireManager &gFireManager = *(CFireManager*)0x8F31D0; + +WRAPPER void CFire::Extinguish(void) { EAXJMP(0x479D40); } + +WRAPPER void CFireManager::StartFire(CEntity *entityOnFire, CEntity *culprit, float, uint32) { EAXJMP(0x479590); } diff --git a/src/core/Fire.h b/src/core/Fire.h index c7f83fd8..9c9e1dec 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -1,13 +1,13 @@ #pragma once -#include "common.h" -#include "Entity.h" + +class CEntity; class CFire { - char m_bIsOngoing; - char m_bExists; - char m_bPropogationFlag; - char m_bAudioSet; + bool m_bIsOngoing; + bool m_bExists; + bool m_bPropogationFlag; + bool m_bAudioSet; CVector m_vecPos; CEntity *m_pEntity; CEntity *m_pSource; @@ -20,4 +20,11 @@ class CFire public: void Extinguish(void); -}; \ No newline at end of file +}; + +class CFireManager +{ +public: + void StartFire(CEntity *entityOnFire, CEntity *culprit, float, uint32); +}; +extern CFireManager &gFireManager; diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index 21853308..4608bfef 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -34,7 +34,7 @@ int CWanted::NumOfHelisRequired() return 2; default: return 0; - }; + } } void CWanted::SetWantedLevel(int32 level) @@ -70,11 +70,17 @@ void CWanted::SetWantedLevel(int32 level) UpdateWantedLevel(); } +void CWanted::SetWantedLevelNoDrop(int32 level) +{ + if (level > m_nWantedLevel) + SetWantedLevel(level); +} + void CWanted::ClearQdCrimes() { for (int i = 0; i < 16; i++) { m_sCrimes[i].m_eCrimeType = CRIME_NONE; - }; + } } void CWanted::UpdateWantedLevel() diff --git a/src/core/Wanted.h b/src/core/Wanted.h index d14bb905..d3f6638b 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -42,6 +42,7 @@ public: bool AreArmyRequired(); int NumOfHelisRequired(); void SetWantedLevel(int32); + void SetWantedLevelNoDrop(int32 level); void ClearQdCrimes(); void UpdateWantedLevel(); }; -- cgit v1.2.3 From 11ae1b06ae658db4be9675dcad4da30493ff0bbc Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Tue, 9 Jul 2019 23:38:05 +0300 Subject: RunningScript: 1/12 --- src/core/Camera.cpp | 1 + src/core/Camera.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 58e65d24..6cafaade 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -22,6 +22,7 @@ WRAPPER void CCamera::DrawBordersForWideScreen(void) { EAXJMP(0x46B430); } WRAPPER void CCamera::CalculateDerivedValues(void) { EAXJMP(0x46EEA0); } WRAPPER void CCamera::Restore(void) { EAXJMP(0x46F990); } WRAPPER void CCamera::SetWidescreenOff(void) { EAXJMP(0x46FF10); } +WRAPPER void CCamera::CamShake(float) { EAXJMP(0x46B100); } bool CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat) diff --git a/src/core/Camera.h b/src/core/Camera.h index db5fff46..da0e55eb 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -463,6 +463,7 @@ int m_iModeObbeCamIsInForCar; void DrawBordersForWideScreen(void); void Restore(void); void SetWidescreenOff(void); + void CamShake(float); void dtor(void) { this->CCamera::~CCamera(); } }; -- cgit v1.2.3 From 702cd0076506dad26abc3c5239a2cfddfa7deb00 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 23:49:44 +0200 Subject: more CVehicle --- src/core/PlayerInfo.cpp | 3 ++- src/core/PlayerInfo.h | 1 + src/core/re3.cpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 59efe2ae..9d003e76 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -2,4 +2,5 @@ #include "patcher.h" #include "PlayerInfo.h" -WRAPPER void CPlayerInfo::MakePlayerSafe(bool) { EAXJMP(0x4A1400); } \ No newline at end of file +WRAPPER void CPlayerInfo::MakePlayerSafe(bool) { EAXJMP(0x4A1400); } +WRAPPER void CPlayerInfo::AwardMoneyForExplosion(CVehicle *vehicle) { EAXJMP(0x4A15F0); } diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index e2b42fe7..a9763766 100644 --- a/src/core/PlayerInfo.h +++ b/src/core/PlayerInfo.h @@ -67,6 +67,7 @@ public: RwTexture *m_pSkinTexture; void MakePlayerSafe(bool); + void AwardMoneyForExplosion(CVehicle *vehicle); }; static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error"); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index f266ffab..8bb9caee 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -158,8 +158,12 @@ void FixCar(void) { CVehicle *veh = FindPlayerVehicle(); - if(veh == nil || !veh->IsCar()) + if(veh == nil) return; + veh->m_fHealth = 1000.0f; + if(!veh->IsCar()) + return; + ((CAutomobile*)veh)->Damage.SetEngineStatus(0); ((CAutomobile*)veh)->Fix(); } -- cgit v1.2.3 From 5b04393bb47b424b8bab6864afe4d50e8a7026fe Mon Sep 17 00:00:00 2001 From: _AG Date: Wed, 10 Jul 2019 09:57:08 +0200 Subject: More frontend inputs. --- src/core/ControllerConfig.cpp | 1 + src/core/ControllerConfig.h | 3 +- src/core/Frontend.cpp | 336 ++++++++++++++++++++++++++++++++---------- src/core/Frontend.h | 36 ++++- src/core/MenuScreens.h | 4 +- src/core/PlayerInfo.cpp | 8 + src/core/PlayerInfo.h | 6 +- src/core/Text.cpp | 2 + src/core/Text.h | 1 + 9 files changed, 305 insertions(+), 92 deletions(-) (limited to 'src/core') diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index d7567ac4..e3a586b2 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -21,6 +21,7 @@ WRAPPER void CControllerConfigManager::InitDefaultControlConfigJoyPad(unsigned i WRAPPER void CControllerConfigManager::ClearSimButtonPressCheckers() { EAXJMP(0x58D220); } WRAPPER void CControllerConfigManager::AffectPadFromKeyBoard() { EAXJMP(0x58D0C0); } WRAPPER void CControllerConfigManager::AffectPadFromMouse() { EAXJMP(0x58D1A0); } +WRAPPER void CControllerConfigManager::ClearSettingsAssociatedWithAction(int, int) { EAXJMP(0x58EB40); } void CControllerConfigManager::LoadSettings(int32 file) { diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index 581efe05..8a434245 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -50,7 +50,8 @@ public: void ClearSimButtonPressCheckers(); void AffectPadFromKeyBoard(); void AffectPadFromMouse(); - + void ClearSettingsAssociatedWithAction(int, int); + }; VALIDATE_SIZE(CControllerConfigManager, 0x143C); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 2fa9d8ea..17a5ad30 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -24,6 +24,8 @@ #include "Vehicle.h" #include "MBlur.h" #include "PlayerSkin.h" +#include "PlayerInfo.h" +#include "World.h" int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; @@ -50,7 +52,9 @@ int8 &CMenuManager::m_bFrontEnd_ReloadObrTxtGxt = *(int8*)0x628CFC; int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; -uint8 *CMenuManager::m_PrefsSkinFile = (uint8*)0x5F2E74; +char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; + +int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; @@ -59,11 +63,14 @@ float lodMultiplier = *(float*)0x5F726C; // Stuff not in CMenuManager: int VibrationTime; -char* pEditString; -int32 pControlEdit; +char* pEditString = (char*)0x628D00; +int32 &pControlEdit = *(int32*)0x628D08; int8 DisplayComboButtonErrMsg; -bool MouseButtonJustClicked; -bool JoyButtonJustClicked; +int8 MouseButtonJustClicked; +int8 JoyButtonJustClicked; +int32 &nTimeForSomething = *(int32*)0x628D54; +int32 TypeOfControl = 0; +int32 *pControlTemp = 0; // Frontend inputs. bool GetPadBack(); @@ -135,12 +142,28 @@ char *MenuFilenames[] = { nil, nil }; -#if 1 -WRAPPER void CMenuManager::BuildStatLine(char *, void *, uint16, void *) { EAXJMP(0x483870); } +#if 0 +WRAPPER void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* stat2) { EAXJMP(0x483870); } #else -void CMenuManager::BuildStatLine(char *, void *, uint16, void *) +void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* stat2) { + if (!text) + return; + if (stat) { + if (aFloat) + sprintf(gString, "%.2f"); + else + sprintf(gString, "%d"); + } + else if (stat2) { + if (aFloat) + sprintf(gString, "%.2f %s %.2f", stat, UnicodeToAscii(TheText.Get("FEST_OO")), stat2); + else + sprintf(gString, "%d %s %d", stat, UnicodeToAscii(TheText.Get("FEST_OO")), stat2); + } + + wcscpy((wchar_t*)gUString, (wchar_t*)TheText.Get(text)); } #endif @@ -164,11 +187,11 @@ void CMenuManager::CentreMousePointer() #endif #if 1 -WRAPPER void CMenuManager::CheckCodesForControls(int, int) { EAXJMP(0x48A950); } +WRAPPER int CMenuManager::CheckCodesForControls(int32) { EAXJMP(0x48A950); } #else -void CMenuManager::CheckCodesForControls() +void CMenuManager::CheckCodesForControls(int, int) { - + DisplayComboButtonErrMsg = 0; } #endif @@ -719,9 +742,9 @@ void CMenuManager::Draw() m_nPrevOption = m_nCurrOption; if (GetMouseForward()) - m_nHoverOption = IGNORE_OPTION; + m_nHoverOption = HOVEROPTION_NULL; else - m_nHoverOption = ACTIVATE_OPTION; + m_nHoverOption = HOVEROPTION_DEFAULT; } } } @@ -1291,75 +1314,144 @@ WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) { - if (m_bSaveMenuActive && TheCamera.GetScreenFadeStatus()) + if (!m_bSaveMenuActive && TheCamera.GetScreenFadeStatus()) return; - field_113 = 0; + field_112 = 0; + m_bLanguageLoaded = false; + m_bStartGameLoading = false; InitialiseChangedLanguageSettings(); + // SwitchMenuOnAndOff(); - if (m_bMenuActive) { - LoadAllTextures(); + // Be able to re-open menu correctly. + if (!m_bMenuActive) { + if (GetPadExitEnter()) + RequestFrontEndStartUp(); + + UnloadTextures(); + field_452 = 0; + SwitchToNewScreen(MENUPAGE_NONE); + pEditString = 0; + field_113 = 0; + return; + } - if (m_nCurrScreen == MENUPAGE_DELETING) { - bool SlotPopulated = false; + // Load frontend textures. + LoadAllTextures(); - if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { - PcSaveHelper.PopulateSlotInfo(); - SlotPopulated = true; - } + // Set save/delete game pages. + if (m_nCurrScreen == MENUPAGE_DELETING) { + bool SlotPopulated = false; - if (SlotPopulated) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else - SaveLoadFileError_SetUpErrorScreen(); - } - if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { - int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); + if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { PcSaveHelper.PopulateSlotInfo(); - if (SaveSlot) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else - SaveLoadFileError_SetUpErrorScreen(); + SlotPopulated = true; } - if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { - if (CheckSlotDataValid(m_nCurrSaveSlot)) { - TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; - if (m_PrefsVsyncDisp != m_PrefsVsync) - m_PrefsVsync = m_PrefsVsyncDisp; - DMAudio.Service(); - m_bStartGameLoading = 1; - RequestFrontEndShutdown(); - m_bLoadingSavedGame = 1; - b_FoundRecentSavedGameWantToLoad = 1; - DMAudio.SetEffectsFadeVol(0); - DMAudio.SetMusicFadeVol(0); - DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); - } - else - SaveLoadFileError_SetUpErrorScreen(); + + if (SlotPopulated) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); } + else + SaveLoadFileError_SetUpErrorScreen(); + } + if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { + int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); + PcSaveHelper.PopulateSlotInfo(); + if (SaveSlot) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { + if (CheckSlotDataValid(m_nCurrSaveSlot)) { + TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; + if (m_PrefsVsyncDisp != m_PrefsVsync) + m_PrefsVsync = m_PrefsVsyncDisp; + DMAudio.Service(); + m_bStartGameLoading = 1; + RequestFrontEndShutdown(); + m_bLoadingSavedGame = 1; + b_FoundRecentSavedGameWantToLoad = 1; + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + } + else + SaveLoadFileError_SetUpErrorScreen(); + } + + ProcessButtonPresses(); - ProcessButtonPresses(); + // Set binding keys. + if (pEditString && !CPad::EditString(pEditString, 0)) { + if (!pEditString) + strcpy(pEditString, "NoName"); + pEditString = 0; + SaveSettings(); } - else { - if (GetPadExitEnter()) - RequestFrontEndStartUp(); - UnloadTextures(); - m_nPrevScreen = MENUPAGE_NONE; - m_nCurrScreen = m_nPrevScreen; - m_nCurrOption = MENUROW_0; + if (field_113) { + if ((m_nCurrScreen == MENUPAGE_13 || m_nCurrScreen == MENUPAGE_16) && CTimer::GetTimeInMillisecondsPauseMode() > field_558) + SwitchToNewScreen(m_nPrevScreen); + + // Reset pad shaking. + if (VibrationTime && CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { + CPad::GetPad(0)->StopPadsShaking(); + VibrationTime = 0; + } + + if (m_bStartGameLoading) { + if (m_bGameNotLoaded) + DMAudio.Service(); + } + } + + if (!field_456) { + JoyButtonJustClicked = 0; + CPad::EditCodesForControls(&pControlEdit, 0); + MouseButtonJustClicked = 0; + + if (GetMouseForward()) + MouseButtonJustClicked = 1; + else { + if (GetMouseBack()) + MouseButtonJustClicked = 3; + } + + JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); + + if (JoyButtonJustClicked) + TypeOfControl = 3; + if (MouseButtonJustClicked) + TypeOfControl = 2; + if (pControlEdit != 1056) + TypeOfControl = 0; + + if (field_534) { + if (!m_bKeyChangeNotProcessed) { + if (pControlEdit != 1056 || MouseButtonJustClicked || JoyButtonJustClicked) + CheckCodesForControls(TypeOfControl); + + field_535 = 1; + return; + } + } + else { + pControlEdit = 0; + field_113 = 0; + m_KeyPressedCode = -1; + } } + field_456 = 0; } #endif @@ -1368,7 +1460,7 @@ WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else void CMenuManager::ProcessButtonPresses() { - // Update Mouse Position + // Update mouse position m_nMouseOldPosX = m_nMousePosX; m_nMouseOldPosY = m_nMousePosY; @@ -1390,6 +1482,70 @@ void CMenuManager::ProcessButtonPresses() else if (GetPadInput()) m_bShowMouse = false; + if (m_nCurrScreen == MENUPAGE_MULTIPLAYER_FIND_GAME || m_nCurrScreen == MENUPAGE_SKIN_SELECT || m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) + field_440 = m_nSkinsTotal; + + if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + field_440 = m_ControlMethod ? 30 : 25; + + if (field_44C > field_440) + field_44C = field_440 - 1; + } + + if (!GetPadBack() || m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS || field_535) + field_535 = 0; + else if (field_536 == 19) { + m_nHoverOption = 42; + field_113 = 1; + field_456 = 1; + m_bKeyChangeNotProcessed = 1; + //pControlEdit = m_KeyPressedCode; + } + + if (GetPadForward()) { + switch (field_536) { + case 19: + if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { + field_113 = 1; + field_456 = 1; + //pControlEdit = m_KeyPressedCode; + } + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { + strcpy(m_PrefsSkinFile, m_aSkinName); + CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); + field_536 = 9; + } + + m_nHoverOption = HOVEROPTION_NULL; + SaveSettings(); + break; + case 21: + strcpy(m_PrefsSkinFile, m_aSkinName); + CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); + field_536 = 9; + break; + default: + break; + }; + } + + bool once = false; + if (!once) { + once = true; + nTimeForSomething = 0; + } + + if ((CTimer::GetTimeInMillisecondsPauseMode() - nTimeForSomething) > 200) { + field_520 = 0; + field_521 = 0; + field_522 = 0; + field_523 = 0; + field_524 = 0; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + } + } + // Get number of menu options. uint8 NumberOfMenuOptions = GetNumberOfMenuOptions(); @@ -1436,6 +1592,14 @@ void CMenuManager::ProcessButtonPresses() RequestFrontEndShutdown(); PlayEscSound = true; break; + case MENUPAGE_KEYBOARD_CONTROLS: + if (!m_bKeyChangeNotProcessed) { + m_bKeyChangeNotProcessed = true; + field_534 = 0; + } + else + SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); + break; default: SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); PlayEscSound = true; @@ -1446,17 +1610,34 @@ void CMenuManager::ProcessButtonPresses() DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); } - // TODO: finish hover options. - // Set mouse buttons. + // Set hover options, how it is supposed to be used isn't really clear yet. if (GetMouseForward()) { switch (m_nHoverOption) { - case ACTIVATE_OPTION: + case HOVEROPTION_DEFAULT: if (m_nCurrOption || m_nCurrScreen != MENUPAGE_PAUSE_MENU) m_nCurrOption = m_nPrevOption; - m_nHoverOption = ACTIVATE_OPTION; + m_nHoverOption = HOVEROPTION_DEFAULT; + break; + case HOVEROPTION_12: + m_nHoverOption = HOVEROPTION_14; + break; + case HOVEROPTION_13: + m_nHoverOption = HOVEROPTION_15; + break; + case HOVEROPTION_19: + m_nHoverOption = HOVEROPTION_20; + break; + case HOVEROPTION_CHANGESKIN: + if (m_nSkinsTotal > 0) { + m_pSelectedSkin = m_sSkin.field_304; + strcpy(m_PrefsSkinFile, m_aSkinName); + CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); + SaveSettings(); + } break; default: + m_nHoverOption = HOVEROPTION_NULL; break; }; } @@ -1495,14 +1676,6 @@ void CMenuManager::ProcessButtonPresses() default: break; }; - - // Reset pad shaking. - if (VibrationTime != 0) { - if (CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { - CPad::GetPad(0)->StopShaking(0); - VibrationTime = 0; - } - } } #endif @@ -1683,6 +1856,9 @@ void CMenuManager::ProcessOnOffMenuOptions() case MENUACTION_UPDATEMEMCARDSAVE: RequestFrontEndShutdown(); break; + case MENUACTION_GETKEY: + //*pControlEdit = m_KeyPressedCode; + break; case MENUACTION_INVVERT: MousePointerStateHelper.bInvertVertically = MousePointerStateHelper.bInvertVertically == false; return; @@ -2204,7 +2380,7 @@ void CMenuManager::SetDefaultPreferences(int8 screen) m_PrefsVsync = true; m_PrefsLOD = 1.2f; m_PrefsVsyncDisp = true; - lodMultiplier = 1.2; + lodMultiplier = 1.2f; CMBlur::BlurOn = true; CMBlur::MotionBlurOpen(Scene.camera); m_PrefsUseVibration = false; diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 9b9377da..ede036d2 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -306,8 +306,29 @@ enum eMenuAction enum eCheckHover { - ACTIVATE_OPTION = 2, - IGNORE_OPTION = 42, + HOVEROPTION_0, + HOVEROPTION_1, + HOVEROPTION_DEFAULT, + HOVEROPTION_3, + HOVEROPTION_4, + HOVEROPTION_5, + HOVEROPTION_6, + HOVEROPTION_7, + HOVEROPTION_8, + HOVEROPTION_9, + HOVEROPTION_10, + HOVEROPTION_11, + HOVEROPTION_12, + HOVEROPTION_13, + HOVEROPTION_14, + HOVEROPTION_15, + HOVEROPTION_16, + HOVEROPTION_17, + HOVEROPTION_18, + HOVEROPTION_19, + HOVEROPTION_20, + HOVEROPTION_CHANGESKIN, + HOVEROPTION_NULL = 42, }; enum eMenuColumns @@ -348,7 +369,7 @@ struct tSkinInfo char skinName[256]; char currSkinName[256]; char date[256]; - int field_304; + tSkinInfo *field_304; }; struct CMenuScreen @@ -388,7 +409,7 @@ public: int32 m_nMouseTempPosX; int32 m_nMouseTempPosY; bool m_bShowMouse; - tSkinInfo field_12C; + tSkinInfo m_sSkin; tSkinInfo *m_pSelectedSkin; tSkinInfo *field_438; float field_43C; @@ -450,16 +471,17 @@ public: static int8 &m_bFrontEnd_ReloadObrTxtGxt; static int32 &m_PrefsMusicVolume; static int32 &m_PrefsSfxVolume; - static uint8 *m_PrefsSkinFile; + static char *m_PrefsSkinFile; + static int32 &m_KeyPressedCode; static bool &m_bStartUpFrontEndRequested; static bool &m_bShutDownFrontEndRequested; static bool &m_PrefsAllowNastyGame; public: - void BuildStatLine(char *, void *, uint16, void *); + void BuildStatLine(char *text, float *stat, bool aFloat, float* stat2); static void CentreMousePointer(); - void CheckCodesForControls(int, int); + int CheckCodesForControls(int32); bool CheckHover(int x1, int x2, int y1, int y2); void CheckSliderMovement(int); int CostructStatLine(int); diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 2da81f1d..866dfc03 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -43,7 +43,7 @@ const CMenuScreen aScreens[] = { { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_2, MENUROW_2, MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, - //MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, + MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_FRAMELIMIT, "FEM_FRM", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_TRAILS, "FED_TRA", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -273,7 +273,7 @@ const CMenuScreen aScreens[] = { MENUACTION_CHANGEMENU, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_CHANGEMENU, "FET_LAN", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, - //MENUACTION_CHANGEMENU, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, + MENUACTION_CHANGEMENU, "FET_PSU", SAVESLOT_NONE, MENUPAGE_SKIN_SELECT, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 9d003e76..81c7a199 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -1,6 +1,14 @@ #include "common.h" #include "patcher.h" #include "PlayerInfo.h" +#include "Frontend.h" WRAPPER void CPlayerInfo::MakePlayerSafe(bool) { EAXJMP(0x4A1400); } +WRAPPER void CPlayerInfo::LoadPlayerSkin() { EAXJMP(0x4A1700); } WRAPPER void CPlayerInfo::AwardMoneyForExplosion(CVehicle *vehicle) { EAXJMP(0x4A15F0); } + +void CPlayerInfo::SetPlayerSkin(char *skin) +{ + strncpy(m_aSkinName, skin, 32); + LoadPlayerSkin(); +} diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index a9763766..d8128424 100644 --- a/src/core/PlayerInfo.h +++ b/src/core/PlayerInfo.h @@ -63,11 +63,13 @@ public: bool m_bFastReload; bool m_bGetOutOfJailFree; bool m_bGetOutOfHospitalFree; - uint8 m_aSkinName[32]; + char m_aSkinName[32]; RwTexture *m_pSkinTexture; void MakePlayerSafe(bool); - void AwardMoneyForExplosion(CVehicle *vehicle); + void LoadPlayerSkin(); + void AwardMoneyForExplosion(CVehicle *vehicle); + void SetPlayerSkin(char* skin); }; static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error"); diff --git a/src/core/Text.cpp b/src/core/Text.cpp index d7d63467..b834a44d 100644 --- a/src/core/Text.cpp +++ b/src/core/Text.cpp @@ -210,6 +210,8 @@ AsciiToUnicode(const char *src, uint16 *dst) while((*dst++ = *src++) != '\0'); } +WRAPPER char UnicodeToAscii(wchar * src) { EAXJMP(0x52C2F0); } + void TextCopy(wchar *dst, const wchar *src) { diff --git a/src/core/Text.h b/src/core/Text.h index 2592e6b8..15ab7a8f 100644 --- a/src/core/Text.h +++ b/src/core/Text.h @@ -1,6 +1,7 @@ #pragma once void AsciiToUnicode(const char *src, wchar *dst); +char UnicodeToAscii(wchar *src); void TextCopy(wchar *dst, const wchar *src); struct CKeyEntry -- cgit v1.2.3 From d360229b5b3a3ef82a8defd6672bfda81ded9326 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 13:42:48 +0200 Subject: fixed some stuff in frontend, badly broke others; disabled reversed frontend for the moment --- src/core/Frontend.cpp | 459 ++++++++++++++++++++++++++++---------------------- src/core/Frontend.h | 2 +- src/core/Text.cpp | 44 ++++- src/core/Text.h | 5 +- src/core/main.cpp | 8 +- src/core/main.h | 8 +- 6 files changed, 323 insertions(+), 203 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 17a5ad30..a846efc6 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -27,6 +27,8 @@ #include "PlayerInfo.h" #include "World.h" +#define ALL_ORIGINAL_FRONTEND 1 + int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; int8 &CMenuManager::m_DisplayControllerOnFoot = *(int8*)0x95CD8D; @@ -62,9 +64,9 @@ CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; float lodMultiplier = *(float*)0x5F726C; // Stuff not in CMenuManager: -int VibrationTime; +uint32 VibrationTime; char* pEditString = (char*)0x628D00; -int32 &pControlEdit = *(int32*)0x628D08; +int32 *&pControlEdit = *(int32**)0x628D08; int8 DisplayComboButtonErrMsg; int8 MouseButtonJustClicked; int8 JoyButtonJustClicked; @@ -73,6 +75,7 @@ int32 TypeOfControl = 0; int32 *pControlTemp = 0; // Frontend inputs. + bool GetPadBack(); bool GetPadExitEnter(); bool GetPadForward(); @@ -80,6 +83,11 @@ bool GetPadMoveUp(); bool GetPadMoveDown(); bool GetPadMoveLeft(); bool GetPadMoveRight(); +bool GetMouseClickLeft(); +bool GetMouseClickRight(); +bool GetMouseClickMiddle(); +bool GetMouseWheelUp(); +bool GetMouseWheelDown(); bool GetMouseForward(); bool GetMouseBack(); bool GetMousePos(); @@ -142,7 +150,7 @@ char *MenuFilenames[] = { nil, nil }; -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* stat2) { EAXJMP(0x483870); } #else void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* stat2) @@ -150,24 +158,27 @@ void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* st if (!text) return; - if (stat) { - if (aFloat) - sprintf(gString, "%.2f"); - else - sprintf(gString, "%d"); - } - else if (stat2) { + if (stat2) { if (aFloat) - sprintf(gString, "%.2f %s %.2f", stat, UnicodeToAscii(TheText.Get("FEST_OO")), stat2); + sprintf(gString2, " %.2f %s %.2f", *stat, UnicodeToAscii(TheText.Get("FEST_OO")), *stat2); else - sprintf(gString, "%d %s %d", stat, UnicodeToAscii(TheText.Get("FEST_OO")), stat2); + sprintf(gString2, " %d %s %d", *(int*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(int*)stat2); + } + else if (stat2) { + if (aFloat) + sprintf(gString2, " %.2f", *stat); + else + sprintf(gString2, " %d", *(int*)stat); } + else + gString2[0] = '\0'; - wcscpy((wchar_t*)gUString, (wchar_t*)TheText.Get(text)); + UnicodeStrcpy(gUString, TheText.Get(text)); + AsciiToUnicode(gString2, gUString2); } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::CentreMousePointer() { EAXJMP(0x48ACE0); } #else void CMenuManager::CentreMousePointer() @@ -195,7 +206,7 @@ void CMenuManager::CheckCodesForControls(int, int) } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER bool CMenuManager::CheckHover(int, int, int, int) { EAXJMP(0x48ACA0); } #else bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) @@ -274,7 +285,7 @@ void CMenuManager::CheckSliderMovement(int value) TheCamera.m_fMouseAccelVertical = fMouseSens; SaveSettings(); break; - }; + } } #if 1 @@ -286,7 +297,7 @@ int CMenuManager::CostructStatLine(int) } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::DisplayHelperText() { EAXJMP(0x48B490); } #else void CMenuManager::DisplayHelperText() @@ -326,7 +337,7 @@ void CMenuManager::DisplayHelperText() break; default: break; - }; + } CFont::SetAlignment(ALIGN_CENTER); CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); @@ -339,7 +350,7 @@ void CMenuManager::DisplayHelperText() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER float CMenuManager::DisplaySlider(float, float, float, float, float, float) { EAXJMP(0x488420); } #else float CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightSize, float rectSize, float progress) @@ -365,12 +376,12 @@ float CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightS float _s = SCREEN_SCALE_X(2.0f); CSprite2d::DrawRect(CRect(_x + _s, _y + _s, _w + _s, _h + _s), CRGBA(0, 0, 0, FadeIn(255))); // Shadow CSprite2d::DrawRect(CRect(i * rectSize/16.0f + x, y + sizeRange - ((16 - i) * leftSize + i * rightSize)/16.0f, SCREEN_SCALE_X(10.0f) + i * rectSize/16.0f + x, y + sizeRange), color); - }; + } return input; } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); } #else void CMenuManager::DoSettingsBeforeStartingAGame() @@ -389,7 +400,7 @@ void CMenuManager::DoSettingsBeforeStartingAGame() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::Draw() { EAXJMP(0x47AE00); } #else void CMenuManager::Draw() @@ -450,7 +461,7 @@ void CMenuManager::Draw() default: str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName); break; - }; + } CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(MENUDROP_COLOR_A))); @@ -503,7 +514,7 @@ void CMenuManager::Draw() case 3: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_CF4"); break; - }; + } break; case MENUACTION_CTRLDISPLAY: break; @@ -533,7 +544,7 @@ void CMenuManager::Draw() case AR_16_9: textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:9"; break; - }; + } #endif break; case MENUACTION_RADIO: @@ -583,7 +594,7 @@ void CMenuManager::Draw() case 2: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_4SP"); break; - }; + } } break; case MENUACTION_CTRLMETHOD: @@ -594,7 +605,7 @@ void CMenuManager::Draw() case 1: textToPrint[MENUCOLUMN_LEFT] = TheText.Get("FET_CCN"); break; - }; + } break; case MENUACTION_DYNAMICACOUSTIC: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsDMA ? "FEM_ON" : "FEM_OFF"); @@ -602,7 +613,7 @@ void CMenuManager::Draw() case MENUACTION_MOUSESTEER: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_bDisableMouseSteering ? "FEM_ON" : "FEM_OFF"); break; - }; + } CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(MENUDROP_COLOR_A))); @@ -690,7 +701,7 @@ void CMenuManager::Draw() default: vecPositions.y = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(MENUCOLUMN_MID_Y); break; - }; + } } if (i > 0) @@ -767,7 +778,7 @@ void CMenuManager::Draw() case MENUACTION_MOUSESENS: DisplaySlider(SCREEN_SCALE_FROM_RIGHT(MENUSLIDER_X), vecPositions.y - SCREEN_SCALE_Y(3.0f), SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(18.0f), SCREEN_SCALE_X(256.0f), TheCamera.m_fMouseAccelHorzntl * 200.0f); break; - }; + } // Radio icons. float fIconSpacing = 59.52f; @@ -816,9 +827,9 @@ void CMenuManager::Draw() case MENUPAGE_MOUSE_CONTROLS: DisplayHelperText(); break; - }; + } } - }; + } } #endif @@ -849,7 +860,7 @@ void CMenuManager::DrawControllerSetupScreen() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::DrawFrontEnd(void) { EAXJMP(0x47A540); } #else void CMenuManager::DrawFrontEnd() @@ -873,7 +884,7 @@ void CMenuManager::DrawFrontEnd() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::DrawFrontEndNormal(void) { EAXJMP(0x47A5B0); } #else void CMenuManager::DrawFrontEndNormal() @@ -927,7 +938,7 @@ void CMenuManager::DrawFrontEndNormal() case MENUPAGE_OPTIONS: previousSprite = MENUSPRITE_PLAYERSET; break; - }; + } if (m_nPrevScreen == MENUPAGE_NONE) CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255)); @@ -972,7 +983,7 @@ void CMenuManager::DrawFrontEndNormal() case MENUPAGE_OPTIONS: currentSprite = MENUSPRITE_PLAYERSET; break; - }; + } uint32 savedShade; uint32 savedAlpha; @@ -1016,7 +1027,7 @@ void CMenuManager::DrawFrontEndNormal() default: CMenuManager::Draw(); break; - }; + } CFont::DrawFonts(); @@ -1035,7 +1046,7 @@ void CMenuManager::DrawPlayerSetupScreen() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER int CMenuManager::FadeIn(int alpha) { EAXJMP(0x48AC60); } #else int CMenuManager::FadeIn(int alpha) @@ -1070,7 +1081,7 @@ int CMenuManager::GetStartOptionsCntrlConfigScreens() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::InitialiseChangedLanguageSettings() { EAXJMP(0x47A4D0); } #else void CMenuManager::InitialiseChangedLanguageSettings() @@ -1092,12 +1103,12 @@ void CMenuManager::InitialiseChangedLanguageSettings() break; default: break; - }; + } } } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::LoadAllTextures() { EAXJMP(0x47A230); } #else void CMenuManager::LoadAllTextures() @@ -1133,7 +1144,7 @@ void CMenuManager::LoadAllTextures() for (int i = 0; i < ARRAY_SIZE(FrontendFilenames); i++) { m_aFrontEndSprites[i].SetTexture(FrontendFilenames[i]); m_aFrontEndSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); - }; + } CTxdStore::PopCurrentTxd(); @@ -1146,7 +1157,7 @@ void CMenuManager::LoadAllTextures() for (int i = 0; i < ARRAY_SIZE(MenuFilenames)/2; i++) { m_aMenuSprites[i].SetTexture(MenuFilenames[i*2], MenuFilenames[i*2+1]); m_aMenuSprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); - }; + } CTxdStore::PopCurrentTxd(); @@ -1155,7 +1166,7 @@ void CMenuManager::LoadAllTextures() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } #else void CMenuManager::LoadSettings() @@ -1174,13 +1185,13 @@ void CMenuManager::LoadSettings() if (strncmp(&Ver, "THIS FILE IS NOT VALID YET", 26)) { CFileMgr::Seek(fileHandle, 0, 0); ControlsManager.LoadSettings(fileHandle); - CFileMgr::Read(fileHandle, buf(&gString), 20); - CFileMgr::Read(fileHandle, buf(&gString), 20); - CFileMgr::Read(fileHandle, buf(&gString), 4); - CFileMgr::Read(fileHandle, buf(&gString), 4); - CFileMgr::Read(fileHandle, buf(&gString), 1); - CFileMgr::Read(fileHandle, buf(&gString), 1); - CFileMgr::Read(fileHandle, buf(&gString), 1); + CFileMgr::Read(fileHandle, buf(gString), 20); + CFileMgr::Read(fileHandle, buf(gString), 20); + CFileMgr::Read(fileHandle, buf(gString), 4); + CFileMgr::Read(fileHandle, buf(gString), 4); + CFileMgr::Read(fileHandle, buf(gString), 1); + CFileMgr::Read(fileHandle, buf(gString), 1); + CFileMgr::Read(fileHandle, buf(gString), 1); CFileMgr::Read(fileHandle, buf(&TheCamera.m_bHeadBob), 1); CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), 4); CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), 4); @@ -1276,7 +1287,7 @@ void CMenuManager::PrintBriefs() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::PrintErrorMessage() { EAXJMP(0x484F70); } #else void CMenuManager::PrintErrorMessage() @@ -1309,157 +1320,180 @@ void CMenuManager::PrintStats() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) { - if (!m_bSaveMenuActive && TheCamera.GetScreenFadeStatus()) + field_112 = 0; + + if (!m_bSaveMenuActive && TheCamera.GetScreenFadeStatus() != FADE_0) return; - field_112 = 0; - m_bLanguageLoaded = false; + //m_bLanguageLoaded = false; //XXX m_bStartGameLoading = false; InitialiseChangedLanguageSettings(); - // + if (GetPadExitEnter()) //XXX only escape + RequestFrontEndStartUp(); + SwitchMenuOnAndOff(); // Be able to re-open menu correctly. - if (!m_bMenuActive) { - if (GetPadExitEnter()) - RequestFrontEndStartUp(); + if (m_bMenuActive) { - UnloadTextures(); - field_452 = 0; - SwitchToNewScreen(MENUPAGE_NONE); - pEditString = 0; - field_113 = 0; - return; - } - - // Load frontend textures. - LoadAllTextures(); + // Load frontend textures. + LoadAllTextures(); - // Set save/delete game pages. - if (m_nCurrScreen == MENUPAGE_DELETING) { - bool SlotPopulated = false; + // Set save/delete game pages. + if (m_nCurrScreen == MENUPAGE_DELETING) { + bool SlotPopulated = false; - if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { - PcSaveHelper.PopulateSlotInfo(); - SlotPopulated = true; - } + if (PcSaveHelper.DeleteSlot(m_nCurrSaveSlot)) { + PcSaveHelper.PopulateSlotInfo(); + SlotPopulated = true; + } - if (SlotPopulated) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else - SaveLoadFileError_SetUpErrorScreen(); - } - if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { - int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); - PcSaveHelper.PopulateSlotInfo(); - if (SaveSlot) { - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; - m_nCurrOption = 0; - m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); - } - else - SaveLoadFileError_SetUpErrorScreen(); - } - if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { - if (CheckSlotDataValid(m_nCurrSaveSlot)) { - TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; - if (m_PrefsVsyncDisp != m_PrefsVsync) - m_PrefsVsync = m_PrefsVsyncDisp; - DMAudio.Service(); - m_bStartGameLoading = 1; - RequestFrontEndShutdown(); - m_bLoadingSavedGame = 1; - b_FoundRecentSavedGameWantToLoad = 1; - DMAudio.SetEffectsFadeVol(0); - DMAudio.SetMusicFadeVol(0); - DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + if (SlotPopulated) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_DELETE_SUCCESS; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); } - else - SaveLoadFileError_SetUpErrorScreen(); - } - - ProcessButtonPresses(); - - // Set binding keys. - if (pEditString && !CPad::EditString(pEditString, 0)) { - if (!pEditString) - strcpy(pEditString, "NoName"); - pEditString = 0; - SaveSettings(); - } - - if (field_113) { - if ((m_nCurrScreen == MENUPAGE_13 || m_nCurrScreen == MENUPAGE_16) && CTimer::GetTimeInMillisecondsPauseMode() > field_558) - SwitchToNewScreen(m_nPrevScreen); - - // Reset pad shaking. - if (VibrationTime && CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { - CPad::GetPad(0)->StopPadsShaking(); - VibrationTime = 0; + if (m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS) { + int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); + PcSaveHelper.PopulateSlotInfo(); + if (SaveSlot) { + m_nPrevScreen = m_nCurrScreen; + m_nCurrScreen = MENUPAGE_SAVE_SUCCESSFUL; + m_nCurrOption = 0; + m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); + } + else + SaveLoadFileError_SetUpErrorScreen(); } - - if (m_bStartGameLoading) { - if (m_bGameNotLoaded) + if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { + if (CheckSlotDataValid(m_nCurrSaveSlot)) { + TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == 0; + if (m_PrefsVsyncDisp != m_PrefsVsync) + m_PrefsVsync = m_PrefsVsyncDisp; DMAudio.Service(); + m_bStartGameLoading = 1; + RequestFrontEndShutdown(); + m_bLoadingSavedGame = 1; + b_FoundRecentSavedGameWantToLoad = 1; + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + } + else + SaveLoadFileError_SetUpErrorScreen(); } - } - if (!field_456) { - JoyButtonJustClicked = 0; - CPad::EditCodesForControls(&pControlEdit, 0); - MouseButtonJustClicked = 0; + ProcessButtonPresses(); - if (GetMouseForward()) - MouseButtonJustClicked = 1; - else { - if (GetMouseBack()) - MouseButtonJustClicked = 3; + // Set binding keys. + if (pEditString && CPad::EditString(pEditString, 0) == nil) { + if (*pEditString == 0) + strcpy(pEditString, "NoName"); + pEditString = nil; + SaveSettings(); } - JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); + if (field_113 && !field_456) { + pControlEdit = CPad::EditCodesForControls(pControlEdit, 1); + JoyButtonJustClicked = 0; + MouseButtonJustClicked = 0; - if (JoyButtonJustClicked) - TypeOfControl = 3; - if (MouseButtonJustClicked) - TypeOfControl = 2; - if (pControlEdit != 1056) - TypeOfControl = 0; - - if (field_534) { - if (!m_bKeyChangeNotProcessed) { - if (pControlEdit != 1056 || MouseButtonJustClicked || JoyButtonJustClicked) + if (GetMouseClickLeft()) + MouseButtonJustClicked = 1; + else if (GetMouseClickRight()) + MouseButtonJustClicked = 3; + else if (GetMouseClickMiddle()) + MouseButtonJustClicked = 2; + else if (GetMouseWheelUp()) + MouseButtonJustClicked = 4; + else if (GetMouseWheelDown()) + MouseButtonJustClicked = 5; + //XXX two more buttons + + JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); + + if (JoyButtonJustClicked) + TypeOfControl = 3; + if (MouseButtonJustClicked) + TypeOfControl = 2; + if (*pControlEdit != rsNULL) + TypeOfControl = 0; + + if (!field_534) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); + pControlEdit = nil; + field_113 = 0; + m_KeyPressedCode = -1; + field_456 = 0; + } + else if (!m_bKeyChangeNotProcessed) { + if (*pControlEdit != rsNULL || MouseButtonJustClicked || JoyButtonJustClicked) CheckCodesForControls(TypeOfControl); field_535 = 1; - return; + } + else { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + for (int i = 0; i < 4; i++) + ControlsManager.ClearSettingsAssociatedWithAction(m_CurrCntrlAction, i); + field_534 = false; + m_bKeyChangeNotProcessed = false; + pControlEdit = nil; + field_113 = 0; + m_KeyPressedCode = -1; + field_456 = 0; } } - else { - pControlEdit = 0; - field_113 = 0; - m_KeyPressedCode = -1; + + if ((m_nCurrScreen == MENUPAGE_13 || m_nCurrScreen == MENUPAGE_16) && CTimer::GetTimeInMillisecondsPauseMode() > field_558) { + m_nCurrScreen = m_nPrevScreen; + m_nCurrOption = 0; } + + // Reset pad shaking. + if (VibrationTime && CTimer::GetTimeInMillisecondsPauseMode() > VibrationTime) { + CPad::StopPadsShaking(); + VibrationTime = 0; + } + } + else { + UnloadTextures(); + field_452 = 0; + // byte_5F33E4 = 1; // unused + m_nPrevScreen = 0; + m_nCurrScreen = m_nPrevScreen; + m_nCurrOption = 0; + pEditString = nil; + field_113 = 0; + } + + if (!m_bStartGameLoading) { + if (m_bGameNotLoaded) + DMAudio.Service(); } - field_456 = 0; } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else void CMenuManager::ProcessButtonPresses() { + if(pEditString) + return; + if(pControlEdit) + return; + // Update mouse position m_nMouseOldPosX = m_nMousePosX; m_nMouseOldPosY = m_nMousePosY; @@ -1500,7 +1534,7 @@ void CMenuManager::ProcessButtonPresses() field_113 = 1; field_456 = 1; m_bKeyChangeNotProcessed = 1; - //pControlEdit = m_KeyPressedCode; + pControlEdit = &m_KeyPressedCode; } if (GetPadForward()) { @@ -1509,7 +1543,7 @@ void CMenuManager::ProcessButtonPresses() if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { field_113 = 1; field_456 = 1; - //pControlEdit = m_KeyPressedCode; + pControlEdit = &m_KeyPressedCode; } if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { strcpy(m_PrefsSkinFile, m_aSkinName); @@ -1527,7 +1561,7 @@ void CMenuManager::ProcessButtonPresses() break; default: break; - }; + } } bool once = false; @@ -1604,7 +1638,7 @@ void CMenuManager::ProcessButtonPresses() SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); PlayEscSound = true; break; - }; + } if (PlayEscSound) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); @@ -1639,7 +1673,7 @@ void CMenuManager::ProcessButtonPresses() default: m_nHoverOption = HOVEROPTION_NULL; break; - }; + } } // Process all menu options here, but first check if it's an option or a redirect. @@ -1675,11 +1709,11 @@ void CMenuManager::ProcessButtonPresses() break; default: break; - }; + } } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); } #else void CMenuManager::ProcessOnOffMenuOptions() @@ -1740,7 +1774,7 @@ void CMenuManager::ProcessOnOffMenuOptions() case AR_16_9: m_PrefsUseWideScreen = AR_AUTO; break; - }; + } } else { switch (m_PrefsUseWideScreen) { @@ -1753,7 +1787,7 @@ void CMenuManager::ProcessOnOffMenuOptions() case AR_16_9: m_PrefsUseWideScreen = AR_4_3; break; - }; + } } #endif SaveSettings(); @@ -1999,7 +2033,7 @@ void CMenuManager::ProcessOnOffMenuOptions() case 2: m_PrefsSpeakers = 0; break; - }; + } } else { switch (m_PrefsSpeakers) { @@ -2012,7 +2046,7 @@ void CMenuManager::ProcessOnOffMenuOptions() case 2: m_PrefsSpeakers = 1; break; - }; + } } DMAudio.SetSpeakerConfig(m_PrefsSpeakers); @@ -2040,11 +2074,11 @@ void CMenuManager::ProcessOnOffMenuOptions() case MENUACTION_MOUSESTEER: m_bDisableMouseSteering = m_bDisableMouseSteering == false; return; - }; + } } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::RequestFrontEndShutdown() { EAXJMP(0x488750); } #else void CMenuManager::RequestFrontEndShutdown() @@ -2054,7 +2088,7 @@ void CMenuManager::RequestFrontEndShutdown() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::RequestFrontEndStartUp() { EAXJMP(0x488770); } #else void CMenuManager::RequestFrontEndStartUp() @@ -2063,7 +2097,7 @@ void CMenuManager::RequestFrontEndStartUp() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::ResetHelperText() { EAXJMP(0x48B470); } #else void CMenuManager::ResetHelperText() @@ -2073,7 +2107,7 @@ void CMenuManager::ResetHelperText() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::SaveLoadFileError_SetUpErrorScreen() { EAXJMP(0x488930); } #else void CMenuManager::SaveLoadFileError_SetUpErrorScreen() @@ -2116,8 +2150,8 @@ void CMenuManager::SaveLoadFileError_SetUpErrorScreen() } #endif -#if 0 -WRAPPER void CMenuManager::SetHelperText() { EAXJMP(0x48B450); } +#if ALL_ORIGINAL_FRONTEND +WRAPPER void CMenuManager::SetHelperText(int text) { EAXJMP(0x48B450); } #else void CMenuManager::SetHelperText(int text) { @@ -2126,7 +2160,7 @@ void CMenuManager::SetHelperText(int text) } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } #else void CMenuManager::SaveSettings() @@ -2173,7 +2207,7 @@ void CMenuManager::SaveSettings() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::ShutdownJustMenu() { EAXJMP(0x488920); } #else void CMenuManager::ShutdownJustMenu() @@ -2184,7 +2218,7 @@ void CMenuManager::ShutdownJustMenu() #endif // We won't ever use this again. -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER float CMenuManager::StretchX(float) { EAXJMP(0x48ABE0); } #else float CMenuManager::StretchX(float x) @@ -2196,7 +2230,7 @@ float CMenuManager::StretchX(float x) } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER float CMenuManager::StretchY(float) { EAXJMP(0x48AC20); } #else float CMenuManager::StretchY(float y) @@ -2208,7 +2242,7 @@ float CMenuManager::StretchY(float y) } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } #else void CMenuManager::SwitchMenuOnAndOff() @@ -2230,7 +2264,7 @@ void CMenuManager::SwitchMenuOnAndOff() ShutdownJustMenu(); SaveSettings(); m_bStartUpFrontEndRequested = false; - pControlEdit = 0; + pControlEdit = nil; m_bShutDownFrontEndRequested = false; DisplayComboButtonErrMsg = 0; CPad::GetPad(0)->Clear(0); @@ -2254,7 +2288,7 @@ void CMenuManager::SwitchMenuOnAndOff() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::UnloadTextures() { EAXJMP(0x47A440); } #else void CMenuManager::UnloadTextures() @@ -2279,7 +2313,7 @@ void CMenuManager::UnloadTextures() } #endif -#if 0 +#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); } #else void CMenuManager::WaitForUserCD() @@ -2307,7 +2341,7 @@ uint8 CMenuManager::GetNumberOfMenuOptions() break; ++Rows; - }; + } return Rows; } @@ -2406,7 +2440,7 @@ void CMenuManager::SetDefaultPreferences(int8 screen) CVehicle::m_bDisableMouseSteering = true; TheCamera.m_bHeadBob = false; break; - }; + } } // Frontend inputs. @@ -2464,18 +2498,47 @@ bool GetPadMoveRight() (CPad::GetPad(0)->NewState.LeftStickX > 0 && !(CPad::GetPad(0)->OldState.LeftStickX > 0)); } -bool GetMouseForward() +bool GetMouseClickLeft() { return (CPad::GetPad(0)->NewMouseControllerState.LMB && !CPad::GetPad(0)->OldMouseControllerState.LMB); } -bool GetMouseBack() +bool GetMouseClickRight() { return (CPad::GetPad(0)->NewMouseControllerState.RMB && !CPad::GetPad(0)->OldMouseControllerState.RMB); } +bool GetMouseClickMiddle() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.MMB && !CPad::GetPad(0)->OldMouseControllerState.MMB); +} + +bool GetMouseWheelUp() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP); +} + +bool GetMouseWheelDown() +{ + return + (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN); +} + + +bool GetMouseForward() +{ + return GetMouseClickLeft(); +} + +bool GetMouseBack() +{ + return GetMouseClickRight; +} + bool GetMousePos() { return @@ -2484,14 +2547,12 @@ bool GetMousePos() bool GetMouseMoveLeft() { - return - (CPad::GetPad(0)->NewMouseControllerState.WHEELDN && !CPad::GetPad(0)->OldMouseControllerState.WHEELDN != 0.0f); + return GetMouseWheelDown(); } bool GetMouseMoveRight() { - return - (CPad::GetPad(0)->NewMouseControllerState.WHEELUP && !CPad::GetPad(0)->OldMouseControllerState.WHEELUP != 0.0f); + return GetMouseWheelUp(); } bool GetPadInput() @@ -2516,6 +2577,7 @@ bool GetMouseInput() } STARTPATCHES +#ifndef ALL_ORIGINAL_FRONTEND InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); @@ -2526,4 +2588,5 @@ STARTPATCHES for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); +#endif ENDPATCHES \ No newline at end of file diff --git a/src/core/Frontend.h b/src/core/Frontend.h index ede036d2..9a3cdd50 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -448,7 +448,7 @@ public: int m_nCurrOption; int m_nPrevOption; int m_nPrevScreen; - int field_558; + uint32 field_558; int m_nCurrSaveSlot; int m_nScreenChangeDelayTimer; diff --git a/src/core/Text.cpp b/src/core/Text.cpp index b834a44d..dfa9815c 100644 --- a/src/core/Text.cpp +++ b/src/core/Text.cpp @@ -210,7 +210,48 @@ AsciiToUnicode(const char *src, uint16 *dst) while((*dst++ = *src++) != '\0'); } -WRAPPER char UnicodeToAscii(wchar * src) { EAXJMP(0x52C2F0); } +char* +UnicodeToAscii(wchar *src) +{ + static char aStr[256]; + int len; + for(len = 0; src && *src != 0 && len < 256-1; len++, src++) + if(*src < 256) + aStr[len] = *src; + else + aStr[len] = '#'; + aStr[len] = '\0'; + return aStr; +} + +char* +UnicodeToAsciiForSaveLoad(wchar *src) +{ + // exact same code as above + static char aStr[256]; + int len; + for(len = 0; src && *src != 0 && len < 256-1; len++, src++) + if(*src < 256) + aStr[len] = *src; + else + aStr[len] = '#'; + aStr[len] = '\0'; + return aStr; +} + +void +UnicodeStrcpy(wchar *dst, const wchar *src) +{ + while((*dst++ = *src++) != '\0'); +} + +int +UnicodeStrlen(const wchar *str) +{ + int len; + for(len = 0; *str != 0; len++, str++); + return len; +} void TextCopy(wchar *dst, const wchar *src) @@ -218,6 +259,7 @@ TextCopy(wchar *dst, const wchar *src) while((*dst++ = *src++) != '\0'); } + STARTPATCHES InjectHook(0x52C3C0, &CText::Load, PATCH_JUMP); InjectHook(0x52C580, &CText::Unload, PATCH_JUMP); diff --git a/src/core/Text.h b/src/core/Text.h index 15ab7a8f..f554628c 100644 --- a/src/core/Text.h +++ b/src/core/Text.h @@ -1,7 +1,10 @@ #pragma once void AsciiToUnicode(const char *src, wchar *dst); -char UnicodeToAscii(wchar *src); +char *UnicodeToAscii(wchar *src); +char *UnicodeToAsciiForSaveLoad(wchar *src); +void UnicodeStrcpy(wchar *dst, const wchar *src); +int UnicodeStrlen(const wchar *str); void TextCopy(wchar *dst, const wchar *src); struct CKeyEntry diff --git a/src/core/main.cpp b/src/core/main.cpp index e7f42780..9ac271f9 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -54,8 +54,14 @@ GlobalScene &Scene = *(GlobalScene*)0x726768; uint8 work_buff[55000]; -char gString[256]; +//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; bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8; diff --git a/src/core/main.h b/src/core/main.h index bdb0e008..dabc0f7b 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -8,8 +8,14 @@ struct GlobalScene extern GlobalScene &Scene; extern uint8 work_buff[55000]; -extern char gString[256]; +//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 bool &b_FoundRecentSavedGameWantToLoad; class CSprite2d; -- cgit v1.2.3 From 86681c6f18b5741ba25bbbb7319bb832ffa4807a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Wed, 10 Jul 2019 09:06:43 +0300 Subject: Phone start, ped spinning and cop car fix, and some love to CPed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: eray orçunus --- src/core/World.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/core/World.h | 4 ++- 2 files changed, 81 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/World.cpp b/src/core/World.cpp index 538e15c5..a31f87a7 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -564,6 +564,82 @@ CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bo return true; } +void +CWorld::FindObjectsInRangeSectorList(CPtrList &list, CVector ¢re, float distance, bool ignoreZ, short *nextObject, short lastObject, CEntity **objects) +{ + float distSqr = distance * distance; + float objDistSqr; + + for (CPtrNode *node = list.first; node; node = node->next) { + CEntity *object = (CEntity*)node->item; + if (object->m_scanCode != CWorld::GetCurrentScanCode()) { + object->m_scanCode = CWorld::GetCurrentScanCode(); + + CVector diff = centre - object->GetPosition(); + if (ignoreZ) + objDistSqr = diff.MagnitudeSqr2D(); + else + objDistSqr = diff.MagnitudeSqr(); + + if (objDistSqr < distSqr && *nextObject < lastObject) { + if (objects) { + objects[*nextObject] = object; + } + (*nextObject)++; + } + } + } +} + +void +CWorld::FindObjectsInRange(CVector ¢re, float distance, bool ignoreZ, short *nextObject, short lastObject, CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies) +{ + int minX = GetSectorIndexX(centre.x - distance); + if (minX <= 0) + minX = 0; + + int minY = GetSectorIndexY(centre.y - distance); + if (minY <= 0) + minY = 0; + + int maxX = GetSectorIndexX(centre.x + distance); + if (maxX >= 100) + maxX = 100; + + int maxY = GetSectorIndexY(centre.y + distance); + if (maxY >= 100) + maxY = 100; + + AdvanceCurrentScanCode(); + + *nextObject = 0; + for(int curY = minY; curY <= maxY; curY++) { + for(int curX = minX; curX <= maxX; curX++) { + CSector *sector = GetSector(curX, curY); + if (checkBuildings) { + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS], centre, distance, ignoreZ, nextObject, lastObject, objects); + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], centre, distance, ignoreZ, nextObject, lastObject, objects); + } + if (checkVehicles) { + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES], centre, distance, ignoreZ, nextObject, lastObject, objects); + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], centre, distance, ignoreZ, nextObject, lastObject, objects); + } + if (checkPeds) { + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS], centre, distance, ignoreZ, nextObject, lastObject, objects); + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS_OVERLAP], centre, distance, ignoreZ, nextObject, lastObject, objects); + } + if (checkObjects) { + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS], centre, distance, ignoreZ, nextObject, lastObject, objects); + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], centre, distance, ignoreZ, nextObject, lastObject, objects); + } + if (checkDummies) { + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES], centre, distance, ignoreZ, nextObject, lastObject, objects); + CWorld::FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], centre, distance, ignoreZ, nextObject, lastObject, objects); + } + } + } +} + float CWorld::FindGroundZForCoord(float x, float y) { @@ -712,6 +788,8 @@ STARTPATCHES 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(0x4B3A80, CWorld::FindGroundZForCoord, PATCH_JUMP); InjectHook(0x4B3AE0, CWorld::FindGroundZFor3DCoord, PATCH_JUMP); InjectHook(0x4B3B50, CWorld::FindRoofZFor3DCoord, PATCH_JUMP); diff --git a/src/core/World.h b/src/core/World.h index 3b7090da..d6063d70 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -93,7 +93,9 @@ public: static bool GetIsLineOfSightClear(const CVector &point1, const CVector &point2, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false); static bool GetIsLineOfSightSectorClear(CSector §or, const CColLine &line, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects = false); static bool GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bool ignoreSeeThrough, bool ignoreSomeObjects = false); - + + 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 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); -- cgit v1.2.3 From 4a36d64f15f898854bb8a76be86ac9a8c536b291 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:18:26 +0200 Subject: added wrappers around math functions --- src/core/Camera.cpp | 56 ++++++++++++++++++++++++------------------------- src/core/Collision.cpp | 20 +++++++++--------- src/core/FileLoader.cpp | 6 +++--- src/core/General.h | 24 ++++++++++----------- src/core/Pad.cpp | 22 +++++++++---------- src/core/Radar.cpp | 20 +++++++++--------- src/core/Streaming.cpp | 10 ++++----- src/core/common.h | 1 + 8 files changed, 80 insertions(+), 79 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 4f565897..4e988c15 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -170,9 +170,9 @@ WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSp float TargetSpeed = Delta * MaxSpeed; // Add or subtract absolute depending on sign, genius! // if(TargetSpeed - *CurrentSpeed > 0.0f) -// *CurrentSpeed += Acceleration * fabs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep(); +// *CurrentSpeed += Acceleration * Abs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep(); // else -// *CurrentSpeed -= Acceleration * fabs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep(); +// *CurrentSpeed -= Acceleration * Abs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep(); // this is simpler: *CurrentSpeed += Acceleration * (TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep(); @@ -249,14 +249,14 @@ CCam::GetPedBetaAngleForClearView(const CVector &Target, float Dist, float BetaO for(a = 0.0f; a <= PI; a += DEGTORAD(5.0f)){ if(BetaOffset <= 0.0f){ - ToSource = CVector(cos(Beta + BetaOffset + a), sin(Beta + BetaOffset + a), 0.0f)*Dist; + ToSource = CVector(Cos(Beta + BetaOffset + a), Sin(Beta + BetaOffset + a), 0.0f)*Dist; if(!CWorld::ProcessLineOfSight(Target, Target + ToSource, point, ent, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, true, true)) return a; } if(BetaOffset >= 0.0f){ - ToSource = CVector(cos(Beta + BetaOffset - a), sin(Beta + BetaOffset - a), 0.0f)*Dist; + ToSource = CVector(Cos(Beta + BetaOffset - a), Sin(Beta + BetaOffset - a), 0.0f)*Dist; if(!CWorld::ProcessLineOfSight(Target, Target + ToSource, point, ent, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, true, true)) @@ -500,7 +500,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl CVector PlayerPos = FindPlayerPed()->GetPosition(); float RotationDist = (AngleToGoTo == Center ? CenterDist : LateralDist) * RealGroundDist; // What's going on here? - AngleToGoTo? - CVector RotatedSource = PlayerPos + CVector(cos(Beta - AngleToGoTo), sin(Beta - AngleToGoTo), 0.0f) * RotationDist; + CVector RotatedSource = PlayerPos + CVector(Cos(Beta - AngleToGoTo), Sin(Beta - AngleToGoTo), 0.0f) * RotationDist; CColPoint colpoint; CEntity *entity; @@ -584,9 +584,9 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl float ReqSpeed = DeltaBeta * MaxSpeed; // Add or subtract absolute depending on sign, genius! if(ReqSpeed - BetaSpeed > 0.0f) - BetaSpeed += SpeedStep * fabs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep(); + BetaSpeed += SpeedStep * Abs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep(); else - BetaSpeed -= SpeedStep * fabs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep(); + BetaSpeed -= SpeedStep * Abs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep(); // this would be simpler: // BetaSpeed += SpeedStep * (ReqSpeed - BetaSpeed) * CTimer::ms_fTimeStep; @@ -604,14 +604,14 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl BetaSpeed = 0.0f; } - Source.x = TargetCoors.x + Distance * cos(Beta); - Source.y = TargetCoors.y + Distance * sin(Beta); + Source.x = TargetCoors.x + Distance * Cos(Beta); + Source.y = TargetCoors.y + Distance * Sin(Beta); // Check if we can stop rotating DeltaBeta = FixedTargetOrientation - Beta; while(DeltaBeta >= PI) DeltaBeta -= 2*PI; while(DeltaBeta < -PI) DeltaBeta += 2*PI; - if(fabs(DeltaBeta) < DEGTORAD(1.0f) && !bBehindPlayerDesired){ + if(Abs(DeltaBeta) < DEGTORAD(1.0f) && !bBehindPlayerDesired){ // Stop rotation PickedASide = false; Rotating = false; @@ -624,18 +624,18 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl HackPlayerOnStoppingTrain || Rotating){ if(TheCamera.m_bCamDirectlyBehind){ Beta = TargetOrientation + PI; - Source.x = TargetCoors.x + Distance * cos(Beta); - Source.y = TargetCoors.y + Distance * sin(Beta); + Source.x = TargetCoors.x + Distance * Cos(Beta); + Source.y = TargetCoors.y + Distance * Sin(Beta); } if(TheCamera.m_bCamDirectlyInFront){ Beta = TargetOrientation; - Source.x = TargetCoors.x + Distance * cos(Beta); - Source.y = TargetCoors.y + Distance * sin(Beta); + Source.x = TargetCoors.x + Distance * Cos(Beta); + Source.y = TargetCoors.y + Distance * Sin(Beta); } if(HackPlayerOnStoppingTrain){ Beta = TargetOrientation + PI; - Source.x = TargetCoors.x + Distance * cos(Beta); - Source.y = TargetCoors.y + Distance * sin(Beta); + Source.x = TargetCoors.x + Distance * Cos(Beta); + Source.y = TargetCoors.y + Distance * Sin(Beta); m_fDimensionOfHighestNearCar = 0.0f; m_fCamBufferedHeight = 0.0f; m_fCamBufferedHeightSpeed = 0.0f; @@ -904,7 +904,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa while(deltaBeta >= PI) deltaBeta -= 2*PI; while(deltaBeta < -PI) deltaBeta += 2*PI; - float BehindCarNess = cos(deltaBeta); // 1 if behind car, 0 if side, -1 if in front + float BehindCarNess = Cos(deltaBeta); // 1 if behind car, 0 if side, -1 if in front CarAlpha = -CarAlpha * BehindCarNess; if(CarAlpha < -0.01f) CarAlpha = -0.01f; @@ -939,8 +939,8 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa Forward = CamTargetEntity->GetForward(); // we actually still have that... Forward.Normalise(); // shouldn't be necessary float CarSideAngle = CGeneral::GetATanOfXY(Forward.x, Forward.y) + PI/2.0f; - float SideX = 2.5f * cos(CarSideAngle); - float SideY = 2.5f * sin(CarSideAngle); + float SideX = 2.5f * Cos(CarSideAngle); + float SideY = 2.5f * Sin(CarSideAngle); CWorld::FindRoofZFor3DCoord(TargetCoors.x + SideX, TargetCoors.y + SideY, CarBottom, &FoundRoofSide1); CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2); @@ -1042,7 +1042,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa WellBufferMe(LastTargetAlphaWithCollisionOn, &Alpha, &AlphaSpeed, LastTopAlphaSpeed, LastAlphaSpeedStep, true); - Source.z = TargetCoors.z + sin(Alpha + ModeAlpha)*Length + m_fCloseInCarHeightOffset; + Source.z = TargetCoors.z + Sin(Alpha + ModeAlpha)*Length + m_fCloseInCarHeightOffset; } // Rotate cam behind the car when the car is moving forward @@ -1062,7 +1062,7 @@ CCam::RotCamIfInFrontCar(CVector &TargetCoors, float TargetOrientation) while(DeltaBeta >= PI) DeltaBeta -= 2*PI; while(DeltaBeta < -PI) DeltaBeta += 2*PI; - if(fabs(DeltaBeta) > DEGTORAD(20.0f) && MovingForward && TheCamera.m_uiTransitionState == 0) + if(Abs(DeltaBeta) > DEGTORAD(20.0f) && MovingForward && TheCamera.m_uiTransitionState == 0) m_bFixingBeta = true; CPad *pad = CPad::GetPad(0); @@ -1088,14 +1088,14 @@ CCam::RotCamIfInFrontCar(CVector &TargetCoors, float TargetOrientation) if(TheCamera.m_bUseTransitionBeta && &TheCamera.Cams[TheCamera.ActiveCam] == this) Beta = m_fTransitionBeta; - Source.x = TargetCoors.x - cos(Beta)*Dist; - Source.y = TargetCoors.y - sin(Beta)*Dist; + Source.x = TargetCoors.x - Cos(Beta)*Dist; + Source.y = TargetCoors.y - Sin(Beta)*Dist; // Check if we're done DeltaBeta = TargetOrientation - Beta; while(DeltaBeta >= PI) DeltaBeta -= 2*PI; while(DeltaBeta < -PI) DeltaBeta += 2*PI; - if(fabs(DeltaBeta) < DEGTORAD(2.0f)) + if(Abs(DeltaBeta) < DEGTORAD(2.0f)) m_bFixingBeta = false; } TheCamera.m_bCamDirectlyBehind = false; @@ -1157,14 +1157,14 @@ CCam::FixCamIfObscured(CVector &TargetCoors, float TargetHeight, float TargetOri return false; if(Fix1){ - Source.x = Target.x - cos(Beta)*Dist1; - Source.y = Target.y - sin(Beta)*Dist1; + Source.x = Target.x - Cos(Beta)*Dist1; + Source.y = Target.y - Sin(Beta)*Dist1; if(Mode == MODE_BEHINDCAR) Source = colPoint.point; }else{ WellBufferMe(Dist2, &m_fDistanceBeforeChanges, &DistanceSpeed, 0.2f, 0.025f, false); - Source.x = Target.x - cos(Beta)*m_fDistanceBeforeChanges; - Source.y = Target.y - sin(Beta)*m_fDistanceBeforeChanges; + Source.x = Target.x - Cos(Beta)*m_fDistanceBeforeChanges; + Source.y = Target.y - Sin(Beta)*m_fDistanceBeforeChanges; } if(ResetStatics){ diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 94da1338..6241b79a 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -457,7 +457,7 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph) // I leave in the strange -2 factors even though they serve no real purpose float projline = -2.0f * DotProduct(v01, v0c); // project v0c onto line // Square of tangent from p0 multiplied by line length so we can compare with projline. - // The length of the tangent would be this: sqrt((c-p0)^2 - r^2). + // The length of the tangent would be this: Sqrt((c-p0)^2 - r^2). // Negative if p0 is inside the sphere! This breaks the test! float tansq = 4.0f * linesq * (sph.center.MagnitudeSqr() - 2.0f*DotProduct(sph.center, line.p0) + line.p0.MagnitudeSqr() - sph.radius*sph.radius); @@ -467,10 +467,10 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph) return false; // projline (negative in GTA for some reason) is the point on the line // in the middle of the two intersection points (startin from p0). - // sqrt(diffsq) somehow works out to be the distance from that + // Sqrt(diffsq) somehow works out to be the distance from that // midpoint to the intersection points. // So subtract that and get rid of the awkward scaling: - float f = (-projline - sqrt(diffsq)) / (2.0f*linesq); + float f = (-projline - Sqrt(diffsq)) / (2.0f*linesq); // f should now be in range [0, 1] for [p0, p1] return f >= 0.0f && f <= 1.0f; } @@ -480,7 +480,7 @@ CCollision::TestSphereTriangle(const CColSphere &sphere, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane) { // If sphere and plane don't intersect, no collision - if(fabs(plane.CalcPoint(sphere.center)) > sphere.radius) + if(Abs(plane.CalcPoint(sphere.center)) > sphere.radius) return false; const CVector &va = verts[tri.a]; @@ -669,7 +669,7 @@ CCollision::ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoin dist = sph.center - p; float lensq = dist.MagnitudeSqr(); if(lensq < mindistsq){ - float len = sqrt(lensq); + float len = Sqrt(lensq); point.point = p; point.normal = dist * (1.0f/len); point.surfaceA = sph.surface; @@ -816,7 +816,7 @@ CCollision::ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CC if(diffsq < 0.0f) return false; // point of first intersection, in range [0,1] between p0 and p1 - float t = (projline - sqrt(diffsq)) / linesq; + float t = (projline - Sqrt(diffsq)) / linesq; // if not on line or beyond mindist, no intersection if(t < 0.0f || t > 1.0f || t >= mindist) return false; @@ -1010,7 +1010,7 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere, // If sphere and plane don't intersect, no collision float planedist = plane.CalcPoint(sphere.center); float distsq = planedist*planedist; - if(fabs(planedist) > sphere.radius || distsq > mindistsq) + if(Abs(planedist) > sphere.radius || distsq > mindistsq) return false; const CVector &va = verts[tri.a]; @@ -1057,7 +1057,7 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere, else assert(0); }else if(testcase == 3){ // center is in triangle - dist = fabs(planedist); + dist = Abs(planedist); p = sphere.center - normal*planedist; }else assert(0); // front fell off @@ -1333,7 +1333,7 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin if(dot >= lensq) return (*point - *l1).Magnitude(); // distance to line - return sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq); + return Sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq); } // same as above but also return the point on the line @@ -1641,7 +1641,7 @@ CColTrianglePlane::Set(const CVector *v, CColTriangle &tri) normal = CrossProduct(vc-va, vb-va); normal.Normalise(); dist = DotProduct(normal, va); - CVector an(fabs(normal.x), fabs(normal.y), fabs(normal.z)); + CVector an(Abs(normal.x), Abs(normal.y), Abs(normal.z)); // find out largest component and its direction if(an.x > an.y && an.x > an.z) dir = normal.x < 0.0f ? DIR_X_NEG : DIR_X_POS; diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index b949eb98..0c53ae66 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -262,9 +262,9 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector)); for(i = 0; i < numVertices; i++){ model.vertices[i] = *(CVector*)buf; - if(fabs(model.vertices[i].x) >= 256.0f || - fabs(model.vertices[i].y) >= 256.0f || - fabs(model.vertices[i].z) >= 256.0f) + if(Abs(model.vertices[i].x) >= 256.0f || + Abs(model.vertices[i].y) >= 256.0f || + Abs(model.vertices[i].z) >= 256.0f) printf("%s:Collision volume too big\n", modelname); buf += 12; } diff --git a/src/core/General.h b/src/core/General.h index cae1caa0..a08b622b 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -6,32 +6,32 @@ public: static float GetATanOfXY(float x, float y){ if(x == 0.0f && y == 0.0f) return 0.0f; - float xabs = fabs(x); - float yabs = fabs(y); + float xabs = Abs(x); + float yabs = Abs(y); if(xabs < yabs){ if(y > 0.0f){ if(x > 0.0f) - return 0.5f*PI - atan2(x / y, 1.0f); + return 0.5f*PI - Atan2(x / y, 1.0f); else - return 0.5f*PI + atan2(-x / y, 1.0f); + return 0.5f*PI + Atan2(-x / y, 1.0f); }else{ if(x > 0.0f) - return 1.5f*PI + atan2(x / -y, 1.0f); + return 1.5f*PI + Atan2(x / -y, 1.0f); else - return 1.5f*PI - atan2(-x / -y, 1.0f); + return 1.5f*PI - Atan2(-x / -y, 1.0f); } }else{ if(y > 0.0f){ if(x > 0.0f) - return atan2(y / x, 1.0f); + return Atan2(y / x, 1.0f); else - return PI - atan2(y / -x, 1.0f); + return PI - Atan2(y / -x, 1.0f); }else{ if(x > 0.0f) - return 2.0f*PI - atan2(-y / x, 1.0f); + return 2.0f*PI - Atan2(-y / x, 1.0f); else - return PI + atan2(-y / -x, 1.0f); + return PI + Atan2(-y / -x, 1.0f); } } } @@ -68,12 +68,12 @@ public: if (x > 0.0f) { if (y > 0.0f) - return PI - atan2(x / y, 1.0f); + return PI - Atan2(x / y, 1.0f); else return -atan2(x / y, 1.0f); } else { if (y > 0.0f) - return -(PI + atan2(x / y, 1.0f)); + return -(PI + Atan2(x / y, 1.0f)); else return -atan2(x / y, 1.0f); } diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 002e7180..9c5e1c8a 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -670,7 +670,7 @@ int16 CPad::GetSteeringLeftRight(void) int16 axis = NewState.LeftStickX; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -703,7 +703,7 @@ int16 CPad::GetSteeringUpDown(void) int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -790,7 +790,7 @@ int16 CPad::GetPedWalkLeftRight(void) int16 axis = NewState.LeftStickX; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -824,7 +824,7 @@ int16 CPad::GetPedWalkUpDown(void) int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -854,7 +854,7 @@ int16 CPad::GetAnalogueUpDown(void) int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -1683,7 +1683,7 @@ int16 CPad::SniperModeLookLeftRight(void) int16 axis = NewState.LeftStickX; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -1694,7 +1694,7 @@ int16 CPad::SniperModeLookUpDown(void) int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; - if ( abs(axis) > abs(dpad) ) + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; @@ -1704,11 +1704,11 @@ int16 CPad::LookAroundLeftRight(void) { float axis = GetPad(0)->NewState.RightStickX; - if ( fabs(axis) > 85 && !GetLookBehindForPed() ) + if ( Abs(axis) > 85 && !GetLookBehindForPed() ) return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) ) * (127.0f / 32.0f) ); // 3.96875f - else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && fabs(axis) > 10 ) + else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && Abs(axis) > 10 ) return (int16) ( (axis + ( ( axis > 0 ) ? -10 : 10) ) * (127.0f / 64.0f) ); // 1.984375f @@ -1719,11 +1719,11 @@ int16 CPad::LookAroundUpDown(void) { int16 axis = GetPad(0)->NewState.RightStickY; - if ( abs(axis) > 85 && !GetLookBehindForPed() ) + if ( Abs(axis) > 85 && !GetLookBehindForPed() ) return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) ) * (127.0f / 32.0f) ); // 3.96875f - else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && abs(axis) > 40 ) + else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && Abs(axis) > 40 ) return (int16) ( (axis + ( ( axis > 0 ) ? -40 : 40) ) * (127.0f / 64.0f) ); // 1.984375f diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index a071b96b..b634e4f5 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -469,8 +469,8 @@ void CRadar::DrawRadarMask() // Then generate a quarter of the circle for (int j = 0; j < 7; j++) { - in.x = corners[i].x * cos(j * (PI / 2.0f / 6.0f)); - in.y = corners[i].y * sin(j * (PI / 2.0f / 6.0f)); + in.x = corners[i].x * Cos(j * (PI / 2.0f / 6.0f)); + in.y = corners[i].y * Sin(j * (PI / 2.0f / 6.0f)); TransformRadarPointToScreenSpace(out[j + 1], in); }; @@ -562,8 +562,8 @@ void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float for (uint32 i = 0; i < 4; i++) { oldPosn[i] = curPosn[i]; - curPosn[i].x = x + (oldPosn[i].x - x) * cosf(angle) + (oldPosn[i].y - y) * sinf(angle); - curPosn[i].y = y - (oldPosn[i].x - x) * sinf(angle) + (oldPosn[i].y - y) * cosf(angle); + curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle); + curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle); } sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha)); @@ -869,7 +869,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D float s, c; s = -sin(TheCamera.GetForward().Heading()); - c = cos(TheCamera.GetForward().Heading()); + c = Cos(TheCamera.GetForward().Heading()); if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN1 || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWNPED) { s = 0.0f; @@ -886,7 +886,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind; s = -sin(forward.Heading()); - c = cos(forward.Heading()); + c = Cos(forward.Heading()); } out.x = s * in.y + c * in.x; @@ -915,8 +915,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D c = 1.0f; } else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) { - s = sin(TheCamera.GetForward().Heading()); - c = cos(TheCamera.GetForward().Heading()); + s = Sin(TheCamera.GetForward().Heading()); + c = Cos(TheCamera.GetForward().Heading()); } else { CVector forward; @@ -928,8 +928,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D else forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind; - s = sin(forward.Heading()); - c = cos(forward.Heading()); + s = Sin(forward.Heading()); + c = Cos(forward.Heading()); } float x = (in.x - vec2DRadarOrigin.x) * (1.0f / m_RadarRange); diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index f8ab19d4..a23e35be 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -2131,8 +2131,8 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos) for(x = 0; x < NUMSECTORS_X; x++) for(y = 0; y < NUMSECTORS_Y; y++) - if(fabs(ix - x) > 3.0f && - fabs(iy - y) > 3.0f){ + if(Abs(ix - x) > 3.0f && + Abs(iy - y) > 3.0f){ sect = CWorld::GetSector(x, y); DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS]); DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]); @@ -2158,7 +2158,7 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem) ix = CWorld::GetSectorIndexX(TheCamera.GetPosition().x); iy = CWorld::GetSectorIndexX(TheCamera.GetPosition().y); - if(fabs(TheCamera.GetForward().x) > fabs(TheCamera.GetForward().y)){ + if(Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y)){ // looking west/east ymin = max(iy - 10, 0); @@ -2312,13 +2312,13 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y) e = (CEntity*)node->item; if(e->m_rwObject && !e->bStreamingDontDelete && !e->bImBeingRendered){ // Now this is pretty weird... - if(fabs(CWorld::GetSectorIndexX(e->GetPosition().x) - x) >= 2.0f) + if(Abs(CWorld::GetSectorIndexX(e->GetPosition().x) - x) >= 2.0f) // { e->DeleteRwObject(); // return; // BUG? // } else // FIX? - if(fabs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f) + if(Abs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f) e->DeleteRwObject(); } } diff --git a/src/core/common.h b/src/core/common.h index 79626acb..e5702a2f 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -97,6 +97,7 @@ extern void **rwengine; #define SCREEN_SCALE_AR(a) (a) #endif +#include "math/maths.h" #include "math/Vector.h" #include "math/Vector2D.h" #include "math/Matrix.h" -- cgit v1.2.3 From 90e093cd47fb2af10617b1d404fc65ca813782ec Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:34:11 +0200 Subject: and of course the last commit didnt fix everything --- src/core/Camera.cpp | 14 +++++++------- src/core/Collision.cpp | 2 +- src/core/General.h | 4 ++-- src/core/Radar.cpp | 4 ++-- src/core/main.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 4e988c15..c06ee48b 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -355,8 +355,8 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl // TODO: what's transition beta? if(TheCamera.m_bUseTransitionBeta && ResetStatics){ CVector VecDistance; - IdealSource.x = TargetCoors.x + GroundDist*cos(m_fTransitionBeta); - IdealSource.y = TargetCoors.y + GroundDist*sin(m_fTransitionBeta); + IdealSource.x = TargetCoors.x + GroundDist*Cos(m_fTransitionBeta); + IdealSource.y = TargetCoors.y + GroundDist*Sin(m_fTransitionBeta); Beta = CGeneral::GetATanOfXY(IdealSource.x - TargetCoors.x, IdealSource.y - TargetCoors.y); }else Beta = CGeneral::GetATanOfXY(Source.x - TargetCoors.x, Source.y - TargetCoors.y); @@ -799,7 +799,7 @@ CCam::WorkOutCamHeightWeeCar(CVector &TargetCoors, float TargetOrientation) if(CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) AlphaTarget = DEGTORAD(14.0f); WellBufferMe(AlphaTarget, &Alpha, &AlphaSpeed, 0.1f, 0.05f, true); - Source.z = TargetCoors.z + CA_MAX_DISTANCE*sin(Alpha); + Source.z = TargetCoors.z + CA_MAX_DISTANCE*Sin(Alpha); if(FindPlayerVehicle()){ m_fUnknownZOffSet = 0.0f; @@ -945,7 +945,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2); // Now find out at what height we'd like to place the camera - float CamGround = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, TargetCoors.z + Length*sin(Alpha + ModeAlpha) + m_fCloseInCarHeightOffset, &FoundCamGround); + float CamGround = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, TargetCoors.z + Length*Sin(Alpha + ModeAlpha) + m_fCloseInCarHeightOffset, &FoundCamGround); float CamTargetZ = 0.0f; if(FoundCamGround){ // This is the normal case @@ -992,7 +992,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa } // Now do things if CamClear...but what is that anyway? - float CamZ = TargetCoors.z + Length*sin(Alpha + DeltaAlpha + ModeAlpha) + m_fCloseInCarHeightOffset; + float CamZ = TargetCoors.z + Length*Sin(Alpha + DeltaAlpha + ModeAlpha) + m_fCloseInCarHeightOffset; bool FoundGround, FoundRoof; float CamGround2 = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, CamZ, &FoundGround); if(FoundGround){ @@ -1138,8 +1138,8 @@ CCam::FixCamIfObscured(CVector &TargetCoors, float TargetHeight, float TargetOri Obscured1 = CWorld::ProcessLineOfSight(EntityPos, TempSource, colPoint, ent, true, false, false, true, false, true, true); }else if(m_bFixingBeta){ float d = (TempSource - Target).Magnitude(); - TempSource.x = Target.x - d*cos(TargetOrientation); - TempSource.y = Target.y - d*sin(TargetOrientation); + TempSource.x = Target.x - d*Cos(TargetOrientation); + TempSource.y = Target.y - d*Sin(TargetOrientation); // same check again Obscured2 = CWorld::ProcessLineOfSight(Target, TempSource, colPoint, ent, true, false, false, true, false, true, true); diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 6241b79a..1ed08867 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -627,7 +627,7 @@ CCollision::ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoin dist = sph.center - p; float lensq = dist.MagnitudeSqr(); if(lensq < mindistsq){ - point.normal = dist * (1.0f/sqrt(lensq)); + point.normal = dist * (1.0f/Sqrt(lensq)); point.point = sph.center - point.normal; point.surfaceA = sph.surface; point.pieceA = sph.piece; diff --git a/src/core/General.h b/src/core/General.h index a08b622b..64613478 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -70,12 +70,12 @@ public: if (y > 0.0f) return PI - Atan2(x / y, 1.0f); else - return -atan2(x / y, 1.0f); + return -Atan2(x / y, 1.0f); } else { if (y > 0.0f) return -(PI + Atan2(x / y, 1.0f)); else - return -atan2(x / y, 1.0f); + return -Atan2(x / y, 1.0f); } } diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index b634e4f5..ea7a7ffa 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -868,7 +868,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D { float s, c; - s = -sin(TheCamera.GetForward().Heading()); + s = -Sin(TheCamera.GetForward().Heading()); c = Cos(TheCamera.GetForward().Heading()); if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN1 || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWNPED) { @@ -885,7 +885,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D else forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind; - s = -sin(forward.Heading()); + s = -Sin(forward.Heading()); c = Cos(forward.Heading()); } diff --git a/src/core/main.cpp b/src/core/main.cpp index 9ac271f9..ffde80bb 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -48,7 +48,7 @@ #include "RpAnimBlend.h" #include "Frontend.h" -#define DEFAULT_VIEWWINDOW (tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) +#define DEFAULT_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) GlobalScene &Scene = *(GlobalScene*)0x726768; -- cgit v1.2.3 From f1951acd6ecb2bedf51ce748637ad28d0ad70d7c Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 22:57:19 +0200 Subject: tried to fix CMenuManager::Process but still issues --- src/core/Frontend.cpp | 116 ++++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 56 deletions(-) (limited to 'src/core') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index a846efc6..77666b12 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -64,15 +64,14 @@ CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; float lodMultiplier = *(float*)0x5F726C; // Stuff not in CMenuManager: -uint32 VibrationTime; +uint32 &VibrationTime = *(uint32*)0x628CF8; char* pEditString = (char*)0x628D00; int32 *&pControlEdit = *(int32**)0x628D08; -int8 DisplayComboButtonErrMsg; -int8 MouseButtonJustClicked; -int8 JoyButtonJustClicked; +bool &DisplayComboButtonErrMsg = *(bool*)0x628D14; +int32 &MouseButtonJustClicked = *(int32*)0x628D0C; +int32 &JoyButtonJustClicked = *(int32*)0x628D10; int32 &nTimeForSomething = *(int32*)0x628D54; -int32 TypeOfControl = 0; -int32 *pControlTemp = 0; +//int32 *pControlTemp = 0; // Frontend inputs. @@ -164,7 +163,7 @@ void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* st else sprintf(gString2, " %d %s %d", *(int*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(int*)stat2); } - else if (stat2) { + else if (stat) { if (aFloat) sprintf(gString2, " %.2f", *stat); else @@ -1330,11 +1329,10 @@ void CMenuManager::Process(void) if (!m_bSaveMenuActive && TheCamera.GetScreenFadeStatus() != FADE_0) return; - //m_bLanguageLoaded = false; //XXX m_bStartGameLoading = false; InitialiseChangedLanguageSettings(); - if (GetPadExitEnter()) //XXX only escape + if (CPad::GetPad(0)->GetEscapeJustDown()) RequestFrontEndStartUp(); SwitchMenuOnAndOff(); @@ -1403,55 +1401,60 @@ void CMenuManager::Process(void) SaveSettings(); } - if (field_113 && !field_456) { - pControlEdit = CPad::EditCodesForControls(pControlEdit, 1); - JoyButtonJustClicked = 0; - MouseButtonJustClicked = 0; - - if (GetMouseClickLeft()) - MouseButtonJustClicked = 1; - else if (GetMouseClickRight()) - MouseButtonJustClicked = 3; - else if (GetMouseClickMiddle()) - MouseButtonJustClicked = 2; - else if (GetMouseWheelUp()) - MouseButtonJustClicked = 4; - else if (GetMouseWheelDown()) - MouseButtonJustClicked = 5; - //XXX two more buttons - - JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); - - if (JoyButtonJustClicked) - TypeOfControl = 3; - if (MouseButtonJustClicked) - TypeOfControl = 2; - if (*pControlEdit != rsNULL) - TypeOfControl = 0; - - if (!field_534) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); - pControlEdit = nil; - field_113 = 0; - m_KeyPressedCode = -1; + if (field_113) { + if (field_456) field_456 = 0; - } - else if (!m_bKeyChangeNotProcessed) { - if (*pControlEdit != rsNULL || MouseButtonJustClicked || JoyButtonJustClicked) - CheckCodesForControls(TypeOfControl); - - field_535 = 1; - } else { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - for (int i = 0; i < 4; i++) - ControlsManager.ClearSettingsAssociatedWithAction(m_CurrCntrlAction, i); - field_534 = false; - m_bKeyChangeNotProcessed = false; - pControlEdit = nil; - field_113 = 0; - m_KeyPressedCode = -1; - field_456 = 0; + pControlEdit = CPad::EditCodesForControls(pControlEdit, 1); + JoyButtonJustClicked = 0; + MouseButtonJustClicked = 0; + + if (GetMouseClickLeft()) + MouseButtonJustClicked = 1; + else if (GetMouseClickRight()) + MouseButtonJustClicked = 3; + else if (GetMouseClickMiddle()) + MouseButtonJustClicked = 2; + else if (GetMouseWheelUp()) + MouseButtonJustClicked = 4; + else if (GetMouseWheelDown()) + MouseButtonJustClicked = 5; + //XXX two more buttons + + JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); + + int32 TypeOfControl = 0; + if (JoyButtonJustClicked) + TypeOfControl = 3; + if (MouseButtonJustClicked) + TypeOfControl = 2; + if (*pControlEdit != rsNULL) + TypeOfControl = 0; + + if (!field_534) { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); + pControlEdit = nil; + field_113 = 0; + m_KeyPressedCode = -1; + field_456 = 0; + } + else if (!m_bKeyChangeNotProcessed) { + if (*pControlEdit != rsNULL || MouseButtonJustClicked || JoyButtonJustClicked) + CheckCodesForControls(TypeOfControl); + + field_535 = 1; + } + else { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + for (int i = 0; i < 4; i++) + ControlsManager.ClearSettingsAssociatedWithAction(m_CurrCntrlAction, i); + field_534 = false; + m_bKeyChangeNotProcessed = false; + pControlEdit = nil; + field_113 = 0; + m_KeyPressedCode = -1; + field_456 = 0; + } } } @@ -1469,6 +1472,7 @@ void CMenuManager::Process(void) else { UnloadTextures(); field_452 = 0; + *(bool*)0x5F33E4 = true; // byte_5F33E4 = 1; // unused m_nPrevScreen = 0; m_nCurrScreen = m_nPrevScreen; -- cgit v1.2.3