some work on zones
This commit is contained in:
parent
edd9301d7f
commit
cbfc45b3f7
@ -306,7 +306,7 @@ cAudioManager::SetupCrimeReport()
|
|||||||
if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return false;
|
if (i == ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) return false;
|
||||||
audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position);
|
audioZoneId = CTheZones::FindAudioZone(&m_sPoliceRadioQueue.crimes[i].position);
|
||||||
if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) {
|
if (audioZoneId >= 0 && audioZoneId < NUMAUDIOZONES) {
|
||||||
zone = &CTheZones::ZoneArray[CTheZones::AudioZoneArray[audioZoneId]];
|
zone = CTheZones::GetAudioZone(audioZoneId);
|
||||||
for (int j = 0; j < NUMAUDIOZONES; j++) {
|
for (int j = 0; j < NUMAUDIOZONES; j++) {
|
||||||
if (strcmp(zone->name, ZoneSfx[j].m_aName) == 0) {
|
if (strcmp(zone->name, ZoneSfx[j].m_aName) == 0) {
|
||||||
sampleIndex = ZoneSfx[j].m_nSampleIndex;
|
sampleIndex = ZoneSfx[j].m_nSampleIndex;
|
||||||
@ -722,7 +722,7 @@ cAudioManager::PlaySuspectLastSeen(float x, float y, float z)
|
|||||||
if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) {
|
if (MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && 60 - m_sPoliceRadioQueue.policeChannelTimer > 9) {
|
||||||
audioZone = CTheZones::FindAudioZone(&vec);
|
audioZone = CTheZones::FindAudioZone(&vec);
|
||||||
if (audioZone >= 0 && audioZone < NUMAUDIOZONES) {
|
if (audioZone >= 0 && audioZone < NUMAUDIOZONES) {
|
||||||
zone = &CTheZones::ZoneArray[CTheZones::AudioZoneArray[audioZone]];
|
zone = CTheZones::GetAudioZone(audioZone);
|
||||||
for (int i = 0; i < NUMAUDIOZONES; i++) {
|
for (int i = 0; i < NUMAUDIOZONES; i++) {
|
||||||
if (strcmp(zone->name, ZoneSfx[i].m_aName) == 0) {
|
if (strcmp(zone->name, ZoneSfx[i].m_aName) == 0) {
|
||||||
sample = ZoneSfx[i].m_nSampleIndex;
|
sample = ZoneSfx[i].m_nSampleIndex;
|
||||||
|
@ -987,7 +987,7 @@ void CReplay::FinishPlayback(void)
|
|||||||
Mode = MODE_RECORD;
|
Mode = MODE_RECORD;
|
||||||
if (bDoLoadSceneWhenDone){
|
if (bDoLoadSceneWhenDone){
|
||||||
CVector v_ls(LoadSceneX, LoadSceneY, LoadSceneZ);
|
CVector v_ls(LoadSceneX, LoadSceneY, LoadSceneZ);
|
||||||
CGame::currLevel = CTheZones::GetLevelFromPosition(v_ls);
|
CGame::currLevel = CTheZones::GetLevelFromPosition(&v_ls);
|
||||||
CCollision::SortOutCollisionAfterLoad();
|
CCollision::SortOutCollisionAfterLoad();
|
||||||
CStreaming::LoadScene(v_ls);
|
CStreaming::LoadScene(v_ls);
|
||||||
}
|
}
|
||||||
@ -1101,7 +1101,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
|
|||||||
LoadSceneZ = TheCamera.GetPosition().z;
|
LoadSceneZ = TheCamera.GetPosition().z;
|
||||||
CVector ff_coord;
|
CVector ff_coord;
|
||||||
FindFirstFocusCoordinate(&ff_coord);
|
FindFirstFocusCoordinate(&ff_coord);
|
||||||
CGame::currLevel = CTheZones::GetLevelFromPosition(ff_coord);
|
CGame::currLevel = CTheZones::GetLevelFromPosition(&ff_coord);
|
||||||
CCollision::SortOutCollisionAfterLoad();
|
CCollision::SortOutCollisionAfterLoad();
|
||||||
CStreaming::LoadScene(ff_coord);
|
CStreaming::LoadScene(ff_coord);
|
||||||
}
|
}
|
||||||
|
@ -1729,7 +1729,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
|
|||||||
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
||||||
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
||||||
CWorld::Add(ped);
|
CWorld::Add(ped);
|
||||||
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
|
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
CPopulation::ms_nTotalMissionPeds++;
|
CPopulation::ms_nTotalMissionPeds++;
|
||||||
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
|
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
|
||||||
StoreParameters(&m_nIp, 1);
|
StoreParameters(&m_nIp, 1);
|
||||||
@ -1968,7 +1968,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
|
|||||||
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
|
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
|
||||||
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
|
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
|
||||||
car->bEngineOn = false;
|
car->bEngineOn = false;
|
||||||
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
|
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
car->bHasBeenOwnedByPlayer = true;
|
car->bHasBeenOwnedByPlayer = true;
|
||||||
CWorld::Add(car);
|
CWorld::Add(car);
|
||||||
handle = CPools::GetVehiclePool()->GetIndex(car);
|
handle = CPools::GetVehiclePool()->GetIndex(car);
|
||||||
@ -2674,7 +2674,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
|
|||||||
m_nIp += KEY_LENGTH_IN_SCRIPT; /* why only if zone != 1? */
|
m_nIp += KEY_LENGTH_IN_SCRIPT; /* why only if zone != 1? */
|
||||||
CVector pos = pPlayer->GetPos();
|
CVector pos = pPlayer->GetPos();
|
||||||
CZone* pZone = CTheZones::GetZone(zoneToCheck);
|
CZone* pZone = CTheZones::GetZone(zoneToCheck);
|
||||||
UpdateCompareFlag(CTheZones::PointLiesWithinZone(pos, pZone));
|
UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, pZone));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case COMMAND_IS_PLAYER_PRESSING_HORN:
|
case COMMAND_IS_PLAYER_PRESSING_HORN:
|
||||||
@ -2773,7 +2773,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
|
|||||||
#endif
|
#endif
|
||||||
pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f);
|
pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f);
|
||||||
pPed->StopNonPartialAnims();
|
pPed->StopNonPartialAnims();
|
||||||
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
|
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
|
||||||
CWorld::Add(pPed);
|
CWorld::Add(pPed);
|
||||||
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
|
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
|
||||||
StoreParameters(&m_nIp, 1);
|
StoreParameters(&m_nIp, 1);
|
||||||
@ -3026,7 +3026,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
|
|||||||
if (zone != -1)
|
if (zone != -1)
|
||||||
m_nIp += KEY_LENGTH_IN_SCRIPT;
|
m_nIp += KEY_LENGTH_IN_SCRIPT;
|
||||||
CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
|
CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
|
||||||
UpdateCompareFlag(CTheZones::PointLiesWithinZone(pos, CTheZones::GetZone(zone)));
|
UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, CTheZones::GetZone(zone)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case COMMAND_SET_CAR_DENSITY:
|
case COMMAND_SET_CAR_DENSITY:
|
||||||
@ -3964,7 +3964,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
|
|||||||
#endif
|
#endif
|
||||||
pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f);
|
pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f);
|
||||||
pPed->StopNonPartialAnims();
|
pPed->StopNonPartialAnims();
|
||||||
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
|
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
|
||||||
CWorld::Add(pPed);
|
CWorld::Add(pPed);
|
||||||
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
|
ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
|
||||||
StoreParameters(&m_nIp, 1);
|
StoreParameters(&m_nIp, 1);
|
||||||
@ -5880,7 +5880,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
|
|||||||
continue;
|
continue;
|
||||||
if (pPed->bIsLeader || pPed->m_leader)
|
if (pPed->bIsLeader || pPed->m_leader)
|
||||||
continue;
|
continue;
|
||||||
if (!CTheZones::PointLiesWithinZone(pPed->GetPosition(), pZone))
|
if (!CTheZones::PointLiesWithinZone(&pPed->GetPosition(), pZone))
|
||||||
continue;
|
continue;
|
||||||
if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
|
if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
|
||||||
continue;
|
continue;
|
||||||
@ -6536,7 +6536,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
|
|||||||
continue;
|
continue;
|
||||||
if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE)
|
if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE)
|
||||||
continue;
|
continue;
|
||||||
if (!CTheZones::PointLiesWithinZone(pVehicle->GetPosition(), pZone))
|
if (!CTheZones::PointLiesWithinZone(&pVehicle->GetPosition(), pZone))
|
||||||
continue;
|
continue;
|
||||||
handle = CPools::GetVehiclePool()->GetIndex(pVehicle);
|
handle = CPools::GetVehiclePool()->GetIndex(pVehicle);
|
||||||
pVehicle->VehicleCreatedBy = MISSION_VEHICLE;
|
pVehicle->VehicleCreatedBy = MISSION_VEHICLE;
|
||||||
@ -7347,7 +7347,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
|
|||||||
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
||||||
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
||||||
CWorld::Add(ped);
|
CWorld::Add(ped);
|
||||||
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
|
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
CPopulation::ms_nTotalMissionPeds++;
|
CPopulation::ms_nTotalMissionPeds++;
|
||||||
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
|
ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
|
||||||
StoreParameters(&m_nIp, 1);
|
StoreParameters(&m_nIp, 1);
|
||||||
@ -8178,7 +8178,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
|
|||||||
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
|
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
|
||||||
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
|
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
|
||||||
car->bEngineOn = false;
|
car->bEngineOn = false;
|
||||||
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
|
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
CWorld::Add(car);
|
CWorld::Add(car);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -8504,7 +8504,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
|
|||||||
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
|
||||||
assert(pVehicle);
|
assert(pVehicle);
|
||||||
if (ScriptParams[1])
|
if (ScriptParams[1])
|
||||||
pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(pVehicle->GetPosition());
|
pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition());
|
||||||
else
|
else
|
||||||
pVehicle->m_nZoneLevel = LEVEL_NONE;
|
pVehicle->m_nZoneLevel = LEVEL_NONE;
|
||||||
return 0;
|
return 0;
|
||||||
@ -8515,7 +8515,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
|
|||||||
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
|
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
|
||||||
assert(pPed);
|
assert(pPed);
|
||||||
if (ScriptParams[1])
|
if (ScriptParams[1])
|
||||||
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
|
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
|
||||||
else
|
else
|
||||||
pPed->m_nZoneLevel = LEVEL_NONE;
|
pPed->m_nZoneLevel = LEVEL_NONE;
|
||||||
return 0;
|
return 0;
|
||||||
@ -8920,7 +8920,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
|
|||||||
if (ScriptParams[1])
|
if (ScriptParams[1])
|
||||||
pPed->m_nZoneLevel = LEVEL_IGNORE;
|
pPed->m_nZoneLevel = LEVEL_IGNORE;
|
||||||
else
|
else
|
||||||
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(pPed->GetPosition());
|
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case COMMAND_GET_CHASE_CAR:
|
case COMMAND_GET_CHASE_CAR:
|
||||||
@ -9119,7 +9119,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
|
|||||||
if (ScriptParams[1])
|
if (ScriptParams[1])
|
||||||
pVehicle->m_nZoneLevel = LEVEL_IGNORE;
|
pVehicle->m_nZoneLevel = LEVEL_IGNORE;
|
||||||
else
|
else
|
||||||
pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(pVehicle->GetPosition());
|
pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case COMMAND_MAKE_CRAIGS_CAR_A_BIT_STRONGER:
|
case COMMAND_MAKE_CRAIGS_CAR_A_BIT_STRONGER:
|
||||||
@ -9465,7 +9465,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
|
|||||||
continue;
|
continue;
|
||||||
if (pPed->bIsLeader || pPed->m_leader)
|
if (pPed->bIsLeader || pPed->m_leader)
|
||||||
continue;
|
continue;
|
||||||
if (!CTheZones::PointLiesWithinZone(pPed->GetPosition(), pZone))
|
if (!CTheZones::PointLiesWithinZone(&pPed->GetPosition(), pZone))
|
||||||
continue;
|
continue;
|
||||||
if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
|
if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1088,7 +1088,7 @@ CFileLoader::LoadObjectInstance(const char *line)
|
|||||||
entity = new CBuilding;
|
entity = new CBuilding;
|
||||||
entity->SetModelIndexNoCreate(id);
|
entity->SetModelIndexNoCreate(id);
|
||||||
entity->GetMatrix() = CMatrix(xform);
|
entity->GetMatrix() = CMatrix(xform);
|
||||||
entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
|
entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
|
||||||
if(mi->IsSimple()){
|
if(mi->IsSimple()){
|
||||||
if(mi->m_isBigBuilding)
|
if(mi->m_isBigBuilding)
|
||||||
entity->SetupBigBuilding();
|
entity->SetupBigBuilding();
|
||||||
@ -1105,7 +1105,7 @@ CFileLoader::LoadObjectInstance(const char *line)
|
|||||||
CWorld::Add(entity);
|
CWorld::Add(entity);
|
||||||
if(IsGlass(entity->GetModelIndex()))
|
if(IsGlass(entity->GetModelIndex()))
|
||||||
entity->bIsVisible = false;
|
entity->bIsVisible = false;
|
||||||
entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition());
|
entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
RwMatrixDestroy(xform);
|
RwMatrixDestroy(xform);
|
||||||
|
@ -2422,7 +2422,7 @@ CStreaming::LoadScene(const CVector &pos)
|
|||||||
CStreamingInfo *si, *prev;
|
CStreamingInfo *si, *prev;
|
||||||
eLevelName level;
|
eLevelName level;
|
||||||
|
|
||||||
level = CTheZones::GetLevelFromPosition(pos);
|
level = CTheZones::GetLevelFromPosition(&pos);
|
||||||
debug("Start load scene\n");
|
debug("Start load scene\n");
|
||||||
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
|
for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){
|
||||||
prev = si->m_prev;
|
prev = si->m_prev;
|
||||||
|
@ -32,15 +32,15 @@ void
|
|||||||
CPlaceName::Process()
|
CPlaceName::Process()
|
||||||
{
|
{
|
||||||
CVector pos = CWorld::Players[CWorld::PlayerInFocus].GetPos();
|
CVector pos = CWorld::Players[CWorld::PlayerInFocus].GetPos();
|
||||||
CZone *navigZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_TYPE1);
|
CZone *navigZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_NAVIG);
|
||||||
CZone *audioZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_AUDIO);
|
CZone *defaultZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_DEFAULT);
|
||||||
|
|
||||||
if (navigZone == nil) m_pZone = nil;
|
if (navigZone == nil) m_pZone = nil;
|
||||||
if (audioZone == nil) m_pZone2 = nil;
|
if (defaultZone == nil) m_pZone2 = nil;
|
||||||
|
|
||||||
if (navigZone == m_pZone) {
|
if (navigZone == m_pZone) {
|
||||||
if (audioZone == m_pZone2 || m_pZone != nil) {
|
if (defaultZone == m_pZone2 || m_pZone != nil) {
|
||||||
if (navigZone != nil || audioZone != nil) {
|
if (navigZone != nil || defaultZone != nil) {
|
||||||
if (m_nAdditionalTimer != 0)
|
if (m_nAdditionalTimer != 0)
|
||||||
m_nAdditionalTimer--;
|
m_nAdditionalTimer--;
|
||||||
} else {
|
} else {
|
||||||
@ -49,7 +49,7 @@ CPlaceName::Process()
|
|||||||
m_pZone2 = nil;
|
m_pZone2 = nil;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_pZone2 = audioZone;
|
m_pZone2 = defaultZone;
|
||||||
m_nAdditionalTimer = 250;
|
m_nAdditionalTimer = 250;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -533,7 +533,7 @@ CCullZone::IsEntityCloseEnoughToZone(CEntity *entity, bool checkLevel)
|
|||||||
|
|
||||||
if (lodDist > distToZone) return true;
|
if (lodDist > distToZone) return true;
|
||||||
if (!checkLevel) return false;
|
if (!checkLevel) return false;
|
||||||
return CTheZones::GetLevelFromPosition(pos) == CTheZones::GetLevelFromPosition(CVector(minx, miny, minz));
|
return CTheZones::GetLevelFromPosition(&pos) == CTheZones::GetLevelFromPosition(&CVector(minx, miny, minz));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -23,6 +23,8 @@ CZoneInfo CTheZones::ZoneInfoArray[2*NUMZONES];
|
|||||||
|
|
||||||
#define SWAPF(a, b) { float t; t = a; a = b; b = t; }
|
#define SWAPF(a, b) { float t; t = a; a = b; b = t; }
|
||||||
|
|
||||||
|
inline bool IsNormalZone(int type) { return type == ZONE_DEFAULT || type == ZONE_NAVIG || type == ZONE_INFO; }
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CheckZoneInfo(CZoneInfo *info)
|
CheckZoneInfo(CZoneInfo *info)
|
||||||
{
|
{
|
||||||
@ -58,6 +60,9 @@ CTheZones::Init(void)
|
|||||||
AudioZoneArray[i] = -1;
|
AudioZoneArray[i] = -1;
|
||||||
NumberOfAudioZones = 0;
|
NumberOfAudioZones = 0;
|
||||||
|
|
||||||
|
for(i = 0; i < NUMZONES; i++)
|
||||||
|
memset(&ZoneArray[i], 0, sizeof(CZone));
|
||||||
|
|
||||||
CZoneInfo *zonei;
|
CZoneInfo *zonei;
|
||||||
int x = 1000/6;
|
int x = 1000/6;
|
||||||
for(i = 0; i < 2*NUMZONES; i++){
|
for(i = 0; i < 2*NUMZONES; i++){
|
||||||
@ -81,10 +86,13 @@ CTheZones::Init(void)
|
|||||||
zonei->gangThreshold[8] = zonei->gangThreshold[7];
|
zonei->gangThreshold[8] = zonei->gangThreshold[7];
|
||||||
CheckZoneInfo(zonei);
|
CheckZoneInfo(zonei);
|
||||||
}
|
}
|
||||||
TotalNumberOfZoneInfos = 1; // why 1?
|
|
||||||
|
|
||||||
for(i = 0; i < NUMZONES; i++)
|
TotalNumberOfZoneInfos = 1; // why 1?
|
||||||
memset(&ZoneArray[i], 0, sizeof(CZone));
|
TotalNumberOfZones = 1;
|
||||||
|
|
||||||
|
m_CurrLevel = LEVEL_NONE;
|
||||||
|
m_pPlayersZone = &ZoneArray[0];
|
||||||
|
|
||||||
strcpy(ZoneArray[0].name, "CITYZON");
|
strcpy(ZoneArray[0].name, "CITYZON");
|
||||||
ZoneArray[0].minx = -4000.0f;
|
ZoneArray[0].minx = -4000.0f;
|
||||||
ZoneArray[0].miny = -4000.0f;
|
ZoneArray[0].miny = -4000.0f;
|
||||||
@ -93,15 +101,14 @@ CTheZones::Init(void)
|
|||||||
ZoneArray[0].maxy = 4000.0f;
|
ZoneArray[0].maxy = 4000.0f;
|
||||||
ZoneArray[0].maxz = 500.0f;
|
ZoneArray[0].maxz = 500.0f;
|
||||||
ZoneArray[0].level = LEVEL_NONE;
|
ZoneArray[0].level = LEVEL_NONE;
|
||||||
TotalNumberOfZones = 1;
|
|
||||||
|
|
||||||
m_CurrLevel = LEVEL_NONE;
|
|
||||||
m_pPlayersZone = &ZoneArray[0];
|
|
||||||
|
|
||||||
for(i = 0; i < NUMMAPZONES; i++){
|
for(i = 0; i < NUMMAPZONES; i++){
|
||||||
memset(&MapZoneArray[i], 0, sizeof(CZone));
|
memset(&MapZoneArray[i], 0, sizeof(CZone));
|
||||||
MapZoneArray[i].type = ZONE_MAPZONE;
|
MapZoneArray[i].type = ZONE_MAPZONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TotalNumberOfMapZones = 1;
|
||||||
|
|
||||||
strcpy(MapZoneArray[0].name, "THEMAP");
|
strcpy(MapZoneArray[0].name, "THEMAP");
|
||||||
MapZoneArray[0].minx = -4000.0f;
|
MapZoneArray[0].minx = -4000.0f;
|
||||||
MapZoneArray[0].miny = -4000.0f;
|
MapZoneArray[0].miny = -4000.0f;
|
||||||
@ -110,7 +117,6 @@ CTheZones::Init(void)
|
|||||||
MapZoneArray[0].maxy = 4000.0f;
|
MapZoneArray[0].maxy = 4000.0f;
|
||||||
MapZoneArray[0].maxz = 500.0f;
|
MapZoneArray[0].maxz = 500.0f;
|
||||||
MapZoneArray[0].level = LEVEL_NONE;
|
MapZoneArray[0].level = LEVEL_NONE;
|
||||||
TotalNumberOfMapZones = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -119,7 +125,7 @@ CTheZones::Update(void)
|
|||||||
CVector pos;
|
CVector pos;
|
||||||
pos = FindPlayerCoors();
|
pos = FindPlayerCoors();
|
||||||
m_pPlayersZone = FindSmallestZonePosition(&pos);
|
m_pPlayersZone = FindSmallestZonePosition(&pos);
|
||||||
m_CurrLevel = GetLevelFromPosition(pos);
|
m_CurrLevel = GetLevelFromPosition(&pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -128,8 +134,8 @@ CTheZones::CreateZone(char *name, eZoneType type,
|
|||||||
float maxx, float maxy, float maxz,
|
float maxx, float maxy, float maxz,
|
||||||
eLevelName level)
|
eLevelName level)
|
||||||
{
|
{
|
||||||
CZone *zone;
|
|
||||||
char *p;
|
char *p;
|
||||||
|
char tmpname[8];
|
||||||
|
|
||||||
if(minx > maxx) SWAPF(minx, maxx);
|
if(minx > maxx) SWAPF(minx, maxx);
|
||||||
if(miny > maxy) SWAPF(miny, maxy);
|
if(miny > maxy) SWAPF(miny, maxy);
|
||||||
@ -139,21 +145,22 @@ CTheZones::CreateZone(char *name, eZoneType type,
|
|||||||
for(p = name; *p; p++) if(islower(*p)) *p = toupper(*p);
|
for(p = name; *p; p++) if(islower(*p)) *p = toupper(*p);
|
||||||
|
|
||||||
// add zone
|
// add zone
|
||||||
zone = &ZoneArray[TotalNumberOfZones++];
|
strncpy(tmpname, name, 7);
|
||||||
strncpy(zone->name, name, 7);
|
tmpname[7] = '\0';
|
||||||
zone->name[7] = '\0';
|
strcpy(ZoneArray[TotalNumberOfZones].name, tmpname);
|
||||||
zone->type = type;
|
ZoneArray[TotalNumberOfZones].type = type;
|
||||||
zone->minx = minx;
|
ZoneArray[TotalNumberOfZones].minx = minx;
|
||||||
zone->miny = miny;
|
ZoneArray[TotalNumberOfZones].miny = miny;
|
||||||
zone->minz = minz;
|
ZoneArray[TotalNumberOfZones].minz = minz;
|
||||||
zone->maxx = maxx;
|
ZoneArray[TotalNumberOfZones].maxx = maxx;
|
||||||
zone->maxy = maxy;
|
ZoneArray[TotalNumberOfZones].maxy = maxy;
|
||||||
zone->maxz = maxz;
|
ZoneArray[TotalNumberOfZones].maxz = maxz;
|
||||||
zone->level = level;
|
ZoneArray[TotalNumberOfZones].level = level;
|
||||||
if(type == ZONE_AUDIO || type == ZONE_TYPE1 || type == ZONE_TYPE2){
|
if(IsNormalZone(type)){
|
||||||
zone->zoneinfoDay = TotalNumberOfZoneInfos++;
|
ZoneArray[TotalNumberOfZones].zoneinfoDay = TotalNumberOfZoneInfos++;
|
||||||
zone->zoneinfoNight = TotalNumberOfZoneInfos++;
|
ZoneArray[TotalNumberOfZones].zoneinfoNight = TotalNumberOfZoneInfos++;
|
||||||
}
|
}
|
||||||
|
TotalNumberOfZones++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -259,11 +266,11 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
|
|||||||
inner->minz < outer->minz ||
|
inner->minz < outer->minz ||
|
||||||
inner->maxz > outer->maxz){
|
inner->maxz > outer->maxz){
|
||||||
CVector vmin(inner->minx, inner->miny, inner->minz);
|
CVector vmin(inner->minx, inner->miny, inner->minz);
|
||||||
if(PointLiesWithinZone(vmin, outer))
|
if(PointLiesWithinZone(&vmin, outer))
|
||||||
sprintf(tmp, "Overlapping zones %s and %s\n",
|
sprintf(tmp, "Overlapping zones %s and %s\n",
|
||||||
inner->name, outer->name);
|
inner->name, outer->name);
|
||||||
CVector vmax(inner->maxx, inner->maxy, inner->maxz);
|
CVector vmax(inner->maxx, inner->maxy, inner->maxz);
|
||||||
if(PointLiesWithinZone(vmax, outer))
|
if(PointLiesWithinZone(&vmax, outer))
|
||||||
sprintf(tmp, "Overlapping zones %s and %s\n",
|
sprintf(tmp, "Overlapping zones %s and %s\n",
|
||||||
inner->name, outer->name);
|
inner->name, outer->name);
|
||||||
return false;
|
return false;
|
||||||
@ -272,15 +279,15 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CTheZones::PointLiesWithinZone(const CVector &v, CZone *zone)
|
CTheZones::PointLiesWithinZone(const CVector *v, CZone *zone)
|
||||||
{
|
{
|
||||||
return zone->minx <= v.x && v.x <= zone->maxx &&
|
return zone->minx <= v->x && v->x <= zone->maxx &&
|
||||||
zone->miny <= v.y && v.y <= zone->maxy &&
|
zone->miny <= v->y && v->y <= zone->maxy &&
|
||||||
zone->minz <= v.z && v.z <= zone->maxz;
|
zone->minz <= v->z && v->z <= zone->maxz;
|
||||||
}
|
}
|
||||||
|
|
||||||
eLevelName
|
eLevelName
|
||||||
CTheZones::GetLevelFromPosition(CVector const &v)
|
CTheZones::GetLevelFromPosition(CVector const *v)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
// char tmp[116];
|
// char tmp[116];
|
||||||
@ -300,7 +307,7 @@ CTheZones::FindSmallestZonePosition(const CVector *v)
|
|||||||
CZone *zone = ZoneArray[0].child;
|
CZone *zone = ZoneArray[0].child;
|
||||||
while(zone)
|
while(zone)
|
||||||
// if in zone, descent into children
|
// if in zone, descent into children
|
||||||
if(PointLiesWithinZone(*v, zone)){
|
if(PointLiesWithinZone(v, zone)){
|
||||||
best = zone;
|
best = zone;
|
||||||
zone = zone->child;
|
zone = zone->child;
|
||||||
// otherwise try next zone
|
// otherwise try next zone
|
||||||
@ -319,7 +326,7 @@ CTheZones::FindSmallestZonePositionType(const CVector *v, eZoneType type)
|
|||||||
CZone *zone = ZoneArray[0].child;
|
CZone *zone = ZoneArray[0].child;
|
||||||
while(zone)
|
while(zone)
|
||||||
// if in zone, descent into children
|
// if in zone, descent into children
|
||||||
if(PointLiesWithinZone(*v, zone)){
|
if(PointLiesWithinZone(v, zone)){
|
||||||
if(zone->type == type)
|
if(zone->type == type)
|
||||||
best = zone;
|
best = zone;
|
||||||
zone = zone->child;
|
zone = zone->child;
|
||||||
@ -333,18 +340,14 @@ CZone*
|
|||||||
CTheZones::FindSmallestZonePositionILN(const CVector *v)
|
CTheZones::FindSmallestZonePositionILN(const CVector *v)
|
||||||
{
|
{
|
||||||
CZone *best = nil;
|
CZone *best = nil;
|
||||||
if(ZoneArray[0].type == ZONE_AUDIO ||
|
if(IsNormalZone(ZoneArray[0].type))
|
||||||
ZoneArray[0].type == ZONE_TYPE1 ||
|
|
||||||
ZoneArray[0].type == ZONE_TYPE2)
|
|
||||||
best = &ZoneArray[0];
|
best = &ZoneArray[0];
|
||||||
// zone to test next
|
// zone to test next
|
||||||
CZone *zone = ZoneArray[0].child;
|
CZone *zone = ZoneArray[0].child;
|
||||||
while(zone)
|
while(zone)
|
||||||
// if in zone, descent into children
|
// if in zone, descent into children
|
||||||
if(PointLiesWithinZone(*v, zone)){
|
if(PointLiesWithinZone(v, zone)){
|
||||||
if(zone->type == ZONE_AUDIO ||
|
if(IsNormalZone(zone->type))
|
||||||
zone->type == ZONE_TYPE1 ||
|
|
||||||
zone->type == ZONE_TYPE2)
|
|
||||||
best = zone;
|
best = zone;
|
||||||
zone = zone->child;
|
zone = zone->child;
|
||||||
// otherwise try next zone
|
// otherwise try next zone
|
||||||
@ -532,7 +535,7 @@ CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity)
|
|||||||
{
|
{
|
||||||
CZone *zone;
|
CZone *zone;
|
||||||
zone = GetZone(zoneid);
|
zone = GetZone(zoneid);
|
||||||
if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
|
if(IsNormalZone(zone->type))
|
||||||
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity;
|
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +544,7 @@ CTheZones::SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity)
|
|||||||
{
|
{
|
||||||
CZone *zone;
|
CZone *zone;
|
||||||
zone = GetZone(zoneid);
|
zone = GetZone(zoneid);
|
||||||
if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
|
if(IsNormalZone(zone->type))
|
||||||
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedDensity = peddensity;
|
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedDensity = peddensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +553,7 @@ CTheZones::SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup)
|
|||||||
{
|
{
|
||||||
CZone *zone;
|
CZone *zone;
|
||||||
zone = GetZone(zoneid);
|
zone = GetZone(zoneid);
|
||||||
if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
|
if(IsNormalZone(zone->type))
|
||||||
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedGroup = pedgroup;
|
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedGroup = pedgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +563,7 @@ CTheZones::FindAudioZone(CVector *pos)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < NumberOfAudioZones; i++)
|
for(i = 0; i < NumberOfAudioZones; i++)
|
||||||
if(PointLiesWithinZone(*pos, GetZone(AudioZoneArray[i])))
|
if(PointLiesWithinZone(pos, GetAudioZone(i)))
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -568,11 +571,11 @@ CTheZones::FindAudioZone(CVector *pos)
|
|||||||
eLevelName
|
eLevelName
|
||||||
CTheZones::FindZoneForPoint(const CVector &pos)
|
CTheZones::FindZoneForPoint(const CVector &pos)
|
||||||
{
|
{
|
||||||
if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("IND_ZON"))))
|
if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("IND_ZON"))))
|
||||||
return LEVEL_INDUSTRIAL;
|
return LEVEL_INDUSTRIAL;
|
||||||
if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("COM_ZON"))))
|
if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("COM_ZON"))))
|
||||||
return LEVEL_COMMERCIAL;
|
return LEVEL_COMMERCIAL;
|
||||||
if(PointLiesWithinZone(pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
|
if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON"))))
|
||||||
return LEVEL_SUBURBAN;
|
return LEVEL_SUBURBAN;
|
||||||
return LEVEL_NONE;
|
return LEVEL_NONE;
|
||||||
}
|
}
|
||||||
@ -582,7 +585,7 @@ CTheZones::AddZoneToAudioZoneArray(CZone *zone)
|
|||||||
{
|
{
|
||||||
int i, z;
|
int i, z;
|
||||||
|
|
||||||
if(zone->type != ZONE_AUDIO)
|
if(zone->type != ZONE_DEFAULT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* This is a bit stupid */
|
/* This is a bit stupid */
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
enum eZoneType
|
enum eZoneType
|
||||||
{
|
{
|
||||||
ZONE_AUDIO,
|
ZONE_DEFAULT,
|
||||||
ZONE_TYPE1, // this should be NAVIG
|
ZONE_NAVIG,
|
||||||
ZONE_TYPE2, // this should be INFO...but all except MAPINFO get zoneinfo??
|
ZONE_INFO,
|
||||||
ZONE_MAPZONE,
|
ZONE_MAPZONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,8 +51,6 @@ public:
|
|||||||
|
|
||||||
class CTheZones
|
class CTheZones
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
static eLevelName m_CurrLevel;
|
|
||||||
static CZone *m_pPlayersZone;
|
static CZone *m_pPlayersZone;
|
||||||
static int16 FindIndex;
|
static int16 FindIndex;
|
||||||
|
|
||||||
@ -64,6 +62,8 @@ public:
|
|||||||
static CZone MapZoneArray[NUMMAPZONES];
|
static CZone MapZoneArray[NUMMAPZONES];
|
||||||
static uint16 TotalNumberOfZoneInfos;
|
static uint16 TotalNumberOfZoneInfos;
|
||||||
static CZoneInfo ZoneInfoArray[2*NUMZONES];
|
static CZoneInfo ZoneInfoArray[2*NUMZONES];
|
||||||
|
public:
|
||||||
|
static eLevelName m_CurrLevel;
|
||||||
|
|
||||||
static void Init(void);
|
static void Init(void);
|
||||||
static void Update(void);
|
static void Update(void);
|
||||||
@ -76,12 +76,13 @@ public:
|
|||||||
float maxx, float maxy, float maxz,
|
float maxx, float maxy, float maxz,
|
||||||
eLevelName level);
|
eLevelName level);
|
||||||
static CZone *GetZone(uint16 i) { return &ZoneArray[i]; }
|
static CZone *GetZone(uint16 i) { return &ZoneArray[i]; }
|
||||||
|
static CZone *GetAudioZone(uint16 i) { return &ZoneArray[AudioZoneArray[i]]; }
|
||||||
static void PostZoneCreation(void);
|
static void PostZoneCreation(void);
|
||||||
static void InsertZoneIntoZoneHierarchy(CZone *zone);
|
static void InsertZoneIntoZoneHierarchy(CZone *zone);
|
||||||
static bool InsertZoneIntoZoneHierRecursive(CZone *z1, CZone *z2);
|
static bool InsertZoneIntoZoneHierRecursive(CZone *z1, CZone *z2);
|
||||||
static bool ZoneIsEntirelyContainedWithinOtherZone(CZone *z1, CZone *z2);
|
static bool ZoneIsEntirelyContainedWithinOtherZone(CZone *z1, CZone *z2);
|
||||||
static bool PointLiesWithinZone(const CVector &v, CZone *zone);
|
static bool PointLiesWithinZone(const CVector *v, CZone *zone);
|
||||||
static eLevelName GetLevelFromPosition(CVector const &v);
|
static eLevelName GetLevelFromPosition(const CVector *v);
|
||||||
static CZone *FindSmallestZonePosition(const CVector *v);
|
static CZone *FindSmallestZonePosition(const CVector *v);
|
||||||
static CZone *FindSmallestZonePositionType(const CVector *v, eZoneType type);
|
static CZone *FindSmallestZonePositionType(const CVector *v, eZoneType type);
|
||||||
static CZone *FindSmallestZonePositionILN(const CVector *v);
|
static CZone *FindSmallestZonePositionILN(const CVector *v);
|
||||||
|
@ -331,7 +331,7 @@ CEntity::SetupBigBuilding(void)
|
|||||||
bIsBIGBuilding = true;
|
bIsBIGBuilding = true;
|
||||||
bStreamingDontDelete = true;
|
bStreamingDontDelete = true;
|
||||||
bUsesCollision = false;
|
bUsesCollision = false;
|
||||||
m_level = CTheZones::GetLevelFromPosition(GetPosition());
|
m_level = CTheZones::GetLevelFromPosition(&GetPosition());
|
||||||
if(m_level == LEVEL_NONE){
|
if(m_level == LEVEL_NONE){
|
||||||
if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){
|
if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){
|
||||||
mi->SetTexDictionary("generic");
|
mi->SetTexDictionary("generic");
|
||||||
|
@ -396,7 +396,7 @@ CPopulation::FindCollisionZoneForCoors(CVector *coors, int *safeZoneOut, eLevelN
|
|||||||
if (*safeZoneOut >= 0)
|
if (*safeZoneOut >= 0)
|
||||||
*levelOut = LEVEL_NONE;
|
*levelOut = LEVEL_NONE;
|
||||||
else
|
else
|
||||||
*levelOut = CTheZones::GetLevelFromPosition(*coors);
|
*levelOut = CTheZones::GetLevelFromPosition(coors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user