summaryrefslogtreecommitdiffstats
path: root/src/objects/Stinger.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-03-06 17:28:59 +0100
committerSergeanur <s.anureev@yandex.ua>2021-06-24 20:34:28 +0200
commit618d689dff9a22d9385abf36f5e364b38273b7cf (patch)
tree9378d463e73933c90dcf90be93da7c9bac3dbeb1 /src/objects/Stinger.cpp
parentFix quiet police scanner on OpenAL (diff)
downloadre3-618d689dff9a22d9385abf36f5e364b38273b7cf.tar
re3-618d689dff9a22d9385abf36f5e364b38273b7cf.tar.gz
re3-618d689dff9a22d9385abf36f5e364b38273b7cf.tar.bz2
re3-618d689dff9a22d9385abf36f5e364b38273b7cf.tar.lz
re3-618d689dff9a22d9385abf36f5e364b38273b7cf.tar.xz
re3-618d689dff9a22d9385abf36f5e364b38273b7cf.tar.zst
re3-618d689dff9a22d9385abf36f5e364b38273b7cf.zip
Diffstat (limited to 'src/objects/Stinger.cpp')
-rw-r--r--src/objects/Stinger.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/objects/Stinger.cpp b/src/objects/Stinger.cpp
index 41040d4a..29efea10 100644
--- a/src/objects/Stinger.cpp
+++ b/src/objects/Stinger.cpp
@@ -46,7 +46,14 @@ CStinger::Init(CPed *pPed)
pOwner = pPed;
for (i = 0; i < NUM_STINGER_SEGMENTS; i++) {
- pSpikes[i] = new CStingerSegment;
+ pSpikes[i] = new CStingerSegment();
+#ifdef FIX_BUGS
+ if (!pSpikes[i]) {
+ // Abort!! Pool is full
+ Remove();
+ return;
+ }
+#endif
pSpikes[i]->bUsesCollision = false;
}
bIsDeployed = true;
@@ -77,8 +84,11 @@ CStinger::Remove()
CStingerSegment *spikeSegment = pSpikes[i];
#ifdef FIX_BUGS
- CWorld::Remove(spikeSegment);
- delete spikeSegment;
+ if (spikeSegment) {
+ CWorld::Remove(spikeSegment);
+ delete spikeSegment;
+ pSpikes[i] = nil;
+ }
#else
if (spikeSegment->m_entryInfoList.first != nil)
spikeSegment->bRemoveFromWorld = true;
@@ -92,9 +102,15 @@ CStinger::Remove()
void
CStinger::Deploy(CPed *pPed)
{
+ // So total number of stingers allowed at the same time is 2, each by different CCopPed.
if (NumOfStingerSegments < NUM_STINGER_SEGMENTS*2 && !pPed->bInVehicle && pPed->IsPedInControl()) {
if (!bIsDeployed && RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_STD_THROW_UNDER) == nil) {
Init(pPed);
+#ifdef FIX_BUGS
+ // Above call won't set it to true no more when object pool is full
+ if (!bIsDeployed)
+ return;
+#endif
pPed->SetPedState(PED_DEPLOY_STINGER);
CAnimManager::AddAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_THROW_UNDER);
}
@@ -167,6 +183,7 @@ CStinger::CheckForBurstTyres()
}
}
+// Only called when bIsDeployed
void
CStinger::Process()
{
@@ -232,10 +249,11 @@ CStinger::Process()
break;
case STINGERSTATE_REMOVE:
Remove();
- break;
- }
#ifdef FIX_BUGS
- if (bIsDeployed)
+ return;
+#else
+ break;
#endif
+ }
CheckForBurstTyres();
} \ No newline at end of file