summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/control/Pickups.cpp54
-rw-r--r--src/control/Pickups.h5
2 files changed, 35 insertions, 24 deletions
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 78084624..6fea43fb 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -54,20 +54,15 @@ uint8 aWeaponGreens[] = { 0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255, 0, 25
uint8 aWeaponBlues[] = { 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, 0, 128, 255, 0, 0 };
float aWeaponScale[] = { 1.0f, 2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f, 1.0f, 1.0f, 1.0f };
-void
-CPickup::RemoveKeepType()
+
+inline void
+CPickup::Remove()
{
CWorld::Remove(m_pObject);
delete m_pObject;
m_bRemoved = true;
m_pObject = nil;
-}
-
-void
-CPickup::Remove()
-{
- RemoveKeepType();
m_eType = PICKUP_NONE;
}
@@ -131,7 +126,6 @@ CPickup::GiveUsAPickUpObject(int32 handle)
bool
CPickup::CanBePickedUp(CPlayerPed *player)
{
- assert(m_pObject != nil);
bool cannotBePickedUp =
(m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f)
@@ -144,6 +138,7 @@ bool
CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
{
float waterLevel;
+ bool result = false;
if (m_bRemoved) {
if (CTimer::GetTimeInMilliseconds() > m_nTimer) {
@@ -204,9 +199,12 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
player->m_nSelectedWepSlot = player->GetWeaponSlot(CPickups::WeaponForModel(m_pObject->GetModelIndex()));
DMAudio.PlayFrontEndSound(SOUND_PICKUP_WEAPON_BOUGHT, m_pObject->GetModelIndex() - MI_GRENADE);
}
- RemoveKeepType();
+ result = true;
+ CWorld::Remove(m_pObject);
+ delete m_pObject;
+ m_pObject = nil;
m_nTimer = CTimer::GetTimeInMilliseconds() + 5000;
- return true;
+ m_bRemoved = true;
}
break;
case PICKUP_ON_STREET:
@@ -235,8 +233,12 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
m_nTimer = CTimer::GetTimeInMilliseconds() + 720000;
}
- RemoveKeepType();
- return true;
+ result = true;
+ CWorld::Remove(m_pObject);
+ delete m_pObject;
+ m_pObject = nil;
+ m_bRemoved = true;
+ break;
case PICKUP_ONCE:
case PICKUP_ONCE_TIMEOUT:
if (!CPickups::GivePlayerGoodiesWithPickUpMI(m_pObject->GetModelIndex(), playerId)) {
@@ -247,8 +249,9 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
DMAudio.PlayFrontEndSound(SOUND_PICKUP_WEAPON, m_pObject->GetModelIndex() - MI_GRENADE);
}
+ result = true;
Remove();
- return true;
+ break;
case PICKUP_COLLECTABLE1:
CWorld::Players[playerId].m_nCollectedPackages++;
CWorld::Players[playerId].m_nMoney += 1000;
@@ -260,18 +263,20 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
} else
CGarages::TriggerMessage("CO_ONE", CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages, 5000, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
+ result = true;
Remove();
DMAudio.PlayFrontEndSound(SOUND_PICKUP_HIDDEN_PACKAGE, 0);
- return true;
+ break;
case PICKUP_MONEY:
CWorld::Players[playerId].m_nMoney += m_nQuantity;
sprintf(gString, "$%d", m_nQuantity);
#ifdef MONEY_MESSAGES
CMoneyMessages::RegisterOne(m_vecPos + CVector(0.0f, 0.0f, 1.0f), gString, 0, 255, 0, 0.5f, 0.5f);
#endif
+ result = true;
Remove();
DMAudio.PlayFrontEndSound(SOUND_PICKUP_MONEY, 0);
- return true;
+ break;
default:
break;
}
@@ -298,7 +303,9 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) {
touched = true;
- break; // added break here
+#ifdef FIX_BUGS
+ break;
+#endif
}
}
@@ -320,12 +327,17 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
bool explode = false;
if (CTimer::GetTimeInMilliseconds() > m_nTimer)
explode = true;
- else {// added else here since vehicle lookup is useless
+#ifdef FIX_BUGS
+ else// added else here since vehicle lookup is useless
+#endif
+ {
for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) {
CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) {
explode = true;
- break; // added break here
+#ifdef FIX_BUGS
+ break;
+#endif
}
}
}
@@ -352,8 +364,8 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
m_pObject->UpdateRwFrame();
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 2.0f)) {
Remove();
+ result = true;
DMAudio.PlayFrontEndSound(SOUND_PICKUP_FLOAT_PACKAGE, 0);
- return true;
}
break;
default: break;
@@ -361,7 +373,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
if (!m_bRemoved && (m_eType == PICKUP_ONCE_TIMEOUT || m_eType == PICKUP_MONEY) && CTimer::GetTimeInMilliseconds() > m_nTimer)
Remove();
- return false;
+ return result;
}
void
diff --git a/src/control/Pickups.h b/src/control/Pickups.h
index b05f5db7..95eb6fbf 100644
--- a/src/control/Pickups.h
+++ b/src/control/Pickups.h
@@ -41,10 +41,9 @@ public:
CObject *GiveUsAPickUpObject(int32 handle);
bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId);
private:
- bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; }
+ inline bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; }
inline bool CanBePickedUp(CPlayerPed *player);
- void RemoveKeepType();
- void Remove();
+ inline void Remove();
};
VALIDATE_SIZE(CPickup, 0x1C);