1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 09:50:00 +00:00

renamed some variables and added files; more CAutomobile::ProcessControl

This commit is contained in:
aap 2019-07-17 13:19:20 +02:00
parent 3bda0da403
commit 0f1fbf5e9a
20 changed files with 217 additions and 49 deletions

5
src/control/CarAI.cpp Normal file
View file

@ -0,0 +1,5 @@
#include "common.h"
#include "patcher.h"
#include "CarAI.h"
WRAPPER void CCarAI::UpdateCarAI(CVehicle*) { EAXJMP(0x413E50); }

9
src/control/CarAI.h Normal file
View file

@ -0,0 +1,9 @@
#pragma once
class CVehicle;
class CCarAI
{
public:
static void UpdateCarAI(CVehicle*);
};

View file

@ -14,3 +14,5 @@ WRAPPER void CCarCtrl::UpdateCarCount(CVehicle*, bool) { EAXJMP(0x4202E0); }
WRAPPER int32 CCarCtrl::ChooseCarModel(int32 vehclass) { EAXJMP(0x418110); } WRAPPER int32 CCarCtrl::ChooseCarModel(int32 vehclass) { EAXJMP(0x418110); }
WRAPPER bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool) { EAXJMP(0x41FA00); } WRAPPER bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool) { EAXJMP(0x41FA00); }
WRAPPER void CCarCtrl::JoinCarWithRoadSystem(CVehicle*) { EAXJMP(0x41F820); } WRAPPER void CCarCtrl::JoinCarWithRoadSystem(CVehicle*) { EAXJMP(0x41F820); }
WRAPPER void CCarCtrl::SteerAICarWithPhysics(CVehicle*) { EAXJMP(0x41DA60); }
WRAPPER void CCarCtrl::UpdateCarOnRails(CVehicle*) { EAXJMP(0x418880); }

View file

@ -11,6 +11,8 @@ public:
static int32 ChooseCarModel(int32 vehclass); static int32 ChooseCarModel(int32 vehclass);
static bool JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool); static bool JoinCarWithRoadSystemGotoCoors(CVehicle*, CVector, bool);
static void JoinCarWithRoadSystem(CVehicle*); static void JoinCarWithRoadSystem(CVehicle*);
static void SteerAICarWithPhysics(CVehicle*);
static void UpdateCarOnRails(CVehicle*);
static int32 &NumLawEnforcerCars; static int32 &NumLawEnforcerCars;
static int32 &NumAmbulancesOnDuty; static int32 &NumAmbulancesOnDuty;

View file

@ -63,6 +63,8 @@ CGarages::IsModelIndexADoor(uint32 id)
id == MI_CRUSHERLID; id == MI_CRUSHERLID;
} }
WRAPPER void CGarages::TriggerMessage(char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
#if 0 #if 0
WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); } WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }
#else #else

View file

@ -22,5 +22,6 @@ public:
public: public:
static bool IsModelIndexADoor(uint32 id); static bool IsModelIndexADoor(uint32 id);
static void TriggerMessage(char *text, int16, uint16 time, int16);
static void PrintMessages(void); static void PrintMessages(void);
}; };

View file

@ -12,3 +12,4 @@ uint32 &CPopulation::ms_nTotalMissionPeds = *(uint32*)0x8F5F70;
WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); } WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); }
WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); } WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); }
WRAPPER CPed *CPopulation::AddPedInCar(CVehicle *vehicle) { EAXJMP(0x4F5800); } WRAPPER CPed *CPopulation::AddPedInCar(CVehicle *vehicle) { EAXJMP(0x4F5800); }
WRAPPER bool CPopulation::IsPointInSafeZone(CVector *coors) { EAXJMP(0x4F60C0); }

View file

@ -20,4 +20,5 @@ public:
static void UpdatePedCount(uint32, bool); static void UpdatePedCount(uint32, bool);
static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool);
static CPed *AddPedInCar(CVehicle *vehicle); static CPed *AddPedInCar(CVehicle *vehicle);
static bool IsPointInSafeZone(CVector *coors);
}; };

5
src/control/Remote.cpp Normal file
View file

@ -0,0 +1,5 @@
#include "common.h"
#include "patcher.h"
#include "Remote.h"
WRAPPER void CRemote::TakeRemoteControlledCarFromPlayer(void) { EAXJMP(0x435DA0); }

7
src/control/Remote.h Normal file
View file

@ -0,0 +1,7 @@
#pragma once
class CRemote
{
public:
static void TakeRemoteControlledCarFromPlayer(void);
};

View file

@ -2050,7 +2050,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CollectParameters(&m_nIp, 2); CollectParameters(&m_nIp, 2);
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(car); assert(car);
car->AutoPilot.m_nCruiseSpeed = min(*(float*)&ScriptParams[1], 60.0f * car->m_handling->TransmissionData.fUnkMaxVelocity); car->AutoPilot.m_nCruiseSpeed = min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity);
return 0; return 0;
} }
case COMMAND_SET_CAR_DRIVING_STYLE: case COMMAND_SET_CAR_DRIVING_STYLE:

View file

@ -1460,7 +1460,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
seatOffset = 0.0f; seatOffset = 0.0f;
vehDoorOffset = offsetToOpenVanDoor; vehDoorOffset = offsetToOpenVanDoor;
} else { } else {
seatOffset = veh->m_handling->fSeatOffsetDistance * seatPosMult; seatOffset = veh->pHandling->fSeatOffsetDistance * seatPosMult;
if (veh->bLowVehicle) { if (veh->bLowVehicle) {
vehDoorOffset = offsetToOpenLowCarDoor; vehDoorOffset = offsetToOpenLowCarDoor;
} else { } else {

View file

@ -12,7 +12,12 @@
#include "World.h" #include "World.h"
#include "SurfaceTable.h" #include "SurfaceTable.h"
#include "HandlingMgr.h" #include "HandlingMgr.h"
#include "Record.h"
#include "Remote.h"
#include "Population.h"
#include "CarCtrl.h" #include "CarCtrl.h"
#include "CarAI.h"
#include "Garages.h"
#include "PathFind.h" #include "PathFind.h"
#include "Ped.h" #include "Ped.h"
#include "PlayerPed.h" #include "PlayerPed.h"
@ -55,9 +60,27 @@ CAutomobile::ProcessControl(void)
if(colModel->level > LEVEL_NONE && colModel->level != CCollision::ms_collisionInMemory) if(colModel->level > LEVEL_NONE && colModel->level != CCollision::ms_collisionInMemory)
return; return;
bool strongGrip = false; // Improve grip of vehicles in certain cases
bool strongGrip1 = false;
assert(0 && "some player stuff"); bool strongGrip2 = false;
if(FindPlayerVehicle() && this != FindPlayerVehicle()){
switch(AutoPilot.m_nCarMission){
case MISSION_RAMPLAYER_FARAWAY:
case MISSION_RAMPLAYER_CLOSE:
case MISSION_BLOCKPLAYER_FARAWAY:
case MISSION_BLOCKPLAYER_CLOSE:
if(FindPlayerSpeed().Magnitude() > 0.3f){
strongGrip1 = true;
if(FindPlayerSpeed().Magnitude() > 0.4f){
if(m_vecMoveSpeed.Magnitude() < 0.3f)
strongGrip2 = true;
}else{
if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
strongGrip2 = true;
}
}
}
}
if(bIsBus) if(bIsBus)
ProcessAutoBusDoors(); ProcessAutoBusDoors();
@ -127,24 +150,106 @@ CAutomobile::ProcessControl(void)
AutoPilot.m_flag2 = false; AutoPilot.m_flag2 = false;
// Set Center of Mass to make car more stable // Set Center of Mass to make car more stable
if(strongGrip || bCheat3) if(strongGrip1 || bCheat3)
m_vecCentreOfMass.z = 0.3f*m_aSuspensionSpringLength[0] + -1.0*m_fHeightAboveRoad; m_vecCentreOfMass.z = 0.3f*m_aSuspensionSpringLength[0] + -1.0*m_fHeightAboveRoad;
else if(m_handling->Flags & HANDLING_NONPLAYER_STABILISER && m_status == STATUS_PHYSICS) else if(pHandling->Flags & HANDLING_NONPLAYER_STABILISER && m_status == STATUS_PHYSICS)
m_vecCentreOfMass.z = m_handling->CentreOfMass.z - 0.2f*m_handling->Dimension.z; m_vecCentreOfMass.z = pHandling->CentreOfMass.z - 0.2f*pHandling->Dimension.z;
else else
m_vecCentreOfMass.z = m_handling->CentreOfMass.z; m_vecCentreOfMass.z = pHandling->CentreOfMass.z;
// Process depending on status // Process depending on status
bool playerRemote = false;
switch(m_status){ switch(m_status){
case STATUS_PLAYER:
case STATUS_SIMPLE:
case STATUS_PHYSICS:
case STATUS_ABANDONED:
case STATUS_WRECKED:
case STATUS_PLAYER_REMOTE: case STATUS_PLAYER_REMOTE:
if(CPad::GetPad(0)->WeaponJustDown()){
BlowUpCar(FindPlayerPed());
CRemote::TakeRemoteControlledCarFromPlayer();
}
if(GetModelIndex() == MI_RCBANDIT){
CVector pos = GetPosition();
// FindPlayerCoors unused
if(RcbanditCheckHitWheels() || bIsInWater || CPopulation::IsPointInSafeZone(&pos)){
if(CPopulation::IsPointInSafeZone(&pos))
CGarages::TriggerMessage("HM2_5", -1, 5000, -1);
CRemote::TakeRemoteControlledCarFromPlayer();
BlowUpCar(FindPlayerPed());
}
}
if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == this)
playerRemote = true;
// fall through
case STATUS_PLAYER:
if(playerRemote ||
pDriver && pDriver->GetPedState() != PED_EXIT_CAR && pDriver->GetPedState() != PED_DRAG_FROM_CAR){
// process control input if controlled by player
if(playerRemote || pDriver->m_nPedType == PEDTYPE_PLAYER1)
ProcessControlInputs(0);
PruneReferences();
if(m_status == STATUS_PLAYER && CRecordDataForChase::Status != RECORDSTATE_1)
DoDriveByShootings();
}
break;
case STATUS_SIMPLE:
CCarAI::UpdateCarAI(this);
CPhysical::ProcessControl();
CCarCtrl::UpdateCarOnRails(this);
m_nWheelsOnGround_2 = 4;
m_nWheelsOnGroundPrev = m_nWheelsOnGround;
m_nWheelsOnGround = 4;
pHandling->Transmission.CalculateGearForSimpleCar(AutoPilot.m_fMaxTrafficSpeed/50.0f, m_nCurrentGear);
{
float wheelRot = ProcessWheelRotation(WHEEL_STATE_0, GetForward(), m_vecMoveSpeed, 0.35f);
for(i = 0; i < 4; i++)
m_aWheelRotation[i] += wheelRot;
}
PlayHornIfNecessary();
ReduceHornCounter();
bVehicleColProcessed = false;
// that's all we do for simple vehicles
return;
case STATUS_PHYSICS:
CCarAI::UpdateCarAI(this);
CCarCtrl::SteerAICarWithPhysics(this);
PlayHornIfNecessary();
break;
case STATUS_ABANDONED:
m_fBrakePedal = 0.2f;
bIsHandbrakeOn = false;
m_fSteerAngle = 0.0f;
m_fGasPedal = 0.0f;
m_nCarHornTimer = 0;
break;
case STATUS_WRECKED:
m_fBrakePedal = 0.05f;
bIsHandbrakeOn = true;
m_fSteerAngle = 0.0f;
m_fGasPedal = 0.0f;
m_nCarHornTimer = 0;
break;
case STATUS_PLAYER_DISABLED: case STATUS_PLAYER_DISABLED:
assert(0); m_fBrakePedal = 1.0f;
bIsHandbrakeOn = true;
m_fSteerAngle = 0.0f;
m_fGasPedal = 0.0f;
m_nCarHornTimer = 0;
break;
} }
if(GetPosition().z < -0.6f){ if(GetPosition().z < -0.6f){
@ -252,11 +357,11 @@ CAutomobile::ProcessControl(void)
// Make springs push up vehicle // Make springs push up vehicle
for(i = 0; i < 4; i++){ for(i = 0; i < 4; i++){
if(m_aSuspensionSpringRatio[i] < 1.0f){ if(m_aSuspensionSpringRatio[i] < 1.0f){
float bias = m_handling->fSuspensionBias; float bias = pHandling->fSuspensionBias;
if(i == 1 || i == 3) // rear if(i == 1 || i == 3) // rear
bias = 1.0f - bias; bias = 1.0f - bias;
ApplySpringCollision(m_handling->fSuspensionForceLevel, ApplySpringCollision(pHandling->fSuspensionForceLevel,
springDirections[i], contactPoints[i], springDirections[i], contactPoints[i],
m_aSuspensionSpringRatio[i], bias); m_aSuspensionSpringRatio[i], bias);
m_aWheelSkidmarkMuddy[i] = m_aWheelSkidmarkMuddy[i] =
@ -284,7 +389,7 @@ CAutomobile::ProcessControl(void)
// dampen springs // dampen springs
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
if(m_aSuspensionSpringRatio[i] < 1.0f) if(m_aSuspensionSpringRatio[i] < 1.0f)
ApplySpringDampening(m_handling->fSuspensionDampingLevel, ApplySpringDampening(pHandling->fSuspensionDampingLevel,
springDirections[i], contactPoints[i], contactSpeeds[i]); springDirections[i], contactPoints[i], contactSpeeds[i]);
// Get speed at contact points again // Get speed at contact points again
@ -493,7 +598,7 @@ CAutomobile::ProcessControlInputs(uint8 pad)
fValue = -sq(m_fSteerRatio); fValue = -sq(m_fSteerRatio);
else else
fValue = sq(m_fSteerRatio); fValue = sq(m_fSteerRatio);
m_fSteerAngle = DEGTORAD(m_handling->fSteeringLock) * fValue; m_fSteerAngle = DEGTORAD(pHandling->fSteeringLock) * fValue;
if(bComedyControls){ if(bComedyControls){
int rnd = CGeneral::GetRandomNumber() % 10; int rnd = CGeneral::GetRandomNumber() % 10;
@ -539,6 +644,16 @@ CAutomobile::ProcessBuoyancy(void)
{ EAXJMP(0x5308D0); { EAXJMP(0x5308D0);
} }
WRAPPER void
CAutomobile::DoDriveByShootings(void)
{ EAXJMP(0x564000);
}
WRAPPER int32
CAutomobile::RcbanditCheckHitWheels(void)
{ EAXJMP(0x53C990);
}
void void
CAutomobile::GetComponentWorldPosition(int32 component, CVector &pos) CAutomobile::GetComponentWorldPosition(int32 component, CVector &pos)
{ {
@ -962,23 +1077,23 @@ CAutomobile::SetupSuspensionLines(void)
m_aWheelPosition[i] = posn.z; m_aWheelPosition[i] = posn.z;
// uppermost wheel position // uppermost wheel position
posn.z += m_handling->fSuspensionUpperLimit; posn.z += pHandling->fSuspensionUpperLimit;
colModel->lines[i].p0 = posn; colModel->lines[i].p0 = posn;
// lowermost wheel position // lowermost wheel position
posn.z += m_handling->fSuspensionLowerLimit - m_handling->fSuspensionUpperLimit; posn.z += pHandling->fSuspensionLowerLimit - pHandling->fSuspensionUpperLimit;
// lowest point on tyre // lowest point on tyre
posn.z -= mi->m_wheelScale*0.5f; posn.z -= mi->m_wheelScale*0.5f;
colModel->lines[i].p1 = posn; colModel->lines[i].p1 = posn;
// this is length of the spring at rest // this is length of the spring at rest
m_aSuspensionSpringLength[i] = m_handling->fSuspensionUpperLimit - m_handling->fSuspensionLowerLimit; m_aSuspensionSpringLength[i] = pHandling->fSuspensionUpperLimit - pHandling->fSuspensionLowerLimit;
m_aSuspensionLineLength[i] = colModel->lines[i].p0.z - colModel->lines[i].p1.z; m_aSuspensionLineLength[i] = colModel->lines[i].p0.z - colModel->lines[i].p1.z;
} }
// Compress spring somewhat to get normal height on road // Compress spring somewhat to get normal height on road
m_fHeightAboveRoad = -(colModel->lines[0].p0.z + (colModel->lines[0].p1.z - colModel->lines[0].p0.z)* m_fHeightAboveRoad = -(colModel->lines[0].p0.z + (colModel->lines[0].p1.z - colModel->lines[0].p0.z)*
(1.0f - 1.0f/(8.0f*m_handling->fSuspensionForceLevel))); (1.0f - 1.0f/(8.0f*pHandling->fSuspensionForceLevel)));
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
m_aWheelPosition[i] = mi->m_wheelScale*0.5f - m_fHeightAboveRoad; m_aWheelPosition[i] = mi->m_wheelScale*0.5f - m_fHeightAboveRoad;
@ -1129,7 +1244,7 @@ CAutomobile::Fix(void)
Damage.ResetDamageStatus(); Damage.ResetDamageStatus();
if(m_handling->Flags & HANDLING_NO_DOORS){ if(pHandling->Flags & HANDLING_NO_DOORS){
Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_MISSING); Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_MISSING);
Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_MISSING); Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_MISSING);
Damage.SetDoorStatus(DOOR_REAR_LEFT, DOOR_STATUS_MISSING); Damage.SetDoorStatus(DOOR_REAR_LEFT, DOOR_STATUS_MISSING);
@ -1382,7 +1497,7 @@ CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents
return; return;
} }
if(door == DOOR_BOOT && status == DOOR_STATUS_SWINGING && m_handling->Flags & HANDLING_NOSWING_BOOT){ if(door == DOOR_BOOT && status == DOOR_STATUS_SWINGING && pHandling->Flags & HANDLING_NOSWING_BOOT){
Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING); Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING);
status = DOOR_STATUS_MISSING; status = DOOR_STATUS_MISSING;
} }

View file

@ -96,6 +96,8 @@ public:
void PlayCarHorn(void); void PlayCarHorn(void);
void ProcessBuoyancy(void); void ProcessBuoyancy(void);
void DoDriveByShootings(void);
int32 RcbanditCheckHitWheels(void);
void PlayHornIfNecessary(void); void PlayHornIfNecessary(void);
void ResetSuspension(void); void ResetSuspension(void);
void SetupSuspensionLines(void); void SetupSuspensionLines(void);

View file

@ -140,11 +140,11 @@ cHandlingDataMgr::LoadHandlingData(void)
case 9: handling->fTractionMultiplier = strtod(word, nil); break; case 9: handling->fTractionMultiplier = strtod(word, nil); break;
case 10: handling->fTractionLoss = strtod(word, nil); break; case 10: handling->fTractionLoss = strtod(word, nil); break;
case 11: handling->fTractionBias = strtod(word, nil); break; case 11: handling->fTractionBias = strtod(word, nil); break;
case 12: handling->TransmissionData.nNumberOfGears = atoi(word); break; case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->TransmissionData.fMaxVelocity = strtod(word, nil); break; case 13: handling->Transmission.fMaxVelocity = strtod(word, nil); break;
case 14: handling->TransmissionData.fEngineAcceleration = strtod(word, nil) * 0.4f; break; case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4f; break;
case 15: handling->TransmissionData.nDriveType = word[0]; break; case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->TransmissionData.nEngineType = word[0]; break; case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = strtod(word, nil); break; case 17: handling->fBrakeDeceleration = strtod(word, nil); break;
case 18: handling->fBrakeBias = strtod(word, nil); break; case 18: handling->fBrakeBias = strtod(word, nil); break;
case 19: handling->bABS = !!atoi(word); break; case 19: handling->bABS = !!atoi(word); break;
@ -159,7 +159,7 @@ cHandlingDataMgr::LoadHandlingData(void)
case 28: handling->fSuspensionBias = strtod(word, nil); break; case 28: handling->fSuspensionBias = strtod(word, nil); break;
case 29: case 29:
sscanf(word, "%x", &handling->Flags); sscanf(word, "%x", &handling->Flags);
handling->TransmissionData.Flags = handling->Flags; handling->Transmission.Flags = handling->Flags;
break; break;
case 30: handling->FrontLights = atoi(word); break; case 30: handling->FrontLights = atoi(word); break;
case 31: handling->RearLights = atoi(word); break; case 31: handling->RearLights = atoi(word); break;
@ -192,8 +192,8 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
// TODO: figure out what exactly is being converted here // TODO: figure out what exactly is being converted here
float velocity, a, b, specificVolume; float velocity, a, b, specificVolume;
handling->TransmissionData.fEngineAcceleration /= 2500.0f; handling->Transmission.fEngineAcceleration /= 2500.0f;
handling->TransmissionData.fMaxVelocity /= 180.0f; handling->Transmission.fMaxVelocity /= 180.0f;
handling->fBrakeDeceleration /= 2500.0f; handling->fBrakeDeceleration /= 2500.0f;
handling->fTurnMass = (sq(handling->Dimension.x) + sq(handling->Dimension.y)) * handling->fMass / 12.0f; handling->fTurnMass = (sq(handling->Dimension.x) + sq(handling->Dimension.y)) * handling->fMass / 12.0f;
if(handling->fTurnMass < 10.0f) if(handling->fTurnMass < 10.0f)
@ -205,27 +205,27 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ? specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ?
a = 0.0f; a = 0.0f;
b = 100.0f; b = 100.0f;
velocity = handling->TransmissionData.fMaxVelocity; velocity = handling->Transmission.fMaxVelocity;
while(a < b && velocity > 0.0f){ while(a < b && velocity > 0.0f){
velocity -= 0.01; velocity -= 0.01;
a = handling->TransmissionData.fEngineAcceleration/6.0f; a = handling->Transmission.fEngineAcceleration/6.0f;
b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f); b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f);
} }
if(handling->nIdentifier == HANDLING_RCBANDIT){ if(handling->nIdentifier == HANDLING_RCBANDIT){
handling->TransmissionData.fUnkMaxVelocity = handling->TransmissionData.fMaxVelocity; handling->Transmission.fUnkMaxVelocity = handling->Transmission.fMaxVelocity;
}else{ }else{
handling->TransmissionData.fUnkMaxVelocity = velocity; handling->Transmission.fUnkMaxVelocity = velocity;
handling->TransmissionData.fMaxVelocity = velocity * 1.2f; handling->Transmission.fMaxVelocity = velocity * 1.2f;
} }
handling->TransmissionData.fMaxReverseVelocity = -0.2f; handling->Transmission.fMaxReverseVelocity = -0.2f;
if(handling->TransmissionData.nDriveType == '4') if(handling->Transmission.nDriveType == '4')
handling->TransmissionData.fEngineAcceleration /= 4.0f; handling->Transmission.fEngineAcceleration /= 4.0f;
else else
handling->TransmissionData.fEngineAcceleration /= 2.0f; handling->Transmission.fEngineAcceleration /= 2.0f;
handling->TransmissionData.InitGearRatios(); handling->Transmission.InitGearRatios();
} }
int32 int32

View file

@ -94,7 +94,7 @@ struct tHandlingData
int8 nPercentSubmerged; int8 nPercentSubmerged;
float fBuoyancy; float fBuoyancy;
float fTractionMultiplier; float fTractionMultiplier;
cTransmission TransmissionData; cTransmission Transmission;
float fBrakeDeceleration; float fBrakeDeceleration;
float fBrakeBias; float fBrakeBias;
int8 bABS; int8 bABS;

View file

@ -35,3 +35,18 @@ cTransmission::InitGearRatios(void)
Gears[1].fShiftDownVelocity = -0.01f; Gears[1].fShiftDownVelocity = -0.01f;
} }
void
cTransmission::CalculateGearForSimpleCar(float speed, uint8 &gear)
{
static tGear *pGearRatio = &Gears[gear];
fCurVelocity = speed;
if(speed > pGearRatio->fShiftUpVelocity)
gear++;
else if(speed < pGearRatio->fShiftDownVelocity){
if(gear - 1 < 0)
gear = 0;
else
gear--;
}
}

View file

@ -20,7 +20,8 @@ public:
float fMaxVelocity; float fMaxVelocity;
float fUnkMaxVelocity; float fUnkMaxVelocity;
float fMaxReverseVelocity; float fMaxReverseVelocity;
float field_5C; float fCurVelocity;
void InitGearRatios(void); void InitGearRatios(void);
void CalculateGearForSimpleCar(float speed, uint8 &gear);
}; };

View file

@ -259,7 +259,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
adhesion *= CTimer::GetTimeStep(); adhesion *= CTimer::GetTimeStep();
if(bAlreadySkidding) if(bAlreadySkidding)
adhesion *= m_handling->fTractionLoss; adhesion *= pHandling->fTractionLoss;
// moving sideways // moving sideways
if(contactSpeedRight != 0.0f){ if(contactSpeedRight != 0.0f){
@ -318,7 +318,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
} }
float l = Sqrt(sq(right) + sq(fwd)); float l = Sqrt(sq(right) + sq(fwd));
float tractionLoss = bAlreadySkidding ? 1.0f : m_handling->fTractionLoss; float tractionLoss = bAlreadySkidding ? 1.0f : pHandling->fTractionLoss;
right *= adhesion * tractionLoss / l; right *= adhesion * tractionLoss / l;
fwd *= adhesion * tractionLoss / l; fwd *= adhesion * tractionLoss / l;
} }
@ -450,7 +450,7 @@ CVehicle::IsVehicleNormal(void)
bool bool
CVehicle::CarHasRoof(void) CVehicle::CarHasRoof(void)
{ {
if((m_handling->Flags & HANDLING_HAS_NO_ROOF) == 0) if((pHandling->Flags & HANDLING_HAS_NO_ROOF) == 0)
return true; return true;
if(m_aExtras[0] && m_aExtras[1]) if(m_aExtras[0] && m_aExtras[1])
return false; return false;

View file

@ -125,7 +125,7 @@ class CVehicle : public CPhysical
{ {
public: public:
// 0x128 // 0x128
tHandlingData *m_handling; tHandlingData *pHandling;
CAutoPilot AutoPilot; CAutoPilot AutoPilot;
uint8 m_currentColour1; uint8 m_currentColour1;
uint8 m_currentColour2; uint8 m_currentColour2;