More use of GetModelIndex

This commit is contained in:
Sergeanur
2020-05-05 14:48:35 +03:00
parent 84c9484e55
commit e9b334d7bf
20 changed files with 121 additions and 128 deletions

View File

@ -369,10 +369,11 @@ CAnimViewer::Update(void)
if (pad->NewState.Triangle) {
#ifdef PED_SKIN
if(IsClumpSkinned(pTarget->GetClump()))
((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->AnimatePedColModelSkinned(pTarget->GetClump());
((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump());
else
#endif
CPedModelInfo::AnimatePedColModel(((CPedModelInfo*)CModelInfo::GetModelInfo(pTarget->m_modelIndex))->GetHitColModel(), RpClumpGetFrame(pTarget->GetClump()));
CPedModelInfo::AnimatePedColModel(((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->GetHitColModel(),
RpClumpGetFrame(pTarget->GetClump()));
AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString);
CMessages::AddMessage(gUString, 100, 0);
}

View File

@ -4639,7 +4639,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
uint8 camSetArrPos = 0;
// We may need those later
bool isPlane = car->m_modelIndex == MI_DODO;
bool isPlane = car->GetModelIndex() == MI_DODO;
bool isHeli = false;
bool isBike = false;
bool isCar = car->IsCar() && !isPlane && !isHeli && !isBike;
@ -4650,9 +4650,9 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
uint8 nextDirectionIsForward = !(pad->GetLookBehindForCar() || pad->GetLookBehindForPed() || pad->GetLookLeft() || pad->GetLookRight()) &&
DirectionWasLooking == LOOKING_FORWARD;
if (car->m_modelIndex == MI_FIRETRUCK) {
if (car->GetModelIndex() == MI_FIRETRUCK) {
camSetArrPos = 7;
} else if (car->m_modelIndex == MI_RCBANDIT) {
} else if (car->GetModelIndex() == MI_RCBANDIT) {
camSetArrPos = 5;
} else if (car->IsBoat()) {
camSetArrPos = 4;
@ -4851,7 +4851,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// This is also original LCS and SA bug, or some attempt to fix lag. We'll never know
// if (car->m_vecMoveSpeed.MagnitudeSqr() < sq(0.2f))
if (car->m_modelIndex != MI_FIRETRUCK) {
if (car->GetModelIndex() != MI_FIRETRUCK) {
// if (!isBike || GetMysteriousWheelRelatedThingBike(car) > 3)
// if (!isHeli && (!isPlane || car->GetWheelsOnGround())) {
@ -4907,7 +4907,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
bool correctAlpha = true;
// if (SA checks if we aren't in work car, why?) {
if (!isCar || car->m_modelIndex != MI_YARDIE) {
if (!isCar || car->GetModelIndex() != MI_YARDIE) {
correctAlpha = false;
}
else {
@ -5186,13 +5186,13 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// gTargetCoordsForLookingBehind = TargetCoors;
// SA code from CAutomobile::TankControl/FireTruckControl.
if (car->m_modelIndex == MI_RHINO || car->m_modelIndex == MI_FIRETRUCK) {
if (car->GetModelIndex() == MI_RHINO || car->GetModelIndex() == MI_FIRETRUCK) {
float &carGunLR = ((CAutomobile*)car)->m_fCarGunLR;
CVector hi = Multiply3x3(Front, car->GetMatrix());
// III/VC's firetruck turret angle is reversed
float angleToFace = (car->m_modelIndex == MI_FIRETRUCK ? -hi.Heading() : hi.Heading());
float angleToFace = (car->GetModelIndex() == MI_FIRETRUCK ? -hi.Heading() : hi.Heading());
if (angleToFace <= carGunLR + PI) {
if (angleToFace < carGunLR - PI)
@ -5202,7 +5202,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
float neededTurn = angleToFace - carGunLR;
float turnPerFrame = CTimer::GetTimeStep() * (car->m_modelIndex == MI_FIRETRUCK ? 0.05f : 0.015f);
float turnPerFrame = CTimer::GetTimeStep() * (car->GetModelIndex() == MI_FIRETRUCK ? 0.05f : 0.015f);
if (neededTurn <= turnPerFrame) {
if (neededTurn < -turnPerFrame)
angleToFace = carGunLR - turnPerFrame;
@ -5210,7 +5210,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
angleToFace = turnPerFrame + carGunLR;
}
if (car->m_modelIndex == MI_RHINO && carGunLR != angleToFace) {
if (car->GetModelIndex() == MI_RHINO && carGunLR != angleToFace) {
DMAudio.PlayOneShot(car->m_audioEntityId, SOUND_CAR_TANK_TURRET_ROTATE, Abs(angleToFace - carGunLR));
}
carGunLR = angleToFace;
@ -5222,7 +5222,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
// Because firetruk turret also has Y movement
if (car->m_modelIndex == MI_FIRETRUCK) {
if (car->GetModelIndex() == MI_FIRETRUCK) {
float &carGunUD = ((CAutomobile*)car)->m_fCarGunUD;
float alphaToFace = Atan2(hi.z, hi.Magnitude2D()) + DEGTORAD(15.0f);

View File

@ -354,7 +354,7 @@ CPlayerInfo::Process(void)
bool startTaxiTimer = true;
if (m_bUnusedTaxiThing && m_pPed->bInVehicle) {
CVehicle *veh = m_pPed->m_pMyVehicle;
if ((veh->m_modelIndex == MI_TAXI || veh->m_modelIndex == MI_CABBIE || veh->m_modelIndex == MI_BORGNINE)
if ((veh->GetModelIndex() == MI_TAXI || veh->GetModelIndex() == MI_CABBIE || veh->GetModelIndex() == MI_BORGNINE)
&& veh->pDriver == m_pPed && veh->m_nNumPassengers != 0) {
for (uint32 timePassed = CTimer::GetTimeInMilliseconds() - m_nUnusedTaxiTimer; timePassed >= 1000; m_nUnusedTaxiTimer += 1000) {
timePassed -= 1000;
@ -407,7 +407,7 @@ CPlayerInfo::Process(void)
if (m_pPed->bInVehicle) {
if (!m_pRemoteVehicle) {
CEntity *surfaceBelowVeh = m_pPed->m_pMyVehicle->m_pCurGroundEntity;
if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->m_modelIndex)) {
if (!surfaceBelowVeh || !CBridge::ThisIsABridgeObjectMovingUp(surfaceBelowVeh->GetModelIndex())) {
CVehicle *veh = m_pPed->m_pMyVehicle;
if (!veh->IsBoat() || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) {

View File

@ -223,21 +223,21 @@ INITSAVEBUF
#ifdef COMPATIBLE_SAVES
if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf<uint32>(buf, pVehicle->m_vehType);
WriteSaveBuf<int16>(buf, pVehicle->m_modelIndex);
WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex());
WriteSaveBuf<int32>(buf, GetVehicleRef(pVehicle));
pVehicle->Save(buf);
}
#else
if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
WriteSaveBuf(buf, pVehicle->m_modelIndex);
WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CAutomobile));
SkipSaveBuf(buf, sizeof(CAutomobile));
}
if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
WriteSaveBuf(buf, (uint32)pVehicle->m_vehType);
WriteSaveBuf(buf, pVehicle->m_modelIndex);
WriteSaveBuf(buf, pVehicle->GetModelIndex());
WriteSaveBuf(buf, GetVehicleRef(pVehicle));
memcpy(buf, pVehicle, sizeof(CBoat));
SkipSaveBuf(buf, sizeof(CBoat));
@ -279,7 +279,7 @@ INITSAVEBUF
bool bHasBeenDamaged = pObject->bHasBeenDamaged;
bool bUseVehicleColours = pObject->bUseVehicleColours;
CCompressedMatrixNotAligned tmp;
WriteSaveBuf(buf, pObject->m_modelIndex);
WriteSaveBuf(buf, pObject->GetModelIndex());
WriteSaveBuf(buf, GetObjectRef(pObject));
tmp.CompressFromFullMatrix(pObject->GetMatrix());
WriteSaveBuf(buf, tmp);
@ -397,7 +397,7 @@ INITSAVEBUF
continue;
if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) {
WriteSaveBuf(buf, pPed->m_nPedType);
WriteSaveBuf(buf, pPed->m_modelIndex);
WriteSaveBuf(buf, pPed->GetModelIndex());
WriteSaveBuf(buf, GetPedRef(pPed));
#ifdef COMPATIBLE_SAVES
pPed->Save(buf);

View File

@ -758,7 +758,7 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList &list, const
CEntity *pEntity = (CEntity *)pNode->item;
if(pEntity->m_scanCode != GetCurrentScanCode()) {
pEntity->m_scanCode = GetCurrentScanCode();
if(modelId == pEntity->m_modelIndex) {
if (modelId == pEntity->GetModelIndex()) {
float fMagnitude = 0.0f;
if(bCheck2DOnly)
fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D();
@ -953,14 +953,13 @@ CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float rad
float distance = diff.Magnitude();
if(e->GetBoundRadius() + radius > distance) {
CColModel *eCol = CModelInfo::GetModelInfo(e->m_modelIndex)->GetColModel();
CColModel *eCol = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel();
int collidedSpheres =
CCollision::ProcessColModels(sphereMat, sphereCol, e->GetMatrix(), *eCol,
gaTempSphereColPoints, nil, nil);
if(collidedSpheres != 0 ||
(e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR &&
e->m_modelIndex != MI_DODO &&
(e->IsVehicle() && ((CVehicle *)e)->m_vehType == VEHICLE_TYPE_CAR && e->GetModelIndex() != MI_DODO &&
radius + eCol->boundingBox.max.x > distance)) {
return e;
}
@ -1823,7 +1822,7 @@ CWorld::RepositionCertainDynamicObjects()
void
CWorld::RepositionOneObject(CEntity *pEntity)
{
int16 modelId = pEntity->m_modelIndex;
int16 modelId = pEntity->GetModelIndex();
if (IsTrafficLight(modelId) || IsTreeModel(modelId) || modelId == MI_PARKINGMETER ||
modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || modelId == MI_BIN || modelId == MI_POSTBOX1 ||
modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || modelId == MI_DUMP1 ||
@ -2026,8 +2025,7 @@ CWorld::Process(void)
if(!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
if(movingEnt->GetStatus() == STATUS_PLAYER) {
printf("STUCK: Final Step: Player Entity %d Is Stuck\n",
movingEnt->m_modelIndex);
printf("STUCK: Final Step: Player Entity %d Is Stuck\n", movingEnt->GetModelIndex());
movingEnt->m_vecMoveSpeed *= 0.3f;
movingEnt->ApplyMoveSpeed();
movingEnt->ApplyTurnSpeed();
@ -2119,13 +2117,13 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) {
if(pEntity->bIsStatic) {
if(pEntity->IsObject()) {
if(fPower > pObject->m_fUprootLimit || IsFence(pObject->m_modelIndex)) {
if(IsGlass(pObject->m_modelIndex)) {
if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) {
if (IsGlass(pObject->GetModelIndex())) {
CGlass::WindowRespondsToExplosion(pObject, position);
} else {
pObject->bIsStatic = false;
pObject->AddToMovingList();
int16 modelId = pEntity->m_modelIndex;
int16 modelId = pEntity->GetModelIndex();
if(modelId != MI_FIRE_HYDRANT ||
pObject->bHasBeenDamaged) {
if(pEntity->IsObject() &&