1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-24 18:20:00 +00:00

sync with master

This commit is contained in:
Nikolay Korolev 2020-05-06 14:42:41 +03:00
commit 8c036ec671
18 changed files with 387 additions and 858 deletions

View file

@ -30,7 +30,7 @@ build:
project: build/reVC.sln project: build/reVC.sln
verbosity: minimal verbosity: minimal
after_build: after_build:
- 7z a "reVC_%configuration%_%platform%_%APPVEYOR_BUILD_VERSION%.zip" bin/%PLATFORM%/%CONFIGURATION%/re3.exe bin/%PLATFORM%/%CONFIGURATION%/re3.pdb - 7z a "reVC_%configuration%_%platform%_%APPVEYOR_BUILD_VERSION%.zip" bin/%PLATFORM%/%CONFIGURATION%/reVC.exe bin/%PLATFORM%/%CONFIGURATION%/reVC.pdb
artifacts: artifacts:
- path: "reVC_%configuration%_%platform%_%APPVEYOR_BUILD_VERSION%.zip" - path: "reVC_%configuration%_%platform%_%APPVEYOR_BUILD_VERSION%.zip"
name: reVC name: reVC

View file

@ -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;

View file

@ -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);
} }

View file

@ -80,13 +80,13 @@ CRestart::FindClosestHospitalRestartPoint(const CVector &pos, CVector *outPos, f
return; return;
} }
eLevelName curlevel = CTheZones::GetLevelFromPosition(pos); eLevelName curlevel = CTheZones::GetLevelFromPosition(&pos);
float fMinDist = 16000000.0f; float fMinDist = 16000000.0f;
int closestPoint = NUM_RESTART_POINTS; int closestPoint = NUM_RESTART_POINTS;
// find closest point on this level // find closest point on this level
for (int i = 0; i < NumberOfHospitalRestarts; i++) { for (int i = 0; i < NumberOfHospitalRestarts; i++) {
if (CTheZones::GetLevelFromPosition(HospitalRestartPoints[i]) == (OverrideHospitalLevel != LEVEL_NONE ? OverrideHospitalLevel : curlevel)) { if (CTheZones::GetLevelFromPosition(&HospitalRestartPoints[i]) == (OverrideHospitalLevel != LEVEL_NONE ? OverrideHospitalLevel : curlevel)) {
float dist = (pos - HospitalRestartPoints[i]).MagnitudeSqr(); float dist = (pos - HospitalRestartPoints[i]).MagnitudeSqr();
if (fMinDist >= dist) { if (fMinDist >= dist) {
fMinDist = dist; fMinDist = dist;
@ -127,13 +127,13 @@ CRestart::FindClosestPoliceRestartPoint(const CVector &pos, CVector *outPos, flo
return; return;
} }
eLevelName curlevel = CTheZones::GetLevelFromPosition(pos); eLevelName curlevel = CTheZones::GetLevelFromPosition(&pos);
float fMinDist = 16000000.0f; float fMinDist = 16000000.0f;
int closestPoint = NUM_RESTART_POINTS; int closestPoint = NUM_RESTART_POINTS;
// find closest point on this level // find closest point on this level
for (int i = 0; i < NumberOfPoliceRestarts; i++) { for (int i = 0; i < NumberOfPoliceRestarts; i++) {
if (CTheZones::GetLevelFromPosition(PoliceRestartPoints[i]) == (OverridePoliceStationLevel != LEVEL_NONE ? OverridePoliceStationLevel : curlevel)) { if (CTheZones::GetLevelFromPosition(&PoliceRestartPoints[i]) == (OverridePoliceStationLevel != LEVEL_NONE ? OverridePoliceStationLevel : curlevel)) {
float dist = (pos - PoliceRestartPoints[i]).MagnitudeSqr(); float dist = (pos - PoliceRestartPoints[i]).MagnitudeSqr();
if (fMinDist >= dist) { if (fMinDist >= dist) {
fMinDist = dist; fMinDist = dist;

View file

@ -1815,7 +1815,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
if (m_bIsMissionScript) if (m_bIsMissionScript)
ped->bIsStaticWaitingForCollision = true; ped->bIsStaticWaitingForCollision = true;
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);
@ -2056,7 +2056,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;
if (m_bIsMissionScript) if (m_bIsMissionScript)
car->bIsStaticWaitingForCollision = true; car->bIsStaticWaitingForCollision = true;
@ -2759,12 +2759,12 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
char label[12]; char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label); CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label); int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT);
if (zoneToCheck != -1) if (zoneToCheck != -1)
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::GetNavigationZone(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:
@ -2863,7 +2863,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);
@ -3091,7 +3091,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
CTheScripts::ReadTextLabelFromScript(&m_nIp, label); CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 16); CollectParameters(&m_nIp, 16);
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO);
if (zone < 0) { if (zone < 0) {
debug("Couldn't find zone - %s\n", label); debug("Couldn't find zone - %s\n", label);
return 0; return 0;
@ -3112,41 +3112,17 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
assert(pPed); assert(pPed);
char label[12]; char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label); CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT);
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::GetNavigationZone(zone)));
return 0; return 0;
} }
/* Not implemented.
case COMMAND_SET_CAR_DENSITY: case COMMAND_SET_CAR_DENSITY:
{
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
m_nIp += 8;
CollectParameters(&m_nIp, 2);
if (zone < 0) {
debug("Couldn't find zone - %s\n", label);
return 0;
}
CTheZones::SetCarDensity(zone, ScriptParams[0], ScriptParams[1]);
return 0;
}
case COMMAND_SET_PED_DENSITY: case COMMAND_SET_PED_DENSITY:
{ */
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 2);
if (zone < 0) {
debug("Couldn't find zone - %s\n", label);
return 0;
}
CTheZones::SetPedDensity(zone, ScriptParams[0], ScriptParams[1]);
return 0;
}
case COMMAND_POINT_CAMERA_AT_PLAYER: case COMMAND_POINT_CAMERA_AT_PLAYER:
{ {
CollectParameters(&m_nIp, 3); CollectParameters(&m_nIp, 3);
@ -3182,7 +3158,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
CTheScripts::ReadTextLabelFromScript(&m_nIp, label); CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 10); CollectParameters(&m_nIp, 10);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO);
if (zone < 0) { if (zone < 0) {
debug("Couldn't find zone - %s\n", label); debug("Couldn't find zone - %s\n", label);
return 0; return 0;
@ -4054,7 +4030,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);
@ -5943,10 +5919,10 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
{ {
char zone[KEY_LENGTH_IN_SCRIPT]; char zone[KEY_LENGTH_IN_SCRIPT];
strncpy(zone, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); strncpy(zone, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT);
int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone); int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT);
if (nZone != -1) if (nZone != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CZone* pZone = CTheZones::GetZone(nZone); CZone* pZone = CTheZones::GetNavigationZone(nZone);
int ped_handle = -1; int ped_handle = -1;
CVector pos = FindPlayerCoors(); CVector pos = FindPlayerCoors();
int i = CPools::GetPedPool()->GetSize(); int i = CPools::GetPedPool()->GetSize();
@ -5970,7 +5946,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;
@ -6551,7 +6527,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 2); CollectParameters(&m_nIp, 2);
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_INFO);
if (zone_id < 0) { if (zone_id < 0) {
printf("Couldn't find zone - %s\n", zone); printf("Couldn't find zone - %s\n", zone);
return 0; return 0;
@ -6611,10 +6587,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
{ {
char zone[KEY_LENGTH_IN_SCRIPT]; char zone[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); // TODO(MIAMI): just getting this to compile with new argument
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT);
if (zone_id != -1) if (zone_id != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CZone* pZone = CTheZones::GetZone(zone_id); CZone* pZone = CTheZones::GetNavigationZone(zone_id);
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
int handle = -1; int handle = -1;
uint32 i = CPools::GetVehiclePool()->GetSize(); uint32 i = CPools::GetVehiclePool()->GetSize();
@ -6626,7 +6603,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;
@ -7117,10 +7094,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
char zone[KEY_LENGTH_IN_SCRIPT]; char zone[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); // TODO(MIAMI): just getting this to compile with new argument
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT);
if (zone_id != -1) if (zone_id != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CZone* pZone = CTheZones::GetZone(zone_id); CZone* pZone = CTheZones::GetNavigationZone(zone_id);
UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0], UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0],
pZone->minx, pZone->maxx, pZone->miny, pZone->maxy, pZone->minz, pZone->maxz)); pZone->minx, pZone->maxx, pZone->miny, pZone->maxy, pZone->minz, pZone->maxz));
return 0; return 0;
@ -7252,7 +7230,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
if (total == 0) if (total == 0)
CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(LEVEL_NONE), pos, range, true, &total, 16, apEntities); CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(LEVEL_NONE), pos, range, true, &total, 16, apEntities);
if (total == 0) if (total == 0)
CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(CTheZones::GetLevelFromPosition(pos)), pos, range, true, &total, 16, apEntities); CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(CTheZones::GetLevelFromPosition(&pos)), pos, range, true, &total, 16, apEntities);
CEntity* pClosestEntity = nil; CEntity* pClosestEntity = nil;
float min_dist = 2.0f * range; float min_dist = 2.0f * range;
for (int i = 0; i < total; i++) { for (int i = 0; i < total; i++) {
@ -7439,7 +7417,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
if (m_bIsMissionScript) if (m_bIsMissionScript)
ped->bIsStaticWaitingForCollision = true; ped->bIsStaticWaitingForCollision = true;
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);
@ -8006,7 +7984,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
if (total == 0) if (total == 0)
CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_NONE), pos, radius, true, &total, 16, apEntities); CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_NONE), pos, radius, true, &total, 16, apEntities);
if (total == 0) if (total == 0)
CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(CTheZones::GetLevelFromPosition(pos)), pos, radius, true, &total, 16, apEntities); CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(CTheZones::GetLevelFromPosition(&pos)), pos, radius, true, &total, 16, apEntities);
CEntity* pClosestEntity = nil; CEntity* pClosestEntity = nil;
float min_dist = 2.0f * radius; float min_dist = 2.0f * radius;
for (int i = 0; i < total; i++) { for (int i = 0; i < total; i++) {
@ -8270,7 +8248,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;
} }
@ -8596,7 +8574,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;
@ -8607,7 +8585,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;
@ -9012,7 +8990,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:
@ -9211,7 +9189,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:
@ -9532,10 +9510,11 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{ {
char zone[KEY_LENGTH_IN_SCRIPT]; char zone[KEY_LENGTH_IN_SCRIPT];
strncpy(zone, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); strncpy(zone, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT);
int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone); // TODO(MIAMI): just getting this to compile with new argument
int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT);
if (nZone != -1) if (nZone != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
CZone* pZone = CTheZones::GetZone(nZone); CZone* pZone = CTheZones::GetNavigationZone(nZone);
int ped_handle = -1; int ped_handle = -1;
CVector pos = FindPlayerCoors(); CVector pos = FindPlayerCoors();
int i = CPools::GetPedPool()->GetSize(); int i = CPools::GetPedPool()->GetSize();
@ -9557,7 +9536,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;

View file

@ -1139,7 +1139,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());
entity->m_area = area; entity->m_area = area;
if(mi->IsSimple()){ if(mi->IsSimple()){
if(mi->m_isBigBuilding) if(mi->m_isBigBuilding)
@ -1165,7 +1165,7 @@ CFileLoader::LoadObjectInstance(const char *line)
CWorld::Add(entity); CWorld::Add(entity);
if(IsGlass(entity->GetModelIndex()) && !mi->m_isArtistGlass) if(IsGlass(entity->GetModelIndex()) && !mi->m_isArtistGlass)
entity->bIsVisible = false; entity->bIsVisible = false;
entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition()); entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
entity->m_area = area; entity->m_area = area;
} }

View file

@ -483,9 +483,6 @@ void CGame::ReInitGameObjectVariables(void)
CSpecialFX::Init(); CSpecialFX::Init();
CWaterCannons::Init(); CWaterCannons::Init();
CParticle::ReloadConfig(); CParticle::ReloadConfig();
#ifdef GTA_ZONECULL
CCullZones::ResolveVisibilities();
#endif
if ( !FrontEndMenuManager.m_bWantToLoad ) if ( !FrontEndMenuManager.m_bWantToLoad )
{ {

View file

@ -2405,7 +2405,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;

View file

@ -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::FindSmallestNavigationZoneForPosition(&pos, false, true);
CZone *audioZone = CTheZones::FindSmallestZonePositionType(&pos, ZONE_AUDIO); CZone *defaultZone = CTheZones::FindSmallestNavigationZoneForPosition(&pos, true, false);
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 {

View file

@ -11,228 +11,32 @@
#include "ZoneCull.h" #include "ZoneCull.h"
#include "Zones.h" #include "Zones.h"
int32 CCullZones::NumCullZones;
CCullZone CCullZones::aZones[NUMCULLZONES];
int32 CCullZones::NumAttributeZones; int32 CCullZones::NumAttributeZones;
CAttributeZone CCullZones::aAttributeZones[NUMATTRIBZONES]; CAttributeZone CCullZones::aAttributeZones[NUMATTRIBZONES];
uint16 CCullZones::aIndices[NUMZONEINDICES];
int16 CCullZones::aPointersToBigBuildingsForBuildings[NUMBUILDINGS];
int16 CCullZones::aPointersToBigBuildingsForTreadables[NUMTREADABLES];
int32 CCullZones::CurrentWantedLevelDrop_Player; int32 CCullZones::CurrentWantedLevelDrop_Player;
int32 CCullZones::CurrentFlags_Camera; int32 CCullZones::CurrentFlags_Camera;
int32 CCullZones::CurrentFlags_Player; int32 CCullZones::CurrentFlags_Player;
int32 CCullZones::OldCullZone;
int32 CCullZones::EntityIndicesUsed;
bool CCullZones::bCurrentSubwayIsInvisible; bool CCullZones::bCurrentSubwayIsInvisible;
bool CCullZones::bCullZonesDisabled;
void void
CCullZones::Init(void) CCullZones::Init(void)
{ {
int i;
NumAttributeZones = 0; NumAttributeZones = 0;
CurrentWantedLevelDrop_Player = 0; CurrentWantedLevelDrop_Player = 0;
CurrentFlags_Camera = 0; CurrentFlags_Camera = 0;
CurrentFlags_Player = 0; CurrentFlags_Player = 0;
bCurrentSubwayIsInvisible = false; bCurrentSubwayIsInvisible = false;
#ifdef GTA_ZONECULL
NumCullZones = 0;
OldCullZone = -1;
EntityIndicesUsed = 0;
for(i = 0; i < NUMBUILDINGS; i++)
aPointersToBigBuildingsForBuildings[i] = -1;
for(i = 0; i < NUMTREADABLES; i++)
aPointersToBigBuildingsForTreadables[i] = -1;
#endif
} }
#ifdef GTA_ZONECULL
bool CCullZone::TestLine(CVector vec1, CVector vec2)
{
CColPoint colPoint;
CEntity *entity;
if (CWorld::ProcessLineOfSight(vec1, vec2, colPoint, entity, true, false, false, false, false, true, false))
return true;
if (CWorld::ProcessLineOfSight(CVector(vec1.x + 0.05f, vec1.y, vec1.z), CVector(vec2.x + 0.05f, vec2.y, vec2.z), colPoint, entity, true, false, false, false, false, true, false))
return true;
if (CWorld::ProcessLineOfSight(CVector(vec1.x - 0.05f, vec1.y, vec1.z), CVector(vec2.x - 0.05f, vec2.y, vec2.z), colPoint, entity, true, false, false, false, false, true, false))
return true;
if (CWorld::ProcessLineOfSight(CVector(vec1.x, vec1.y + 0.05f, vec1.z), CVector(vec2.x, vec2.y + 0.05f, vec2.z), colPoint, entity, true, false, false, false, false, true, false))
return true;
if (CWorld::ProcessLineOfSight(CVector(vec1.x, vec1.y - 0.05f, vec1.z), CVector(vec2.x, vec2.y - 0.05f, vec2.z), colPoint, entity, true, false, false, false, false, true, false))
return true;
if (CWorld::ProcessLineOfSight(CVector(vec1.x, vec1.y, vec1.z + 0.05f), CVector(vec2.x, vec2.y, vec2.z + 0.05f), colPoint, entity, true, false, false, false, false, true, false))
return true;
return CWorld::ProcessLineOfSight(CVector(vec1.x, vec1.y, vec1.z - 0.05f), CVector(vec2.x, vec2.y, vec2.z - 0.05f), colPoint, entity, true, false, false, false, false, true, false);
}
uint16* pTempArrayIndices;
int TempEntityIndicesUsed;
void
CCullZones::ResolveVisibilities(void)
{
int fd;
CFileMgr::SetDir("");
fd = CFileMgr::OpenFile("DATA\\cullzone.dat", "rb");
if(fd > 0){
CFileMgr::Read(fd, (char*)&NumCullZones, sizeof(NumCullZones));
CFileMgr::Read(fd, (char*)aZones, sizeof(aZones));
CFileMgr::Read(fd, (char*)&NumAttributeZones, sizeof(NumAttributeZones));
CFileMgr::Read(fd, (char*)aAttributeZones, sizeof(aAttributeZones));
CFileMgr::Read(fd, (char*)aIndices, sizeof(aIndices));
CFileMgr::Read(fd, (char*)aPointersToBigBuildingsForBuildings, sizeof(aPointersToBigBuildingsForBuildings));
CFileMgr::Read(fd, (char*)aPointersToBigBuildingsForTreadables, sizeof(aPointersToBigBuildingsForTreadables));
CFileMgr::CloseFile(fd);
}else{
#if 0
// TODO: implement code from mobile to generate data here
EntityIndicesUsed = 0;
BuildListForBigBuildings();
pTempArrayIndices = new uint16[140000];
TempEntityIndicesUsed = 0;
for (int i = 0; i < NumCullZones; i++) {
DoVisibilityTestCullZone(i, true);
}
CompressIndicesArray();
delete[] pTempArrayIndices;
fd = CFileMgr::OpenFileForWriting("data\\cullzone.dat");
if (fd != 0) {
CFileMgr::Write(fd, (char*)&NumCullZones, sizeof(NumCullZones));
CFileMgr::Write(fd, (char*)aZones, sizeof(aZones));
CFileMgr::Write(fd, (char*)&NumAttributeZones, sizeof(NumAttributeZones));
CFileMgr::Write(fd, (char*)&aAttributeZones, sizeof(aAttributeZones));
CFileMgr::Write(fd, (char*)&aIndices, sizeof(aIndices));
CFileMgr::Write(fd, (char*)&aPointersToBigBuildingsForBuildings, sizeof(aPointersToBigBuildingsForBuildings));
CFileMgr::Write(fd, (char*)&aPointersToBigBuildingsForTreadables, sizeof(aPointersToBigBuildingsForTreadables));
CFileMgr::CloseFile(fd);
}
#endif
}
}
void
CCullZones::BuildListForBigBuildings()
{
for (int i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--) {
CBuilding *building = CPools::GetBuildingPool()->GetSlot(i);
if (building == nil || !building->bIsBIGBuilding) continue;
CSimpleModelInfo *nonlod = (CSimpleModelInfo*)((CSimpleModelInfo *)CModelInfo::GetModelInfo(building->GetModelIndex()))->m_atomics[2];
if (nonlod == nil) continue;
for (int j = i; j >= 0; j--) {
CBuilding *building2 = CPools::GetBuildingPool()->GetSlot(j);
if (building2 == nil || building2->bIsBIGBuilding) continue;
if (CModelInfo::GetModelInfo(building2->GetModelIndex()) == nonlod) {
if ((building2->GetPosition() - building->GetPosition()).Magnitude() < 5.0f) {
aPointersToBigBuildingsForBuildings[j] = i;
}
}
}
for (int j = CPools::GetTreadablePool()->GetSize()-1; j >= 0; j--) {
CTreadable *treadable = CPools::GetTreadablePool()->GetSlot(j);
if (treadable == nil || treadable->bIsBIGBuilding) continue;
if (CModelInfo::GetModelInfo(treadable->GetModelIndex()) == nonlod) {
if ((treadable->GetPosition() - building->GetPosition()).Magnitude() < 5.0f) {
aPointersToBigBuildingsForTreadables[j] = i;
}
}
}
}
}
void
CCullZones::DoVisibilityTestCullZone(int zoneId, bool doIt)
{
aZones[zoneId].m_groupIndexCount[0] = 0;
aZones[zoneId].m_groupIndexCount[1] = 0;
aZones[zoneId].m_groupIndexCount[2] = 0;
aZones[zoneId].m_indexStart = TempEntityIndicesUsed;
aZones[zoneId].FindTestPoints();
if (!doIt) return;
for (int i = CPools::GetBuildingPool()->GetSize() - 1; i >= 0; i--) {
CBuilding *building = CPools::GetBuildingPool()->GetSlot(i);
if (building != nil && !building->bIsBIGBuilding && aZones[zoneId].IsEntityCloseEnoughToZone(building, aPointersToBigBuildingsForBuildings[i] != -1)) {
CBuilding *building2 = nil;
if (aPointersToBigBuildingsForBuildings[i] != -1)
building2 = CPools::GetBuildingPool()->GetSlot(aPointersToBigBuildingsForBuildings[i]);
if (!aZones[zoneId].TestEntityVisibilityFromCullZone(building, 0.0f, building2)) {
pTempArrayIndices[TempEntityIndicesUsed++] = i;
aZones[zoneId].m_groupIndexCount[0]++;
}
}
}
for (int i = CPools::GetTreadablePool()->GetSize() - 1; i >= 0; i--) {
CTreadable* building = CPools::GetTreadablePool()->GetSlot(i);
if (building != nil && aZones[zoneId].IsEntityCloseEnoughToZone(building, aPointersToBigBuildingsForTreadables[i] != -1)) {
CTreadable* building2 = nil;
if (aPointersToBigBuildingsForTreadables[i] != -1)
building2 = CPools::GetTreadablePool()->GetSlot(aPointersToBigBuildingsForTreadables[i]);
if (!aZones[zoneId].TestEntityVisibilityFromCullZone(building, 10.0f, building2)) {
pTempArrayIndices[TempEntityIndicesUsed++] = i;
aZones[zoneId].m_groupIndexCount[1]++;
}
}
}
for (int i = CPools::GetTreadablePool()->GetSize() - 1; i >= 0; i--) {
CTreadable *building = CPools::GetTreadablePool()->GetSlot(i);
if (building != nil && aZones[zoneId].CalcDistToCullZoneSquared(building->GetPosition().x, building->GetPosition().y) < 40000.0f) {
int start = aZones[zoneId].m_groupIndexCount[0] + aZones[zoneId].m_indexStart;
int end = aZones[zoneId].m_groupIndexCount[1] + start;
bool alreadyAdded = false;
for (int k = start; k < end; k++) {
if (aIndices[k] == i)
alreadyAdded = true;
}
if (!alreadyAdded) {
CBuilding *building2 = nil;
if (aPointersToBigBuildingsForTreadables[i] != -1)
building2 = CPools::GetBuildingPool()->GetSlot(aPointersToBigBuildingsForTreadables[i]);
if (!aZones[zoneId].TestEntityVisibilityFromCullZone(building, 0.0f, building2)) {
pTempArrayIndices[TempEntityIndicesUsed++] = i;
aZones[zoneId].m_groupIndexCount[2]++;
}
}
}
}
}
#endif
void void
CCullZones::Update(void) CCullZones::Update(void)
{ {
bool invisible; bool invisible;
if(bCullZonesDisabled)
return;
switch(CTimer::GetFrameCounter() & 7){ switch(CTimer::GetFrameCounter() & 7){
case 0: case 0:
case 4: case 4:
#ifdef GTA_ZONECULL
/* Update Cull zone */
ForceCullZoneCoors(TheCamera.GetGameCamPosition());
#endif
break; break;
case 2: case 2:
@ -256,33 +60,7 @@ CCullZones::Update(void)
void void
CCullZones::ForceCullZoneCoors(CVector coors) CCullZones::ForceCullZoneCoors(CVector coors)
{ {
#ifdef GTA_ZONECULL
int32 z;
z = FindCullZoneForCoors(coors);
if(z != OldCullZone){
if(OldCullZone >= 0)
aZones[OldCullZone].DoStuffLeavingZone();
if(z >= 0)
aZones[z].DoStuffEnteringZone();
OldCullZone = z;
} }
#endif
}
#ifdef GTA_ZONECULL
int32
CCullZones::FindCullZoneForCoors(CVector coors)
{
int i;
for(i = 0; i < NumCullZones; i++)
if(coors.x >= aZones[i].minx && coors.x <= aZones[i].maxx &&
coors.y >= aZones[i].miny && coors.y <= aZones[i].maxy &&
coors.z >= aZones[i].minz && coors.z <= aZones[i].maxz)
return i;
return -1;
}
#endif
int32 int32
CCullZones::FindAttributesForCoors(CVector coors, int32 *wantedLevel) CCullZones::FindAttributesForCoors(CVector coors, int32 *wantedLevel)
@ -356,35 +134,9 @@ CCullZones::AddCullZone(CVector const &position,
float minz, float maxz, float minz, float maxz,
uint16 flag, int16 wantedLevel) uint16 flag, int16 wantedLevel)
{ {
CCullZone *cull;
CAttributeZone *attrib; CAttributeZone *attrib;
CVector v; assert(NumAttributeZones < NUMATTRIBZONES);
#ifdef GTA_ZONECULL
if((flag & ATTRZONE_NOTCULLZONE) == 0){
cull = &aZones[NumCullZones++];
v = position;
// WTF is this?
if((v-CVector(1032.14f, -624.255f, 24.93f)).Magnitude() < 1.0f)
v = CVector(1061.7f, -613.0f, 19.0f);
if((v-CVector(1029.48f, -495.757f, 21.98f)).Magnitude() < 1.0f)
v = CVector(1061.4f, -506.0f, 18.5f);
cull->position.x = clamp(v.x, minx, maxx);
cull->position.y = clamp(v.y, miny, maxy);
cull->position.z = clamp(v.z, minz, maxz);
cull->minx = minx;
cull->maxx = maxx;
cull->miny = miny;
cull->maxy = maxy;
cull->minz = minz;
cull->maxz = maxz;
cull->m_groupIndexCount[0] = 0;
cull->m_groupIndexCount[1] = 0;
cull->m_groupIndexCount[2] = 0;
cull->m_indexStart = 0;
}
#endif
if(flag & ~ATTRZONE_NOTCULLZONE){
attrib = &aAttributeZones[NumAttributeZones++]; attrib = &aAttributeZones[NumAttributeZones++];
attrib->minx = minx; attrib->minx = minx;
attrib->maxx = maxx; attrib->maxx = maxx;
@ -395,183 +147,3 @@ CCullZones::AddCullZone(CVector const &position,
attrib->attributes = flag; attrib->attributes = flag;
attrib->wantedLevel = wantedLevel; attrib->wantedLevel = wantedLevel;
} }
}
#ifdef GTA_ZONECULL
void
CCullZone::DoStuffLeavingZone(void)
{
int i;
for(i = 0; i < m_numBuildings; i++)
DoStuffLeavingZone_OneBuilding(CCullZones::aIndices[m_indexStart + i]);
for(; i < m_numBuildings + m_numTreadablesPlus10m + m_numTreadables ; i++)
DoStuffLeavingZone_OneTreadableBoth(CCullZones::aIndices[m_indexStart + i]);
}
void
CCullZone::DoStuffLeavingZone_OneBuilding(uint16 i)
{
int16 bb;
int j;
if(i < 6000){
CPools::GetBuildingPool()->GetSlot(i)->bZoneCulled = false;
bb = CCullZones::aPointersToBigBuildingsForBuildings[i];
if(bb != -1)
CPools::GetBuildingPool()->GetSlot(bb)->bZoneCulled = false;
}else{
i -= 6000;
for(j = 0; j < 3; j++)
DoStuffLeavingZone_OneBuilding(CCullZones::aIndices[i+j]);
}
}
void
CCullZone::DoStuffLeavingZone_OneTreadableBoth(uint16 i)
{
int16 bb;
int j;
if(i < 6000){
CPools::GetTreadablePool()->GetSlot(i)->bZoneCulled = false;
CPools::GetTreadablePool()->GetSlot(i)->bZoneCulled2 = false;
bb = CCullZones::aPointersToBigBuildingsForTreadables[i];
if(bb != -1)
CPools::GetBuildingPool()->GetSlot(bb)->bZoneCulled = false;
}else{
i -= 6000;
for(j = 0; j < 3; j++)
DoStuffLeavingZone_OneTreadableBoth(CCullZones::aIndices[i+j]);
}
}
void
CCullZone::DoStuffEnteringZone(void)
{
int i;
for(i = 0; i < m_numBuildings; i++)
DoStuffEnteringZone_OneBuilding(CCullZones::aIndices[m_indexStart + i]);
for(; i < m_numBuildings + m_numTreadablesPlus10m; i++)
DoStuffEnteringZone_OneTreadablePlus10m(CCullZones::aIndices[m_indexStart + i]);
for(; i < m_numBuildings + m_numTreadablesPlus10m + m_numTreadables; i++)
DoStuffEnteringZone_OneTreadable(CCullZones::aIndices[m_indexStart + i]);
}
void
CCullZone::DoStuffEnteringZone_OneBuilding(uint16 i)
{
int16 bb;
int j;
if(i < 6000){
CPools::GetBuildingPool()->GetSlot(i)->bZoneCulled = true;
bb = CCullZones::aPointersToBigBuildingsForBuildings[i];
if(bb != -1)
CPools::GetBuildingPool()->GetSlot(bb)->bZoneCulled = true;
}else{
i -= 6000;
for(j = 0; j < 3; j++)
DoStuffEnteringZone_OneBuilding(CCullZones::aIndices[i+j]);
}
}
void
CCullZone::DoStuffEnteringZone_OneTreadablePlus10m(uint16 i)
{
int16 bb;
int j;
if(i < 6000){
CPools::GetTreadablePool()->GetSlot(i)->bZoneCulled = true;
CPools::GetTreadablePool()->GetSlot(i)->bZoneCulled2 = true;
bb = CCullZones::aPointersToBigBuildingsForTreadables[i];
if(bb != -1)
CPools::GetBuildingPool()->GetSlot(bb)->bZoneCulled = true;
}else{
i -= 6000;
for(j = 0; j < 3; j++)
DoStuffEnteringZone_OneTreadablePlus10m(CCullZones::aIndices[i+j]);
}
}
void
CCullZone::DoStuffEnteringZone_OneTreadable(uint16 i)
{
int16 bb;
int j;
if(i < 6000){
CPools::GetTreadablePool()->GetSlot(i)->bZoneCulled = true;
bb = CCullZones::aPointersToBigBuildingsForTreadables[i];
if(bb != -1)
CPools::GetBuildingPool()->GetSlot(bb)->bZoneCulled = true;
}else{
i -= 6000;
for(j = 0; j < 3; j++)
DoStuffEnteringZone_OneTreadable(CCullZones::aIndices[i+j]);
}
}
float
CCullZone::CalcDistToCullZoneSquared(float x, float y)
{
float rx, ry;
if (x < minx) rx = sq(x - minx);
else if (x > maxx) rx = sq(x - maxx);
else rx = 0.0f;
if (y < miny) ry = sq(y - miny);
else if (y > maxy) ry = sq(y - maxy);
else ry = 0.0f;
return rx + ry;
}
bool
CCullZone::IsEntityCloseEnoughToZone(CEntity *entity, bool checkLevel)
{
const CVector &pos = entity->GetPosition();
CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(entity->GetModelIndex());
float distToZone = CalcDistToCullZone(pos.x, pos.y);
float lodDist;
if (minfo->m_isSubway)
lodDist = minfo->GetLargestLodDistance() + 30.0f;
else
lodDist = minfo->GetLargestLodDistance() + 50.0f;
if (lodDist > distToZone) return true;
if (!checkLevel) return false;
return CTheZones::GetLevelFromPosition(pos) == CTheZones::GetLevelFromPosition(CVector(minx, miny, minz));
}
bool
CCullZones::DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set)
{
int32 curCount;
int32 start;
int32 size;
for (int i = 0; i < NumCullZones; i++) {
curCount = 0;
for (int group = 0; group < 3; group++) {
aZones[i].GetGroupStartAndSize(group, start, size);
int unk = 0; // TODO: figure out
for (int j = 0; j < size; j++) {
for (int k = 0; k < 3; k++) {
if (set[k] == pTempArrayIndices[start+j])
unk++;
}
}
if (unk == 3 && ++curCount >= count)
return true;
}
}
return false;
}
#endif

View file

@ -1,57 +1,5 @@
class CEntity; class CEntity;
class CCullZone
{
public:
CVector position;
float minx;
float maxx;
float miny;
float maxy;
float minz;
float maxz;
int32 m_indexStart;
int16 m_groupIndexCount[3];
int16 m_numBuildings;
int16 m_numTreadablesPlus10m;
int16 m_numTreadables;
void DoStuffLeavingZone(void);
static void DoStuffLeavingZone_OneBuilding(uint16 i);
static void DoStuffLeavingZone_OneTreadableBoth(uint16 i);
void DoStuffEnteringZone(void);
static void DoStuffEnteringZone_OneBuilding(uint16 i);
static void DoStuffEnteringZone_OneTreadablePlus10m(uint16 i);
static void DoStuffEnteringZone_OneTreadable(uint16 i);
static bool TestLine(CVector a1, CVector a2);
float CalcDistToCullZoneSquared(float x, float y);
float CalcDistToCullZone(float x, float y) { return Sqrt(CalcDistToCullZoneSquared(x, y)); };
bool IsEntityCloseEnoughToZone(CEntity* entity, bool checkLevel);
void GetGroupStartAndSize(int32 groupid, int32 &start, int32 &size) {
switch (groupid) {
case 1:
start = m_groupIndexCount[0] + m_indexStart;
size = m_groupIndexCount[1];
break;
case 2:
start = m_groupIndexCount[0] + m_groupIndexCount[1] + m_indexStart;
size = m_groupIndexCount[2];
break;
default:
start = m_indexStart;
size = m_groupIndexCount[0];
break;
}
}
void FindTestPoints() {}; // todo
bool TestEntityVisibilityFromCullZone(CEntity*, float, CEntity*) { return false; }; // todo
};
enum eZoneAttribs enum eZoneAttribs
{ {
ATTRZONE_CAMCLOSEIN = 1, ATTRZONE_CAMCLOSEIN = 1,
@ -79,27 +27,17 @@ struct CAttributeZone
class CCullZones class CCullZones
{ {
public: public:
static int32 NumCullZones;
static CCullZone aZones[NUMCULLZONES];
static int32 NumAttributeZones; static int32 NumAttributeZones;
static CAttributeZone aAttributeZones[NUMATTRIBZONES]; static CAttributeZone aAttributeZones[NUMATTRIBZONES];
static uint16 aIndices[NUMZONEINDICES];
static int16 aPointersToBigBuildingsForBuildings[NUMBUILDINGS];
static int16 aPointersToBigBuildingsForTreadables[NUMTREADABLES];
static int32 CurrentWantedLevelDrop_Player; static int32 CurrentWantedLevelDrop_Player;
static int32 CurrentFlags_Camera; static int32 CurrentFlags_Camera;
static int32 CurrentFlags_Player; static int32 CurrentFlags_Player;
static int32 OldCullZone;
static int32 EntityIndicesUsed;
static bool bCurrentSubwayIsInvisible; static bool bCurrentSubwayIsInvisible;
static bool bCullZonesDisabled;
static void Init(void); static void Init(void);
static void ResolveVisibilities(void);
static void Update(void); static void Update(void);
static void ForceCullZoneCoors(CVector coors); static void ForceCullZoneCoors(CVector coors);
static int32 FindCullZoneForCoors(CVector coors);
static int32 FindAttributesForCoors(CVector coors, int32 *wantedLevel); static int32 FindAttributesForCoors(CVector coors, int32 *wantedLevel);
static CAttributeZone *FindZoneWithStairsAttributeForPlayer(void); static CAttributeZone *FindZoneWithStairsAttributeForPlayer(void);
static void MarkSubwayAsInvisible(bool visible); static void MarkSubwayAsInvisible(bool visible);
@ -117,12 +55,6 @@ public:
static bool CamNoRain(void) { return (CurrentFlags_Camera & ATTRZONE_NORAIN) != 0; } static bool CamNoRain(void) { return (CurrentFlags_Camera & ATTRZONE_NORAIN) != 0; }
static int32 GetWantedLevelDrop(void) { return CurrentWantedLevelDrop_Player; } static int32 GetWantedLevelDrop(void) { return CurrentWantedLevelDrop_Player; }
static void BuildListForBigBuildings();
static void DoVisibilityTestCullZone(int zoneId, bool doIt);
static bool DoWeHaveMoreThanXOccurencesOfSet(int32 count, uint16 *set);
static void CompressIndicesArray() {};// todo
//--MIAMI: TODO //--MIAMI: TODO
static bool PoliceAbandonCars(void) { return false; } static bool PoliceAbandonCars(void) { return false; }
}; };

View file

@ -9,17 +9,19 @@
#include "World.h" #include "World.h"
eLevelName CTheZones::m_CurrLevel; eLevelName CTheZones::m_CurrLevel;
CZone *CTheZones::m_pPlayersZone;
int16 CTheZones::FindIndex; int16 CTheZones::FindIndex;
uint16 CTheZones::NumberOfAudioZones; uint16 CTheZones::NumberOfAudioZones;
int16 CTheZones::AudioZoneArray[NUMAUDIOZONES]; int16 CTheZones::AudioZoneArray[NUMAUDIOZONES];
uint16 CTheZones::TotalNumberOfMapZones; uint16 CTheZones::TotalNumberOfMapZones;
uint16 CTheZones::TotalNumberOfZones; uint16 CTheZones::TotalNumberOfInfoZones;
CZone CTheZones::ZoneArray[NUMZONES]; uint16 CTheZones::TotalNumberOfNavigationZones;
CZone CTheZones::InfoZoneArray[NUMINFOZONES];
CZone CTheZones::MapZoneArray[NUMMAPZONES]; CZone CTheZones::MapZoneArray[NUMMAPZONES];
CZone CTheZones::NavigationZoneArray[NUMNAVIGZONES];
uint16 CTheZones::TotalNumberOfZoneInfos; uint16 CTheZones::TotalNumberOfZoneInfos;
CZoneInfo CTheZones::ZoneInfoArray[2*NUMZONES]; CZoneInfo CTheZones::ZoneInfoArray[2*NUMINFOZONES];
#define SWAPF(a, b) { float t; t = a; a = b; b = t; } #define SWAPF(a, b) { float t; t = a; a = b; b = t; }
@ -44,12 +46,14 @@ CheckZoneInfo(CZoneInfo *info)
assert(info->gangThreshold[7] <= info->gangThreshold[8]); assert(info->gangThreshold[7] <= info->gangThreshold[8]);
} }
//--MIAMI: done
wchar* wchar*
CZone::GetTranslatedName(void) CZone::GetTranslatedName(void)
{ {
return TheText.Get(name); return TheText.Get(name);
} }
//--MIAMI: check out zoneinfo
void void
CTheZones::Init(void) CTheZones::Init(void)
{ {
@ -58,9 +62,15 @@ CTheZones::Init(void)
AudioZoneArray[i] = -1; AudioZoneArray[i] = -1;
NumberOfAudioZones = 0; NumberOfAudioZones = 0;
for(i = 0; i < NUMNAVIGZONES; i++)
memset(&NavigationZoneArray[i], 0, sizeof(CZone));
for(i = 0; i < NUMINFOZONES; i++)
memset(&InfoZoneArray[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*NUMINFOZONES; i++){
zonei = &ZoneInfoArray[i]; zonei = &ZoneInfoArray[i];
zonei->carDensity = 10; zonei->carDensity = 10;
zonei->carThreshold[0] = x; zonei->carThreshold[0] = x;
@ -81,54 +91,64 @@ 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)); TotalNumberOfNavigationZones = 1;
strcpy(ZoneArray[0].name, "CITYZON"); TotalNumberOfInfoZones = 1;
ZoneArray[0].minx = -4000.0f;
ZoneArray[0].miny = -4000.0f; strcpy(InfoZoneArray[0].name, "CITYINF");
ZoneArray[0].minz = -500.0f; InfoZoneArray[0].minx = -2400.0f;
ZoneArray[0].maxx = 4000.0f; InfoZoneArray[0].miny = -2000.0f;
ZoneArray[0].maxy = 4000.0f; InfoZoneArray[0].minz = -500.0f;
ZoneArray[0].maxz = 500.0f; InfoZoneArray[0].maxx = 1600.0f;
ZoneArray[0].level = LEVEL_NONE; InfoZoneArray[0].maxy = 2000.0f;
TotalNumberOfZones = 1; InfoZoneArray[0].maxz = 500.0f;
InfoZoneArray[0].level = LEVEL_NONE;
InfoZoneArray[0].type = ZONE_INFO;
strcpy(NavigationZoneArray[0].name, "VICE_C");
NavigationZoneArray[0].minx = -2400.0f;
NavigationZoneArray[0].miny = -2000.0f;
NavigationZoneArray[0].minz = -500.0f;
NavigationZoneArray[0].maxx = 1600.0f;
NavigationZoneArray[0].maxy = 2000.0f;
NavigationZoneArray[0].maxz = 500.0f;
NavigationZoneArray[0].level = LEVEL_NONE;
NavigationZoneArray[0].type = ZONE_NAVIG;
m_CurrLevel = LEVEL_NONE; 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;
} }
strcpy(MapZoneArray[0].name, "THEMAP"); strcpy(MapZoneArray[0].name, "THEMAP");
MapZoneArray[0].minx = -4000.0f; MapZoneArray[0].minx = -2400.0f;
MapZoneArray[0].miny = -4000.0f; MapZoneArray[0].miny = -2000.0f;
MapZoneArray[0].minz = -500.0f; MapZoneArray[0].minz = -500.0f;
MapZoneArray[0].maxx = 4000.0f; MapZoneArray[0].maxx = 1600.0f;
MapZoneArray[0].maxy = 4000.0f; MapZoneArray[0].maxy = 2000.0f;
MapZoneArray[0].maxz = 500.0f; MapZoneArray[0].maxz = 500.0f;
MapZoneArray[0].level = LEVEL_NONE; MapZoneArray[0].level = LEVEL_NONE;
TotalNumberOfMapZones = 1;
} }
//--MIAMI: done
void void
CTheZones::Update(void) CTheZones::Update(void)
{ {
CVector pos; CVector pos;
pos = FindPlayerCoors(); pos = FindPlayerCoors();
m_pPlayersZone = FindSmallestZonePosition(&pos); m_CurrLevel = GetLevelFromPosition(&pos);
m_CurrLevel = GetLevelFromPosition(pos);
} }
//--MIAMI: done
void void
CTheZones::CreateZone(char *name, eZoneType type, CTheZones::CreateZone(char *name, eZoneType type,
float minx, float miny, float minz, float minx, float miny, float minz,
float maxx, float maxy, float maxz, float maxx, float maxy, float maxz,
eLevelName level) eLevelName level)
{ {
CZone *zone; char tmpname[24];
char *p; char *p;
if(minx > maxx) SWAPF(minx, maxx); if(minx > maxx) SWAPF(minx, maxx);
@ -138,46 +158,94 @@ CTheZones::CreateZone(char *name, eZoneType type,
// make upper case // make upper case
for(p = name; *p; p++) if(islower(*p)) *p = toupper(*p); for(p = name; *p; p++) if(islower(*p)) *p = toupper(*p);
strncpy(tmpname, name, 7);
tmpname[7] = '\0';
// add zone // add zone
// TODO(MIAMI): do this properly, also navig zones switch(type){
if(type == ZONE_MAPZONE) case ZONE_DEFAULT:
zone = &MapZoneArray[TotalNumberOfMapZones++]; case ZONE_NAVIG:
else assert(TotalNumberOfNavigationZones < NUMNAVIGZONES);
zone = &ZoneArray[TotalNumberOfZones++]; strcpy(NavigationZoneArray[TotalNumberOfNavigationZones].name, tmpname);
strncpy(zone->name, name, 7); NavigationZoneArray[TotalNumberOfNavigationZones].type = type;
zone->name[7] = '\0'; NavigationZoneArray[TotalNumberOfNavigationZones].minx = minx;
zone->type = type; NavigationZoneArray[TotalNumberOfNavigationZones].miny = miny;
zone->minx = minx; NavigationZoneArray[TotalNumberOfNavigationZones].minz = minz;
zone->miny = miny; NavigationZoneArray[TotalNumberOfNavigationZones].maxx = maxx;
zone->minz = minz; NavigationZoneArray[TotalNumberOfNavigationZones].maxy = maxy;
zone->maxx = maxx; NavigationZoneArray[TotalNumberOfNavigationZones].maxz = maxz;
zone->maxy = maxy; NavigationZoneArray[TotalNumberOfNavigationZones].level = level;
zone->maxz = maxz; TotalNumberOfNavigationZones++;
zone->level = level; break;
if(type == ZONE_AUDIO || type == ZONE_TYPE1 || type == ZONE_TYPE2){ case ZONE_INFO:
zone->zoneinfoDay = TotalNumberOfZoneInfos++; assert(TotalNumberOfInfoZones < NUMINFOZONES);
zone->zoneinfoNight = TotalNumberOfZoneInfos++; strcpy(InfoZoneArray[TotalNumberOfInfoZones].name, tmpname);
InfoZoneArray[TotalNumberOfInfoZones].type = type;
InfoZoneArray[TotalNumberOfInfoZones].minx = minx;
InfoZoneArray[TotalNumberOfInfoZones].miny = miny;
InfoZoneArray[TotalNumberOfInfoZones].minz = minz;
InfoZoneArray[TotalNumberOfInfoZones].maxx = maxx;
InfoZoneArray[TotalNumberOfInfoZones].maxy = maxy;
InfoZoneArray[TotalNumberOfInfoZones].maxz = maxz;
InfoZoneArray[TotalNumberOfInfoZones].level = level;
InfoZoneArray[TotalNumberOfInfoZones].zoneinfoDay = TotalNumberOfZoneInfos++;
InfoZoneArray[TotalNumberOfInfoZones].zoneinfoNight = TotalNumberOfZoneInfos++;
TotalNumberOfInfoZones++;
break;
case ZONE_MAPZONE:
assert(TotalNumberOfMapZones < NUMMAPZONES);
strcpy(MapZoneArray[TotalNumberOfMapZones].name, tmpname);
MapZoneArray[TotalNumberOfMapZones].type = type;
MapZoneArray[TotalNumberOfMapZones].minx = minx;
MapZoneArray[TotalNumberOfMapZones].miny = miny;
MapZoneArray[TotalNumberOfMapZones].minz = minz;
MapZoneArray[TotalNumberOfMapZones].maxx = maxx;
MapZoneArray[TotalNumberOfMapZones].maxy = maxy;
MapZoneArray[TotalNumberOfMapZones].maxz = maxz;
MapZoneArray[TotalNumberOfMapZones].level = level;
TotalNumberOfMapZones++;
break;
} }
} }
//--MIAMI: done
void void
CTheZones::PostZoneCreation(void) CTheZones::PostZoneCreation(void)
{ {
int i; int i;
for(i = 1; i < TotalNumberOfZones; i++) for(i = 1; i < TotalNumberOfNavigationZones; i++)
InsertZoneIntoZoneHierarchy(&ZoneArray[i]); InsertZoneIntoZoneHierarchy(&NavigationZoneArray[i]);
InitialiseAudioZoneArray(); InitialiseAudioZoneArray();
} }
//--MIAMI: done, but does nothing
void
CTheZones::CheckZonesForOverlap(void)
{
int i, j;
char str[116];
for(i = 1; i < TotalNumberOfInfoZones; i++){
ZoneIsEntirelyContainedWithinOtherZone(&InfoZoneArray[i], &InfoZoneArray[0]);
for(j = 1; j < TotalNumberOfInfoZones; j++)
if(i != j && ZoneIsEntirelyContainedWithinOtherZone(&InfoZoneArray[i], &InfoZoneArray[j]))
sprintf(str, "Info zone %s contains %s\n",
&InfoZoneArray[j].name, &InfoZoneArray[i].name);
}
}
//--MIAMI: done
void void
CTheZones::InsertZoneIntoZoneHierarchy(CZone *zone) CTheZones::InsertZoneIntoZoneHierarchy(CZone *zone)
{ {
zone->child = nil; zone->child = nil;
zone->parent = nil; zone->parent = nil;
zone->next = nil; zone->next = nil;
InsertZoneIntoZoneHierRecursive(zone, &ZoneArray[0]); InsertZoneIntoZoneHierRecursive(zone, &NavigationZoneArray[0]);
} }
//--MIAMI: done
bool bool
CTheZones::InsertZoneIntoZoneHierRecursive(CZone *inner, CZone *outer) CTheZones::InsertZoneIntoZoneHierRecursive(CZone *inner, CZone *outer)
{ {
@ -221,6 +289,7 @@ CTheZones::InsertZoneIntoZoneHierRecursive(CZone *inner, CZone *outer)
return true; return true;
} }
//--MIAMI: done
bool bool
CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer) CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
{ {
@ -233,11 +302,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;
@ -245,16 +314,18 @@ CTheZones::ZoneIsEntirelyContainedWithinOtherZone(CZone *inner, CZone *outer)
return true; return true;
} }
//--MIAMI: done
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;
} }
//--MIAMI: done
eLevelName eLevelName
CTheZones::GetLevelFromPosition(CVector const &v) CTheZones::GetLevelFromPosition(CVector const *v)
{ {
int i; int i;
// char tmp[116]; // char tmp[116];
@ -266,59 +337,35 @@ CTheZones::GetLevelFromPosition(CVector const &v)
return MapZoneArray[0].level; return MapZoneArray[0].level;
} }
//--MIAMI: done
CZone* CZone*
CTheZones::FindSmallestZonePosition(const CVector *v) CTheZones::FindInformationZoneForPosition(const CVector *v)
{ {
CZone *best = &ZoneArray[0]; int i;
// zone to test next // char tmp[116];
CZone *zone = ZoneArray[0].child; // if(!PointLiesWithinZone(v, &InfoZoneArray[0]))
while(zone) // sprintf(tmp, "x = %.3f y= %.3f z = %.3f\n", v.x, v.y, v.z);
// if in zone, descent into children for(i = 1; i < TotalNumberOfInfoZones; i++)
if(PointLiesWithinZone(*v, zone)){ if(PointLiesWithinZone(v, &InfoZoneArray[i]))
best = zone; return &InfoZoneArray[i];
zone = zone->child; return &InfoZoneArray[0];
// otherwise try next zone
}else
zone = zone->next;
return best;
} }
//--MIAMI: done
CZone* CZone*
CTheZones::FindSmallestZonePositionType(const CVector *v, eZoneType type) CTheZones::FindSmallestNavigationZoneForPosition(const CVector *v, bool findDefault, bool findNavig)
{ {
CZone *best = nil; CZone *best = nil;
if(ZoneArray[0].type == type) if(findDefault && NavigationZoneArray[0].type == ZONE_DEFAULT ||
best = &ZoneArray[0]; findNavig && NavigationZoneArray[0].type == ZONE_NAVIG)
best = &NavigationZoneArray[0];
// zone to test next // zone to test next
CZone *zone = ZoneArray[0].child; CZone *zone = NavigationZoneArray[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(findDefault && zone->type == ZONE_DEFAULT ||
best = zone; findNavig && zone->type == ZONE_NAVIG)
zone = zone->child;
// otherwise try next zone
}else
zone = zone->next;
return best;
}
CZone*
CTheZones::FindSmallestZonePositionILN(const CVector *v)
{
CZone *best = nil;
if(ZoneArray[0].type == ZONE_AUDIO ||
ZoneArray[0].type == ZONE_TYPE1 ||
ZoneArray[0].type == ZONE_TYPE2)
best = &ZoneArray[0];
// zone to test next
CZone *zone = ZoneArray[0].child;
while(zone)
// if in zone, descent into children
if(PointLiesWithinZone(*v, zone)){
if(zone->type == ZONE_AUDIO ||
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
@ -327,23 +374,72 @@ CTheZones::FindSmallestZonePositionILN(const CVector *v)
return best; return best;
} }
//--MIAMI: done
int16 int16
CTheZones::FindZoneByLabelAndReturnIndex(char *name) CTheZones::FindZoneByLabelAndReturnIndex(char *name, eZoneType type)
{ {
char str[8]; char str[8];
memset(str, 0, 8); memset(str, 0, 8);
strncpy(str, name, 8); strncpy(str, name, 8);
for(FindIndex = 0; FindIndex < TotalNumberOfZones; FindIndex++) switch(type){
if(strcmp(GetZone(FindIndex)->name, name) == 0) case ZONE_DEFAULT:
case ZONE_NAVIG:
for(FindIndex = 0; FindIndex < TotalNumberOfNavigationZones; FindIndex++)
if(strcmp(GetNavigationZone(FindIndex)->name, name) == 0)
return FindIndex; return FindIndex;
break;
case ZONE_INFO:
for(FindIndex = 0; FindIndex < TotalNumberOfInfoZones; FindIndex++)
if(strcmp(GetInfoZone(FindIndex)->name, name) == 0)
return FindIndex;
break;
case ZONE_MAPZONE:
for(FindIndex = 0; FindIndex < TotalNumberOfMapZones; FindIndex++)
if(strcmp(GetMapZone(FindIndex)->name, name) == 0)
return FindIndex;
break;
}
return -1; return -1;
} }
//--MIAMI: done
int16
CTheZones::FindNextZoneByLabelAndReturnIndex(char *name, eZoneType type)
{
char str[8];
memset(str, 0, 8);
strncpy(str, name, 8);
switch(type){
case ZONE_DEFAULT:
case ZONE_NAVIG:
for(; FindIndex < TotalNumberOfNavigationZones; FindIndex++)
if(strcmp(GetNavigationZone(FindIndex)->name, name) == 0)
return FindIndex;
break;
case ZONE_INFO:
for(; FindIndex < TotalNumberOfInfoZones; FindIndex++)
if(strcmp(GetInfoZone(FindIndex)->name, name) == 0)
return FindIndex;
break;
case ZONE_MAPZONE:
for(; FindIndex < TotalNumberOfMapZones; FindIndex++)
if(strcmp(GetMapZone(FindIndex)->name, name) == 0)
return FindIndex;
break;
}
return -1;
}
//--MIAMI: done
CZoneInfo* CZoneInfo*
CTheZones::GetZoneInfo(const CVector *v, uint8 day) CTheZones::GetZoneInfo(const CVector *v, uint8 day)
{ {
CZone *zone; CZone *zone;
zone = FindSmallestZonePositionILN(v); zone = FindInformationZoneForPosition(v);
if(zone == nil) if(zone == nil)
return &ZoneInfoArray[0]; return &ZoneInfoArray[0];
return &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight]; return &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight];
@ -421,7 +517,7 @@ CTheZones::SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity,
{ {
CZone *zone; CZone *zone;
CZoneInfo *info; CZoneInfo *info;
zone = GetZone(zoneid); zone = GetInfoZone(zoneid);
info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight]; info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight];
CheckZoneInfo(info); CheckZoneInfo(info);
@ -486,7 +582,7 @@ CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity,
{ {
CZone *zone; CZone *zone;
CZoneInfo *info; CZoneInfo *info;
zone = GetZone(zoneid); zone = GetInfoZone(zoneid);
info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight]; info = &ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight];
if(pedDensity != -1) info->pedDensity = pedDensity; if(pedDensity != -1) info->pedDensity = pedDensity;
if(copDensity != -1) info->copDensity = copDensity; if(copDensity != -1) info->copDensity = copDensity;
@ -501,60 +597,64 @@ CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity,
if(gang8Density != -1) info->gangDensity[8] = gang8Density; if(gang8Density != -1) info->gangDensity[8] = gang8Density;
} }
//--MIAMI: done, unused
void void
CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity) CTheZones::SetCarDensity(uint16 zoneid, uint8 day, uint16 cardensity)
{ {
CZone *zone; CZone *zone;
zone = GetZone(zoneid); zone = GetInfoZone(zoneid);
if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity; ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].carDensity = cardensity;
} }
//--MIAMI: done, unused
void void
CTheZones::SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity) CTheZones::SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity)
{ {
CZone *zone; CZone *zone;
zone = GetZone(zoneid); zone = GetInfoZone(zoneid);
if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedDensity = peddensity; ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedDensity = peddensity;
} }
//--MIAMI: done
void void
CTheZones::SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup) CTheZones::SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup)
{ {
CZone *zone; CZone *zone;
zone = GetZone(zoneid); zone = GetInfoZone(zoneid);
if(zone->type == ZONE_AUDIO || zone->type == ZONE_TYPE1 || zone->type == ZONE_TYPE2)
ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedGroup = pedgroup; ZoneInfoArray[day ? zone->zoneinfoDay : zone->zoneinfoNight].pedGroup = pedgroup;
} }
//--MIAMI: done
int16 int16
CTheZones::FindAudioZone(CVector *pos) 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;
} }
//--MIAMI: done
void void
CTheZones::AddZoneToAudioZoneArray(CZone *zone) 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 */
z = -1; z = -1;
for(i = 0; i < NUMZONES; i++) for(i = 0; i < NUMNAVIGZONES; i++)
if(&ZoneArray[i] == zone) if(&NavigationZoneArray[i] == zone)
z = i; z = i;
assert(NumberOfAudioZones < NUMAUDIOZONES);
AudioZoneArray[NumberOfAudioZones++] = z; AudioZoneArray[NumberOfAudioZones++] = z;
} }
//--MIAMI: done
void void
CTheZones::InitialiseAudioZoneArray(void) CTheZones::InitialiseAudioZoneArray(void)
{ {
@ -562,7 +662,7 @@ CTheZones::InitialiseAudioZoneArray(void)
CZone *zone; CZone *zone;
gonext = false; gonext = false;
zone = &ZoneArray[0]; zone = &NavigationZoneArray[0];
// Go deep first, // Go deep first,
// set gonext when backing up a level to visit the next child // set gonext when backing up a level to visit the next child
while(zone) while(zone)
@ -586,6 +686,7 @@ CTheZones::InitialiseAudioZoneArray(void)
} }
} }
//--MIAMI: TODO
void void
CTheZones::SaveAllZones(uint8 *buffer, uint32 *size) CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
{ {
@ -593,32 +694,39 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
int i; int i;
*size = SAVE_HEADER_SIZE *size = SAVE_HEADER_SIZE
+ sizeof(int32) // GetIndexForZonePointer
+ sizeof(m_CurrLevel) + sizeof(FindIndex) + sizeof(m_CurrLevel) + sizeof(FindIndex)
+ sizeof(int16) // padding + sizeof(int16) // padding
+ sizeof(ZoneArray) + sizeof(ZoneInfoArray) + sizeof(NavigationZoneArray) + sizeof(InfoZoneArray) + sizeof(ZoneInfoArray)
+ sizeof(TotalNumberOfZones) + sizeof(TotalNumberOfZoneInfos) + sizeof(TotalNumberOfNavigationZones) + sizeof(TotalNumberOfInfoZones) + sizeof(TotalNumberOfZoneInfos)
+ sizeof(MapZoneArray) + sizeof(AudioZoneArray) + sizeof(MapZoneArray) + sizeof(AudioZoneArray)
+ sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones); + sizeof(TotalNumberOfMapZones) + sizeof(NumberOfAudioZones);
WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE); WriteSaveHeader(buffer, 'Z', 'N', 'S', '\0', *size - SAVE_HEADER_SIZE);
WriteSaveBuf(buffer, GetIndexForZonePointer(m_pPlayersZone));
WriteSaveBuf(buffer, m_CurrLevel); WriteSaveBuf(buffer, m_CurrLevel);
WriteSaveBuf(buffer, FindIndex); WriteSaveBuf(buffer, FindIndex);
WriteSaveBuf(buffer, (int16)0); // padding WriteSaveBuf(buffer, (int16)0); // padding
for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){ // TODO(MIAMI): implement SaveOneZone
CZone *zone = WriteSaveBuf(buffer, ZoneArray[i]); for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++){
zone->child = (CZone*)GetIndexForZonePointer(ZoneArray[i].child); CZone *zone = WriteSaveBuf(buffer, NavigationZoneArray[i]);
zone->parent = (CZone*)GetIndexForZonePointer(ZoneArray[i].parent); zone->child = (CZone*)GetIndexForZonePointer(NavigationZoneArray[i].child);
zone->next = (CZone*)GetIndexForZonePointer(ZoneArray[i].next); zone->parent = (CZone*)GetIndexForZonePointer(NavigationZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(NavigationZoneArray[i].next);
}
for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++){
CZone *zone = WriteSaveBuf(buffer, InfoZoneArray[i]);
zone->child = (CZone*)GetIndexForZonePointer(InfoZoneArray[i].child);
zone->parent = (CZone*)GetIndexForZonePointer(InfoZoneArray[i].parent);
zone->next = (CZone*)GetIndexForZonePointer(InfoZoneArray[i].next);
} }
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
WriteSaveBuf(buffer, ZoneInfoArray[i]); WriteSaveBuf(buffer, ZoneInfoArray[i]);
WriteSaveBuf(buffer, TotalNumberOfZones); WriteSaveBuf(buffer, TotalNumberOfNavigationZones);
WriteSaveBuf(buffer, TotalNumberOfInfoZones);
WriteSaveBuf(buffer, TotalNumberOfZoneInfos); WriteSaveBuf(buffer, TotalNumberOfZoneInfos);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++) { for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++) {
@ -646,6 +754,7 @@ CTheZones::SaveAllZones(uint8 *buffer, uint32 *size)
VALIDATESAVEBUF(*size) VALIDATESAVEBUF(*size)
} }
//--MIAMI: TODO
void void
CTheZones::LoadAllZones(uint8 *buffer, uint32 size) CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
{ {
@ -654,23 +763,32 @@ CTheZones::LoadAllZones(uint8 *buffer, uint32 size)
CheckSaveHeader(buffer, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE); CheckSaveHeader(buffer, 'Z', 'N', 'S', '\0', size - SAVE_HEADER_SIZE);
m_pPlayersZone = GetPointerForZoneIndex(ReadSaveBuf<int32>(buffer));
m_CurrLevel = ReadSaveBuf<eLevelName>(buffer); m_CurrLevel = ReadSaveBuf<eLevelName>(buffer);
FindIndex = ReadSaveBuf<int16>(buffer); FindIndex = ReadSaveBuf<int16>(buffer);
ReadSaveBuf<int16>(buffer); ReadSaveBuf<int16>(buffer);
for(i = 0; i < ARRAY_SIZE(ZoneArray); i++){ // TODO(MIAMI): implement LoadOneZone
ZoneArray[i] = ReadSaveBuf<CZone>(buffer); for(i = 0; i < ARRAY_SIZE(NavigationZoneArray); i++){
NavigationZoneArray[i] = ReadSaveBuf<CZone>(buffer);
ZoneArray[i].child = GetPointerForZoneIndex((int32)ZoneArray[i].child); NavigationZoneArray[i].child = GetPointerForZoneIndex((int32)NavigationZoneArray[i].child);
ZoneArray[i].parent = GetPointerForZoneIndex((int32)ZoneArray[i].parent); NavigationZoneArray[i].parent = GetPointerForZoneIndex((int32)NavigationZoneArray[i].parent);
ZoneArray[i].next = GetPointerForZoneIndex((int32)ZoneArray[i].next); NavigationZoneArray[i].next = GetPointerForZoneIndex((int32)NavigationZoneArray[i].next);
}
for(i = 0; i < ARRAY_SIZE(InfoZoneArray); i++){
InfoZoneArray[i] = ReadSaveBuf<CZone>(buffer);
InfoZoneArray[i].child = GetPointerForZoneIndex((int32)InfoZoneArray[i].child);
InfoZoneArray[i].parent = GetPointerForZoneIndex((int32)InfoZoneArray[i].parent);
InfoZoneArray[i].next = GetPointerForZoneIndex((int32)InfoZoneArray[i].next);
} }
for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++) for(i = 0; i < ARRAY_SIZE(ZoneInfoArray); i++)
ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer); ZoneInfoArray[i] = ReadSaveBuf<CZoneInfo>(buffer);
TotalNumberOfZones = ReadSaveBuf<int16>(buffer); TotalNumberOfNavigationZones = ReadSaveBuf<int16>(buffer);
TotalNumberOfInfoZones = ReadSaveBuf<int16>(buffer);
TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer); TotalNumberOfZoneInfos = ReadSaveBuf<int16>(buffer);
for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){ for(i = 0; i < ARRAY_SIZE(MapZoneArray); i++){

View file

@ -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,19 +51,20 @@ public:
class CTheZones class CTheZones
{ {
public:
static eLevelName m_CurrLevel;
static CZone *m_pPlayersZone;
static int16 FindIndex; static int16 FindIndex;
static uint16 NumberOfAudioZones; static uint16 NumberOfAudioZones;
static int16 AudioZoneArray[NUMAUDIOZONES]; static int16 AudioZoneArray[NUMAUDIOZONES];
static uint16 TotalNumberOfMapZones; static uint16 TotalNumberOfMapZones;
static uint16 TotalNumberOfZones; static uint16 TotalNumberOfInfoZones;
static CZone ZoneArray[NUMZONES]; static uint16 TotalNumberOfNavigationZones;
static CZone InfoZoneArray[NUMINFOZONES];
static CZone MapZoneArray[NUMMAPZONES]; static CZone MapZoneArray[NUMMAPZONES];
static CZone NavigationZoneArray[NUMNAVIGZONES];
static uint16 TotalNumberOfZoneInfos; static uint16 TotalNumberOfZoneInfos;
static CZoneInfo ZoneInfoArray[2*NUMZONES]; static CZoneInfo ZoneInfoArray[2*NUMINFOZONES];
public:
static eLevelName m_CurrLevel;
static void Init(void); static void Init(void);
static void Update(void); static void Update(void);
@ -71,17 +72,21 @@ public:
float minx, float miny, float minz, float minx, float miny, float minz,
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 *GetInfoZone(uint16 i) { return &InfoZoneArray[i]; }
static CZone *GetNavigationZone(uint16 i) { return &NavigationZoneArray[i]; }
static CZone *GetMapZone(uint16 i) { return &MapZoneArray[i]; }
static CZone *GetAudioZone(uint16 i) { return &InfoZoneArray[AudioZoneArray[i]]; }
static void PostZoneCreation(void); static void PostZoneCreation(void);
static void CheckZonesForOverlap(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 *FindInformationZoneForPosition(const CVector *v);
static CZone *FindSmallestZonePositionType(const CVector *v, eZoneType type); static CZone *FindSmallestNavigationZoneForPosition(const CVector *v, bool findDefault, bool findNavig);
static CZone *FindSmallestZonePositionILN(const CVector *v); static int16 FindZoneByLabelAndReturnIndex(char *name, eZoneType type);
static int16 FindZoneByLabelAndReturnIndex(char *name); static int16 FindNextZoneByLabelAndReturnIndex(char *name, eZoneType type);
static CZoneInfo *GetZoneInfo(const CVector *v, uint8 day); static CZoneInfo *GetZoneInfo(const CVector *v, uint8 day);
static void GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info); static void GetZoneInfoForTimeOfDay(const CVector *pos, CZoneInfo *info);
static void SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity, static void SetZoneCarInfo(uint16 zoneid, uint8 day, int16 carDensity,
@ -99,8 +104,8 @@ public:
static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity); static void SetPedDensity(uint16 zoneid, uint8 day, uint16 peddensity);
static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup); static void SetPedGroup(uint16 zoneid, uint8 day, uint16 pedgroup);
static int16 FindAudioZone(CVector *pos); static int16 FindAudioZone(CVector *pos);
static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &ZoneArray[i]; } static CZone *GetPointerForZoneIndex(int32 i) { return i == -1 ? nil : &InfoZoneArray[i]; }
static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - ZoneArray; } static int32 GetIndexForZonePointer(CZone *zone) { return zone == nil ? -1 : zone - InfoZoneArray; }
static void AddZoneToAudioZoneArray(CZone *zone); static void AddZoneToAudioZoneArray(CZone *zone);
static void InitialiseAudioZoneArray(void); static void InitialiseAudioZoneArray(void);
static void SaveAllZones(uint8 *buffer, uint32 *length); static void SaveAllZones(uint8 *buffer, uint32 *length);

View file

@ -53,14 +53,13 @@ enum Config {
NUMREFERENCES = 800, NUMREFERENCES = 800,
// Zones // Zones
NUMAUDIOZONES = 36, NUMAUDIOZONES = 14,
NUMZONES = 50, NUMINFOZONES = 169,
NUMMAPZONES = 25, NUMMAPZONES = 39,
NUMNAVIGZONES = 20,
// Cull zones // Cull zones
NUMCULLZONES = 512, NUMATTRIBZONES = 704,
NUMATTRIBZONES = 288,
NUMZONEINDICES = 55000,
NUMHANDLINGS = 57, NUMHANDLINGS = 57,

View file

@ -333,7 +333,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(mi->m_lodDistances[0] <= 2000.0f) if(mi->m_lodDistances[0] <= 2000.0f)
bStreamBIGBuilding = true; bStreamBIGBuilding = true;
if(mi->m_lodDistances[0] > 2500.0f || mi->m_ignoreDrawDist) if(mi->m_lodDistances[0] > 2500.0f || mi->m_ignoreDrawDist)

View file

@ -361,7 +361,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

View file

@ -1003,9 +1003,6 @@ CRenderer::ScanSectorList(CPtrList *lists)
continue; // already seen continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->m_scanCode = CWorld::GetCurrentScanCode();
#ifdef GTA_ZONECULL
if(IsEntityCullZoneVisible(ent))
#endif
switch(SetupEntityVisibility(ent)){ switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE: case VIS_VISIBLE:
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
@ -1028,14 +1025,6 @@ CRenderer::ScanSectorList(CPtrList *lists)
CStreaming::RequestModel(ent->GetModelIndex(), 0); CStreaming::RequestModel(ent->GetModelIndex(), 0);
break; break;
} }
#ifdef GTA_ZONECULL
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
if(!CStreaming::ms_disableStreaming)
if(SetupEntityVisibility(ent) == VIS_STREAMME)
if(!m_loadingPriority || CStreaming::ms_numModelsRequested < 10)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}
#endif
} }
} }
} }
@ -1057,9 +1046,6 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
continue; // already seen continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->m_scanCode = CWorld::GetCurrentScanCode();
#ifdef GTA_ZONECULL
if(IsEntityCullZoneVisible(ent))
#endif
switch(SetupEntityVisibility(ent)){ switch(SetupEntityVisibility(ent)){
case VIS_VISIBLE: case VIS_VISIBLE:
ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent;
@ -1084,13 +1070,6 @@ CRenderer::ScanSectorList_Priority(CPtrList *lists)
} }
break; break;
} }
#ifdef GTA_ZONECULL
else if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){
if(!CStreaming::ms_disableStreaming)
if(SetupEntityVisibility(ent) == VIS_STREAMME)
CStreaming::RequestModel(ent->GetModelIndex(), 0);
}
#endif
} }
} }
} }
@ -1143,9 +1122,6 @@ CRenderer::ScanSectorList_RequestModels(CPtrList *lists)
if(ent->m_scanCode == CWorld::GetCurrentScanCode()) if(ent->m_scanCode == CWorld::GetCurrentScanCode())
continue; // already seen continue; // already seen
ent->m_scanCode = CWorld::GetCurrentScanCode(); ent->m_scanCode = CWorld::GetCurrentScanCode();
#ifdef GTA_ZONECULL
if(IsEntityCullZoneVisible(ent))
#endif
if(ShouldModelBeStreamed(ent)) if(ShouldModelBeStreamed(ent))
CStreaming::RequestModel(ent->GetModelIndex(), 0); CStreaming::RequestModel(ent->GetModelIndex(), 0);
} }
@ -1191,51 +1167,6 @@ CRenderer::ShouldModelBeStreamed(CEntity *ent)
return dist - FADE_DISTANCE - STREAM_DISTANCE < mi->GetLargestLodDistance(); return dist - FADE_DISTANCE - STREAM_DISTANCE < mi->GetLargestLodDistance();
} }
#ifdef GTA_ZONECULL
bool
CRenderer::IsEntityCullZoneVisible(CEntity *ent)
{
CPed *ped;
CObject *obj;
if(ent->bZoneCulled)
return false;
switch(ent->GetType()){
case ENTITY_TYPE_VEHICLE:
return IsVehicleCullZoneVisible(ent);
case ENTITY_TYPE_PED:
ped = (CPed*)ent;
if (ped->bInVehicle) {
if (ped->m_pMyVehicle)
return IsVehicleCullZoneVisible(ped->m_pMyVehicle);
else
return true;
}
return !(ped->m_pCurSurface && ped->m_pCurSurface->bZoneCulled2);
case ENTITY_TYPE_OBJECT:
obj = (CObject*)ent;
if(!obj->IsStatic())
return true;
return !(obj->m_pCurSurface && obj->m_pCurSurface->bZoneCulled2);
}
return true;
}
bool
CRenderer::IsVehicleCullZoneVisible(CEntity *ent)
{
CVehicle *v = (CVehicle*)ent;
switch(v->GetStatus())
case STATUS_SIMPLE:
case STATUS_PHYSICS:
case STATUS_ABANDONED:
case STATUS_WRECKED:
return !(v->m_pCurGroundEntity && v->m_pCurGroundEntity->bZoneCulled2);
return true;
}
#endif
void void
CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset) CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset)
{ {

View file

@ -62,10 +62,6 @@ public:
static void SortBIGBuildingsForSectorList(CPtrList *list); static void SortBIGBuildingsForSectorList(CPtrList *list);
static bool ShouldModelBeStreamed(CEntity *ent); static bool ShouldModelBeStreamed(CEntity *ent);
#ifdef GTA_ZONECULL
static bool IsEntityCullZoneVisible(CEntity *ent);
static bool IsVehicleCullZoneVisible(CEntity *ent);
#endif
static void RemoveVehiclePedLights(CEntity *ent, bool reset); static void RemoveVehiclePedLights(CEntity *ent, bool reset);
}; };