diff --git a/premake5.lua b/premake5.lua index cbd4c7f9..6966ec16 100644 --- a/premake5.lua +++ b/premake5.lua @@ -3,30 +3,39 @@ workspace "re3" location "build" files { "src/*.*" } - files { "src/skel/*.*" } - files { "src/skel/win/*.*" } - files { "src/math/*.*" } - files { "src/modelinfo/*.*" } - files { "src/entities/*.*" } - files { "src/weapons/*.*" } - files { "src/render/*.*" } - files { "src/control/*.*" } files { "src/animation/*.*" } files { "src/audio/*.*" } + files { "src/control/*.*" } + files { "src/core/*.*" } + files { "src/entities/*.*" } + files { "src/math/*.*" } + files { "src/modelinfo/*.*" } + files { "src/objects/*.*" } + files { "src/peds/*.*" } + files { "src/render/*.*" } + files { "src/skel/*.*" } + files { "src/skel/win/*.*" } + files { "src/vehicles/*.*" } + files { "src/weapons/*.*" } includedirs { "src" } + includedirs { "src/animation" } + includedirs { "src/audio" } + includedirs { "src/control" } + includedirs { "src/core" } + includedirs { "src/entities" } + includedirs { "src/modelinfo" } + includedirs { "src/objects" } + includedirs { "src/peds" } + includedirs { "src/render" } includedirs { "src/skel/" } includedirs { "src/skel/win" } - includedirs { "src/modelinfo" } - includedirs { "src/entities" } + includedirs { "src/vehicles" } includedirs { "src/weapons" } - includedirs { "src/render" } - includedirs { "src/control" } - includedirs { "src/audio" } - includedirs { "src/animation" } + includedirs { "dxsdk/include" } includedirs { "rwsdk/include/d3d8" } - + libdirs { "dxsdk/lib" } project "re3" diff --git a/src/animation/AnimBlendAssociation.h b/src/animation/AnimBlendAssociation.h index d846a4d3..a7e127f7 100644 --- a/src/animation/AnimBlendAssociation.h +++ b/src/animation/AnimBlendAssociation.h @@ -77,7 +77,7 @@ public: void UpdateTime(float timeDelta, float relSpeed); bool UpdateBlend(float timeDelta); - float GetTimeLeft() { return hierarchy->totalLength - currentTime; } + inline float GetTimeLeft() { return hierarchy->totalLength - currentTime; } static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) { return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link)); diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index 73fc4d94..6ad63e49 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -752,7 +752,7 @@ CAnimManager::LoadAnimFiles(void) AnimAssocDefinition *def = &CAnimManager::ms_aAnimAssocDefinitions[i]; group->CreateAssociations(def->blockName, clump, def->animNames, def->numAnims); for(j = 0; j < group->numAssociations; j++) - group->GetAnimation(def->animDescs[j].animId)->flags |= def->animDescs[j].flags; + group->GetAnimation(j)->flags |= def->animDescs[j].flags; RpClumpDestroy(clump); } } diff --git a/src/control/PhoneInfo.cpp b/src/control/Phones.cpp similarity index 80% rename from src/control/PhoneInfo.cpp rename to src/control/Phones.cpp index dbb7acc5..fa4f83e5 100644 --- a/src/control/PhoneInfo.cpp +++ b/src/control/Phones.cpp @@ -1,6 +1,6 @@ #include "common.h" #include "patcher.h" -#include "PhoneInfo.h" +#include "Phones.h" WRAPPER void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x42F570); } -WRAPPER void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x42F470); } \ No newline at end of file +WRAPPER void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x42F470); } diff --git a/src/control/PhoneInfo.h b/src/control/Phones.h similarity index 100% rename from src/control/PhoneInfo.h rename to src/control/Phones.h diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index e166e6b5..06995663 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -16,7 +16,7 @@ #include "ModelInfo.h" #include "Object.h" #include "Pad.h" -#include "PhoneInfo.h" +#include "Phones.h" #include "Pickups.h" #include "Plane.h" #include "Pools.h" @@ -638,7 +638,7 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) if (vehicle->IsCar()){ CAutomobile* car = (CAutomobile*)vehicle; for (int i = 0; i < 4; i++){ - vp->wheel_susp_dist[i] = 50.0f * car->m_aWheelDist[i]; + vp->wheel_susp_dist[i] = 50.0f * car->m_aSuspensionSpringRatio[i]; vp->wheel_rotation[i] = 128.0f / M_PI * car->m_aWheelRotation[i]; } vp->door_angles[0] = 127.0f / M_PI * car->Doors[2].m_fAngle; @@ -683,7 +683,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI if (vehicle->IsCar()) { CAutomobile* car = (CAutomobile*)vehicle; for (int i = 0; i < 4; i++) { - car->m_aWheelDist[i] = vp->wheel_susp_dist[i] / 50.0f; + car->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f; car->m_aWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f; } car->Doors[2].m_fAngle = car->Doors[2].m_fPreviousAngle = vp->door_angles[0] * M_PI / 127.0f; diff --git a/src/control/Replay.h b/src/control/Replay.h index e6885f59..cd8d9a45 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -262,8 +262,8 @@ public: static void StreamAllNecessaryCarsAndPeds(void); static bool ShouldStandardCameraBeProcessed(void); - inline static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; } - inline static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; } + static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; } + static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; } private: static void RecordThisFrame(void); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index e7f64541..5e7f4936 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -129,6 +129,10 @@ void CMissionCleanup::Process() } } +/* NB: CUpsideDownCarCheck is not used by actual script at all + * It has a weird usage: AreAnyCarsUpsideDown would fail any mission + * just like death or arrest. */ + void CUpsideDownCarCheck::Init() { for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ @@ -137,18 +141,142 @@ void CUpsideDownCarCheck::Init() } } +bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id) +{ + CVehicle* v = CPools::GetVehiclePool()->GetAt(id); + return v->GetUp().z <= -0.97f && + v->GetMoveSpeed().Magnitude() < 0.01f && + v->GetTurnSpeed().Magnitude() < 0.02f; +} + +void CUpsideDownCarCheck::UpdateTimers() +{ + uint32 timeStep = CTimer::GetTimeStepInMilliseconds(); + for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ + CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sCars[i].m_nVehicleIndex); + if (v){ + if (IsCarUpsideDown(m_sCars[i].m_nVehicleIndex)) + m_sCars[i].m_nUpsideDownTimer += timeStep; + else + m_sCars[i].m_nUpsideDownTimer = 0; + }else{ + m_sCars[i].m_nVehicleIndex = -1; + m_sCars[i].m_nUpsideDownTimer = 0; + } + } +} + +bool CUpsideDownCarCheck::AreAnyCarsUpsideDown() +{ + for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ + if (m_sCars[i].m_nVehicleIndex >= 0 && m_sCars[i].m_nUpsideDownTimer > 1000) + return true; + } + return false; +} + +void CUpsideDownCarCheck::AddCarToCheck(int32 id) +{ + uint16 index = 0; + while (index < MAX_UPSIDEDOWN_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0) + index++; + if (index >= MAX_UPSIDEDOWN_CAR_CHECKS) + return; + m_sCars[index].m_nVehicleIndex = id; + m_sCars[index].m_nUpsideDownTimer = 0; +} + +void CUpsideDownCarCheck::RemoveCarFromCheck(int32 id) +{ + for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ + if (m_sCars[i].m_nVehicleIndex == id){ + m_sCars[i].m_nVehicleIndex = -1; + m_sCars[i].m_nUpsideDownTimer = 0; + } + } +} + +bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id) +{ + for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ + if (m_sCars[i].m_nVehicleIndex == id) + return m_sCars[i].m_nUpsideDownTimer > 1000; + } + return false; +} + +void CStuckCarCheckEntry::Reset() +{ + m_nVehicleIndex = -1; + m_vecPos = CVector(-5000.0f, -5000.0f, -5000.0f); + m_nLastCheck = -1; + m_fRadius = 0.0f; + m_nStuckTime = 0; + m_bStuck = false; +} + void CStuckCarCheck::Init() { for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++) { - m_sCars[i].m_nVehicleIndex = -1; - m_sCars[i].m_vecPos = CVector(-5000.0f, -5000.0f, -5000.0f); - m_sCars[i].m_nStartTime = -1; - m_sCars[i].m_fDistance = 0.0f; - m_sCars[i].m_nStuckTime = 0; - m_sCars[i].m_bStuck = false; + m_sCars[i].Reset(); } } +void CStuckCarCheck::Process() +{ + uint32 timer = CTimer::GetTimeInMilliseconds(); + for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){ + if (m_sCars[i].m_nVehicleIndex < 0) + continue; + if (timer <= m_sCars[i].m_nStuckTime + m_sCars[i].m_nLastCheck) + continue; + CVehicle* pv = CPools::GetVehiclePool()->GetAt(m_sCars[i].m_nVehicleIndex); + if (!pv){ + m_sCars[i].Reset(); + continue; + } + float distance = (pv->GetPosition() - m_sCars[i].m_vecPos).Magnitude(); + m_sCars[i].m_bStuck = distance < m_sCars[i].m_fRadius; + m_sCars[i].m_vecPos = pv->GetPosition(); + m_sCars[i].m_nLastCheck = timer; + } +} + +void CStuckCarCheck::AddCarToCheck(int32 id, float radius, uint32 time) +{ + CVehicle* pv = CPools::GetVehiclePool()->GetAt(id); + if (!pv) + return; + int index = 0; + while (index < MAX_STUCK_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0) + index++; + /* Would be nice to return if index >= MAX_STUCK_CAR_CHECKS... */ + m_sCars[index].m_nVehicleIndex = id; + m_sCars[index].m_vecPos = pv->GetPosition(); + m_sCars[index].m_nLastCheck = CTimer::GetTimeInMilliseconds(); + m_sCars[index].m_fRadius = radius; + m_sCars[index].m_nStuckTime = time; + m_sCars[index].m_bStuck = false; +} + +void CStuckCarCheck::RemoveCarFromCheck(int32 id) +{ + for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){ + if (m_sCars[i].m_nVehicleIndex == id){ + m_sCars[i].Reset(); + } + } +} + +bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id) +{ + for (int i = 0; i < MAX_STUCK_CAR_CHECKS; i++){ + if (m_sCars[i].m_nVehicleIndex == id) + return m_sCars[i].m_bStuck; + } + return false; +} + WRAPPER void CTheScripts::CleanUpThisVehicle(CVehicle*) { EAXJMP(0x4548D0); } WRAPPER void CTheScripts::CleanUpThisPed(CPed*) { EAXJMP(0x4547A0); } WRAPPER void CTheScripts::CleanUpThisObject(CObject*) { EAXJMP(0x454910); } @@ -160,4 +288,15 @@ InjectHook(0x437AE0, &CMissionCleanup::Init, PATCH_JUMP); InjectHook(0x437BA0, &CMissionCleanup::AddEntityToList, PATCH_JUMP); InjectHook(0x437BD0, &CMissionCleanup::RemoveEntityFromList, PATCH_JUMP); InjectHook(0x437C10, &CMissionCleanup::Process, PATCH_JUMP); +InjectHook(0x437DC0, &CUpsideDownCarCheck::Init, PATCH_JUMP); +InjectHook(0x437EE0, &CUpsideDownCarCheck::UpdateTimers, PATCH_JUMP); +InjectHook(0x437F80, &CUpsideDownCarCheck::AreAnyCarsUpsideDown, PATCH_JUMP); +InjectHook(0x437FB0, &CUpsideDownCarCheck::AddCarToCheck, PATCH_JUMP); +InjectHook(0x437FE0, &CUpsideDownCarCheck::RemoveCarFromCheck, PATCH_JUMP); +InjectHook(0x438010, &CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile, PATCH_JUMP); +InjectHook(0x438050, &CStuckCarCheck::Init, PATCH_JUMP); +InjectHook(0x4380A0, &CStuckCarCheck::Process, PATCH_JUMP); +InjectHook(0x4381C0, &CStuckCarCheck::AddCarToCheck, PATCH_JUMP); +InjectHook(0x438240, &CStuckCarCheck::RemoveCarFromCheck, PATCH_JUMP); +InjectHook(0x4382A0, &CStuckCarCheck::HasCarBeenStuckForAWhile, PATCH_JUMP); ENDPATCHES \ No newline at end of file diff --git a/src/control/Script.h b/src/control/Script.h index 7b62a1b0..42e41c70 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -101,16 +101,24 @@ class CUpsideDownCarCheck public: void Init(); + bool IsCarUpsideDown(int32); + void UpdateTimers(); + bool AreAnyCarsUpsideDown(); + void AddCarToCheck(int32); + void RemoveCarFromCheck(int32); + bool HasCarBeenUpsideDownForAWhile(int32); }; struct CStuckCarCheckEntry { int32 m_nVehicleIndex; CVector m_vecPos; - int32 m_nStartTime; - float m_fDistance; + int32 m_nLastCheck; + float m_fRadius; uint32 m_nStuckTime; bool m_bStuck; + + inline void Reset(); }; class CStuckCarCheck @@ -119,6 +127,10 @@ class CStuckCarCheck public: void Init(); + void Process(); + void AddCarToCheck(int32, float, uint32); + void RemoveCarFromCheck(int32); + bool HasCarBeenStuckForAWhile(int32); }; class CTheScripts diff --git a/src/Camera.cpp b/src/core/Camera.cpp similarity index 99% rename from src/Camera.cpp rename to src/core/Camera.cpp index 735ff4a2..58e65d24 100644 --- a/src/Camera.cpp +++ b/src/core/Camera.cpp @@ -8,7 +8,7 @@ #include "PlayerPed.h" #include "Pad.h" #include "General.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "SurfaceTable.h" #include "MBlur.h" #include "Camera.h" diff --git a/src/Camera.h b/src/core/Camera.h similarity index 100% rename from src/Camera.h rename to src/core/Camera.h diff --git a/src/CdStream.cpp b/src/core/CdStream.cpp similarity index 100% rename from src/CdStream.cpp rename to src/core/CdStream.cpp diff --git a/src/CdStream.h b/src/core/CdStream.h similarity index 100% rename from src/CdStream.h rename to src/core/CdStream.h diff --git a/src/Clock.cpp b/src/core/Clock.cpp similarity index 100% rename from src/Clock.cpp rename to src/core/Clock.cpp diff --git a/src/Clock.h b/src/core/Clock.h similarity index 100% rename from src/Clock.h rename to src/core/Clock.h diff --git a/src/Collision.cpp b/src/core/Collision.cpp similarity index 99% rename from src/Collision.cpp rename to src/core/Collision.cpp index 62b27eff..d15ccca5 100644 --- a/src/Collision.cpp +++ b/src/core/Collision.cpp @@ -5,7 +5,7 @@ #include "Game.h" #include "Zones.h" #include "General.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "World.h" #include "Entity.h" #include "Train.h" diff --git a/src/Collision.h b/src/core/Collision.h similarity index 100% rename from src/Collision.h rename to src/core/Collision.h diff --git a/src/ControllerConfig.cpp b/src/core/ControllerConfig.cpp similarity index 100% rename from src/ControllerConfig.cpp rename to src/core/ControllerConfig.cpp diff --git a/src/ControllerConfig.h b/src/core/ControllerConfig.h similarity index 100% rename from src/ControllerConfig.h rename to src/core/ControllerConfig.h diff --git a/src/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp similarity index 100% rename from src/CutsceneMgr.cpp rename to src/core/CutsceneMgr.cpp diff --git a/src/CutsceneMgr.h b/src/core/CutsceneMgr.h similarity index 100% rename from src/CutsceneMgr.h rename to src/core/CutsceneMgr.h diff --git a/src/Directory.cpp b/src/core/Directory.cpp similarity index 100% rename from src/Directory.cpp rename to src/core/Directory.cpp diff --git a/src/Directory.h b/src/core/Directory.h similarity index 100% rename from src/Directory.h rename to src/core/Directory.h diff --git a/src/FileLoader.cpp b/src/core/FileLoader.cpp similarity index 99% rename from src/FileLoader.cpp rename to src/core/FileLoader.cpp index d87964ac..fdc3b9d7 100644 --- a/src/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -21,7 +21,7 @@ #include "DummyObject.h" #include "World.h" #include "Zones.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "CdStream.h" #include "FileLoader.h" diff --git a/src/FileLoader.h b/src/core/FileLoader.h similarity index 100% rename from src/FileLoader.h rename to src/core/FileLoader.h diff --git a/src/FileMgr.cpp b/src/core/FileMgr.cpp similarity index 100% rename from src/FileMgr.cpp rename to src/core/FileMgr.cpp diff --git a/src/FileMgr.h b/src/core/FileMgr.h similarity index 100% rename from src/FileMgr.h rename to src/core/FileMgr.h diff --git a/src/Fire.cpp b/src/core/Fire.cpp similarity index 100% rename from src/Fire.cpp rename to src/core/Fire.cpp diff --git a/src/Fire.h b/src/core/Fire.h similarity index 100% rename from src/Fire.h rename to src/core/Fire.h diff --git a/src/Frontend.cpp b/src/core/Frontend.cpp similarity index 100% rename from src/Frontend.cpp rename to src/core/Frontend.cpp diff --git a/src/Frontend.h b/src/core/Frontend.h similarity index 100% rename from src/Frontend.h rename to src/core/Frontend.h diff --git a/src/Game.cpp b/src/core/Game.cpp similarity index 100% rename from src/Game.cpp rename to src/core/Game.cpp diff --git a/src/Game.h b/src/core/Game.h similarity index 100% rename from src/Game.h rename to src/core/Game.h diff --git a/src/General.h b/src/core/General.h similarity index 100% rename from src/General.h rename to src/core/General.h diff --git a/src/Lists.cpp b/src/core/Lists.cpp similarity index 100% rename from src/Lists.cpp rename to src/core/Lists.cpp diff --git a/src/Lists.h b/src/core/Lists.h similarity index 100% rename from src/Lists.h rename to src/core/Lists.h diff --git a/src/MenuScreens.h b/src/core/MenuScreens.h similarity index 100% rename from src/MenuScreens.h rename to src/core/MenuScreens.h diff --git a/src/Messages.cpp b/src/core/Messages.cpp similarity index 100% rename from src/Messages.cpp rename to src/core/Messages.cpp diff --git a/src/Messages.h b/src/core/Messages.h similarity index 100% rename from src/Messages.h rename to src/core/Messages.h diff --git a/src/NodeName.cpp b/src/core/NodeName.cpp similarity index 100% rename from src/NodeName.cpp rename to src/core/NodeName.cpp diff --git a/src/NodeName.h b/src/core/NodeName.h similarity index 100% rename from src/NodeName.h rename to src/core/NodeName.h diff --git a/src/PCSave.cpp b/src/core/PCSave.cpp similarity index 100% rename from src/PCSave.cpp rename to src/core/PCSave.cpp diff --git a/src/PCSave.h b/src/core/PCSave.h similarity index 100% rename from src/PCSave.h rename to src/core/PCSave.h diff --git a/src/Pad.cpp b/src/core/Pad.cpp similarity index 100% rename from src/Pad.cpp rename to src/core/Pad.cpp diff --git a/src/Pad.h b/src/core/Pad.h similarity index 51% rename from src/Pad.h rename to src/core/Pad.h index e06aa9a6..30cdb8df 100644 --- a/src/Pad.h +++ b/src/core/Pad.h @@ -288,80 +288,80 @@ public: static int32 *EditCodesForControls(int32 *pRsKeys, int32 nSize); // mouse - inline bool GetLeftMouseJustDown() { return !!(NewMouseControllerState.LMB && !OldMouseControllerState.LMB); } + bool GetLeftMouseJustDown() { return !!(NewMouseControllerState.LMB && !OldMouseControllerState.LMB); } // keyboard - inline bool GetCharJustDown(int32 c) { return !!(NewKeyState.VK_KEYS[c] && !OldKeyState.VK_KEYS[c]); } - inline bool GetFJustDown(int32 n) { return !!(NewKeyState.F[n] && !OldKeyState.F[n]); } - inline bool GetEscapeJustDown() { return !!(NewKeyState.ESC && !OldKeyState.ESC); } - inline bool GetInsertJustDown() { return !!(NewKeyState.INS && !OldKeyState.INS); } - inline bool GetDeleteJustDown() { return !!(NewKeyState.DEL && !OldKeyState.DEL); } - inline bool GetHomeJustDown() { return !!(NewKeyState.HOME && !OldKeyState.HOME); } - inline bool GetEndJustDown() { return !!(NewKeyState.END && !OldKeyState.END); } - inline bool GetPageUpJustDown() { return !!(NewKeyState.PGUP && !OldKeyState.PGUP); } - inline bool GetPageDownJustDown() { return !!(NewKeyState.PGDN && !OldKeyState.PGDN); } - inline bool GetUpJustDown() { return !!(NewKeyState.UP && !OldKeyState.UP); } - inline bool GetDownJustDown() { return !!(NewKeyState.DOWN && !OldKeyState.DOWN); } - inline bool GetLeftJustDown() { return !!(NewKeyState.LEFT && !OldKeyState.LEFT); } - inline bool GetRightJustDown() { return !!(NewKeyState.RIGHT && !OldKeyState.RIGHT); } - inline bool GetScrollLockJustDown() { return !!(NewKeyState.SCROLLLOCK && !OldKeyState.SCROLLLOCK); } - inline bool GetPauseJustDown() { return !!(NewKeyState.PAUSE && !OldKeyState.PAUSE); } - inline bool GetNumLockJustDown() { return !!(NewKeyState.NUMLOCK && !OldKeyState.NUMLOCK); } - inline bool GetDivideJustDown() { return !!(NewKeyState.DIV && !OldKeyState.DIV); } - inline bool GetTimesJustDown() { return !!(NewKeyState.MUL && !OldKeyState.MUL); } - inline bool GetMinusJustDown() { return !!(NewKeyState.SUB && !OldKeyState.SUB); } - inline bool GetPlusJustDown() { return !!(NewKeyState.ADD && !OldKeyState.ADD); } - inline bool GetPadEnterJustDown() { return !!(NewKeyState.ENTER && !OldKeyState.ENTER); } // GetEnterJustDown - inline bool GetPadDelJustDown() { return !!(NewKeyState.DECIMAL && !OldKeyState.DECIMAL); } - inline bool GetPad1JustDown() { return !!(NewKeyState.NUM1 && !OldKeyState.NUM1); } - inline bool GetPad2JustDown() { return !!(NewKeyState.NUM2 && !OldKeyState.NUM2); } - inline bool GetPad3JustDown() { return !!(NewKeyState.NUM3 && !OldKeyState.NUM3); } - inline bool GetPad4JustDown() { return !!(NewKeyState.NUM4 && !OldKeyState.NUM4); } - inline bool GetPad5JustDown() { return !!(NewKeyState.NUM5 && !OldKeyState.NUM5); } - inline bool GetPad6JustDown() { return !!(NewKeyState.NUM6 && !OldKeyState.NUM6); } - inline bool GetPad7JustDown() { return !!(NewKeyState.NUM7 && !OldKeyState.NUM7); } - inline bool GetPad8JustDown() { return !!(NewKeyState.NUM8 && !OldKeyState.NUM8); } - inline bool GetPad9JustDown() { return !!(NewKeyState.NUM9 && !OldKeyState.NUM9); } - inline bool GetPad0JustDown() { return !!(NewKeyState.NUM0 && !OldKeyState.NUM0); } - inline bool GetBackspaceJustDown() { return !!(NewKeyState.BACKSP && !OldKeyState.BACKSP); } - inline bool GetTabJustDown() { return !!(NewKeyState.TAB && !OldKeyState.TAB); } - inline bool GetCapsLockJustDown() { return !!(NewKeyState.CAPSLOCK && !OldKeyState.CAPSLOCK); } - inline bool GetEnterJustDown() { return !!(NewKeyState.EXTENTER && !OldKeyState.EXTENTER); } - inline bool GetLeftShiftJustDown() { return !!(NewKeyState.LSHIFT && !OldKeyState.LSHIFT); } - inline bool GetShiftJustDown() { return !!(NewKeyState.SHIFT && !OldKeyState.SHIFT); } - inline bool GetRightShiftJustDown() { return !!(NewKeyState.RSHIFT && !OldKeyState.RSHIFT); } - inline bool GetLeftCtrlJustDown() { return !!(NewKeyState.LCTRL && !OldKeyState.LCTRL); } - inline bool GetRightCtrlJustDown() { return !!(NewKeyState.RCTRL && !OldKeyState.RCTRL); } - inline bool GetLeftAltJustDown() { return !!(NewKeyState.LALT && !OldKeyState.LALT); } - inline bool GetRightAltJustDown() { return !!(NewKeyState.RALT && !OldKeyState.RALT); } - inline bool GetLeftWinJustDown() { return !!(NewKeyState.LWIN && !OldKeyState.LWIN); } - inline bool GetRightWinJustDown() { return !!(NewKeyState.RWIN && !OldKeyState.RWIN); } - inline bool GetAppsJustDown() { return !!(NewKeyState.APPS && !OldKeyState.APPS); } + bool GetCharJustDown(int32 c) { return !!(NewKeyState.VK_KEYS[c] && !OldKeyState.VK_KEYS[c]); } + bool GetFJustDown(int32 n) { return !!(NewKeyState.F[n] && !OldKeyState.F[n]); } + bool GetEscapeJustDown() { return !!(NewKeyState.ESC && !OldKeyState.ESC); } + bool GetInsertJustDown() { return !!(NewKeyState.INS && !OldKeyState.INS); } + bool GetDeleteJustDown() { return !!(NewKeyState.DEL && !OldKeyState.DEL); } + bool GetHomeJustDown() { return !!(NewKeyState.HOME && !OldKeyState.HOME); } + bool GetEndJustDown() { return !!(NewKeyState.END && !OldKeyState.END); } + bool GetPageUpJustDown() { return !!(NewKeyState.PGUP && !OldKeyState.PGUP); } + bool GetPageDownJustDown() { return !!(NewKeyState.PGDN && !OldKeyState.PGDN); } + bool GetUpJustDown() { return !!(NewKeyState.UP && !OldKeyState.UP); } + bool GetDownJustDown() { return !!(NewKeyState.DOWN && !OldKeyState.DOWN); } + bool GetLeftJustDown() { return !!(NewKeyState.LEFT && !OldKeyState.LEFT); } + bool GetRightJustDown() { return !!(NewKeyState.RIGHT && !OldKeyState.RIGHT); } + bool GetScrollLockJustDown() { return !!(NewKeyState.SCROLLLOCK && !OldKeyState.SCROLLLOCK); } + bool GetPauseJustDown() { return !!(NewKeyState.PAUSE && !OldKeyState.PAUSE); } + bool GetNumLockJustDown() { return !!(NewKeyState.NUMLOCK && !OldKeyState.NUMLOCK); } + bool GetDivideJustDown() { return !!(NewKeyState.DIV && !OldKeyState.DIV); } + bool GetTimesJustDown() { return !!(NewKeyState.MUL && !OldKeyState.MUL); } + bool GetMinusJustDown() { return !!(NewKeyState.SUB && !OldKeyState.SUB); } + bool GetPlusJustDown() { return !!(NewKeyState.ADD && !OldKeyState.ADD); } + bool GetPadEnterJustDown() { return !!(NewKeyState.ENTER && !OldKeyState.ENTER); } // GetEnterJustDown + bool GetPadDelJustDown() { return !!(NewKeyState.DECIMAL && !OldKeyState.DECIMAL); } + bool GetPad1JustDown() { return !!(NewKeyState.NUM1 && !OldKeyState.NUM1); } + bool GetPad2JustDown() { return !!(NewKeyState.NUM2 && !OldKeyState.NUM2); } + bool GetPad3JustDown() { return !!(NewKeyState.NUM3 && !OldKeyState.NUM3); } + bool GetPad4JustDown() { return !!(NewKeyState.NUM4 && !OldKeyState.NUM4); } + bool GetPad5JustDown() { return !!(NewKeyState.NUM5 && !OldKeyState.NUM5); } + bool GetPad6JustDown() { return !!(NewKeyState.NUM6 && !OldKeyState.NUM6); } + bool GetPad7JustDown() { return !!(NewKeyState.NUM7 && !OldKeyState.NUM7); } + bool GetPad8JustDown() { return !!(NewKeyState.NUM8 && !OldKeyState.NUM8); } + bool GetPad9JustDown() { return !!(NewKeyState.NUM9 && !OldKeyState.NUM9); } + bool GetPad0JustDown() { return !!(NewKeyState.NUM0 && !OldKeyState.NUM0); } + bool GetBackspaceJustDown() { return !!(NewKeyState.BACKSP && !OldKeyState.BACKSP); } + bool GetTabJustDown() { return !!(NewKeyState.TAB && !OldKeyState.TAB); } + bool GetCapsLockJustDown() { return !!(NewKeyState.CAPSLOCK && !OldKeyState.CAPSLOCK); } + bool GetEnterJustDown() { return !!(NewKeyState.EXTENTER && !OldKeyState.EXTENTER); } + bool GetLeftShiftJustDown() { return !!(NewKeyState.LSHIFT && !OldKeyState.LSHIFT); } + bool GetShiftJustDown() { return !!(NewKeyState.SHIFT && !OldKeyState.SHIFT); } + bool GetRightShiftJustDown() { return !!(NewKeyState.RSHIFT && !OldKeyState.RSHIFT); } + bool GetLeftCtrlJustDown() { return !!(NewKeyState.LCTRL && !OldKeyState.LCTRL); } + bool GetRightCtrlJustDown() { return !!(NewKeyState.RCTRL && !OldKeyState.RCTRL); } + bool GetLeftAltJustDown() { return !!(NewKeyState.LALT && !OldKeyState.LALT); } + bool GetRightAltJustDown() { return !!(NewKeyState.RALT && !OldKeyState.RALT); } + bool GetLeftWinJustDown() { return !!(NewKeyState.LWIN && !OldKeyState.LWIN); } + bool GetRightWinJustDown() { return !!(NewKeyState.RWIN && !OldKeyState.RWIN); } + bool GetAppsJustDown() { return !!(NewKeyState.APPS && !OldKeyState.APPS); } // pad - inline bool GetTriangleJustDown() { return !!(NewState.Triangle && !OldState.Triangle); } - inline bool GetCircleJustDown() { return !!(NewState.Circle && !OldState.Circle); } - inline bool GetCrossJustDown() { return !!(NewState.Cross && !OldState.Cross); } - inline bool GetSquareJustDown() { return !!(NewState.Square && !OldState.Square); } - inline bool GetDPadUpJustDown() { return !!(NewState.DPadUp && !OldState.DPadUp); } - inline bool GetDPadDownJustDown() { return !!(NewState.DPadDown && !OldState.DPadDown); } - inline bool GetDPadLeftJustDown() { return !!(NewState.DPadLeft && !OldState.DPadLeft); } - inline bool GetDPadRightJustDown() { return !!(NewState.DPadRight && !OldState.DPadRight); } - inline bool GetLeftShoulder1JustDown() { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); } - inline bool GetLeftShoulder2JustDown() { return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); } - inline bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); } - inline bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } + bool GetTriangleJustDown() { return !!(NewState.Triangle && !OldState.Triangle); } + bool GetCircleJustDown() { return !!(NewState.Circle && !OldState.Circle); } + bool GetCrossJustDown() { return !!(NewState.Cross && !OldState.Cross); } + bool GetSquareJustDown() { return !!(NewState.Square && !OldState.Square); } + bool GetDPadUpJustDown() { return !!(NewState.DPadUp && !OldState.DPadUp); } + bool GetDPadDownJustDown() { return !!(NewState.DPadDown && !OldState.DPadDown); } + bool GetDPadLeftJustDown() { return !!(NewState.DPadLeft && !OldState.DPadLeft); } + bool GetDPadRightJustDown() { return !!(NewState.DPadRight && !OldState.DPadRight); } + bool GetLeftShoulder1JustDown() { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); } + bool GetLeftShoulder2JustDown() { return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); } + bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); } + bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } - inline int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; } - inline int32 GetLeftShoulder2(void) { return NewState.LeftShoulder2; } - inline int32 GetRightShoulder1(void) { return NewState.RightShoulder1; } - inline int32 GetRightShoulder2(void) { return NewState.RightShoulder2; } + int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; } + int32 GetLeftShoulder2(void) { return NewState.LeftShoulder2; } + int32 GetRightShoulder1(void) { return NewState.RightShoulder1; } + int32 GetRightShoulder2(void) { return NewState.RightShoulder2; } }; VALIDATE_SIZE(CPad, 0xFC); #define IsButtonJustDown(pad, btn) \ (!(pad)->OldState.btn && (pad)->NewState.btn) -void LittleTest(void); \ No newline at end of file +void LittleTest(void); diff --git a/src/Placeable.cpp b/src/core/Placeable.cpp similarity index 100% rename from src/Placeable.cpp rename to src/core/Placeable.cpp diff --git a/src/Placeable.h b/src/core/Placeable.h similarity index 100% rename from src/Placeable.h rename to src/core/Placeable.h diff --git a/src/entities/PlayerInfo.cpp b/src/core/PlayerInfo.cpp similarity index 100% rename from src/entities/PlayerInfo.cpp rename to src/core/PlayerInfo.cpp diff --git a/src/entities/PlayerInfo.h b/src/core/PlayerInfo.h similarity index 100% rename from src/entities/PlayerInfo.h rename to src/core/PlayerInfo.h diff --git a/src/entities/PlayerSkin.cpp b/src/core/PlayerSkin.cpp similarity index 100% rename from src/entities/PlayerSkin.cpp rename to src/core/PlayerSkin.cpp diff --git a/src/entities/PlayerSkin.h b/src/core/PlayerSkin.h similarity index 100% rename from src/entities/PlayerSkin.h rename to src/core/PlayerSkin.h diff --git a/src/Pools.cpp b/src/core/Pools.cpp similarity index 100% rename from src/Pools.cpp rename to src/core/Pools.cpp diff --git a/src/Pools.h b/src/core/Pools.h similarity index 100% rename from src/Pools.h rename to src/core/Pools.h diff --git a/src/Radar.cpp b/src/core/Radar.cpp similarity index 100% rename from src/Radar.cpp rename to src/core/Radar.cpp diff --git a/src/Radar.h b/src/core/Radar.h similarity index 100% rename from src/Radar.h rename to src/core/Radar.h diff --git a/src/References.cpp b/src/core/References.cpp similarity index 100% rename from src/References.cpp rename to src/core/References.cpp diff --git a/src/References.h b/src/core/References.h similarity index 100% rename from src/References.h rename to src/core/References.h diff --git a/src/RwClumpRead.cpp b/src/core/RwClumpRead.cpp similarity index 100% rename from src/RwClumpRead.cpp rename to src/core/RwClumpRead.cpp diff --git a/src/RwHelper.cpp b/src/core/RwHelper.cpp similarity index 100% rename from src/RwHelper.cpp rename to src/core/RwHelper.cpp diff --git a/src/RwHelper.h b/src/core/RwHelper.h similarity index 100% rename from src/RwHelper.h rename to src/core/RwHelper.h diff --git a/src/RwMatFX.cpp b/src/core/RwMatFX.cpp similarity index 100% rename from src/RwMatFX.cpp rename to src/core/RwMatFX.cpp diff --git a/src/RwTexRead.cpp b/src/core/RwTexRead.cpp similarity index 100% rename from src/RwTexRead.cpp rename to src/core/RwTexRead.cpp diff --git a/src/Stats.cpp b/src/core/Stats.cpp similarity index 100% rename from src/Stats.cpp rename to src/core/Stats.cpp diff --git a/src/Stats.h b/src/core/Stats.h similarity index 100% rename from src/Stats.h rename to src/core/Stats.h diff --git a/src/Streaming.cpp b/src/core/Streaming.cpp similarity index 99% rename from src/Streaming.cpp rename to src/core/Streaming.cpp index 08fd80f0..f8ab19d4 100644 --- a/src/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -16,7 +16,7 @@ #include "FileMgr.h" #include "FileLoader.h" #include "Zones.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "Radar.h" #include "Camera.h" #include "Record.h" diff --git a/src/Streaming.h b/src/core/Streaming.h similarity index 100% rename from src/Streaming.h rename to src/core/Streaming.h diff --git a/src/SurfaceTable.cpp b/src/core/SurfaceTable.cpp similarity index 100% rename from src/SurfaceTable.cpp rename to src/core/SurfaceTable.cpp diff --git a/src/SurfaceTable.h b/src/core/SurfaceTable.h similarity index 100% rename from src/SurfaceTable.h rename to src/core/SurfaceTable.h diff --git a/src/TempColModels.cpp b/src/core/TempColModels.cpp similarity index 100% rename from src/TempColModels.cpp rename to src/core/TempColModels.cpp diff --git a/src/TempColModels.h b/src/core/TempColModels.h similarity index 100% rename from src/TempColModels.h rename to src/core/TempColModels.h diff --git a/src/Text.cpp b/src/core/Text.cpp similarity index 100% rename from src/Text.cpp rename to src/core/Text.cpp diff --git a/src/Text.h b/src/core/Text.h similarity index 100% rename from src/Text.h rename to src/core/Text.h diff --git a/src/Timer.cpp b/src/core/Timer.cpp similarity index 100% rename from src/Timer.cpp rename to src/core/Timer.cpp diff --git a/src/Timer.h b/src/core/Timer.h similarity index 64% rename from src/Timer.h rename to src/core/Timer.h index 75d4048c..9e6d447e 100644 --- a/src/Timer.h +++ b/src/core/Timer.h @@ -14,21 +14,24 @@ class CTimer static bool &m_CodePause; public: static float GetTimeStep(void) { return ms_fTimeStep; } - static inline void SetTimeStep(float ts) { ms_fTimeStep = ts; } + static void SetTimeStep(float ts) { ms_fTimeStep = ts; } + static float GetTimeStepInSeconds() { return ms_fTimeStep / 50.0f; } + static float GetTimeStepInMilliseconds() { return ms_fTimeStep / 50.0f * 1000.0f; } static float GetTimeStepNonClipped(void) { return ms_fTimeStepNonClipped; } - static inline void SetTimeStepNonClipped(float ts) { ms_fTimeStepNonClipped = ts; } + static float GetTimeStepNonClippedInSeconds(void) { return ms_fTimeStepNonClipped / 50.0f; } + static void SetTimeStepNonClipped(float ts) { ms_fTimeStepNonClipped = ts; } static uint32 GetFrameCounter(void) { return m_FrameCounter; } - static inline void SetFrameCounter(uint32 fc) { m_FrameCounter = fc; } + static void SetFrameCounter(uint32 fc) { m_FrameCounter = fc; } static uint32 GetTimeInMilliseconds(void) { return m_snTimeInMilliseconds; } - static inline void SetTimeInMilliseconds(uint32 t) { m_snTimeInMilliseconds = t; } + static void SetTimeInMilliseconds(uint32 t) { m_snTimeInMilliseconds = t; } static uint32 GetTimeInMillisecondsNonClipped(void) { return m_snTimeInMillisecondsNonClipped; } - static inline void SetTimeInMillisecondsNonClipped(uint32 t) { m_snTimeInMillisecondsNonClipped = t; } + static void SetTimeInMillisecondsNonClipped(uint32 t) { m_snTimeInMillisecondsNonClipped = t; } static uint32 GetTimeInMillisecondsPauseMode(void) { return m_snTimeInMillisecondsPauseMode; } - static inline void SetTimeInMillisecondsPauseMode(uint32 t) { m_snTimeInMillisecondsPauseMode = t; } + static void SetTimeInMillisecondsPauseMode(uint32 t) { m_snTimeInMillisecondsPauseMode = t; } static uint32 GetPreviousTimeInMilliseconds(void) { return m_snPreviousTimeInMilliseconds; } - static inline void SetPreviousTimeInMilliseconds(uint32 t) { m_snPreviousTimeInMilliseconds = t; } + static void SetPreviousTimeInMilliseconds(uint32 t) { m_snPreviousTimeInMilliseconds = t; } static float GetTimeScale(void) { return ms_fTimeScale; } - static inline void SetTimeScale(float ts) { ms_fTimeScale = ts; } + static void SetTimeScale(float ts) { ms_fTimeScale = ts; } static bool GetIsPaused() { return m_UserPause || m_CodePause; } static bool GetIsUserPaused() { return m_UserPause; } diff --git a/src/TxdStore.cpp b/src/core/TxdStore.cpp similarity index 100% rename from src/TxdStore.cpp rename to src/core/TxdStore.cpp diff --git a/src/TxdStore.h b/src/core/TxdStore.h similarity index 100% rename from src/TxdStore.h rename to src/core/TxdStore.h diff --git a/src/User.cpp b/src/core/User.cpp similarity index 100% rename from src/User.cpp rename to src/core/User.cpp diff --git a/src/User.h b/src/core/User.h similarity index 100% rename from src/User.h rename to src/core/User.h diff --git a/src/Wanted.cpp b/src/core/Wanted.cpp similarity index 100% rename from src/Wanted.cpp rename to src/core/Wanted.cpp diff --git a/src/Wanted.h b/src/core/Wanted.h similarity index 100% rename from src/Wanted.h rename to src/core/Wanted.h diff --git a/src/World.cpp b/src/core/World.cpp similarity index 100% rename from src/World.cpp rename to src/core/World.cpp diff --git a/src/World.h b/src/core/World.h similarity index 100% rename from src/World.h rename to src/core/World.h diff --git a/src/CullZones.cpp b/src/core/ZoneCull.cpp similarity index 99% rename from src/CullZones.cpp rename to src/core/ZoneCull.cpp index 6155ae57..90155bcf 100644 --- a/src/CullZones.cpp +++ b/src/core/ZoneCull.cpp @@ -8,7 +8,7 @@ #include "Camera.h" #include "World.h" #include "FileMgr.h" -#include "CullZones.h" +#include "ZoneCull.h" int32 &CCullZones::NumCullZones = *(int*)0x8F2564; CCullZone *CCullZones::aZones = (CCullZone*)0x864750; // [NUMCULLZONES]; diff --git a/src/CullZones.h b/src/core/ZoneCull.h similarity index 100% rename from src/CullZones.h rename to src/core/ZoneCull.h diff --git a/src/Zones.cpp b/src/core/Zones.cpp similarity index 100% rename from src/Zones.cpp rename to src/core/Zones.cpp diff --git a/src/Zones.h b/src/core/Zones.h similarity index 100% rename from src/Zones.h rename to src/core/Zones.h diff --git a/src/common.h b/src/core/common.h similarity index 100% rename from src/common.h rename to src/core/common.h diff --git a/src/config.h b/src/core/config.h similarity index 100% rename from src/config.h rename to src/core/config.h diff --git a/src/debugmenu_public.h b/src/core/debugmenu_public.h similarity index 100% rename from src/debugmenu_public.h rename to src/core/debugmenu_public.h diff --git a/src/main.cpp b/src/core/main.cpp similarity index 99% rename from src/main.cpp rename to src/core/main.cpp index 2835f396..e7f42780 100644 --- a/src/main.cpp +++ b/src/core/main.cpp @@ -40,7 +40,7 @@ #include "CutsceneMgr.h" #include "Lights.h" #include "Credits.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "Timecycle.h" #include "TxdStore.h" #include "FileMgr.h" diff --git a/src/main.h b/src/core/main.h similarity index 100% rename from src/main.h rename to src/core/main.h diff --git a/src/patcher.cpp b/src/core/patcher.cpp similarity index 100% rename from src/patcher.cpp rename to src/core/patcher.cpp diff --git a/src/patcher.h b/src/core/patcher.h similarity index 100% rename from src/patcher.h rename to src/core/patcher.h diff --git a/src/re3.cpp b/src/core/re3.cpp similarity index 100% rename from src/re3.cpp rename to src/core/re3.cpp diff --git a/src/rw.cpp b/src/core/rw.cpp similarity index 100% rename from src/rw.cpp rename to src/core/rw.cpp diff --git a/src/templates.h b/src/core/templates.h similarity index 100% rename from src/templates.h rename to src/core/templates.h diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index 14891cd9..d6a82658 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -304,6 +304,22 @@ CPhysical::RemoveRefsToEntity(CEntity *ent) } } +void +CPhysical::PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos) +{ + CVector worldPos = other->GetMatrix() * localPos; + float step = 0.9f * CTimer::GetTimeStep(); + CVector pos = other->m_vecMoveSpeed*step + worldPos; + + CWorld::Remove(phys); + phys->GetMatrix() = other->GetMatrix(); + phys->GetPosition() = pos; + phys->m_vecMoveSpeed = other->m_vecMoveSpeed; + phys->GetMatrix().UpdateRW(); + phys->UpdateRwFrame(); + CWorld::Add(phys); +} + int32 CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints) { @@ -346,7 +362,7 @@ CPhysical::ProcessControl(void) IsPed() && !bPedPhysics){ m_vecMoveSpeedAvg = (m_vecMoveSpeedAvg + m_vecMoveSpeed)/2.0f; m_vecTurnSpeedAvg = (m_vecTurnSpeedAvg + m_vecTurnSpeed)/2.0f; - float step = CTimer::GetTimeStep() * 0.003; + float step = CTimer::GetTimeStep() * 0.003f; if(m_vecMoveSpeedAvg.MagnitudeSqr() < step*step && m_vecTurnSpeedAvg.MagnitudeSqr() < step*step){ m_nStaticFrames++; @@ -434,15 +450,38 @@ CPhysical::ApplyFrictionTurnForce(float jx, float jy, float jz, float px, float m_vecTurnFriction += turnimpulse*(1.0f/m_fTurnMass); } -void -CPhysical::ApplySpringCollision(float f1, CVector &v, CVector &p, float f2, float f3) +bool +CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias) { - if(1.0f - f2 <= 0.0f) - return; + float compression = 1.0f - springRatio; + if(compression > 0.0f){ + float step = min(CTimer::GetTimeStep(), 3.0f); + float impulse = -0.008f*m_fMass*step * springConst * compression * bias*2.0f; + ApplyMoveForce(springDir*impulse); + ApplyTurnForce(springDir*impulse, point); + } + return true; +} + +// What exactly is speed? +bool +CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed) +{ + float speedA = DotProduct(speed, springDir); + float speedB = DotProduct(GetSpeed(point), springDir); float step = min(CTimer::GetTimeStep(), 3.0f); - float strength = -0.008f*m_fMass*2.0f*step * f1 * (1.0f-f2) * f3; - ApplyMoveForce(v*strength); - ApplyTurnForce(v*strength, p); + float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f; + + // what is this? + float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass); + a = min(a, 1.0f); + float b = fabs(impulse / (speedB * m_fMass)); + if(a < b) + impulse *= a/b; + + ApplyMoveForce(springDir*impulse); + ApplyTurnForce(springDir*impulse, point); + return true; } void @@ -1858,10 +1897,10 @@ CPhysical::ProcessCollision(void) CVehicle *veh = (CVehicle*)this; if(veh->m_vehType == VEHICLE_TYPE_CAR){ CAutomobile *car = (CAutomobile*)this; - car->m_aWheelDist[0] = 1.0f; - car->m_aWheelDist[1] = 1.0f; - car->m_aWheelDist[2] = 1.0f; - car->m_aWheelDist[3] = 1.0f; + car->m_aSuspensionSpringRatio[0] = 1.0f; + car->m_aSuspensionSpringRatio[1] = 1.0f; + car->m_aSuspensionSpringRatio[2] = 1.0f; + car->m_aSuspensionSpringRatio[3] = 1.0f; }else if(veh->m_vehType == VEHICLE_TYPE_BIKE){ assert(0 && "TODO - but unused"); } @@ -1909,6 +1948,7 @@ STARTPATCHES InjectHook(0x4970C0, &CPhysical::AddCollisionRecord_Treadable, PATCH_JUMP); InjectHook(0x497240, &CPhysical::GetHasCollidedWith, PATCH_JUMP); InjectHook(0x49F820, &CPhysical::RemoveRefsToEntity, PATCH_JUMP); + InjectHook(0x49F890, &CPhysical::PlacePhysicalRelativeToOtherPhysical, PATCH_JUMP); #define F3 float, float, float InjectHook(0x495B10, &CPhysical::ApplyMoveSpeed, PATCH_JUMP); @@ -1918,6 +1958,7 @@ STARTPATCHES InjectHook(0x495D90, (void (CPhysical::*)(F3))&CPhysical::ApplyFrictionMoveForce, PATCH_JUMP); InjectHook(0x495E10, (void (CPhysical::*)(F3, F3))&CPhysical::ApplyFrictionTurnForce, PATCH_JUMP); InjectHook(0x499890, &CPhysical::ApplySpringCollision, PATCH_JUMP); + InjectHook(0x499990, &CPhysical::ApplySpringDampening, PATCH_JUMP); InjectHook(0x495B50, &CPhysical::ApplyGravity, PATCH_JUMP); InjectHook(0x495B80, (void (CPhysical::*)(void))&CPhysical::ApplyFriction, PATCH_JUMP); InjectHook(0x495C20, &CPhysical::ApplyAirResistance, PATCH_JUMP); diff --git a/src/entities/Physical.h b/src/entities/Physical.h index 0f517cf3..81d3d649 100644 --- a/src/entities/Physical.h +++ b/src/entities/Physical.h @@ -81,6 +81,7 @@ public: void AddCollisionRecord_Treadable(CEntity *ent); bool GetHasCollidedWith(CEntity *ent); void RemoveRefsToEntity(CEntity *ent); + static void PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos); float GetDistanceSq(void) { return m_vecMoveSpeed.MagnitudeSqr() * sq(CTimer::GetTimeStep()); } // get speed of point p relative to entity center @@ -104,6 +105,9 @@ public: bIsInSafePosition = false; } + const CVector &GetMoveSpeed() { return m_vecMoveSpeed; } + const CVector &GetTurnSpeed() { return m_vecTurnSpeed; } + void ApplyMoveSpeed(void); void ApplyTurnSpeed(void); // Force actually means Impulse here @@ -117,7 +121,9 @@ public: void ApplyFrictionMoveForce(const CVector &j) { ApplyFrictionMoveForce(j.x, j.y, j.z); } void ApplyFrictionTurnForce(float jx, float jy, float jz, float rx, float ry, float rz); void ApplyFrictionTurnForce(const CVector &j, const CVector &p) { ApplyFrictionTurnForce(j.x, j.y, j.z, p.x, p.y, p.z); } - void ApplySpringCollision(float f1, CVector &v, CVector &p, float f2, float f3); + // springRatio: 1.0 fully extended, 0.0 fully compressed + bool ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias); + bool ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed); void ApplyGravity(void); void ApplyFriction(void); void ApplyAirResistance(void); diff --git a/src/math/Vector.h b/src/math/Vector.h index 2c431d0d..b49f00f2 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -38,35 +38,35 @@ public: x = 1.0f; } - inline const CVector &operator+=(CVector const &right) { + const CVector &operator+=(CVector const &right) { x += right.x; y += right.y; z += right.z; return *this; } - inline const CVector &operator-=(CVector const &right) { + const CVector &operator-=(CVector const &right) { x -= right.x; y -= right.y; z -= right.z; return *this; } - inline const CVector &operator*=(float right) { + const CVector &operator*=(float right) { x *= right; y *= right; z *= right; return *this; } - inline const CVector &operator/=(float right) { + const CVector &operator/=(float right) { x /= right; y /= right; z /= right; return *this; } - inline CVector operator-() const { + CVector operator-() const { return CVector(-x, -y, -z); } diff --git a/src/MloInstance.cpp b/src/modelinfo/MloInstance.cpp similarity index 100% rename from src/MloInstance.cpp rename to src/modelinfo/MloInstance.cpp diff --git a/src/MloInstance.h b/src/modelinfo/MloInstance.h similarity index 100% rename from src/MloInstance.h rename to src/modelinfo/MloInstance.h diff --git a/src/entities/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp similarity index 100% rename from src/entities/CutsceneHead.cpp rename to src/objects/CutsceneHead.cpp diff --git a/src/entities/CutsceneHead.h b/src/objects/CutsceneHead.h similarity index 100% rename from src/entities/CutsceneHead.h rename to src/objects/CutsceneHead.h diff --git a/src/entities/CutsceneObject.cpp b/src/objects/CutsceneObject.cpp similarity index 100% rename from src/entities/CutsceneObject.cpp rename to src/objects/CutsceneObject.cpp diff --git a/src/entities/CutsceneObject.h b/src/objects/CutsceneObject.h similarity index 100% rename from src/entities/CutsceneObject.h rename to src/objects/CutsceneObject.h diff --git a/src/entities/DummyObject.cpp b/src/objects/DummyObject.cpp similarity index 100% rename from src/entities/DummyObject.cpp rename to src/objects/DummyObject.cpp diff --git a/src/entities/DummyObject.h b/src/objects/DummyObject.h similarity index 100% rename from src/entities/DummyObject.h rename to src/objects/DummyObject.h diff --git a/src/entities/Object.cpp b/src/objects/Object.cpp similarity index 100% rename from src/entities/Object.cpp rename to src/objects/Object.cpp diff --git a/src/entities/Object.h b/src/objects/Object.h similarity index 100% rename from src/entities/Object.h rename to src/objects/Object.h diff --git a/src/control/ObjectData.cpp b/src/objects/ObjectData.cpp similarity index 100% rename from src/control/ObjectData.cpp rename to src/objects/ObjectData.cpp diff --git a/src/control/ObjectData.h b/src/objects/ObjectData.h similarity index 100% rename from src/control/ObjectData.h rename to src/objects/ObjectData.h diff --git a/src/ParticleObject.cpp b/src/objects/ParticleObject.cpp similarity index 100% rename from src/ParticleObject.cpp rename to src/objects/ParticleObject.cpp diff --git a/src/ParticleObject.h b/src/objects/ParticleObject.h similarity index 100% rename from src/ParticleObject.h rename to src/objects/ParticleObject.h diff --git a/src/entities/Projectile.cpp b/src/objects/Projectile.cpp similarity index 100% rename from src/entities/Projectile.cpp rename to src/objects/Projectile.cpp diff --git a/src/entities/Projectile.h b/src/objects/Projectile.h similarity index 100% rename from src/entities/Projectile.h rename to src/objects/Projectile.h diff --git a/src/entities/CivilianPed.cpp b/src/peds/CivilianPed.cpp similarity index 100% rename from src/entities/CivilianPed.cpp rename to src/peds/CivilianPed.cpp diff --git a/src/entities/CivilianPed.h b/src/peds/CivilianPed.h similarity index 100% rename from src/entities/CivilianPed.h rename to src/peds/CivilianPed.h diff --git a/src/entities/CopPed.cpp b/src/peds/CopPed.cpp similarity index 100% rename from src/entities/CopPed.cpp rename to src/peds/CopPed.cpp diff --git a/src/entities/CopPed.h b/src/peds/CopPed.h similarity index 100% rename from src/entities/CopPed.h rename to src/peds/CopPed.h diff --git a/src/entities/DummyPed.h b/src/peds/DummyPed.h similarity index 100% rename from src/entities/DummyPed.h rename to src/peds/DummyPed.h diff --git a/src/entities/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp similarity index 100% rename from src/entities/EmergencyPed.cpp rename to src/peds/EmergencyPed.cpp diff --git a/src/entities/EmergencyPed.h b/src/peds/EmergencyPed.h similarity index 100% rename from src/entities/EmergencyPed.h rename to src/peds/EmergencyPed.h diff --git a/src/entities/Ped.cpp b/src/peds/Ped.cpp similarity index 98% rename from src/entities/Ped.cpp rename to src/peds/Ped.cpp index 2cc8e4c4..e4cc848e 100644 --- a/src/entities/Ped.cpp +++ b/src/peds/Ped.cpp @@ -17,7 +17,7 @@ #include "PedPlacement.h" #include "Shadows.h" #include "Weather.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "Population.h" #include "Renderer.h" #include "Lights.h" @@ -559,11 +559,11 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround) if (currentPedState == PED_DEAD) { foundDead = 1; if (!deadPed) - deadPed = (CPed*)currentPed; + deadPed = currentPed; } else if (!currentPed->IsPedHeadAbovePos(-0.6f)) { foundOnTheFloor = 1; if (!pedOnTheFloor) - pedOnTheFloor = (CPed*)currentPed; + pedOnTheFloor = currentPed; } } } else if ((distance >= 0.8f || angleDiff >= DEGTORAD(75.0f)) @@ -574,11 +574,11 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround) if (angleDiff < DEGTORAD(75.0f)) { foundBelow = 1; if (!pedBelow) - pedBelow = (CPed*)currentPed; + pedBelow = currentPed; } } else { foundBelow = 1; - pedBelow = (CPed*)currentPed; + pedBelow = currentPed; break; } } @@ -599,7 +599,7 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround) } if (pedOnGround) - * pedOnGround = (CPed*)currentPed; + * pedOnGround = currentPed; return stateToReturn; } @@ -1371,7 +1371,7 @@ CPed::RestartNonPartialAnims(void) { CAnimBlendAssociation *assoc; - for (assoc = RpAnimBlendClumpGetFirstAssociation((RpClump*)m_rwObject); !assoc; assoc = RpAnimBlendGetNextAssociation(assoc)) { + for (assoc = RpAnimBlendClumpGetFirstAssociation((RpClump*)m_rwObject); assoc; assoc = RpAnimBlendGetNextAssociation(assoc)) { if (!assoc->IsPartial()) assoc->flags |= ASSOC_RUNNING; } @@ -1681,7 +1681,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) float pedZSpeedOnExit = m_vecMoveSpeed.z - 0.008f * CTimer::GetTimeStep(); // If we're not in ground at next step, apply animation - if (neededPos.z + pedZSpeedOnExit > autoZPos.z) { + if (neededPos.z + pedZSpeedOnExit >= autoZPos.z) { m_vecMoveSpeed.z = pedZSpeedOnExit; ApplyMoveSpeed(); // Removing below line breaks the animation @@ -1743,9 +1743,9 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) neededPos -= timeUntilStateChange * m_vecOffsetSeek; } - if (limitedAngle >= PI + m_fRotationCur) { + if (limitedAngle > PI + m_fRotationCur) { limitedAngle -= 2 * PI; - } else if (limitedAngle <= m_fRotationCur - PI) { + } else if (limitedAngle < m_fRotationCur - PI) { limitedAngle += 2 * PI; } m_fRotationCur -= (m_fRotationCur - limitedAngle) * (1.0f - timeUntilStateChange); @@ -2377,7 +2377,7 @@ CPed::SetLeader(CEntity *leader) m_leader = (CPed*)leader; if(m_leader) - m_leader->RegisterReference((CEntity **)m_leader); + m_leader->RegisterReference((CEntity **)&m_leader); } void @@ -2459,9 +2459,9 @@ CPed::SetObjective(eObjective newObj, void *entity) m_ped_flagD20 = false; m_vecSeekVehicle = CVector(0.0f, 0.0f, 0.0f); m_pedInObjective = (CPed*)entity; - m_pedInObjective->RegisterReference((CEntity**)m_pedInObjective); + m_pedInObjective->RegisterReference((CEntity**)&m_pedInObjective); m_pLookTarget = (CEntity*)entity; - m_pLookTarget->RegisterReference((CEntity**)m_pLookTarget); + m_pLookTarget->RegisterReference((CEntity**)&m_pLookTarget); return; case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE: case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS: @@ -2469,17 +2469,17 @@ CPed::SetObjective(eObjective newObj, void *entity) case OBJECTIVE_FIGHT_CHAR: m_vecSeekVehicle = CVector(0.0f, 0.0f, 0.0f); m_pedInObjective = (CPed*)entity; - m_pedInObjective->RegisterReference((CEntity**)m_pedInObjective); + m_pedInObjective->RegisterReference((CEntity**)&m_pedInObjective); return; case OBJECTIVE_FOLLOW_PED_IN_FORMATION: m_pedInObjective = (CPed*)entity; - m_pedInObjective->RegisterReference((CEntity**)m_pedInObjective); + m_pedInObjective->RegisterReference((CEntity**)&m_pedInObjective); m_pedFormation = 1; return; case OBJECTIVE_LEAVE_VEHICLE: case OBJECTIVE_FLEE_CAR: m_carInObjective = (CVehicle*)entity; - m_carInObjective->RegisterReference((CEntity **)m_carInObjective); + m_carInObjective->RegisterReference((CEntity **)&m_carInObjective); if (!m_carInObjective->bIsBus || m_leaveCarTimer) return; break; @@ -2497,9 +2497,9 @@ CPed::SetObjective(eObjective newObj, void *entity) case OBJECTIVE_SOLICIT: case OBJECTIVE_BUY_ICE_CREAM: m_carInObjective = (CVehicle*)entity; - m_carInObjective->RegisterReference((CEntity**)m_carInObjective); + m_carInObjective->RegisterReference((CEntity**)&m_carInObjective); m_pSeekTarget = m_carInObjective; - m_pSeekTarget->RegisterReference((CEntity**)m_pSeekTarget); + m_pSeekTarget->RegisterReference((CEntity**)&m_pSeekTarget); m_vecSeekVehicle = CVector(0.0f, 0.0f, 0.0f); if (newObj == OBJECTIVE_SOLICIT) { m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 10000; diff --git a/src/entities/Ped.h b/src/peds/Ped.h similarity index 97% rename from src/entities/Ped.h rename to src/peds/Ped.h index c6d61df4..0493eeee 100644 --- a/src/entities/Ped.h +++ b/src/peds/Ped.h @@ -524,11 +524,11 @@ public: void SetPedStats(ePedStats); bool IsGangMember(void); - inline bool HasWeapon(uint8 weaponType) { return m_weapons[weaponType].m_eWeaponType == weaponType; } - inline CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; } - inline CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; } - inline RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; } - inline static uint8 GetVehEnterExitFlag(eVehEnter vehEnter) { + bool HasWeapon(uint8 weaponType) { return m_weapons[weaponType].m_eWeaponType == weaponType; } + CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; } + CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; } + RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; } + static uint8 GetVehEnterExitFlag(eVehEnter vehEnter) { switch (vehEnter) { case VEHICLE_ENTER_FRONT_RIGHT: return 4; diff --git a/src/entities/PedIK.cpp b/src/peds/PedIK.cpp similarity index 100% rename from src/entities/PedIK.cpp rename to src/peds/PedIK.cpp diff --git a/src/entities/PedIK.h b/src/peds/PedIK.h similarity index 100% rename from src/entities/PedIK.h rename to src/peds/PedIK.h diff --git a/src/control/PedPlacement.cpp b/src/peds/PedPlacement.cpp similarity index 100% rename from src/control/PedPlacement.cpp rename to src/peds/PedPlacement.cpp diff --git a/src/control/PedPlacement.h b/src/peds/PedPlacement.h similarity index 100% rename from src/control/PedPlacement.h rename to src/peds/PedPlacement.h diff --git a/src/control/PedStats.cpp b/src/peds/PedStats.cpp similarity index 100% rename from src/control/PedStats.cpp rename to src/peds/PedStats.cpp diff --git a/src/control/PedStats.h b/src/peds/PedStats.h similarity index 100% rename from src/control/PedStats.h rename to src/peds/PedStats.h diff --git a/src/control/PedType.cpp b/src/peds/PedType.cpp similarity index 100% rename from src/control/PedType.cpp rename to src/peds/PedType.cpp diff --git a/src/control/PedType.h b/src/peds/PedType.h similarity index 100% rename from src/control/PedType.h rename to src/peds/PedType.h diff --git a/src/entities/PlayerPed.cpp b/src/peds/PlayerPed.cpp similarity index 100% rename from src/entities/PlayerPed.cpp rename to src/peds/PlayerPed.cpp diff --git a/src/entities/PlayerPed.h b/src/peds/PlayerPed.h similarity index 100% rename from src/entities/PlayerPed.h rename to src/peds/PlayerPed.h diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 081aaa64..680720e0 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -496,7 +496,7 @@ void CHud::Draw() fZoneAlpha = 255.0f; break; case 2: - m_ZoneFadeTimer += (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_ZoneFadeTimer += CTimer::GetTimeStepInMilliseconds(); if (m_ZoneFadeTimer > 1000) { m_ZoneState = 1; m_ZoneFadeTimer = 1000; @@ -504,7 +504,7 @@ void CHud::Draw() fZoneAlpha = m_ZoneFadeTimer * 0.001f * 255.0f; break; case 3: - m_ZoneFadeTimer += (CTimer::GetTimeStep() * 0.02f * -1000.0f); + m_ZoneFadeTimer -= CTimer::GetTimeStepInMilliseconds(); if (m_ZoneFadeTimer < 0) { m_ZoneState = 0; m_ZoneFadeTimer = 0; @@ -512,7 +512,7 @@ void CHud::Draw() fZoneAlpha = m_ZoneFadeTimer * 0.001f * 255.0f; break; case 4: - m_ZoneFadeTimer += (CTimer::GetTimeStep() * 0.02f * -1000.0f); + m_ZoneFadeTimer -= CTimer::GetTimeStepInMilliseconds(); if (m_ZoneFadeTimer < 0) { m_ZoneFadeTimer = 0; m_ZoneToPrint = m_pLastZoneName; @@ -526,7 +526,7 @@ void CHud::Draw() } if (!m_Message[0]) { - m_ZoneNameTimer += (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_ZoneNameTimer += CTimer::GetTimeStepInMilliseconds(); CFont::SetJustifyOff(); CFont::SetPropOn(); CFont::SetBackgroundOff(); @@ -592,7 +592,7 @@ void CHud::Draw() fVehicleAlpha = 255.0f; break; case 2: - m_VehicleFadeTimer += (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_VehicleFadeTimer += CTimer::GetTimeStepInMilliseconds(); if (m_VehicleFadeTimer > 1000) { m_VehicleState = 1; m_VehicleFadeTimer = 1000; @@ -600,7 +600,7 @@ void CHud::Draw() fVehicleAlpha = m_VehicleFadeTimer * 0.001f * 255.0f; break; case 3: - m_VehicleFadeTimer += (CTimer::GetTimeStep() * 0.02f * -1000.0f); + m_VehicleFadeTimer -= CTimer::GetTimeStepInMilliseconds(); if (m_VehicleFadeTimer < 0) { m_VehicleState = 0; m_VehicleFadeTimer = 0; @@ -608,7 +608,7 @@ void CHud::Draw() fVehicleAlpha = m_VehicleFadeTimer * 0.001f * 255.0f; break; case 4: - m_VehicleFadeTimer += (CTimer::GetTimeStep() * 0.02f * -1000.0f); + m_VehicleFadeTimer -= CTimer::GetTimeStepInMilliseconds(); if (m_VehicleFadeTimer < 0) { m_VehicleFadeTimer = 0; m_pVehicleNameToPrint = m_pLastVehicleName; @@ -622,7 +622,7 @@ void CHud::Draw() } if (!m_Message[0]) { - m_VehicleNameTimer += (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_VehicleNameTimer += CTimer::GetTimeStepInMilliseconds(); CFont::SetJustifyOff(); CFont::SetPropOn(); CFont::SetBackgroundOff(); @@ -924,11 +924,11 @@ void CHud::Draw() CFont::SetFontStyle(FONT_HEADING); if (BigMessageX[0] >= (SCREEN_WIDTH - 20)) { - BigMessageInUse[0] += (CTimer::GetTimeStep() * 0.02f * 120.0f); + BigMessageInUse[0] += (CTimer::GetTimeStepInSeconds() * 120.0f); if (BigMessageInUse[0] >= 120.0f) { BigMessageInUse[0] = 120.0; - BigMessageAlpha[0] += (CTimer::GetTimeStep() * 0.02f * -255.0f); + BigMessageAlpha[0] += (CTimer::GetTimeStepInSeconds() * -255.0f); } if (BigMessageAlpha[0] <= 0.0f) { @@ -937,8 +937,8 @@ void CHud::Draw() } } else { - BigMessageX[0] += (CTimer::GetTimeStep() * 0.02f * 255.0f); - BigMessageAlpha[0] += (CTimer::GetTimeStep() * 0.02f * 255.0f); + BigMessageX[0] += (CTimer::GetTimeStepInSeconds() * 255.0f); + BigMessageAlpha[0] += (CTimer::GetTimeStepInSeconds() * 255.0f); if (BigMessageAlpha[0] >= 255.0f) BigMessageAlpha[0] = 255.0f; @@ -963,7 +963,7 @@ void CHud::Draw() // WastedBustedText if (m_BigMessage[2][0]) { if (BigMessageInUse[2] != 0.0f) { - BigMessageAlpha[2] += (CTimer::GetTimeStep() * 0.02f * 255.0f); + BigMessageAlpha[2] += (CTimer::GetTimeStepInSeconds() * 255.0f); if (BigMessageAlpha[2] > 255.0f) BigMessageAlpha[2] = 255.0; @@ -1045,7 +1045,7 @@ void CHud::DrawAfterFade() } break; case 2: - m_HelpMessageFadeTimer += 2 * (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_HelpMessageFadeTimer += 2 * CTimer::GetTimeStepInMilliseconds(); if (m_HelpMessageFadeTimer > 0) { m_HelpMessageState = 1; m_HelpMessageFadeTimer = 0; @@ -1053,7 +1053,7 @@ void CHud::DrawAfterFade() fAlpha = m_HelpMessageFadeTimer * 0.001f * 255.0f; break; case 3: - m_HelpMessageFadeTimer -= 2 * (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_HelpMessageFadeTimer -= 2 * CTimer::GetTimeStepInMilliseconds(); if (m_HelpMessageFadeTimer >= 0) { m_HelpMessageState = 0; m_HelpMessageFadeTimer = 0; @@ -1061,7 +1061,7 @@ void CHud::DrawAfterFade() fAlpha = m_HelpMessageFadeTimer * 0.001f * 255.0f; break; case 4: - m_HelpMessageFadeTimer -= 2 * (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_HelpMessageFadeTimer -= 2 * CTimer::GetTimeStepInMilliseconds(); if (m_HelpMessageFadeTimer >= 0) { m_HelpMessageState = 2; m_HelpMessageFadeTimer = 0; @@ -1073,7 +1073,7 @@ void CHud::DrawAfterFade() break; } - m_HelpMessageTimer += (CTimer::GetTimeStep() * 0.02f * 1000.0f); + m_HelpMessageTimer += CTimer::GetTimeStepInMilliseconds(); CFont::SetAlphaFade(fAlpha); CFont::SetCentreOff(); @@ -1121,7 +1121,7 @@ void CHud::DrawAfterFade() // Oddjob result if (OddJob2OffTimer > 0) - OddJob2OffTimer = OddJob2OffTimer - (CTimer::GetTimeStep() * 0.02f * 1000.0f); + OddJob2OffTimer = OddJob2OffTimer - CTimer::GetTimeStepInMilliseconds(); static float fStep; if (!m_BigMessage[1][0] && m_BigMessage[4][0] && m_BigMessage[5][0] && OddJob2OffTimer <= 0.0f) { @@ -1197,11 +1197,11 @@ void CHud::DrawAfterFade() CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); if (BigMessageX[1] >= (SCREEN_WIDTH - 20)) { - BigMessageInUse[1] += (CTimer::GetTimeStep() * 0.02f * 120.0f); + BigMessageInUse[1] += (CTimer::GetTimeStepInSeconds() * 120.0f); if (BigMessageInUse[1] >= 120.0f) { BigMessageInUse[1] = 120.0; - BigMessageAlpha[1] += (CTimer::GetTimeStep() * 0.02f * -255.0f); + BigMessageAlpha[1] += (CTimer::GetTimeStepInSeconds() * -255.0f); } if (BigMessageAlpha[1] <= 0) { m_BigMessage[1][0] = 0; @@ -1209,8 +1209,8 @@ void CHud::DrawAfterFade() } } else { - BigMessageX[1] += (CTimer::GetTimeStep() * 0.02f * 255.0f); - BigMessageAlpha[1] += (CTimer::GetTimeStep() * 0.02f * 255.0f); + BigMessageX[1] += (CTimer::GetTimeStepInSeconds() * 255.0f); + BigMessageAlpha[1] += (CTimer::GetTimeStepInSeconds() * 255.0f); if (BigMessageAlpha[1] >= 255.0f) BigMessageAlpha[1] = 255.0f; diff --git a/src/render/Lights.cpp b/src/render/Lights.cpp index 1e27ec48..cd83a898 100644 --- a/src/render/Lights.cpp +++ b/src/render/Lights.cpp @@ -6,7 +6,7 @@ #include "Timecycle.h" #include "Coronas.h" #include "Weather.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "Frontend.h" RpLight *&pAmbient = *(RpLight**)0x885B6C; diff --git a/src/render/Particle.h b/src/render/Particle.h index 92b6809e..25677569 100644 --- a/src/render/Particle.h +++ b/src/render/Particle.h @@ -74,7 +74,7 @@ public: static void RemovePSystem(tParticleType type); static void RemoveParticle(CParticle *pParticle, CParticle *pPrevParticle, tParticleSystemData *pPSystemData); - static inline void _Next(CParticle *&pParticle, CParticle *&pPrevParticle, tParticleSystemData *pPSystemData, bool bRemoveParticle) + static void _Next(CParticle *&pParticle, CParticle *&pPrevParticle, tParticleSystemData *pPSystemData, bool bRemoveParticle) { if ( bRemoveParticle ) { diff --git a/src/Timecycle.cpp b/src/render/Timecycle.cpp similarity index 99% rename from src/Timecycle.cpp rename to src/render/Timecycle.cpp index c04295dd..af154716 100644 --- a/src/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -5,7 +5,7 @@ #include "Weather.h" #include "Camera.h" #include "Shadows.h" -#include "CullZones.h" +#include "ZoneCull.h" #include "CutsceneMgr.h" #include "FileMgr.h" #include "Timecycle.h" diff --git a/src/Timecycle.h b/src/render/Timecycle.h similarity index 100% rename from src/Timecycle.h rename to src/render/Timecycle.h diff --git a/src/Weather.cpp b/src/render/Weather.cpp similarity index 100% rename from src/Weather.cpp rename to src/render/Weather.cpp diff --git a/src/Weather.h b/src/render/Weather.h similarity index 100% rename from src/Weather.h rename to src/render/Weather.h diff --git a/src/entities/Automobile.cpp b/src/vehicles/Automobile.cpp similarity index 100% rename from src/entities/Automobile.cpp rename to src/vehicles/Automobile.cpp diff --git a/src/entities/Automobile.h b/src/vehicles/Automobile.h similarity index 90% rename from src/entities/Automobile.h rename to src/vehicles/Automobile.h index b6617f4b..630635c7 100644 --- a/src/entities/Automobile.h +++ b/src/vehicles/Automobile.h @@ -25,8 +25,8 @@ public: CDoor Doors[6]; RwFrame *m_aCarNodes[NUM_CAR_NODES]; CColPoint m_aWheelColPoints[4]; - float m_aWheelDist[4]; - float m_aWheelDist_2[4]; + float m_aSuspensionSpringRatio[4]; + float m_aSuspensionSpringRatioPrev[4]; float m_aWheelSkidThing[4]; int field_49C; bool m_aWheelSkidmarkMuddy[4]; @@ -37,7 +37,7 @@ public: uint8 stuff3[12]; uint32 m_nBusDoorTimerEnd; uint32 m_nBusDoorTimerStart; - float m_aSuspensionRange[4]; + float m_aSuspensionSpringLength[4]; float m_aSuspensionLineLength[4]; float m_fHeightAboveRoad; float m_fImprovedHandling; @@ -65,4 +65,3 @@ public: void dtor() { this->CAutomobile::~CAutomobile(); } }; static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error"); -static_assert(offsetof(CAutomobile, m_aWheelDist) == 0x46C, "CAutomobile: error"); diff --git a/src/entities/Boat.cpp b/src/vehicles/Boat.cpp similarity index 100% rename from src/entities/Boat.cpp rename to src/vehicles/Boat.cpp diff --git a/src/entities/Boat.h b/src/vehicles/Boat.h similarity index 100% rename from src/entities/Boat.h rename to src/vehicles/Boat.h diff --git a/src/DamageManager.cpp b/src/vehicles/DamageManager.cpp similarity index 100% rename from src/DamageManager.cpp rename to src/vehicles/DamageManager.cpp diff --git a/src/DamageManager.h b/src/vehicles/DamageManager.h similarity index 100% rename from src/DamageManager.h rename to src/vehicles/DamageManager.h diff --git a/src/control/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp similarity index 100% rename from src/control/HandlingMgr.cpp rename to src/vehicles/HandlingMgr.cpp diff --git a/src/control/HandlingMgr.h b/src/vehicles/HandlingMgr.h similarity index 100% rename from src/control/HandlingMgr.h rename to src/vehicles/HandlingMgr.h diff --git a/src/entities/Heli.cpp b/src/vehicles/Heli.cpp similarity index 100% rename from src/entities/Heli.cpp rename to src/vehicles/Heli.cpp diff --git a/src/entities/Heli.h b/src/vehicles/Heli.h similarity index 100% rename from src/entities/Heli.h rename to src/vehicles/Heli.h diff --git a/src/entities/Plane.cpp b/src/vehicles/Plane.cpp similarity index 100% rename from src/entities/Plane.cpp rename to src/vehicles/Plane.cpp diff --git a/src/entities/Plane.h b/src/vehicles/Plane.h similarity index 100% rename from src/entities/Plane.h rename to src/vehicles/Plane.h diff --git a/src/entities/Train.cpp b/src/vehicles/Train.cpp similarity index 100% rename from src/entities/Train.cpp rename to src/vehicles/Train.cpp diff --git a/src/entities/Train.h b/src/vehicles/Train.h similarity index 100% rename from src/entities/Train.h rename to src/vehicles/Train.h diff --git a/src/control/Transmission.cpp b/src/vehicles/Transmission.cpp similarity index 100% rename from src/control/Transmission.cpp rename to src/vehicles/Transmission.cpp diff --git a/src/control/Transmission.h b/src/vehicles/Transmission.h similarity index 100% rename from src/control/Transmission.h rename to src/vehicles/Transmission.h diff --git a/src/entities/Vehicle.cpp b/src/vehicles/Vehicle.cpp similarity index 99% rename from src/entities/Vehicle.cpp rename to src/vehicles/Vehicle.cpp index 25bede65..dccd9195 100644 --- a/src/entities/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -429,7 +429,7 @@ CVehicle::ProcessCarAlarm(void) if(m_nAlarmState == 0 || m_nAlarmState == -1) return; - step = CTimer::GetTimeStep()/50.0f * 1000.0f; + step = CTimer::GetTimeStepInMilliseconds(); if((uint16)m_nAlarmState < step) m_nAlarmState = 0; else diff --git a/src/entities/Vehicle.h b/src/vehicles/Vehicle.h similarity index 98% rename from src/entities/Vehicle.h rename to src/vehicles/Vehicle.h index 7b9bebef..39a56fe0 100644 --- a/src/entities/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -69,13 +69,6 @@ enum eDoors DOOR_REAR_RIGHT }; -enum { - GETTING_IN_OUT_FL = 1, - GETTING_IN_OUT_RL = 2, - GETTING_IN_OUT_FR = 4, - GETTING_IN_OUT_RR = 8 -}; - class CVehicle : public CPhysical { public: