2019-05-15 16:52:37 +02:00
|
|
|
#include "common.h"
|
2020-04-17 15:31:11 +02:00
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
#include "Building.h"
|
|
|
|
#include "Treadable.h"
|
2019-06-28 19:23:28 +02:00
|
|
|
#include "Train.h"
|
2019-05-15 16:52:37 +02:00
|
|
|
#include "Pools.h"
|
|
|
|
#include "Timer.h"
|
|
|
|
#include "Camera.h"
|
|
|
|
#include "World.h"
|
2019-06-13 12:25:55 +02:00
|
|
|
#include "FileMgr.h"
|
2019-07-07 13:09:11 +02:00
|
|
|
#include "ZoneCull.h"
|
2019-11-02 18:15:01 +01:00
|
|
|
#include "Zones.h"
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2020-04-17 07:54:14 +02:00
|
|
|
int32 CCullZones::NumAttributeZones;
|
|
|
|
CAttributeZone CCullZones::aAttributeZones[NUMATTRIBZONES];
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2020-04-17 07:54:14 +02:00
|
|
|
int32 CCullZones::CurrentWantedLevelDrop_Player;
|
|
|
|
int32 CCullZones::CurrentFlags_Camera;
|
|
|
|
int32 CCullZones::CurrentFlags_Player;
|
|
|
|
bool CCullZones::bCurrentSubwayIsInvisible;
|
2019-05-15 16:52:37 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
CCullZones::Init(void)
|
|
|
|
{
|
|
|
|
NumAttributeZones = 0;
|
|
|
|
CurrentWantedLevelDrop_Player = 0;
|
|
|
|
CurrentFlags_Camera = 0;
|
|
|
|
CurrentFlags_Player = 0;
|
2020-05-03 17:44:10 +02:00
|
|
|
bCurrentSubwayIsInvisible = false;
|
2019-11-02 18:15:01 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
void
|
|
|
|
CCullZones::Update(void)
|
|
|
|
{
|
|
|
|
bool invisible;
|
|
|
|
|
|
|
|
switch(CTimer::GetFrameCounter() & 7){
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
/* Update camera attributes */
|
|
|
|
CurrentFlags_Camera = FindAttributesForCoors(TheCamera.GetGameCamPosition(), nil);
|
|
|
|
invisible = (CurrentFlags_Camera & ATTRZONE_SUBWAYVISIBLE) == 0;
|
|
|
|
if(invisible != bCurrentSubwayIsInvisible){
|
|
|
|
MarkSubwayAsInvisible(!invisible);
|
|
|
|
bCurrentSubwayIsInvisible = invisible;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
/* Update player attributes */
|
2019-06-29 11:09:33 +02:00
|
|
|
CurrentFlags_Player = FindAttributesForCoors(FindPlayerCoors(),
|
2019-05-15 16:52:37 +02:00
|
|
|
&CurrentWantedLevelDrop_Player);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CCullZones::ForceCullZoneCoors(CVector coors)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int32
|
|
|
|
CCullZones::FindAttributesForCoors(CVector coors, int32 *wantedLevel)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int32 attribs;
|
|
|
|
|
2020-01-01 21:55:01 +01:00
|
|
|
if (wantedLevel)
|
|
|
|
*wantedLevel = 0;
|
2019-05-15 16:52:37 +02:00
|
|
|
attribs = 0;
|
|
|
|
for(i = 0; i < NumAttributeZones; i++)
|
|
|
|
if(coors.x >= aAttributeZones[i].minx && coors.x <= aAttributeZones[i].maxx &&
|
|
|
|
coors.y >= aAttributeZones[i].miny && coors.y <= aAttributeZones[i].maxy &&
|
|
|
|
coors.z >= aAttributeZones[i].minz && coors.z <= aAttributeZones[i].maxz){
|
|
|
|
attribs |= aAttributeZones[i].attributes;
|
2020-01-01 21:55:01 +01:00
|
|
|
if(wantedLevel)
|
2020-04-19 18:34:08 +02:00
|
|
|
*wantedLevel = Max(*wantedLevel, aAttributeZones[i].wantedLevel);
|
2019-05-15 16:52:37 +02:00
|
|
|
}
|
|
|
|
return attribs;
|
|
|
|
}
|
|
|
|
|
|
|
|
CAttributeZone*
|
|
|
|
CCullZones::FindZoneWithStairsAttributeForPlayer(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
CVector coors;
|
|
|
|
|
2019-06-29 11:09:33 +02:00
|
|
|
coors = FindPlayerCoors();
|
2019-05-15 16:52:37 +02:00
|
|
|
for(i = 0; i < NumAttributeZones; i++)
|
|
|
|
if(aAttributeZones[i].attributes & ATTRZONE_STAIRS &&
|
|
|
|
coors.x >= aAttributeZones[i].minx && coors.x <= aAttributeZones[i].maxx &&
|
|
|
|
coors.y >= aAttributeZones[i].miny && coors.y <= aAttributeZones[i].maxy &&
|
|
|
|
coors.z >= aAttributeZones[i].minz && coors.z <= aAttributeZones[i].maxz)
|
|
|
|
return &aAttributeZones[i];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2019-06-28 19:23:28 +02:00
|
|
|
void
|
2019-05-15 16:52:37 +02:00
|
|
|
CCullZones::MarkSubwayAsInvisible(bool visible)
|
2019-06-28 19:23:28 +02:00
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
CEntity *e;
|
|
|
|
CVehicle *v;
|
|
|
|
|
2019-10-16 23:53:25 +02:00
|
|
|
n = CPools::GetBuildingPool()->GetSize()-1;
|
|
|
|
for(i = n; i >= 0; i--){
|
2019-06-28 19:23:28 +02:00
|
|
|
e = CPools::GetBuildingPool()->GetSlot(i);
|
|
|
|
if(e && e->bIsSubway)
|
|
|
|
e->bIsVisible = visible;
|
|
|
|
}
|
|
|
|
|
2019-10-16 23:53:25 +02:00
|
|
|
n = CPools::GetTreadablePool()->GetSize()-1;
|
|
|
|
for(i = n; i >= 0; i--){
|
2019-06-28 19:23:28 +02:00
|
|
|
e = CPools::GetTreadablePool()->GetSlot(i);
|
|
|
|
if(e && e->bIsSubway)
|
|
|
|
e->bIsVisible = visible;
|
|
|
|
}
|
|
|
|
|
2019-10-16 23:53:25 +02:00
|
|
|
n = CPools::GetVehiclePool()->GetSize()-1;
|
|
|
|
for(i = n; i >= 0; i--){
|
2019-06-28 19:23:28 +02:00
|
|
|
v = CPools::GetVehiclePool()->GetSlot(i);
|
2019-07-29 19:18:03 +02:00
|
|
|
if(v && v->IsTrain() && ((CTrain*)v)->m_nTrackId != TRACK_ELTRAIN)
|
2019-06-28 19:23:28 +02:00
|
|
|
v->bIsVisible = visible;
|
|
|
|
}
|
2019-05-15 16:52:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CCullZones::AddCullZone(CVector const &position,
|
|
|
|
float minx, float maxx,
|
|
|
|
float miny, float maxy,
|
|
|
|
float minz, float maxz,
|
|
|
|
uint16 flag, int16 wantedLevel)
|
|
|
|
{
|
|
|
|
CAttributeZone *attrib;
|
|
|
|
|
2020-05-06 12:23:57 +02:00
|
|
|
assert(NumAttributeZones < NUMATTRIBZONES);
|
|
|
|
attrib = &aAttributeZones[NumAttributeZones++];
|
|
|
|
attrib->minx = minx;
|
|
|
|
attrib->maxx = maxx;
|
|
|
|
attrib->miny = miny;
|
|
|
|
attrib->maxy = maxy;
|
|
|
|
attrib->minz = minz;
|
|
|
|
attrib->maxz = maxz;
|
|
|
|
attrib->attributes = flag;
|
|
|
|
attrib->wantedLevel = wantedLevel;
|
2019-11-02 18:15:01 +01:00
|
|
|
}
|