diff options
Diffstat (limited to '')
-rw-r--r-- | src/control/Script.cpp | 181 |
1 files changed, 147 insertions, 34 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 23527e55..a453c077 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1659,11 +1659,13 @@ const uint32 CRunningScript::nSaveStructSize = sizeof(CRunningScript); #endif +// done(LCS) CMissionCleanup::CMissionCleanup() { Init(); } +// done(LCS) void CMissionCleanup::Init() { m_nCount = 0; @@ -1673,6 +1675,7 @@ void CMissionCleanup::Init() } } +// done(LCS) cleanup_entity_struct* CMissionCleanup::FindFree() { for (int i = 0; i < MAX_CLEANUP; i++){ @@ -1683,6 +1686,61 @@ cleanup_entity_struct* CMissionCleanup::FindFree() return nil; } +// done(LCS) +void SleepThisPed(cleanup_entity_struct* pCleanup, CPed* pPed) +{ + printf("*** SLEEPING PED %i %i\n", pCleanup->id, pPed->GetModelIndex()); + if (!pPed->GetIsStatic()) + pPed->RemoveFromMovingList(); + pPed->bIsStaticWaitingForCollision = true; +} + +// done(LCS) +void WakeThisPed(cleanup_entity_struct* pCleanup, CPed* pPed) +{ + printf("*** WAKING UP PED %i %i\n", pCleanup->id, pPed->GetModelIndex()); + pPed->bIsStaticWaitingForCollision = false; + if (!pPed->bIsStatic) + pPed->AddToMovingList(); + +} + +// done(LCS) +void SleepThisVehicle(cleanup_entity_struct* pCleanup, CVehicle* pVehicle) +{ + printf("*** SLEEPING VEHICLE %i %i\n", pCleanup->id, pVehicle->GetModelIndex()); + if (!pVehicle->GetIsStatic()) + pVehicle->RemoveFromMovingList(); + pVehicle->bIsStaticWaitingForCollision = true; +} + +// done(LCS) +void WakeThisVehicle(cleanup_entity_struct* pCleanup, CVehicle* pVehicle) +{ + printf("*** WAKING UP VEHICLE %i %i\n", pCleanup->id, pVehicle->GetModelIndex()); + pVehicle->bIsStaticWaitingForCollision = false; + if (!pVehicle->bIsStatic) + pVehicle->AddToMovingList(); +} + +// done(LCS) +void SleepThisObject(cleanup_entity_struct* pCleanup, CObject* pObject) +{ + if (!pObject->GetIsStatic()) + pObject->RemoveFromMovingList(); + pObject->bIsStaticWaitingForCollision = true; +} + +// done(LCS) +void WakeThisObject(cleanup_entity_struct* pCleanup, CObject* pObject) +{ + pObject->bIsStaticWaitingForCollision = false; + if (!pObject->bIsStatic) + pObject->AddToMovingList(); + +} + +// done(LCS) void CMissionCleanup::AddEntityToList(int32 id, uint8 type) { cleanup_entity_struct* pNew = FindFree(); @@ -1744,6 +1802,7 @@ void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type) } } +// done(LCS) void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects() { for (int i = 0; i < MAX_CLEANUP; i++) { @@ -1752,46 +1811,88 @@ void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects() { CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); if (pVehicle) { - if (pVehicle->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pVehicle->GetPosition())) { - pVehicle->bIsStaticWaitingForCollision = false; - if (!pVehicle->GetIsStatic()) - pVehicle->AddToMovingList(); + eLevelName level = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!CColStore::HasCollisionLoaded(level)) { + if (!pVehicle->bIsStaticWaitingForCollision) { + if (!pVehicle->IsHeli() && !pVehicle->IsPlane() && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI && + pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE) { + SleepThisVehicle(&m_sEntities[i], pVehicle); + } } } + else { + if (pVehicle->bIsStaticWaitingForCollision) + WakeThisVehicle(&m_sEntities[i], pVehicle); + } + } + } + break; + case CLEANUP_OBJECT: + CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); + if (pObject) { + eLevelName level = CTheZones::GetLevelFromPosition(&pObject->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!CColStore::HasCollisionLoaded(level)) { + if (!pObject->bIsStaticWaitingForCollision) { + SleepThisObject(&m_sEntities[i], pObject); + } + } + else { + if (pObject->bIsStaticWaitingForCollision) + WakeThisObject(&m_sEntities[i], pObject); + } } - break; } + } + for (int i = 0; i < MAX_CLEANUP; i++) { + switch (m_sEntities[i].type) { case CLEANUP_CHAR: { CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id); if (pPed) { - if (pPed->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pPed->GetPosition())) { - pPed->bIsStaticWaitingForCollision = false; - if (!pPed->GetIsStatic()) - pPed->AddToMovingList(); + eLevelName level = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!pPed->bIsStaticWaitingForCollision) { + if (pPed->bInVehicle) { + if (pPed->m_pMyVehicle->GetIsStatic()) { + SleepThisPed(&m_sEntities[i], pPed); + continue; + } + } + if (!CColStore::HasCollisionLoaded(level)) { + if (pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()) + SleepThisPed(&m_sEntities[i], pPed); } } - } - break; - } - case CLEANUP_OBJECT: - { - CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); - if (pObject) { - if (pObject->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pObject->GetPosition())) { - pObject->bIsStaticWaitingForCollision = false; - if (!pObject->GetIsStatic()) - pObject->AddToMovingList(); + else { + if (!pPed->bInVehicle) { + if (CColStore::HasCollisionLoaded(level)) { + if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())) + WakeThisPed(&m_sEntities[i], pPed); + } + } + else { + if (!pPed->m_pMyVehicle->GetIsStatic()) { + WakeThisPed(&m_sEntities[i], pPed); + continue; + } + if (CColStore::HasCollisionLoaded(level)) { + if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())) + WakeThisPed(&m_sEntities[i], pPed); + } } } + } - break; } - default: - break; + break; } } } @@ -1803,6 +1904,8 @@ void CMissionCleanup::Process() CCarCtrl::CarDensityMultiplier = 1.0f; CPed::nThreatReactionRangeMultiplier = 1; CPed::nEnterCarRangeMultiplier = 1; + for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++) + CTheScripts::AllowedCollision[i] = 0; FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f; CRoadBlocks::ClearScriptRoadBlocks(); CRouteNode::Initialise(); @@ -1810,20 +1913,19 @@ void CMissionCleanup::Process() TheCamera.Restore(); TheCamera.SetWideScreenOff(); CSpecialFX::bLiftCam = false; - CSpecialFX::bVideoCam = false; - CTimeCycle::StopExtraColour(0); + // TODO(LCS): CHud::m_ClockEventWarningMinutes = 0; + // TODO(LCS): CHud::m_ClockEventFlashTimer = 0; + CTimeCycle::StopExtraColour(0); // TODO: thiscall for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) DMAudio.ClearMissionAudio(i); CWeather::ReleaseWeather(); for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++) CStreaming::SetMissionDoesntRequireSpecialChar(i); - for (int i = 0; i < NUM_OF_CUTSCENE_OBJECTS; i++) - CStreaming::SetMissionDoesntRequireModel(MI_CUTOBJ01 + i); CStreaming::ms_disableStreaming = false; - CHud::m_ItemToFlash = -1; - CHud::SetHelpMessage(nil, false); + if (CHud::m_ItemToFlash != ITEM_ARMOUR && CHud::m_ItemToFlash != ITEM_HEALTH) + CHud::m_ItemToFlash = -1; + CHud::SetHelpMessage(nil, false); // nil, false, false, true TODO(LCS) CUserDisplay::OnscnTimer.m_bDisabled = false; - CTheScripts::RemoveScriptTextureDictionary(); CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByCops = false; CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByEveryone = false; CWorld::Players[0].MakePlayerSafe(false); @@ -1831,10 +1933,11 @@ void CMissionCleanup::Process() CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0; CPad::GetPad(0)->SetDrunkInputDelay(0); CWorld::Players[0].m_bDriveByAllowed = true; + CPad::GetPad(0)->unk_B4 = 1.0f; + CPad::GetPad(0)->unk_B8 = 0.5f; DMAudio.ShutUpPlayerTalking(0); CVehicle::bDisableRemoteDetonation = false; CVehicle::bDisableRemoteDetonationOnContact = false; - CGameLogic::ClearShortCut(); CTheScripts::RiotIntensity = 0; CTheScripts::StoreVehicleIndex = -1; CTheScripts::StoreVehicleWasRandom = true; @@ -1872,12 +1975,17 @@ void CMissionCleanup::Process() m_sEntities[i].type = CLEANUP_UNUSED; m_nCount--; } + for (int i = 1; i < NUMSTREAMINFO; i++) { + if (CStreaming::IsScriptOwnedModel(i)) + CStreaming::SetMissionDoesntRequireModel(i); + } } /* NB: CUpsideDownCarCheck is not used by actual script at all * It has a weird usage: AreAnyCarsUpsideDown would fail any mission * just like death or arrest. */ + // done(LCS) except TODO void CUpsideDownCarCheck::Init() { for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ @@ -1886,6 +1994,7 @@ void CUpsideDownCarCheck::Init() } } +// done(LCS) bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id) { CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(id); @@ -1917,6 +2026,7 @@ void CUpsideDownCarCheck::UpdateTimers() } } +// done(LCS) bool CUpsideDownCarCheck::AreAnyCarsUpsideDown() { for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ @@ -1926,6 +2036,7 @@ bool CUpsideDownCarCheck::AreAnyCarsUpsideDown() return false; } +// done(LCS) void CUpsideDownCarCheck::AddCarToCheck(int32 id) { uint16 index = 0; @@ -1939,6 +2050,7 @@ void CUpsideDownCarCheck::AddCarToCheck(int32 id) m_sCars[index].m_nUpsideDownTimer = 0; } +// done(LCS) void CUpsideDownCarCheck::RemoveCarFromCheck(int32 id) { for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ @@ -1949,6 +2061,7 @@ void CUpsideDownCarCheck::RemoveCarFromCheck(int32 id) } } +// done(LCS) bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id) { for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ |