This commit is contained in:
Nikolay Korolev 2021-01-31 01:38:00 +03:00
parent 01d4312251
commit 07a5cc6544
7 changed files with 162 additions and 89 deletions

View file

@ -8,6 +8,7 @@
#include "DMAudio.h" #include "DMAudio.h"
#include "General.h" #include "General.h"
#include "Font.h" #include "Font.h"
#include "Frontend.h"
#include "HandlingMgr.h" #include "HandlingMgr.h"
#include "Hud.h" #include "Hud.h"
#include "Messages.h" #include "Messages.h"
@ -15,6 +16,7 @@
#include "Pad.h" #include "Pad.h"
#include "Particle.h" #include "Particle.h"
#include "PlayerPed.h" #include "PlayerPed.h"
#include "Radar.h"
#include "Replay.h" #include "Replay.h"
#include "Script.h" #include "Script.h"
#include "Stats.h" #include "Stats.h"
@ -101,10 +103,10 @@
const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLLECTCARS_CARS] = const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLLECTCARS_CARS] =
{ {
{ MI_LANDSTAL, MI_IDAHO, MI_ESPERANT, MI_STALLION, MI_RANCHER, MI_BLISTAC }, { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL },
{ MI_SABRE, MI_VIRGO, MI_SENTINEL, MI_STRETCH, MI_WASHING, MI_ADMIRAL }, { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL },
{ MI_CHEETAH, MI_INFERNUS, MI_BANSHEE, MI_PHEONIX, MI_COMET, MI_STINGER }, { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL },
{ MI_VOODOO, MI_CUBAN, MI_CADDY, MI_BAGGAGE, MI_MRWHOOP, MI_PIZZABOY } { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL },
}; };
const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO };
@ -890,7 +892,7 @@ void CGarage::Update()
m_pTarget = nil; m_pTarget = nil;
break; break;
} }
if (IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) { if (!IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) {
printf("FIX FOR IE GARAGE TRAPPING PLAYER\n"); printf("FIX FOR IE GARAGE TRAPPING PLAYER\n");
m_eGarageState = GS_OPENING; m_eGarageState = GS_OPENING;
} }
@ -1677,23 +1679,20 @@ void CGarage::RemoveCarsBlockingDoorNotInside()
void CGarages::PrintMessages() void CGarages::PrintMessages()
{ {
if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) { if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) {
// CRadar::m_FadeDownRadar = true; // TODO
CFont::DrawFonts(); CFont::DrawFonts();
CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); float x_scale = FrontEndMenuManager.m_PrefsUseWideScreen ? 0.34506f : 0.3834f;
CFont::SetScale(PSP_SCREEN_SCALE_X(x_scale), PSP_SCREEN_SCALE_Y(0.71f));
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
#ifdef FIX_BUGS
CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 50));
#else
CFont::SetCentreSize(SCREEN_WIDTH - 50);
#endif
CFont::SetCentreOn(); CFont::SetCentreOn();
CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD));
CFont::SetColor(CRGBA(27, 89, 130, 255)); CFont::SetColor(CRGBA(27, 89, 130, 255));
CFont::SetDropShadowPosition(2); CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetCentreSize(PSP_SCREEN_SCALE_X(454.0f));
float y_offset = SCREEN_SCALE_Y(140.0f); float y_offset = PSP_SCREEN_SCALE_Y(170.0f);
if (MessageNumberInString2 >= 0) { if (MessageNumberInString2 >= 0) {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString); CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
@ -1714,6 +1713,7 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle)
switch (pVehicle->GetModelIndex()) { switch (pVehicle->GetModelIndex()) {
case MI_FIRETRUCK: case MI_FIRETRUCK:
case MI_AMBULAN: case MI_AMBULAN:
case MI_FBICAR:
case MI_POLICE: case MI_POLICE:
case MI_ENFORCER: case MI_ENFORCER:
case MI_BUS: case MI_BUS:
@ -1721,9 +1721,6 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle)
case MI_BARRACKS: case MI_BARRACKS:
case MI_DODO: case MI_DODO:
case MI_COACH: case MI_COACH:
#ifndef GTA_PS2
case MI_FBIRANCH:
#endif
return false; return false;
default: default:
break; break;
@ -1773,9 +1770,9 @@ void CGarage::BuildRotatedDoorMatrix(CEntity * pDoor, float fPosition)
void CGarage::UpdateCrusherAngle() void CGarage::UpdateCrusherAngle()
{ {
RefreshDoorPointers(false); RefreshDoorPointers(false);
m_pDoor1->GetMatrix().SetRotateXOnly(TWOPI - m_fDoorPos); m_pDoor2->GetMatrix().SetRotateXOnly(TWOPI - m_fDoorPos);
m_pDoor1->GetMatrix().UpdateRW(); m_pDoor2->GetMatrix().UpdateRW();
m_pDoor1->UpdateRwFrame(); m_pDoor2->UpdateRwFrame();
} }
void CGarage::UpdateCrusherShake(float X, float Y) void CGarage::UpdateCrusherShake(float X, float Y)
@ -1860,6 +1857,7 @@ void CGarages::TriggerMessage(const char* text, int16 num1, uint16 time, int16 n
MessageEndTime = CTimer::GetTimeInMilliseconds() - 500 + time; MessageEndTime = CTimer::GetTimeInMilliseconds() - 500 + time;
} }
else { else {
CMessages::AddToPreviousBriefArray(TheText.Get(text), -1, -1, -1, -1, -1, -1, nil);
strcpy(MessageIDString, text); strcpy(MessageIDString, text);
MessageStartTime = CTimer::GetTimeInMilliseconds(); MessageStartTime = CTimer::GetTimeInMilliseconds();
MessageEndTime = CTimer::GetTimeInMilliseconds() + time; MessageEndTime = CTimer::GetTimeInMilliseconds() + time;
@ -1926,6 +1924,8 @@ bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id)
bool CGarage::DoesCraigNeedThisCar(int32 mi) bool CGarage::DoesCraigNeedThisCar(int32 mi)
{ {
int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType);
if (ct != 0)
return false;
for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) {
if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE))
return (CGarages::CarTypesCollected[ct] & BIT(i)) == 0; return (CGarages::CarTypesCollected[ct] & BIT(i)) == 0;
@ -1936,8 +1936,10 @@ bool CGarage::DoesCraigNeedThisCar(int32 mi)
bool CGarage::HasCraigCollectedThisCar(int32 mi) bool CGarage::HasCraigCollectedThisCar(int32 mi)
{ {
int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType);
if (ct != 0)
return 0;
for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) {
if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) if (mi == gaCarsToCollectInCraigsGarages[ct][i])
return CGarages::CarTypesCollected[ct] & BIT(i); return CGarages::CarTypesCollected[ct] & BIT(i);
} }
return false; return false;
@ -1946,23 +1948,21 @@ bool CGarage::HasCraigCollectedThisCar(int32 mi)
bool CGarage::MarkThisCarAsCollectedForCraig(int32 mi) bool CGarage::MarkThisCarAsCollectedForCraig(int32 mi)
{ {
int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType);
if (ct != 0)
return 0;
int index; int index;
for (index = 0; index < TOTAL_COLLECTCARS_CARS; index++) { for (index = 0; index < TOTAL_COLLECTCARS_CARS; index++) {
if (mi == gaCarsToCollectInCraigsGarages[ct][index] || (gaCarsToCollectInCraigsGarages[ct][index] == MI_CHEETAH && mi == MI_VICECHEE)) if (mi == gaCarsToCollectInCraigsGarages[ct][index])
break; break;
} }
if (index >= TOTAL_COLLECTCARS_CARS) if (index >= TOTAL_COLLECTCARS_CARS)
return false; return false;
CGarages::CarTypesCollected[ct] |= BIT(index); CGarages::CarTypesCollected[ct] |= BIT(index);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_REWARD;
for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) {
if ((CGarages::CarTypesCollected[ct] & BIT(i)) == 0) { if ((CGarages::CarTypesCollected[ct] & BIT(i)) == 0) {
CGarages::TriggerMessage("GA_13", -1, 5000, -1); // Delivered like a pro. Complete the list and there'll be a bonus for you.
return false; return false;
} }
} }
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_ALLCARS_REWARD;
CGarages::TriggerMessage("GA_14", -1, 5000, -1); // All the cars. NICE! Here's a little something.
return true; return true;
} }
@ -2059,8 +2059,27 @@ void CGarage::FindDoorsEntitiesSectorList(CPtrList& list, bool dummy)
pEntity->m_scanCode = CWorld::GetCurrentScanCode(); pEntity->m_scanCode = CWorld::GetCurrentScanCode();
if (!pEntity || !CGarages::IsModelIndexADoor(pEntity->GetModelIndex())) if (!pEntity || !CGarages::IsModelIndexADoor(pEntity->GetModelIndex()))
continue; continue;
if (!IsPointInsideGarage(pEntity->GetPosition(), 2.0f)) if (Abs(pEntity->GetPosition().x - GetGarageCenterX()) >= 20.0f ||
Abs(pEntity->GetPosition().y - GetGarageCenterY()) >= 20.0f)
continue; continue;
if (pEntity->GetModelIndex() == MI_CRUSHERBODY) {
m_pDoor1 = pEntity;
m_bDoor1IsDummy = dummy;
if (dummy)
m_bDoor1PoolIndex = (CPools::GetDummyPool()->GetIndex((CDummy*)pEntity)) & 0x7F;
else
m_bDoor1PoolIndex = (CPools::GetObjectPool()->GetIndex((CObject*)pEntity)) & 0x7F;
continue;
}
if (pEntity->GetModelIndex() == MI_CRUSHERLID) {
m_pDoor2 = pEntity;
m_bDoor2IsDummy = dummy;
if (dummy)
m_bDoor2PoolIndex = (CPools::GetDummyPool()->GetIndex((CDummy*)pEntity)) & 0x7F;
else
m_bDoor2PoolIndex = (CPools::GetObjectPool()->GetIndex((CObject*)pEntity)) & 0x7F;
continue;
}
if (!m_pDoor1) { if (!m_pDoor1) {
m_pDoor1 = pEntity; m_pDoor1 = pEntity;
m_bDoor1IsDummy = dummy; m_bDoor1IsDummy = dummy;
@ -2117,25 +2136,48 @@ bool CGarages::HasCarBeenCrushed(int32 handle)
void CStoredCar::StoreCar(CVehicle* pVehicle) void CStoredCar::StoreCar(CVehicle* pVehicle)
{ {
m_nModelIndex = pVehicle->GetModelIndex(); m_nModelIndex = pVehicle->GetModelIndex();
m_vecPos = pVehicle->GetPosition(); m_fPosX = pVehicle->GetPosition().x;
m_vecAngle = pVehicle->GetForward(); m_fPosY = pVehicle->GetPosition().y;
m_fPosY = pVehicle->GetPosition().z;
m_fForwardX = pVehicle->GetForward().x;
m_fForwardY = pVehicle->GetForward().y;
m_fForwardZ = pVehicle->GetForward().z;
m_fTractionMultiplier = 1.0f;
m_nPrimaryColor = pVehicle->m_currentColour1; m_nPrimaryColor = pVehicle->m_currentColour1;
m_nSecondaryColor = pVehicle->m_currentColour2; m_nSecondaryColor = pVehicle->m_currentColour2;
m_nRadioStation = pVehicle->m_nRadioStation; m_nRadioStation = pVehicle->m_nRadioStation;
m_nVariationA = pVehicle->m_aExtras[0]; m_nVariationA = pVehicle->m_aExtras[0];
m_nVariationB = pVehicle->m_aExtras[1]; m_nVariationB = pVehicle->m_aExtras[1];
m_bBulletproof = pVehicle->bBulletProof; m_nFlags = 0;
m_bFireproof = pVehicle->bFireProof; if (pVehicle->bRewardVehicle) m_nFlags |= FLAG_REWARD_VEHICLE;
m_bExplosionproof = pVehicle->bExplosionProof; if (pVehicle->bBulletProof) m_nFlags |= FLAG_BULLETPROOF;
m_bCollisionproof = pVehicle->bCollisionProof; if (pVehicle->bFireProof) m_nFlags |= FLAG_FIREPROOF;
m_bMeleeproof = pVehicle->bMeleeProof; if (pVehicle->bExplosionProof) m_nFlags |= FLAG_EXPLOSIONPROOF;
if (pVehicle->IsCar() || pVehicle->IsBike()) if (pVehicle->bCollisionProof) m_nFlags |= FLAG_COLLISIONPROOF;
m_nCarBombType = ((CAutomobile*)pVehicle)->m_bombType; // NB: cast to CAutomobile is original behaviour if (pVehicle->bMeleeProof) m_nFlags |= FLAG_MELEEPROOF;
if (pVehicle->bTyresDontBurst) m_nFlags |= FLAG_TIRES_INVULNERABLE;
if (pVehicle->bTakeLessDamage) m_nFlags |= FLAG_STRONG;
if (pVehicle->bIsHeavy) m_nFlags |= FLAG_HEAVY;
if (pVehicle->IsCar()) {
CAutomobile* pAutomobile = (CAutomobile*)pVehicle;
if (pAutomobile->bFixedColour) m_nFlags |= FLAG_PERMANENT_COLOUR;
if (pAutomobile->m_bombType) m_nFlags |= FLAG_BOMB;
if (pAutomobile->bNotDamagedUpsideDown) m_nFlags |= FLAG_NOT_DAMAGED_UPSIDEDOWN;
m_fTractionMultiplier = pAutomobile->m_fTraction;
}
else if (pVehicle->IsBike()) {
CBike* pBike = (CBike*)pVehicle;
if (pBike->bFixedColour) m_nFlags |= FLAG_PERMANENT_COLOUR;
m_fTractionMultiplier = pBike->m_fTraction;
}
} }
CVehicle* CStoredCar::RestoreCar() CVehicle* CStoredCar::RestoreCar()
{ {
CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY); CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY);
uint8 owner = RANDOM_VEHICLE;
if (m_nFlags & FLAG_REWARD_VEHICLE)
owner = MISSION_VEHICLE;
if (!CStreaming::HasModelLoaded(m_nModelIndex)) if (!CStreaming::HasModelLoaded(m_nModelIndex))
return nil; return nil;
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -2148,19 +2190,19 @@ CVehicle* CStoredCar::RestoreCar()
} }
CVehicle* pVehicle; CVehicle* pVehicle;
if (CModelInfo::IsBoatModel(m_nModelIndex)) if (CModelInfo::IsBoatModel(m_nModelIndex))
pVehicle = new CBoat(m_nModelIndex, RANDOM_VEHICLE); pVehicle = new CBoat(m_nModelIndex, owner);
else if (CModelInfo::IsBikeModel(m_nModelIndex)) else if (CModelInfo::IsBikeModel(m_nModelIndex))
{ {
CBike* pBike = new CBike(m_nModelIndex, RANDOM_VEHICLE); CBike* pBike = new CBike(m_nModelIndex, owner);
pBike->bIsStanding = true; pBike->bIsStanding = true;
pVehicle = pBike; pVehicle = pBike;
} }
else else
pVehicle = new CAutomobile(m_nModelIndex, RANDOM_VEHICLE); pVehicle = new CAutomobile(m_nModelIndex, owner);
pVehicle->SetPosition(m_vecPos); pVehicle->SetPosition(m_fPosX, m_fPosY, m_fPosZ);
pVehicle->SetStatus(STATUS_ABANDONED); pVehicle->SetStatus(STATUS_ABANDONED);
pVehicle->GetForward() = m_vecAngle; pVehicle->GetForward() = CVector(m_fForwardX, m_fForwardY, m_fForwardZ);
pVehicle->GetRight() = CVector(m_vecAngle.y, -m_vecAngle.x, 0.0f); pVehicle->GetRight() = CVector(m_fForwardY, -m_fForwardX, 0.0f);
pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f); pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);
pVehicle->pDriver = nil; pVehicle->pDriver = nil;
pVehicle->m_currentColour1 = m_nPrimaryColor; pVehicle->m_currentColour1 = m_nPrimaryColor;
@ -2177,11 +2219,36 @@ CVehicle* CStoredCar::RestoreCar()
} }
pVehicle->bHasBeenOwnedByPlayer = true; pVehicle->bHasBeenOwnedByPlayer = true;
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
pVehicle->bBulletProof = m_bBulletproof; if (m_nFlags & FLAG_REWARD_VEHICLE) pVehicle->bRewardVehicle = true;
pVehicle->bFireProof = m_bFireproof; if (m_nFlags & FLAG_BULLETPROOF) pVehicle->bBulletProof = true;
pVehicle->bExplosionProof = m_bExplosionproof; if (m_nFlags & FLAG_FIREPROOF) pVehicle->bFireProof = true;
pVehicle->bCollisionProof = m_bCollisionproof; if (m_nFlags & FLAG_EXPLOSIONPROOF) pVehicle->bExplosionProof = true;
pVehicle->bMeleeProof = m_bMeleeproof; if (m_nFlags & FLAG_COLLISIONPROOF) pVehicle->bCollisionProof = true;
if (m_nFlags & FLAG_MELEEPROOF) pVehicle->bMeleeProof = true;
if (m_nFlags & FLAG_TIRES_INVULNERABLE) pVehicle->bTyresDontBurst = true;
if (m_nFlags & FLAG_STRONG) pVehicle->bTakeLessDamage = true;
if (m_nFlags & FLAG_HEAVY) {
pVehicle->bIsHeavy = true;
pVehicle->m_fMass = pVehicle->pHandling->GetMass();
pVehicle->m_fTurnMass = pVehicle->pHandling->GetTurnMass();
}
else {
pVehicle->bIsHeavy = false;
pVehicle->m_fMass = pVehicle->pHandling->GetMass() * 3.0f;
pVehicle->m_fTurnMass = pVehicle->pHandling->GetTurnMass() * 5.0f;
}
if (pVehicle->IsCar()) {
CAutomobile* pAutomobile = (CAutomobile*)pVehicle;
if (m_nFlags & FLAG_PERMANENT_COLOUR) pAutomobile->bFixedColour = true;
if (m_nFlags & FLAG_BOMB) pAutomobile->m_bombType = CARBOMB_TIMED;
if (m_nFlags & FLAG_NOT_DAMAGED_UPSIDEDOWN) pAutomobile->bNotDamagedUpsideDown = true;
m_fTractionMultiplier = pAutomobile->m_fTraction;
}
else if (pVehicle->IsBike()) {
CBike* pBike = (CBike*)pVehicle;
if (m_nFlags & FLAG_PERMANENT_COLOUR) pBike->bFixedColour = true;
m_fTractionMultiplier = pBike->m_fTraction;
}
return pVehicle; return pVehicle;
} }
@ -2196,13 +2263,23 @@ void CGarage::StoreAndRemoveCarsForThisHideout(CStoredCar* aCars, int32 nMax)
if (!pVehicle) if (!pVehicle)
continue; continue;
if (IsPointInsideGarage(pVehicle->GetPosition())) { if (IsPointInsideGarage(pVehicle->GetPosition())) {
if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE) { #if defined GTA_PS2 || defined GTA_MOBILE
if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f)) if (pVehicle->GetStatus() == STATUS_WRECKED) {
aCars[index++].StoreCar(pVehicle);
CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle); CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle);
CWorld::Remove(pVehicle); CWorld::Remove(pVehicle);
delete pVehicle; delete pVehicle;
} }
else if (pVehicle->m_bombType == CARBOMB_NONE || pVehicle->bRewardVehicle) // <- probably condition looked different
#endif
{
if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE || pVehicle->bRewardVehicle) {
if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f))
aCars[index++].StoreCar(pVehicle);
CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle);
CWorld::Remove(pVehicle);
delete pVehicle;
}
}
} }
} }
// why? // why?
@ -2507,6 +2584,8 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
default: default:
aGarages[i].RefreshDoorPointers(true); aGarages[i].RefreshDoorPointers(true);
if (aGarages[i].m_pDoor1) { if (aGarages[i].m_pDoor1) {
aGarages[i].m_pDoor1->GetMatrix().GetPosition().x = aGarages[i].m_fDoor1X;
aGarages[i].m_pDoor1->GetMatrix().GetPosition().y = aGarages[i].m_fDoor1Y;
aGarages[i].m_pDoor1->GetMatrix().GetPosition().z = aGarages[i].m_fDoor1Z; aGarages[i].m_pDoor1->GetMatrix().GetPosition().z = aGarages[i].m_fDoor1Z;
if (aGarages[i].m_pDoor1->IsObject()) if (aGarages[i].m_pDoor1->IsObject())
((CObject*)aGarages[i].m_pDoor1)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor1Z; ((CObject*)aGarages[i].m_pDoor1)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor1Z;
@ -2516,6 +2595,8 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
aGarages[i].m_pDoor1->UpdateRwFrame(); aGarages[i].m_pDoor1->UpdateRwFrame();
} }
if (aGarages[i].m_pDoor2) { if (aGarages[i].m_pDoor2) {
aGarages[i].m_pDoor2->GetMatrix().GetPosition().x = aGarages[i].m_fDoor2X;
aGarages[i].m_pDoor2->GetMatrix().GetPosition().y = aGarages[i].m_fDoor2Y;
aGarages[i].m_pDoor2->GetMatrix().GetPosition().z = aGarages[i].m_fDoor2Z; aGarages[i].m_pDoor2->GetMatrix().GetPosition().z = aGarages[i].m_fDoor2Z;
if (aGarages[i].m_pDoor2->IsObject()) if (aGarages[i].m_pDoor2->IsObject())
((CObject*)aGarages[i].m_pDoor2)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor2Z; ((CObject*)aGarages[i].m_pDoor2)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor2Z;
@ -2531,7 +2612,7 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
void CGarages::Save(uint8 * buf, uint32 * size) void CGarages::Save(uint8 * buf, uint32 * size)
{ {
//INITSAVEBUF //INITSAVEBUF
*size = 7876; // for some reason it's not actual size again *size = 10692; // for some reason it's not actual size again
//*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)); //*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage));
CloseHideOutGaragesBeforeSave(); CloseHideOutGaragesBeforeSave();
WriteSaveBuf(buf, NumGarages); WriteSaveBuf(buf, NumGarages);
@ -2553,29 +2634,10 @@ void CGarages::Save(uint8 * buf, uint32 * size)
//VALIDATESAVEBUF(*size); //VALIDATESAVEBUF(*size);
} }
const CStoredCar &CStoredCar::operator=(const CStoredCar & other)
{
m_nModelIndex = other.m_nModelIndex;
m_vecPos = other.m_vecPos;
m_vecAngle = other.m_vecAngle;
m_bBulletproof = other.m_bBulletproof;
m_bFireproof = other.m_bFireproof;
m_bExplosionproof = other.m_bExplosionproof;
m_bCollisionproof = other.m_bCollisionproof;
m_bMeleeproof = other.m_bMeleeproof;
m_nPrimaryColor = other.m_nPrimaryColor;
m_nSecondaryColor = other.m_nSecondaryColor;
m_nRadioStation = other.m_nRadioStation;
m_nVariationA = other.m_nVariationA;
m_nVariationB = other.m_nVariationB;
m_nCarBombType = other.m_nCarBombType;
return *this;
}
void CGarages::Load(uint8* buf, uint32 size) void CGarages::Load(uint8* buf, uint32 size)
{ {
//INITSAVEBUF //INITSAVEBUF
assert(size = 7876); assert(size == 10692);
//assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage))); //assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)));
CloseHideOutGaragesBeforeSave(); CloseHideOutGaragesBeforeSave();
NumGarages = ReadSaveBuf<uint32>(buf); NumGarages = ReadSaveBuf<uint32>(buf);

View file

@ -6,8 +6,6 @@
class CVehicle; class CVehicle;
#define GTA_NETWORK
enum eGarageState enum eGarageState
{ {
GS_FULLYCLOSED, GS_FULLYCLOSED,
@ -61,19 +59,34 @@ enum
{ {
TOTAL_COLLECTCARS_GARAGES = 4, TOTAL_COLLECTCARS_GARAGES = 4,
TOTAL_HIDEOUT_GARAGES = 12, TOTAL_HIDEOUT_GARAGES = 12,
TOTAL_COLLECTCARS_CARS = 6 TOTAL_COLLECTCARS_CARS = 16
}; };
class CStoredCar class CStoredCar
{ {
enum {
FLAG_BULLETPROOF = 0x1,
FLAG_FIREPROOF = 0x2,
FLAG_EXPLOSIONPROOF = 0x4,
FLAG_COLLISIONPROOF = 0x8,
FLAG_MELEEPROOF = 0x10,
FLAG_TIRES_INVULNERABLE = 0x20,
FLAG_STRONG = 0x40,
FLAG_HEAVY = 0x80,
FLAG_PERMANENT_COLOUR = 0x100,
FLAG_BOMB = 0x200,
FLAG_NOT_DAMAGED_UPSIDEDOWN = 0x400,
FLAG_REWARD_VEHICLE = 0x8000
};
int32 m_nModelIndex; int32 m_nModelIndex;
CVector m_vecPos; float m_fPosX;
CVector m_vecAngle; float m_fPosY;
int32 m_bBulletproof : 1; float m_fPosZ;
int32 m_bFireproof : 1; float m_fForwardX;
int32 m_bExplosionproof : 1; float m_fForwardY;
int32 m_bCollisionproof : 1; float m_fForwardZ;
int32 m_bMeleeproof : 1; float m_fTractionMultiplier;
int32 m_nFlags;
int8 m_nPrimaryColor; int8 m_nPrimaryColor;
int8 m_nSecondaryColor; int8 m_nSecondaryColor;
int8 m_nRadioStation; int8 m_nRadioStation;
@ -84,7 +97,6 @@ public:
void Init() { m_nModelIndex = 0; } void Init() { m_nModelIndex = 0; }
void Clear() { m_nModelIndex = 0; } void Clear() { m_nModelIndex = 0; }
bool HasCar() { return m_nModelIndex != 0; } bool HasCar() { return m_nModelIndex != 0; }
const CStoredCar &operator=(const CStoredCar& other);
void StoreCar(CVehicle*); void StoreCar(CVehicle*);
CVehicle* RestoreCar(); CVehicle* RestoreCar();
}; };

View file

@ -1808,7 +1808,7 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_SET_MISSION_CAR_CAN_BE_STORED_IN_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_CAR_IS_REWARD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
}; };
#undef REGISTER_COMMAND #undef REGISTER_COMMAND

View file

@ -392,12 +392,12 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command)
CHud::SetHelpMessage(text, false, true); // + false CHud::SetHelpMessage(text, false, true); // + false
return 0; return 0;
} }
case COMMAND_SET_MISSION_CAR_CAN_BE_STORED_IN_GARAGE: case COMMAND_SET_CAR_IS_REWARD:
{ {
CollectParameters(&m_nIp, 2); CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pVehicle); script_assert(pVehicle);
pVehicle->bAllowGarageToStore = (GET_INTEGER_PARAM(1) != 0); pVehicle->bRewardVehicle = (GET_INTEGER_PARAM(1) != 0);
return 0; return 0;
} }
case COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS: case COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS:

View file

@ -1656,7 +1656,7 @@ enum {
COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, COMMAND_PRINT_HELP_FOREVER_NO_BRIEF,
COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF,
COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF,
COMMAND_SET_MISSION_CAR_CAN_BE_STORED_IN_GARAGE, COMMAND_SET_CAR_IS_REWARD,
COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS,
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
LAST_SCRIPT_COMMAND LAST_SCRIPT_COMMAND

View file

@ -647,7 +647,7 @@ extern CModelIndices *gpModelIndices;
X("ind_slidedoor", MI_GARAGEDOOR6) \ X("ind_slidedoor", MI_GARAGEDOOR6) \
X("bankjobdoor", MI_GARAGEDOOR7) \ X("bankjobdoor", MI_GARAGEDOOR7) \
X("door_jmsgrage", MI_GARAGEDOOR9) \ X("door_jmsgrage", MI_GARAGEDOOR9) \
X("jamesgrge_kb", MI_GARAGEDOOR10) \ X("ind_safeh_gdoor", MI_GARAGEDOOR10) \
X("door_sfehousegrge", MI_GARAGEDOOR11) \ X("door_sfehousegrge", MI_GARAGEDOOR11) \
X("shedgaragedoor", MI_GARAGEDOOR12) \ X("shedgaragedoor", MI_GARAGEDOOR12) \
X("door4_garage", MI_GARAGEDOOR13) \ X("door4_garage", MI_GARAGEDOOR13) \

View file

@ -240,12 +240,11 @@ public:
uint8 bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed uint8 bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed
uint8 bParking : 1; uint8 bParking : 1;
uint8 bCanPark : 1; uint8 bCanPark : 1;
#if (!defined GTA_PS2 || defined FIX_BUGS) #if (!defined GTA_PS2 || defined FIX_BUGS) // <- I think this can be moved back to CAutomobile?
uint8 m_bombType : 3; uint8 m_bombType : 3;
#endif #endif
uint8 bDriverLastFrame : 1; uint8 bDriverLastFrame : 1;
uint8 bRewardVehicle : 1; // 25B_40
uint8 bAllowGarageToStore : 1; // <- many LCS flags before
int8 m_numPedsUseItAsCover; int8 m_numPedsUseItAsCover;
uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default) uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default)