diff options
Diffstat (limited to '')
-rw-r--r-- | src/Camera.cpp | 2 | ||||
-rw-r--r-- | src/Camera.h | 1 | ||||
-rw-r--r-- | src/Clock.cpp | 29 | ||||
-rw-r--r-- | src/ControllerConfig.cpp | 3 | ||||
-rw-r--r-- | src/ControllerConfig.h | 3 | ||||
-rw-r--r-- | src/CutsceneMgr.cpp | 1 | ||||
-rw-r--r-- | src/CutsceneMgr.h | 3 | ||||
-rw-r--r-- | src/Frontend.cpp | 1 | ||||
-rw-r--r-- | src/Frontend.h | 1 | ||||
-rw-r--r-- | src/Game.cpp | 1 | ||||
-rw-r--r-- | src/Game.h | 1 | ||||
-rw-r--r-- | src/Pad.cpp | 2051 | ||||
-rw-r--r-- | src/Pad.h | 214 | ||||
-rw-r--r-- | src/Stats.cpp | 4 | ||||
-rw-r--r-- | src/Stats.h | 7 | ||||
-rw-r--r-- | src/Timer.h | 1 | ||||
-rw-r--r-- | src/Weather.cpp | 5 | ||||
-rw-r--r-- | src/Weather.h | 2 | ||||
-rw-r--r-- | src/control/Population.cpp | 4 | ||||
-rw-r--r-- | src/control/Population.h | 7 | ||||
-rw-r--r-- | src/control/Replay.cpp | 1 | ||||
-rw-r--r-- | src/control/Replay.h | 3 | ||||
-rw-r--r-- | src/entities/Ped.cpp | 4 | ||||
-rw-r--r-- | src/entities/Ped.h | 4 | ||||
-rw-r--r-- | src/entities/Vehicle.cpp | 6 | ||||
-rw-r--r-- | src/entities/Vehicle.h | 6 | ||||
-rw-r--r-- | src/skel/win/win.cpp | 4 |
27 files changed, 2232 insertions, 137 deletions
diff --git a/src/Camera.cpp b/src/Camera.cpp index 98966549..6054f1fc 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -15,6 +15,8 @@ const float DefaultFOV = 80.0f; // actually 70.0f CCamera &TheCamera = *(CCamera*)0x6FACF8; +WRAPPER Bool CCam::Using3rdPersonMouseCam() { EAXJMP(0x457460); } + WRAPPER void CCamera::DrawBordersForWideScreen(void) { EAXJMP(0x46B430); } bool diff --git a/src/Camera.h b/src/Camera.h index a5602cf0..c2e63876 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -161,6 +161,7 @@ struct CCam CPed *m_pLastPedLookedAt;// So interpolation works bool m_bFirstPersonRunAboutActive; + Bool Using3rdPersonMouseCam(); void GetVectorsReadyForRW(void); CVector DoAverageOnVector(const CVector &vec); diff --git a/src/Clock.cpp b/src/Clock.cpp index bd4126f2..dd7b99fe 100644 --- a/src/Clock.cpp +++ b/src/Clock.cpp @@ -3,6 +3,10 @@ #include "Timer.h" #include "Pad.h" #include "Clock.h" +#include "Stats.h" + +_TODO("gbFastTime"); +Bool &gbFastTime = *(Bool*)0x95CDBB; uint8 &CClock::ms_nGameClockHours = *(uint8*)0x95CDA6; uint8 &CClock::ms_nGameClockMinutes = *(uint8*)0x95CDC8; @@ -30,26 +34,37 @@ CClock::Initialise(uint32 scale) void CClock::Update(void) { - if(CPad::GetPad(1)->GetRightShoulder1()){ + if(CPad::GetPad(1)->GetRightShoulder1()) + { ms_nGameClockMinutes += 8; ms_nLastClockTick = CTimer::GetTimeInMilliseconds(); - if(ms_nGameClockMinutes >= 60){ + + if(ms_nGameClockMinutes >= 60) + { ms_nGameClockHours++; ms_nGameClockMinutes = 0; if(ms_nGameClockHours >= 24) ms_nGameClockHours = 0; } - }else - if(CTimer::GetTimeInMilliseconds() - ms_nLastClockTick > - ms_nMillisecondsPerGameMinute){ + + } + else if(CTimer::GetTimeInMilliseconds() - ms_nLastClockTick > ms_nMillisecondsPerGameMinute || gbFastTime) + { ms_nGameClockMinutes++; ms_nLastClockTick += ms_nMillisecondsPerGameMinute; - if(ms_nGameClockMinutes >= 60){ + + if ( gbFastTime ) + ms_nLastClockTick = CTimer::GetTimeInMilliseconds(); + + if(ms_nGameClockMinutes >= 60) + { ms_nGameClockHours++; ms_nGameClockMinutes = 0; if(ms_nGameClockHours >= 24) + { + CStats::DaysPassed++; ms_nGameClockHours = 0; - // TODO: stats days passed + } } } ms_nGameClockSeconds += diff --git a/src/ControllerConfig.cpp b/src/ControllerConfig.cpp index 6ac89f6c..cd38049e 100644 --- a/src/ControllerConfig.cpp +++ b/src/ControllerConfig.cpp @@ -18,6 +18,9 @@ WRAPPER void CControllerConfigManager::InitDefaultControlConfiguration() { EAXJM WRAPPER void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerState const &mousestate) { EAXJMP(0x58BD00); } WRAPPER Int32 CControllerConfigManager::GetJoyButtonJustDown() { EAXJMP(0x58B7D0); } WRAPPER void CControllerConfigManager::InitDefaultControlConfigJoyPad(unsigned int buttons) { EAXJMP(0x58BD90); } +WRAPPER void CControllerConfigManager::ClearSimButtonPressCheckers() { EAXJMP(0x58D220); } +WRAPPER void CControllerConfigManager::AffectPadFromKeyBoard() { EAXJMP(0x58D0C0); } +WRAPPER void CControllerConfigManager::AffectPadFromMouse() { EAXJMP(0x58D1A0); } void CControllerConfigManager::LoadSettings(Int32 file) { diff --git a/src/ControllerConfig.h b/src/ControllerConfig.h index 0bcda754..01d34b3c 100644 --- a/src/ControllerConfig.h +++ b/src/ControllerConfig.h @@ -46,6 +46,9 @@ public: void InitDefaultControlConfiguration(); void InitDefaultControlConfigMouse(CMouseControllerState const &mousestate); void InitDefaultControlConfigJoyPad(unsigned int buttons); + void ClearSimButtonPressCheckers(); + void AffectPadFromKeyBoard(); + void AffectPadFromMouse(); }; diff --git a/src/CutsceneMgr.cpp b/src/CutsceneMgr.cpp index 1fdf4b65..0e54ff34 100644 --- a/src/CutsceneMgr.cpp +++ b/src/CutsceneMgr.cpp @@ -4,3 +4,4 @@ bool &CCutsceneMgr::ms_running = *(bool*)0x95CCF5; bool &CCutsceneMgr::ms_cutsceneProcessing = *(bool*)0x95CD9F; +Bool &CCutsceneMgr::ms_running = *(Bool*)0x95CCF5; diff --git a/src/CutsceneMgr.h b/src/CutsceneMgr.h index 4b810114..9cafad8b 100644 --- a/src/CutsceneMgr.h +++ b/src/CutsceneMgr.h @@ -4,7 +4,10 @@ class CCutsceneMgr { static bool &ms_running; static bool &ms_cutsceneProcessing; + public: static bool IsRunning(void) { return ms_running; } static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; } + + static Bool &ms_running; }; diff --git a/src/Frontend.cpp b/src/Frontend.cpp index 6f3dfe5e..35e48065 100644 --- a/src/Frontend.cpp +++ b/src/Frontend.cpp @@ -10,6 +10,7 @@ Bool &CMenuManager::m_PrefsVsync = *(Bool*)0x5F2E58; Bool &CMenuManager::m_PrefsAllowNastyGame = *(Bool*)0x5F2E64; Bool &CMenuManager::m_bStartUpFrontEndRequested = *(Bool*)0x95CCF4; Bool &CMenuManager::m_PrefsFrameLimiter = *(Bool*)0x5F2E60; +Bool &CMenuManager::m_PrefsUseVibration = *(Bool*)0x95CD92; CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; diff --git a/src/Frontend.h b/src/Frontend.h index e8ad3314..65b8c29a 100644 --- a/src/Frontend.h +++ b/src/Frontend.h @@ -91,6 +91,7 @@ public: static Bool &m_PrefsAllowNastyGame; static Bool &m_bStartUpFrontEndRequested; static Bool &m_PrefsFrameLimiter; + static Bool &m_PrefsUseVibration; void Process(void); void DrawFrontEnd(void); diff --git a/src/Game.cpp b/src/Game.cpp index e99d88d3..9da2dab7 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -8,6 +8,7 @@ bool &CGame::nastyGame = *(bool*)0x5F4DD4; bool &CGame::frenchGame = *(bool*)0x95CDCB; bool &CGame::germanGame = *(bool*)0x95CD1E; bool &CGame::noProstitutes = *(bool*)0x95CDCF; +bool &CGame::playingIntro = *(bool*)0x95CDC2; WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); } WRAPPER Bool CGame::InitialiseOnceBeforeRW(void) { EAXJMP(0x48BB80); } @@ -17,6 +17,7 @@ public: static bool &frenchGame; static bool &germanGame; static bool &noProstitutes; + static bool &playingIntro; static void Process(void); static Bool InitialiseOnceBeforeRW(void); diff --git a/src/Pad.cpp b/src/Pad.cpp index 2cb93a77..ebb5a791 100644 --- a/src/Pad.cpp +++ b/src/Pad.cpp @@ -1,54 +1,163 @@ +#pragma warning( push ) +#pragma warning( disable : 4005) +#define DIRECTINPUT_VERSION 0x0800 +#include <dinput.h> +#pragma warning( pop ) + #include "common.h" #include "patcher.h" #include "Pad.h" +#include "ControllerConfig.h" +#include "Timer.h" +#include "Frontend.h" +#include "Camera.h" +#include "Game.h" +#include "CutsceneMgr.h" +#include "Font.h" +#include "Text.h" +#include "Timer.h" +#include "World.h" +#include "Vehicle.h" +#include "Ped.h" +#include "Population.h" +#include "Replay.h" +#include "Weather.h" +#include "win.h" -CPad *CPad::Pads = (CPad*)0x6F0360; +CPad *Pads = (CPad*)0x6F0360; // [2] CMousePointerStateHelper &MousePointerStateHelper = *(CMousePointerStateHelper*)0x95CC8C; +Bool &CPad::bDisplayNoControllerMessage = *(Bool *)0x95CD52; +Bool &CPad::bObsoleteControllerMessage = *(Bool *)0x95CDB8; +Bool &CPad::m_bMapPadOneToPadTwo = *(Bool *)0x95CD48; + CKeyboardState &CPad::OldKeyState = *(CKeyboardState*)0x6F1E70; CKeyboardState &CPad::NewKeyState = *(CKeyboardState*)0x6E60D0; CKeyboardState &CPad::TempKeyState = *(CKeyboardState*)0x774DE8; +Char CPad::KeyBoardCheatString[18]; + CMouseControllerState &CPad::OldMouseControllerState = *(CMouseControllerState*)0x8472A0; CMouseControllerState &CPad::NewMouseControllerState = *(CMouseControllerState*)0x8809F0; CMouseControllerState &CPad::PCTempMouseControllerState = *(CMouseControllerState*)0x6F1E60; -Bool &CPad::m_bMapPadOneToPadTwo = *(Bool *)0x95CD48; +_TODO("gbFastTime"); +extern Bool &gbFastTime; -WRAPPER void CPad::Clear(Bool unk) { EAXJMP(0x491A10); } -WRAPPER void CPad::AddToPCCheatString(Char c) { EAXJMP(0x492450); } -WRAPPER void CPad::UpdatePads(void) { EAXJMP(0x492720); } -WRAPPER void CPad::PrintErrorMessage(void) { EAXJMP(0x4942B0); } -WRAPPER void CPad::ResetCheats(void) { EAXJMP(0x494450); } -WRAPPER void CPad::StopPadsShaking(void) { EAXJMP(0x492F30); } +WRAPPER void WeaponCheat() { EAXJMP(0x490D90); } +WRAPPER void HealthCheat() { EAXJMP(0x490E70); } +WRAPPER void TankCheat() { EAXJMP(0x490EE0); } +WRAPPER void BlowUpCarsCheat() { EAXJMP(0x491040); } +WRAPPER void ChangePlayerCheat() { EAXJMP(0x4910B0); } +WRAPPER void MayhemCheat() { EAXJMP(0x4911C0); } +WRAPPER void EverybodyAttacksPlayerCheat() { EAXJMP(0x491270); } +WRAPPER void WeaponsForAllCheat() { EAXJMP(0x491370); } +WRAPPER void FastTimeCheat() { EAXJMP(0x4913A0); } +WRAPPER void SlowTimeCheat() { EAXJMP(0x4913F0); } +WRAPPER void MoneyCheat() { EAXJMP(0x491430); } +WRAPPER void ArmourCheat() { EAXJMP(0x491460); } +WRAPPER void WantedLevelUpCheat() { EAXJMP(0x491490); } +WRAPPER void WantedLevelDownCheat() { EAXJMP(0x4914F0); } +WRAPPER void SunnyWeatherCheat() { EAXJMP(0x491520); } +WRAPPER void CloudyWeatherCheat() { EAXJMP(0x491550); } +WRAPPER void RainyWeatherCheat() { EAXJMP(0x491580); } +WRAPPER void FoggyWeatherCheat() { EAXJMP(0x4915B0); } +WRAPPER void FastWeatherCheat() { EAXJMP(0x4915E0); } +WRAPPER void OnlyRenderWheelsCheat() { EAXJMP(0x491610); } +WRAPPER void ChittyChittyBangBangCheat() { EAXJMP(0x491640); } +WRAPPER void StrongGripCheat() { EAXJMP(0x491670); } +WRAPPER void NastyLimbsCheat() { EAXJMP(0x4916A0); } +////////////////////////////////////////////////////////////////////////// void CControllerState::Clear(void) { - LeftStickX = 0; - LeftStickY = 0; - RightStickX = 0; - RightStickY = 0; - LeftShoulder1 = 0; - LeftShoulder2 = 0; - RightShoulder1 = 0; - RightShoulder2 = 0; - DPadUp = 0; - DPadDown = 0; - DPadLeft = 0; - DPadRight = 0; - Start = 0; - Select = 0; - Square = 0; - Triangle = 0; - Cross = 0; - Circle = 0; - LeftShock = 0; - RightShock = 0; + LeftStickX = LeftStickY = RightStickX = RightStickY = 0; + LeftShoulder1 = LeftShoulder2 = RightShoulder1 = RightShoulder2 = 0; + DPadUp = DPadDown = DPadLeft = DPadRight = 0; + Start = Select = 0; + Square = Triangle = Cross = Circle = 0; + LeftShock = RightShock = 0; NetworkTalk = 0; } +void CKeyboardState::Clear() +{ + for ( Int32 i = 0; i < 12; i++ ) + F[i] = 0; + + for ( Int32 i = 0; i < 256; i++ ) + VK_KEYS[i] = 0; + + ESC = INS = DEL = HOME = END = PGUP = PGDN = 0; + + UP = DOWN = LEFT = RIGHT = 0; + + NUMLOCK = 0; + + DIV = MUL = SUB = ADD = 0; + + DECIMAL = NUM1 = NUM2 = NUM3 = NUM4 = 0; + + NUM5 = NUM6 = NUM7 = NUM8 = 0; + + NUM9 = NUM0 = SCROLLLOCK = PAUSE = 0; + + BACKSP = TAB = CAPSLOCK = EXTENTER = 0; + + LSHIFT = SHIFT = RSHIFT = LCTRL = RCTRL = LALT = RALT = 0; + + LWIN = RWIN = APPS = 0; +} + +void CPad::Clear(Bool bResetPlayerControls) +{ + NewState.Clear(); + OldState.Clear(); + + PCTempKeyState.Clear(); + PCTempJoyState.Clear(); + PCTempMouseState.Clear(); + + NewKeyState.Clear(); + OldKeyState.Clear(); + TempKeyState.Clear(); + + NewMouseControllerState.Clear(); + OldMouseControllerState.Clear(); + PCTempMouseControllerState.Clear(); + + Phase = 0; + ShakeFreq = 0; + ShakeDur = 0; + + if ( bResetPlayerControls ) + DisablePlayerControls = false; + + bApplyBrakes = false; + + + for ( Int32 i = 0; i < _TODOCONST(5); i++ ) + bHornHistory[i] = false; + + iCurrHornHistory = 0; + + for ( Int32 i = 0; i < _TODOCONST(12); i++ ) + _unk[i] = ' '; + + LastTimeTouched = CTimer::GetTimeInMilliseconds(); + AverageWeapon = 0; + AverageEntries = 0; +} + +void CPad::ClearMouseHistory() +{ + PCTempMouseControllerState.Clear(); + NewMouseControllerState.Clear(); + OldMouseControllerState.Clear(); +} + CMouseControllerState::CMouseControllerState() { LMB = 0; @@ -76,103 +185,1875 @@ void CMouseControllerState::Clear() CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() { - CMouseControllerState r; - ((void (__thiscall *)(CMousePointerStateHelper *, CMouseControllerState*))0x491BD0)(this, &r); - return r; - //EAXJMP(0x491BD0); // yep, this doesn't work here + CMouseControllerState state; + + if ( PSGLOBAL(mouse) == NULL ) + _InputInitialiseMouse(); + + if ( PSGLOBAL(mouse) != NULL ) + { + DIDEVCAPS devCaps; + devCaps.dwSize = sizeof(DIDEVCAPS); + + PSGLOBAL(mouse)->GetCapabilities(&devCaps); + + switch ( devCaps.dwButtons ) + { + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + state.MMB = true; + + case 2: + state.RMB = true; + + case 1: + state.LMB = true; + } + + if ( devCaps.dwAxes == 3 ) + { + state.WHEELDN = true; + state.WHEELUP = true; + } + } + + return state; } -void CKeyboardState::Clear() +void CPad::UpdateMouse() { - for ( Int32 i = 0; i < 12; i++ ) - F[i] = 0; + if ( IsForegroundApp() ) + { + if ( PSGLOBAL(mouse) == NULL ) + _InputInitialiseMouse(); + + DIMOUSESTATE2 state; + + if ( PSGLOBAL(mouse) != NULL && SUCCEEDED(_InputGetMouseState(&state)) ) + { + Int32 signX = 1; + Int32 signy = 1; + + if ( !FrontEndMenuManager.m_bMenuActive ) + { + if ( MousePointerStateHelper.bInvertVertically ) + signy = -1; + if ( MousePointerStateHelper.bInvertHorizontally ) + signX = -1; + } + + PCTempMouseControllerState.Clear(); + + PCTempMouseControllerState.x = (Float)(signX * state.lX); + PCTempMouseControllerState.y = (Float)(signy * state.lY); + PCTempMouseControllerState.LMB = state.rgbButtons[0] & 128; + PCTempMouseControllerState.RMB = state.rgbButtons[1] & 128; + PCTempMouseControllerState.MMB = state.rgbButtons[2] & 128; + PCTempMouseControllerState.MXB1 = state.rgbButtons[3] & 128; + PCTempMouseControllerState.MXB2 = state.rgbButtons[4] & 128; + + if ( state.lZ > 0 ) + PCTempMouseControllerState.WHEELUP = 1; + else if ( state.lZ < 0 ) + PCTempMouseControllerState.WHEELDN = 1; + + OldMouseControllerState = NewMouseControllerState; + NewMouseControllerState = PCTempMouseControllerState; + } + } +} + +CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2) +{ + static CControllerState ReconState; - for ( Int32 i = 0; i < 256; i++ ) - VK_KEYS[i] = 0; + ReconState.Clear(); - ESC = INS = DEL = HOME = END = PGUP = PGDN = 0; +#define _RECONCILE_BUTTON(button) \ + { if ( State1.button || State2.button ) ReconState.button = 255; } - UP = DOWN = LEFT = RIGHT = 0; +#define _RECONCILE_AXIS_POSITIVE(axis) \ + { if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = max(State1.axis, State2.axis); } + +#define _RECONCILE_AXIS_NEGATIVE(axis) \ + { if ( State1.axis <= 0 && State2.axis <= 0 ) ReconState.axis = min(State1.axis, State2.axis); } + +#define _RECONCILE_AXIS(axis) \ + { _RECONCILE_AXIS_POSITIVE(axis); _RECONCILE_AXIS_NEGATIVE(axis); } - NUMLOCK = 0; +#define _FIX_AXIS_DIR(axis) \ + { if ( State1.axis > 0 && State2.axis < 0 || State1.axis < 0 && State2.axis > 0 ) ReconState.axis = 0; } + +#define _FIX_RECON_DIR(pos, neg, axis) \ + { if ( (ReconState.pos || ReconState.axis < 0) && (ReconState.neg || ReconState.axis > 0) ) { ReconState.pos = 0; ReconState.neg = 0; ReconState.axis = 0; } } + + _RECONCILE_BUTTON(LeftShoulder1); + _RECONCILE_BUTTON(LeftShoulder2); + _RECONCILE_BUTTON(RightShoulder1); + _RECONCILE_BUTTON(RightShoulder2); + _RECONCILE_BUTTON(Start); + _RECONCILE_BUTTON(Select); + _RECONCILE_BUTTON(Square); + _RECONCILE_BUTTON(Triangle); + _RECONCILE_BUTTON(Cross); + _RECONCILE_BUTTON(Circle); + _RECONCILE_BUTTON(LeftShock); + _RECONCILE_BUTTON(RightShock); + _RECONCILE_BUTTON(NetworkTalk); + _RECONCILE_AXIS(LeftStickX); + _RECONCILE_AXIS(LeftStickY); + _FIX_AXIS_DIR(LeftStickX); + _FIX_AXIS_DIR(LeftStickY); + _RECONCILE_AXIS(RightStickX); + _RECONCILE_AXIS(RightStickY); + _FIX_AXIS_DIR(RightStickX); + _FIX_AXIS_DIR(RightStickY); + _RECONCILE_BUTTON(DPadUp); + _RECONCILE_BUTTON(DPadDown); + _RECONCILE_BUTTON(DPadLeft); + _RECONCILE_BUTTON(DPadRight); + _FIX_RECON_DIR(DPadUp, DPadDown, LeftStickY); + _FIX_RECON_DIR(DPadLeft, DPadRight, LeftStickX); + + return ReconState; - DIV = MUL = SUB = ADD = 0; +#undef _RECONCILE_BUTTON +#undef _RECONCILE_AXIS_POSITIVE +#undef _RECONCILE_AXIS_NEGATIVE +#undef _RECONCILE_AXIS +#undef _FIX_AXIS_DIR +#undef _FIX_RECON_DIR +} + +void CPad::StartShake(Int16 nDur, UInt8 nFreq) +{ + if ( !CMenuManager::m_PrefsUseVibration ) + return; - DECIMAL = NUM1 = NUM2 = NUM3 = NUM4 = 0; + if ( CCutsceneMgr::ms_running || CGame::playingIntro ) + return; - NUM5 = NUM6 = NUM7 = NUM8 = 0; + if ( nFreq == 0 ) + { + ShakeDur = 0; + ShakeFreq = 0; + return; + } - NUM9 = NUM0 = SCROLLLOCK = PAUSE = 0; + if ( nDur > ShakeDur ) + { + ShakeDur = nDur; + ShakeFreq = nFreq; + } +} - BACKSP = TAB = CAPSLOCK = EXTENTER = 0; +void CPad::StartShake_Distance(Int16 nDur, UInt8 nFreq, Float fX, Float fY, Float fZ) +{ + if ( !CMenuManager::m_PrefsUseVibration ) + return; + + if ( CCutsceneMgr::ms_running || CGame::playingIntro ) + return; + + Float fDist = ( TheCamera.GetPosition() - CVector(fX, fY, fZ) ).Magnitude(); + + if ( fDist < 70.0f ) + { + if ( nFreq == 0 ) + { + ShakeDur = 0; + ShakeFreq = 0; + return; + } + + if ( nDur > ShakeDur ) + { + ShakeDur = nDur; + ShakeFreq = nFreq; + } + } +} - LSHIFT = SHIFT = RSHIFT = LCTRL = RCTRL = LALT = RALT = 0; +void CPad::StartShake_Train(Float fX, Float fY) +{ + if ( !CMenuManager::m_PrefsUseVibration ) + return; + + if ( CCutsceneMgr::ms_running || CGame::playingIntro ) + return; + + if (FindPlayerVehicle() != NULL && FindPlayerVehicle()->IsTrain() ) + return; + + Float fDist = ( TheCamera.GetPosition() - CVector(fX, fY, 0.0f) ).Magnitude2D(); + + if ( fDist < 70.0f ) + { + Int32 freq = (Int32)((70.0f - fDist) * 70.0f / 70.0f + 30.0f); - LWIN = RWIN = APPS = 0; + if ( ShakeDur < 100 ) + { + ShakeDur = 100; + ShakeFreq = freq; + } + } } -bool -CPad::ForceCameraBehindPlayer(void) +void CPad::AddToPCCheatString(Char c) { - if(DisablePlayerControls) + for ( Int32 i = ARRAY_SIZE(KeyBoardCheatString); i >= 0; i-- ) + KeyBoardCheatString[i + 1] = KeyBoardCheatString[i]; + + KeyBoardCheatString[0] = c; + + #define _CHEATCMP(str) strncmp(str, KeyBoardCheatString, sizeof(str)-1) + + // "GUNSGUNSGUNS" + if ( !_CHEATCMP("SNUGSNUGSNUG") ) + WeaponCheat(); + + // "IFIWEREARICHMAN" + if ( !_CHEATCMP("NAMHCIRAEREWIFI") ) + MoneyCheat(); + + // "GESUNDHEIT" + if ( !_CHEATCMP("TIEHDNUSEG") ) + HealthCheat(); + + // "MOREPOLICEPLEASE" + if ( !_CHEATCMP("ESAELPECILOPEROM") ) + WantedLevelUpCheat(); + + // "NOPOLICEPLEASE" + if ( !_CHEATCMP("ESAELPECILOPON") ) + WantedLevelDownCheat(); + + // "GIVEUSATANK" + if ( !_CHEATCMP("KNATASUEVIG") ) + TankCheat(); + + // "BANGBANGBANG" + if ( !_CHEATCMP("GNABGNABGNAB") ) + BlowUpCarsCheat(); + + // "ILIKEDRESSINGUP" + if ( !_CHEATCMP("PUGNISSERDEKILI") ) + ChangePlayerCheat(); + + // "ITSALLGOINGMAAAD" + if ( !_CHEATCMP("DAAAMGNIOGLLASTI") ) + MayhemCheat(); + + // "NOBODYLIKESME" + if ( !_CHEATCMP("EMSEKILYDOBON") ) + EverybodyAttacksPlayerCheat(); + + // "WEAPONSFORALL" + if ( !_CHEATCMP("LLAROFSNOPAEW") ) + WeaponsForAllCheat(); + + // "TIMEFLIESWHENYOU" + if ( !_CHEATCMP("UOYNEHWSEILFEMIT") ) + FastTimeCheat(); + + // "BOOOOORING" + if ( !_CHEATCMP("GNIROOOOOB") ) + SlowTimeCheat(); + +#ifndef GTA3_1_1_PATCH + // "TURTOISE" + if ( !_CHEATCMP("ESIOTRUT") ) + ArmourCheat(); +#else + // "TORTOISE" + if ( !_CHEATCMP("ESIOTROT") ) + ArmourCheat(); +#endif + + // "SKINCANCERFORME" + if ( !_CHEATCMP("EMROFRECNACNIKS") ) + SunnyWeatherCheat(); + + // "ILIKESCOTLAND" + if ( !_CHEATCMP("DNALTOCSEKILI") ) + CloudyWeatherCheat(); + + // "ILOVESCOTLAND" + if ( !_CHEATCMP("DNALTOCSEVOLI") ) + RainyWeatherCheat(); + + // "PEASOUP" + if ( !_CHEATCMP("PUOSAEP") ) + FoggyWeatherCheat(); + + // "MADWEATHER" + if ( !_CHEATCMP("REHTAEWDAM") ) + FastWeatherCheat(); + + // "ANICESETOFWHEELS" + if ( !_CHEATCMP("SLEEHWFOTESECINA") ) + OnlyRenderWheelsCheat(); + + // "CHITTYCHITTYBB" + if ( !_CHEATCMP("BBYTTIHCYTTIHC") ) + ChittyChittyBangBangCheat(); + + // "CORNERSLIKEMAD" + if ( !_CHEATCMP("DAMEKILSRENROC") ) + StrongGripCheat(); + + // "NASTYLIMBSCHEAT" + if ( !_CHEATCMP("TAEHCSBMILYTSAN") ) + NastyLimbsCheat(); + + #undef _CHEATCMP +} + +void CPad::UpdatePads(void) +{ + Bool bUpdate = true; + + GetPad(0)->UpdateMouse(); + CapturePad(0); + + + ControlsManager.ClearSimButtonPressCheckers(); + ControlsManager.AffectPadFromKeyBoard(); + ControlsManager.AffectPadFromMouse(); + + if ( CReplay::bPlayingBackFromFile ) + bUpdate = false; + + if ( bUpdate ) + { + GetPad(0)->Update(0); + } + + GetPad(1)->NewState.Clear(); + GetPad(1)->OldState.Clear(); + + OldKeyState = NewKeyState; + NewKeyState = TempKeyState; +} + +void CPad::ProcessPCSpecificStuff(void) +{ + ; +} + +void CPad::Update(Int16 unk) +{ + OldState = NewState; + + NewState = ReconcileTwoControllersInput(PCTempKeyState, PCTempJoyState); + NewState = ReconcileTwoControllersInput(PCTempMouseState, NewState); + + PCTempJoyState.Clear(); + PCTempKeyState.Clear(); + PCTempMouseState.Clear(); + + ProcessPCSpecificStuff(); + + if ( ++iCurrHornHistory >= _TODOCONST(5) ) + iCurrHornHistory = 0; + + bHornHistory[iCurrHornHistory] = GetHorn(); + + + if ( !bDisplayNoControllerMessage ) + CGame::bDemoMode = false; +} + +void CPad::DoCheats(void) +{ + GetPad(0)->DoCheats(0); +} + +void CPad::DoCheats(Int16 unk) +{ +#ifdef PS2 + if ( GetTriangleJustDown() ) + AddToCheatString('T'); + + if ( GetCircleJustDown() ) + AddToCheatString('C'); + + if ( GetCrossJustDown() ) + AddToCheatString('X'); + + if ( GetSquareJustDown() ) + AddToCheatString('S'); + + if ( GetDPadUpJustDown() ) + AddToCheatString('U'); + + if ( GetDPadDownJustDown() ) + AddToCheatString('D'); + + if ( GetDPadLeftJustDown() ) + AddToCheatString('L'); + + if ( GetDPadRightJustDown() ) + AddToCheatString('R'); + + if ( GetLeftShoulder1JustDown() ) + AddToCheatString('1'); + + if ( GetLeftShoulder2JustDown() ) + AddToCheatString('2'); + + if ( GetRightShoulder1JustDown() ) + AddToCheatString('3'); + + if ( GetRightShoulder2JustDown() ) + AddToCheatString('4'); +#endif +} + +void CPad::StopPadsShaking(void) +{ + GetPad(0)->StopShaking(0); +} + +void CPad::StopShaking(Int16 unk) +{ + ; +} + +CPad *CPad::GetPad(Int32 pad) +{ + return &Pads[pad]; +} + +Int16 CPad::GetSteeringLeftRight(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 2: + { + Int16 axis = NewState.LeftStickX; + Int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; + + break; + } + + case 1: + case 3: + { + return NewState.LeftStickX; + + break; + } + } + + return 0; +} + +Int16 CPad::GetSteeringUpDown(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 2: + { + Int16 axis = NewState.LeftStickY; + Int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; + + break; + } + + case 1: + case 3: + { + return NewState.LeftStickY; + + break; + } + } + + return 0; +} + +Int16 CPad::GetCarGunUpDown(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 1: + case 2: + { + return NewState.RightStickY; + + break; + } + + case 3: + { + return (NewState.DPadUp - NewState.DPadDown) / 2; + + break; + } + } + + return 0; +} + +Int16 CPad::GetCarGunLeftRight(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 1: + case 2: + { + return NewState.RightStickX; + + break; + } + + case 3: + { + return (NewState.DPadRight - NewState.DPadLeft) / 2; + + break; + } + } + + return 0; +} + +Int16 CPad::GetPedWalkLeftRight(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 2: + { + Int16 axis = NewState.LeftStickX; + Int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; + + break; + } + + case 1: + case 3: + { + return NewState.LeftStickX; + + break; + } + } + + return 0; +} + + +Int16 CPad::GetPedWalkUpDown(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 2: + { + Int16 axis = NewState.LeftStickY; + Int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; + + break; + } + + case 1: + case 3: + { + return NewState.LeftStickY; + + break; + } + } + + return 0; +} + +Int16 CPad::GetAnalogueUpDown(void) +{ + switch ( Mode ) + { + case 0: + case 2: + { + Int16 axis = NewState.LeftStickY; + Int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; + + break; + } + + case 1: + case 3: + { + return NewState.LeftStickY; + + break; + } + } + + return 0; +} + +Bool CPad::GetLookLeft(void) +{ + if ( DisablePlayerControls ) return false; - switch(Mode){ - case 0: - case 1: - return !!NewState.LeftShoulder1; - case 2: - return !!NewState.Triangle; - case 3: - return !!NewState.Circle; + + return !!(NewState.LeftShoulder2 && !NewState.RightShoulder2); +} + +Bool CPad::GetLookRight(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.RightShoulder2 && !NewState.LeftShoulder2); +} + + +Bool CPad::GetLookBehindForCar(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.RightShoulder2 && NewState.LeftShoulder2); +} + +Bool CPad::GetLookBehindForPed(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!NewState.RightShock; +} + +Bool CPad::GetHorn(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + { + return !!NewState.LeftShock; + + break; + } + + case 1: + { + return !!NewState.LeftShoulder1; + + break; + } + + case 2: + { + return !!NewState.RightShoulder1; + + break; + } + + case 3: + { + return !!NewState.LeftShock; + + break; + } } + return false; } -bool -CPad::GetWeapon(void) +Bool CPad::HornJustDown(void) { - if(DisablePlayerControls) + if ( DisablePlayerControls ) return false; - switch(Mode){ - case 0: - case 1: - return !!NewState.Circle; - case 2: - return !!NewState.Cross; - case 3: - return !!NewState.RightShoulder1; + + switch ( Mode ) + { + case 0: + { + return !!(NewState.LeftShock && !OldState.LeftShock); + + break; + } + + case 1: + { + return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); + + break; + } + + case 2: + { + return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); + + break; + } + + case 3: + { + return !!(NewState.LeftShock && !OldState.LeftShock); + + break; + } } + return false; } -bool -CPad::GetLookBehindForCar(void) + +Bool CPad::GetCarGunFired(void) { - if(DisablePlayerControls) + if ( DisablePlayerControls ) return false; - return NewState.LeftShoulder2 && NewState.RightShoulder2; + + switch ( Mode ) + { + case 0: + case 1: + case 2: + { + return !!NewState.Circle; + + break; + } + + case 3: + { + return !!NewState.RightShoulder1; + + break; + } + } + + return false; } -bool -CPad::GetLookBehindForPed(void) +Bool CPad::CarGunJustDown(void) { - if(DisablePlayerControls) + if ( DisablePlayerControls ) return false; - return !!NewState.RightShock; + + switch ( Mode ) + { + case 0: + case 1: + case 2: + { + return !!(NewState.Circle && !OldState.Circle); + + break; + } + + case 3: + { + return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); + + break; + } + } + + return false; } -bool -CPad::GetLookLeft(void) +Int16 CPad::GetHandBrake(void) { - if(DisablePlayerControls) + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 1: + { + return NewState.RightShoulder1; + + break; + } + + case 2: + { + return NewState.Triangle; + + break; + } + + case 3: + { + return NewState.LeftShoulder1; + + break; + } + } + + return 0; +} + +Int16 CPad::GetBrake(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 2: + { + return NewState.Square; + + break; + } + + case 1: + { + return NewState.Square; + + break; + } + + case 3: + { + Int16 axis = 2 * NewState.RightStickY; + + if ( axis < 0 ) + return 0; + else + return axis; + + break; + } + } + + return 0; +} + +Bool CPad::GetExitVehicle(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + case 3: + { + return !!NewState.Triangle; + + break; + } + + case 2: + { + return !!NewState.LeftShoulder1; + + break; + } + } + + return false; +} + +Bool CPad::ExitVehicleJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + case 3: + { + return !!(NewState.Triangle && !OldState.Triangle); + + break; + } + + case 2: + { + return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); + + break; + } + } + + return false; +} + +Int32 CPad::GetWeapon(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + { + return NewState.Circle; + + break; + } + + case 2: + { + return NewState.Cross; + + break; + } + + case 3: + { + return NewState.RightShoulder1; + + break; + } + } + + return false; +} + +Bool CPad::WeaponJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + { + return !!(NewState.Circle && !OldState.Circle); + + break; + } + + case 2: + { + return !!(NewState.Cross && !OldState.Cross); + + break; + } + + case 3: + { + return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); + + break; + } + } + + return false; +} + +Int16 CPad::GetAccelerate(void) +{ + if ( DisablePlayerControls ) + return 0; + + switch ( Mode ) + { + case 0: + case 2: + { + return NewState.Cross; + + break; + } + + case 1: + { + return NewState.Cross; + + break; + } + + case 3: + { + Int16 axis = -2 * NewState.RightStickY; + + if ( axis < 0 ) + return 0; + else + return axis; + + break; + } + } + + return 0; +} + +Bool CPad::CycleCameraModeUpJustDown(void) +{ + switch ( Mode ) + { + case 0: + case 2: + case 3: + { + return !!(NewState.Select && !OldState.Select); + + break; + } + + case 1: + { + return !!(NewState.DPadUp && !OldState.DPadUp); + + break; + } + } + + return false; +} + +Bool CPad::CycleCameraModeDownJustDown(void) +{ + switch ( Mode ) + { + case 0: + case 2: + case 3: + { + return false; + + break; + } + + case 1: + { + return !!(NewState.DPadDown && !OldState.DPadDown); + + break; + } + } + + return false; +} + +Bool CPad::ChangeStationJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + { + return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); + + break; + } + + case 1: + { + return !!(NewState.Select && !OldState.Select); + + break; + } + + case 2: + { + return !!(NewState.LeftShock && !OldState.LeftShock); + + break; + } + + case 3: + { + return !!(NewState.Circle && !OldState.Circle); + + break; + } + } + + return false; +} + + +Bool CPad::CycleWeaponLeftJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); +} + +Bool CPad::CycleWeaponRightJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); +} + +Bool CPad::GetTarget(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + case 2: + { + return !!NewState.RightShoulder1; + + break; + } + + case 3: + { + return !!NewState.LeftShoulder1; + + break; + } + } + + return false; +} + +Bool CPad::TargetJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + case 2: + { + return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); + + break; + } + + case 3: + { + return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); + + break; + } + } + + return false; +} + +Bool CPad::JumpJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.Square && !OldState.Square); +} + +Bool CPad::GetSprint(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + case 3: + { + return !!NewState.Cross; + + break; + } + + case 2: + { + return !!NewState.Circle; + + break; + } + } + + return false; +} + +Bool CPad::ShiftTargetLeftJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); +} + +Bool CPad::ShiftTargetRightJustDown(void) +{ + if ( DisablePlayerControls ) + return false; + + return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); +} + +Bool CPad::GetAnaloguePadUp(void) +{ + static Int16 oldfStickY = 0; + + Int16 Y = CPad::GetPad(0)->GetAnalogueUpDown(); + + if ( Y < 0 && oldfStickY >= 0 ) + { + oldfStickY = Y; + return true; + } + else + { + oldfStickY = Y; + return false; + } +} + +Bool CPad::GetAnaloguePadDown(void) +{ + static Int16 oldfStickY = 0; + + Int16 Y = CPad::GetPad(0)->GetAnalogueUpDown(); + + if ( Y > 0 && oldfStickY <= 0 ) + { + oldfStickY = Y; + return true; + } + else + { + oldfStickY = Y; + return false; + } +} + +Bool CPad::GetAnaloguePadLeft(void) +{ + static Int16 oldfStickX = 0; + + Int16 X = CPad::GetPad(0)->GetPedWalkLeftRight(); + + if ( X < 0 && oldfStickX >= 0 ) + { + oldfStickX = X; + return true; + } + else + { + oldfStickX = X; + return false; + } +} + +Bool CPad::GetAnaloguePadRight(void) +{ + static Int16 oldfStickX = 0; + + Int16 X = CPad::GetPad(0)->GetPedWalkLeftRight(); + + if ( X > 0 && oldfStickX <= 0 ) + { + oldfStickX = X; + return true; + } + else + { + oldfStickX = X; + return false; + } +} + +Bool CPad::GetAnaloguePadLeftJustUp(void) +{ + static Int16 oldfStickX = 0; + + Int16 X = GetPad(0)->GetPedWalkLeftRight(); + + if ( X == 0 && oldfStickX < 0 ) + { + oldfStickX = X; + + return true; + } + else + { + oldfStickX = X; + + return false; + } +} + +Bool CPad::GetAnaloguePadRightJustUp(void) +{ + static Int16 oldfStickX = 0; + + Int16 X = GetPad(0)->GetPedWalkLeftRight(); + + if ( X == 0 && oldfStickX > 0 ) + { + oldfStickX = X; + + return true; + } + else + { + oldfStickX = X; + + return false; + } +} + +Bool CPad::ForceCameraBehindPlayer(void) +{ + if ( DisablePlayerControls ) + return false; + + switch ( Mode ) + { + case 0: + case 1: + { + return !!NewState.LeftShoulder1; + + break; + } + + case 2: + { + return !!NewState.Triangle; + + break; + } + + case 3: + { + return !!NewState.Circle; + + break; + } + } + + return false; +} + +Bool CPad::SniperZoomIn(void) +{ + if ( DisablePlayerControls ) return false; - return !!NewState.LeftShoulder2; + + switch ( Mode ) + { + case 0: + case 1: + case 3: + { + return !!NewState.Square; + + break; + } + + case 2: + { + return !!NewState.Triangle; + + break; + } + } + + return false; } -bool -CPad::GetLookRight(void) +Bool CPad::SniperZoomOut(void) { - if(DisablePlayerControls) + if ( DisablePlayerControls ) return false; - return !!NewState.RightShoulder2; + + switch ( Mode ) + { + case 0: + case 1: + case 3: + { + return !!NewState.Cross; + + break; + } + + case 2: + { + return !!NewState.Square; + + break; + } + } + + return false; } + + +Int16 CPad::SniperModeLookLeftRight(void) +{ + Int16 axis = NewState.LeftStickX; + Int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; +} + +Int16 CPad::SniperModeLookUpDown(void) +{ + Int16 axis = NewState.LeftStickY; + Int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; + + if ( abs(axis) > abs(dpad) ) + return axis; + else + return dpad; +} + +Int16 CPad::LookAroundLeftRight(void) +{ + Float axis = GetPad(0)->NewState.RightStickX; + + if ( fabs(axis) > 85 && !GetLookBehindForPed() ) + return (Int16) ( (axis + ( axis > 0 ) ? -85 : 85) + * (127.0f / 32.0f) ); // 3.96875f + + else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && fabs(axis) > 10 ) + return (Int16) ( (axis + ( axis > 0 ) ? -10 : 10) + * (127.0f / 64.0f) ); // 1.984375f + + return 0; +} + +Int16 CPad::LookAroundUpDown(void) +{ + Int16 axis = GetPad(0)->NewState.RightStickY; + + if ( abs(axis) > 85 && !GetLookBehindForPed() ) + return (Int16) ( (axis + ( axis > 0 ) ? -85 : 85) + * (127.0f / 32.0f) ); // 3.96875f + + else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && abs(axis) > 40 ) + return (Int16) ( (axis + ( axis > 0 ) ? -40 : 40) + * (127.0f / 64.0f) ); // 1.984375f + + return 0; +} + + +void CPad::ResetAverageWeapon(void) +{ + AverageWeapon = GetWeapon(); + AverageEntries = 1; +} + +void CPad::PrintErrorMessage(void) +{ + if ( bDisplayNoControllerMessage && !CGame::playingIntro && !FrontEndMenuManager.m_bMenuActive ) + { + CFont::SetScale(0.85f, 1.0f); + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); + CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreOn(); + CFont::SetPropOn(); + CFont::SetColor(CRGBA(255, 255, 200, 200)); + CFont::SetFontStyle(FONT_BANK); + CFont::PrintString + ( + SCREEN_WIDTH / 2, + SCREEN_HEIGHT / 2, + TheText.Get("NOCONT") // Please reconnect an analog controller (DUALSHOCK@) or analog controller (DUALSHOCK@2). to controller port 1 to continue + ); + } + else if ( bObsoleteControllerMessage ) + { + CFont::SetScale(0.85f, 1.0f); + CFont::SetJustifyOff(); + CFont::SetBackgroundOff(); + CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreOn(); + CFont::SetPropOn(); + CFont::SetColor(CRGBA(255, 255, 200, 200)); + CFont::SetFontStyle(FONT_BANK); + CFont::PrintString + ( + SCREEN_WIDTH / 2, + SCREEN_HEIGHT / 2, + TheText.Get("WRCONT") // The controller connected to controller port 1 is an unsupported controller. Grand Theft Auto III requires an analog controller (DUALSHOCK@) or analog controller (DUALSHOCK@2). + ); + } + +} + +void LittleTest(void) +{ + static Int32 Cunt = 0; + + Cunt++; // ??? +} + +void CPad::ResetCheats(void) +{ + CWeather::ReleaseWeather(); + + CPopulation::ms_bGivePedsWeapons = false; + + CPed::bNastyLimbsCheat = false; + CPed::bPedCheat2 = false; + CPed::bPedCheat3 = false; + + CVehicle::bWheelsOnlyCheat = false; + CVehicle::bAllDodosCheat = false; + CVehicle::bCheat3 = false; + CVehicle::bCheat4 = false; + CVehicle::bCheat5 = false; + + gbFastTime = false; + CTimer::SetTimeScale(1.0f); +} + +Char *CPad::EditString(Char *pStr, Int32 nSize) +{ + Int32 pos = strlen(pStr); + + // letters + for ( Int32 i = 0; i < ('Z' - 'A' + 1); i++ ) + { + if ( GetPad(0)->GetCharJustDown(i + 'A') && pos < nSize - 1 ) + { + pStr[pos++] = i + 'A'; + pStr[pos] = '\0'; + } + + if ( GetPad(0)->GetCharJustDown(i + 'a') && pos < nSize - 1 ) + { + pStr[pos++] = i + 'a'; + pStr[pos] = '\0'; + } + } + + // numbers + for ( Int32 i = 0; i < ('0' - '9' + 1); i++ ) + { + if ( GetPad(0)->GetCharJustDown(i + '0') && pos < nSize - 1 ) + { + pStr[pos++] = i + '0'; + pStr[pos] = '\0'; + } + } + + // space + if ( GetPad(0)->GetCharJustDown(' ') && pos < nSize - 1 ) + { + pStr[pos++] = ' '; + pStr[pos] = '\0'; + } + + + // del + if ( GetPad(0)->GetDeleteJustDown() || GetPad(0)->GetBackspaceJustDown() ) + { + if ( pos > 0 ) + pStr[pos - 1] = '\0'; + } + + // extenter/up/down + if ( GetPad(0)->GetEnterJustDown() || GetPad(0)->GetUpJustDown() || GetPad(0)->GetDownJustDown() ) + return NULL; + + return pStr; +} + +Int32 *CPad::EditCodesForControls(Int32 *pRsKeys, Int32 nSize) +{ + *pRsKeys = rsNULL; + + for ( Int32 i = 0; i < 255; i++ ) + { + if ( GetPad(0)->GetCharJustDown(i) ) + *pRsKeys = i; + } + + for ( Int32 i = 0; i < 255; i++ ) + { + if ( GetPad(0)->GetFJustDown(i) ) + *pRsKeys = i + rsF1; + } + + if ( GetPad(0)->GetEscapeJustDown() ) + *pRsKeys = rsESC; + + if ( GetPad(0)->GetInsertJustDown() ) + *pRsKeys = rsINS; + + if ( GetPad(0)->GetDeleteJustDown() ) + *pRsKeys = rsDEL; + + if ( GetPad(0)->GetHomeJustDown() ) + *pRsKeys = rsHOME; + + if ( GetPad(0)->GetEndJustDown() ) + *pRsKeys = rsEND; + + if ( GetPad(0)->GetPageUpJustDown() ) + *pRsKeys = rsPGUP; + + if ( GetPad(0)->GetPageDownJustDown() ) + *pRsKeys = rsPGDN; + + if ( GetPad(0)->GetUpJustDown() ) + *pRsKeys = rsUP; + + if ( GetPad(0)->GetDownJustDown() ) + *pRsKeys = rsDOWN; + + if ( GetPad(0)->GetLeftJustDown() ) + *pRsKeys = rsLEFT; + + if ( GetPad(0)->GetRightJustDown() ) + *pRsKeys = rsRIGHT; + + if ( GetPad(0)->GetScrollLockJustDown() ) + *pRsKeys = rsSCROLL; + + if ( GetPad(0)->GetPauseJustDown() ) + *pRsKeys = rsPAUSE; + + if ( GetPad(0)->GetNumLockJustDown() ) + *pRsKeys = rsNUMLOCK; + + if ( GetPad(0)->GetDivideJustDown() ) + *pRsKeys = rsDIVIDE; + + if ( GetPad(0)->GetTimesJustDown() ) + *pRsKeys = rsTIMES; + + if ( GetPad(0)->GetMinusJustDown() ) + *pRsKeys = rsMINUS; + + if ( GetPad(0)->GetPlusJustDown() ) + *pRsKeys = rsPLUS; + + if ( GetPad(0)->GetPadEnterJustDown() ) + *pRsKeys = rsPADENTER; + + if ( GetPad(0)->GetPadDelJustDown() ) + *pRsKeys = rsPADDEL; + + if ( GetPad(0)->GetPad1JustDown() ) + *pRsKeys = rsPADEND; + + if ( GetPad(0)->GetPad2JustDown() ) + *pRsKeys = rsPADDOWN; + + if ( GetPad(0)->GetPad3JustDown() ) + *pRsKeys = rsPADPGDN; + + if ( GetPad(0)->GetPad4JustDown() ) + *pRsKeys = rsPADLEFT; + + if ( GetPad(0)->GetPad5JustDown() ) + *pRsKeys = rsPAD5; + + if ( GetPad(0)->GetPad6JustDown() ) + *pRsKeys = rsPADRIGHT; + + if ( GetPad(0)->GetPad7JustDown() ) + *pRsKeys = rsPADHOME; + + if ( GetPad(0)->GetPad8JustDown() ) + *pRsKeys = rsPADUP; + + if ( GetPad(0)->GetPad9JustDown() ) + *pRsKeys = rsPADPGUP; + + if ( GetPad(0)->GetPad0JustDown() ) + *pRsKeys = rsPADINS; + + if ( GetPad(0)->GetBackspaceJustDown() ) + *pRsKeys = rsBACKSP; + + if ( GetPad(0)->GetTabJustDown() ) + *pRsKeys = rsTAB; + + if ( GetPad(0)->GetCapsLockJustDown() ) + *pRsKeys = rsCAPSLK; + + if ( GetPad(0)->GetEnterJustDown() ) + *pRsKeys = rsENTER; + + if ( GetPad(0)->GetLeftShiftJustDown() ) + *pRsKeys = rsLSHIFT; + + if ( GetPad(0)->GetShiftJustDown() ) + *pRsKeys = rsSHIFT; + + if ( GetPad(0)->GetRightShiftJustDown() ) + *pRsKeys = rsRSHIFT; + + if ( GetPad(0)->GetLeftCtrlJustDown() ) + *pRsKeys = rsLCTRL; + + if ( GetPad(0)->GetRightCtrlJustDown() ) + *pRsKeys = rsRCTRL; + + if ( GetPad(0)->GetLeftAltJustDown() ) + *pRsKeys = rsLALT; + + if ( GetPad(0)->GetRightAltJustDown() ) + *pRsKeys = rsRALT; + + if ( GetPad(0)->GetLeftWinJustDown() ) + *pRsKeys = rsLWIN; + + if ( GetPad(0)->GetRightWinJustDown() ) + *pRsKeys = rsRWIN; + + if ( GetPad(0)->GetAppsJustDown() ) + *pRsKeys = rsAPPS; + + return pRsKeys; +} + +STARTPATCHES + InjectHook(0x4916C0, &CControllerState::Clear, PATCH_JUMP); + InjectHook(0x491760, &CKeyboardState::Clear, PATCH_JUMP); + InjectHook(0x491A10, &CPad::Clear, PATCH_JUMP); + InjectHook(0x491B50, &CPad::ClearMouseHistory, PATCH_JUMP); + //InjectHook(0x491B80, &CMouseControllerState::CMouseControllerState, PATCH_JUMP); + InjectHook(0x491BB0, &CMouseControllerState::Clear, PATCH_JUMP); + InjectHook(0x491BD0, &CMousePointerStateHelper::GetMouseSetUp, PATCH_JUMP); + InjectHook(0x491CA0, &CPad::UpdateMouse, PATCH_JUMP); + InjectHook(0x491E60, &CPad::ReconcileTwoControllersInput, PATCH_JUMP); + InjectHook(0x492230, &CPad::StartShake, PATCH_JUMP); + InjectHook(0x492290, &CPad::StartShake_Distance, PATCH_JUMP); + InjectHook(0x492360, &CPad::StartShake_Train, PATCH_JUMP); + InjectHook(0x492450, &CPad::AddToPCCheatString, PATCH_JUMP); + InjectHook(0x492720, CPad::UpdatePads, PATCH_JUMP); + InjectHook(0x492C60, &CPad::ProcessPCSpecificStuff, PATCH_JUMP); + InjectHook(0x492C70, &CPad::Update, PATCH_JUMP); + InjectHook(0x492F00, (void (*)())CPad::DoCheats, PATCH_JUMP); + InjectHook(0x492F20, (void (CPad::*)(Int16))&CPad::DoCheats, PATCH_JUMP); + InjectHook(0x492F30, CPad::StopPadsShaking, PATCH_JUMP); + InjectHook(0x492F50, &CPad::StopShaking, PATCH_JUMP); + InjectHook(0x492F60, CPad::GetPad, PATCH_JUMP); + InjectHook(0x492F70, &CPad::GetSteeringLeftRight, PATCH_JUMP); + InjectHook(0x492FF0, &CPad::GetSteeringUpDown, PATCH_JUMP); + InjectHook(0x493070, &CPad::GetCarGunUpDown, PATCH_JUMP); + InjectHook(0x4930C0, &CPad::GetCarGunLeftRight, PATCH_JUMP); + InjectHook(0x493110, &CPad::GetPedWalkLeftRight, PATCH_JUMP); + InjectHook(0x493190, &CPad::GetPedWalkUpDown, PATCH_JUMP); + InjectHook(0x493210, &CPad::GetAnalogueUpDown, PATCH_JUMP); + InjectHook(0x493290, &CPad::GetLookLeft, PATCH_JUMP); + InjectHook(0x4932C0, &CPad::GetLookRight, PATCH_JUMP); + InjectHook(0x4932F0, &CPad::GetLookBehindForCar, PATCH_JUMP); + InjectHook(0x493320, &CPad::GetLookBehindForPed, PATCH_JUMP); + InjectHook(0x493350, &CPad::GetHorn, PATCH_JUMP); + InjectHook(0x4933F0, &CPad::HornJustDown, PATCH_JUMP); + InjectHook(0x493490, &CPad::GetCarGunFired, PATCH_JUMP); + InjectHook(0x4934F0, &CPad::CarGunJustDown, PATCH_JUMP); + InjectHook(0x493560, &CPad::GetHandBrake, PATCH_JUMP); + InjectHook(0x4935A0, &CPad::GetBrake, PATCH_JUMP); + InjectHook(0x4935F0, &CPad::GetExitVehicle, PATCH_JUMP); + InjectHook(0x493650, &CPad::ExitVehicleJustDown, PATCH_JUMP); + InjectHook(0x4936C0, &CPad::GetWeapon, PATCH_JUMP); + InjectHook(0x493700, &CPad::WeaponJustDown, PATCH_JUMP); + InjectHook(0x493780, &CPad::GetAccelerate, PATCH_JUMP); + InjectHook(0x4937D0, &CPad::CycleCameraModeUpJustDown, PATCH_JUMP); + InjectHook(0x493830, &CPad::CycleCameraModeDownJustDown, PATCH_JUMP); + InjectHook(0x493870, &CPad::ChangeStationJustDown, PATCH_JUMP); + InjectHook(0x493910, &CPad::CycleWeaponLeftJustDown, PATCH_JUMP); + InjectHook(0x493940, &CPad::CycleWeaponRightJustDown, PATCH_JUMP); + InjectHook(0x493970, &CPad::GetTarget, PATCH_JUMP); + InjectHook(0x4939D0, &CPad::TargetJustDown, PATCH_JUMP); + InjectHook(0x493A40, &CPad::JumpJustDown, PATCH_JUMP); + InjectHook(0x493A70, &CPad::GetSprint, PATCH_JUMP); + InjectHook(0x493AE0, &CPad::ShiftTargetLeftJustDown, PATCH_JUMP); + InjectHook(0x493B10, &CPad::ShiftTargetRightJustDown, PATCH_JUMP); + InjectHook(0x493B40, &CPad::GetAnaloguePadUp, PATCH_JUMP); + InjectHook(0x493BA0, &CPad::GetAnaloguePadDown, PATCH_JUMP); + InjectHook(0x493C00, &CPad::GetAnaloguePadLeft, PATCH_JUMP); + InjectHook(0x493C60, &CPad::GetAnaloguePadRight, PATCH_JUMP); + InjectHook(0x493CC0, &CPad::GetAnaloguePadLeftJustUp, PATCH_JUMP); + InjectHook(0x493D20, &CPad::GetAnaloguePadRightJustUp, PATCH_JUMP); + InjectHook(0x493D80, &CPad::ForceCameraBehindPlayer, PATCH_JUMP); + InjectHook(0x493E00, &CPad::SniperZoomIn, PATCH_JUMP); + InjectHook(0x493E70, &CPad::SniperZoomOut, PATCH_JUMP); + InjectHook(0x493EE0, &CPad::SniperModeLookLeftRight, PATCH_JUMP); + InjectHook(0x493F30, &CPad::SniperModeLookUpDown, PATCH_JUMP); + InjectHook(0x493F80, &CPad::LookAroundLeftRight, PATCH_JUMP); + InjectHook(0x494130, &CPad::LookAroundUpDown, PATCH_JUMP); + InjectHook(0x494290, &CPad::ResetAverageWeapon, PATCH_JUMP); + InjectHook(0x4942B0, CPad::PrintErrorMessage, PATCH_JUMP); + InjectHook(0x494420, LittleTest, PATCH_JUMP); + InjectHook(0x494450, CPad::ResetCheats, PATCH_JUMP); + InjectHook(0x4944B0, CPad::EditString, PATCH_JUMP); + InjectHook(0x494690, CPad::EditCodesForControls, PATCH_JUMP); + //InjectHook(0x494E50, `global constructor keyed to'Pad.cpp, PATCH_JUMP); + //InjectHook(0x494EB0, sub_494EB0, PATCH_JUMP); + //InjectHook(0x494ED0, &CPad::~CPad, PATCH_JUMP); + //InjectHook(0x494EE0, &CPad::CPad, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file @@ -71,21 +71,21 @@ public: void Clear(void); }; -static_assert(sizeof(CControllerState) == 0x2A, "CControllerState: error"); +VALIDATE_SIZE(CControllerState, 0x2A); class CMouseControllerState { public: //uint32 btns; // bit 0-2 button 1-3 - UInt8 LMB; - UInt8 RMB; - UInt8 MMB; - UInt8 WHEELUP; - UInt8 WHEELDN; - UInt8 MXB1; - UInt8 MXB2; - UInt8 _pad0; + Bool LMB; + Bool RMB; + Bool MMB; + Bool WHEELUP; + Bool WHEELDN; + Bool MXB1; + Bool MXB2; + char _pad0; Float x, y; @@ -164,6 +164,15 @@ public: VALIDATE_SIZE(CKeyboardState, 0x270); +enum +{ + // taken from miss2 + PAD1 = 0, + PAD2, + + MAX_PADS +}; + class CPad { public: @@ -176,60 +185,183 @@ public: int16 Phase; int16 Mode; int16 ShakeDur; - int8 ShakeFreq; + UInt8 ShakeFreq; int8 bHornHistory[5]; - int8 iCurrHornHistory; - int8 DisablePlayerControls; - int8 JustOutOfFrontEnd; + UInt8 iCurrHornHistory; + Bool DisablePlayerControls; int8 bApplyBrakes; - int32 unk[3]; + Char _unk[12]; //int32 unk[3]; + char _pad0[3]; int32 LastTimeTouched; int32 AverageWeapon; int32 AverageEntries; + + CPad() { } + ~CPad() { } - static CPad *Pads; //[2]; + static Bool &bDisplayNoControllerMessage; + static Bool &bObsoleteControllerMessage; + static Bool &m_bMapPadOneToPadTwo; + static CKeyboardState &OldKeyState; static CKeyboardState &NewKeyState; static CKeyboardState &TempKeyState; + static Char KeyBoardCheatString[18]; static CMouseControllerState &OldMouseControllerState; static CMouseControllerState &NewMouseControllerState; static CMouseControllerState &PCTempMouseControllerState; - static Bool &m_bMapPadOneToPadTwo; - - int GetLeftShoulder1(void) { return NewState.LeftShoulder1; } - int GetLeftShoulder2(void) { return NewState.LeftShoulder2; } - int GetRightShoulder1(void) { return NewState.RightShoulder1; } - int GetRightShoulder2(void) { return NewState.RightShoulder2; } - - bool ForceCameraBehindPlayer(void); - bool GetWeapon(void); - bool GetLookBehindForCar(void); - bool GetLookBehindForPed(void); - bool GetLookLeft(void); - bool GetLookRight(void); + + + + void Clear(Bool bResetPlayerControls); + void ClearMouseHistory(); + void UpdateMouse(); + CControllerState ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2); + void StartShake(Int16 nDur, UInt8 nFreq); + void StartShake_Distance(Int16 nDur, UInt8 nFreq, Float fX, Float fY, Float fz); + void StartShake_Train(Float fX, Float fY); + void AddToPCCheatString(Char c); - static void StopPadsShaking(void); - static void ResetCheats(void); static void UpdatePads(void); - static CPad *GetPad(int n) { return &Pads[n]; } - static void PrintErrorMessage(void); + void ProcessPCSpecificStuff(void); + void Update(Int16 unk); - void AddToPCCheatString(Char c); - void Clear(Bool unk); + static void DoCheats(void); + void DoCheats(Int16 unk); - // + static void StopPadsShaking(void); + void StopShaking(Int16 unk); + + static CPad *GetPad(Int32 pad); + Int16 GetSteeringLeftRight(void); + Int16 GetSteeringUpDown(void); + Int16 GetCarGunUpDown(void); + Int16 GetCarGunLeftRight(void); + Int16 GetPedWalkLeftRight(void); + Int16 GetPedWalkUpDown(void); + Int16 GetAnalogueUpDown(void); + Bool GetLookLeft(void); + Bool GetLookRight(void); + Bool GetLookBehindForCar(void); + Bool GetLookBehindForPed(void); + Bool GetHorn(void); + Bool HornJustDown(void); + Bool GetCarGunFired(void); + Bool CarGunJustDown(void); + Int16 GetHandBrake(void); + Int16 GetBrake(void); + Bool GetExitVehicle(void); + Bool ExitVehicleJustDown(void); + Int32 GetWeapon(void); + Bool WeaponJustDown(void); + Int16 GetAccelerate(void); + Bool CycleCameraModeUpJustDown(void); + Bool CycleCameraModeDownJustDown(void); + Bool ChangeStationJustDown(void); + Bool CycleWeaponLeftJustDown(void); + Bool CycleWeaponRightJustDown(void); + Bool GetTarget(void); + Bool TargetJustDown(void); + Bool JumpJustDown(void); + Bool GetSprint(void); + Bool ShiftTargetLeftJustDown(void); + Bool ShiftTargetRightJustDown(void); + Bool GetAnaloguePadUp(void); + Bool GetAnaloguePadDown(void); + Bool GetAnaloguePadLeft(void); + Bool GetAnaloguePadRight(void); + Bool GetAnaloguePadLeftJustUp(void); + Bool GetAnaloguePadRightJustUp(void); + Bool ForceCameraBehindPlayer(void); + Bool SniperZoomIn(void); + Bool SniperZoomOut(void); + Int16 SniperModeLookLeftRight(void); + Int16 SniperModeLookUpDown(void); + Int16 LookAroundLeftRight(void); + Int16 LookAroundUpDown(void); + void ResetAverageWeapon(void); + static void PrintErrorMessage(void); + static void ResetCheats(void); + static Char *EditString(Char *pStr, Int32 nSize); + static Int32 *EditCodesForControls(Int32 *pRsKeys, Int32 nSize); + + // mouse inline Bool GetLeftMouseJustDown() { return !!(NewMouseControllerState.LMB && !OldMouseControllerState.LMB); } + + // keyboard - inline Bool GetEnterJustDown() { return !!(NewKeyState.ENTER && !OldKeyState.ENTER); } - inline Bool GetExtEnterJustDown() { return !!(NewKeyState.EXTENTER && !OldKeyState.EXTENTER); } inline Bool GetCharJustDown(Char c) { return !!(NewKeyState.VK_KEYS[c] && !OldKeyState.VK_KEYS[c]); } - inline Bool GetLeftAltJustDown() { return !!(NewKeyState.LALT && !OldKeyState.LALT); } - inline Bool GetRightAltJustDown() { return !!(NewKeyState.RALT && !OldKeyState.RALT); } - inline Bool GetTabJustDown() { return !!(NewKeyState.TAB && !OldKeyState.TAB); } + inline Bool GetFJustDown(Int32 n) { return !!(NewKeyState.F[n] && !OldKeyState.F[n]); } + inline Bool GetEscapeJustDown() { return !!(NewKeyState.ESC && !OldKeyState.ESC); } + inline Bool GetInsertJustDown() { return !!(NewKeyState.INS && !OldKeyState.INS); } + inline Bool GetDeleteJustDown() { return !!(NewKeyState.DEL && !OldKeyState.DEL); } + inline Bool GetHomeJustDown() { return !!(NewKeyState.HOME && !OldKeyState.HOME); } + inline Bool GetEndJustDown() { return !!(NewKeyState.END && !OldKeyState.END); } + inline Bool GetPageUpJustDown() { return !!(NewKeyState.PGUP && !OldKeyState.PGUP); } + inline Bool GetPageDownJustDown() { return !!(NewKeyState.PGDN && !OldKeyState.PGDN); } + inline Bool GetUpJustDown() { return !!(NewKeyState.UP && !OldKeyState.UP); } + inline Bool GetDownJustDown() { return !!(NewKeyState.DOWN && !OldKeyState.DOWN); } + inline Bool GetLeftJustDown() { return !!(NewKeyState.LEFT && !OldKeyState.LEFT); } + inline Bool GetRightJustDown() { return !!(NewKeyState.RIGHT && !OldKeyState.RIGHT); } + inline Bool GetScrollLockJustDown() { return !!(NewKeyState.SCROLLLOCK && !OldKeyState.SCROLLLOCK); } + inline Bool GetPauseJustDown() { return !!(NewKeyState.PAUSE && !OldKeyState.PAUSE); } + inline Bool GetNumLockJustDown() { return !!(NewKeyState.NUMLOCK && !OldKeyState.NUMLOCK); } + inline Bool GetDivideJustDown() { return !!(NewKeyState.DIV && !OldKeyState.DIV); } + inline Bool GetTimesJustDown() { return !!(NewKeyState.MUL && !OldKeyState.MUL); } + inline Bool GetMinusJustDown() { return !!(NewKeyState.SUB && !OldKeyState.SUB); } + inline Bool GetPlusJustDown() { return !!(NewKeyState.ADD && !OldKeyState.ADD); } + inline Bool GetPadEnterJustDown() { return !!(NewKeyState.ENTER && !OldKeyState.ENTER); } // GetEnterJustDown + inline Bool GetPadDelJustDown() { return !!(NewKeyState.DECIMAL && !OldKeyState.DECIMAL); } + inline Bool GetPad1JustDown() { return !!(NewKeyState.NUM1 && !OldKeyState.NUM1); } + inline Bool GetPad2JustDown() { return !!(NewKeyState.NUM2 && !OldKeyState.NUM2); } + inline Bool GetPad3JustDown() { return !!(NewKeyState.NUM3 && !OldKeyState.NUM3); } + inline Bool GetPad4JustDown() { return !!(NewKeyState.NUM4 && !OldKeyState.NUM4); } + inline Bool GetPad5JustDown() { return !!(NewKeyState.NUM5 && !OldKeyState.NUM5); } + inline Bool GetPad6JustDown() { return !!(NewKeyState.NUM6 && !OldKeyState.NUM6); } + inline Bool GetPad7JustDown() { return !!(NewKeyState.NUM7 && !OldKeyState.NUM7); } + inline Bool GetPad8JustDown() { return !!(NewKeyState.NUM8 && !OldKeyState.NUM8); } + inline Bool GetPad9JustDown() { return !!(NewKeyState.NUM9 && !OldKeyState.NUM9); } + inline Bool GetPad0JustDown() { return !!(NewKeyState.NUM0 && !OldKeyState.NUM0); } + inline Bool GetBackspaceJustDown() { return !!(NewKeyState.BACKSP && !OldKeyState.BACKSP); } + inline Bool GetTabJustDown() { return !!(NewKeyState.TAB && !OldKeyState.TAB); } + inline Bool GetCapsLockJustDown() { return !!(NewKeyState.CAPSLOCK && !OldKeyState.CAPSLOCK); } + inline Bool GetEnterJustDown() { return !!(NewKeyState.EXTENTER && !OldKeyState.EXTENTER); } + inline Bool GetLeftShiftJustDown() { return !!(NewKeyState.LSHIFT && !OldKeyState.LSHIFT); } + inline Bool GetShiftJustDown() { return !!(NewKeyState.SHIFT && !OldKeyState.SHIFT); } + inline Bool GetRightShiftJustDown() { return !!(NewKeyState.RSHIFT && !OldKeyState.RSHIFT); } + inline Bool GetLeftCtrlJustDown() { return !!(NewKeyState.LCTRL && !OldKeyState.LCTRL); } + inline Bool GetRightCtrlJustDown() { return !!(NewKeyState.RCTRL && !OldKeyState.RCTRL); } + inline Bool GetLeftAltJustDown() { return !!(NewKeyState.LALT && !OldKeyState.LALT); } + inline Bool GetRightAltJustDown() { return !!(NewKeyState.RALT && !OldKeyState.RALT); } + inline Bool GetLeftWinJustDown() { return !!(NewKeyState.LWIN && !OldKeyState.LWIN); } + inline Bool GetRightWinJustDown() { return !!(NewKeyState.RWIN && !OldKeyState.RWIN); } + inline Bool GetAppsJustDown() { return !!(NewKeyState.APPS && !OldKeyState.APPS); } + + // pad + + inline Bool GetTriangleJustDown() { return !!(NewState.Triangle && !OldState.Triangle); } + inline Bool GetCircleJustDown() { return !!(NewState.Circle && !OldState.Circle); } + inline Bool GetCrossJustDown() { return !!(NewState.Cross && !OldState.Cross); } + inline Bool GetSquareJustDown() { return !!(NewState.Square && !OldState.Square); } + inline Bool GetDPadUpJustDown() { return !!(NewState.DPadUp && !OldState.DPadUp); } + inline Bool GetDPadDownJustDown() { return !!(NewState.DPadDown && !OldState.DPadDown); } + inline Bool GetDPadLeftJustDown() { return !!(NewState.DPadLeft && !OldState.DPadLeft); } + inline Bool GetDPadRightJustDown() { return !!(NewState.DPadRight && !OldState.DPadRight); } + inline Bool GetLeftShoulder1JustDown() { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); } + inline Bool GetLeftShoulder2JustDown() { return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); } + inline Bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); } + inline Bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); } + + inline Int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; } + inline Int32 GetLeftShoulder2(void) { return NewState.LeftShoulder2; } + inline Int32 GetRightShoulder1(void) { return NewState.RightShoulder1; } + inline Int32 GetRightShoulder2(void) { return NewState.RightShoulder2; } }; -static_assert(sizeof(CPad) == 0xFC, "CPad: error"); +VALIDATE_SIZE(CPad, 0xFC); #define IsButtonJustDown(pad, btn) \ (!(pad)->OldState.btn && (pad)->NewState.btn) + +void LittleTest(void);
\ No newline at end of file diff --git a/src/Stats.cpp b/src/Stats.cpp new file mode 100644 index 00000000..d7816f36 --- /dev/null +++ b/src/Stats.cpp @@ -0,0 +1,4 @@ +#include "common.h" +#include "Stats.h" + +Int32 &CStats::DaysPassed = *(Int32*)0x8F2BB8;
\ No newline at end of file diff --git a/src/Stats.h b/src/Stats.h new file mode 100644 index 00000000..b82497b5 --- /dev/null +++ b/src/Stats.h @@ -0,0 +1,7 @@ +#pragma once + +class CStats +{ +public: + static Int32 &DaysPassed; +};
\ No newline at end of file diff --git a/src/Timer.h b/src/Timer.h index d5e51dfc..fdd21144 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -19,6 +19,7 @@ public: static uint32 GetTimeInMilliseconds(void) { return m_snTimeInMilliseconds; } static inline Bool GetIsPaused() { return m_UserPause || m_CodePause; } + static inline void SetTimeScale(Float ts) { ms_fTimeScale = ts; } static void Initialise(void); static void Shutdown(void); diff --git a/src/Weather.cpp b/src/Weather.cpp index 845ef014..460deeac 100644 --- a/src/Weather.cpp +++ b/src/Weather.cpp @@ -28,3 +28,8 @@ bool &CWeather::bScriptsForceRain = *(bool*)0x95CD7D; bool &CWeather::Stored_StateStored = *(bool*)0x95CDC1; WRAPPER void CWeather::RenderRainStreaks(void) { EAXJMP(0x524550); } + +void CWeather::ReleaseWeather() +{ + ForcedWeatherType = -1; +} diff --git a/src/Weather.h b/src/Weather.h index 63e819ff..a9c15fd9 100644 --- a/src/Weather.h +++ b/src/Weather.h @@ -34,4 +34,6 @@ public: static bool &Stored_StateStored; static void RenderRainStreaks(void); + + static void ReleaseWeather(); }; diff --git a/src/control/Population.cpp b/src/control/Population.cpp new file mode 100644 index 00000000..3626381d --- /dev/null +++ b/src/control/Population.cpp @@ -0,0 +1,4 @@ +#include "common.h" +#include "Population.h" + +Bool &CPopulation::ms_bGivePedsWeapons = *(Bool*)0x95CCF6;
\ No newline at end of file diff --git a/src/control/Population.h b/src/control/Population.h new file mode 100644 index 00000000..e01d2712 --- /dev/null +++ b/src/control/Population.h @@ -0,0 +1,7 @@ +#pragma once + +class CPopulation +{ +public: + static Bool &ms_bGivePedsWeapons; +};
\ No newline at end of file diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 6cfbd846..b1bdc1bf 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -3,5 +3,6 @@ #include "Replay.h" uint8 &CReplay::Mode = *(uint8*)0x95CD5B; +Bool &CReplay::bPlayingBackFromFile = *(Bool*)0x95CD58; WRAPPER void CReplay::Display(void) { EAXJMP(0x595EE0); } diff --git a/src/control/Replay.h b/src/control/Replay.h index 85a9e35e..b680cacc 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -8,6 +8,5 @@ public: }; static uint8 &Mode; - - static void Display(void); + static Bool &bPlayingBackFromFile; }; diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp index 018979eb..55e33a2d 100644 --- a/src/entities/Ped.cpp +++ b/src/entities/Ped.cpp @@ -3,6 +3,10 @@ #include "Ped.h" #include "Pools.h" +Bool &CPed::bNastyLimbsCheat = *(Bool*)0x95CD44; +Bool &CPed::bPedCheat2 = *(Bool*)0x95CD5A; +Bool &CPed::bPedCheat3 = *(Bool*)0x95CD59; + void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); } void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); } diff --git a/src/entities/Ped.h b/src/entities/Ped.h index 366674d4..adf24c88 100644 --- a/src/entities/Ped.h +++ b/src/entities/Ped.h @@ -188,6 +188,10 @@ public: bool UseGroundColModel(void); void KillPedWithCar(CVehicle *veh, float impulse); CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; } + + static Bool &bNastyLimbsCheat; + static Bool &bPedCheat2; + static Bool &bPedCheat3; }; static_assert(offsetof(CPed, m_nPedState) == 0x224, "CPed: error"); static_assert(offsetof(CPed, m_pCurSurface) == 0x2FC, "CPed: error"); diff --git a/src/entities/Vehicle.cpp b/src/entities/Vehicle.cpp index f18cb5a7..ebd7ae68 100644 --- a/src/entities/Vehicle.cpp +++ b/src/entities/Vehicle.cpp @@ -3,5 +3,11 @@ #include "Vehicle.h" #include "Pools.h" +Bool &CVehicle::bWheelsOnlyCheat = *(Bool *)0x95CD78; +Bool &CVehicle::bAllDodosCheat = *(Bool *)0x95CD75; +Bool &CVehicle::bCheat3 = *(Bool *)0x95CD66; +Bool &CVehicle::bCheat4 = *(Bool *)0x95CD65; +Bool &CVehicle::bCheat5 = *(Bool *)0x95CD64; + void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h index 46e1c57c..00126c31 100644 --- a/src/entities/Vehicle.h +++ b/src/entities/Vehicle.h @@ -62,6 +62,12 @@ uint8 m_extra2; bool IsTrain(void) { return m_vehType == VEHICLE_TYPE_TRAIN; } bool IsHeli(void) { return m_vehType == VEHICLE_TYPE_HELI; } bool IsPlane(void) { return m_vehType == VEHICLE_TYPE_PLANE; } + + static Bool &bWheelsOnlyCheat; + static Bool &bAllDodosCheat; + static Bool &bCheat3; + static Bool &bCheat4; + static Bool &bCheat5; }; static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error"); static_assert(offsetof(CVehicle, m_pCurSurface) == 0x1E0, "CVehicle: error"); diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index c26855eb..627bdb0f 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1988,7 +1988,7 @@ _WinMain(HINSTANCE instance, ++gGameState; else if ( CPad::GetPad(0)->GetLeftMouseJustDown() ) ++gGameState; - else if ( CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetExtEnterJustDown() ) + else if ( CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() ) ++gGameState; else if ( CPad::GetPad(0)->GetCharJustDown(' ') ) ++gGameState; @@ -2024,7 +2024,7 @@ _WinMain(HINSTANCE instance, ++gGameState; else if ( CPad::GetPad(0)->GetLeftMouseJustDown() ) ++gGameState; - else if ( CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetExtEnterJustDown() ) + else if ( CPad::GetPad(0)->GetPadEnterJustDown() || CPad::GetPad(0)->GetEnterJustDown() ) ++gGameState; else if ( CPad::GetPad(0)->GetCharJustDown(' ') ) ++gGameState; |