summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-08-16 16:10:59 +0200
committereray orçunus <erayorcunus@gmail.com>2020-08-16 16:10:59 +0200
commit980dd1b5a17440e9a272b7b47ad3553cd1ce11ff (patch)
treef0bc6cfc1030f3eaf25c53b4e22db3717fc49074 /src
parentMerge branch 'master' into miami (diff)
downloadre3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.gz
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.bz2
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.lz
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.xz
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.tar.zst
re3-980dd1b5a17440e9a272b7b47ad3553cd1ce11ff.zip
Diffstat (limited to 'src')
-rw-r--r--src/control/Script.cpp11
-rw-r--r--src/core/Pad.cpp27
-rw-r--r--src/core/Pad.h4
-rw-r--r--src/peds/Ped.cpp10
-rw-r--r--src/peds/Ped.h2
-rw-r--r--src/peds/PlayerPed.cpp2
-rw-r--r--src/peds/PlayerPed.h2
7 files changed, 41 insertions, 17 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index e16ba9e0..e3ee5503 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -1824,7 +1824,7 @@ void CMissionCleanup::Process()
CWorld::Players[0].MakePlayerSafe(false);
CWorld::Players[0].m_pPed->m_nFadeDrunkenness = 1;
CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0;
- // CPad::GetPad(0)->SetDrunkInputDelay(0); // TODO(Miami)
+ CPad::GetPad(0)->SetDrunkInputDelay(0);
CWorld::Players[0].m_bDriveByAllowed = true;
// DMAudio::ShutUpPlayerTalking(0); // TODO(Miami)
CVehicle::bDisableRemoteDetonation = false;
@@ -10645,7 +10645,8 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
case COMMAND_SET_DRUNK_INPUT_DELAY:
{
CollectParameters(&m_nIp, 2);
- debug("SET_DRUNK_INPUT_DELAY not implemented\n");
+ assert(ScriptParams[1] < CPad::DRUNK_STEERING_BUFFER_SIZE);
+ CPad::GetPad(ScriptParams[0])->SetDrunkInputDelay(ScriptParams[1]);
return 0;
}
case COMMAND_SET_CHAR_MONEY:
@@ -13606,9 +13607,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER:
{
CollectParameters(&m_nIp, 1);
- debug("GET_BUS_FARES_COLLECTED_BY_PLAYER not implemented\n"); // TODO(MIAMI)
- ScriptParams[0] = 0;
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
+ ScriptParams[0] = pPlayerInfo->m_pPed->m_nLastBusFareCollected;
+ pPlayerInfo->m_pPed->m_nLastBusFareCollected = 0;
StoreParameters(&m_nIp, 1);
+ return 0;
}
case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM:
{
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 6d6c30e4..222fe349 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -631,6 +631,11 @@ void CPad::Clear(bool bResetPlayerControls)
ShakeFreq = 0;
ShakeDur = 0;
+ for (int32 i = 0; i < DRUNK_STEERING_BUFFER_SIZE; i++)
+ SteeringLeftRightBuffer[i] = 0;
+
+ DrunkDrivingBufferUsed = 0;
+
if ( bResetPlayerControls )
DisablePlayerControls = PLAYERCONTROL_ENABLED;
@@ -1806,6 +1811,9 @@ void CPad::Update(int16 pad)
bHornHistory[iCurrHornHistory] = GetHorn();
+ for (int32 i = DRUNK_STEERING_BUFFER_SIZE - 2; i >= 0; i--) {
+ SteeringLeftRightBuffer[i + 1] = SteeringLeftRightBuffer[i];
+ }
if ( !bDisplayNoControllerMessage )
CGame::bDemoMode = false;
@@ -1899,6 +1907,7 @@ int16 CPad::GetSteeringLeftRight(void)
if ( ArePlayerControlsDisabled() )
return 0;
+ int16 value;
switch (CURMODE)
{
case 0:
@@ -1908,9 +1917,12 @@ int16 CPad::GetSteeringLeftRight(void)
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
if ( Abs(axis) > Abs(dpad) )
- return axis;
+ value = axis;
else
- return dpad;
+ value = dpad;
+
+ SteeringLeftRightBuffer[0] = value;
+ value = SteeringLeftRightBuffer[DrunkDrivingBufferUsed];
break;
}
@@ -1918,13 +1930,18 @@ int16 CPad::GetSteeringLeftRight(void)
case 1:
case 3:
{
- return NewState.LeftStickX;
-
+ SteeringLeftRightBuffer[0] = NewState.LeftStickX;
+ value = SteeringLeftRightBuffer[DrunkDrivingBufferUsed];
+ break;
+ }
+ default:
+ {
+ value = 0;
break;
}
}
- return 0;
+ return value;
}
int16 CPad::GetSteeringUpDown(void)
diff --git a/src/core/Pad.h b/src/core/Pad.h
index 4374bc1a..72851317 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -141,9 +141,12 @@ public:
enum
{
HORNHISTORY_SIZE = 5,
+ DRUNK_STEERING_BUFFER_SIZE = 10,
};
CControllerState NewState;
CControllerState OldState;
+ int16 SteeringLeftRightBuffer[DRUNK_STEERING_BUFFER_SIZE];
+ int32 DrunkDrivingBufferUsed;
CControllerState PCTempKeyState;
CControllerState PCTempJoyState;
CControllerState PCTempMouseState;
@@ -263,6 +266,7 @@ public:
static char *EditString(char *pStr, int32 nSize);
static int32 *EditCodesForControls(int32 *pRsKeys, int32 nSize);
uint32 InputHowLongAgo(void);
+ void SetDrunkInputDelay(int32 delay) { DrunkDrivingBufferUsed = delay; }
#ifdef XINPUT
void AffectFromXinput(uint32 pad);
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 303c0cbc..c675b7e5 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -439,7 +439,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
bCrouchWhenScared = false;
bKnockedOffBike = false;
b158_8 = false;
- b158_10 = false;
+ bCollectBusFare = false;
bBoughtIceCream = false;
b158_40 = false;
@@ -12986,10 +12986,10 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->b157_40 = false;
ped->bRemoveFromWorld = true;
}
- if (ped->b158_10) {
- ped->b158_10 = false;
+ if (ped->bCollectBusFare) {
+ ped->bCollectBusFare = false;
if (FindPlayerPed())
- FindPlayerPed()->m_nPadUpPressedInMilliseconds += 5;
+ FindPlayerPed()->m_nLastBusFareCollected += 5;
}
if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead())
@@ -15176,7 +15176,7 @@ CPed::ProcessObjective(void)
b157_40 = true;
CPlayerPed *player = FindPlayerPed();
if (pBus->IsPassenger(player) || pBus->IsDriver(player)) {
- b158_10 = true;
+ bCollectBusFare = true;
}
}
}
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 6b0cc5fb..b7d0a856 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -485,7 +485,7 @@ public:
uint32 bCrouchWhenScared : 1;
uint32 bKnockedOffBike : 1;
uint32 b158_8 : 1;
- uint32 b158_10 : 1;
+ uint32 bCollectBusFare : 1;
uint32 bBoughtIceCream : 1;
uint32 b158_40 : 1;
//uint32 b158_80
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index cba01e31..041fb5e8 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -83,7 +83,7 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_pMeleeList[i] = nil;
}
m_nCheckPlayersIndex = 0;
- m_nPadUpPressedInMilliseconds = 0;
+ m_nLastBusFareCollected = 0;
idleAnimBlockIndex = CAnimManager::GetAnimationBlockIndex("playidles");
}
diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h
index 3b8d8fcb..8a6e7576 100644
--- a/src/peds/PlayerPed.h
+++ b/src/peds/PlayerPed.h
@@ -43,7 +43,7 @@ public:
float m_fGunSpinSpeed; // for minigun
float m_fGunSpinAngle;
unsigned int m_nPadDownPressedInMilliseconds;
- unsigned int m_nPadUpPressedInMilliseconds;
+ unsigned int m_nLastBusFareCollected;
CPlayerPed();
~CPlayerPed();