diff options
-rw-r--r-- | src/core/Pools.cpp | 56 | ||||
-rw-r--r-- | src/objects/Object.h | 3 | ||||
-rw-r--r-- | src/peds/Ped.cpp | 23 | ||||
-rw-r--r-- | src/peds/PlayerPed.cpp | 4 | ||||
-rw-r--r-- | src/save/GenericGameStorage.cpp | 14 | ||||
-rw-r--r-- | src/vehicles/Automobile.cpp | 6 | ||||
-rw-r--r-- | src/vehicles/Bike.cpp | 24 | ||||
-rw-r--r-- | src/vehicles/Bike.h | 6 | ||||
-rw-r--r-- | src/vehicles/Boat.cpp | 6 | ||||
-rw-r--r-- | src/vehicles/Cranes.h | 1 | ||||
-rw-r--r-- | src/vehicles/Vehicle.cpp | 20 |
11 files changed, 109 insertions, 54 deletions
diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index fe2cf7ad..e0c45982 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -2,6 +2,7 @@ #include "Pools.h" +#include "Bike.h" #include "Boat.h" #include "CarCtrl.h" #ifdef MISSION_REPLAY @@ -13,6 +14,8 @@ #include "Wanted.h" #include "World.h" +//--MIAMI: file done + CCPtrNodePool *CPools::ms_pPtrNodePool; CEntryInfoNodePool *CPools::ms_pEntryInfoNodePool; CPedPool *CPools::ms_pPedPool; @@ -24,7 +27,6 @@ CDummyPool *CPools::ms_pDummyPool; CAudioScriptObjectPool *CPools::ms_pAudioScriptObjectPool; CColModelPool *CPools::ms_pColModelPool; -//--MIAMI: done void CPools::Initialise(void) { @@ -40,7 +42,6 @@ CPools::Initialise(void) ms_pColModelPool = new CColModelPool(NUMCOLMODELS, "ColModel"); } -//--MIAMI: done void CPools::ShutDown(void) { @@ -119,7 +120,8 @@ void CPools::LoadVehiclePool(uint8* buf, uint32 size) INITSAVEBUF int nNumCars = ReadSaveBuf<int>(buf); int nNumBoats = ReadSaveBuf<int>(buf); - for (int i = 0; i < nNumCars + nNumBoats; i++) { + int nNumBikes = ReadSaveBuf<int>(buf); + for (int i = 0; i < nNumCars + nNumBoats + nNumBikes; i++) { uint32 type = ReadSaveBuf<uint32>(buf); int16 model = ReadSaveBuf<int16>(buf); CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY); @@ -131,13 +133,15 @@ INITSAVEBUF pVehicle = new(slot) CBoat(model, RANDOM_VEHICLE); else if (type == VEHICLE_TYPE_CAR) pVehicle = new(slot) CAutomobile(model, RANDOM_VEHICLE); + else if (type == VEHICLE_TYPE_BIKE) + pVehicle = new(slot) CBike(model, RANDOM_VEHICLE); else assert(0); --CCarCtrl::NumRandomCars; pVehicle->Load(buf); CWorld::Add(pVehicle); #else - char* vbuf = new char[Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize)]; + char* vbuf = new char[Max(CBike::nSaveStructSize, Max(CAutomobile::nSaveStructSize, CBoat::nSaveStructSize))]; if (type == VEHICLE_TYPE_BOAT) { memcpy(vbuf, buf, sizeof(CBoat)); SkipSaveBuf(buf, sizeof(CBoat)); @@ -156,6 +160,17 @@ INITSAVEBUF pAutomobile->Damage = ((CAutomobile*)vbuf)->Damage; pAutomobile->SetupDamageAfterLoad(); } + else if (type == VEHICLE_TYPE_BIKE) { +#ifdef FIX_BUGS + memcpy(vbuf, buf, sizeof(CBike)); +#else + memcpy(vbuf, buf, sizeof(CAutomobile)); +#endif + SkipSaveBuf(buf, sizeof(CBike)); + CBike* pBike = new(slot) CBike(model, RANDOM_VEHICLE); + pVehicle = pBike; + --CCarCtrl::NumRandomCars; + } else assert(0); CVehicle* pBufferVehicle = (CVehicle*)vbuf; @@ -193,6 +208,7 @@ INITSAVEBUF (pVehicle->GetAddressOfEntityProperties())[0] = (pBufferVehicle->GetAddressOfEntityProperties())[0]; (pVehicle->GetAddressOfEntityProperties())[1] = (pBufferVehicle->GetAddressOfEntityProperties())[1]; pVehicle->AutoPilot = pBufferVehicle->AutoPilot; + CCarCtrl::UpdateCarCount(pVehicle, false); CWorld::Add(pVehicle); delete[] vbuf; #endif @@ -205,6 +221,7 @@ void CPools::SaveVehiclePool(uint8* buf, uint32* size) INITSAVEBUF int nNumCars = 0; int nNumBoats = 0; + int nNumBikes = 0; int nPoolSize = GetVehiclePool()->GetSize(); for (int i = 0; i < nPoolSize; i++) { CVehicle* pVehicle = GetVehiclePool()->GetSlot(i); @@ -226,19 +243,25 @@ INITSAVEBUF ++nNumCars; if (pVehicle->IsBoat() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) ++nNumBoats; + if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) + ++nNumBoats; #else if (!pVehicle->pDriver && !bHasPassenger) { if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) ++nNumCars; if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) ++nNumBoats; + if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) + ++nNumBoats; #endif } } *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CAutomobile::nSaveStructSize) + sizeof(int) + - nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int); + nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBoat::nSaveStructSize) + sizeof(int) + + nNumBikes * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CBike::nSaveStructSize) + sizeof(int); WriteSaveBuf(buf, nNumCars); WriteSaveBuf(buf, nNumBoats); + WriteSaveBuf(buf, nNumBikes); for (int i = 0; i < nPoolSize; i++) { CVehicle* pVehicle = GetVehiclePool()->GetSlot(i); if (!pVehicle) @@ -258,9 +281,9 @@ INITSAVEBUF #endif #ifdef COMPATIBLE_SAVES #ifdef MISSION_REPLAY - if ((pVehicle->IsCar() || pVehicle->IsBoat()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { + if ((pVehicle->IsCar() || pVehicle->IsBoat() || pVehicle->IsBike()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { #else - if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { + if ((pVehicle->IsCar() || pVehicle->IsBoat() || pVehicle->IsBike()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { #endif WriteSaveBuf<uint32>(buf, pVehicle->m_vehType); WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex()); @@ -290,6 +313,17 @@ INITSAVEBUF memcpy(buf, pVehicle, sizeof(CBoat)); SkipSaveBuf(buf, sizeof(CBoat)); } +#ifdef MISSION_REPLAY + if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { +#else + if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { +#endif + WriteSaveBuf(buf, (uint32)pVehicle->m_vehType); + WriteSaveBuf(buf, pVehicle->GetModelIndex()); + WriteSaveBuf(buf, GetVehicleRef(pVehicle)); + memcpy(buf, pVehicle, sizeof(CBike)); + SkipSaveBuf(buf, sizeof(CBike)); + } #endif } } @@ -336,6 +370,7 @@ INITSAVEBUF tmp.CompressFromFullMatrix(pObject->m_objectMatrix); CopyToBuf(buf, tmp); CopyToBuf(buf, pObject->ObjectCreatedBy); + SkipSaveBuf(buf, 1); CopyToBuf(buf, bIsPickup); CopyToBuf(buf, bPickupObjWithMessage); CopyToBuf(buf, bOutOfStock); @@ -343,6 +378,8 @@ INITSAVEBUF CopyToBuf(buf, bGlassBroken); CopyToBuf(buf, bHasBeenDamaged); CopyToBuf(buf, bUseVehicleColours); + CopyToBuf(buf, pObject->m_unk); + CopyToBuf(buf, pObject->m_nBonusValue); CopyToBuf(buf, pObject->m_fCollisionDamageMultiplier); CopyToBuf(buf, pObject->m_nCollisionDamageEffect); CopyToBuf(buf, pObject->m_nSpecialCollisionResponseCases); @@ -392,6 +429,9 @@ INITSAVEBUF pBufferObject->bHasBeenDamaged = bitFlag; CopyFromBuf(buf, bitFlag); pBufferObject->bUseVehicleColours = bitFlag; + CopyFromBuf(buf, pBufferObject->m_unk); + CopyFromBuf(buf, pBufferObject->m_nBonusValue); + SkipSaveBuf(buf, 1); CopyFromBuf(buf, pBufferObject->m_fCollisionDamageMultiplier); CopyFromBuf(buf, pBufferObject->m_nCollisionDamageEffect); CopyFromBuf(buf, pBufferObject->m_nSpecialCollisionResponseCases); @@ -426,6 +466,8 @@ INITSAVEBUF (pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1]; #endif pObject->bHasCollided = false; + pObject->m_unk = pBufferObject->m_unk; + pObject->m_nBonusValue = pBufferObject->m_nBonusValue; CWorld::Add(pObject); delete[] obuf; } diff --git a/src/objects/Object.h b/src/objects/Object.h index b81e84b6..e255c20d 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -70,7 +70,8 @@ public: uint8 bUseVehicleColours : 1; uint8 bIsWeapon : 1; uint8 bIsStreetLight : 1; - int8 m_nBonusValue; + int8 m_nBonusValue; + uint16 m_unk; // TODO(MIAMI) float m_fCollisionDamageMultiplier; uint8 m_nCollisionDamageEffect; uint8 m_nSpecialCollisionResponseCases; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index c5b19241..72276e81 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -20037,15 +20037,13 @@ CPed::Save(uint8*& buf) CopyToBuf(buf, GetPosition().z); SkipSaveBuf(buf, 288); CopyToBuf(buf, CharCreatedBy); - SkipSaveBuf(buf, 351); + SkipSaveBuf(buf, 499); CopyToBuf(buf, m_fHealth); CopyToBuf(buf, m_fArmour); - SkipSaveBuf(buf, 148); - for (int i = 0; i < 13; i++) // has to be hardcoded + SkipSaveBuf(buf, 172); + for (int i = 0; i < 10; i++) // has to be hardcoded m_weapons[i].Save(buf); - SkipSaveBuf(buf, 5); - CopyToBuf(buf, m_maxWeaponTypeAllowed); - SkipSaveBuf(buf, 162); + SkipSaveBuf(buf, 252); } void @@ -20057,16 +20055,15 @@ CPed::Load(uint8*& buf) CopyFromBuf(buf, GetMatrix().GetPosition().z); SkipSaveBuf(buf, 288); CopyFromBuf(buf, CharCreatedBy); - SkipSaveBuf(buf, 351); + SkipSaveBuf(buf, 499); CopyFromBuf(buf, m_fHealth); CopyFromBuf(buf, m_fArmour); - SkipSaveBuf(buf, 148); + SkipSaveBuf(buf, 172); + m_currentWeapon = WEAPONTYPE_UNARMED; CWeapon bufWeapon; - for (int i = 0; i < 13; i++) { // has to be hardcoded + for (int i = 0; i < 10; i++) { // has to be hardcoded bufWeapon.Load(buf); - if (i >= 10) - continue; // tmp hack before we fix save/load if (bufWeapon.m_eWeaponType != WEAPONTYPE_UNARMED) { int modelId = CWeaponInfo::GetWeaponInfo(bufWeapon.m_eWeaponType)->m_nModelId; @@ -20081,9 +20078,7 @@ CPed::Load(uint8*& buf) GiveWeapon(bufWeapon.m_eWeaponType, bufWeapon.m_nAmmoTotal); } } - SkipSaveBuf(buf, 5); - CopyFromBuf(buf, m_maxWeaponTypeAllowed); - SkipSaveBuf(buf, 162); + SkipSaveBuf(buf, 252); } #undef CopyFromBuf #undef CopyToBuf diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 041fb5e8..f43ccead 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -23,7 +23,7 @@ const uint32 CPlayerPed::nSaveStructSize = #ifdef COMPATIBLE_SAVES - 1520; + 1752; #else sizeof(CPlayerPed); #endif @@ -1949,7 +1949,7 @@ CPlayerPed::Load(uint8*& buf) CopyFromBuf(buf, m_nTargettableObjects[1]); CopyFromBuf(buf, m_nTargettableObjects[2]); CopyFromBuf(buf, m_nTargettableObjects[3]); - SkipSaveBuf(buf, 116); + SkipSaveBuf(buf, 164); } #undef CopyFromBuf #undef CopyToBuf diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 18eecd95..7e89afff 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -42,7 +42,7 @@ #include "Fluff.h" #define BLOCK_COUNT 20 -#define SIZE_OF_SIMPLEVARS 0xFC +#define SIZE_OF_SIMPLEVARS 0xE4 const uint32 SIZE_OF_ONE_GAME_IN_BYTES = 201729; @@ -194,12 +194,6 @@ GenericSave(int file) WriteDataToBufferPointer(buf, CWeather::NewWeatherType); WriteDataToBufferPointer(buf, CWeather::ForcedWeatherType); WriteDataToBufferPointer(buf, CWeather::InterpolationValue); - WriteDataToBufferPointer(buf, CompileDateAndTime.m_nSecond); - WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMinute); - WriteDataToBufferPointer(buf, CompileDateAndTime.m_nHour); - WriteDataToBufferPointer(buf, CompileDateAndTime.m_nDay); - WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth); - WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear); WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList); #ifdef COMPATIBLE_SAVES // converted to float for compatibility with original format @@ -331,12 +325,6 @@ GenericLoad() ReadDataFromBufferPointer(buf, CWeather::NewWeatherType); ReadDataFromBufferPointer(buf, CWeather::ForcedWeatherType); ReadDataFromBufferPointer(buf, CWeather::InterpolationValue); - ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nSecond); - ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMinute); - ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nHour); - ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nDay); - ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nMonth); - ReadDataFromBufferPointer(buf, CompileDateAndTime.m_nYear); ReadDataFromBufferPointer(buf, CWeather::WeatherTypeInList); #ifdef COMPATIBLE_SAVES // converted to float for compatibility with original format diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 1316985d..69388a96 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -59,7 +59,7 @@ bool CAutomobile::m_sAllTaxiLights; const uint32 CAutomobile::nSaveStructSize = #ifdef COMPATIBLE_SAVES - 1448; + 1500; #else sizeof(CAutomobile); #endif @@ -5713,7 +5713,7 @@ CAutomobile::Save(uint8*& buf) { CVehicle::Save(buf); WriteSaveBuf<CDamageManager>(buf, Damage); - SkipSaveBuf(buf, 800 - sizeof(CDamageManager)); + SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager)); } void @@ -5721,7 +5721,7 @@ CAutomobile::Load(uint8*& buf) { CVehicle::Load(buf); Damage = ReadSaveBuf<CDamageManager>(buf); - SkipSaveBuf(buf, 800 - sizeof(CDamageManager)); + SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager)); SetupDamageAfterLoad(); } #endif diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index b5bc9480..4a4b0516 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -39,6 +39,14 @@ //--MIAMI: file done +const uint32 CBike::nSaveStructSize = +#ifdef COMPATIBLE_SAVES + 1260; +#else + sizeof(CBoat); +#endif + + // TODO: maybe put this somewhere else inline void GetRelativeMatrix(RwMatrix *mat, RwFrame *frm, RwFrame *end) @@ -2922,3 +2930,19 @@ CBike::ReduceHornCounter(void) if(m_nCarHornTimer != 0) m_nCarHornTimer--; } + +#ifdef COMPATIBLE_SAVES +void +CBike::Save(uint8*& buf) +{ + CVehicle::Save(buf); + SkipSaveBuf(buf, 1260 - 672); +} + +void +CBike::Load(uint8*& buf) +{ + CVehicle::Load(buf); + SkipSaveBuf(buf, 1260 - 672); +} +#endif diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index 885fe1b0..3fcf66a2 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -132,6 +132,12 @@ public: void Fix(void); void SetupModelNodes(void); void ReduceHornCounter(void); + +#ifdef COMPATIBLE_SAVES + virtual void Save(uint8*& buf); + virtual void Load(uint8*& buf); +#endif + static const uint32 nSaveStructSize; }; // These functions and function names are made up diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 8c9dd241..dfb3dade 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -43,7 +43,7 @@ CBoat *CBoat::apFrameWakeGeneratingBoats[4]; const uint32 CBoat::nSaveStructSize = #ifdef COMPATIBLE_SAVES - 1156; + 1216; #else sizeof(CBoat); #endif @@ -1449,13 +1449,13 @@ void CBoat::Save(uint8*& buf) { CVehicle::Save(buf); - SkipSaveBuf(buf, 1156 - 648); + SkipSaveBuf(buf, 1216 - 672); } void CBoat::Load(uint8*& buf) { CVehicle::Load(buf); - SkipSaveBuf(buf, 1156 - 648); + SkipSaveBuf(buf, 1216 - 672); } #endif diff --git a/src/vehicles/Cranes.h b/src/vehicles/Cranes.h index 6d877d82..45ea7a8d 100644 --- a/src/vehicles/Cranes.h +++ b/src/vehicles/Cranes.h @@ -26,7 +26,6 @@ public: }; CBuilding *m_pCraneEntity; CObject *m_pHook; - int32 m_nAudioEntity; float m_fPickupX1; float m_fPickupX2; float m_fPickupY1; diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 994f3c99..cba465b7 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -2367,15 +2367,15 @@ CVehicle::Save(uint8*& buf) WriteSaveBuf<float>(buf, GetPosition().z); SkipSaveBuf(buf, 16); SaveEntityFlags(buf); - SkipSaveBuf(buf, 212); + SkipSaveBuf(buf, 208); AutoPilot.Save(buf); WriteSaveBuf<int8>(buf, m_currentColour1); WriteSaveBuf<int8>(buf, m_currentColour2); SkipSaveBuf(buf, 2); WriteSaveBuf<int16>(buf, m_nAlarmState); - SkipSaveBuf(buf, 43); + SkipSaveBuf(buf, 42); WriteSaveBuf<uint8>(buf, m_nNumMaxPassengers); - SkipSaveBuf(buf, 2); + SkipSaveBuf(buf, 3); WriteSaveBuf<float>(buf, field_1D0[0]); WriteSaveBuf<float>(buf, field_1D0[1]); WriteSaveBuf<float>(buf, field_1D0[2]); @@ -2398,13 +2398,13 @@ CVehicle::Save(uint8*& buf) WriteSaveBuf<uint8>(buf, m_nCurrentGear); SkipSaveBuf(buf, 3); WriteSaveBuf<float>(buf, m_fChangeGearTime); - SkipSaveBuf(buf, 4); + SkipSaveBuf(buf, 12); WriteSaveBuf<uint32>(buf, m_nTimeOfDeath); SkipSaveBuf(buf, 2); WriteSaveBuf<int16>(buf, m_nBombTimer); SkipSaveBuf(buf, 12); WriteSaveBuf<int8>(buf, m_nDoorLock); - SkipSaveBuf(buf, 99); + SkipSaveBuf(buf, 111); } void @@ -2430,15 +2430,15 @@ CVehicle::Load(uint8*& buf) m_matrix = tmp; SkipSaveBuf(buf, 16); LoadEntityFlags(buf); - SkipSaveBuf(buf, 212); + SkipSaveBuf(buf, 208); AutoPilot.Load(buf); m_currentColour1 = ReadSaveBuf<int8>(buf); m_currentColour2 = ReadSaveBuf<int8>(buf); SkipSaveBuf(buf, 2); m_nAlarmState = ReadSaveBuf<int16>(buf); - SkipSaveBuf(buf, 43); + SkipSaveBuf(buf, 42); m_nNumMaxPassengers = ReadSaveBuf<int8>(buf); - SkipSaveBuf(buf, 2); + SkipSaveBuf(buf, 3); field_1D0[0] = ReadSaveBuf<float>(buf); field_1D0[1] = ReadSaveBuf<float>(buf); field_1D0[2] = ReadSaveBuf<float>(buf); @@ -2460,13 +2460,13 @@ CVehicle::Load(uint8*& buf) m_nCurrentGear = ReadSaveBuf<uint8>(buf); SkipSaveBuf(buf, 3); m_fChangeGearTime = ReadSaveBuf<float>(buf); - SkipSaveBuf(buf, 4); + SkipSaveBuf(buf, 12); m_nTimeOfDeath = ReadSaveBuf<uint32>(buf); SkipSaveBuf(buf, 2); m_nBombTimer = ReadSaveBuf<int16>(buf); SkipSaveBuf(buf, 12); m_nDoorLock = (eCarLock)ReadSaveBuf<int8>(buf); - SkipSaveBuf(buf, 99); + SkipSaveBuf(buf, 111); } #endif |