diff options
Diffstat (limited to 'src/peds')
-rw-r--r-- | src/peds/Gangs.cpp | 3 | ||||
-rw-r--r-- | src/peds/Ped.cpp | 86 | ||||
-rw-r--r-- | src/peds/Ped.h | 10 | ||||
-rw-r--r-- | src/peds/PedAI.cpp | 4 | ||||
-rw-r--r-- | src/peds/PedFight.cpp | 2 | ||||
-rw-r--r-- | src/peds/PedIK.cpp | 16 | ||||
-rw-r--r-- | src/peds/PedIK.h | 2 | ||||
-rw-r--r-- | src/peds/PedType.cpp | 3 | ||||
-rw-r--r-- | src/peds/PlayerPed.cpp | 9 | ||||
-rw-r--r-- | src/peds/Population.cpp | 27 |
10 files changed, 103 insertions, 59 deletions
diff --git a/src/peds/Gangs.cpp b/src/peds/Gangs.cpp index 8859e61e..be29379c 100644 --- a/src/peds/Gangs.cpp +++ b/src/peds/Gangs.cpp @@ -3,6 +3,7 @@ #include "ModelIndices.h" #include "Gangs.h" #include "Weapon.h" +#include "SaveBuf.h" CGangInfo CGangs::Gang[NUM_GANGS]; @@ -72,6 +73,6 @@ INITSAVEBUF CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE); for (int i = 0; i < NUM_GANGS; i++) - Gang[i] = ReadSaveBuf<CGangInfo>(buf); + ReadSaveBuf(&Gang[i], buf); VALIDATESAVEBUF(size); } diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 28a4e989..4d80cac2 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -32,6 +32,7 @@ #include "Floater.h" #include "Range2D.h" #include "Wanted.h" +#include "SaveBuf.h" CPed *gapTempPedList[50]; uint16 gnNumTempPedList; @@ -47,10 +48,10 @@ bool CPed::bPedCheat2; bool CPed::bPedCheat3; CVector2D CPed::ms_vec2DFleePosition; -void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); } -void *CPed::operator new(size_t sz, int handle) { 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, int handle) { CPools::GetPedPool()->Delete((CPed*)p); } +void *CPed::operator new(size_t sz) throw() { return CPools::GetPedPool()->New(); } +void *CPed::operator new(size_t sz, int handle) throw() { return CPools::GetPedPool()->New(handle); } +void CPed::operator delete(void *p, size_t sz) throw() { CPools::GetPedPool()->Delete((CPed*)p); } +void CPed::operator delete(void *p, int handle) throw() { CPools::GetPedPool()->Delete((CPed*)p); } #ifdef DEBUGMENU bool CPed::bPopHeadsOnHeadshot = false; @@ -244,7 +245,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) bHasACamera = true; m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this); - DMAudio.SetEntityStatus(m_audioEntityId, true); + DMAudio.SetEntityStatus(m_audioEntityId, TRUE); m_fearFlags = CPedType::GetThreats(m_nPedType); m_threatEntity = nil; m_eventOrThreat = CVector2D(0.0f, 0.0f); @@ -307,6 +308,30 @@ CPed::~CPed(void) m_pFire->Extinguish(); CPopulation::UpdatePedCount((ePedType)m_nPedType, true); DMAudio.DestroyEntity(m_audioEntityId); + + // Because of the nature of ped lists in GTA, it can sometimes be outdated. + // Remove ourself from nearPeds list of the Peds in our nearPeds list. +#ifdef FIX_BUGS + for(int i = 0; i < m_numNearPeds; i++) { + CPed *nearPed = m_nearPeds[i]; + assert(nearPed != nil); + if (!nearPed->IsPointerValid()) + continue; + + for(int j = 0; j < nearPed->m_numNearPeds;) { + assert(j == ARRAY_SIZE(m_nearPeds) - 1 || nearPed->m_nearPeds[j] || !nearPed->m_nearPeds[j+1]); // ensure nil comes after nil + + if (nearPed->m_nearPeds[j] == this) { + for (int k = j; k < ARRAY_SIZE(m_nearPeds) - 1; k++) { + nearPed->m_nearPeds[k] = nearPed->m_nearPeds[k + 1]; + nearPed->m_nearPeds[k + 1] = nil; + } + nearPed->m_numNearPeds--; + } else + j++; + } + } +#endif } void @@ -397,13 +422,15 @@ CPed::BuildPedLists(void) } else removePed = true; } + + assert(i == ARRAY_SIZE(m_nearPeds) - 1 || m_nearPeds[i] || !m_nearPeds[i+1]); // ensure nil comes after nil + if (removePed) { // If we arrive here, the ped we're checking isn't "near", so we should remove it. for (int j = i; j < ARRAY_SIZE(m_nearPeds) - 1; j++) { m_nearPeds[j] = m_nearPeds[j + 1]; m_nearPeds[j + 1] = nil; } - // Above loop won't work on last slot, so we need to empty it. m_nearPeds[ARRAY_SIZE(m_nearPeds) - 1] = nil; m_numNearPeds--; } else @@ -2501,7 +2528,7 @@ CPed::ProcessControl(void) if (m_nPedState == PED_JUMP) { if (m_nWaitTimer <= 2000) { if (m_nWaitTimer < 1000) - m_nWaitTimer += CTimer::GetTimeStep() * 0.02f * 1000.0f; + m_nWaitTimer += CTimer::GetTimeStepInMilliseconds(); } else { m_nWaitTimer = 0; } @@ -2927,7 +2954,7 @@ CPed::ProcessControl(void) lDriveAssoc->blendAmount = 0.0f; if (rDriveAssoc) - rDriveAssoc->blendAmount = clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f); + rDriveAssoc->blendAmount = Clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f); else if (m_pMyVehicle->bLowVehicle) CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_CAR_DRIVE_RIGHT_LO); else @@ -2938,7 +2965,7 @@ CPed::ProcessControl(void) rDriveAssoc->blendAmount = 0.0f; if (lDriveAssoc) - lDriveAssoc->blendAmount = clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f); + lDriveAssoc->blendAmount = Clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f); else if (m_pMyVehicle->bLowVehicle) CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_STD_CAR_DRIVE_LEFT_LO); else @@ -3022,7 +3049,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) CColModel *hisCol = CModelInfo::GetModelInfo(collidingEnt->GetModelIndex())->GetColModel(); if (!bUsesCollision) - return false; + return 0; if (collidingEnt->IsVehicle() && ((CVehicle*)collidingEnt)->IsBoat()) collidedWithBoat = true; @@ -6067,7 +6094,7 @@ CPed::FollowPath(void) } void -CPed::SetEvasiveStep(CEntity *reason, uint8 animType) +CPed::SetEvasiveStep(CPhysical *reason, uint8 animType) { AnimationId stepAnim; @@ -6085,22 +6112,23 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) if (neededTurn > PI) neededTurn = TWOPI - neededTurn; - CVehicle *veh = (CVehicle*)reason; - if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR) { + if (reason->IsVehicle() && ((CVehicle*)reason)->IsCar()) { + CVehicle *veh = (CVehicle*)reason; if (veh->m_nCarHornTimer != 0) { vehPressedHorn = true; if (!IsPlayer()) animType = 1; } } - if (neededTurn <= DEGTORAD(90.0f) || veh->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) { - SetLookFlag(veh, true); - if ((CGeneral::GetRandomNumber() & 1) && veh->GetModelIndex() != MI_RCBANDIT && animType == 0) { + + if (neededTurn <= DEGTORAD(90.0f) || reason->GetModelIndex() == MI_RCBANDIT || vehPressedHorn || animType != 0) { + SetLookFlag(reason, true); + if ((CGeneral::GetRandomNumber() & 1) && reason->GetModelIndex() != MI_RCBANDIT && animType == 0) { stepAnim = ANIM_STD_HAILTAXI; } else { - float vehDirection = CGeneral::GetRadianAngleBetweenPoints( - veh->m_vecMoveSpeed.x, veh->m_vecMoveSpeed.y, + float dangerDirection = CGeneral::GetRadianAngleBetweenPoints( + reason->m_vecMoveSpeed.x, reason->m_vecMoveSpeed.y, 0.0f, 0.0f); // Let's turn our back to the "reason" @@ -6110,14 +6138,14 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) angleToFace -= TWOPI; // We don't want to run towards car's direction - float dangerZone = angleToFace - vehDirection; + float dangerZone = angleToFace - dangerDirection; dangerZone = CGeneral::LimitRadianAngle(dangerZone); // So, add or subtract 90deg (jump to left/right) according to that if (dangerZone > 0.0f) - angleToFace = vehDirection - HALFPI; + angleToFace = dangerDirection - HALFPI; else - angleToFace = vehDirection + HALFPI; + angleToFace = dangerDirection + HALFPI; stepAnim = ANIM_STD_NUM; if (animType == 0 || animType == 1) @@ -6983,14 +7011,21 @@ CPed::SetPedPositionInCar(void) } else { m_fRotationCur = m_pMyVehicle->GetForward().Heading(); } - GetMatrix() = newMat; + SetMatrix(newMat); } void CPed::LookForSexyPeds(void) { if ((!IsPedInControl() && m_nPedState != PED_DRIVING) - || m_lookTimer >= CTimer::GetTimeInMilliseconds() || m_nPedType != PEDTYPE_CIVMALE) + || m_lookTimer >= CTimer::GetTimeInMilliseconds() || +#ifdef FIX_BUGS + // gang members have these lines too + (!IsGangMember() && m_nPedType != PEDTYPE_CIVMALE) +#else + m_nPedType != PEDTYPE_CIVMALE +#endif + ) return; for (int i = 0; i < m_numNearPeds; i++) { @@ -6998,7 +7033,12 @@ CPed::LookForSexyPeds(void) if ((GetPosition() - m_nearPeds[i]->GetPosition()).Magnitude() < 10.0f) { CPed *nearPed = m_nearPeds[i]; if ((nearPed->m_pedStats->m_sexiness > m_pedStats->m_sexiness) +#ifdef FIX_BUGS + // react to prostitutes as well + && ((nearPed->m_nPedType == PEDTYPE_CIVFEMALE) || (nearPed->m_nPedType == PEDTYPE_PROSTITUTE))) { +#else && nearPed->m_nPedType == PEDTYPE_CIVFEMALE) { +#endif SetLookFlag(nearPed, true); m_lookTimer = CTimer::GetTimeInMilliseconds() + 4000; diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 0617a7bb..33839aa7 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -515,10 +515,10 @@ public: CVector m_vecSeekPosEx; // used for OBJECTIVE_GUARD_SPOT float m_distanceToCountSeekDoneEx; // used for OBJECTIVE_GUARD_SPOT - static void *operator new(size_t); - static void *operator new(size_t, int); - static void operator delete(void*, size_t); - static void operator delete(void*, int); + static void *operator new(size_t) throw(); + static void *operator new(size_t, int) throw(); + static void operator delete(void*, size_t) throw(); + static void operator delete(void*, int) throw(); CPed(uint32 pedType); ~CPed(void); @@ -625,7 +625,7 @@ public: void SetAimFlag(CEntity* to); void SetAimFlag(float angle); void SetAmmo(eWeaponType weaponType, uint32 ammo); - void SetEvasiveStep(CEntity*, uint8); + void SetEvasiveStep(CPhysical*, uint8); void GrantAmmo(eWeaponType, uint32); void SetEvasiveDive(CPhysical*, uint8); void SetAttack(CEntity*); diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp index 7f7120af..f1c753ec 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -5362,7 +5362,7 @@ CPed::WarpPedToNearLeaderOffScreen(void) continue; appropriatePos.z = zCorrectedPos.z; - if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f, &TheCamera.GetCameraMatrix()) + if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f) && CWorld::GetIsLineOfSightClear(appropriatePos, warpToPos, true, true, false, true, false, false, false) && !CWorld::TestSphereAgainstWorld(appropriatePos, 0.6f, this, true, true, false, true, false, false)) { teleported = true; @@ -5396,7 +5396,7 @@ CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo) continue; appropriatePos.z = zCorrectedPos.z; - if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f, &TheCamera.GetCameraMatrix()) + if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f) && CWorld::GetIsLineOfSightClear(appropriatePos, warpToPos, true, true, false, true, false, false, false) && !CWorld::TestSphereAgainstWorld(appropriatePos, 0.6f, this, true, true, false, true, false, false)) { teleported = true; diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index c03d492a..46ac369c 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -1044,7 +1044,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) if (IsPlayer()) moveAssoc->speed = 1.3f; - m_takeAStepAfterAttack = 0; + m_takeAStepAfterAttack = false; m_fightButtonPressure = 0; } else if (IsPlayer() && m_currentWeapon != WEAPONTYPE_UNARMED) { CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f); diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index 8bace9a0..8358a196 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -17,9 +17,9 @@ const RwV3d XaxisIK = { 1.0f, 0.0f, 0.0f}; const RwV3d YaxisIK = { 0.0f, 1.0f, 0.0f}; const RwV3d ZaxisIK = { 0.0f, 0.0f, 1.0f}; -CPedIK::CPedIK(CPed *ped) +CPedIK::CPedIK(CPed *ped) : m_ped(ped) { - m_ped = ped; + assert(ped != nil); m_flags = 0; m_headOrient.yaw = 0.0f; m_headOrient.pitch = 0.0f; @@ -194,7 +194,7 @@ CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, Limb } if (limb.yaw > moveInfo.maxYaw || limb.yaw < moveInfo.minYaw) { - limb.yaw = clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw); + limb.yaw = Clamp(limb.yaw, moveInfo.minYaw, moveInfo.maxYaw); result = ANGLES_SET_TO_MAX; } @@ -212,7 +212,7 @@ CPedIK::MoveLimb(LimbOrientation &limb, float targetYaw, float targetPitch, Limb result = ONE_ANGLE_COULDNT_BE_SET_EXACTLY; if (limb.pitch > moveInfo.maxPitch || limb.pitch < moveInfo.minPitch) { - limb.pitch = clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch); + limb.pitch = Clamp(limb.pitch, moveInfo.minPitch, moveInfo.maxPitch); result = ANGLES_SET_TO_MAX; } return result; @@ -527,11 +527,11 @@ CPedIK::RestoreLookAt(void) void CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch) { - float f = clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f); + float f = Clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f); *yaw = Acos(f); if (mat->up.x > 0.0f) *yaw = -*yaw; - f = clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); + f = Clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); *pitch = Acos(f); if (mat->up.z > 0.0f) *pitch = -*pitch; } @@ -539,11 +539,11 @@ CPedIK::ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch) void CPedIK::ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch) { - float f = clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); + float f = Clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f); *yaw = Acos(f); if (mat->at.y > 0.0f) *yaw = -*yaw; - f = clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f); + f = Clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f); *pitch = Acos(f); if (mat->up.x > 0.0f) *pitch = -*pitch; } diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h index 4eeef6f0..9077fbea 100644 --- a/src/peds/PedIK.h +++ b/src/peds/PedIK.h @@ -34,7 +34,7 @@ public: AIMS_WITH_ARM = 4, }; - CPed *m_ped; + CPed *Const m_ped; LimbOrientation m_headOrient; LimbOrientation m_torsoOrient; LimbOrientation m_upperArmOrient; diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index bacb1a78..dcd4c717 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -3,6 +3,7 @@ #include "General.h" #include "FileMgr.h" #include "PedType.h" +#include "SaveBuf.h" CPedType *CPedType::ms_apPedType[NUM_PEDTYPES]; CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS]; @@ -201,7 +202,7 @@ INITSAVEBUF CheckSaveHeader(buf, 'P', 'T', 'P', '\0', size - SAVE_HEADER_SIZE); for(int i = 0; i < NUM_PEDTYPES; i++) - *ms_apPedType[i] = ReadSaveBuf<CPedType>(buf); + ReadSaveBuf(ms_apPedType[i], buf); VALIDATESAVEBUF(size) } diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 53187d0b..93a403bd 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -16,6 +16,7 @@ #include "Pools.h" #include "Darkel.h" #include "CarCtrl.h" +#include "SaveBuf.h" #define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f @@ -681,8 +682,8 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed) if (padMove > 0.0f) { m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation; - m_takeAStepAfterAttack = padMove > 2 * PAD_MOVE_TO_GAME_WORLD_MOVE; - if (padUsed->GetSprint() && padMove > 1 * PAD_MOVE_TO_GAME_WORLD_MOVE) + m_takeAStepAfterAttack = padMove > (2 * PAD_MOVE_TO_GAME_WORLD_MOVE); + if (padUsed->GetSprint() && padMove > (1 * PAD_MOVE_TO_GAME_WORLD_MOVE)) bIsAttacking = false; } @@ -714,7 +715,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed) if (m_nPedState == PED_JUMP) { if (bIsInTheAir) { if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f) - && m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) { + && m_fDistanceTravelled < CTimer::GetTimeStepInSeconds() && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) { float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O float angleCos = Cos(m_fRotationCur); @@ -1205,7 +1206,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed) if (m_nPedState == PED_JUMP) { if (bIsInTheAir) { if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f) - && m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) { + && m_fDistanceTravelled < CTimer::GetTimeStepInSeconds() && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) { float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O float angleCos = Cos(m_fRotationCur); diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index a0bf8be6..ace6d37c 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -484,7 +484,7 @@ CPopulation::PedCreationDistMultiplier() return 1.0f; float vehSpeed = veh->m_vecMoveSpeed.Magnitude2D(); - return clamp(vehSpeed - 0.1f + 1.0f, 1.0f, 1.5f); + return Clamp(vehSpeed - 0.1f + 1.0f, 1.0f, 1.5f); } CPed* @@ -706,8 +706,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree generatedCoors.z = Max(generatedCoors.z, groundZ); } bool farEnoughToAdd = true; - CMatrix mat(TheCamera.GetCameraMatrix()); - if (TheCamera.IsSphereVisible(generatedCoors, 2.0f, &mat)) { + if (TheCamera.IsSphereVisible(generatedCoors, 2.0f)) { if (PedCreationDistMultiplier() * MIN_CREATION_DIST > (generatedCoors - playerCentreOfWorld).Magnitude2D()) farEnoughToAdd = false; } @@ -945,10 +944,9 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones() void CPopulation::ConvertAllObjectsToDummyObjects() { - int poolSize = CPools::GetObjectPool()->GetSize(); - for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { - - CObject *obj = CPools::GetObjectPool()->GetSlot(poolIndex); + uint32 i = CPools::GetObjectPool()->GetSize(); + while(i--) { + CObject *obj = CPools::GetObjectPool()->GetSlot(i); if (obj) { if (obj->CanBeDeleted()) ConvertToDummyObject(obj); @@ -1012,27 +1010,30 @@ CPopulation::TestSafeForRealObject(CDummyObject *dummy) { CPtrNode *ptrNode; CColModel *dummyCol = dummy->GetColModel(); - float colRadius = dummy->GetBoundRadius(); - CVector colCentre = dummy->GetBoundCentre(); - int minX = CWorld::GetSectorIndexX(dummy->GetPosition().x - colRadius); + float radius = dummyCol->boundingSphere.radius; + int minX = CWorld::GetSectorIndexX(dummy->GetPosition().x - radius); if (minX < 0) minX = 0; - int minY = CWorld::GetSectorIndexY(dummy->GetPosition().y - colRadius); + int minY = CWorld::GetSectorIndexY(dummy->GetPosition().y - radius); if (minY < 0) minY = 0; - int maxX = CWorld::GetSectorIndexX(dummy->GetPosition().x + colRadius); + int maxX = CWorld::GetSectorIndexX(dummy->GetPosition().x + radius); #ifdef FIX_BUGS if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1; #else if (maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X; #endif - int maxY = CWorld::GetSectorIndexY(dummy->GetPosition().y + colRadius); + int maxY = CWorld::GetSectorIndexY(dummy->GetPosition().y + radius); #ifdef FIX_BUGS if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1; #else if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y; #endif + float colRadius = dummy->GetBoundRadius(); + CVUVECTOR colCentre; + dummy->GetBoundCentre(colCentre); + static CColPoint aTempColPoints[MAX_COLLISION_POINTS]; for (int curY = minY; curY <= maxY; curY++) { |