Merge pull request #246 from Sergeanur/Pools
Some CPool and CPools funcs, restoring original logic of pool lookup loops
This commit is contained in:
commit
4844b3a3f8
@ -123,8 +123,7 @@ void CBridge::FindBridgeEntities()
|
|||||||
pLiftRoad = nil;
|
pLiftRoad = nil;
|
||||||
pLiftPart = nil;
|
pLiftPart = nil;
|
||||||
|
|
||||||
for (int i = 1; i < CPools::GetBuildingPool()->GetSize(); ++i)
|
for (int i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--) {
|
||||||
{
|
|
||||||
CBuilding* entry = CPools::GetBuildingPool()->GetSlot(i);
|
CBuilding* entry = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
|
@ -588,7 +588,7 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle)
|
|||||||
CVector2D forward = pVehicle->GetMoveSpeed() / flatSpeed;
|
CVector2D forward = pVehicle->GetMoveSpeed() / flatSpeed;
|
||||||
float projection = flatSpeed * 45 + 20;
|
float projection = flatSpeed * 45 + 20;
|
||||||
int i = CPools::GetVehiclePool()->GetSize();
|
int i = CPools::GetVehiclePool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
|
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if (!vehicle)
|
if (!vehicle)
|
||||||
continue;
|
continue;
|
||||||
|
@ -648,8 +648,7 @@ CCarCtrl::AddToCarArray(int32 id, int32 vehclass)
|
|||||||
void
|
void
|
||||||
CCarCtrl::RemoveDistantCars()
|
CCarCtrl::RemoveDistantCars()
|
||||||
{
|
{
|
||||||
uint32 i = CPools::GetVehiclePool()->GetSize();
|
for (int i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) {
|
||||||
while (--i){
|
|
||||||
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if (!pVehicle)
|
if (!pVehicle)
|
||||||
continue;
|
continue;
|
||||||
@ -733,8 +732,7 @@ int32
|
|||||||
CCarCtrl::CountCarsOfType(int32 mi)
|
CCarCtrl::CountCarsOfType(int32 mi)
|
||||||
{
|
{
|
||||||
int32 total = 0;
|
int32 total = 0;
|
||||||
uint32 i = CPools::GetVehiclePool()->GetSize();
|
for (int i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) {
|
||||||
while (i--){
|
|
||||||
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if (!pVehicle)
|
if (!pVehicle)
|
||||||
continue;
|
continue;
|
||||||
|
@ -153,8 +153,8 @@ CPhoneInfo::Initialise(void)
|
|||||||
pickedUpPhone = nil;
|
pickedUpPhone = nil;
|
||||||
m_nMax = 0;
|
m_nMax = 0;
|
||||||
m_nNum = 0;
|
m_nNum = 0;
|
||||||
for (int v5 = pool->GetSize() - 1; v5 >= 0; v5--) {
|
for (int i = pool->GetSize() - 1; i >= 0; i--) {
|
||||||
CBuilding *building = pool->GetSlot(v5);
|
CBuilding *building = pool->GetSlot(i);
|
||||||
if (building) {
|
if (building) {
|
||||||
if (building->m_modelIndex == MI_PHONEBOOTH1) {
|
if (building->m_modelIndex == MI_PHONEBOOTH1) {
|
||||||
CPhone *maxPhone = &m_aPhones[m_nMax];
|
CPhone *maxPhone = &m_aPhones[m_nMax];
|
||||||
|
@ -297,7 +297,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
|
|||||||
m_pObject->UpdateRwFrame();
|
m_pObject->UpdateRwFrame();
|
||||||
|
|
||||||
bool touched = false;
|
bool touched = false;
|
||||||
for (int32 i = CPools::GetVehiclePool()->GetSize(); i > 0; i--) { // TODO: check if i > 0 is not a R* mistake
|
for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) {
|
||||||
CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(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)) {
|
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) {
|
||||||
touched = true;
|
touched = true;
|
||||||
@ -324,7 +324,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
|
|||||||
if (CTimer::GetTimeInMilliseconds() > m_nTimer)
|
if (CTimer::GetTimeInMilliseconds() > m_nTimer)
|
||||||
explode = true;
|
explode = true;
|
||||||
else {// added else here since vehicle lookup is useless
|
else {// added else here since vehicle lookup is useless
|
||||||
for (int32 i = CPools::GetVehiclePool()->GetSize(); i > 0; i--) { // TODO: check if i > 0 is not a R* mistake
|
for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) {
|
||||||
CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(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)) {
|
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) {
|
||||||
explode = true;
|
explode = true;
|
||||||
|
@ -1156,7 +1156,7 @@ void CReplay::RestoreStuffFromMem(void)
|
|||||||
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */
|
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */
|
||||||
CWorld::Players[0] = PlayerInfo;
|
CWorld::Players[0] = PlayerInfo;
|
||||||
int i = CPools::GetPedPool()->GetSize();
|
int i = CPools::GetPedPool()->GetSize();
|
||||||
while (i--){
|
while (--i >= 0) {
|
||||||
CPed* ped = CPools::GetPedPool()->GetSlot(i);
|
CPed* ped = CPools::GetPedPool()->GetSlot(i);
|
||||||
if (!ped)
|
if (!ped)
|
||||||
continue;
|
continue;
|
||||||
@ -1174,7 +1174,7 @@ void CReplay::RestoreStuffFromMem(void)
|
|||||||
ped->AddWeaponModel(ped->m_wepModelID);
|
ped->AddWeaponModel(ped->m_wepModelID);
|
||||||
}
|
}
|
||||||
i = CPools::GetVehiclePool()->GetSize();
|
i = CPools::GetVehiclePool()->GetSize();
|
||||||
while (i--){
|
while (--i >= 0) {
|
||||||
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
|
CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if (!vehicle)
|
if (!vehicle)
|
||||||
continue;
|
continue;
|
||||||
@ -1233,7 +1233,7 @@ void CReplay::RestoreStuffFromMem(void)
|
|||||||
}
|
}
|
||||||
PrintElementsInPtrList();
|
PrintElementsInPtrList();
|
||||||
i = CPools::GetObjectPool()->GetSize();
|
i = CPools::GetObjectPool()->GetSize();
|
||||||
while (i--){
|
while (--i >= 0) {
|
||||||
CObject* object = CPools::GetObjectPool()->GetSlot(i);
|
CObject* object = CPools::GetObjectPool()->GetSlot(i);
|
||||||
if (!object)
|
if (!object)
|
||||||
continue;
|
continue;
|
||||||
@ -1248,7 +1248,7 @@ void CReplay::RestoreStuffFromMem(void)
|
|||||||
object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false);
|
object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false);
|
||||||
}
|
}
|
||||||
i = CPools::GetDummyPool()->GetSize();
|
i = CPools::GetDummyPool()->GetSize();
|
||||||
while (i--){
|
while (--i >= 0) {
|
||||||
CDummy* dummy = CPools::GetDummyPool()->GetSlot(i);
|
CDummy* dummy = CPools::GetDummyPool()->GetSlot(i);
|
||||||
if (!dummy)
|
if (!dummy)
|
||||||
continue;
|
continue;
|
||||||
@ -1294,7 +1294,7 @@ WRAPPER void CReplay::EmptyPedsAndVehiclePools(void) { EAXJMP(0x5970E0); }
|
|||||||
void CReplay::EmptyPedsAndVehiclePools(void)
|
void CReplay::EmptyPedsAndVehiclePools(void)
|
||||||
{
|
{
|
||||||
int i = CPools::GetVehiclePool()->GetSize();
|
int i = CPools::GetVehiclePool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if (!v)
|
if (!v)
|
||||||
continue;
|
continue;
|
||||||
@ -1302,7 +1302,7 @@ void CReplay::EmptyPedsAndVehiclePools(void)
|
|||||||
delete v;
|
delete v;
|
||||||
}
|
}
|
||||||
i = CPools::GetPedPool()->GetSize();
|
i = CPools::GetPedPool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
@ -1319,7 +1319,7 @@ void CReplay::EmptyAllPools(void)
|
|||||||
{
|
{
|
||||||
EmptyPedsAndVehiclePools();
|
EmptyPedsAndVehiclePools();
|
||||||
int i = CPools::GetObjectPool()->GetSize();
|
int i = CPools::GetObjectPool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CObject* o = CPools::GetObjectPool()->GetSlot(i);
|
CObject* o = CPools::GetObjectPool()->GetSlot(i);
|
||||||
if (!o)
|
if (!o)
|
||||||
continue;
|
continue;
|
||||||
@ -1327,7 +1327,7 @@ void CReplay::EmptyAllPools(void)
|
|||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
i = CPools::GetDummyPool()->GetSize();
|
i = CPools::GetDummyPool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CDummy* d = CPools::GetDummyPool()->GetSlot(i);
|
CDummy* d = CPools::GetDummyPool()->GetSlot(i);
|
||||||
if (!d)
|
if (!d)
|
||||||
continue;
|
continue;
|
||||||
@ -1343,14 +1343,14 @@ WRAPPER void CReplay::MarkEverythingAsNew(void) { EAXJMP(0x597280); }
|
|||||||
void CReplay::MarkEverythingAsNew(void)
|
void CReplay::MarkEverythingAsNew(void)
|
||||||
{
|
{
|
||||||
int i = CPools::GetVehiclePool()->GetSize();
|
int i = CPools::GetVehiclePool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if (!v)
|
if (!v)
|
||||||
continue;
|
continue;
|
||||||
v->bHasAlreadyBeenRecorded = false;
|
v->bHasAlreadyBeenRecorded = false;
|
||||||
}
|
}
|
||||||
i = CPools::GetPedPool()->GetSize();
|
i = CPools::GetPedPool()->GetSize();
|
||||||
while (i--) {
|
while (--i >= 0) {
|
||||||
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
CPed* p = CPools::GetPedPool()->GetSlot(i);
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
#include "Pools.h"
|
#include "Pools.h"
|
||||||
|
#include "World.h"
|
||||||
|
#include "ProjectileInfo.h"
|
||||||
|
|
||||||
CCPtrNodePool *&CPools::ms_pPtrNodePool = *(CCPtrNodePool**)0x943044;
|
CCPtrNodePool *&CPools::ms_pPtrNodePool = *(CCPtrNodePool**)0x943044;
|
||||||
CEntryInfoNodePool *&CPools::ms_pEntryInfoNodePool = *(CEntryInfoNodePool**)0x941448;
|
CEntryInfoNodePool *&CPools::ms_pEntryInfoNodePool = *(CEntryInfoNodePool**)0x941448;
|
||||||
@ -12,15 +14,9 @@ CObjectPool *&CPools::ms_pObjectPool = *(CObjectPool**)0x880E28;
|
|||||||
CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18;
|
CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18;
|
||||||
CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C;
|
CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C;
|
||||||
|
|
||||||
WRAPPER void CPools::Initialise(void) { EAXJMP(0x4A1770); }
|
|
||||||
WRAPPER void CPools::MakeSureSlotInObjectPoolIsEmpty(int32 handle) { EAXJMP(0x4A2DB0); }
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void
|
void
|
||||||
CPools::Initialise(void)
|
CPools::Initialise(void)
|
||||||
{
|
{
|
||||||
// TODO: unused right now
|
|
||||||
assert(0);
|
|
||||||
ms_pPtrNodePool = new CCPtrNodePool(NUMPTRNODES);
|
ms_pPtrNodePool = new CCPtrNodePool(NUMPTRNODES);
|
||||||
ms_pEntryInfoNodePool = new CEntryInfoNodePool(NUMENTRYINFOS);
|
ms_pEntryInfoNodePool = new CEntryInfoNodePool(NUMENTRYINFOS);
|
||||||
ms_pPedPool = new CPedPool(NUMPEDS);
|
ms_pPedPool = new CPedPool(NUMPEDS);
|
||||||
@ -31,7 +27,33 @@ CPools::Initialise(void)
|
|||||||
ms_pDummyPool = new CDummyPool(NUMDUMMIES);
|
ms_pDummyPool = new CDummyPool(NUMDUMMIES);
|
||||||
ms_pAudioScriptObjectPool = new CAudioScriptObjectPool(NUMAUDIOSCRIPTOBJECTS);
|
ms_pAudioScriptObjectPool = new CAudioScriptObjectPool(NUMAUDIOSCRIPTOBJECTS);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
void
|
||||||
|
CPools::ShutDown(void)
|
||||||
|
{
|
||||||
|
debug("PtrNodes left %d\n", ms_pPtrNodePool->GetNoOfUsedSpaces());
|
||||||
|
debug("EntryInfoNodes left %d\n", ms_pEntryInfoNodePool->GetNoOfUsedSpaces());
|
||||||
|
debug("Peds left %d\n", ms_pPedPool->GetNoOfUsedSpaces());
|
||||||
|
debug("Vehicles left %d\n", ms_pVehiclePool->GetNoOfUsedSpaces());
|
||||||
|
debug("Buildings left %d\n", ms_pBuildingPool->GetNoOfUsedSpaces());
|
||||||
|
debug("Treadables left %d\n", ms_pTreadablePool->GetNoOfUsedSpaces());
|
||||||
|
debug("Objects left %d\n", ms_pObjectPool->GetNoOfUsedSpaces());
|
||||||
|
debug("Dummys left %d\n", ms_pDummyPool->GetNoOfUsedSpaces());
|
||||||
|
debug("AudioScriptObjects left %d\n", ms_pAudioScriptObjectPool->GetNoOfUsedSpaces());
|
||||||
|
printf("Shutdown pool started\n");
|
||||||
|
|
||||||
|
delete ms_pPtrNodePool;
|
||||||
|
delete ms_pEntryInfoNodePool;
|
||||||
|
delete ms_pPedPool;
|
||||||
|
delete ms_pVehiclePool;
|
||||||
|
delete ms_pBuildingPool;
|
||||||
|
delete ms_pTreadablePool;
|
||||||
|
delete ms_pObjectPool;
|
||||||
|
delete ms_pDummyPool;
|
||||||
|
delete ms_pAudioScriptObjectPool;
|
||||||
|
|
||||||
|
printf("Shutdown pool done\n");
|
||||||
|
}
|
||||||
|
|
||||||
int32 CPools::GetPedRef(CPed *ped) { return ms_pPedPool->GetIndex(ped); }
|
int32 CPools::GetPedRef(CPed *ped) { return ms_pPedPool->GetIndex(ped); }
|
||||||
CPed *CPools::GetPed(int32 handle) { return ms_pPedPool->GetAt(handle); }
|
CPed *CPools::GetPed(int32 handle) { return ms_pPedPool->GetAt(handle); }
|
||||||
@ -39,3 +61,47 @@ int32 CPools::GetVehicleRef(CVehicle *vehicle) { return ms_pVehiclePool->GetInde
|
|||||||
CVehicle *CPools::GetVehicle(int32 handle) { return ms_pVehiclePool->GetAt(handle); }
|
CVehicle *CPools::GetVehicle(int32 handle) { return ms_pVehiclePool->GetAt(handle); }
|
||||||
int32 CPools::GetObjectRef(CObject *object) { return ms_pObjectPool->GetIndex(object); }
|
int32 CPools::GetObjectRef(CObject *object) { return ms_pObjectPool->GetIndex(object); }
|
||||||
CObject *CPools::GetObject(int32 handle) { return ms_pObjectPool->GetAt(handle); }
|
CObject *CPools::GetObject(int32 handle) { return ms_pObjectPool->GetAt(handle); }
|
||||||
|
|
||||||
|
void
|
||||||
|
CPools::CheckPoolsEmpty()
|
||||||
|
{
|
||||||
|
assert(ms_pPedPool->GetNoOfUsedSpaces() == 0);
|
||||||
|
assert(ms_pVehiclePool->GetNoOfUsedSpaces() == 0);
|
||||||
|
printf("pools have beem cleared \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot)
|
||||||
|
{
|
||||||
|
if (ms_pObjectPool->IsFreeSlot(slot)) return;
|
||||||
|
|
||||||
|
CObject *object = ms_pObjectPool->GetSlot(slot);
|
||||||
|
if (object->ObjectCreatedBy == TEMP_OBJECT) {
|
||||||
|
CWorld::Remove(object);
|
||||||
|
delete object;
|
||||||
|
} else if (!CProjectileInfo::RemoveIfThisIsAProjectile(object)) {
|
||||||
|
// relocate to another slot??
|
||||||
|
CObject *newObject = new CObject();
|
||||||
|
CWorld::Remove(object);
|
||||||
|
memcpy(newObject, object, ms_pObjectPool->GetMaxEntrySize());
|
||||||
|
CWorld::Add(newObject);
|
||||||
|
object->m_rwObject = nil;
|
||||||
|
delete object;
|
||||||
|
newObject->m_pFirstReference = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STARTPATCHES
|
||||||
|
InjectHook(0x4A1770, CPools::Initialise, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1880, CPools::ShutDown, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1A50, CPools::CheckPoolsEmpty, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1A80, CPools::GetPedRef, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1AA0, CPools::GetPed, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1AC0, CPools::GetVehicleRef, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1AE0, CPools::GetVehicle, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1B00, CPools::GetObjectRef, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A1B20, CPools::GetObject, PATCH_JUMP);
|
||||||
|
InjectHook(0x4A2DB0, CPools::MakeSureSlotInObjectPoolIsEmpty, PATCH_JUMP);
|
||||||
|
ENDPATCHES
|
||||||
|
@ -43,11 +43,13 @@ public:
|
|||||||
static CAudioScriptObjectPool *GetAudioScriptObjectPool(void) { return ms_pAudioScriptObjectPool; }
|
static CAudioScriptObjectPool *GetAudioScriptObjectPool(void) { return ms_pAudioScriptObjectPool; }
|
||||||
|
|
||||||
static void Initialise(void);
|
static void Initialise(void);
|
||||||
|
static void ShutDown(void);
|
||||||
static int32 GetPedRef(CPed *ped);
|
static int32 GetPedRef(CPed *ped);
|
||||||
static CPed *GetPed(int32 handle);
|
static CPed *GetPed(int32 handle);
|
||||||
static int32 GetVehicleRef(CVehicle *vehicle);
|
static int32 GetVehicleRef(CVehicle *vehicle);
|
||||||
static CVehicle *GetVehicle(int32 handle);
|
static CVehicle *GetVehicle(int32 handle);
|
||||||
static int32 GetObjectRef(CObject *object);
|
static int32 GetObjectRef(CObject *object);
|
||||||
static CObject *GetObject(int32 handle);
|
static CObject *GetObject(int32 handle);
|
||||||
static void MakeSureSlotInObjectPoolIsEmpty(int32 handle);
|
static void CheckPoolsEmpty();
|
||||||
|
static void MakeSureSlotInObjectPoolIsEmpty(int32 slot);
|
||||||
};
|
};
|
||||||
|
@ -226,7 +226,7 @@ CStreaming::Init(void)
|
|||||||
CModelInfo::GetModelInfo("IslandLODsubIND", &islandLODsubInd);
|
CModelInfo::GetModelInfo("IslandLODsubIND", &islandLODsubInd);
|
||||||
CModelInfo::GetModelInfo("IslandLODsubCOM", &islandLODsubCom);
|
CModelInfo::GetModelInfo("IslandLODsubCOM", &islandLODsubCom);
|
||||||
|
|
||||||
for(i = 0; i < CPools::GetBuildingPool()->GetSize(); i++){
|
for(i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--){
|
||||||
CBuilding *building = CPools::GetBuildingPool()->GetSlot(i);
|
CBuilding *building = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if(building == nil)
|
if(building == nil)
|
||||||
continue;
|
continue;
|
||||||
@ -682,8 +682,8 @@ CStreaming::RequestBigBuildings(eLevelName level)
|
|||||||
int i, n;
|
int i, n;
|
||||||
CBuilding *b;
|
CBuilding *b;
|
||||||
|
|
||||||
n = CPools::GetBuildingPool()->GetSize();
|
n = CPools::GetBuildingPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
b = CPools::GetBuildingPool()->GetSlot(i);
|
b = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if(b && b->bIsBIGBuilding && b->m_level == level)
|
if(b && b->bIsBIGBuilding && b->m_level == level)
|
||||||
RequestModel(b->GetModelIndex(), STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
|
RequestModel(b->GetModelIndex(), STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY);
|
||||||
@ -837,8 +837,8 @@ CStreaming::RemoveBuildings(eLevelName level)
|
|||||||
CEntity *e;
|
CEntity *e;
|
||||||
CBaseModelInfo *mi;
|
CBaseModelInfo *mi;
|
||||||
|
|
||||||
n = CPools::GetBuildingPool()->GetSize();
|
n = CPools::GetBuildingPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetBuildingPool()->GetSlot(i);
|
e = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if(e && e->m_level == level){
|
if(e && e->m_level == level){
|
||||||
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
||||||
@ -850,8 +850,8 @@ CStreaming::RemoveBuildings(eLevelName level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = CPools::GetTreadablePool()->GetSize();
|
n = CPools::GetTreadablePool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetTreadablePool()->GetSlot(i);
|
e = CPools::GetTreadablePool()->GetSlot(i);
|
||||||
if(e && e->m_level == level){
|
if(e && e->m_level == level){
|
||||||
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
||||||
@ -863,8 +863,8 @@ CStreaming::RemoveBuildings(eLevelName level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = CPools::GetObjectPool()->GetSize();
|
n = CPools::GetObjectPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetObjectPool()->GetSlot(i);
|
e = CPools::GetObjectPool()->GetSlot(i);
|
||||||
if(e && e->m_level == level){
|
if(e && e->m_level == level){
|
||||||
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
||||||
@ -876,8 +876,8 @@ CStreaming::RemoveBuildings(eLevelName level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = CPools::GetDummyPool()->GetSize();
|
n = CPools::GetDummyPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetDummyPool()->GetSlot(i);
|
e = CPools::GetDummyPool()->GetSlot(i);
|
||||||
if(e && e->m_level == level){
|
if(e && e->m_level == level){
|
||||||
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
||||||
@ -951,8 +951,8 @@ CStreaming::RemoveBigBuildings(eLevelName level)
|
|||||||
CEntity *e;
|
CEntity *e;
|
||||||
CBaseModelInfo *mi;
|
CBaseModelInfo *mi;
|
||||||
|
|
||||||
n = CPools::GetBuildingPool()->GetSize();
|
n = CPools::GetBuildingPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetBuildingPool()->GetSlot(i);
|
e = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if(e && e->bIsBIGBuilding && e->m_level == level){
|
if(e && e->bIsBIGBuilding && e->m_level == level){
|
||||||
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
mi = CModelInfo::GetModelInfo(e->GetModelIndex());
|
||||||
@ -1172,8 +1172,8 @@ CStreaming::HaveAllBigBuildingsLoaded(eLevelName level)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = CPools::GetBuildingPool()->GetSize();
|
n = CPools::GetBuildingPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetBuildingPool()->GetSlot(i);
|
e = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if(e && e->bIsBIGBuilding && e->m_level == level &&
|
if(e && e->bIsBIGBuilding && e->m_level == level &&
|
||||||
ms_aInfoForModel[e->GetModelIndex()].m_loadState != STREAMSTATE_LOADED)
|
ms_aInfoForModel[e->GetModelIndex()].m_loadState != STREAMSTATE_LOADED)
|
||||||
|
@ -169,22 +169,22 @@ CCullZones::MarkSubwayAsInvisible(bool visible)
|
|||||||
CEntity *e;
|
CEntity *e;
|
||||||
CVehicle *v;
|
CVehicle *v;
|
||||||
|
|
||||||
n = CPools::GetBuildingPool()->GetSize();
|
n = CPools::GetBuildingPool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetBuildingPool()->GetSlot(i);
|
e = CPools::GetBuildingPool()->GetSlot(i);
|
||||||
if(e && e->bIsSubway)
|
if(e && e->bIsSubway)
|
||||||
e->bIsVisible = visible;
|
e->bIsVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = CPools::GetTreadablePool()->GetSize();
|
n = CPools::GetTreadablePool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
e = CPools::GetTreadablePool()->GetSlot(i);
|
e = CPools::GetTreadablePool()->GetSlot(i);
|
||||||
if(e && e->bIsSubway)
|
if(e && e->bIsSubway)
|
||||||
e->bIsVisible = visible;
|
e->bIsVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = CPools::GetVehiclePool()->GetSize();
|
n = CPools::GetVehiclePool()->GetSize()-1;
|
||||||
for(i = 0; i < n; i++){
|
for(i = n; i >= 0; i--){
|
||||||
v = CPools::GetVehiclePool()->GetSlot(i);
|
v = CPools::GetVehiclePool()->GetSlot(i);
|
||||||
if(v && v->IsTrain() && ((CTrain*)v)->m_nTrackId != TRACK_ELTRAIN)
|
if(v && v->IsTrain() && ((CTrain*)v)->m_nTrackId != TRACK_ELTRAIN)
|
||||||
v->bIsVisible = visible;
|
v->bIsVisible = visible;
|
||||||
|
@ -44,7 +44,20 @@ public:
|
|||||||
m_flags[i].free = 1;
|
m_flags[i].free = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int GetSize(void) { return m_size; }
|
~CPool() {
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
void Flush() {
|
||||||
|
if (m_size > 0) {
|
||||||
|
free(m_entries);
|
||||||
|
free(m_flags);
|
||||||
|
m_entries = nil;
|
||||||
|
m_flags = nil;
|
||||||
|
m_size = 0;
|
||||||
|
m_allocPtr = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int GetSize(void) const { return m_size; }
|
||||||
T *New(void){
|
T *New(void){
|
||||||
bool wrapped = false;
|
bool wrapped = false;
|
||||||
do
|
do
|
||||||
@ -101,12 +114,14 @@ public:
|
|||||||
n++;
|
n++;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
bool IsFreeSlot(int i) { return !!m_flags[i].free; }
|
||||||
void ClearStorage(uint8 *&flags, U *&entries){
|
void ClearStorage(uint8 *&flags, U *&entries){
|
||||||
free(flags);
|
free(flags);
|
||||||
free(entries);
|
free(entries);
|
||||||
flags = nil;
|
flags = nil;
|
||||||
entries = nil;
|
entries = nil;
|
||||||
}
|
}
|
||||||
|
uint32 GetMaxEntrySize() const { return sizeof(U); }
|
||||||
void CopyBack(uint8 *&flags, U *&entries){
|
void CopyBack(uint8 *&flags, U *&entries){
|
||||||
memcpy(m_flags, flags, sizeof(uint8)*m_size);
|
memcpy(m_flags, flags, sizeof(uint8)*m_size);
|
||||||
memcpy(m_entries, entries, sizeof(U)*m_size);
|
memcpy(m_entries, entries, sizeof(U)*m_size);
|
||||||
|
7
src/weapons/ProjectileInfo.cpp
Normal file
7
src/weapons/ProjectileInfo.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "common.h"
|
||||||
|
#include "patcher.h"
|
||||||
|
#include "ProjectileInfo.h"
|
||||||
|
#include "Projectile.h"
|
||||||
|
|
||||||
|
|
||||||
|
WRAPPER bool CProjectileInfo::RemoveIfThisIsAProjectile(CObject *pObject) { EAXJMP(0x55BBD0); }
|
9
src/weapons/ProjectileInfo.h
Normal file
9
src/weapons/ProjectileInfo.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CObject;
|
||||||
|
|
||||||
|
class CProjectileInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool RemoveIfThisIsAProjectile(CObject *pObject);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user