summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-02-03 19:09:37 +0100
committerGitHub <noreply@github.com>2020-02-03 19:09:37 +0100
commit6a04ec01cbdca62bd8b648a3cda39654d1699023 (patch)
treeabc03f5f4136a0f229c108943d82604eb8b4e73e
parentMerge pull request #321 from Sergeanur/audio_enums (diff)
parentA bug fix and VC ports for veh. enter/exit (diff)
downloadre3-6a04ec01cbdca62bd8b648a3cda39654d1699023.tar
re3-6a04ec01cbdca62bd8b648a3cda39654d1699023.tar.gz
re3-6a04ec01cbdca62bd8b648a3cda39654d1699023.tar.bz2
re3-6a04ec01cbdca62bd8b648a3cda39654d1699023.tar.lz
re3-6a04ec01cbdca62bd8b648a3cda39654d1699023.tar.xz
re3-6a04ec01cbdca62bd8b648a3cda39654d1699023.tar.zst
re3-6a04ec01cbdca62bd8b648a3cda39654d1699023.zip
-rw-r--r--src/peds/Ped.cpp65
-rw-r--r--src/vehicles/Automobile.cpp4
2 files changed, 57 insertions, 12 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index f7578bac..922de3ce 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -718,7 +718,7 @@ CheckForPedsOnGroundToAttack(CPed *attacker, CPed **pedOnGround)
}
if (pedOnGround)
- * pedOnGround = currentPed;
+ *pedOnGround = currentPed;
return stateToReturn;
}
@@ -11060,6 +11060,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
int padNo;
if (ped->IsPlayer()) {
+ // BUG? This will cause crash if m_nPedType is bigger then 1, there are only 2 pads
switch (ped->m_nPedType) {
case PEDTYPE_PLAYER1:
padNo = 0;
@@ -11073,9 +11074,6 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
case PEDTYPE_PLAYER4:
padNo = 3;
break;
- default:
- // FIX: that was "break"
- return;
}
CPad *pad = CPad::GetPad(padNo);
@@ -11175,6 +11173,7 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
int padNo;
if (ped->IsPlayer()) {
+ // BUG? This will cause crash if m_nPedType is bigger then 1, there are only 2 pads
switch (ped->m_nPedType) {
case PEDTYPE_PLAYER1:
padNo = 0;
@@ -11188,9 +11187,6 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
case PEDTYPE_PLAYER4:
padNo = 3;
break;
- default:
- // FIX: that was "break"
- return;
}
CPad* pad = CPad::GetPad(padNo);
bool engineIsIntact = false;
@@ -11417,6 +11413,34 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (!veh)
return;
+#ifdef VC_PED_PORTS
+ // Situation of entering car as a driver while there is already a driver exiting atm.
+ CPed *driver = veh->pDriver;
+ if (driver && driver->m_nPedState == PED_DRIVING && !veh->bIsBus && driver->m_objective == OBJECTIVE_LEAVE_VEHICLE
+ && (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK)) {
+
+ if (!ped->IsPlayer() && (ped->CharCreatedBy != MISSION_CHAR || driver->IsPlayer())) {
+ ped->QuitEnteringCar();
+ return;
+ }
+ if (driver->CharCreatedBy == MISSION_CHAR) {
+ PedSetOutCarCB(nil, veh->pDriver);
+ if (driver->m_pMyVehicle) {
+ driver->PositionPedOutOfCollision();
+ } else {
+ driver->m_pMyVehicle = veh;
+ driver->PositionPedOutOfCollision();
+ driver->m_pMyVehicle = nil;
+ }
+ veh->pDriver = nil;
+ } else {
+ driver->SetDead();
+ driver->FlagToDestroyWhenNextProcessed();
+ veh->pDriver = nil;
+ }
+ }
+#endif
+
if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead())
return;
@@ -11446,7 +11470,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (veh->IsBoat()) {
if (ped->IsPlayer()) {
-#ifdef VC_PED_PORTS
+#if defined(FIX_BUGS) || defined(VC_PED_PORTS)
CCarCtrl::RegisterVehicleOfInterest(veh);
#endif
if (veh->m_status == STATUS_SIMPLE) {
@@ -11499,7 +11523,10 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif
}
}
- } else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
+ }
+ // This shouldn't happen at all. Passengers can't enter with PED_CARJACK. Even though they did, we shouldn't call AddPassenger in here and SetDriver in below.
+#ifndef VC_PED_PORTS
+ else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
if (ped->m_nPedState == PED_CARJACK) {
veh->AddPassenger(ped, 0);
ped->m_nPedState = PED_DRIVING;
@@ -11509,6 +11536,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->AutoPilot.m_nCruiseSpeed = 17;
}
}
+#endif
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK) {
veh->SetDriver(ped);
@@ -11572,6 +11600,10 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->m_prevObjective = OBJECTIVE_NONE;
ped->RestorePreviousObjective();
+#ifdef VC_PED_PORTS
+ if(veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR)
+ veh->AutoPilot.m_nCruiseSpeed = 17;
+#endif
}
veh->m_nGettingInFlags &= ~GetCarDoorFlag(ped->m_vehEnterType);
@@ -13098,13 +13130,22 @@ CPed::ProcessObjective(void)
m_objectiveTimer = 0;
}
}
+ // fall through
}
case OBJECTIVE_ENTER_CAR_AS_DRIVER:
{
if (!m_carInObjective || bInVehicle) {
- bObjectiveCompleted = true;
- bScriptObjectiveCompleted = true;
- RestorePreviousState();
+#ifdef VC_PED_PORTS
+ if (bInVehicle && m_pMyVehicle != m_carInObjective)
+ {
+ SetExitCar(m_pMyVehicle, 0);
+ }
+#endif
+ {
+ bObjectiveCompleted = true;
+ bScriptObjectiveCompleted = true;
+ RestorePreviousState();
+ }
} else {
if (m_leaveCarTimer > CTimer::GetTimeInMilliseconds()) {
SetMoveState(PEDMOVE_STILL);
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index d6032457..a79f619c 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -3885,6 +3885,9 @@ CAutomobile::IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset)
}
CVector dist = doorPos - seatPos;
+
+ // Removing that makes this func. return false for van doors.
+ doorPos.z += 0.5f;
float length = dist.Magnitude();
CVector pedPos = seatPos + dist*((length+0.6f)/length);
@@ -4193,6 +4196,7 @@ GetCurrentAtomicObjectCB(RwObject *object, void *data)
}
CColPoint aTempPedColPts[32]; // this name doesn't make any sense
+ // they probably copied it from Ped (both serves same purpose) and didn't change the name
CObject*
CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)