Pool fixes + peds not forming circle fix

This commit is contained in:
erorcun 2021-03-06 19:28:59 +03:00 committed by Sergeanur
parent 0c41734c20
commit 618d689dff
22 changed files with 132 additions and 75 deletions

View File

@ -23,25 +23,25 @@ cAudioScriptObject::Reset()
} }
void * void *
cAudioScriptObject::operator new(size_t sz) cAudioScriptObject::operator new(size_t sz) throw()
{ {
return CPools::GetAudioScriptObjectPool()->New(); return CPools::GetAudioScriptObjectPool()->New();
} }
void * void *
cAudioScriptObject::operator new(size_t sz, int handle) cAudioScriptObject::operator new(size_t sz, int handle) throw()
{ {
return CPools::GetAudioScriptObjectPool()->New(handle); return CPools::GetAudioScriptObjectPool()->New(handle);
} }
void void
cAudioScriptObject::operator delete(void *p, size_t sz) cAudioScriptObject::operator delete(void *p, size_t sz) throw()
{ {
CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p);
} }
void void
cAudioScriptObject::operator delete(void *p, int handle) cAudioScriptObject::operator delete(void *p, int handle) throw()
{ {
CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p); CPools::GetAudioScriptObjectPool()->Delete((cAudioScriptObject *)p);
} }

View File

@ -12,10 +12,10 @@ public:
void Reset(); /// ok void Reset(); /// ok
static void* operator new(size_t); static void* operator new(size_t) throw();
static void* operator new(size_t, int); static void* operator new(size_t, int) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
static void operator delete(void*, int); static void operator delete(void*, int) throw();
static void LoadAllAudioScriptObjects(uint8 *buf, uint32 size); static void LoadAllAudioScriptObjects(uint8 *buf, uint32 size);
static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size); static void SaveAllAudioScriptObjects(uint8 *buf, uint32 *size);

View File

@ -4,8 +4,8 @@
#include "Streaming.h" #include "Streaming.h"
#include "Pools.h" #include "Pools.h"
void *CBuilding::operator new(size_t sz) { return CPools::GetBuildingPool()->New(); } void *CBuilding::operator new(size_t sz) throw() { return CPools::GetBuildingPool()->New(); }
void CBuilding::operator delete(void *p, size_t sz) { CPools::GetBuildingPool()->Delete((CBuilding*)p); } void CBuilding::operator delete(void *p, size_t sz) throw() { CPools::GetBuildingPool()->Delete((CBuilding*)p); }
void void
CBuilding::ReplaceWithNewModel(int32 id) CBuilding::ReplaceWithNewModel(int32 id)

View File

@ -9,8 +9,8 @@ public:
m_type = ENTITY_TYPE_BUILDING; m_type = ENTITY_TYPE_BUILDING;
bUsesCollision = true; bUsesCollision = true;
} }
static void *operator new(size_t); static void *operator new(size_t) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
void ReplaceWithNewModel(int32 id); void ReplaceWithNewModel(int32 id);

View File

@ -4,5 +4,5 @@
#include "Treadable.h" #include "Treadable.h"
#include "Pools.h" #include "Pools.h"
void *CTreadable::operator new(size_t sz) { return CPools::GetTreadablePool()->New(); } void *CTreadable::operator new(size_t sz) throw() { return CPools::GetTreadablePool()->New(); }
void CTreadable::operator delete(void *p, size_t sz) { CPools::GetTreadablePool()->Delete((CTreadable*)p); } void CTreadable::operator delete(void *p, size_t sz) throw() { CPools::GetTreadablePool()->Delete((CTreadable*)p); }

View File

@ -5,8 +5,8 @@
class CTreadable : public CBuilding class CTreadable : public CBuilding
{ {
public: public:
static void *operator new(size_t); static void *operator new(size_t) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
bool GetIsATreadable(void) { return true; } bool GetIsATreadable(void) { return true; }
}; };

View File

@ -27,7 +27,7 @@ CColModel::~CColModel(void)
} }
void* void*
CColModel::operator new(size_t) CColModel::operator new(size_t) throw()
{ {
CColModel* node = CPools::GetColModelPool()->New(); CColModel* node = CPools::GetColModelPool()->New();
assert(node); assert(node);
@ -35,7 +35,7 @@ CColModel::operator new(size_t)
} }
void void
CColModel::operator delete(void *p, size_t) CColModel::operator delete(void *p, size_t) throw()
{ {
CPools::GetColModelPool()->Delete((CColModel*)p); CPools::GetColModelPool()->Delete((CColModel*)p);
} }

View File

@ -33,7 +33,7 @@ struct CColModel
void SetLinkPtr(CLink<CColModel*>*); void SetLinkPtr(CLink<CColModel*>*);
void GetTrianglePoint(CVector &v, int i) const; void GetTrianglePoint(CVector &v, int i) const;
void *operator new(size_t); void *operator new(size_t) throw();
void operator delete(void *p, size_t); void operator delete(void *p, size_t) throw();
CColModel& operator=(const CColModel& other); CColModel& operator=(const CColModel& other);
}; };

View File

@ -1873,8 +1873,7 @@ CStreaming::RemoveCurrentZonesModels(void)
if (ms_currentPedGrp != -1) if (ms_currentPedGrp != -1)
for (i = 0; i < NUMMODELSPERPEDGROUP; i++) { for (i = 0; i < NUMMODELSPERPEDGROUP; i++) {
ms_bIsPedFromPedGroupLoaded[i] = false; ms_bIsPedFromPedGroupLoaded[i] = false;
if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1 && if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1) {
CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01) {
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
} }

View File

@ -452,6 +452,7 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info)
assert(d >= 0.0f && d <= 1.0f); assert(d >= 0.0f && d <= 1.0f);
n = 1.0f - d; n = 1.0f - d;
} }
#ifdef FIX_BUGS
info->carDensity = day->carDensity * d + night->carDensity * n; info->carDensity = day->carDensity * d + night->carDensity * n;
for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++) for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++)
info->carThreshold[i] = day->carThreshold[i] * d + night->carThreshold[i] * n; info->carThreshold[i] = day->carThreshold[i] * d + night->carThreshold[i] * n;
@ -465,6 +466,22 @@ CTheZones::GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info)
info->copPedThreshold = day->copPedThreshold * d + night->copPedThreshold * n; info->copPedThreshold = day->copPedThreshold * d + night->copPedThreshold * n;
for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++) for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++)
info->gangPedThreshold[i] = day->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n; info->gangPedThreshold[i] = day->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n;
#else
// This is a complete mess.
info->carDensity = day->carDensity * n + night->carDensity * d;
for(i = 0; i < ARRAY_SIZE(info->carThreshold); i++)
info->carThreshold[i] = night->carThreshold[i] * d + night->carThreshold[i] * n;
for(i = 0; i < ARRAY_SIZE(info->boatThreshold); i++)
info->boatThreshold[i] = night->boatThreshold[i] * d + night->boatThreshold[i] * n;
for(i = 0; i < ARRAY_SIZE(info->gangThreshold); i++)
info->gangThreshold[i] = night->gangThreshold[i] * d + night->gangThreshold[i] * n;
info->copThreshold = night->copThreshold * d + night->copThreshold * n;
info->pedDensity = night->pedDensity * d + night->pedDensity * n;
info->copPedThreshold = night->copPedThreshold * d + night->copPedThreshold * n;
for(i = 0; i < ARRAY_SIZE(info->gangPedThreshold); i++)
info->gangPedThreshold[i] = night->gangPedThreshold[i] * d + night->gangPedThreshold[i] * n;
#endif
} }
if(CClock::GetIsTimeInRange(5, 19)) if(CClock::GetIsTimeInRange(5, 19))
info->pedGroup = day->pedGroup; info->pedGroup = day->pedGroup;

View File

@ -4,8 +4,8 @@
#include "World.h" #include "World.h"
#include "Dummy.h" #include "Dummy.h"
void *CDummy::operator new(size_t sz) { return CPools::GetDummyPool()->New(); } void *CDummy::operator new(size_t sz) throw() { return CPools::GetDummyPool()->New(); }
void CDummy::operator delete(void *p, size_t sz) { CPools::GetDummyPool()->Delete((CDummy*)p); } void CDummy::operator delete(void *p, size_t sz) throw() { CPools::GetDummyPool()->Delete((CDummy*)p); }
void void
CDummy::Add(void) CDummy::Add(void)

View File

@ -12,8 +12,8 @@ public:
void Add(void); void Add(void);
void Remove(void); void Remove(void);
static void *operator new(size_t); static void *operator new(size_t) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
}; };
bool IsDummyPointerValid(CDummy* pDummy); bool IsDummyPointerValid(CDummy* pDummy);

View File

@ -25,10 +25,32 @@ int16 CObject::nNoTempObjects;
//int16 CObject::nBodyCastHealth = 1000; //int16 CObject::nBodyCastHealth = 1000;
float CObject::fDistToNearestTree; float CObject::fDistToNearestTree;
void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); } // Object pools tends to be full sometimes, let's free a temp. object in this case.
void *CObject::operator new(size_t sz, int handle) { return CPools::GetObjectPool()->New(handle);}; #ifdef FIX_BUGS
void CObject::operator delete(void *p, size_t sz) { CPools::GetObjectPool()->Delete((CObject*)p); } void *CObject::operator new(size_t sz) throw() {
void CObject::operator delete(void *p, int handle) { CPools::GetObjectPool()->Delete((CObject*)p); } CObject *obj = CPools::GetObjectPool()->New();
if (!obj) {
CObjectPool *objectPool = CPools::GetObjectPool();
for (int32 i = 0; i < objectPool->GetSize(); i++) {
CObject *existing = objectPool->GetSlot(i);
if (existing && existing->ObjectCreatedBy == TEMP_OBJECT) {
int32 handle = objectPool->GetIndex(existing);
CWorld::Remove(existing);
delete existing;
obj = objectPool->New(handle);
break;
}
}
}
return obj;
}
#else
void *CObject::operator new(size_t sz) throw() { return CPools::GetObjectPool()->New(); }
#endif
void *CObject::operator new(size_t sz, int handle) throw() { return CPools::GetObjectPool()->New(handle); };
void CObject::operator delete(void *p, size_t sz) throw() { CPools::GetObjectPool()->Delete((CObject*)p); }
void CObject::operator delete(void *p, int handle) throw() { CPools::GetObjectPool()->Delete((CObject*)p); }
CObject::CObject(void) CObject::CObject(void)
{ {

View File

@ -87,10 +87,10 @@ public:
static int16 nNoTempObjects; static int16 nNoTempObjects;
static float fDistToNearestTree; static float fDistToNearestTree;
static void *operator new(size_t); static void *operator new(size_t) throw();
static void *operator new(size_t, int); static void *operator new(size_t, int) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
static void operator delete(void*, int); static void operator delete(void*, int) throw();
CObject(void); CObject(void);
CObject(int32, bool); CObject(int32, bool);

View File

@ -46,7 +46,14 @@ CStinger::Init(CPed *pPed)
pOwner = pPed; pOwner = pPed;
for (i = 0; i < NUM_STINGER_SEGMENTS; i++) { 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; pSpikes[i]->bUsesCollision = false;
} }
bIsDeployed = true; bIsDeployed = true;
@ -77,8 +84,11 @@ CStinger::Remove()
CStingerSegment *spikeSegment = pSpikes[i]; CStingerSegment *spikeSegment = pSpikes[i];
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (spikeSegment) {
CWorld::Remove(spikeSegment); CWorld::Remove(spikeSegment);
delete spikeSegment; delete spikeSegment;
pSpikes[i] = nil;
}
#else #else
if (spikeSegment->m_entryInfoList.first != nil) if (spikeSegment->m_entryInfoList.first != nil)
spikeSegment->bRemoveFromWorld = true; spikeSegment->bRemoveFromWorld = true;
@ -92,9 +102,15 @@ CStinger::Remove()
void void
CStinger::Deploy(CPed *pPed) 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 (NumOfStingerSegments < NUM_STINGER_SEGMENTS*2 && !pPed->bInVehicle && pPed->IsPedInControl()) {
if (!bIsDeployed && RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_STD_THROW_UNDER) == nil) { if (!bIsDeployed && RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_STD_THROW_UNDER) == nil) {
Init(pPed); 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); pPed->SetPedState(PED_DEPLOY_STINGER);
CAnimManager::AddAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_THROW_UNDER); CAnimManager::AddAnimation(pPed->GetClump(), ASSOCGRP_STD, ANIM_STD_THROW_UNDER);
} }
@ -167,6 +183,7 @@ CStinger::CheckForBurstTyres()
} }
} }
// Only called when bIsDeployed
void void
CStinger::Process() CStinger::Process()
{ {
@ -232,10 +249,11 @@ CStinger::Process()
break; break;
case STINGERSTATE_REMOVE: case STINGERSTATE_REMOVE:
Remove(); Remove();
break;
}
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (bIsDeployed) return;
#else
break;
#endif #endif
}
CheckForBurstTyres(); CheckForBurstTyres();
} }

View File

@ -93,7 +93,7 @@ CCopPed::CCopPed(eCopType copType, int32 modifier) : CPed(PEDTYPE_COP)
m_nHassleTimer = 0; m_nHassleTimer = 0;
field_61C = 0; field_61C = 0;
field_624 = 0; field_624 = 0;
m_pStinger = new CStinger; m_pStinger = new CStinger();
SetWeaponLockOnTarget(nil); SetWeaponLockOnTarget(nil);
} }

View File

@ -53,10 +53,10 @@ bool CPed::bFannyMagnetCheat;
bool CPed::bPedCheat3; bool CPed::bPedCheat3;
CVector2D CPed::ms_vec2DFleePosition; CVector2D CPed::ms_vec2DFleePosition;
void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); } void *CPed::operator new(size_t sz) throw() { return CPools::GetPedPool()->New(); }
void *CPed::operator new(size_t sz, int handle) { return CPools::GetPedPool()->New(handle); } void *CPed::operator new(size_t sz, int handle) throw() { return CPools::GetPedPool()->New(handle); }
void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); } void CPed::operator delete(void *p, size_t sz) throw() { CPools::GetPedPool()->Delete((CPed*)p); }
void CPed::operator delete(void *p, int handle) { CPools::GetPedPool()->Delete((CPed*)p); } void CPed::operator delete(void *p, int handle) throw() { CPools::GetPedPool()->Delete((CPed*)p); }
float gfTommyFatness = 1.0f; float gfTommyFatness = 1.0f;

View File

@ -650,10 +650,10 @@ public:
CVector m_vecSpotToGuard; CVector m_vecSpotToGuard;
float m_radiusToGuard; float m_radiusToGuard;
static void *operator new(size_t); static void *operator new(size_t) throw();
static void *operator new(size_t, int); static void *operator new(size_t, int) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
static void operator delete(void*, int); static void operator delete(void*, int) throw();
CPed(uint32 pedType); CPed(uint32 pedType);
~CPed(void); ~CPed(void);

View File

@ -1434,7 +1434,7 @@ CPopulation::PlaceGangMembersInFormation(ePedType pedType, int pedAmount, CVecto
CPed *createdPeds[5]; CPed *createdPeds[5];
if (!TheCamera.IsSphereVisible(coors, 3.0f) || MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) { if (!TheCamera.IsSphereVisible(coors, 3.0f) || MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) {
if (CPedPlacement::IsPositionClearForPed(coors, 3.0f, -1, 0)) { if (CPedPlacement::IsPositionClearForPed(coors, 3.0f, -1, nil)) {
bool leaderFoundGround; bool leaderFoundGround;
float leaderGroundZ = CWorld::FindGroundZFor3DCoord(coors.x, coors.y, coors.z, &leaderFoundGround) + 1.0f; float leaderGroundZ = CWorld::FindGroundZFor3DCoord(coors.x, coors.y, coors.z, &leaderFoundGround) + 1.0f;
if (leaderFoundGround) { if (leaderFoundGround) {
@ -1514,7 +1514,7 @@ CPopulation::PlaceGangMembersInCircle(ePedType pedType, int pedAmount, CVector c
if (!TheCamera.IsSphereVisible(coors, circleR) || if (!TheCamera.IsSphereVisible(coors, circleR) ||
MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) { MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) {
if (CPedPlacement::IsPositionClearForPed(coors, circleR, -1, 0)) { if (CPedPlacement::IsPositionClearForPed(coors, circleR, -1, nil)) {
int pedIdx = 0; int pedIdx = 0;
CVector leaderPos; CVector leaderPos;
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -1558,9 +1558,9 @@ CPopulation::PlaceGangMembersInCircle(ePedType pedType, int pedAmount, CVector c
} }
bool memberCanSeeLeader = createLeader ? true : CWorld::GetIsLineOfSightClear(finalPos, leaderPos, true, false, false, false, false, false, false); bool memberCanSeeLeader = createLeader ? true : CWorld::GetIsLineOfSightClear(finalPos, leaderPos, true, false, false, false, false, false, false);
bool notTooCloseToLeader = createLeader ? true : !(Abs(finalPos.z - leaderPos.z) < 1.0f); bool notTooHighFromLeader = createLeader ? true : !(Abs(finalPos.z - leaderPos.z) >= 1.0f);
if (!foundObstacle && memberCanSeeLeader && notTooCloseToLeader) { if (!foundObstacle && memberCanSeeLeader && notTooHighFromLeader) {
CPed* newPed = AddPed(pedType, gangModel, finalPos); CPed* newPed = AddPed(pedType, gangModel, finalPos);
if (newPed) { if (newPed) {
createdPeds[pedIdx++] = newPed; createdPeds[pedIdx++] = newPed;
@ -1573,6 +1573,9 @@ CPopulation::PlaceGangMembersInCircle(ePedType pedType, int pedAmount, CVector c
newPed->bCanAttackPlayerWithCops = true; newPed->bCanAttackPlayerWithCops = true;
CVisibilityPlugins::SetClumpAlpha(newPed->GetClump(), 0); CVisibilityPlugins::SetClumpAlpha(newPed->GetClump(), 0);
#ifdef FIX_BUGS
createLeader = false;
#endif
} }
// No. // No.
#ifndef FIX_BUGS #ifndef FIX_BUGS
@ -1581,9 +1584,6 @@ CPopulation::PlaceGangMembersInCircle(ePedType pedType, int pedAmount, CVector c
#endif #endif
} }
} }
#ifdef FIX_BUGS
createLeader = false;
#endif
} }
} }
if (pedIdx >= 3) { if (pedIdx >= 3) {
@ -1623,7 +1623,7 @@ CPopulation::PlaceCouple(ePedType manType, int32 manModel, ePedType womanType, i
return; return;
if (!TheCamera.IsSphereVisible(coors, 1.5f) || MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) { if (!TheCamera.IsSphereVisible(coors, 1.5f) || MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) {
if (CPedPlacement::IsPositionClearForPed(coors, CModelInfo::GetModelInfo(manModel)->GetColModel()->boundingSphere.radius, -1, 0)) { if (CPedPlacement::IsPositionClearForPed(coors, CModelInfo::GetModelInfo(manModel)->GetColModel()->boundingSphere.radius, -1, nil)) {
bool manFoundGround; bool manFoundGround;
float manGroundZ = CWorld::FindGroundZFor3DCoord(coors.x, coors.y, coors.z, &manFoundGround) + 1.0f; float manGroundZ = CWorld::FindGroundZFor3DCoord(coors.x, coors.y, coors.z, &manFoundGround) + 1.0f;
if (manFoundGround) { if (manFoundGround) {
@ -1705,7 +1705,7 @@ CPopulation::PlaceMallPedsAsStationaryGroup(CVector const& coors, int32 group)
if (!TheCamera.IsSphereVisible(coors, circleR) || if (!TheCamera.IsSphereVisible(coors, circleR) ||
MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) { MIN_CREATION_DIST * PedCreationDistMultiplier() <= (coors - FindPlayerPed()->GetPosition()).Magnitude2D()) {
if (CPedPlacement::IsPositionClearForPed(coors, circleR, -1, 0)) { if (CPedPlacement::IsPositionClearForPed(coors, circleR, -1, nil)) {
int pedIdx = 0; int pedIdx = 0;
CVector leaderPos; CVector leaderPos;
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -1730,6 +1730,7 @@ CPopulation::PlaceMallPedsAsStationaryGroup(CVector const& coors, int32 group)
int pedModel = ChooseCivilianOccupation(group); int pedModel = ChooseCivilianOccupation(group);
CPedModelInfo *pedModelInfo = (CPedModelInfo*)CModelInfo::GetModelInfo(pedModel); CPedModelInfo *pedModelInfo = (CPedModelInfo*)CModelInfo::GetModelInfo(pedModel);
if (pedModelInfo->GetRwObject()) { if (pedModelInfo->GetRwObject()) {
CEntity* obstacles[6] = { nil, nil, nil, nil, nil, nil }; CEntity* obstacles[6] = { nil, nil, nil, nil, nil, nil };
CPedPlacement::IsPositionClearForPed(finalPos, CModelInfo::GetModelInfo(pedModel)->GetColModel()->boundingSphere.radius, ARRAY_SIZE(obstacles), obstacles); CPedPlacement::IsPositionClearForPed(finalPos, CModelInfo::GetModelInfo(pedModel)->GetColModel()->boundingSphere.radius, ARRAY_SIZE(obstacles), obstacles);
@ -1751,9 +1752,9 @@ CPopulation::PlaceMallPedsAsStationaryGroup(CVector const& coors, int32 group)
} }
bool memberCanSeeLeader = createLeader ? true : CWorld::GetIsLineOfSightClear(finalPos, leaderPos, true, false, false, false, false, false, false); bool memberCanSeeLeader = createLeader ? true : CWorld::GetIsLineOfSightClear(finalPos, leaderPos, true, false, false, false, false, false, false);
bool notTooCloseToLeader = createLeader ? true : !(Abs(finalPos.z - leaderPos.z) < 1.0f); bool notTooHighFromLeader = createLeader ? true : !(Abs(finalPos.z - leaderPos.z) >= 1.0f);
if (!foundObstacle && memberCanSeeLeader && notTooCloseToLeader) { if (!foundObstacle && memberCanSeeLeader && notTooHighFromLeader) {
CPed *newPed = AddPed(pedModelInfo->m_pedType, pedModel, finalPos); CPed *newPed = AddPed(pedModelInfo->m_pedType, pedModel, finalPos);
if (newPed) { if (newPed) {
createdPeds[pedIdx++] = newPed; createdPeds[pedIdx++] = newPed;
@ -1764,6 +1765,9 @@ CPopulation::PlaceMallPedsAsStationaryGroup(CVector const& coors, int32 group)
newPed->m_fRotationCur = angle; newPed->m_fRotationCur = angle;
newPed->m_fearFlags = 0; newPed->m_fearFlags = 0;
CVisibilityPlugins::SetClumpAlpha(newPed->GetClump(), 0); CVisibilityPlugins::SetClumpAlpha(newPed->GetClump(), 0);
#ifdef FIX_BUGS
createLeader = false;
#endif
} }
// No. // No.
#ifndef FIX_BUGS #ifndef FIX_BUGS
@ -1772,9 +1776,6 @@ CPopulation::PlaceMallPedsAsStationaryGroup(CVector const& coors, int32 group)
#endif #endif
} }
} }
#ifdef FIX_BUGS
createLeader = false;
#endif
} }
} }
if (pedIdx >= 3) { if (pedIdx >= 3) {

View File

@ -28,10 +28,10 @@ RwMemoryFunctions memFuncs = {
#ifdef USE_CUSTOM_ALLOCATOR #ifdef USE_CUSTOM_ALLOCATOR
// game seems to be using heap directly here, but this is nicer // game seems to be using heap directly here, but this is nicer
void *operator new(size_t sz) { return MemoryMgrMalloc(sz); } void *operator new(size_t sz) throw() { return MemoryMgrMalloc(sz); }
void *operator new[](size_t sz) { return MemoryMgrMalloc(sz); } void *operator new[](size_t sz) throw() { return MemoryMgrMalloc(sz); }
void operator delete(void *ptr) noexcept { MemoryMgrFree(ptr); } void operator delete(void *ptr) throw() { MemoryMgrFree(ptr); }
void operator delete[](void *ptr) noexcept { MemoryMgrFree(ptr); } void operator delete[](void *ptr) throw() { MemoryMgrFree(ptr); }
#endif #endif
void* void*

View File

@ -50,10 +50,10 @@ bool CVehicle::bDisableRemoteDetonationOnContact;
bool CVehicle::m_bDisplayHandlingInfo; bool CVehicle::m_bDisplayHandlingInfo;
#endif #endif
void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } void *CVehicle::operator new(size_t sz) throw() { return CPools::GetVehiclePool()->New(); }
void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void *CVehicle::operator new(size_t sz, int handle) throw() { return CPools::GetVehiclePool()->New(handle); }
void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } void CVehicle::operator delete(void *p, size_t sz) throw() { CPools::GetVehiclePool()->Delete((CVehicle*)p); }
void CVehicle::operator delete(void *p, int handle) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } void CVehicle::operator delete(void *p, int handle) throw() { CPools::GetVehiclePool()->Delete((CVehicle*)p); }
#ifdef FIX_BUGS #ifdef FIX_BUGS
// I think they meant that // I think they meant that

View File

@ -278,10 +278,10 @@ public:
float m_fSteerInput; float m_fSteerInput;
uint8 m_vehType; uint8 m_vehType;
static void *operator new(size_t); static void *operator new(size_t) throw();
static void *operator new(size_t sz, int slot); static void *operator new(size_t sz, int slot) throw();
static void operator delete(void*, size_t); static void operator delete(void*, size_t) throw();
static void operator delete(void*, int); static void operator delete(void*, int) throw();
CVehicle(void) {} // FAKE CVehicle(void) {} // FAKE
CVehicle(uint8 CreatedBy); CVehicle(uint8 CreatedBy);