diff options
author | aap <aap@papnet.eu> | 2019-07-16 18:31:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-16 18:31:18 +0200 |
commit | 9477aca836efd0bcf5017ff6a6c81f2326fd97c1 (patch) | |
tree | b80e8bc8569fbdda5929123a8f47d0c62aea0ab0 | |
parent | Phone, World, Ped (diff) | |
parent | Merge pull request #136 from Nick007J/master (diff) | |
download | re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.tar re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.tar.gz re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.tar.bz2 re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.tar.lz re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.tar.xz re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.tar.zst re3-9477aca836efd0bcf5017ff6a6c81f2326fd97c1.zip |
32 files changed, 1374 insertions, 435 deletions
diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 1c1316a8..2019c394 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -20,9 +20,9 @@ WRAPPER void cDMAudio::PlayFrontEndSound(uint32, uint32) { EAXJMP(0x57CC20); } WRAPPER void cDMAudio::PlayFrontEndTrack(uint32, uint32) { EAXJMP(0x57CC80); } WRAPPER void cDMAudio::StopFrontEndTrack() { EAXJMP(0x57CCB0); } WRAPPER void cDMAudio::PlayOneShot(int32 audioentity, uint16 sound/*eSound*/, float) { EAXJMP(0x57C840); } -WRAPPER void cDMAudio::SetMusicMasterVolume(int8) { EAXJMP(0x57C8C0); } -WRAPPER void cDMAudio::SetEffectsMasterVolume(int8) { EAXJMP(0x57C890); } -WRAPPER int8 cDMAudio::SetCurrent3DProvider(int8) { EAXJMP(0x57C9B0); } +WRAPPER void cDMAudio::SetMusicMasterVolume(uint8) { EAXJMP(0x57C8C0); } +WRAPPER void cDMAudio::SetEffectsMasterVolume(uint8) { EAXJMP(0x57C890); } +WRAPPER uint8 cDMAudio::SetCurrent3DProvider(uint8) { EAXJMP(0x57C9B0); } WRAPPER int32 cDMAudio::SetSpeakerConfig(int32) { EAXJMP(0x57C9D0); } WRAPPER int32 cDMAudio::GetRadioInCar() { EAXJMP(0x57CE40); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 0a2ce6ac..b671e260 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -192,9 +192,9 @@ public: void PlayFrontEndTrack(uint32, uint32); void StopFrontEndTrack(); void PlayOneShot(int32 audioentity, uint16 sound/*eSound*/, float); - void SetMusicMasterVolume(int8); - void SetEffectsMasterVolume(int8); - int8 SetCurrent3DProvider(int8); + void SetMusicMasterVolume(uint8); + void SetEffectsMasterVolume(uint8); + uint8 SetCurrent3DProvider(uint8); int32 SetSpeakerConfig(int32); int32 GetRadioInCar(void); void SetEffectsFadeVol(uint8); diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h index 364cb633..b1c824d8 100644 --- a/src/control/AutoPilot.h +++ b/src/control/AutoPilot.h @@ -72,8 +72,8 @@ public: int8 m_nPreviousDirection; int8 m_nCurrentDirecton; int8 m_nNextDirection; - int8 m_nPreviousPathDirection; - int8 m_nCurrentPathDirection; + int8 m_nPreviousLane; + int8 m_nCurrentLane; eCarDrivingStyle m_nDrivingStyle; eCarMission m_nCarMission; eCarTempAction m_nAnimationId; @@ -101,8 +101,7 @@ public: m_nCurrentPathNodeInfo = m_nNextPathNodeInfo; m_nNextDirection = 1; m_nCurrentDirecton = m_nNextDirection; - m_nCurrentPathDirection = 0; - m_nPreviousPathDirection = m_nCurrentPathDirection; + m_nPreviousLane = m_nCurrentLane = 0; m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; m_nCarMission = MISSION_NONE; m_nAnimationId = TEMPACT_NONE; diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index b0f4c1ed..8c2ee76c 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -12,3 +12,5 @@ WRAPPER void CCarCtrl::SwitchVehicleToRealPhysics(CVehicle*) { EAXJMP(0x41F7F0); WRAPPER void CCarCtrl::AddToCarArray(int32 id, int32 vehclass) { EAXJMP(0x4182F0); } WRAPPER void CCarCtrl::UpdateCarCount(CVehicle*, bool) { EAXJMP(0x4202E0); } WRAPPER int32 CCarCtrl::ChooseCarModel(int32 vehclass) { EAXJMP(0x418110); } +WRAPPER bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool) { EAXJMP(0x41FA00); } +WRAPPER void CCarCtrl::JoinCarWithRoadSystem(CVehicle*) { EAXJMP(0x41F820); } diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h index c54f747f..1fe3c31e 100644 --- a/src/control/CarCtrl.h +++ b/src/control/CarCtrl.h @@ -9,6 +9,8 @@ public: static void AddToCarArray(int32 id, int32 vehclass); static void UpdateCarCount(CVehicle*, bool); static int32 ChooseCarModel(int32 vehclass); + static bool JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool); + static void JoinCarWithRoadSystem(CVehicle*); static int32 &NumLawEnforcerCars; static int32 &NumAmbulancesOnDuty; diff --git a/src/control/Population.cpp b/src/control/Population.cpp index 1ae5962d..72de300d 100644 --- a/src/control/Population.cpp +++ b/src/control/Population.cpp @@ -7,6 +7,7 @@ PedGroup *CPopulation::ms_pPedGroups = (PedGroup*)0x6E9248; bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6; int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570; float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C; +uint32 &CPopulation::ms_nTotalMissionPeds = *(uint32*)0x8F5F70; WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); } WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); } diff --git a/src/control/Population.h b/src/control/Population.h index 6bd2e3ae..e24ace3a 100644 --- a/src/control/Population.h +++ b/src/control/Population.h @@ -15,6 +15,7 @@ public: static bool &ms_bGivePedsWeapons; static int32 &m_AllRandomPedsThisType; static float &PedDensityMultiplier; + static uint32 &ms_nTotalMissionPeds; static void UpdatePedCount(uint32, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index f3a18195..a363cc41 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -4,10 +4,17 @@ #include "Script.h" #include "ScriptCommands.h" +#include "Boat.h" #include "Camera.h" #include "CarCtrl.h" +#include "CivilianPed.h" +#include "Clock.h" +#include "CopPed.h" #include "DMAudio.h" +#include "EmergencyPed.h" #include "FileMgr.h" +#include "General.h" +#include "HandlingMgr.h" #include "Hud.h" #include "Messages.h" #include "ModelIndices.h" @@ -18,9 +25,11 @@ #include "Population.h" #include "Replay.h" #include "Streaming.h" +#include "Text.h" #include "User.h" #include "Weather.h" #include "World.h" +#include "Zones.h" uint8 (&CTheScripts::ScriptSpace)[SIZE_SCRIPT_SPACE] = *(uint8(*)[SIZE_SCRIPT_SPACE])*(uintptr*)0x74B248; CRunningScript(&CTheScripts::ScriptsArray)[MAX_NUM_SCRIPTS] = *(CRunningScript(*)[MAX_NUM_SCRIPTS])*(uintptr*)0x6F5C08; @@ -1342,6 +1351,7 @@ int8 CRunningScript::ProcessCommandsFrom0To99(int32 command) *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) -= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; default: + assert(0); break; } return -1; @@ -1374,7 +1384,813 @@ void CRunningScript::UpdateCompareFlag(bool flag) } -WRAPPER int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) { EAXJMP(0x43AEA0); } +int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) +{ + switch (command) { + case COMMAND_SUB_INT_LVAR_FROM_INT_VAR: + *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) -= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_SUB_INT_VAR_FROM_INT_LVAR: + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) -= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_SUB_FLOAT_LVAR_FROM_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) -= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_SUB_FLOAT_VAR_FROM_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) -= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_MULT_INT_VAR_BY_INT_VAR: + *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_MULT_INT_LVAR_BY_INT_VAR: + *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_MULT_INT_VAR_BY_INT_LVAR: + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_MULT_INT_LVAR_BY_INT_LVAR: + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_DIV_INT_VAR_BY_INT_VAR: + *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_DIV_INT_LVAR_BY_INT_VAR: + *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_DIV_INT_VAR_BY_INT_LVAR: + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_DIV_INT_LVAR_BY_INT_LVAR: + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_ADD_TIMED_VAL_TO_FLOAT_VAR: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + CollectParameters(&m_nIp, 1); + *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + return 0; + } + case COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + CollectParameters(&m_nIp, 1); + *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + return 0; + } + case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_SUB_TIMED_VAL_FROM_FLOAT_VAR: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + CollectParameters(&m_nIp, 1); + *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + return 0; + } + case COMMAND_SUB_TIMED_VAL_FROM_FLOAT_LVAR: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + CollectParameters(&m_nIp, 1); + *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + return 0; + } + case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR: + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL) -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + case COMMAND_SET_VAR_INT_TO_VAR_INT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_SET_LVAR_INT_TO_VAR_INT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_SET_VAR_INT_TO_LVAR_INT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_SET_LVAR_INT_TO_LVAR_INT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_SET_VAR_FLOAT_TO_VAR_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_SET_LVAR_FLOAT_TO_LVAR_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_CSET_VAR_INT_TO_VAR_FLOAT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_CSET_VAR_FLOAT_TO_VAR_INT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + return 0; + } + case COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + return 0; + } + case COMMAND_ABS_VAR_INT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = ABS(*ptr); + return 0; + } + case COMMAND_ABS_LVAR_INT: + { + int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = ABS(*ptr); + return 0; + } + case COMMAND_ABS_VAR_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + *ptr = ABS(*ptr); + return 0; + } + case COMMAND_ABS_LVAR_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); + *ptr = ABS(*ptr); + return 0; + } + case COMMAND_GENERATE_RANDOM_FLOAT: + { + float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); + CGeneral::GetRandomNumber(); + CGeneral::GetRandomNumber(); + CGeneral::GetRandomNumber(); /* To make it EXTRA random! */ + *ptr = CGeneral::GetRandomNumber() / 65536.0f; + /* Between 0 and 0.5 on PC (oh well...), never used in original script. */ + return 0; + } + case COMMAND_GENERATE_RANDOM_INT: + /* On PC between 0 and 32767, even though script expects values between 0 and 65536 */ + *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) = CGeneral::GetRandomNumber(); + return 0; + case COMMAND_CREATE_CHAR: + { + CollectParameters(&m_nIp, 5); + switch (ScriptParams[1]) { + case MI_COP: + if (ScriptParams[0] = PEDTYPE_COP) + ScriptParams[1] = COP_STREET; + break; + case MI_SWAT: + if (ScriptParams[0] = PEDTYPE_COP) + ScriptParams[1] = COP_SWAT; + break; + case MI_FBI: + if (ScriptParams[0] = PEDTYPE_COP) + ScriptParams[1] = COP_FBI; + break; + case MI_ARMY: + if (ScriptParams[0] = PEDTYPE_COP) + ScriptParams[1] = COP_ARMY; + break; + case MI_MEDIC: + if (ScriptParams[0] = PEDTYPE_EMERGENCY) + ScriptParams[1] = PEDTYPE_EMERGENCY; + break; + case MI_FIREMAN: + if (ScriptParams[0] = PEDTYPE_FIREMAN) + ScriptParams[1] = PEDTYPE_FIREMAN; + break; + default: + break; + } + CPed* ped; + if (ScriptParams[0] == PEDTYPE_COP) + ped = new CCopPed((eCopType)ScriptParams[1]); + else if (ScriptParams[0] == PEDTYPE_EMERGENCY || ScriptParams[0] == PEDTYPE_FIREMAN) + ped = new CEmergencyPed(ScriptParams[1]); + else + ped = new CCivilianPed(ScriptParams[0], ScriptParams[1]); + ped->CharCreatedBy = MISSION_CHAR; + ped->bRespondsToThreats = false; + ped->m_ped_flagG2 = false; + CVector pos = *(CVector*)&ScriptParams[2]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + pos.z += 1.0f; + ped->GetPosition() = pos; + ped->SetOrientation(0.0f, 0.0f, 0.0f); + CTheScripts::ClearSpaceForMissionEntity(pos, ped); + CWorld::Add(ped); + ped->m_level = CTheZones::GetLevelFromPosition(pos); + CPopulation::ms_nTotalMissionPeds++; + ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped); + StoreParameters(&m_nIp, 1); + if (m_bIsMissionScript) + CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + return 0; + } + case COMMAND_DELETE_CHAR: + { + CollectParameters(&m_nIp, 1); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + if (ped) { + if (ped->bInVehicle && ped->m_pMyVehicle) { + if (ped->m_pMyVehicle->pDriver == ped) { + ped->m_pMyVehicle->RemoveDriver(); + ped->m_pMyVehicle->m_status = STATUS_ABANDONED; + if (ped->m_pMyVehicle->m_nDoorLock == CARLOCK_LOCKED_INITIALLY) + ped->m_pMyVehicle->m_nDoorLock = CARLOCK_UNLOCKED; + if (ped->m_nPedType == PEDTYPE_COP && ped->m_pMyVehicle->IsLawEnforcementVehicle()) + ped->m_pMyVehicle->ChangeLawEnforcerState(0); + } + else { + ped->m_pMyVehicle->RemovePassenger(ped); + } + } + CWorld::RemoveReferencesToDeletedObject(ped); + delete ped; + --CPopulation::ms_nTotalMissionPeds; + } + if (m_bIsMissionScript) + CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); + return 0; + } + case COMMAND_CHAR_WANDER_DIR: + { + CollectParameters(&m_nIp, 2); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + ped->ClearAll(); + int8 path = ScriptParams[1]; + if (ScriptParams[1] < 0 || ScriptParams[1] > 7) + path = CGeneral::GetRandomNumberInRange(0, 7); + ped->SetWanderPath(path); + return 0; + } + case COMMAND_CHAR_FOLLOW_PATH: + { + CollectParameters(&m_nIp, 4); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + ped->ClearAll(); + ped->SetFollowPath(pos); + return 0; + } + case COMMAND_CHAR_SET_IDLE: + { + CollectParameters(&m_nIp, 1); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + ped->m_bScriptObjectiveCompleted = false; + ped->SetObjective(OBJECTIVE_IDLE); + return 0; + } + case COMMAND_GET_CHAR_COORDINATES: + { + CollectParameters(&m_nIp, 1); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + CVehicle* vehicle; + CVector pos; + /* Seems a bit clumsy but I'll leave original flow */ + if (ped->bInVehicle) + vehicle = ped->m_pMyVehicle; + else + vehicle = nil; + if (vehicle) + pos = vehicle->GetPosition(); + else + pos = ped->GetPosition(); + *(CVector*)&ScriptParams[0] = pos; + StoreParameters(&m_nIp, 3); + return 0; + } + case COMMAND_SET_CHAR_COORDINATES: + { + CollectParameters(&m_nIp, 4); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + CVehicle* vehicle; + if (ped->bInVehicle) + vehicle = ped->m_pMyVehicle; + else + vehicle = nil; + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + /* The following block was once again written + * by someone not familiar with virtual functions. + * It doesn't require any ifs at all. + * To keep as close to original as possible, I'll keep it. + * Maybe there was more commented out/debug + * stuff, but I doubt it. + */ + if (!vehicle) { + pos.z += ped->GetDistanceFromCentreOfMassToBaseOfModel(); + ped->Teleport(pos); + CTheScripts::ClearSpaceForMissionEntity(pos, ped); + } + else if (vehicle->IsBoat()) { + pos.z += vehicle->GetDistanceFromCentreOfMassToBaseOfModel(); + vehicle->Teleport(pos); + CTheScripts::ClearSpaceForMissionEntity(pos, vehicle); + } + else { + pos.z += vehicle->GetDistanceFromCentreOfMassToBaseOfModel(); + vehicle->Teleport(pos); + CTheScripts::ClearSpaceForMissionEntity(pos, vehicle); + } + /* Short version of this command. + * + * CollectParameters(&m_nIp, 4); + * CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + * assert(ped); + * CEntity* entityToMove = ped->bInVehicle ? ped->m_pMyVehicle : ped; + * CVector pos = *(CVector*)&ScriptParams[1]; + * if (pos.z <= -100.0f) + * pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + * pos.z += entityToMove->GetDistanceFromCentreOfMassToBaseOfModel(); + * entityToMove->Teleport(pos); + * CTheScripts::ClearSpaceForMissionEntity(pos, entityToMove); + * + */ + return 0; + } + case COMMAND_IS_CHAR_STILL_ALIVE: + { + CollectParameters(&m_nIp, 1); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + UpdateCompareFlag(ped && ped->m_status != PED_DEAD && ped->m_status != PED_DIE); + return 0; + } + case COMMAND_IS_CHAR_IN_AREA_2D: + { + CollectParameters(&m_nIp, 6); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + CVehicle* vehicle; + if (ped->bInVehicle) + vehicle = ped->m_pMyVehicle; + else + vehicle = nil; + float x1, y1, x2, y2; + x1 = *(float*)&ScriptParams[1]; + y1 = *(float*)&ScriptParams[2]; + x2 = *(float*)&ScriptParams[3]; + y2 = *(float*)&ScriptParams[4]; + if (vehicle) + UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); + else + UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f); + if (CTheScripts::DbgFlag) + CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + return 0; + } + case COMMAND_IS_CHAR_IN_AREA_3D: + { + CollectParameters(&m_nIp, 8); + CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(ped); + CVehicle* vehicle; + if (ped->bInVehicle) + vehicle = ped->m_pMyVehicle; + else + vehicle = nil; + float x1, y1, z1, x2, y2, z2; + x1 = *(float*)&ScriptParams[1]; + y1 = *(float*)&ScriptParams[2]; + z1 = *(float*)&ScriptParams[3]; + x2 = *(float*)&ScriptParams[4]; + y2 = *(float*)&ScriptParams[5]; + z2 = *(float*)&ScriptParams[6]; + if (vehicle) + UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); + else + UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f); + if (CTheScripts::DbgFlag) + CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + return 0; + } + case COMMAND_CREATE_CAR: + { + CollectParameters(&m_nIp, 4); + int32 handle; + if (CModelInfo::IsBoatModel(ScriptParams[0])) { + CBoat* boat = new CBoat(ScriptParams[0], MISSION_VEHICLE); + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + pos.z += boat->GetDistanceFromCentreOfMassToBaseOfModel(); + boat->GetPosition() = pos; + CTheScripts::ClearSpaceForMissionEntity(pos, boat); + boat->m_status = STATUS_ABANDONED; + boat->bIsLocked = true; + boat->m_autoPilot.m_nCarMission = MISSION_NONE; + boat->m_autoPilot.m_nAnimationId = TEMPACT_NONE; /* Animation ID? */ + boat->m_autoPilot.m_nCruiseSpeed = boat->m_autoPilot.m_fMaxTrafficSpeed = 20.0f; + CWorld::Add(boat); + handle = CPools::GetVehiclePool()->GetIndex(boat); + } + else { + CVehicle* car; + if (!CModelInfo::IsBikeModel(ScriptParams[0])) + car = new CAutomobile(ScriptParams[0], MISSION_VEHICLE); + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); + car->GetPosition() = pos; + CTheScripts::ClearSpaceForMissionEntity(pos, car); + car->m_status = STATUS_ABANDONED; + car->bIsLocked = true; + car->m_autoPilot.m_nCarMission = MISSION_NONE; + car->m_autoPilot.m_nAnimationId = TEMPACT_NONE; /* Animation ID? */ + car->m_autoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; + car->m_autoPilot.m_nCruiseSpeed = car->m_autoPilot.m_fMaxTrafficSpeed = 9.0f; + car->m_autoPilot.m_nPreviousLane = car->m_autoPilot.m_nCurrentLane = 0; + car->bEngineOn = false; + car->m_level = CTheZones::GetLevelFromPosition(pos); + car->bHasBeenOwnedByPlayer = true; + CWorld::Add(car); + handle = CPools::GetVehiclePool()->GetIndex(car); + } + ScriptParams[0] = handle; + StoreParameters(&m_nIp, 1); + if (m_bIsMissionScript) + CTheScripts::MissionCleanup.AddEntityToList(handle, CLEANUP_CAR); + return 0; + } + case COMMAND_DELETE_CAR: + { + CollectParameters(&m_nIp, 1); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + if (car) { + CWorld::Remove(car); + CWorld::RemoveReferencesToDeletedObject(car); + delete car; + } + if (m_bIsMissionScript) + CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR); + return 0; + } + case COMMAND_CAR_GOTO_COORDINATES: + { + CollectParameters(&m_nIp, 4); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); + if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, pos, false)) + car->m_autoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT; + else + car->m_autoPilot.m_nCarMission = MISSION_GOTOCOORDS; + car->m_status = STATUS_PHYSICS; + car->bEngineOn = true; + car->m_autoPilot.m_nCruiseSpeed = max(car->m_autoPilot.m_nCruiseSpeed, 6); + car->m_autoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); + return 0; + } + case COMMAND_CAR_WANDER_RANDOMLY: + { + CollectParameters(&m_nIp, 1); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + CCarCtrl::JoinCarWithRoadSystem(car); + car->m_autoPilot.m_nCarMission = MISSION_CRUISE; + car->bEngineOn = true; + car->m_autoPilot.m_nCruiseSpeed = max(car->m_autoPilot.m_nCruiseSpeed, 6); + car->m_autoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); + return 0; + } + case COMMAND_CAR_SET_IDLE: + { + CollectParameters(&m_nIp, 1); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + car->m_autoPilot.m_nCarMission = MISSION_NONE; + return 0; + } + case COMMAND_GET_CAR_COORDINATES: + { + CollectParameters(&m_nIp, 1); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + *(CVector*)&ScriptParams[0] = car->GetPosition(); + StoreParameters(&m_nIp, 3); + return 0; + } + case COMMAND_SET_CAR_COORDINATES: + { + CollectParameters(&m_nIp, 4); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + CVector pos = *(CVector*)&ScriptParams[1]; + if (pos.z <= -100.0f) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); + car->bIsStatic = false; + /* Again weird usage of virtual functions. */ + if (car->IsBoat()) { + car->Teleport(pos); + CTheScripts::ClearSpaceForMissionEntity(pos, car); + } + else { + car->Teleport(pos); + CTheScripts::ClearSpaceForMissionEntity(pos, car); + /* May the following be inlined CCarCtrl function? */ + switch (car->m_autoPilot.m_nCarMission) { + case MISSION_CRUISE: + CCarCtrl::JoinCarWithRoadSystem(car); + break; + case MISSION_RAMPLAYER_FARAWAY: + case MISSION_RAMPLAYER_CLOSE: + case MISSION_BLOCKPLAYER_FARAWAY: + case MISSION_BLOCKPLAYER_CLOSE: + case MISSION_BLOCKPLAYER_HANDBRAKESTOP: + CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, FindPlayerCoors(), false); + break; + case MISSION_GOTOCOORDS: + case MISSION_GOTOCOORDS_STRAIGHT: + CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, car->m_autoPilot.m_vecDestinationCoors, false); + break; + case MISSION_GOTOCOORDS_ACCURATE: + case MISSION_GOTO_COORDS_STRAIGHT_ACCURATE: + CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, car->m_autoPilot.m_vecDestinationCoors, false); + break; + case MISSION_RAMCAR_FARAWAY: + case MISSION_RAMCAR_CLOSE: + case MISSION_BLOCKCAR_FARAWAY: + case MISSION_BLOCKCAR_CLOSE: + case MISSION_BLOCKCAR_HANDBRAKESTOP: + CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, car->m_autoPilot.m_pTargetCar->GetPosition(), false); + break; + default: + break; + } + } + return 0; + } + case COMMAND_IS_CAR_STILL_ALIVE: + { + CollectParameters(&m_nIp, 4); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + UpdateCompareFlag(car && car->m_status != STATUS_WRECKED && (car->IsBoat() || !car->bIsInWater)); + return 0; + } + case COMMAND_SET_CAR_CRUISE_SPEED: + { + CollectParameters(&m_nIp, 2); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + car->m_autoPilot.m_nCruiseSpeed = min(*(float*)&ScriptParams[1], 60.0f * car->m_handling->TransmissionData.fUnkMaxVelocity); + return 0; + } + case COMMAND_SET_CAR_DRIVING_STYLE: + { + CollectParameters(&m_nIp, 2); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + car->m_autoPilot.m_nDrivingStyle = (eCarDrivingStyle)ScriptParams[1]; + return 0; + } + case COMMAND_SET_CAR_MISSION: + { + CollectParameters(&m_nIp, 2); + CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(car); + car->m_autoPilot.m_nCarMission = (eCarMission)ScriptParams[1]; + car->m_autoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); + car->bEngineOn = true; + return 0; + } + case COMMAND_IS_CAR_IN_AREA_2D: + { + CollectParameters(&m_nIp, 6); + CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(vehicle); + float x1, y1, x2, y2; + x1 = *(float*)&ScriptParams[1]; + y1 = *(float*)&ScriptParams[2]; + x2 = *(float*)&ScriptParams[3]; + y2 = *(float*)&ScriptParams[4]; + UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2)); + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f); + if (CTheScripts::DbgFlag) + CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + return 0; + } + case COMMAND_IS_CAR_IN_AREA_3D: + { + CollectParameters(&m_nIp, 8); + CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(vehicle); + float x1, y1, z1, x2, y2, z2; + x1 = *(float*)&ScriptParams[1]; + y1 = *(float*)&ScriptParams[2]; + z1 = *(float*)&ScriptParams[3]; + x2 = *(float*)&ScriptParams[4]; + y2 = *(float*)&ScriptParams[5]; + z2 = *(float*)&ScriptParams[6]; + UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f); + if (CTheScripts::DbgFlag) + CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + return 0; + } + case COMMAND_SPECIAL_0: + case COMMAND_SPECIAL_1: + case COMMAND_SPECIAL_2: + case COMMAND_SPECIAL_3: + case COMMAND_SPECIAL_4: + case COMMAND_SPECIAL_5: + case COMMAND_SPECIAL_6: + case COMMAND_SPECIAL_7: + assert(0); + return 0; + case COMMAND_PRINT_BIG: + { + wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + m_nIp += 8; + CollectParameters(&m_nIp, 2); + CMessages::AddBigMessage(key, ScriptParams[0], ScriptParams[1] - 1); + return 0; + } + case COMMAND_PRINT: + { + wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + m_nIp += 8; + CollectParameters(&m_nIp, 2); + CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]); + return 0; + } + case COMMAND_PRINT_NOW: + { + wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + m_nIp += 8; + CollectParameters(&m_nIp, 2); + CMessages::AddMessageJumpQ(key, ScriptParams[0], ScriptParams[1]); + return 0; + } + case COMMAND_PRINT_SOON: + { + wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + m_nIp += 8; + CollectParameters(&m_nIp, 2); + CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]); + return 0; + } + case COMMAND_CLEAR_PRINTS: + CMessages::ClearMessages(); + return 0; + case COMMAND_GET_TIME_OF_DAY: + ScriptParams[0] = CClock::GetHours(); + ScriptParams[1] = CClock::GetMinutes(); + StoreParameters(&m_nIp, 2); + return 0; + case COMMAND_SET_TIME_OF_DAY: + CollectParameters(&m_nIp, 2); + CClock::SetGameClock(ScriptParams[0], ScriptParams[1]); + return 0; + case COMMAND_GET_MINUTES_TO_TIME_OF_DAY: + CollectParameters(&m_nIp, 2); + ScriptParams[0] = CClock::GetGameClockMinutesUntil(ScriptParams[0], ScriptParams[1]); + StoreParameters(&m_nIp, 1); + return 0; + case COMMAND_IS_POINT_ON_SCREEN: + { + CollectParameters(&m_nIp, 4); + CVector pos = *(CVector*)&ScriptParams[0]; + if (pos.z <= -100) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + UpdateCompareFlag(TheCamera.IsSphereVisible(pos, *(float*)&ScriptParams[3])); + } + case COMMAND_DEBUG_ON: + CTheScripts::DbgFlag = true; + return 0; + case COMMAND_DEBUG_OFF: + CTheScripts::DbgFlag = false; + return 0; + case COMMAND_RETURN_TRUE: + UpdateCompareFlag(true); + return 0; + case COMMAND_RETURN_FALSE: + UpdateCompareFlag(false); + return 0; + default: + assert(0); + break; + } + return -1; +} + WRAPPER int8 CRunningScript::ProcessCommandsFrom200To299(int32 command) { EAXJMP(0x43D530); } WRAPPER int8 CRunningScript::ProcessCommandsFrom300To399(int32 command) { EAXJMP(0x43ED30); } WRAPPER int8 CRunningScript::ProcessCommandsFrom400To499(int32 command) { EAXJMP(0x440CB0); } diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index c06ee48b..166928c1 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -41,6 +41,13 @@ CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat } bool +CCamera::IsSphereVisible(const CVector ¢er, float radius) +{ + CMatrix mat = m_cameraMatrix; + return IsSphereVisible(center, radius, &mat); +} + +bool CCamera::IsPointVisible(const CVector ¢er, const CMatrix *mat) { RwV3d c; @@ -1290,7 +1297,7 @@ CCam::GetWeaponFirstPersonOn() } STARTPATCHES - InjectHook(0x42C760, &CCamera::IsSphereVisible, PATCH_JUMP); + InjectHook(0x42C760, (bool (CCamera::*)(const CVector ¢er, float radius, const CMatrix *mat))&CCamera::IsSphereVisible, PATCH_JUMP); InjectHook(0x46FD00, &CCamera::SetFadeColour, PATCH_JUMP); InjectHook(0x46FD40, &CCamera::SetMotionBlur, PATCH_JUMP); diff --git a/src/core/Camera.h b/src/core/Camera.h index c0309b5f..10554601 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -445,6 +445,7 @@ int m_iModeObbeCamIsInForCar; CVector &GetGameCamPosition(void) { return m_vecGameCamPos; } bool IsPointVisible(const CVector ¢er, const CMatrix *mat); bool IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat); + bool IsSphereVisible(const CVector ¢er, float radius); bool IsBoxVisible(RwV3d *box, const CMatrix *mat); int GetLookDirection(void); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 77666b12..1de5c94f 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -26,46 +26,47 @@ #include "PlayerSkin.h" #include "PlayerInfo.h" #include "World.h" +#include "Renderer.h" #define ALL_ORIGINAL_FRONTEND 1 -int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; +int32 &CMenuManager::OS_Language = *(int32*)0x5F2F78; // 9 int8 &CMenuManager::m_PrefsUseVibration = *(int8*)0x95CD92; int8 &CMenuManager::m_DisplayControllerOnFoot = *(int8*)0x95CD8D; -int8 &CMenuManager::m_PrefsVsync = *(int8*)0x5F2E58; -int8 &CMenuManager::m_PrefsVsyncDisp = *(int8*)0x5F2E5C; -int8 &CMenuManager::m_PrefsFrameLimiter = *(int8*)0x5F2E60; -int8 &CMenuManager::m_PrefsShowSubtitles = *(int8*)0x5F2E54; +int8 &CMenuManager::m_PrefsVsync = *(int8*)0x5F2E58; // 1 +int8 &CMenuManager::m_PrefsVsyncDisp = *(int8*)0x5F2E5C; // 1 +int8 &CMenuManager::m_PrefsFrameLimiter = *(int8*)0x5F2E60; // 1 +int8 &CMenuManager::m_PrefsShowSubtitles = *(int8*)0x5F2E54; // 1 int8 &CMenuManager::m_PrefsSpeakers = *(int8*)0x95CD7E; -int8 &CMenuManager::m_ControlMethod = *(int8*)0x8F5F7C; -int8 &CMenuManager::m_PrefsDMA = *(int8*)0x5F2F74; -int8 &CMenuManager::m_PrefsLanguage = *(int8*)0x941238; +int32 &CMenuManager::m_ControlMethod = *(int32*)0x8F5F7C; +int8 &CMenuManager::m_PrefsDMA = *(int8*)0x5F2F74; // 1 +int32 &CMenuManager::m_PrefsLanguage = *(int32*)0x941238; -bool &CMenuManager::m_PrefsAllowNastyGame = *(bool*)0x5F2E64; +bool &CMenuManager::m_PrefsAllowNastyGame = *(bool*)0x5F2E64; // true bool &CMenuManager::m_bStartUpFrontEndRequested = *(bool*)0x95CCF4; bool &CMenuManager::m_bShutDownFrontEndRequested = *(bool*)0x95CD6A; int8 &CMenuManager::m_PrefsUseWideScreen = *(int8*)0x95CD23; int8 &CMenuManager::m_PrefsRadioStation = *(int8*)0x95CDA4; -int8 &CMenuManager::m_bDisableMouseSteering = *(int8*)0x60252C; -int32 &CMenuManager::m_PrefsBrightness = *(int32*)0x5F2E50; +int8 &CMenuManager::m_bDisableMouseSteering = *(int8*)0x60252C; // 1 +int32 &CMenuManager::m_PrefsBrightness = *(int32*)0x5F2E50; // 256 float &CMenuManager::m_PrefsLOD = *(float*)0x8F42C4; int8 &CMenuManager::m_bFrontEnd_ReloadObrTxtGxt = *(int8*)0x628CFC; -int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; -int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; +int32 &CMenuManager::m_PrefsMusicVolume = *(int32*)0x5F2E4C; // 102 +int32 &CMenuManager::m_PrefsSfxVolume = *(int32*)0x5F2E48; // 102 -char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; +char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; //[256] "$$\"\"" -int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; +int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; // -1 CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; // Move this somewhere else. -float lodMultiplier = *(float*)0x5F726C; +float &CRenderer::ms_lodDistScale = *(float*)0x5F726C; // 1.2 // Stuff not in CMenuManager: uint32 &VibrationTime = *(uint32*)0x628CF8; -char* pEditString = (char*)0x628D00; +char *&pEditString = *(char**)0x628D00; int32 *&pControlEdit = *(int32**)0x628D08; bool &DisplayComboButtonErrMsg = *(bool*)0x628D14; int32 &MouseButtonJustClicked = *(int32*)0x628D0C; @@ -74,7 +75,6 @@ int32 &nTimeForSomething = *(int32*)0x628D54; //int32 *pControlTemp = 0; // Frontend inputs. - bool GetPadBack(); bool GetPadExitEnter(); bool GetPadForward(); @@ -149,7 +149,7 @@ char *MenuFilenames[] = { nil, nil }; -#if ALL_ORIGINAL_FRONTEND +#if 0 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) @@ -177,7 +177,7 @@ void CMenuManager::BuildStatLine(char *text, float *stat, bool aFloat, float* st } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER void CMenuManager::CentreMousePointer() { EAXJMP(0x48ACE0); } #else void CMenuManager::CentreMousePointer() @@ -205,7 +205,7 @@ void CMenuManager::CheckCodesForControls(int, int) } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER bool CMenuManager::CheckHover(int, int, int, int) { EAXJMP(0x48ACA0); } #else bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) @@ -217,74 +217,35 @@ bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) void CMenuManager::CheckSliderMovement(int value) { - float fBrightness = 0.0f; - float fDrawDistance = 0.0f; - float fRadioVolume = 0.0f; - float fSfxVolume = 0.0f; - float fMouseSens = 0.0f; - switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_BRIGHTNESS: - fBrightness = m_PrefsBrightness + (value * (512.0f) / 16.0f); - - if (fBrightness > 511.0f) - fBrightness = 511.0f; - else if (fBrightness < 0.0f) - fBrightness = 0.0f; - - m_PrefsBrightness = fBrightness; - SaveSettings(); + m_PrefsBrightness += m_PrefsBrightness + value * (512/16); + m_PrefsBrightness = clamp(m_PrefsBrightness, 0, 511); break; case MENUACTION_DRAWDIST: - fDrawDistance = m_PrefsLOD + (value * (1.8f - 0.8f) / 16.0f); - - if (fDrawDistance > 1.8f) - fDrawDistance = 1.8f; - else if (fDrawDistance < 0.8f) - fDrawDistance = 0.8f; - - m_PrefsLOD = fDrawDistance; - SaveSettings(); + m_PrefsLOD += value * ((1.8f - 0.8f)/16.0f); + m_PrefsLOD = clamp(m_PrefsLOD, 0.8f, 1.8f); + CRenderer::ms_lodDistScale = m_PrefsLOD; break; case MENUACTION_MUSICVOLUME: - fRadioVolume = m_PrefsMusicVolume + (value * (128.0f) / 16.0f); - - if (fRadioVolume > 127.0f) - fRadioVolume = 127.0f; - else if (fRadioVolume < 0.0f) - fRadioVolume = 0.0f; - - m_PrefsMusicVolume = fRadioVolume; - DMAudio.SetMusicMasterVolume(fRadioVolume); - SaveSettings(); + m_PrefsMusicVolume += value * (128/16); + m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 127); + DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); break; case MENUACTION_SFXVOLUME: - fSfxVolume = m_PrefsSfxVolume + (value * (128.0f) / 16.0f); - - if (fSfxVolume > 127) - fSfxVolume = 127; - else if (fSfxVolume < 0.0f) - fSfxVolume = 0.0f; - - m_PrefsSfxVolume = fSfxVolume; - DMAudio.SetEffectsMasterVolume(fSfxVolume); - SaveSettings(); + m_PrefsSfxVolume += value * (128/16); + m_PrefsSfxVolume = clamp(m_PrefsSfxVolume, 0, 127); + DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); break; case MENUACTION_MOUSESENS: - fMouseSens = TheCamera.m_fMouseAccelHorzntl + (value * (0.005f - 0.0003125f) / 16.0f); - - if (fMouseSens > 0.005f) - fMouseSens = 0.005f; - else if (fMouseSens < 0.0003125f) - fMouseSens = 0.0003125f; - - TheCamera.m_fMouseAccelHorzntl = fMouseSens; - - // BUG: game doesn't set Y Axis. - TheCamera.m_fMouseAccelVertical = fMouseSens; - SaveSettings(); + TheCamera.m_fMouseAccelHorzntl += value * 1.0f/200.0f/15.0f; // ??? + TheCamera.m_fMouseAccelHorzntl = clamp(TheCamera.m_fMouseAccelHorzntl, 1.0f/3200.0f, 1.0f/200.0f); + TheCamera.m_fMouseAccelVertical = TheCamera.m_fMouseAccelHorzntl; break; + default: + return; } + SaveSettings(); } #if 1 @@ -471,7 +432,7 @@ void CMenuManager::Draw() CFont::PrintString(SCREEN_SCALE_X(MENUACTION_POS_X), SCREEN_SCALE_Y(MENUACTION_POS_Y), str); } - for (int i = 0; i < MENUROWS; ++i) { + for (int i = 0; i < NUM_MENUROWS; ++i) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0]) { wchar *textToPrint[MENUCOLUMNS] = { nil, nil }; bool Locked = false; @@ -543,7 +504,7 @@ void CMenuManager::Draw() case AR_16_9: textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:9"; break; - } + } #endif break; case MENUACTION_RADIO: @@ -611,7 +572,7 @@ void CMenuManager::Draw() break; case MENUACTION_MOUSESTEER: textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_bDisableMouseSteering ? "FEM_ON" : "FEM_OFF"); - break; + break; } CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); @@ -711,7 +672,7 @@ void CMenuManager::Draw() CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); CSprite2d::DrawRect(CRect(SCREEN_STRETCH_X(11.0f), vecPositions.y - SCREEN_STRETCH_Y(fBarSize * 0.13f), SCREEN_STRETCH_FROM_RIGHT(11.0f), vecPositions.y + SCREEN_STRETCH_Y(fBarSize)), CRGBA(100, 200, 50, 50)); } - else + else CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); // Draw @@ -727,35 +688,27 @@ void CMenuManager::Draw() } // Mouse support. - // TODO: inputs for these pages. - if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { - } - else if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { - - } - else { - static bool bIsMouseInPosition = false; - if (m_nMenuFadeAlpha >= 255 && GetMouseInput()) { - CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; - if (m_bShowMouse && - ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) - bIsMouseInPosition = true; - else - bIsMouseInPosition = false; + static bool bIsMouseInPosition = false; + if (m_nMenuFadeAlpha >= 255 && GetMouseInput()) { + CVector2D vecInputSize = { SCREEN_SCALE_X(20.0f), SCREEN_SCALE_FROM_RIGHT(20.0f) }; + if (m_bShowMouse && + ((CheckHover(vecInputSize.x, vecInputSize.y, vecPositions.y, vecPositions.y + SCREEN_STRETCH_Y(20.0f))))) + bIsMouseInPosition = true; + else + bIsMouseInPosition = false; - if (bIsMouseInPosition) { - if (m_nCurrOption != i) { - m_nCurrOption = i; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - } + if (bIsMouseInPosition) { + if (m_nCurrOption != i) { + m_nCurrOption = i; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + } - m_nPrevOption = m_nCurrOption; + m_nPrevOption = m_nCurrOption; - if (GetMouseForward()) - m_nHoverOption = HOVEROPTION_NULL; - else - m_nHoverOption = HOVEROPTION_DEFAULT; - } + if (GetMouseForward()) + m_nHoverOption = HOVEROPTION_42; + else + m_nHoverOption = HOVEROPTION_DEFAULT; } } @@ -763,16 +716,16 @@ void CMenuManager::Draw() // TODO: CheckHover switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { case MENUACTION_BRIGHTNESS: - 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), m_PrefsBrightness/512.0f); + 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), m_PrefsBrightness / 512.0f); break; case MENUACTION_DRAWDIST: 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), (m_PrefsLOD - 0.8f) * 1.0f); break; case MENUACTION_MUSICVOLUME: - 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), m_PrefsMusicVolume/128.0f); + 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), m_PrefsMusicVolume / 128.0f); break; case MENUACTION_SFXVOLUME: - 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), m_PrefsSfxVolume/128.0f); + 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), m_PrefsSfxVolume / 128.0f); break; 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); @@ -859,7 +812,7 @@ void CMenuManager::DrawControllerSetupScreen() } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER void CMenuManager::DrawFrontEnd(void) { EAXJMP(0x47A540); } #else void CMenuManager::DrawFrontEnd() @@ -867,7 +820,7 @@ void CMenuManager::DrawFrontEnd() CFont::SetAlphaFade(255.0f); if (m_nCurrScreen == MENUPAGE_NONE) { - m_nMenuFadeAlpha = 0; + // m_nMenuFadeAlpha = 0; if (m_bGameNotLoaded) m_nCurrScreen = MENUPAGE_START_MENU; @@ -875,31 +828,27 @@ void CMenuManager::DrawFrontEnd() m_nCurrScreen = MENUPAGE_PAUSE_MENU; } - if (!m_nCurrOption && aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) - m_nCurrOption = MENUROW_1; + if (m_nCurrOption == 0 && aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) + m_nCurrOption = 1; CMenuManager::DrawFrontEndNormal(); CMenuManager::PrintErrorMessage(); } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER void CMenuManager::DrawFrontEndNormal(void) { EAXJMP(0x47A5B0); } #else void CMenuManager::DrawFrontEndNormal() { - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)FALSE); - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA); - RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void *)rwTEXTUREADDRESSCLAMP); CSprite2d::InitPerFrame(); CFont::InitPerFrame(); - eMenuSprites previousSprite = MENUSPRITE_MAINMENU; + LoadSplash(nil); + + eMenuSprites previousSprite = MENUSPRITE_MAINMENU; // actually uninitialized if (m_nMenuFadeAlpha < 255) { switch (m_nPrevScreen) { case MENUPAGE_STATS: @@ -939,13 +888,16 @@ void CMenuManager::DrawFrontEndNormal() break; } - if (m_nPrevScreen == MENUPAGE_NONE) - CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255)); + if (m_nPrevScreen == m_nCurrScreen) + CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(0, 0, 0, 255-m_nMenuFadeAlpha)); else - m_aMenuSprites[previousSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + m_aMenuSprites[previousSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255-m_nMenuFadeAlpha)); } - eMenuSprites currentSprite = MENUSPRITE_MAINMENU; + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); + + eMenuSprites currentSprite = MENUSPRITE_MAINMENU; // actually uninitialized switch (m_nCurrScreen) { case MENUPAGE_STATS: case MENUPAGE_START_MENU: @@ -984,38 +936,45 @@ void CMenuManager::DrawFrontEndNormal() break; } - uint32 savedShade; - uint32 savedAlpha; - RwRenderStateGet(rwRENDERSTATESHADEMODE, &savedShade); - RwRenderStateSet(rwRENDERSTATESHADEMODE, reinterpret_cast<void *>(rwSHADEMODEGOURAUD)); - RwRenderStateGet(rwRENDERSTATEVERTEXALPHAENABLE, &savedAlpha); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void *>(TRUE)); - if (m_nMenuFadeAlpha >= 255) { - m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); - } - else { - if (m_nMenuFadeAlpha < 255) { - m_nMenuFadeAlpha += 0.1f * 255.0f; - - if (m_nMenuFadeAlpha >= 255) - m_nMenuFadeAlpha = 255; + if (m_nMenuFadeAlpha < 255) { + static int LastFade = 0; - m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, m_nMenuFadeAlpha)); + if(CTimer::GetTimeInMillisecondsPauseMode() - LastFade > 10){ + m_nMenuFadeAlpha += 20; + LastFade = CTimer::GetTimeInMillisecondsPauseMode(); } - else + + if (m_nMenuFadeAlpha > 255){ m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + }else{ + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, m_nMenuFadeAlpha)); + } + } + else { + m_aMenuSprites[currentSprite].Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + // TODO: what is this? waiting mouse? + if(field_518 == 4){ + if(m_nHoverOption == 3 || m_nHoverOption == 4 || m_nHoverOption == 5 || m_nHoverOption == 6 || m_nHoverOption == 7) + field_518 = 2; + else + field_518 = 1; + } } // GTA LOGO + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_PAUSE_MENU) { if (CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) m_aMenuSprites[MENUSPRITE_GTA3LOGO].Draw(CRect((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(115.0f), SCREEN_SCALE_Y(70.0f), (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(115.0f), SCREEN_SCALE_Y(180.0f)), CRGBA(255, 255, 255, FadeIn(255))); else m_aMenuSprites[MENUSPRITE_GTALOGO].Draw(CRect((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(95.0f), SCREEN_SCALE_Y(40.0f), (SCREEN_WIDTH / 2) + SCREEN_SCALE_X(95.0f), SCREEN_SCALE_Y(210.0f)), CRGBA(255, 255, 255, FadeIn(255))); } - RwRenderStateSet(rwRENDERSTATESHADEMODE, reinterpret_cast<void *>(savedShade)); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast<void *>(savedAlpha)); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); switch (m_nCurrScreen) { case MENUPAGE_SKIN_SELECT: CMenuManager::DrawPlayerSetupScreen(); @@ -1031,8 +990,25 @@ void CMenuManager::DrawFrontEndNormal() CFont::DrawFonts(); // Draw mouse - if (m_bShowMouse) - m_aMenuSprites[MENUSPRITE_MOUSE].Draw(m_nMousePosX, m_nMousePosY, SCREEN_SCALE_X(60.0f), SCREEN_SCALE_Y(60.0f), CRGBA(255, 255, 255, 255)); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + if (m_bShowMouse) { + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + + CRect mouse(0.0f, 0.0f, SCREEN_SCALE_X(75.0f), SCREEN_SCALE_X(75.0f)); + mouse.Translate(m_nMousePosX, m_nMousePosY); + CRect shad = mouse; + shad.Translate(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(3.0f)); + if(field_518 == 4){ + m_aMenuSprites[MENUSPRITE_MOUSET].Draw(shad, CRGBA(100, 100, 100, 50)); + m_aMenuSprites[MENUSPRITE_MOUSET].Draw(mouse, CRGBA(255, 255, 255, 255)); + }else{ + m_aMenuSprites[MENUSPRITE_MOUSE].Draw(shad, CRGBA(100, 100, 100, 50)); + m_aMenuSprites[MENUSPRITE_MOUSE].Draw(mouse, CRGBA(255, 255, 255, 255)); + } + } } #endif @@ -1045,7 +1021,7 @@ void CMenuManager::DrawPlayerSetupScreen() } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER int CMenuManager::FadeIn(int alpha) { EAXJMP(0x48AC60); } #else int CMenuManager::FadeIn(int alpha) @@ -1054,11 +1030,7 @@ int CMenuManager::FadeIn(int alpha) m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS || m_nCurrScreen == MENUPAGE_DELETING) return alpha; - - if (m_nMenuFadeAlpha >= alpha) - return alpha; - - return m_nMenuFadeAlpha; + return min(m_nMenuFadeAlpha, alpha); } #endif @@ -1116,7 +1088,7 @@ void CMenuManager::LoadAllTextures() CMenuManager::CentreMousePointer(); DMAudio.ChangeMusicMode(0); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0); - m_nCurrOption = MENUROW_0; + m_nCurrOption = 0; m_PrefsRadioStation = DMAudio.GetRadioInCar(); if (DMAudio.IsMP3RadioChannelAvailable()) { @@ -1165,7 +1137,7 @@ void CMenuManager::LoadAllTextures() } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } #else void CMenuManager::LoadSettings() @@ -1173,46 +1145,47 @@ void CMenuManager::LoadSettings() CFileMgr::SetDirMyDocuments(); - uint8 prevLang = m_PrefsLanguage; + int32 prevLang = m_PrefsLanguage; + CMBlur::BlurOn = true; MousePointerStateHelper.bInvertVertically = true; static char Ver; int fileHandle = CFileMgr::OpenFile("gta3.set", "r"); if (fileHandle) { - CFileMgr::Read(fileHandle, buf(&Ver), sizeof(Ver)); + CFileMgr::Read(fileHandle, (char*)&Ver, sizeof(Ver)); 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(&TheCamera.m_bHeadBob), 1); - CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), 4); - CFileMgr::Read(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), 4); - CFileMgr::Read(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), 1); - CFileMgr::Read(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsSfxVolume), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsMusicVolume), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsRadioStation), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsSpeakers), 1); - CFileMgr::Read(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsDMA), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsBrightness), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsLOD), 4); - CFileMgr::Read(fileHandle, buf(&m_PrefsShowSubtitles), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsUseWideScreen), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsVsyncDisp), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsFrameLimiter), 1); - CFileMgr::Read(fileHandle, buf(&m_nDisplayVideoMode), 1); - CFileMgr::Read(fileHandle, buf(&CMBlur::BlurOn), 1); - CFileMgr::Read(fileHandle, buf(m_PrefsSkinFile), 256); - CFileMgr::Read(fileHandle, buf(&m_ControlMethod), 1); - CFileMgr::Read(fileHandle, buf(&m_PrefsLanguage), 1); + CFileMgr::Read(fileHandle, gString, 20); + CFileMgr::Read(fileHandle, gString, 20); + CFileMgr::Read(fileHandle, gString, 4); + CFileMgr::Read(fileHandle, gString, 4); + CFileMgr::Read(fileHandle, gString, 1); + CFileMgr::Read(fileHandle, gString, 1); + CFileMgr::Read(fileHandle, gString, 1); + CFileMgr::Read(fileHandle, (char*)&TheCamera.m_bHeadBob, 1); + CFileMgr::Read(fileHandle, (char*)&TheCamera.m_fMouseAccelHorzntl, 4); + CFileMgr::Read(fileHandle, (char*)&TheCamera.m_fMouseAccelVertical, 4); + CFileMgr::Read(fileHandle, (char*)&MousePointerStateHelper.bInvertVertically, 1); + CFileMgr::Read(fileHandle, (char*)&CVehicle::m_bDisableMouseSteering, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsSfxVolume, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsMusicVolume, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsRadioStation, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsSpeakers, 1); + CFileMgr::Read(fileHandle, (char*)&m_nPrefsAudio3DProviderIndex, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsDMA, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsBrightness, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsLOD, 4); + CFileMgr::Read(fileHandle, (char*)&m_PrefsShowSubtitles, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsUseWideScreen, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsVsyncDisp, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsFrameLimiter, 1); + CFileMgr::Read(fileHandle, (char*)&m_nDisplayVideoMode, 1); + CFileMgr::Read(fileHandle, (char*)&CMBlur::BlurOn, 1); + CFileMgr::Read(fileHandle, m_PrefsSkinFile, 256); + CFileMgr::Read(fileHandle, (char*)&m_ControlMethod, 1); + CFileMgr::Read(fileHandle, (char*)&m_PrefsLanguage, 1); } } @@ -1220,7 +1193,7 @@ void CMenuManager::LoadSettings() CFileMgr::SetDir(""); m_PrefsVsync = m_PrefsVsyncDisp; - lodMultiplier = m_PrefsLOD; + CRenderer::ms_lodDistScale = m_PrefsLOD; if (m_nPrefsAudio3DProviderIndex == -1) m_nPrefsAudio3DProviderIndex = -2; @@ -1237,25 +1210,72 @@ void CMenuManager::LoadSettings() debug("The previously saved language is now in use"); } - /*struct _WIN32_FIND_DATAA FindFileData; - HANDLE H = FindFirstFileA("skins\*.bmp", &FindFileData); - char Dest; + struct _WIN32_FIND_DATAA FindFileData; + char skinfile[256+16]; // ?? + 16? bool SkinFound = false; - - for (int i = 1; H != (HANDLE)-1 && i; i = FindNextFileA(H, &FindFileData)) { - strcpy(&Dest, buf(m_PrefsSkinFile)); - strcat(&Dest, ".bmp"); - if (!strcmp(FindFileData.cFileName, &Dest)) + HANDLE handle = FindFirstFileA("skins\\*.bmp", &FindFileData); + for (int i = 1; handle != (HANDLE)-1 && i; i = FindNextFileA(handle, &FindFileData)) { + strcpy(skinfile, m_PrefsSkinFile); + strcat(skinfile, ".bmp"); + if (strcmp(FindFileData.cFileName, skinfile) == 0) SkinFound = true; } - - FindClose(H); + FindClose(handle); if (!SkinFound) { debug("Default skin set as no other skins are available OR saved skin not found!"); - strcpy((char *)CMenuManager::m_PrefsSkinFile, "$$\"\""); + strcpy(m_PrefsSkinFile, "$$\"\""); strcpy(m_aSkinName, "$$\"\""); - }*/ + } +} +#endif + +#if 0 +WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } +#else +void CMenuManager::SaveSettings() +{ + static char RubbishString[48] = "stuffmorestuffevenmorestuff etc"; + + CFileMgr::SetDirMyDocuments(); + + int fileHandle = CFileMgr::OpenFile("gta3.set", "w"); + if (fileHandle) { + + ControlsManager.SaveSettings(fileHandle); + CFileMgr::Write(fileHandle, RubbishString, 20); + CFileMgr::Write(fileHandle, RubbishString, 20); + CFileMgr::Write(fileHandle, RubbishString, 4); + CFileMgr::Write(fileHandle, RubbishString, 4); + CFileMgr::Write(fileHandle, RubbishString, 1); + CFileMgr::Write(fileHandle, RubbishString, 1); + CFileMgr::Write(fileHandle, RubbishString, 1); + CFileMgr::Write(fileHandle, (char*)&TheCamera.m_bHeadBob, 1); + CFileMgr::Write(fileHandle, (char*)&TheCamera.m_fMouseAccelHorzntl, 4); + CFileMgr::Write(fileHandle, (char*)&TheCamera.m_fMouseAccelVertical, 4); + CFileMgr::Write(fileHandle, (char*)&MousePointerStateHelper.bInvertVertically, 1); + CFileMgr::Write(fileHandle, (char*)&CVehicle::m_bDisableMouseSteering, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsSfxVolume, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsMusicVolume, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsRadioStation, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsSpeakers, 1); + CFileMgr::Write(fileHandle, (char*)&m_nPrefsAudio3DProviderIndex, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsDMA, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsBrightness, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsLOD, sizeof(m_PrefsLOD)); + CFileMgr::Write(fileHandle, (char*)&m_PrefsShowSubtitles, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsUseWideScreen, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsVsyncDisp, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsFrameLimiter, 1); + CFileMgr::Write(fileHandle, (char*)&m_nDisplayVideoMode, 1); + CFileMgr::Write(fileHandle, (char*)&CMBlur::BlurOn, 1); + CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256); + CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1); + CFileMgr::Write(fileHandle, (char*)&m_PrefsLanguage, 1); + } + + CFileMgr::CloseFile(fileHandle); + CFileMgr::SetDir(""); } #endif @@ -1319,7 +1339,7 @@ void CMenuManager::PrintStats() } #endif -#if ALL_ORIGINAL_FRONTEND +#if 0 WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } #else void CMenuManager::Process(void) @@ -1423,7 +1443,7 @@ void CMenuManager::Process(void) JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); - int32 TypeOfControl = 0; + int32 TypeOfControl = 0; if (JoyButtonJustClicked) TypeOfControl = 3; if (MouseButtonJustClicked) @@ -1468,11 +1488,10 @@ void CMenuManager::Process(void) CPad::StopPadsShaking(); VibrationTime = 0; } - } - else { + + } else { UnloadTextures(); field_452 = 0; - *(bool*)0x5F33E4 = true; // byte_5F33E4 = 1; // unused m_nPrevScreen = 0; m_nCurrScreen = m_nPrevScreen; @@ -1493,15 +1512,12 @@ WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } #else void CMenuManager::ProcessButtonPresses() { - if(pEditString) - return; - if(pControlEdit) + if (pEditString || pControlEdit) return; // Update mouse position m_nMouseOldPosX = m_nMousePosX; m_nMouseOldPosY = m_nMousePosY; - m_nMousePosX = m_nMouseTempPosX; m_nMousePosY = m_nMouseTempPosY; @@ -1521,28 +1537,58 @@ void CMenuManager::ProcessButtonPresses() 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_SKIN_SELECT) + m_nCurrExSize = 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 (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) + m_nCurrExSize = m_ControlMethod ? 30 : 25; if (!GetPadBack() || m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS || field_535) field_535 = 0; - else if (field_536 == 19) { - m_nHoverOption = 42; + else if (m_nCurrExLayer == 19) { + m_nHoverOption = HOVEROPTION_42; field_113 = 1; field_456 = 1; - m_bKeyChangeNotProcessed = 1; + m_bKeyChangeNotProcessed = true; pControlEdit = &m_KeyPressedCode; } + bool Trigger = false; + if (!Trigger) { + nTimeForSomething = 0; + Trigger = true; + } + + if ((CTimer::GetTimeInMillisecondsPauseMode() - nTimeForSomething) > 200) { + field_520 = 0; + field_521 = 0; + field_522 = 0; + field_523 = 0; + field_524 = 0; + nTimeForSomething = CTimer::GetTimeInMillisecondsPauseMode(); + } + + if (CPad::GetPad(0)->NewKeyState.TAB && !CPad::GetPad(0)->OldKeyState.TAB) { + switch (m_nCurrExLayer) { + case 9: + m_nCurrExLayer = 19; + break; + case 19: + m_nCurrExLayer = 21; + break; + case 21: + m_nCurrExLayer = 9; + break; + } + if (m_nCurrScreen == MENUPAGE_SKIN_SELECT && m_nCurrExLayer == 21 && !strcmp(m_aSkinName, m_PrefsSkinFile)) { + m_nCurrExLayer = 9; + } + if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS && m_nCurrExLayer == 21) + m_nCurrExLayer = 9; + } + if (GetPadForward()) { - switch (field_536) { + switch (m_nCurrExLayer) { case 19: if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { field_113 = 1; @@ -1552,36 +1598,21 @@ void CMenuManager::ProcessButtonPresses() if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { strcpy(m_PrefsSkinFile, m_aSkinName); CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); - field_536 = 9; + m_nCurrExLayer = 9; } - m_nHoverOption = HOVEROPTION_NULL; + m_nHoverOption = HOVEROPTION_42; SaveSettings(); break; case 21: strcpy(m_PrefsSkinFile, m_aSkinName); CWorld::Players->SetPlayerSkin(m_PrefsSkinFile); - field_536 = 9; + m_nCurrExLayer = 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. @@ -1591,31 +1622,41 @@ void CMenuManager::ProcessButtonPresses() if (GetPadMoveUp()) { m_nPrevOption = m_nCurrOption; m_nCurrOption -= 1; + m_nCurrExOption -= 1; + //field_438 -= 1; if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { - if (m_nCurrOption < MENUROW_1) + if (m_nCurrOption < 1) m_nCurrOption = NumberOfMenuOptions; } else { - if (m_nCurrOption < MENUROW_0) + if (m_nCurrOption < 0) m_nCurrOption = NumberOfMenuOptions; } + if (m_nCurrExOption < 0) + m_nCurrExOption = 0; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); } else if (GetPadMoveDown()) { m_nPrevOption = m_nCurrOption; m_nCurrOption += 1; + m_nCurrExOption += 1; + //field_438 = += 1; if (aScreens[m_nCurrScreen].m_aEntries[0].m_Action == MENUACTION_LABEL) { if (m_nCurrOption > NumberOfMenuOptions) - m_nCurrOption = MENUROW_1; + m_nCurrOption = 1; } else { if (m_nCurrOption > NumberOfMenuOptions) - m_nCurrOption = MENUROW_0; + m_nCurrOption = 0; } + if (m_nCurrExOption > m_nCurrExSize - 1) + m_nCurrExOption = m_nCurrExSize - 1; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); } @@ -1637,6 +1678,8 @@ void CMenuManager::ProcessButtonPresses() } else SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); + + PlayEscSound = true; break; default: SwitchToNewScreen(aScreens[m_nCurrScreen].m_PreviousPage[0]); @@ -1675,7 +1718,7 @@ void CMenuManager::ProcessButtonPresses() } break; default: - m_nHoverOption = HOVEROPTION_NULL; + m_nHoverOption = HOVEROPTION_42; break; } } @@ -1871,10 +1914,12 @@ void CMenuManager::ProcessOnOffMenuOptions() break; case MENUACTION_UPDATESAVE: PcSaveHelper.PopulateSlotInfo(); - if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { - m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; + if (!m_bGameNotLoaded) { + if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrOption].m_aEntries[m_nCurrOption].m_SaveSlot <= SAVESLOT_8) { + m_nCurrSaveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 2; - SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + SwitchToNewScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu); + } } break; case MENUACTION_CHECKSAVE: @@ -2120,32 +2165,24 @@ void CMenuManager::SaveLoadFileError_SetUpErrorScreen() case 1: case 2: case 3: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_SAVE_FAILED; - m_nCurrOption = MENUROW_0; + SwitchToNewScreen(MENUPAGE_SAVE_FAILED); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); break; break; case 4: case 5: case 6: - this->m_nPrevScreen = m_nCurrScreen; - this->m_nCurrScreen = MENUPAGE_LOAD_FAILED; - m_nCurrOption = MENUROW_0; + SwitchToNewScreen(MENUPAGE_LOAD_FAILED); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); break; case 7: - this->m_nPrevScreen = m_nCurrScreen; - this->m_nCurrScreen = MENUPAGE_LOAD_FAILED_2; - m_nCurrOption = MENUROW_0; + SwitchToNewScreen(MENUPAGE_LOAD_FAILED_2); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); break; case 8: case 9: case 10: - m_nPrevScreen = m_nCurrScreen; - m_nCurrScreen = MENUPAGE_DELETE_FAILED; - m_nCurrOption = MENUROW_0; + SwitchToNewScreen(MENUPAGE_DELETE_FAILED); m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); break; default: @@ -2165,53 +2202,6 @@ void CMenuManager::SetHelperText(int text) #endif #if ALL_ORIGINAL_FRONTEND -WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } -#else -void CMenuManager::SaveSettings() -{ - CFileMgr::SetDirMyDocuments(); - - int fileHandle = CFileMgr::OpenFile("gta3.set", "w"); - if (fileHandle) { - - ControlsManager.SaveSettings(fileHandle); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 20); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 4); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); - CFileMgr::Write(fileHandle, buf("stuffmorestuffevenmorestuff etc"), 1); - CFileMgr::Write(fileHandle, buf(&TheCamera.m_bHeadBob), 1); - CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelHorzntl), 4); - CFileMgr::Write(fileHandle, buf(&TheCamera.m_fMouseAccelVertical), 4); - CFileMgr::Write(fileHandle, buf(&MousePointerStateHelper.bInvertVertically), 1); - CFileMgr::Write(fileHandle, buf(&CVehicle::m_bDisableMouseSteering), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsSfxVolume), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsMusicVolume), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsRadioStation), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsSpeakers), 1); - CFileMgr::Write(fileHandle, buf(&m_nPrefsAudio3DProviderIndex), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsDMA), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsBrightness), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsLOD), sizeof(m_PrefsLOD)); - CFileMgr::Write(fileHandle, buf(&m_PrefsShowSubtitles), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsUseWideScreen), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsVsyncDisp), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsFrameLimiter), 1); - CFileMgr::Write(fileHandle, buf(&m_nDisplayVideoMode), 1); - CFileMgr::Write(fileHandle, buf(&CMBlur::BlurOn), 1); - CFileMgr::Write(fileHandle, buf(m_PrefsSkinFile), 256); - CFileMgr::Write(fileHandle, buf(&m_ControlMethod), 1); - CFileMgr::Write(fileHandle, buf(&m_PrefsLanguage), 1); - } - - CFileMgr::CloseFile(fileHandle); - CFileMgr::SetDir(""); -} -#endif - -#if ALL_ORIGINAL_FRONTEND WRAPPER void CMenuManager::ShutdownJustMenu() { EAXJMP(0x488920); } #else void CMenuManager::ShutdownJustMenu() @@ -2221,7 +2211,6 @@ void CMenuManager::ShutdownJustMenu() } #endif -// We won't ever use this again. #if ALL_ORIGINAL_FRONTEND WRAPPER float CMenuManager::StretchX(float) { EAXJMP(0x48ABE0); } #else @@ -2230,7 +2219,11 @@ float CMenuManager::StretchX(float x) if (SCREEN_WIDTH == 640) return x; else +#ifndef ASPECT_RATIO_SCALE return SCREEN_WIDTH * x * 0.0015625f; +#else + return SCREEN_SCALE_X(x); +#endif } #endif @@ -2337,10 +2330,11 @@ void CMenuManager::WaitForUserCD() #endif // New content: +#if 0 uint8 CMenuManager::GetNumberOfMenuOptions() { - uint8 Rows = MENUROW_NONE; - for (int i = 0; i < MENUROWS; i++) { + uint8 Rows = -1; + for (int i = 0; i < NUM_MENUROWS; i++) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_NOTHING) break; @@ -2349,7 +2343,7 @@ uint8 CMenuManager::GetNumberOfMenuOptions() return Rows; } -void CMenuManager::SwitchToNewScreen(int8 screen) +void CMenuManager::SwitchToNewScreen(int32 screen) { ResetHelperText(); @@ -2372,21 +2366,24 @@ void CMenuManager::SwitchToNewScreen(int8 screen) if (screen) { m_nPrevScreen = m_nCurrScreen; m_nCurrScreen = screen; - m_nCurrOption = MENUROW_0; + m_nCurrOption = 0; + // + m_nCurrExOption = 0; + m_nCurrExLayer = 19; + // m_nMenuFadeAlpha = 0; m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); } else { m_nPrevScreen = MENUPAGE_NONE; m_nCurrScreen = MENUPAGE_NONE; - m_nCurrOption = MENUROW_0; + m_nCurrOption = 0; } } // Set player skin. if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { CPlayerSkin::BeginFrontEndSkinEdit(); - field_535 = 19; m_bSkinsFound = false; } @@ -2399,7 +2396,7 @@ void CMenuManager::SwitchToNewScreen(int8 screen) DMAudio.StopFrontEndTrack(); } -void CMenuManager::SetDefaultPreferences(int8 screen) +void CMenuManager::SetDefaultPreferences(int32 screen) { switch (screen) { case MENUPAGE_SOUND_SETTINGS: @@ -2446,6 +2443,7 @@ void CMenuManager::SetDefaultPreferences(int8 screen) break; } } +#endif // Frontend inputs. bool GetPadBack() @@ -2480,7 +2478,7 @@ bool GetPadMoveUp() bool GetPadMoveDown() { - return + 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)); @@ -2540,7 +2538,7 @@ bool GetMouseForward() bool GetMouseBack() { - return GetMouseClickRight; + return GetMouseClickRight(); } bool GetMousePos() @@ -2581,7 +2579,8 @@ bool GetMouseInput() } STARTPATCHES -#ifndef ALL_ORIGINAL_FRONTEND +#if ALL_ORIGINAL_FRONTEND +#else InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); InjectHook(0x47A440, &CMenuManager::UnloadTextures, PATCH_JUMP); InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); @@ -2589,8 +2588,13 @@ STARTPATCHES InjectHook(0x48AE60, &CMenuManager::ProcessOnOffMenuOptions, PATCH_JUMP); InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); + InjectHook(0x48ABE0, &CMenuManager::StretchX, PATCH_JUMP); + InjectHook(0x48AC20, &CMenuManager::StretchY, PATCH_JUMP); for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); #endif + + InjectHook(0x488EE0, &CMenuManager::LoadSettings, PATCH_JUMP); + InjectHook(0x488CC0, &CMenuManager::SaveSettings, PATCH_JUMP); ENDPATCHES
\ No newline at end of file diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 9a3cdd50..b588b1af 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -43,8 +43,6 @@ #define MENUSLIDER_X 306.0f -#define buf(a) (char*)(a) - enum eLanguages { LANGUAGE_AMERICAN, @@ -328,7 +326,7 @@ enum eCheckHover HOVEROPTION_19, HOVEROPTION_20, HOVEROPTION_CHANGESKIN, - HOVEROPTION_NULL = 42, + HOVEROPTION_42 = 42, }; enum eMenuColumns @@ -339,28 +337,9 @@ enum eMenuColumns MENUCOLUMNS, }; -enum eMenuRow +enum { - MENUROW_NONE = -1, - MENUROW_0, - MENUROW_1, - MENUROW_2, - MENUROW_3, - MENUROW_4, - MENUROW_5, - MENUROW_6, - MENUROW_7, - MENUROW_8, - MENUROW_9, - MENUROW_10, - MENUROW_11, - MENUROW_12, - MENUROW_13, - MENUROW_14, - MENUROW_15, - MENUROW_16, - MENUROW_17, - MENUROWS, + NUM_MENUROWS = 18, }; struct tSkinInfo @@ -377,7 +356,7 @@ struct CMenuScreen char m_ScreenName[8]; int32 unk; int32 m_PreviousPage[2]; // eMenuScreen - int32 m_ParentEntry[2]; // eMenuRow + int32 m_ParentEntry[2]; // row struct CMenuEntry { @@ -385,7 +364,7 @@ struct CMenuScreen char m_EntryName[8]; int32 m_SaveSlot; // eSaveSlot int32 m_TargetMenu; // eMenuScreen - } m_aEntries[MENUROWS]; + } m_aEntries[NUM_MENUROWS]; }; class CMenuManager @@ -413,10 +392,10 @@ public: tSkinInfo *m_pSelectedSkin; tSkinInfo *field_438; float field_43C; - int field_440; + int m_nCurrExSize; int m_nSkinsTotal; char _unk0[4]; - int field_44C; + int m_nCurrExOption; bool m_bSkinsFound; bool m_bQuitGameNoCD; char field_452; @@ -439,7 +418,7 @@ public: int field_530; char field_534; char field_535; - int8 field_536; + int8 m_nCurrExLayer; int m_nHelperTextAlpha; int m_nMouseOldPosX; int m_nMouseOldPosY; @@ -452,6 +431,7 @@ public: int m_nCurrSaveSlot; int m_nScreenChangeDelayTimer; +public: static int32 &OS_Language; static int8 &m_PrefsUseVibration; static int8 &m_DisplayControllerOnFoot; @@ -462,9 +442,9 @@ public: static int8 &m_PrefsFrameLimiter; static int8 &m_PrefsShowSubtitles; static int8 &m_PrefsSpeakers; - static int8 &m_ControlMethod; + static int32 &m_ControlMethod; static int8 &m_PrefsDMA; - static int8 &m_PrefsLanguage; + static int32 &m_PrefsLanguage; static int8 &m_bDisableMouseSteering; static int32 &m_PrefsBrightness; static float &m_PrefsLOD; @@ -516,17 +496,16 @@ public: void SaveSettings(); void SetHelperText(int text); void ShutdownJustMenu(); - static float StretchX(float); - static float StretchY(float); + float StretchX(float); + float StretchY(float); void SwitchMenuOnAndOff(); void UnloadTextures(); void WaitForUserCD(); // New content: uint8 GetNumberOfMenuOptions(); - void SwitchToNewScreen(int8 screen); - void SetDefaultPreferences(int8 screen); - + void SwitchToNewScreen(int32 screen); + void SetDefaultPreferences(int32 screen); }; static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error"); diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index 866dfc03..b464d657 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -2,15 +2,15 @@ const CMenuScreen aScreens[] = { // MENUPAGE_NONE = 0 - { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, }, + { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_STATS = 1 - { "FET_STA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_5, MENUROW_2, + { "FET_STA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_NEW_GAME = 2 - { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_0, MENUROW_1, + { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 0, 1, MENUACTION_CHANGEMENU, "FES_SNG", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, MENUACTION_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, @@ -18,17 +18,17 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_BRIEFS = 3 - { "FET_BRE", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_6, MENUROW_3, + { "FET_BRE", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 6, 3, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENU_CONTROLLER_SETTINGS = 4 - { "FET_CON", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_0, MENUROW_0, + { "FET_CON", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, }, // MENUPAGE_SOUND_SETTINGS = 5 - { "FET_AUD", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_1, MENUROW_1, + { "FET_AUD", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 1, 1, MENUACTION_MUSICVOLUME, "FEA_MUS", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_SFXVOLUME, "FEA_SFX", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_AUDIOHW, "FEA_3DH", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, @@ -40,7 +40,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_GRAPHICS_SETTINGS = 6 - { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_2, MENUROW_2, + { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 2, 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, @@ -54,7 +54,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_LANGUAGE_SETTINGS = 7 - { "FET_LAN", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_3, MENUROW_3, + { "FET_LAN", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 3, 3, MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, @@ -64,7 +64,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CHOOSE_LOAD_SLOT = 8 - { "FET_LG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_1, MENUROW_1, + { "FET_LG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 1, 1, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, @@ -77,7 +77,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CHOOSE_DELETE_SLOT = 9 - { "FET_DG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_2, MENUROW_2, + { "FET_DG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 2, 2, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, @@ -90,96 +90,96 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_NEW_GAME_RELOAD = 10 - { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUROW_0, MENUROW_0, + { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 0, 0, MENUACTION_LABEL, "FESZ_QR", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_LOAD_SLOT_CONFIRM = 11 - { "FET_LG", MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, MENUROW_0, MENUROW_0, + { "FET_LG", MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, 0, 0, MENUACTION_LABEL, "FESZ_QL", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_LOADING_IN_PROGRESS, }, // MENUPAGE_DELETE_SLOT_CONFIRM = 12 - { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUROW_0, MENUROW_0, + { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, MENUACTION_LABEL, "FESZ_QD", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_DELETING, }, // MENUPAGE_13 = 13 - { "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_LOADING_IN_PROGRESS = 14 - { "FET_LG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_LG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FED_LDW", SAVESLOT_NONE, MENUPAGE_LOAD_SLOT_CONFIRM, }, // MENUPAGE_DELETING_IN_PROGRESS = 15 - { "FET_DG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_DG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FEDL_WR", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_16 = 16 - { "FET_LG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_LG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_LOE", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_DELETE_FAILED = 17 - { "FET_DG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_DG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_DEE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, }, // MENUPAGE_DEBUG_MENU = 18 - { "FED_DBG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FED_DBG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MEMORY_CARD_1 = 19 - { "FEM_MCM", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FEM_MCM", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MEMORY_CARD_2 = 20 - { "FEM_MC2", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FEM_MC2", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_MAIN = 21 - { "FET_MP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_MP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_SAVE_FAILED_1 = 22 - { "MCDNSP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "MCDNSP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SAVE_FAILED_2 = 23 - { "MCGNSP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "MCGNSP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SAVE = 24 - { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_UPDATESAVE, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_NO_MEMORY_CARD = 25 - { "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_CHOOSE_SAVE_SLOT = 26 - { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_UPDATESAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, MENUACTION_UPDATESAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, @@ -192,49 +192,49 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUROW_0, MENUROW_0, + { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FESZ_QO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_SAVING_IN_PROGRESS, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_MULTIPLAYER_MAP = 28 - { "FET_MAP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_MAP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_CONNECTION = 29 - { "FET_CON", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_CON", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_FIND_GAME = 30 - { "FET_FG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_FG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_MODE = 31 - { "FET_GT", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_GT", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_CREATE = 32 - { "FET_HG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_HG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_START = 33 - { "FEN_STA", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FEN_STA", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_SKIN_SELECT_OLD = 34 - { "FET_PS", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_PS", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_CONTROLLER_PC = 35 - { "FET_CTL", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_0, MENUROW_0, + { "FET_CTL", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, @@ -243,32 +243,32 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CONTROLLER_PC_OLD1 = 36 - { "FET_CTL", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_0, MENUROW_0, + { "FET_CTL", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 0, 0, }, // MENUPAGE_CONTROLLER_PC_OLD2 = 37 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_CONTROLLER_PC_OLD3 = 38 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_CONTROLLER_PC_OLD4 = 39 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_CONTROLLER_DEBUG = 40 - { "FEC_DBG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FEC_DBG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_OPTIONS = 41 - { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_1, MENUROW_4, + { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 1, 4, MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -278,65 +278,65 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_EXIT = 42 - { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, MENUROW_2, MENUROW_5, + { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCLEGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SAVING_IN_PROGRESS = 43 - { "", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUROW_0, MENUROW_0, + { "", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FES_WAR", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SAVE_SUCCESSFUL = 44 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUROW_0, MENUROW_0, + { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FES_SSC", SAVESLOT_LABEL, MENUPAGE_NONE, MENUACTION_UPDATEMEMCARDSAVE, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_DELETING = 45 - { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUROW_0, MENUROW_0, + { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, MENUACTION_LABEL, "FED_DLW", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_DELETE_SUCCESS = 46 - { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUROW_0, MENUROW_0, + { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, MENUACTION_LABEL, "DEL_FNM", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, }, // MENUPAGE_SAVE_FAILED = 47 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUROW_0, MENUROW_0, + { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FEC_SVU", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_LOAD_FAILED = 48 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUROW_0, MENUROW_0, + { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FEC_SVU", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_LOAD_FAILED_2 = 49 - { "FET_LG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUROW_0, MENUROW_0, + { "FET_LG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FEC_LUN", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, }, // MENUPAGE_FILTER_GAME = 50 - { "FIL_FLT", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FIL_FLT", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_START_MENU = 51 - { "FEM_MM", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FEM_MM", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHANGEMENU, "FET_OPT", SAVESLOT_NONE, MENUPAGE_OPTIONS, MENUACTION_CHANGEMENU, "FEM_QT", SAVESLOT_NONE, MENUPAGE_EXIT, }, // MENUPAGE_PAUSE_MENU = 52 - { "FET_PAU", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FET_PAU", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_RESUME, "FEM_RES", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHANGEMENU, "FEP_STA", SAVESLOT_NONE, MENUPAGE_STATS, @@ -346,22 +346,22 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CHOOSE_MODE = 53 - { "FEN_STA", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "FEN_STA", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_SKIN_SELECT = 54 - { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUROW_4, MENUROW_4, + { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 4, 4, //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, }, // MENUPAGE_KEYBOARD_CONTROLS = 55 - { "FET_STI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_1, MENUROW_1, + { "FET_STI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 1, 1, //MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, }, // MENUPAGE_MOUSE_CONTROLS = 56 - { "FET_MTI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUROW_2, MENUROW_2, + { "FET_MTI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 2, 2, MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, @@ -369,12 +369,12 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_57 = 57 - { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_58 = 58 - { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUROW_0, MENUROW_0, + { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, }; diff --git a/src/core/Messages.cpp b/src/core/Messages.cpp index aedcb0b9..c6f3bc1b 100644 --- a/src/core/Messages.cpp +++ b/src/core/Messages.cpp @@ -9,7 +9,11 @@ WRAPPER char CMessages::WideStringCompare(wchar* str1, wchar* str2, unsigned sho WRAPPER void CMessages::InsertNumberInString(wchar* src, int n1, int n2, int n3, int n4, int n5, int n6, wchar* dst) { EAXJMP(0x52A1A0); } WRAPPER void CMessages::InsertPlayerControlKeysInString(wchar* src) { EAXJMP(0x52A490); } WRAPPER int CMessages::GetWideStringLength(wchar* src) { EAXJMP(0x529490); } -WRAPPER void CMessages::AddMessage(wchar*, uint32, uint16) { EAXJMP(0x529900); } +WRAPPER void CMessages::AddBigMessage(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529EB0); } +WRAPPER void CMessages::AddMessage(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529900); } +WRAPPER void CMessages::AddMessageJumpQ(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529A10); } +WRAPPER void CMessages::AddMessageSoon(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529AF0); } +WRAPPER void CMessages::ClearMessages() { EAXJMP(0x529CE0); } tPreviousBrief *CMessages::PreviousBriefs = (tPreviousBrief *)0x713C08; tMessage *CMessages::BriefMessages = (tMessage *)0x8786E0; diff --git a/src/core/Messages.h b/src/core/Messages.h index e1f4ced1..51c36212 100644 --- a/src/core/Messages.h +++ b/src/core/Messages.h @@ -41,5 +41,9 @@ public: static void InsertNumberInString(wchar* src, int n1, int n2, int n3, int n4, int n5, int n6, wchar* dst); static void InsertPlayerControlKeysInString(wchar* src); static int GetWideStringLength(wchar *src); - static void AddMessage(wchar*, uint32, uint16); + static void AddBigMessage(wchar* key, uint32 time, uint16 pos); + static void AddMessage(wchar* key, uint32 time, uint16 pos); + static void AddMessageJumpQ(wchar* key, uint32 time, uint16 pos); + static void AddMessageSoon(wchar* key, uint32 time, uint16 pos); + static void ClearMessages(); }; diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index 2868eb8c..7b865311 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -212,6 +212,8 @@ CWanted::ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesnt wantedLevelDrop = min(CCullZones::GetWantedLevelDrop(), 100); chaos = (1.0f - wantedLevelDrop/100.0f) * sensitivity; + if (policeDoesntCare) + chaos *= 0.333f; switch(type){ case CRIME_POSSESSION_GUN: break; diff --git a/src/core/World.cpp b/src/core/World.cpp index a9ec1f2a..e8fc54a2 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -28,6 +28,8 @@ bool &CWorld::bSecondShift = *(bool*)0x95CD54; bool &CWorld::bForceProcessControl = *(bool*)0x95CD6C; bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B; +WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); } + void CWorld::Add(CEntity *ent) { diff --git a/src/core/World.h b/src/core/World.h index a8650d93..fd9d6fc3 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -102,6 +102,7 @@ public: static float FindGroundZForCoord(float x, float y); static float FindGroundZFor3DCoord(float x, float y, float z, bool *found); static float FindRoofZFor3DCoord(float x, float y, float z, bool *found); + static void RemoveReferencesToDeletedObject(CEntity*); static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); } static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); } diff --git a/src/core/common.h b/src/core/common.h index 4b7bcb0a..fd961dd7 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -178,3 +178,4 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) +#define ABS(a) (((a) < 0) ? (-a) : (a)) diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index 454a73f1..0c3ec76a 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -175,6 +175,13 @@ CModelInfo::IsBoatModel(int32 id) ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT; } +bool +CModelInfo::IsBikeModel(int32 id) +{ + return GetModelInfo(id)->m_type == MITYPE_VEHICLE && + ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE; +} + void CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) { diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h index d20367d1..ee82276d 100644 --- a/src/modelinfo/ModelInfo.h +++ b/src/modelinfo/ModelInfo.h @@ -36,5 +36,6 @@ public: } static bool IsBoatModel(int32 id); + static bool IsBikeModel(int32 id); static void RemoveColModelsFromOtherLevels(eLevelName level); }; diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 383a3e56..3b1f9e1c 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -7,7 +7,7 @@ WRAPPER void CCivilianPed::ProcessControl(void) { EAXJMP(0x4BFFE0); } CCivilianPed::CCivilianPed(int pedtype, int mi) : CPed(pedtype) { - CPed::SetModelIndex(mi); + SetModelIndex(mi); for (int i = 0; i < 10; i++) { m_nearPeds[i] = nil; diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 0ac0473f..5bc67e15 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -1,6 +1,64 @@ #include "common.h" #include "patcher.h" #include "CopPed.h" +#include "ModelIndices.h" + +WRAPPER void CCopPed::ProcessControl() { EAXJMP(0x4C1400); } + +CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP) +{ + m_nCopType = copType; + switch (copType) { + case COP_STREET: + SetModelIndex(MI_COP); + GiveWeapon(WEAPONTYPE_COLT45, 1000); + m_currentWeapon = WEAPONTYPE_UNARMED; + m_fArmour = 0.0f; + m_wepSkills = 208; /* TODO: what is this? seems unused */ + m_wepAccuracy = 60; + break; + case COP_FBI: + SetModelIndex(MI_FBI); + GiveWeapon(WEAPONTYPE_COLT45, 1000); + GiveWeapon(WEAPONTYPE_AK47, 1000); + SetCurrentWeapon(WEAPONTYPE_AK47); + m_fArmour = 100.0f; + m_wepSkills = 176; /* TODO: what is this? seems unused */ + m_wepAccuracy = 76; + break; + case COP_SWAT: + SetModelIndex(MI_SWAT); + GiveWeapon(WEAPONTYPE_COLT45, 1000); + GiveWeapon(WEAPONTYPE_UZI, 1000); + SetCurrentWeapon(WEAPONTYPE_UZI); + m_fArmour = 50.0f; + m_wepSkills = 32; /* TODO: what is this? seems unused */ + m_wepAccuracy = 64; + break; + case COP_ARMY: + SetModelIndex(MI_ARMY); + GiveWeapon(WEAPONTYPE_COLT45, 1000); + GiveWeapon(WEAPONTYPE_M16, 1000); + GiveWeapon(WEAPONTYPE_GRENADE, 10); + SetCurrentWeapon(WEAPONTYPE_M16); + m_fArmour = 100.0f; + m_wepSkills = 32; /* TODO: what is this? seems unused */ + m_wepAccuracy = 84; + break; + default: + break; + } + m_bIsInPursuit = false; + field_1350 = 1; + m_bIsDisabledCop = false; + field_1356 = 0; + m_attackTimer = 0; + field_1351 = 0; + m_bZoneDisabledButClose = false; + m_bZoneDisabled = false; + field_1364 = -1; + m_pPointGunAt = nil; +} CCopPed::~CCopPed() { @@ -12,9 +70,11 @@ WRAPPER void CCopPed::ClearPursuit(void) { EAXJMP(0x4C28C0); } class CCopPed_ : public CCopPed { public: + CCopPed *ctor(eCopType type) { return ::new (this) CCopPed(type); }; void dtor(void) { CCopPed::~CCopPed(); } }; STARTPATCHES + InjectHook(0x4C11B0, &CCopPed_::ctor, PATCH_JUMP); InjectHook(0x4C13E0, &CCopPed_::dtor, PATCH_JUMP); ENDPATCHES diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h index f8139046..162f14a6 100644 --- a/src/peds/CopPed.h +++ b/src/peds/CopPed.h @@ -31,9 +31,11 @@ public: int8 field_1366; int8 field_1367; + CCopPed(eCopType); ~CCopPed(); void ClearPursuit(void); + void ProcessControl(void); }; static_assert(sizeof(CCopPed) == 0x558, "CCopPed: error"); diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index 664bd6f6..cbcfb403 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -1,13 +1,38 @@ #include "common.h" #include "patcher.h" #include "EmergencyPed.h" +#include "ModelIndices.h" class CEmergencyPed_ : public CEmergencyPed { public: + CEmergencyPed *ctor(int pedtype) { return ::new (this) CEmergencyPed(pedtype); }; void dtor(void) { CEmergencyPed::~CEmergencyPed(); } }; +WRAPPER void CEmergencyPed::ProcessControl(void) { EAXJMP(0x4C2F10); } + +CEmergencyPed::CEmergencyPed(uint32 type) : CPed(type) +{ + switch (type){ + case PEDTYPE_EMERGENCY: + SetModelIndex(MI_MEDIC); + m_pRevivedPed = nil; + field_1360 = 0; + break; + case PEDTYPE_FIREMAN: + SetModelIndex(MI_FIREMAN); + m_pRevivedPed = nil; + break; + default: + break; + } + m_nEmergencyPedState = 0; + m_pAttendedAccident = nil; + field_1356 = 0; +} + STARTPATCHES + InjectHook(0x4C2E40, &CEmergencyPed_::ctor, PATCH_JUMP); InjectHook(0x4C2EF0, &CEmergencyPed_::dtor, PATCH_JUMP); ENDPATCHES diff --git a/src/peds/EmergencyPed.h b/src/peds/EmergencyPed.h index f21996e8..f55fa4e2 100644 --- a/src/peds/EmergencyPed.h +++ b/src/peds/EmergencyPed.h @@ -1,11 +1,20 @@ #pragma once +#include "Fire.h" #include "Ped.h" class CEmergencyPed : public CPed { public: // 0x53C - uint8 stuff[24]; + CPed* m_pRevivedPed; + int32 m_nEmergencyPedState; // looks like flags + void* m_pAttendedAccident; //TODO: CAccident* + CFire* m_pAttendedFire; + int8 field_1356; + int32 field_1360; + + CEmergencyPed(uint32); + void ProcessControl(void); }; static_assert(sizeof(CEmergencyPed) == 0x554, "CEmergencyPed: error"); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 45074d2b..7e24faa6 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -47,6 +47,10 @@ WRAPPER void CPed::SetDuck(uint32) { EAXJMP(0x4E4920); } WRAPPER void CPed::RegisterThreatWithGangPeds(CEntity*) { EAXJMP(0x4E3870); } WRAPPER void CPed::MakeChangesForNewWeapon(int8) { EAXJMP(0x4F2560); } WRAPPER void CPed::SetSeek(CVector, float) { EAXJMP(0x4D14B0); } +WRAPPER bool CPed::Seek(void) { EAXJMP(0x4D1640); } +WRAPPER void CPed::ClearAll(void) { EAXJMP(0x4C7F20); } +WRAPPER void CPed::SetWanderPath(int8) { EAXJMP(0x4D2750); } +WRAPPER void CPed::SetFollowPath(CVector) { EAXJMP(0x4D2EA0); } bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44; bool &CPed::bPedCheat2 = *(bool*)0x95CD5A; @@ -394,7 +398,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_ped_flagD10 = false; m_ped_flagD20 = false; m_ped_flagD40 = false; - m_ped_flagD80 = false; + m_bScriptObjectiveCompleted = false; m_ped_flagE1 = false; m_ped_flagE2 = false; @@ -1405,7 +1409,7 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) if (vehicle->pDriver == ped) { vehicle->RemoveDriver(); - if (vehicle->m_nDoorLock == CARLOCK_COP_CAR) + if (vehicle->m_nDoorLock == CARLOCK_LOCKED_INITIALLY) vehicle->m_nDoorLock = CARLOCK_UNLOCKED; if (ped->m_nPedType == PEDTYPE_COP && vehicle->IsLawEnforcementVehicle()) diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 8439e0f8..2cc064a5 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -210,7 +210,7 @@ public: uint8 m_ped_flagD10 : 1; uint8 m_ped_flagD20 : 1; uint8 m_ped_flagD40 : 1; // reset when objective changes - uint8 m_ped_flagD80 : 1; + uint8 m_bScriptObjectiveCompleted : 1; uint8 m_ped_flagE1 : 1; uint8 m_ped_flagE2 : 1; @@ -469,6 +469,9 @@ public: bool CheckIfInTheAir(void); void ClearAll(void); void SetPointGunAt(CEntity*); + bool Seek(void); + void SetWanderPath(int8); + void SetFollowPath(CVector); // Static methods static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 81f27153..1db7b07c 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -325,7 +325,7 @@ void CHud::Draw() else { Clip = AmmoInClip; - if (TotalAmmo - AmmoInClip > 9999) + if ((TotalAmmo - AmmoInClip) > 9999) Ammo = 9999; else Ammo = TotalAmmo - AmmoInClip; diff --git a/src/render/Renderer.h b/src/render/Renderer.h index 4b96c775..5d3436c3 100644 --- a/src/render/Renderer.h +++ b/src/render/Renderer.h @@ -23,7 +23,9 @@ class CRenderer static CVector &ms_vecCameraPosition; static CVehicle *&m_pFirstPersonVehicle; + public: + static float &ms_lodDistScale; // defined in Frontend.cpp static bool &m_loadingPriority; static void Init(void); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index b21c859a..0abdffd2 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -65,7 +65,7 @@ CVehicle::CVehicle(uint8 CreatedBy) bIsDamaged = false; m_veh_flagC8 = false; m_veh_flagC10 = false; - m_veh_flagC4 = false; + bHasBeenOwnedByPlayer = false; m_veh_flagC20 = false; bCanBeDamaged = true; m_veh_flagC80 = false; @@ -519,7 +519,7 @@ bool CVehicle::CanPedOpenLocks(CPed *ped) { if(m_nDoorLock == CARLOCK_LOCKED || - m_nDoorLock == CARLOCK_COP_CAR || + m_nDoorLock == CARLOCK_LOCKED_INITIALLY || m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) return false; if(ped->IsPlayer() && m_nDoorLock == CARLOCK_LOCKOUT_PLAYER_ONLY) diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index 55805e9d..03bdad69 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -20,7 +20,7 @@ enum eCarLock { CARLOCK_LOCKED, CARLOCK_LOCKOUT_PLAYER_ONLY, CARLOCK_LOCKED_PLAYER_INSIDE, - CARLOCK_COP_CAR, + CARLOCK_LOCKED_INITIALLY, CARLOCK_FORCE_SHUT_DOORS, CARLOCK_SKIP_SHUT_DOORS }; @@ -168,7 +168,7 @@ public: uint8 m_veh_flagC1 : 1; uint8 bIsDamaged : 1; // This vehicle has been damaged and is displaying all its components - uint8 m_veh_flagC4 : 1; + uint8 bHasBeenOwnedByPlayer : 1; uint8 m_veh_flagC8 : 1; uint8 m_veh_flagC10 : 1; uint8 m_veh_flagC20 : 1; |