mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-23 20:32:51 +00:00
- refactored the global sectors array into a more VM friendly type and moved it into FLevelLocals.
This commit is contained in:
parent
d381fb5e3f
commit
c02281a439
57 changed files with 438 additions and 456 deletions
|
@ -2781,14 +2781,13 @@ void AM_drawKeys ()
|
|||
void AM_drawThings ()
|
||||
{
|
||||
AMColor color;
|
||||
int i;
|
||||
AActor* t;
|
||||
mpoint_t p;
|
||||
DAngle angle;
|
||||
|
||||
for (i=0;i<numsectors;i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
t = sectors[i].thinglist;
|
||||
t = sec.thinglist;
|
||||
while (t)
|
||||
{
|
||||
if (am_cheat > 0 || !(t->flags6 & MF6_NOTONAUTOMAP))
|
||||
|
|
|
@ -1189,12 +1189,12 @@ static void PrintSecretString(const char *string, bool thislevel)
|
|||
{
|
||||
if (string[1] == 'S' || string[1] == 's')
|
||||
{
|
||||
long secnum = strtol(string+2, (char**)&string, 10);
|
||||
auto secnum = strtoul(string+2, (char**)&string, 10);
|
||||
if (*string == ';') string++;
|
||||
if (thislevel && secnum >= 0 && secnum < numsectors)
|
||||
if (thislevel && secnum < level.sectors.Size())
|
||||
{
|
||||
if (sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED;
|
||||
else if (sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN;
|
||||
if (level.sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED;
|
||||
else if (level.sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN;
|
||||
else colstr = TEXTCOLOR_ORANGE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -530,9 +530,9 @@ void SetCompatibilityParams()
|
|||
}
|
||||
case CP_SECTORFLOOROFFSET:
|
||||
{
|
||||
if (CompatParams[i+1] < numsectors)
|
||||
if ((unsigned)CompatParams[i+1] < level.sectors.Size())
|
||||
{
|
||||
sector_t *sec = §ors[CompatParams[i+1]];
|
||||
sector_t *sec = &level.sectors[CompatParams[i+1]];
|
||||
const double delta = CompatParams[i + 2] / 65536.0;
|
||||
sec->floorplane.ChangeHeight(delta);
|
||||
sec->ChangePlaneTexZ(sector_t::floor, delta);
|
||||
|
@ -542,10 +542,10 @@ void SetCompatibilityParams()
|
|||
}
|
||||
case CP_SETSECTORSPECIAL:
|
||||
{
|
||||
const int index = CompatParams[i + 1];
|
||||
if (index < numsectors)
|
||||
const unsigned index = CompatParams[i + 1];
|
||||
if (index < level.sectors.Size())
|
||||
{
|
||||
sectors[index].special = CompatParams[i + 2];
|
||||
level.sectors[index].special = CompatParams[i + 2];
|
||||
}
|
||||
i += 3;
|
||||
break;
|
||||
|
@ -575,7 +575,7 @@ void SetCompatibilityParams()
|
|||
}
|
||||
case CP_SETTAG:
|
||||
{
|
||||
if ((unsigned)CompatParams[i + 1] < (unsigned)numsectors)
|
||||
if ((unsigned)CompatParams[i + 1] < level.sectors.Size())
|
||||
{
|
||||
// this assumes that the sector does not have any tags yet!
|
||||
if (CompatParams[i + 2] == 0)
|
||||
|
|
|
@ -479,12 +479,10 @@ size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld, bool s
|
|||
}
|
||||
|
||||
// Go through sectors.
|
||||
if (sectors != NULL)
|
||||
{
|
||||
for (i = 0; i < numsectors; ++i)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
#define SECTOR_CHECK(f,t) \
|
||||
if (sectors[i].f.p == static_cast<t *>(old)) { sectors[i].f = static_cast<t *>(notOld); changed++; }
|
||||
if (sec.f.p == static_cast<t *>(old)) { sec.f = static_cast<t *>(notOld); changed++; }
|
||||
SECTOR_CHECK( SoundTarget, AActor );
|
||||
SECTOR_CHECK( SecActTarget, ASectorAction );
|
||||
SECTOR_CHECK( floordata, DSectorEffect );
|
||||
|
@ -492,7 +490,6 @@ size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld, bool s
|
|||
SECTOR_CHECK( lightingdata, DSectorEffect );
|
||||
#undef SECTOR_CHECK
|
||||
}
|
||||
}
|
||||
|
||||
// Go through bot stuff.
|
||||
if (bglobal.firstthing.p == (AActor *)old) bglobal.firstthing = (AActor *)notOld, ++changed;
|
||||
|
|
|
@ -346,13 +346,13 @@ static void MarkRoot()
|
|||
// Mark sound sequences.
|
||||
DSeqNode::StaticMarkHead();
|
||||
// Mark sectors.
|
||||
if (SectorMarker == NULL && sectors != NULL)
|
||||
if (SectorMarker == nullptr && level.sectors.Size() > 0)
|
||||
{
|
||||
SectorMarker = new DSectorMarker;
|
||||
}
|
||||
else if (sectors == NULL)
|
||||
else if (level.sectors.Size() == 0)
|
||||
{
|
||||
SectorMarker = NULL;
|
||||
SectorMarker = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -677,12 +677,11 @@ size_t DSectorMarker::PropagateMark()
|
|||
int i;
|
||||
int marked = 0;
|
||||
bool moretodo = false;
|
||||
int numsectors = level.sectors.Size();
|
||||
|
||||
if (sectors != NULL)
|
||||
{
|
||||
for (i = 0; i < SECTORSTEPSIZE && SecNum + i < numsectors; ++i)
|
||||
{
|
||||
sector_t *sec = §ors[SecNum + i];
|
||||
sector_t *sec = &level.sectors[SecNum + i];
|
||||
GC::Mark(sec->SoundTarget);
|
||||
GC::Mark(sec->SecActTarget);
|
||||
GC::Mark(sec->floordata);
|
||||
|
@ -696,7 +695,7 @@ size_t DSectorMarker::PropagateMark()
|
|||
SecNum += i;
|
||||
moretodo = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!moretodo && polyobjs != NULL)
|
||||
{
|
||||
for (i = 0; i < POLYSTEPSIZE && PolyNum + i < po_NumPolyobjs; ++i)
|
||||
|
|
|
@ -753,27 +753,26 @@ void ProcessEDSector(sector_t *sec, int recordnum)
|
|||
|
||||
void ProcessEDSectors()
|
||||
{
|
||||
int i;
|
||||
|
||||
InitED();
|
||||
if (EDSectors.CountUsed() == 0) return; // don't waste time if there's no records.
|
||||
|
||||
// collect all Extradata sector records up front so we do not need to search the complete line array for each sector separately.
|
||||
auto numsectors = level.sectors.Size();
|
||||
int *sectorrecord = new int[numsectors];
|
||||
memset(sectorrecord, -1, numsectors * sizeof(int));
|
||||
for (i = 0; i < numlines; i++)
|
||||
for (int i = 0; i < numlines; i++)
|
||||
{
|
||||
if (lines[i].special == Static_Init && lines[i].args[1] == Init_EDSector)
|
||||
{
|
||||
sectorrecord[lines[i].frontsector - sectors] = lines[i].args[0];
|
||||
sectorrecord[lines[i].frontsector - &level.sectors[0]] = lines[i].args[0];
|
||||
lines[i].special = 0;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < numsectors; i++)
|
||||
for (unsigned i = 0; i < numsectors; i++)
|
||||
{
|
||||
if (sectorrecord[i] >= 0)
|
||||
{
|
||||
ProcessEDSector(§ors[i], sectorrecord[i]);
|
||||
ProcessEDSector(&level.sectors[i], sectorrecord[i]);
|
||||
}
|
||||
}
|
||||
delete[] sectorrecord;
|
||||
|
|
|
@ -321,7 +321,7 @@ public:
|
|||
if (tag < 0)
|
||||
{
|
||||
searchtag = INT_MIN;
|
||||
start = tag == -32768? 0 : -tag < numsectors? -tag : -1;
|
||||
start = tag == -32768? 0 : -tag < (int)level.sectors.Size()? -tag : -1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1531,7 +1531,7 @@ void FParser::SF_StartSectorSound(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sector = §ors[i];
|
||||
sector = &level.sectors[i];
|
||||
S_Sound(sector, CHAN_BODY, T_FindSound(stringvalue(t_argv[1])), 1.0f, ATTN_NORM);
|
||||
}
|
||||
}
|
||||
|
@ -1568,13 +1568,14 @@ void FParser::SF_FloorHeight(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
if (sectors[i].floordata) continue; // don't move floors that are active!
|
||||
auto &sec = level.sectors[i];
|
||||
if (sec.floordata) continue; // don't move floors that are active!
|
||||
|
||||
if (sectors[i].MoveFloor(
|
||||
fabs(dest - sectors[i].CenterFloor()),
|
||||
sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest),
|
||||
if (sec.MoveFloor(
|
||||
fabs(dest - sec.CenterFloor()),
|
||||
sec.floorplane.PointToDist (sec.centerspot, dest),
|
||||
crush? 10:-1,
|
||||
(dest > sectors[i].CenterFloor()) ? 1 : -1,
|
||||
(dest > sec.CenterFloor()) ? 1 : -1,
|
||||
false) == EMoveResult::crushed)
|
||||
{
|
||||
returnval = 0;
|
||||
|
@ -1589,7 +1590,7 @@ void FParser::SF_FloorHeight(void)
|
|||
script_error("sector not found with tagnum %i\n", tagnum);
|
||||
return;
|
||||
}
|
||||
returnval = sectors[secnum].CenterFloor();
|
||||
returnval = level.sectors[secnum].CenterFloor();
|
||||
}
|
||||
|
||||
// return floor height
|
||||
|
@ -1622,7 +1623,7 @@ void FParser::SF_MoveFloor(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
P_CreateFloor(§ors[secnum], DFloor::floorMoveToValue, NULL, platspeed, destheight, crush, 0, false, false);
|
||||
P_CreateFloor(&level.sectors[secnum], DFloor::floorMoveToValue, NULL, platspeed, destheight, crush, 0, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1657,13 +1658,14 @@ void FParser::SF_CeilingHeight(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
if (sectors[i].ceilingdata) continue; // don't move ceilings that are active!
|
||||
auto &sec = level.sectors[i];
|
||||
if (sec.ceilingdata) continue; // don't move ceilings that are active!
|
||||
|
||||
if (sectors[i].MoveCeiling(
|
||||
fabs(dest - sectors[i].CenterCeiling()),
|
||||
sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest),
|
||||
if (sec.MoveCeiling(
|
||||
fabs(dest - sec.CenterCeiling()),
|
||||
sec.ceilingplane.PointToDist (sec.centerspot, dest),
|
||||
crush? 10:-1,
|
||||
(dest > sectors[i].CenterCeiling()) ? 1 : -1,
|
||||
(dest > sec.CenterCeiling()) ? 1 : -1,
|
||||
false) == EMoveResult::crushed)
|
||||
{
|
||||
returnval = 0;
|
||||
|
@ -1678,7 +1680,7 @@ void FParser::SF_CeilingHeight(void)
|
|||
script_error("sector not found with tagnum %i\n", tagnum);
|
||||
return;
|
||||
}
|
||||
returnval = sectors[secnum].CenterCeiling();
|
||||
returnval = level.sectors[secnum].CenterCeiling();
|
||||
}
|
||||
|
||||
// return ceiling height
|
||||
|
@ -1713,7 +1715,7 @@ void FParser::SF_MoveCeiling(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
P_CreateCeiling(§ors[secnum], DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom);
|
||||
P_CreateCeiling(&level.sectors[secnum], DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1742,7 +1744,7 @@ void FParser::SF_LightLevel(void)
|
|||
return;
|
||||
}
|
||||
|
||||
sector = §ors[secnum];
|
||||
sector = &level.sectors[secnum];
|
||||
|
||||
if(t_argc > 1) // > 1: set light level
|
||||
{
|
||||
|
@ -1752,7 +1754,7 @@ void FParser::SF_LightLevel(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[i].SetLightLevel(intvalue(t_argv[1]));
|
||||
level.sectors[i].SetLightLevel(intvalue(t_argv[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1870,7 +1872,7 @@ void FParser::SF_FadeLight(void)
|
|||
FSectorTagIterator it(sectag);
|
||||
while ((i = it.Next()) >= 0)
|
||||
{
|
||||
if (!sectors[i].lightingdata) new DLightLevel(§ors[i],destlevel,speed);
|
||||
if (!level.sectors[i].lightingdata) new DLightLevel(&level.sectors[i],destlevel,speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1895,7 +1897,7 @@ void FParser::SF_FloorTexture(void)
|
|||
if(secnum < 0)
|
||||
{ script_error("sector not found with tagnum %i\n", tagnum); return;}
|
||||
|
||||
sector = §ors[secnum];
|
||||
sector = &level.sectors[secnum];
|
||||
|
||||
if(t_argc > 1)
|
||||
{
|
||||
|
@ -1906,7 +1908,7 @@ void FParser::SF_FloorTexture(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[i].SetTexture(sector_t::floor, picnum);
|
||||
level.sectors[i].SetTexture(sector_t::floor, picnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1947,7 +1949,7 @@ void FParser::SF_SectorColormap(void)
|
|||
if(secnum < 0)
|
||||
{ script_error("sector not found with tagnum %i\n", tagnum); return;}
|
||||
|
||||
sector = §ors[secnum];
|
||||
sector = &level.sectors[secnum];
|
||||
|
||||
if (t_argv[1].type==svt_string)
|
||||
{
|
||||
|
@ -1957,7 +1959,7 @@ void FParser::SF_SectorColormap(void)
|
|||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[i].midmap=cm;
|
||||
sectors[i].heightsec=§ors[i];
|
||||
sectors[i].heightsec=&level.sectors[i];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1985,7 +1987,7 @@ void FParser::SF_CeilingTexture(void)
|
|||
if(secnum < 0)
|
||||
{ script_error("sector not found with tagnum %i\n", tagnum); return;}
|
||||
|
||||
sector = §ors[secnum];
|
||||
sector = &level.sectors[secnum];
|
||||
|
||||
if(t_argc > 1)
|
||||
{
|
||||
|
@ -1996,7 +1998,7 @@ void FParser::SF_CeilingTexture(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[i].SetTexture(sector_t::ceiling, picnum);
|
||||
level.sectors[i].SetTexture(sector_t::ceiling, picnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3888,7 +3890,7 @@ void FParser::SF_SetColor(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[i].ColorMap = GetSpecialLights (color, sectors[i].ColorMap->Fade, 0);
|
||||
level.sectors[i].ColorMap = GetSpecialLights (color, level.sectors[i].ColorMap->Fade, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,7 +489,7 @@ bool DFraggleThinker::wait_finished(DRunningScript *script)
|
|||
FSectorTagIterator itr(script->wait_data);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
if(sec->floordata || sec->ceilingdata || sec->lightingdata)
|
||||
return false; // not finished
|
||||
}
|
||||
|
|
|
@ -2241,7 +2241,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
|
|||
|
||||
// Do not even try, if we're not in a level. (Can happen after
|
||||
// a demo finishes playback.)
|
||||
if (lines == NULL || sectors == NULL || gamestate != GS_LEVEL)
|
||||
if (lines == NULL || level.sectors.Size() == 0 || gamestate != GS_LEVEL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2801,7 +2801,7 @@ void G_DoPlayDemo (void)
|
|||
{
|
||||
G_InitNew (mapname, false);
|
||||
}
|
||||
else if (numsectors == 0)
|
||||
else if (level.sectors.Size() == 0)
|
||||
{
|
||||
I_Error("Cannot play demo without its savegame\n");
|
||||
}
|
||||
|
|
|
@ -1841,8 +1841,8 @@ void FLevelLocals::AddScroller (int secnum)
|
|||
}
|
||||
if (Scrolls.Size() == 0)
|
||||
{
|
||||
Scrolls.Resize(numsectors);
|
||||
memset (&Scrolls[0], 0, sizeof(Scrolls[0])*numsectors);
|
||||
Scrolls.Resize(sectors.Size());
|
||||
memset(&Scrolls[0], 0, sizeof(Scrolls[0])*Scrolls.Size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -400,6 +400,8 @@ struct FLevelLocals
|
|||
FString NextSecretMap; // map to go to when used secret exit
|
||||
EMapType maptype;
|
||||
|
||||
TStaticArray<sector_t> sectors;
|
||||
|
||||
DWORD flags;
|
||||
DWORD flags2;
|
||||
DWORD flags3;
|
||||
|
|
|
@ -22,8 +22,8 @@ DLightningThinker::DLightningThinker ()
|
|||
LightningFlashCount = 0;
|
||||
NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start
|
||||
|
||||
LightningLightLevels.Resize(numsectors);
|
||||
fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
|
||||
LightningLightLevels.Resize(level.sectors.Size());
|
||||
fillshort(&LightningLightLevels[0], LightningLightLevels.Size(), SHRT_MAX);
|
||||
}
|
||||
|
||||
DLightningThinker::~DLightningThinker ()
|
||||
|
@ -63,8 +63,8 @@ void DLightningThinker::LightningFlash ()
|
|||
LightningFlashCount--;
|
||||
if (LightningFlashCount)
|
||||
{ // reduce the brightness of the flash
|
||||
tempSec = sectors;
|
||||
for (i = numsectors, j = 0; i > 0; ++j, --i, ++tempSec)
|
||||
tempSec = &level.sectors[0];
|
||||
for (i = level.sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
|
||||
{
|
||||
// [RH] Checking this sector's applicability to lightning now
|
||||
// is not enough to know if we should lower its light level,
|
||||
|
@ -79,15 +79,15 @@ void DLightningThinker::LightningFlash ()
|
|||
}
|
||||
else
|
||||
{ // remove the alternate lightning flash special
|
||||
tempSec = sectors;
|
||||
for (i = numsectors, j = 0; i > 0; ++j, --i, ++tempSec)
|
||||
tempSec = &level.sectors[0];
|
||||
for (i = level.sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
|
||||
{
|
||||
if (LightningLightLevels[j] != SHRT_MAX)
|
||||
{
|
||||
tempSec->SetLightLevel(LightningLightLevels[j]);
|
||||
}
|
||||
}
|
||||
fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
|
||||
fillshort(&LightningLightLevels[0], level.sectors.Size(), SHRT_MAX);
|
||||
level.flags &= ~LEVEL_SWAPSKIES;
|
||||
}
|
||||
return;
|
||||
|
@ -95,8 +95,8 @@ void DLightningThinker::LightningFlash ()
|
|||
|
||||
LightningFlashCount = (pr_lightning()&7)+8;
|
||||
flashLight = 200+(pr_lightning()&31);
|
||||
tempSec = sectors;
|
||||
for (i = numsectors, j = 0; i > 0; --i, ++j, ++tempSec)
|
||||
tempSec = &level.sectors[0];
|
||||
for (i = level.sectors.Size(), j = 0; i > 0; ++j, --i, ++tempSec)
|
||||
{
|
||||
// allow combination of the lightning sector specials with bit masks
|
||||
int special = tempSec->special;
|
||||
|
|
|
@ -117,7 +117,7 @@ void ASkyPicker::PostBeginPlay ()
|
|||
|
||||
if (box == NULL && args[0] != 0)
|
||||
{
|
||||
Printf ("Can't find SkyViewpoint %d for sector %td\n", args[0], Sector - sectors);
|
||||
Printf ("Can't find SkyViewpoint %d for sector %d\n", args[0], Sector->sectornum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -154,9 +154,9 @@ int LS_Sector_SetPlaneReflection (line_t *ln, AActor *it, bool backSide,
|
|||
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sector_t * s = §ors[secnum];
|
||||
sector_t * s = &level.sectors[secnum];
|
||||
if (!s->floorplane.isSlope()) s->reflect[sector_t::floor] = arg1/255.f;
|
||||
if (!s->ceilingplane.isSlope()) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f;
|
||||
if (!s->ceilingplane.isSlope()) level.sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -532,14 +532,12 @@ void gl_InitData()
|
|||
|
||||
CCMD(dumpgeometry)
|
||||
{
|
||||
for(int i=0;i<numsectors;i++)
|
||||
for(auto §or : level.sectors)
|
||||
{
|
||||
sector_t * sector = §ors[i];
|
||||
|
||||
Printf(PRINT_LOG, "Sector %d\n",i);
|
||||
for(int j=0;j<sector->subsectorcount;j++)
|
||||
Printf(PRINT_LOG, "Sector %d\n", sector.sectornum);
|
||||
for(int j=0;j<sector.subsectorcount;j++)
|
||||
{
|
||||
subsector_t * sub = sector->subsectors[j];
|
||||
subsector_t * sub = sector.subsectors[j];
|
||||
|
||||
Printf(PRINT_LOG, " Subsector %d - real sector = %d - %s\n", int(sub-subsectors), sub->sector->sectornum, sub->hacked&1? "hacked":"");
|
||||
for(DWORD k=0;k<sub->numlines;k++)
|
||||
|
|
|
@ -337,18 +337,17 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, c
|
|||
|
||||
static void CollectPortalSectors(FPortalMap &collection)
|
||||
{
|
||||
for (int i=0;i<numsectors;i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
sector_t *sec = §ors[i];
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
int ptype = sec->GetPortalType(j);
|
||||
int ptype = sec.GetPortalType(j);
|
||||
if (ptype== PORTS_STACKEDSECTORTHING || ptype == PORTS_PORTAL || ptype == PORTS_LINKEDPORTAL) // only offset-displacing portal types
|
||||
{
|
||||
FPortalID id = { sec->GetPortalDisplacement(j) };
|
||||
FPortalID id = { sec.GetPortalDisplacement(j) };
|
||||
|
||||
FPortalSectors &sss = collection[id];
|
||||
FPortalSector ss = { sec, j };
|
||||
FPortalSector ss = { &sec, j };
|
||||
sss.Push(ss);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,11 +257,11 @@ static void PrepareSectorData()
|
|||
ss->render_sector->subsectorcount++;
|
||||
}
|
||||
|
||||
for (i=0; i<numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
sectors[i].subsectors = subsectorbuffer;
|
||||
subsectorbuffer += sectors[i].subsectorcount;
|
||||
sectors[i].subsectorcount = 0;
|
||||
sec.subsectors = subsectorbuffer;
|
||||
subsectorbuffer += sec.subsectorcount;
|
||||
sec.subsectorcount = 0;
|
||||
}
|
||||
|
||||
for(i=0, ss = subsectors; i<numsubsectors; i++, ss++)
|
||||
|
@ -307,13 +307,6 @@ static void PrepareTransparentDoors(sector_t * sector)
|
|||
unsigned int selfref=0;
|
||||
sector_t * nextsec=NULL;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (sector-sectors==34)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
P_Recalculate3DFloors(sector);
|
||||
if (sector->subsectorcount==0) return;
|
||||
|
||||
|
@ -388,7 +381,7 @@ static void PrepareTransparentDoors(sector_t * sector)
|
|||
|
||||
static void AddToVertex(const sector_t * sec, TArray<int> & list)
|
||||
{
|
||||
int secno = int(sec-sectors);
|
||||
int secno = int(sec-&level.sectors[0]);
|
||||
|
||||
for(unsigned i=0;i<list.Size();i++)
|
||||
{
|
||||
|
@ -448,7 +441,7 @@ static void InitVertexData()
|
|||
vertexes[i].heightlist = new float[cnt*2];
|
||||
for(int j=0;j<cnt;j++)
|
||||
{
|
||||
vertexes[i].sectors[j] = §ors[vt_sectorlists[i][j]];
|
||||
vertexes[i].sectors[j] = &level.sectors[vt_sectorlists[i][j]];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -590,20 +583,18 @@ extern int restart;
|
|||
|
||||
void gl_PreprocessLevel()
|
||||
{
|
||||
int i;
|
||||
|
||||
PrepareSegs();
|
||||
PrepareSectorData();
|
||||
InitVertexData();
|
||||
int *checkmap = new int[numvertexes];
|
||||
memset(checkmap, -1, sizeof(int)*numvertexes);
|
||||
for(i=0;i<numsectors;i++)
|
||||
for(auto &sec : level.sectors)
|
||||
{
|
||||
sectors[i].sectornum = i;
|
||||
PrepareTransparentDoors(§ors[i]);
|
||||
int i = sec.sectornum;
|
||||
PrepareTransparentDoors(&sec);
|
||||
|
||||
// This ignores vertices only used for seg splitting because those aren't needed here
|
||||
for(auto l : sectors[i].Lines)
|
||||
for(auto l : sec.Lines)
|
||||
{
|
||||
if (l->sidedef[0]->Flags & WALLF_POLYOBJ) continue; // don't bother with polyobjects
|
||||
|
||||
|
@ -613,14 +604,14 @@ void gl_PreprocessLevel()
|
|||
if (checkmap[vtnum1] < i)
|
||||
{
|
||||
checkmap[vtnum1] = i;
|
||||
sectors[i].e->vertices.Push(&vertexes[vtnum1]);
|
||||
sec.e->vertices.Push(&vertexes[vtnum1]);
|
||||
vertexes[vtnum1].dirty = true;
|
||||
}
|
||||
|
||||
if (checkmap[vtnum2] < i)
|
||||
{
|
||||
checkmap[vtnum2] = i;
|
||||
sectors[i].e->vertices.Push(&vertexes[vtnum2]);
|
||||
sec.e->vertices.Push(&vertexes[vtnum2]);
|
||||
vertexes[vtnum2].dirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -683,10 +674,10 @@ void gl_CleanLevelData()
|
|||
delete [] sides[0].segs;
|
||||
sides[0].segs = NULL;
|
||||
}
|
||||
if (sectors && sectors[0].subsectors)
|
||||
if (level.sectors.Size() > 0 && level.sectors[0].subsectors)
|
||||
{
|
||||
delete [] sectors[0].subsectors;
|
||||
sectors[0].subsectors = NULL;
|
||||
delete [] level.sectors[0].subsectors;
|
||||
level.sectors[0].subsectors = nullptr;
|
||||
}
|
||||
for (int i=0;i<numsubsectors;i++)
|
||||
{
|
||||
|
|
|
@ -394,27 +394,25 @@ void FFlatVertexBuffer::CreateFlatVBO()
|
|||
{
|
||||
for (int h = sector_t::floor; h <= sector_t::ceiling; h++)
|
||||
{
|
||||
for(int i=0; i<numsectors;i++)
|
||||
for(auto &sec : level.sectors)
|
||||
{
|
||||
CreateVertices(h, §ors[i], sectors[i].GetSecPlane(h), h == sector_t::floor);
|
||||
CreateVertices(h, &sec, sec.GetSecPlane(h), h == sector_t::floor);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to do a final check for Vavoom water and FF_FIX sectors.
|
||||
// No new vertices are needed here. The planes come from the actual sector
|
||||
for(int i=0; i<numsectors;i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
for(unsigned j=0;j<sectors[i].e->XFloor.ffloors.Size(); j++)
|
||||
for(auto ff : sec.e->XFloor.ffloors)
|
||||
{
|
||||
F3DFloor *ff = sectors[i].e->XFloor.ffloors[j];
|
||||
|
||||
if (ff->top.model == §ors[i])
|
||||
if (ff->top.model == &sec)
|
||||
{
|
||||
ff->top.vindex = sectors[i].vboindex[ff->top.isceiling];
|
||||
ff->top.vindex = sec.vboindex[ff->top.isceiling];
|
||||
}
|
||||
if (ff->bottom.model == §ors[i])
|
||||
if (ff->bottom.model == &sec)
|
||||
{
|
||||
ff->bottom.vindex = sectors[i].vboindex[ff->top.isceiling];
|
||||
ff->bottom.vindex = sec.vboindex[ff->top.isceiling];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -420,7 +420,7 @@ static void DoSubsector(subsector_t * sub)
|
|||
sector_t fake;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (sub->sector-sectors==931)
|
||||
if (sub->sector->sectornum==931)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
|
|
|
@ -1043,11 +1043,11 @@ void FDrawInfo::StartScene()
|
|||
{
|
||||
ClearBuffers();
|
||||
|
||||
sectorrenderflags.Resize(numsectors);
|
||||
sectorrenderflags.Resize(level.sectors.Size());
|
||||
ss_renderflags.Resize(numsubsectors);
|
||||
no_renderflags.Resize(numsubsectors);
|
||||
|
||||
memset(§orrenderflags[0], 0, numsectors * sizeof(sectorrenderflags[0]));
|
||||
memset(§orrenderflags[0], 0, level.sectors.Size() * sizeof(sectorrenderflags[0]));
|
||||
memset(&ss_renderflags[0], 0, numsubsectors * sizeof(ss_renderflags[0]));
|
||||
memset(&no_renderflags[0], 0, numnodes * sizeof(no_renderflags[0]));
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
|
|||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (sec-sectors==560)
|
||||
if (sec->sectornum==560)
|
||||
{
|
||||
int a = 0;
|
||||
}
|
||||
|
|
|
@ -582,7 +582,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
#endif
|
||||
|
||||
// Get the real sector for this one.
|
||||
sector = §ors[frontsector->sectornum];
|
||||
sector = &level.sectors[frontsector->sectornum];
|
||||
extsector_t::xfloor &x = sector->e->XFloor;
|
||||
dynlightindex = -1;
|
||||
|
||||
|
|
|
@ -895,7 +895,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
|||
Colormap=rendersector->ColorMap;
|
||||
if (fullbright)
|
||||
{
|
||||
if (rendersector == §ors[rendersector->sectornum] || in_area != area_below)
|
||||
if (rendersector == &level.sectors[rendersector->sectornum] || in_area != area_below)
|
||||
// under water areas keep their color for fullbright objects
|
||||
{
|
||||
// Only make the light white but keep everything else (fog, desaturation and Boom colormap.)
|
||||
|
|
|
@ -1435,8 +1435,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|||
else
|
||||
{
|
||||
// Need these for aligning the textures
|
||||
realfront = §ors[frontsector->sectornum];
|
||||
realback = backsector ? §ors[backsector->sectornum] : NULL;
|
||||
realfront = &level.sectors[frontsector->sectornum];
|
||||
realback = backsector ? &level.sectors[backsector->sectornum] : NULL;
|
||||
segfront = frontsector;
|
||||
segback = backsector;
|
||||
}
|
||||
|
|
|
@ -1053,7 +1053,7 @@ void FNodeBuilder::PrintSet (int l, DWORD set)
|
|||
Printf (PRINT_LOG, "set %d:\n", l);
|
||||
for (; set != DWORD_MAX; set = Segs[set].next)
|
||||
{
|
||||
Printf (PRINT_LOG, "\t%u(%td)%c%d(%d,%d)-%d(%d,%d)\n", set, Segs[set].frontsector-sectors,
|
||||
Printf (PRINT_LOG, "\t%u(%td)%c%d(%d,%d)-%d(%d,%d)\n", set, Segs[set].frontsector->sectornum,
|
||||
Segs[set].linedef == -1 ? '+' : ':',
|
||||
Segs[set].v1,
|
||||
Vertices[Segs[set].v1].x>>16, Vertices[Segs[set].v1].y>>16,
|
||||
|
|
|
@ -224,7 +224,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha)
|
|||
FSectorTagIterator itr(tag);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
ss = §ors[s];
|
||||
ss = &level.sectors[s];
|
||||
|
||||
if (param == 0)
|
||||
{
|
||||
|
@ -888,9 +888,9 @@ void P_Spawn3DFloors (void)
|
|||
line->args[0] = line->args[1] = line->args[2] = line->args[3] = line->args[4] = 0;
|
||||
}
|
||||
// kg3D - do it in software
|
||||
for (i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
P_Recalculate3DFloors(§ors[i]);
|
||||
P_Recalculate3DFloors(&sec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -984,7 +984,7 @@ CCMD (dump3df)
|
|||
if (argv.argc() > 1)
|
||||
{
|
||||
int sec = strtol(argv[1], NULL, 10);
|
||||
sector_t *sector = §ors[sec];
|
||||
sector_t *sector = &level.sectors[sec];
|
||||
TArray<F3DFloor*> & ffloors=sector->e->XFloor.ffloors;
|
||||
|
||||
for (unsigned int i = 0; i < ffloors.Size(); i++)
|
||||
|
|
|
@ -122,10 +122,10 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
|
|||
|
||||
// Bit arrays that mark whether a line or sector is to be attached.
|
||||
BYTE *found_lines = new BYTE[(numlines+7)/8];
|
||||
BYTE *found_sectors = new BYTE[(numsectors+7)/8];
|
||||
BYTE *found_sectors = new BYTE[(level.sectors.Size()+7)/8];
|
||||
|
||||
memset(found_lines, 0, sizeof (BYTE) * ((numlines+7)/8));
|
||||
memset(found_sectors, 0, sizeof (BYTE) * ((numsectors+7)/8));
|
||||
memset(found_sectors, 0, sizeof (BYTE) * ((level.sectors.Size()+7)/8));
|
||||
|
||||
// mark all lines and sectors that are already attached to this one
|
||||
// and clear the arrays. The old data will be re-added automatically
|
||||
|
@ -138,7 +138,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
|
|||
|
||||
for (unsigned i=0; i < scrollplane.AttachedSectors.Size(); i++)
|
||||
{
|
||||
int sec = int(scrollplane.AttachedSectors[i] - sectors);
|
||||
int sec = scrollplane.AttachedSectors[i]->sectornum;
|
||||
found_sectors[sec>>3] |= 1 << (sec&7);
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
|
|||
int sec;
|
||||
while ((sec = it.Next()) >= 0)
|
||||
{
|
||||
for (auto ln : sectors[sec].Lines)
|
||||
for (auto ln : level.sectors[sec].Lines)
|
||||
{
|
||||
if (lineid != 0 && !tagManager.LineHasID(ln, lineid)) continue;
|
||||
|
||||
|
@ -189,21 +189,21 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
|
|||
{
|
||||
scrollplane.AttachedLines.Push(&lines[i]);
|
||||
|
||||
v = int(lines[i].frontsector - sectors);
|
||||
assert(v < numsectors);
|
||||
v = lines[i].frontsector->sectornum;
|
||||
assert(v < (int)level.sectors.Size());
|
||||
found_sectors[v>>3] |= 1 << (v&7);
|
||||
|
||||
v = int(lines[i].backsector - sectors);
|
||||
assert(v < numsectors);
|
||||
v = lines[i].backsector->sectornum;
|
||||
assert(v < (int)level.sectors.Size());
|
||||
found_sectors[v>>3] |= 1 << (v&7);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i < numsectors; i++)
|
||||
for (unsigned i=0; i < level.sectors.Size(); i++)
|
||||
{
|
||||
if (found_sectors[i>>3] & (1 << (i&7)))
|
||||
{
|
||||
scrollplane.AttachedSectors.Push(§ors[i]);
|
||||
scrollplane.AttachedSectors.Push(&level.sectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1423,7 +1423,7 @@ DPlaneWatcher::DPlaneWatcher (AActor *it, line_t *line, int lineSide, bool ceili
|
|||
{
|
||||
secplane_t plane;
|
||||
|
||||
Sector = §ors[secnum];
|
||||
Sector = &level.sectors[secnum];
|
||||
if (bCeiling)
|
||||
{
|
||||
plane = Sector->ceilingplane;
|
||||
|
@ -3263,7 +3263,7 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling)
|
|||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor;
|
||||
sectors[secnum].SetTexture(pos, flat);
|
||||
level.sectors[secnum].SetTexture(pos, flat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3351,14 +3351,12 @@ void DLevelScript::ReplaceTextures (int fromnamei, int tonamei, int flags)
|
|||
picnum1 = TexMan.GetTexture (fromname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture (toname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (int i = 0; i < numsectors; ++i)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
sector_t *sec = §ors[i];
|
||||
|
||||
if (!(flags & NOT_FLOOR) && sec->GetTexture(sector_t::floor) == picnum1)
|
||||
sec->SetTexture(sector_t::floor, picnum2);
|
||||
if (!(flags & NOT_CEILING) && sec->GetTexture(sector_t::ceiling) == picnum1)
|
||||
sec->SetTexture(sector_t::ceiling, picnum2);
|
||||
if (!(flags & NOT_FLOOR) && sec.GetTexture(sector_t::floor) == picnum1)
|
||||
sec.SetTexture(sector_t::floor, picnum2);
|
||||
if (!(flags & NOT_CEILING) && sec.GetTexture(sector_t::ceiling) == picnum1)
|
||||
sec.SetTexture(sector_t::ceiling, picnum2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5150,7 +5148,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
|
|||
int s;
|
||||
while ((s = it.Next()) >= 0)
|
||||
{
|
||||
SN_StartSequence(§ors[s], args[2], seqname, 0);
|
||||
SN_StartSequence(&level.sectors[s], args[2], seqname, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5922,7 +5920,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
int s;
|
||||
while ((s = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[s];
|
||||
sector_t *sec = &level.sectors[s];
|
||||
|
||||
sec->damageamount = args[1];
|
||||
sec->damagetype = argCount >= 3 ? FName(FBehavior::StaticLookupString(args[2])) : FName(NAME_None);
|
||||
|
@ -5942,7 +5940,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
int s;
|
||||
while ((s = it.Next()) >= 0)
|
||||
{
|
||||
sectors[s].terrainnum[args[1]] = terrain;
|
||||
level.sectors[s].terrainnum[args[1]] = terrain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6083,8 +6081,8 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
int s;
|
||||
while ((s = it.Next()) >= 0)
|
||||
{
|
||||
sectors[s].planes[which].GlowColor = color;
|
||||
sectors[s].planes[which].GlowHeight = height;
|
||||
level.sectors[s].planes[which].GlowColor = color;
|
||||
level.sectors[s].planes[which].GlowHeight = height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -6096,8 +6094,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
int d = clamp(args[1]/2, 0, 255);
|
||||
while ((s = it.Next()) >= 0)
|
||||
{
|
||||
auto f = sectors[s].ColorMap->Fade;
|
||||
sectors[s].ColorMap = GetSpecialLights(sectors[s].ColorMap->Color, PalEntry(d, f.r, f.g, f.b), sectors[s].ColorMap->Desaturate);
|
||||
auto &sec = level.sectors[s];
|
||||
auto f = sec.ColorMap->Fade;
|
||||
sec.ColorMap = GetSpecialLights(sec.ColorMap->Color, PalEntry(d, f.r, f.g, f.b), sec.ColorMap->Desaturate);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -6227,7 +6226,7 @@ int DLevelScript::RunScript ()
|
|||
FSectorTagIterator it(statedata);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
if (sectors[secnum].floordata || sectors[secnum].ceilingdata)
|
||||
if (level.sectors[secnum].floordata || level.sectors[secnum].ceilingdata)
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
|
@ -8838,17 +8837,17 @@ scriptwait:
|
|||
if (tag != 0)
|
||||
secnum = P_FindFirstSectorFromTag (tag);
|
||||
else
|
||||
secnum = int(P_PointInSector (x, y) - sectors);
|
||||
secnum = P_PointInSector (x, y)->sectornum;
|
||||
|
||||
if (secnum >= 0)
|
||||
{
|
||||
if (pcd == PCD_GETSECTORFLOORZ)
|
||||
{
|
||||
z = sectors[secnum].floorplane.ZatPoint (x, y);
|
||||
z = level.sectors[secnum].floorplane.ZatPoint (x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
z = sectors[secnum].ceilingplane.ZatPoint (x, y);
|
||||
z = level.sectors[secnum].ceilingplane.ZatPoint (x, y);
|
||||
}
|
||||
}
|
||||
sp -= 2;
|
||||
|
@ -8863,7 +8862,7 @@ scriptwait:
|
|||
|
||||
if (secnum >= 0)
|
||||
{
|
||||
z = sectors[secnum].lightlevel;
|
||||
z = level.sectors[secnum].lightlevel;
|
||||
}
|
||||
STACK(1) = z;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ void P_AdjustLine (line_t *line);
|
|||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **sprites, int *numsprites);
|
||||
static void LoadSectors (sectortype *bsectors);
|
||||
static void LoadSectors (sectortype *bsectors, int count);
|
||||
static void LoadWalls (walltype *walls, int numwalls, sectortype *bsectors);
|
||||
static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, sectortype *bsectors, FMapThing *mapthings);
|
||||
static vertex_t *FindVertex (SDWORD x, SDWORD y);
|
||||
|
@ -225,15 +225,14 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr)
|
|||
return false;
|
||||
}
|
||||
|
||||
numsectors = numsec;
|
||||
LoadSectors ((sectortype *)(data + 22));
|
||||
LoadWalls ((walltype *)(data + 24 + numsectors*sizeof(sectortype)), numwalls,
|
||||
LoadSectors ((sectortype *)(data + 22), numsec);
|
||||
LoadWalls ((walltype *)(data + 24 + numsec*sizeof(sectortype)), numwalls,
|
||||
(sectortype *)(data + 22));
|
||||
|
||||
numsprites = *(WORD *)(data + 24 + numsectors*sizeof(sectortype) + numwalls*sizeof(walltype));
|
||||
numsprites = *(WORD *)(data + 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype));
|
||||
*sprites = new FMapThing[numsprites + 1];
|
||||
CreateStartSpot ((SDWORD *)(data + 4), *sprites);
|
||||
*numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsectors*sizeof(sectortype) + numwalls*sizeof(walltype)),
|
||||
*numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)),
|
||||
NULL, numsprites, (sectortype *)(data + 22), *sprites + 1);
|
||||
|
||||
return true;
|
||||
|
@ -274,7 +273,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int *
|
|||
visibility = LittleLong(*(DWORD *)(infoBlock + 18));
|
||||
parallaxType = infoBlock[26];
|
||||
numRevisions = LittleLong(*(DWORD *)(infoBlock + 27));
|
||||
numsectors = LittleShort(*(WORD *)(infoBlock + 31));
|
||||
int numsectors = LittleShort(*(WORD *)(infoBlock + 31));
|
||||
numWalls = LittleShort(*(WORD *)(infoBlock + 33));
|
||||
numsprites = LittleShort(*(WORD *)(infoBlock + 35));
|
||||
Printf("Visibility: %d\n", visibility);
|
||||
|
@ -364,7 +363,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int *
|
|||
|
||||
// Now convert to Doom format, since we've extracted all the standard
|
||||
// BUILD info from the map we need. (Sprites are ignored.)
|
||||
LoadSectors (bsec);
|
||||
LoadSectors (bsec, numsectors);
|
||||
LoadWalls (bwal, numWalls, bsec);
|
||||
*mapthings = new FMapThing[numsprites];
|
||||
*numspr = LoadSprites (bspr, xspr, numsprites, bsec, *mapthings);
|
||||
|
@ -383,25 +382,26 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int *
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void LoadSectors (sectortype *bsec)
|
||||
static void LoadSectors (sectortype *bsec, int count)
|
||||
{
|
||||
FDynamicColormap *map = GetSpecialLights (PalEntry (255,255,255), level.fadeto, 0);
|
||||
sector_t *sec;
|
||||
char tnam[9];
|
||||
|
||||
sec = sectors = new sector_t[numsectors];
|
||||
memset (sectors, 0, sizeof(sector_t)*numsectors);
|
||||
level.sectors.Alloc(count);
|
||||
sec = &level.sectors[0];
|
||||
memset (sec, 0, sizeof(sector_t)*count);
|
||||
|
||||
sectors[0].e = new extsector_t[numsectors];
|
||||
sec->e = new extsector_t[count];
|
||||
|
||||
for (int i = 0; i < numsectors; ++i, ++bsec, ++sec)
|
||||
for (int i = 0; i < count; ++i, ++bsec, ++sec)
|
||||
{
|
||||
bsec->wallptr = WORD(bsec->wallptr);
|
||||
bsec->wallnum = WORD(bsec->wallnum);
|
||||
bsec->ceilingstat = WORD(bsec->ceilingstat);
|
||||
bsec->floorstat = WORD(bsec->floorstat);
|
||||
|
||||
sec->e = §ors[0].e[i];
|
||||
sec->e = &sec->e[i];
|
||||
double floorheight = -LittleLong(bsec->floorZ) / 256.;
|
||||
sec->SetPlaneTexZ(sector_t::floor, floorheight);
|
||||
sec->floorplane.SetAtHeight(floorheight, sector_t::floor);
|
||||
|
@ -496,13 +496,13 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
|
|||
numvertexes = 0;
|
||||
|
||||
// First mark each sidedef with the sector it belongs to
|
||||
for (i = 0; i < numsectors; ++i)
|
||||
for (unsigned i = 0; i < level.sectors.Size(); i++)
|
||||
{
|
||||
if (bsec[i].wallptr >= 0)
|
||||
{
|
||||
for (j = 0; j < bsec[i].wallnum; ++j)
|
||||
{
|
||||
sides[j + bsec[i].wallptr].sector = sectors + i;
|
||||
sides[j + bsec[i].wallptr].sector = &level.sectors[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
|
|||
lines[j].flags |= ML_WRAP_MIDTEX;
|
||||
if (walls[i].nextsector >= 0)
|
||||
{
|
||||
lines[j].backsector = sectors + walls[i].nextsector;
|
||||
lines[j].backsector = &level.sectors[walls[i].nextsector];
|
||||
lines[j].flags |= ML_TWOSIDED;
|
||||
}
|
||||
else
|
||||
|
@ -629,7 +629,7 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
|
|||
}
|
||||
|
||||
// Finish setting sector properties that depend on walls
|
||||
for (i = 0; i < numsectors; ++i, ++bsec)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
SlopeWork slope;
|
||||
|
||||
|
@ -646,13 +646,13 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec)
|
|||
{ // floor is sloped
|
||||
slope.heinum = -LittleShort(bsec->floorheinum);
|
||||
slope.z[0] = slope.z[1] = slope.z[2] = -bsec->floorZ;
|
||||
CalcPlane (slope, sectors[i].floorplane);
|
||||
CalcPlane (slope, sec.floorplane);
|
||||
}
|
||||
if ((bsec->ceilingstat & 2) && (bsec->ceilingheinum != 0))
|
||||
{ // ceiling is sloped
|
||||
slope.heinum = -LittleShort(bsec->ceilingheinum);
|
||||
slope.z[0] = slope.z[1] = slope.z[2] = -bsec->ceilingZ;
|
||||
CalcPlane (slope, sectors[i].ceilingplane);
|
||||
CalcPlane (slope, sec.ceilingplane);
|
||||
}
|
||||
int linenum = int(intptr_t(sides[bsec->wallptr].linedef));
|
||||
int sidenum = int(intptr_t(lines[linenum].sidedef[1]));
|
||||
|
|
|
@ -498,7 +498,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
|
|||
{
|
||||
if (!line || !(sec = line->backsector))
|
||||
return rtn;
|
||||
secnum = (int)(sec-sectors);
|
||||
secnum = sec->sectornum;
|
||||
// [RH] Hack to let manual crushers be retriggerable, too
|
||||
tag ^= secnum | 0x1000000;
|
||||
P_ActivateInStasisCeiling (tag);
|
||||
|
@ -516,7 +516,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
rtn |= P_CreateCeiling(§ors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
|
||||
rtn |= P_CreateCeiling(&level.sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing,
|
|||
|
||||
// get the sector on the second side of activating linedef
|
||||
sec = line->sidedef[1]->sector;
|
||||
secnum = int(sec-sectors);
|
||||
secnum = sec->sectornum;
|
||||
|
||||
// if door already has a thinker, use it
|
||||
if (sec->PlaneMoving(sector_t::ceiling))
|
||||
|
@ -493,7 +493,7 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing,
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
// if the ceiling is already moving, don't start the door action
|
||||
if (sec->PlaneMoving(sector_t::ceiling))
|
||||
continue;
|
||||
|
@ -782,7 +782,7 @@ bool EV_SlidingDoor (line_t *line, AActor *actor, int tag, int speed, int delay)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
if (sec->ceilingdata != NULL)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -350,7 +350,7 @@ void P_RunEffects ()
|
|||
{
|
||||
if (players[consoleplayer].camera == NULL) return;
|
||||
|
||||
int pnum = int(players[consoleplayer].camera->Sector - sectors) * numsectors;
|
||||
int pnum = int(players[consoleplayer].camera->Sector - &level.sectors[0]) * level.sectors.Size();
|
||||
|
||||
AActor *actor;
|
||||
TThinkerIterator<AActor> iterator;
|
||||
|
@ -360,7 +360,7 @@ void P_RunEffects ()
|
|||
if (actor->effects)
|
||||
{
|
||||
// Only run the effect if the actor is potentially visible
|
||||
int rnum = pnum + int(actor->Sector - sectors);
|
||||
int rnum = pnum + int(actor->Sector - &level.sectors[0]);
|
||||
if (rejectmatrix == NULL || !(rejectmatrix[rnum>>3] & (1 << (rnum & 7))))
|
||||
P_RunEffect (actor, actor->effects);
|
||||
}
|
||||
|
|
|
@ -185,19 +185,19 @@ void DFloor::Tick ()
|
|||
sector_t *sec = m_Sector;
|
||||
sec->stairlock = -1; // thinker done, promote lock to -1
|
||||
|
||||
while (sec->prevsec != -1 && sectors[sec->prevsec].stairlock != -2)
|
||||
sec = §ors[sec->prevsec]; // search for a non-done thinker
|
||||
while (sec->prevsec != -1 && level.sectors[sec->prevsec].stairlock != -2)
|
||||
sec = &level.sectors[sec->prevsec]; // search for a non-done thinker
|
||||
if (sec->prevsec == -1) // if all thinkers previous are done
|
||||
{
|
||||
sec = m_Sector; // search forward
|
||||
while (sec->nextsec != -1 && sectors[sec->nextsec].stairlock != -2)
|
||||
sec = §ors[sec->nextsec];
|
||||
while (sec->nextsec != -1 && level.sectors[sec->nextsec].stairlock != -2)
|
||||
sec = &level.sectors[sec->nextsec];
|
||||
if (sec->nextsec == -1) // if all thinkers ahead are done too
|
||||
{
|
||||
while (sec->prevsec != -1) // clear all locks
|
||||
{
|
||||
sec->stairlock = 0;
|
||||
sec = §ors[sec->prevsec];
|
||||
sec = &level.sectors[sec->prevsec];
|
||||
}
|
||||
sec->stairlock = 0;
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
|
|||
FSectorTagIterator it(tag, line);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
rtn |= P_CreateFloor(§ors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower);
|
||||
rtn |= P_CreateFloor(&level.sectors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower);
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ bool EV_FloorCrushStop (int tag)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = sectors + secnum;
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
|
||||
if (sec->floordata && sec->floordata->IsKindOf (RUNTIME_CLASS(DFloor)) &&
|
||||
barrier_cast<DFloor *>(sec->floordata)->m_Type == DFloor::floorRaiseAndCrush)
|
||||
|
@ -602,7 +602,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
|
|||
bool compatible = tag != 0 && (i_compatflags & COMPATF_STAIRINDEX);
|
||||
while ((secnum = itr.NextCompat(compatible, secnum)) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
|
||||
// ALREADY MOVING? IF SO, KEEP GOING...
|
||||
//jff 2/26/98 add special lockout condition to wait for entire
|
||||
|
@ -664,7 +664,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
|
|||
}
|
||||
|
||||
}
|
||||
newsecnum = (int)(tsec - sectors);
|
||||
newsecnum = tsec->sectornum;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -674,14 +674,14 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
|
|||
continue;
|
||||
|
||||
tsec = line->frontsector;
|
||||
newsecnum = (int)(tsec-sectors);
|
||||
newsecnum = tsec->sectornum;
|
||||
|
||||
if (secnum != newsecnum)
|
||||
continue;
|
||||
|
||||
tsec = line->backsector;
|
||||
if (!tsec) continue; //jff 5/7/98 if no backside, continue
|
||||
newsecnum = (int)(tsec - sectors);
|
||||
newsecnum = tsec->sectornum;
|
||||
|
||||
if (!igntxt && tsec->GetTexture(sector_t::floor) != texture)
|
||||
continue;
|
||||
|
@ -746,7 +746,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
|
|||
} while (ok);
|
||||
// [RH] make sure the first sector doesn't point to a previous one, otherwise
|
||||
// it can infinite loop when the first sector stops moving.
|
||||
sectors[osecnum].prevsec = -1;
|
||||
level.sectors[osecnum].prevsec = -1;
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed)
|
|||
FSectorTagIterator itr(tag, line);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
s1 = §ors[secnum]; // s1 is pillar's sector
|
||||
s1 = &level.sectors[secnum]; // s1 is pillar's sector
|
||||
|
||||
// ALREADY MOVING? IF SO, KEEP GOING...
|
||||
if (s1->PlaneMoving(sector_t::floor))
|
||||
|
@ -990,7 +990,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
|
|||
// act on all sectors with the same tag as the triggering linedef
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
// If either floor or ceiling is already activated, skip it
|
||||
if (sec->PlaneMoving(sector_t::floor) || sec->ceilingdata) //jff 2/22/98
|
||||
continue; // the loop used to break at the end if tag were 0, but would miss that step if "continue" occured [FDARI]
|
||||
|
@ -1083,7 +1083,7 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
|
||||
rtn = true;
|
||||
|
||||
|
@ -1298,7 +1298,7 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset,
|
|||
|
||||
while ((sectorIndex = itr.Next()) >= 0)
|
||||
{
|
||||
sector = §ors[sectorIndex];
|
||||
sector = &level.sectors[sectorIndex];
|
||||
if ((!ceiling && sector->PlaneMoving(sector_t::floor)) ||
|
||||
(ceiling && sector->PlaneMoving(sector_t::ceiling)))
|
||||
{ // Already busy with another thinker
|
||||
|
|
|
@ -324,7 +324,7 @@ void EV_StartLightFlickering (int tag, int upper, int lower)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
new DFlicker (§ors[secnum], upper, lower);
|
||||
new DFlicker (&level.sectors[secnum], upper, lower);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
if (sec->lightingdata)
|
||||
continue;
|
||||
|
||||
|
@ -515,7 +515,7 @@ void EV_StartLightStrobing (int tag, int utics, int ltics)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
if (sec->lightingdata)
|
||||
continue;
|
||||
|
||||
|
@ -537,7 +537,7 @@ void EV_TurnTagLightsOff (int tag)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sector = sectors + secnum;
|
||||
sector_t *sector = &level.sectors[secnum];
|
||||
int min = sector->lightlevel;
|
||||
|
||||
for (auto ln : sector->Lines)
|
||||
|
@ -566,7 +566,7 @@ void EV_LightTurnOn (int tag, int bright)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sector = sectors + secnum;
|
||||
sector_t *sector = &level.sectors[secnum];
|
||||
int tbright = bright; //jff 5/17/98 search for maximum PER sector
|
||||
|
||||
// bright = -1 means to search ([RH] Not 0)
|
||||
|
@ -619,7 +619,7 @@ void EV_LightTurnOnPartway (int tag, double frac)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *temp, *sector = §ors[secnum];
|
||||
sector_t *temp, *sector = &level.sectors[secnum];
|
||||
int bright = 0, min = sector->lightlevel;
|
||||
|
||||
for (auto ln : sector->Lines)
|
||||
|
@ -655,7 +655,7 @@ void EV_LightChange (int tag, int value)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetLightLevel(sectors[secnum].lightlevel + value);
|
||||
level.sectors[secnum].SetLightLevel(level.sectors[secnum].lightlevel + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -821,7 +821,7 @@ void EV_StartLightGlowing (int tag, int upper, int lower, int tics)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
if (sec->lightingdata)
|
||||
continue;
|
||||
|
||||
|
@ -841,7 +841,7 @@ void EV_StartLightFading (int tag, int value, int tics)
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
if (sec->lightingdata)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -322,9 +322,9 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype)
|
|||
while ((sec = itr.Next()) >= 0)
|
||||
{
|
||||
// Don't attach to self!
|
||||
if (control != §ors[sec])
|
||||
if (control != &level.sectors[sec])
|
||||
{
|
||||
AddSingleSector(scrollplane, §ors[sec], movetype);
|
||||
AddSingleSector(scrollplane, &level.sectors[sec], movetype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2163,7 +2163,7 @@ FUNC(LS_Sector_ChangeSound)
|
|||
FSectorTagIterator itr(arg0);
|
||||
while ((secNum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secNum].seqType = arg1;
|
||||
level.sectors[secNum].seqType = arg1;
|
||||
rtn = true;
|
||||
}
|
||||
return rtn;
|
||||
|
@ -2185,7 +2185,7 @@ FUNC(LS_Sector_ChangeFlags)
|
|||
arg2 &= ~SECF_NOMODIFY;
|
||||
while ((secNum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secNum].Flags = (sectors[secNum].Flags | arg1) & ~arg2;
|
||||
level.sectors[secNum].Flags = (level.sectors[secNum].Flags | arg1) & ~arg2;
|
||||
rtn = true;
|
||||
}
|
||||
return rtn;
|
||||
|
@ -2231,8 +2231,8 @@ FUNC(LS_Sector_SetTranslucent)
|
|||
FSectorTagIterator itr(arg0);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetAlpha(arg1, clamp(arg2, 0, 255) / 255.);
|
||||
sectors[secnum].ChangeFlags(arg1, ~PLANEF_ADDITIVE, arg3? PLANEF_ADDITIVE:0);
|
||||
level.sectors[secnum].SetAlpha(arg1, clamp(arg2, 0, 255) / 255.);
|
||||
level.sectors[secnum].ChangeFlags(arg1, ~PLANEF_ADDITIVE, arg3? PLANEF_ADDITIVE:0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2247,7 +2247,7 @@ FUNC(LS_Sector_SetLink)
|
|||
int control = P_FindFirstSectorFromTag(arg0);
|
||||
if (control >= 0)
|
||||
{
|
||||
return P_AddSectorLinks(§ors[control], arg1, arg2, arg3);
|
||||
return P_AddSectorLinks(&level.sectors[control], arg1, arg2, arg3);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -2367,10 +2367,10 @@ FUNC(LS_Sector_SetDamage)
|
|||
arg3 = 1;
|
||||
}
|
||||
}
|
||||
sectors[secnum].damageamount = (short)arg1;
|
||||
sectors[secnum].damagetype = MODtoDamageType(arg2);
|
||||
sectors[secnum].damageinterval = (short)arg3;
|
||||
sectors[secnum].leakydamage = (short)arg4;
|
||||
level.sectors[secnum].damageamount = (short)arg1;
|
||||
level.sectors[secnum].damagetype = MODtoDamageType(arg2);
|
||||
level.sectors[secnum].damageinterval = (short)arg3;
|
||||
level.sectors[secnum].leakydamage = (short)arg4;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2387,7 +2387,7 @@ FUNC(LS_Sector_SetGravity)
|
|||
FSectorTagIterator itr(arg0);
|
||||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
sectors[secnum].gravity = gravity;
|
||||
level.sectors[secnum].gravity = gravity;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2399,7 +2399,7 @@ FUNC(LS_Sector_SetColor)
|
|||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetColor(arg1, arg2, arg3, arg4);
|
||||
level.sectors[secnum].SetColor(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -2412,7 +2412,7 @@ FUNC(LS_Sector_SetFade)
|
|||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetFade(arg1, arg2, arg3);
|
||||
level.sectors[secnum].SetFade(arg1, arg2, arg3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2427,8 +2427,8 @@ FUNC(LS_Sector_SetCeilingPanning)
|
|||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetXOffset(sector_t::ceiling, xofs);
|
||||
sectors[secnum].SetYOffset(sector_t::ceiling, yofs);
|
||||
level.sectors[secnum].SetXOffset(sector_t::ceiling, xofs);
|
||||
level.sectors[secnum].SetYOffset(sector_t::ceiling, yofs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2443,8 +2443,8 @@ FUNC(LS_Sector_SetFloorPanning)
|
|||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetXOffset(sector_t::floor, xofs);
|
||||
sectors[secnum].SetYOffset(sector_t::floor, yofs);
|
||||
level.sectors[secnum].SetXOffset(sector_t::floor, xofs);
|
||||
level.sectors[secnum].SetYOffset(sector_t::floor, yofs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2465,9 +2465,9 @@ FUNC(LS_Sector_SetFloorScale)
|
|||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
if (xscale)
|
||||
sectors[secnum].SetXScale(sector_t::floor, xscale);
|
||||
level.sectors[secnum].SetXScale(sector_t::floor, xscale);
|
||||
if (yscale)
|
||||
sectors[secnum].SetYScale(sector_t::floor, yscale);
|
||||
level.sectors[secnum].SetYScale(sector_t::floor, yscale);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2488,9 +2488,9 @@ FUNC(LS_Sector_SetCeilingScale)
|
|||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
if (xscale)
|
||||
sectors[secnum].SetXScale(sector_t::ceiling, xscale);
|
||||
level.sectors[secnum].SetXScale(sector_t::ceiling, xscale);
|
||||
if (yscale)
|
||||
sectors[secnum].SetYScale(sector_t::ceiling, yscale);
|
||||
level.sectors[secnum].SetYScale(sector_t::ceiling, yscale);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2510,9 +2510,9 @@ FUNC(LS_Sector_SetFloorScale2)
|
|||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
if (arg1)
|
||||
sectors[secnum].SetXScale(sector_t::floor, xscale);
|
||||
level.sectors[secnum].SetXScale(sector_t::floor, xscale);
|
||||
if (arg2)
|
||||
sectors[secnum].SetYScale(sector_t::floor, yscale);
|
||||
level.sectors[secnum].SetYScale(sector_t::floor, yscale);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2532,9 +2532,9 @@ FUNC(LS_Sector_SetCeilingScale2)
|
|||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
if (arg1)
|
||||
sectors[secnum].SetXScale(sector_t::ceiling, xscale);
|
||||
level.sectors[secnum].SetXScale(sector_t::ceiling, xscale);
|
||||
if (arg2)
|
||||
sectors[secnum].SetYScale(sector_t::ceiling, yscale);
|
||||
level.sectors[secnum].SetYScale(sector_t::ceiling, yscale);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2549,8 +2549,8 @@ FUNC(LS_Sector_SetRotation)
|
|||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[secnum].SetAngle(sector_t::floor, floor);
|
||||
sectors[secnum].SetAngle(sector_t::ceiling, ceiling);
|
||||
level.sectors[secnum].SetAngle(sector_t::floor, floor);
|
||||
level.sectors[secnum].SetAngle(sector_t::ceiling, ceiling);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3151,7 +3151,7 @@ FUNC(LS_ClearForceField)
|
|||
int secnum;
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
rtn = true;
|
||||
|
||||
sec->RemoveForceField();
|
||||
|
|
|
@ -3961,9 +3961,9 @@ void AActor::Tick ()
|
|||
sector_t *sec = node->m_sector;
|
||||
DVector2 scrollv;
|
||||
|
||||
if (level.Scrolls.Size() > unsigned(sec-sectors))
|
||||
if (level.Scrolls.Size() > unsigned(sec-&level.sectors[0]))
|
||||
{
|
||||
scrollv = level.Scrolls[sec - sectors];
|
||||
scrollv = level.Scrolls[sec - &level.sectors[0]];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5251,9 +5251,9 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
|
|||
{
|
||||
if (th->LastHeard == oldactor) th->LastHeard = NULL;
|
||||
}
|
||||
for(int i = 0; i < numsectors; i++)
|
||||
for(auto &sec : level.sectors)
|
||||
{
|
||||
if (sectors[i].SoundTarget == oldactor) sectors[i].SoundTarget = NULL;
|
||||
if (sec.SoundTarget == oldactor) sec.SoundTarget = nullptr;
|
||||
}
|
||||
|
||||
DObject::StaticPointerSubstitution (oldactor, p->mo);
|
||||
|
|
|
@ -220,7 +220,7 @@ bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag,
|
|||
FSectorTagIterator itr(tag, line);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
|
||||
if (sec->PlaneMoving(sector_t::floor) || sec->PlaneMoving(sector_t::ceiling))
|
||||
continue;
|
||||
|
|
|
@ -243,7 +243,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
|
|||
FSectorTagIterator itr(tag, line);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
sec = &level.sectors[secnum];
|
||||
|
||||
if (sec->PlaneMoving(sector_t::floor))
|
||||
{
|
||||
|
|
|
@ -192,7 +192,7 @@ void DPusher::Tick ()
|
|||
if (!var_pushers)
|
||||
return;
|
||||
|
||||
sec = sectors + m_Affectee;
|
||||
sec = &level.sectors[m_Affectee];
|
||||
|
||||
// Be sure the special sector type is still turned on. If so, proceed.
|
||||
// Else, bail out; the sector type has been changed on us.
|
||||
|
@ -339,7 +339,7 @@ AActor *P_GetPushThing (int s)
|
|||
AActor* thing;
|
||||
sector_t* sec;
|
||||
|
||||
sec = sectors + s;
|
||||
sec = &level.sectors[s];
|
||||
thing = sec->thinglist;
|
||||
|
||||
while (thing &&
|
||||
|
@ -407,7 +407,7 @@ void P_SpawnPushers ()
|
|||
thing->GetClass()->TypeName == NAME_PointPuller)
|
||||
{
|
||||
new DPusher (DPusher::p_push, l->args[3] ? l : NULL, l->args[2],
|
||||
0, thing, int(thing->Sector - sectors));
|
||||
0, thing, int(thing->Sector - &level.sectors[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ void AdjustPusher (int tag, int magnitude, int angle, bool wind)
|
|||
unsigned int i;
|
||||
for (i = 0; i < numcollected; i++)
|
||||
{
|
||||
if (Collection[i].RefNum == sectors[secnum].sectornum)
|
||||
if (Collection[i].RefNum == secnum)
|
||||
break;
|
||||
}
|
||||
if (i == numcollected)
|
||||
|
|
|
@ -281,7 +281,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t
|
|||
{
|
||||
if (level.Scrolls.Size() == 0)
|
||||
{
|
||||
level.Scrolls.Resize(numsectors);
|
||||
level.Scrolls.Resize(level.sectors.Size());
|
||||
memset(&level.Scrolls[0], 0, sizeof(level.Scrolls[0])*level.Scrolls.Size());
|
||||
level.Scrolls[p.sectornum] = scroll;
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
arc.Array("checksum", chk, 16);
|
||||
if (arc.GetSize("linedefs") != (unsigned)numlines ||
|
||||
arc.GetSize("sidedefs") != (unsigned)numsides ||
|
||||
arc.GetSize("sectors") != (unsigned)numsectors ||
|
||||
arc.GetSize("sectors") != level.sectors.Size() ||
|
||||
arc.GetSize("polyobjs") != (unsigned)po_NumPolyobjs ||
|
||||
memcmp(chk, level.md5, 16))
|
||||
{
|
||||
|
@ -954,7 +954,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
// The order here is important: First world state, then portal state, then thinkers, and last polyobjects.
|
||||
arc.Array("linedefs", lines, &loadlines[0], numlines);
|
||||
arc.Array("sidedefs", sides, &loadsides[0], numsides);
|
||||
arc.Array("sectors", sectors, &loadsectors[0], numsectors);
|
||||
arc.Array("sectors", &level.sectors[0], &loadsectors[0], level.sectors.Size());
|
||||
arc("zones", Zones);
|
||||
arc("lineportals", linePortals);
|
||||
arc("sectorportals", sectorPortals);
|
||||
|
@ -972,9 +972,9 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
|
||||
if (arc.isReading())
|
||||
{
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
P_Recalculate3DFloors(§ors[i]);
|
||||
P_Recalculate3DFloors(&sec);
|
||||
}
|
||||
for (int i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
|
|
|
@ -168,8 +168,8 @@ void DScroller::Tick ()
|
|||
|
||||
if (m_Control != -1)
|
||||
{ // compute scroll amounts based on a sector's height changes
|
||||
double height = sectors[m_Control].CenterFloor () +
|
||||
sectors[m_Control].CenterCeiling ();
|
||||
double height = level.sectors[m_Control].CenterFloor () +
|
||||
level.sectors[m_Control].CenterCeiling ();
|
||||
double delta = height - m_LastHeight;
|
||||
m_LastHeight = height;
|
||||
dx *= delta;
|
||||
|
@ -208,15 +208,15 @@ void DScroller::Tick ()
|
|||
break;
|
||||
|
||||
case EScroll::sc_floor: // killough 3/7/98: Scroll floor texture
|
||||
RotationComp(§ors[m_Affectee], sector_t::floor, dx, dy, tdx, tdy);
|
||||
sectors[m_Affectee].AddXOffset(sector_t::floor, tdx);
|
||||
sectors[m_Affectee].AddYOffset(sector_t::floor, tdy);
|
||||
RotationComp(&level.sectors[m_Affectee], sector_t::floor, dx, dy, tdx, tdy);
|
||||
level.sectors[m_Affectee].AddXOffset(sector_t::floor, tdx);
|
||||
level.sectors[m_Affectee].AddYOffset(sector_t::floor, tdy);
|
||||
break;
|
||||
|
||||
case EScroll::sc_ceiling: // killough 3/7/98: Scroll ceiling texture
|
||||
RotationComp(§ors[m_Affectee], sector_t::ceiling, dx, dy, tdx, tdy);
|
||||
sectors[m_Affectee].AddXOffset(sector_t::ceiling, tdx);
|
||||
sectors[m_Affectee].AddYOffset(sector_t::ceiling, tdy);
|
||||
RotationComp(&level.sectors[m_Affectee], sector_t::ceiling, dx, dy, tdx, tdy);
|
||||
level.sectors[m_Affectee].AddXOffset(sector_t::ceiling, tdx);
|
||||
level.sectors[m_Affectee].AddYOffset(sector_t::ceiling, tdy);
|
||||
break;
|
||||
|
||||
// [RH] Don't actually carry anything here. That happens later.
|
||||
|
@ -262,8 +262,10 @@ DScroller::DScroller (EScroll type, double dx, double dy,
|
|||
m_vdx = m_vdy = 0;
|
||||
m_LastHeight = 0;
|
||||
if ((m_Control = control) != -1)
|
||||
{
|
||||
m_LastHeight =
|
||||
sectors[control].CenterFloor () + sectors[control].CenterCeiling ();
|
||||
level.sectors[control].CenterFloor() + level.sectors[control].CenterCeiling();
|
||||
}
|
||||
m_Affectee = affectee;
|
||||
m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL;
|
||||
|
||||
|
@ -291,11 +293,11 @@ DScroller::DScroller (EScroll type, double dx, double dy,
|
|||
break;
|
||||
|
||||
case EScroll::sc_floor:
|
||||
m_Interpolations[0] = sectors[affectee].SetInterpolation(sector_t::FloorScroll, false);
|
||||
m_Interpolations[0] = level.sectors[affectee].SetInterpolation(sector_t::FloorScroll, false);
|
||||
break;
|
||||
|
||||
case EScroll::sc_ceiling:
|
||||
m_Interpolations[0] = sectors[affectee].SetInterpolation(sector_t::CeilingScroll, false);
|
||||
m_Interpolations[0] = level.sectors[affectee].SetInterpolation(sector_t::CeilingScroll, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -346,7 +348,7 @@ DScroller::DScroller (double dx, double dy, const line_t *l,
|
|||
m_Parts = scrollpos;
|
||||
m_LastHeight = 0;
|
||||
if ((m_Control = control) != -1)
|
||||
m_LastHeight = sectors[control].CenterFloor() + sectors[control].CenterCeiling();
|
||||
m_LastHeight = level.sectors[control].CenterFloor() + level.sectors[control].CenterCeiling();
|
||||
m_Affectee = int(l->sidedef[0] - sides);
|
||||
sides[m_Affectee].Flags |= WALLF_NOAUTODECALS;
|
||||
m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL;
|
||||
|
@ -439,7 +441,7 @@ void P_SpawnScrollers(void)
|
|||
{
|
||||
// if 1, then displacement
|
||||
// if 2, then accelerative (also if 3)
|
||||
control = int(l->sidedef[0]->sector - sectors);
|
||||
control = int(l->sidedef[0]->sector - &level.sectors[0]);
|
||||
if (l->args[1] & 2)
|
||||
accel = 1;
|
||||
}
|
||||
|
@ -476,7 +478,7 @@ void P_SpawnScrollers(void)
|
|||
|
||||
if (line->args[0] == l->args[0] && (line->args[1] & 1))
|
||||
{
|
||||
new DScroller(EScroll::sc_ceiling, -dx, dy, control, int(line->frontsector - sectors), accel);
|
||||
new DScroller(EScroll::sc_ceiling, -dx, dy, control, int(line->frontsector - &level.sectors[0]), accel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -496,7 +498,7 @@ void P_SpawnScrollers(void)
|
|||
|
||||
if (line->args[0] == l->args[0] && (line->args[1] & 2))
|
||||
{
|
||||
new DScroller (EScroll::sc_floor, -dx, dy, control, int(line->frontsector-sectors), accel);
|
||||
new DScroller(EScroll::sc_floor, -dx, dy, control, int(line->frontsector - &level.sectors[0]), accel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,7 +516,7 @@ void P_SpawnScrollers(void)
|
|||
|
||||
if (line->args[0] == l->args[0] && (line->args[1] & 4))
|
||||
{
|
||||
new DScroller (EScroll::sc_carry, dx, dy, control, int(line->frontsector-sectors), accel);
|
||||
new DScroller (EScroll::sc_carry, dx, dy, control, int(line->frontsector-&level.sectors[0]), accel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,8 +122,8 @@ int numsegs;
|
|||
seg_t* segs;
|
||||
glsegextra_t* glsegextras;
|
||||
|
||||
int numsectors;
|
||||
sector_t* sectors;
|
||||
//int numsectors;
|
||||
//sector_t* sectors;
|
||||
TArray<sector_t> loadsectors;
|
||||
|
||||
int numsubsectors;
|
||||
|
@ -808,11 +808,11 @@ void P_FloodZones ()
|
|||
int z = 0, i;
|
||||
ReverbContainer *reverb;
|
||||
|
||||
for (i = 0; i < numsectors; ++i)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
if (sectors[i].ZoneNumber == 0xFFFF)
|
||||
if (sec.ZoneNumber == 0xFFFF)
|
||||
{
|
||||
P_FloodZone (§ors[i], z++);
|
||||
P_FloodZone (&sec, z++);
|
||||
}
|
||||
}
|
||||
Zones.Resize(z);
|
||||
|
@ -1463,7 +1463,6 @@ void P_LoadSubsectors (MapData * map)
|
|||
|
||||
void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
|
||||
{
|
||||
int i;
|
||||
char *msp;
|
||||
mapsector_t *ms;
|
||||
sector_t* ss;
|
||||
|
@ -1471,8 +1470,9 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
|
|||
FDynamicColormap *fogMap, *normMap;
|
||||
int lumplen = map->Size(ML_SECTORS);
|
||||
|
||||
numsectors = lumplen / sizeof(mapsector_t);
|
||||
sectors = new sector_t[numsectors];
|
||||
unsigned numsectors = lumplen / sizeof(mapsector_t);
|
||||
level.sectors.Alloc(numsectors);
|
||||
auto sectors = &level.sectors[0];
|
||||
memset (sectors, 0, numsectors*sizeof(sector_t));
|
||||
|
||||
if (level.flags & LEVEL_SNDSEQTOTALCTRL)
|
||||
|
@ -1490,7 +1490,7 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
|
|||
// Extended properties
|
||||
sectors[0].e = new extsector_t[numsectors];
|
||||
|
||||
for (i = 0; i < numsectors; i++, ss++, ms++)
|
||||
for (unsigned i = 0; i < numsectors; i++, ss++, ms++)
|
||||
{
|
||||
ss->e = §ors[0].e[i];
|
||||
if (!map->HasBehavior) ss->Flags |= SECF_FLOORDROP;
|
||||
|
@ -2529,22 +2529,21 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps
|
|||
|
||||
if (colorgood | foggood)
|
||||
{
|
||||
int s;
|
||||
FDynamicColormap *colormap = NULL;
|
||||
|
||||
for (s = 0; s < numsectors; s++)
|
||||
for (unsigned s = 0; s < level.sectors.Size(); s++)
|
||||
{
|
||||
if (tagManager.SectorHasTag(s, tag))
|
||||
{
|
||||
if (!colorgood) color = sectors[s].ColorMap->Color;
|
||||
if (!foggood) fog = sectors[s].ColorMap->Fade;
|
||||
if (!colorgood) color = level.sectors[s].ColorMap->Color;
|
||||
if (!foggood) fog = level.sectors[s].ColorMap->Fade;
|
||||
if (colormap == NULL ||
|
||||
colormap->Color != color ||
|
||||
colormap->Fade != fog)
|
||||
{
|
||||
colormap = GetSpecialLights (color, fog, 0);
|
||||
}
|
||||
sectors[s].ColorMap = colormap;
|
||||
level.sectors[s].ColorMap = colormap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2638,14 +2637,14 @@ void P_LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex)
|
|||
// killough 4/11/98: refined to allow colormaps to work as wall
|
||||
// textures if invalid as colormaps but valid as textures.
|
||||
|
||||
if ((unsigned)LittleShort(msd->sector)>=(unsigned)numsectors)
|
||||
if ((unsigned)LittleShort(msd->sector)>=level.sectors.Size())
|
||||
{
|
||||
Printf (PRINT_HIGH, "Sidedef %d has a bad sector\n", i);
|
||||
sd->sector = sec = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
sd->sector = sec = §ors[LittleShort(msd->sector)];
|
||||
sd->sector = sec = &level.sectors[LittleShort(msd->sector)];
|
||||
}
|
||||
|
||||
intmapsidedef_t imsd;
|
||||
|
@ -3089,28 +3088,26 @@ static void P_GroupLines (bool buildmap)
|
|||
{
|
||||
cycle_t times[16];
|
||||
unsigned int* linesDoneInEachSector;
|
||||
int i;
|
||||
int total;
|
||||
line_t* li;
|
||||
sector_t* sector;
|
||||
FBoundingBox bbox;
|
||||
bool flaggedNoFronts = false;
|
||||
unsigned int jj;
|
||||
|
||||
for (i = 0; i < (int)countof(times); ++i)
|
||||
for (unsigned i = 0; i < countof(times); ++i)
|
||||
{
|
||||
times[i].Reset();
|
||||
}
|
||||
|
||||
// look up sector number for each subsector
|
||||
times[0].Clock();
|
||||
for (i = 0; i < numsubsectors; i++)
|
||||
for (int i = 0; i < numsubsectors; i++)
|
||||
{
|
||||
subsectors[i].sector = subsectors[i].firstline->sidedef->sector;
|
||||
}
|
||||
if (glsegextras != NULL)
|
||||
{
|
||||
for (i = 0; i < numsubsectors; i++)
|
||||
for (int i = 0; i < numsubsectors; i++)
|
||||
{
|
||||
for (jj = 0; jj < subsectors[i].numlines; ++jj)
|
||||
{
|
||||
|
@ -3123,8 +3120,9 @@ static void P_GroupLines (bool buildmap)
|
|||
// count number of lines in each sector
|
||||
times[1].Clock();
|
||||
total = 0;
|
||||
for (i = 0, li = lines; i < numlines; i++, li++)
|
||||
for (int i = 0; i < numlines; i++)
|
||||
{
|
||||
auto li = &lines[i];
|
||||
if (li->frontsector == NULL)
|
||||
{
|
||||
if (!flaggedNoFronts)
|
||||
|
@ -3156,10 +3154,12 @@ static void P_GroupLines (bool buildmap)
|
|||
times[3].Clock();
|
||||
linebuffer = new line_t *[total];
|
||||
line_t **lineb_p = linebuffer;
|
||||
auto numsectors = level.sectors.Size();
|
||||
linesDoneInEachSector = new unsigned int[numsectors];
|
||||
memset (linesDoneInEachSector, 0, sizeof(int)*numsectors);
|
||||
|
||||
for (sector = sectors, i = 0; i < numsectors; i++, sector++)
|
||||
sector = &level.sectors[0];
|
||||
for (unsigned i = 0; i < numsectors; i++, sector++)
|
||||
{
|
||||
if (sector->Lines.Count == 0)
|
||||
{
|
||||
|
@ -3174,19 +3174,21 @@ static void P_GroupLines (bool buildmap)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = numlines, li = lines; i > 0; --i, ++li)
|
||||
for (int i = 0; i < numlines; i++)
|
||||
{
|
||||
auto li = &lines[i];
|
||||
if (li->frontsector != NULL)
|
||||
{
|
||||
li->frontsector->Lines[linesDoneInEachSector[li->frontsector - sectors]++] = li;
|
||||
li->frontsector->Lines[linesDoneInEachSector[li->frontsector - &level.sectors[0]]++] = li;
|
||||
}
|
||||
if (li->backsector != NULL && li->backsector != li->frontsector)
|
||||
{
|
||||
li->backsector->Lines[linesDoneInEachSector[li->backsector - sectors]++] = li;
|
||||
li->backsector->Lines[linesDoneInEachSector[li->backsector - &level.sectors[0]]++] = li;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, sector = sectors; i < numsectors; ++i, ++sector)
|
||||
sector = &level.sectors[0];
|
||||
for (unsigned i = 0; i < numsectors; ++i, ++sector)
|
||||
{
|
||||
if (linesDoneInEachSector[i] != sector->Lines.Size())
|
||||
{
|
||||
|
@ -3235,7 +3237,7 @@ static void P_GroupLines (bool buildmap)
|
|||
if (showloadtimes)
|
||||
{
|
||||
Printf ("---Group Lines Times---\n");
|
||||
for (i = 0; i < 7; ++i)
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
Printf (" time %d:%9.4f ms\n", i, times[i].TimeMS());
|
||||
}
|
||||
|
@ -3247,7 +3249,7 @@ static void P_GroupLines (bool buildmap)
|
|||
//
|
||||
void P_LoadReject (MapData * map, bool junk)
|
||||
{
|
||||
const int neededsize = (numsectors * numsectors + 7) >> 3;
|
||||
const int neededsize = (level.sectors.Size() * level.sectors.Size() + 7) >> 3;
|
||||
int rejectsize;
|
||||
|
||||
if (strnicmp (map->MapLumps[ML_REJECT].Name, "REJECT", 8) != 0)
|
||||
|
@ -3385,10 +3387,10 @@ static void P_PrecacheLevel()
|
|||
if (cls != NULL) actorhitlist[cls] = true;
|
||||
}
|
||||
|
||||
for (i = numsectors - 1; i >= 0; i--)
|
||||
for (i = level.sectors.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[sectors[i].GetTexture(sector_t::floor).GetIndex()] |= FTextureManager::HIT_Flat;
|
||||
hitlist[sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= FTextureManager::HIT_Flat;
|
||||
hitlist[level.sectors[i].GetTexture(sector_t::floor).GetIndex()] |= FTextureManager::HIT_Flat;
|
||||
hitlist[level.sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= FTextureManager::HIT_Flat;
|
||||
}
|
||||
|
||||
for (i = numsides - 1; i >= 0; i--)
|
||||
|
@ -3458,13 +3460,12 @@ void P_FreeLevelData ()
|
|||
delete[] glsegextras;
|
||||
glsegextras = NULL;
|
||||
}
|
||||
if (sectors != NULL)
|
||||
if (level.sectors.Size() > 0)
|
||||
{
|
||||
delete[] sectors[0].e;
|
||||
delete[] sectors;
|
||||
sectors = NULL;
|
||||
delete[] level.sectors[0].e;
|
||||
}
|
||||
numsectors = 0;
|
||||
level.sectors.Clear();
|
||||
|
||||
if (gamenodes != NULL && gamenodes != nodes)
|
||||
{
|
||||
delete[] gamenodes;
|
||||
|
@ -4069,10 +4070,10 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
P_SpawnSpecials ();
|
||||
|
||||
// disable reflective planes on sloped sectors.
|
||||
for (auto i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
if (sectors[i].floorplane.isSlope()) sectors[i].reflect[sector_t::floor] = 0;
|
||||
if (sectors[i].ceilingplane.isSlope()) sectors[i].reflect[sector_t::ceiling] = 0;
|
||||
if (sec.floorplane.isSlope()) sec.reflect[sector_t::floor] = 0;
|
||||
if (sec.ceilingplane.isSlope()) sec.reflect[sector_t::ceiling] = 0;
|
||||
}
|
||||
|
||||
// This must be done BEFORE the PolyObj Spawn!!!
|
||||
|
@ -4192,8 +4193,8 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
MapThingsUserDataIndex.Clear();
|
||||
MapThingsUserData.Clear();
|
||||
|
||||
loadsectors.Resize(numsectors);
|
||||
memcpy(&loadsectors[0], sectors, numsectors * sizeof(sector_t));
|
||||
loadsectors.Resize(level.sectors.Size());
|
||||
memcpy(&loadsectors[0], &level.sectors[0], loadsectors.Size() * sizeof(sector_t));
|
||||
loadlines.Resize(numlines);
|
||||
memcpy(&loadlines[0], lines, numlines * sizeof(line_t));
|
||||
loadsides.Resize(numsides);
|
||||
|
|
|
@ -821,7 +821,7 @@ bool P_CheckSight (AActor *t1, AActor *t2, int flags)
|
|||
|
||||
const sector_t *s1 = t1->Sector;
|
||||
const sector_t *s2 = t2->Sector;
|
||||
int pnum = int(s1 - sectors) * numsectors + int(s2 - sectors);
|
||||
int pnum = int(s1 - &level.sectors[0]) * level.sectors.Size() + int(s2 - &level.sectors[0]);
|
||||
|
||||
//
|
||||
// check for trivial rejection
|
||||
|
|
|
@ -125,7 +125,7 @@ static void P_CopyPlane (int tag, sector_t *dest, bool copyCeil)
|
|||
return;
|
||||
}
|
||||
|
||||
source = §ors[secnum];
|
||||
source = &level.sectors[secnum];
|
||||
|
||||
if (copyCeil)
|
||||
{
|
||||
|
@ -301,19 +301,18 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
|
|||
|
||||
if (vt_found)
|
||||
{
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
sector_t *sec = §ors[i];
|
||||
if (sec->Lines.Size() != 3) continue; // only works with triangular sectors
|
||||
if (sec.Lines.Size() != 3) continue; // only works with triangular sectors
|
||||
|
||||
DVector3 vt1, vt2, vt3, cross;
|
||||
DVector3 vec1, vec2;
|
||||
int vi1, vi2, vi3;
|
||||
|
||||
vi1 = int(sec->Lines[0]->v1 - vertexes);
|
||||
vi2 = int(sec->Lines[0]->v2 - vertexes);
|
||||
vi3 = (sec->Lines[1]->v1 == sec->Lines[0]->v1 || sec->Lines[1]->v1 == sec->Lines[0]->v2)?
|
||||
int(sec->Lines[1]->v2 - vertexes) : int(sec->Lines[1]->v1 - vertexes);
|
||||
vi1 = int(sec.Lines[0]->v1 - vertexes);
|
||||
vi2 = int(sec.Lines[0]->v2 - vertexes);
|
||||
vi3 = (sec.Lines[1]->v1 == sec.Lines[0]->v1 || sec.Lines[1]->v1 == sec.Lines[0]->v2)?
|
||||
int(sec.Lines[1]->v2 - vertexes) : int(sec.Lines[1]->v1 - vertexes);
|
||||
|
||||
vt1 = DVector3(vertexes[vi1].fPos(), 0);
|
||||
vt2 = DVector3(vertexes[vi2].fPos(), 0);
|
||||
|
@ -326,11 +325,11 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
|
|||
double *h3 = vt_heights[j].CheckKey(vi3);
|
||||
if (h1 == NULL && h2 == NULL && h3 == NULL) continue;
|
||||
|
||||
vt1.Z = h1? *h1 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
||||
vt2.Z = h2? *h2 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
||||
vt3.Z = h3? *h3 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
||||
vt1.Z = h1? *h1 : j==0? sec.GetPlaneTexZ(sector_t::floor) : sec.GetPlaneTexZ(sector_t::ceiling);
|
||||
vt2.Z = h2? *h2 : j==0? sec.GetPlaneTexZ(sector_t::floor) : sec.GetPlaneTexZ(sector_t::ceiling);
|
||||
vt3.Z = h3? *h3 : j==0? sec.GetPlaneTexZ(sector_t::floor) : sec.GetPlaneTexZ(sector_t::ceiling);
|
||||
|
||||
if (P_PointOnLineSidePrecise(vertexes[vi3].fX(), vertexes[vi3].fY(), sec->Lines[0]) == 0)
|
||||
if (P_PointOnLineSidePrecise(vertexes[vi3].fX(), vertexes[vi3].fY(), sec.Lines[0]) == 0)
|
||||
{
|
||||
vec1 = vt2 - vt3;
|
||||
vec2 = vt1 - vt3;
|
||||
|
@ -358,7 +357,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
|
|||
cross = -cross;
|
||||
}
|
||||
|
||||
secplane_t *plane = j==0? &sec->floorplane : &sec->ceilingplane;
|
||||
secplane_t *plane = j==0? &sec.floorplane : &sec.ceilingplane;
|
||||
|
||||
double dist = -cross[0] * vertexes[vi3].fX() - cross[1] * vertexes[vi3].fY() - cross[2] * vt3.Z;
|
||||
plane->set(cross[0], cross[1], cross[2], dist);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "d_event.h"
|
||||
#include "g_level.h"
|
||||
#include "gstrings.h"
|
||||
|
||||
#include "i_system.h"
|
||||
|
@ -432,7 +433,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector)
|
|||
if (sector->isSecret())
|
||||
{
|
||||
sector->ClearSecret();
|
||||
P_GiveSecret(player->mo, true, true, int(sector - sectors));
|
||||
P_GiveSecret(player->mo, true, true, int(sector - &level.sectors[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,7 +473,7 @@ void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass,
|
|||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
AActor *actor, *next;
|
||||
sector_t *sec = §ors[secnum];
|
||||
sector_t *sec = &level.sectors[secnum];
|
||||
|
||||
// Do for actors in this sector.
|
||||
for (actor = sec->thinglist; actor != NULL; actor = next)
|
||||
|
@ -629,13 +630,10 @@ CUSTOM_CVAR (Bool, forcewater, false, CVAR_ARCHIVE|CVAR_SERVERINFO)
|
|||
{
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
sector_t *hsec = sectors[i].GetHeightSec();
|
||||
if (hsec &&
|
||||
!(sectors[i].heightsec->MoreFlags & SECF_UNDERWATER))
|
||||
sector_t *hsec = sec.GetHeightSec();
|
||||
if (hsec && !(hsec->MoreFlags & SECF_UNDERWATER))
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
|
@ -693,13 +691,13 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor)
|
|||
{
|
||||
FSectorTagIterator itr(target);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
|
||||
level.sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
FSectorTagIterator itr(target);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING);
|
||||
level.sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING);
|
||||
}
|
||||
ChangeStatNum (STAT_LIGHTTRANSFER);
|
||||
}
|
||||
|
@ -715,7 +713,7 @@ void DLightTransfer::Tick ()
|
|||
}
|
||||
}
|
||||
|
||||
void DLightTransfer::DoTransfer (int level, int target, bool floor)
|
||||
void DLightTransfer::DoTransfer (int llevel, int target, bool floor)
|
||||
{
|
||||
int secnum;
|
||||
|
||||
|
@ -723,13 +721,13 @@ void DLightTransfer::DoTransfer (int level, int target, bool floor)
|
|||
{
|
||||
FSectorTagIterator itr(target);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
sectors[secnum].SetPlaneLight(sector_t::floor, level);
|
||||
level.sectors[secnum].SetPlaneLight(sector_t::floor, llevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
FSectorTagIterator itr(target);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
sectors[secnum].SetPlaneLight(sector_t::ceiling, level);
|
||||
level.sectors[secnum].SetPlaneLight(sector_t::ceiling, llevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -957,7 +955,7 @@ static void CopyPortal(int sectortag, int plane, unsigned pnum, double alpha, bo
|
|||
FSectorTagIterator itr(sectortag);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SetPortal(§ors[s], plane, pnum, alpha);
|
||||
SetPortal(&level.sectors[s], plane, pnum, alpha);
|
||||
}
|
||||
|
||||
for (int j=0;j<numlines;j++)
|
||||
|
@ -978,7 +976,7 @@ static void CopyPortal(int sectortag, int plane, unsigned pnum, double alpha, bo
|
|||
FSectorTagIterator itr(lines[j].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SetPortal(§ors[s], plane, pnum, alpha);
|
||||
SetPortal(&level.sectors[s], plane, pnum, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1159,7 +1157,7 @@ void P_InitSectorSpecial(sector_t *sector, int special)
|
|||
|
||||
case dScroll_EastLavaDamage:
|
||||
P_SetupSectorDamage(sector, 5, 32, 256, NAME_Fire, SECF_DMGTERRAINFX);
|
||||
P_CreateScroller(EScroll::sc_floor, -4., 0, -1, int(sector - sectors), 0);
|
||||
P_CreateScroller(EScroll::sc_floor, -4., 0, -1, int(sector - &level.sectors[0]), 0);
|
||||
keepspecial = true;
|
||||
break;
|
||||
|
||||
|
@ -1217,14 +1215,14 @@ void P_InitSectorSpecial(sector_t *sector, int special)
|
|||
int i = sector->special - Scroll_North_Slow;
|
||||
double dx = hexenScrollies[i][0] / 2.;
|
||||
double dy = hexenScrollies[i][1] / 2.;
|
||||
P_CreateScroller(EScroll::sc_floor, dx, dy, -1, int(sector-sectors), 0);
|
||||
P_CreateScroller(EScroll::sc_floor, dx, dy, -1, int(sector-&level.sectors[0]), 0);
|
||||
}
|
||||
else if (sector->special >= Carry_East5 &&
|
||||
sector->special <= Carry_East35)
|
||||
{ // Heretic scroll special
|
||||
// Only east scrollers also scroll the texture
|
||||
P_CreateScroller(EScroll::sc_floor,
|
||||
-0.5 * (1 << ((sector->special & 0xff) - Carry_East5)), 0, -1, int(sector-sectors), 0);
|
||||
-0.5 * (1 << ((sector->special & 0xff) - Carry_East5)), 0, -1, int(sector-&level.sectors[0]), 0);
|
||||
}
|
||||
keepspecial = true;
|
||||
break;
|
||||
|
@ -1240,20 +1238,14 @@ void P_InitSectorSpecial(sector_t *sector, int special)
|
|||
|
||||
void P_SpawnSpecials (void)
|
||||
{
|
||||
sector_t *sector;
|
||||
int i;
|
||||
|
||||
P_SetupPortals();
|
||||
|
||||
// Init special SECTORs.
|
||||
sector = sectors;
|
||||
|
||||
for (i = 0; i < numsectors; i++, sector++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
if (sector->special == 0)
|
||||
if (sec.special == 0)
|
||||
continue;
|
||||
|
||||
P_InitSectorSpecial(sector, sector->special);
|
||||
P_InitSectorSpecial(&sec, sec.special);
|
||||
}
|
||||
|
||||
#ifndef NO_EDATA
|
||||
|
@ -1274,7 +1266,7 @@ void P_SpawnSpecials (void)
|
|||
P_SpawnSkybox(pt2);
|
||||
}
|
||||
|
||||
for (i = 0; i < numlines; i++)
|
||||
for (int i = 0; i < numlines; i++)
|
||||
{
|
||||
switch (lines[i].special)
|
||||
{
|
||||
|
@ -1313,9 +1305,9 @@ void P_SpawnSpecials (void)
|
|||
FSectorTagIterator itr(lines[i].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[s].heightsec = sec;
|
||||
sec->e->FakeFloor.Sectors.Push(§ors[s]);
|
||||
sectors[s].AdjustFloorClip();
|
||||
level.sectors[s].heightsec = sec;
|
||||
sec->e->FakeFloor.Sectors.Push(&level.sectors[s]);
|
||||
level.sectors[s].AdjustFloorClip();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1388,7 +1380,7 @@ void P_SpawnSpecials (void)
|
|||
double grav = lines[i].Delta().Length() / 100.;
|
||||
FSectorTagIterator itr(lines[i].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
sectors[s].gravity = grav;
|
||||
level.sectors[s].gravity = grav;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1401,7 +1393,7 @@ void P_SpawnSpecials (void)
|
|||
FSectorTagIterator itr(lines[i].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
sector_t *sec = §ors[s];
|
||||
sector_t *sec = &level.sectors[s];
|
||||
sec->damageamount = damage;
|
||||
sec->damagetype = NAME_None;
|
||||
if (sec->damageamount < 20)
|
||||
|
@ -1441,7 +1433,7 @@ void P_SpawnSpecials (void)
|
|||
{
|
||||
FSectorTagIterator itr(lines[i].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
sectors[s].sky = (i + 1) | PL_SKYFLAT;
|
||||
level.sectors[s].sky = (i + 1) | PL_SKYFLAT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1561,19 +1553,19 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag)
|
|||
// drag on CPU. New code adjusts friction of sector only once
|
||||
// at level startup, and then uses this friction value.
|
||||
|
||||
sectors[s].friction = friction;
|
||||
sectors[s].movefactor = movefactor;
|
||||
level.sectors[s].friction = friction;
|
||||
level.sectors[s].movefactor = movefactor;
|
||||
if (alterFlag)
|
||||
{
|
||||
// When used inside a script, the sectors' friction flags
|
||||
// can be enabled and disabled at will.
|
||||
if (friction == ORIG_FRICTION)
|
||||
{
|
||||
sectors[s].Flags &= ~SECF_FRICTION;
|
||||
level.sectors[s].Flags &= ~SECF_FRICTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
sectors[s].Flags |= SECF_FRICTION;
|
||||
level.sectors[s].Flags |= SECF_FRICTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ FTagManager tagManager;
|
|||
|
||||
static inline int sectindex(const sector_t *sector)
|
||||
{
|
||||
return (int)(intptr_t)(sector - sectors);
|
||||
return (int)(intptr_t)(sector - &level.sectors[0]);
|
||||
}
|
||||
|
||||
static inline int lineindex(const line_t *line)
|
||||
|
@ -334,11 +334,11 @@ int FSectorTagIterator::Next()
|
|||
else
|
||||
{
|
||||
// with the tag manager, searching for tag 0 has to be different, because it won't create entries for untagged sectors.
|
||||
while (start < numsectors && tagManager.SectorHasTags(start))
|
||||
while (start < (int)level.sectors.Size() && tagManager.SectorHasTags(start))
|
||||
{
|
||||
start++;
|
||||
}
|
||||
if (start == numsectors) return -1;
|
||||
if (start == (int)level.sectors.Size()) return -1;
|
||||
ret = start;
|
||||
start++;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ int FSectorTagIterator::NextCompat(bool compat, int start)
|
|||
{
|
||||
if (!compat) return Next();
|
||||
|
||||
for (int i = start + 1; i < numsectors; i++)
|
||||
for (unsigned i = start + 1; i < level.sectors.Size(); i++)
|
||||
{
|
||||
if (tagManager.SectorHasTag(i, searchtag)) return i;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
if (tag == 0)
|
||||
{
|
||||
searchtag = INT_MIN;
|
||||
start = (line == NULL || line->backsector == NULL)? -1 : (int)(line->backsector - sectors);
|
||||
start = (line == NULL || line->backsector == NULL)? -1 : (int)(line->backsector - &level.sectors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -333,7 +333,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
|
|||
TThinkerIterator<AActor> it2(NAME_TeleportDest);
|
||||
while ((searcher = it2.Next()) != NULL)
|
||||
{
|
||||
if (searcher->Sector == sectors + secnum)
|
||||
if (searcher->Sector == &level.sectors[secnum])
|
||||
{
|
||||
return searcher;
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro
|
|||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
msecnode_t *node;
|
||||
const sector_t * const sec = §ors[secnum];
|
||||
const sector_t * const sec = &level.sectors[secnum];
|
||||
|
||||
for (node = sec->touching_thinglist; node; )
|
||||
{
|
||||
|
|
|
@ -444,7 +444,7 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit)
|
|||
// hit crossed a water plane
|
||||
if (CheckSectorPlane(hsec, true))
|
||||
{
|
||||
Results->CrossedWater = §ors[CurSector->sectornum];
|
||||
Results->CrossedWater = &level.sectors[CurSector->sectornum];
|
||||
Results->CrossedWaterPos = Results->HitPos;
|
||||
Results->Distance = 0;
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ cont:
|
|||
if (Results->HitType != TRACE_HitNone)
|
||||
{
|
||||
// We hit something, so figure out where exactly
|
||||
Results->Sector = §ors[CurSector->sectornum];
|
||||
Results->Sector = &level.sectors[CurSector->sectornum];
|
||||
|
||||
if (Results->HitType != TRACE_HitWall &&
|
||||
!CheckSectorPlane(CurSector, Results->HitType == TRACE_HitFloor))
|
||||
|
@ -698,7 +698,7 @@ bool FTraceInfo::ThingCheck(intercept_t *in, double dist, DVector3 hit)
|
|||
|
||||
// the trace hit a 3D floor before the thing.
|
||||
// Calculate an intersection and abort.
|
||||
Results->Sector = §ors[CurSector->sectornum];
|
||||
Results->Sector = &level.sectors[CurSector->sectornum];
|
||||
if (!CheckSectorPlane(CurSector, Results->HitType == TRACE_HitFloor))
|
||||
{
|
||||
Results->HitType = TRACE_HitNone;
|
||||
|
@ -850,7 +850,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
|
|||
}
|
||||
|
||||
// check for intersection with floor/ceiling
|
||||
Results->Sector = §ors[CurSector->sectornum];
|
||||
Results->Sector = &level.sectors[CurSector->sectornum];
|
||||
|
||||
if (Results->CrossedWater == NULL &&
|
||||
CurSector->heightsec != NULL &&
|
||||
|
@ -864,7 +864,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
|
|||
|
||||
if (CheckSectorPlane(CurSector->heightsec, true))
|
||||
{
|
||||
Results->CrossedWater = §ors[CurSector->sectornum];
|
||||
Results->CrossedWater = &level.sectors[CurSector->sectornum];
|
||||
Results->CrossedWaterPos = Results->HitPos;
|
||||
Results->Distance = 0;
|
||||
}
|
||||
|
|
|
@ -1834,7 +1834,7 @@ public:
|
|||
{
|
||||
sides[side] = ParsedSides[mapside];
|
||||
sides[side].linedef = &lines[line];
|
||||
sides[side].sector = §ors[intptr_t(sides[side].sector)];
|
||||
sides[side].sector = &level.sectors[intptr_t(sides[side].sector)];
|
||||
lines[line].sidedef[sd] = &sides[side];
|
||||
|
||||
P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
|
||||
|
@ -2019,13 +2019,12 @@ public:
|
|||
memcpy(vertexdatas, &ParsedVertexDatas[0], numvertexdatas * sizeof(*vertexdatas));
|
||||
|
||||
// Create the real sectors
|
||||
numsectors = ParsedSectors.Size();
|
||||
sectors = new sector_t[numsectors];
|
||||
memcpy(sectors, &ParsedSectors[0], numsectors * sizeof(*sectors));
|
||||
sectors[0].e = new extsector_t[numsectors];
|
||||
for(int i = 0; i < numsectors; i++)
|
||||
level.sectors.Alloc(ParsedSectors.Size());
|
||||
memcpy(&level.sectors[0], &ParsedSectors[0], level.sectors.Size() * sizeof(sector_t));
|
||||
level.sectors[0].e = new extsector_t[level.sectors.Size()];
|
||||
for(unsigned i = 0; i < level.sectors.Size(); i++)
|
||||
{
|
||||
sectors[i].e = §ors[0].e[i];
|
||||
level.sectors[i].e = &level.sectors[0].e[i];
|
||||
}
|
||||
|
||||
// Create the real linedefs and decompress the sidedefs
|
||||
|
|
|
@ -2060,7 +2060,7 @@ void P_MovePlayer (player_t *player)
|
|||
msecnode_t *n = player->mo->touching_sectorlist;
|
||||
while (n != NULL)
|
||||
{
|
||||
fprintf (debugfile, "%td ", n->m_sector-sectors);
|
||||
fprintf (debugfile, "%d ", n->m_sector->sectornum);
|
||||
n = n->m_tnext;
|
||||
}
|
||||
fprintf (debugfile, "]\n");
|
||||
|
|
|
@ -152,7 +152,7 @@ static int WriteSIDEDEFS (FILE *file)
|
|||
{
|
||||
msd.textureoffset = LittleShort(short(sides[i].GetTextureXOffset(side_t::mid)));
|
||||
msd.rowoffset = LittleShort(short(sides[i].GetTextureYOffset(side_t::mid)));
|
||||
msd.sector = LittleShort(short(sides[i].sector - sectors));
|
||||
msd.sector = LittleShort(short(sides[i].sector - &level.sectors[0]));
|
||||
uppercopy (msd.toptexture, GetTextureName (sides[i].GetTexture(side_t::top)));
|
||||
uppercopy (msd.bottomtexture, GetTextureName (sides[i].GetTexture(side_t::bottom)));
|
||||
uppercopy (msd.midtexture, GetTextureName (sides[i].GetTexture(side_t::mid)));
|
||||
|
@ -194,18 +194,18 @@ static int WriteSECTORS (FILE *file)
|
|||
{
|
||||
mapsector_t ms;
|
||||
|
||||
for (int i = 0; i < numsectors; ++i)
|
||||
for (unsigned i = 0; i < level.sectors.Size(); ++i)
|
||||
{
|
||||
ms.floorheight = LittleShort(short(sectors[i].GetPlaneTexZ(sector_t::floor)));
|
||||
ms.ceilingheight = LittleShort(short(sectors[i].GetPlaneTexZ(sector_t::ceiling)));
|
||||
uppercopy (ms.floorpic, GetTextureName (sectors[i].GetTexture(sector_t::floor)));
|
||||
uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling)));
|
||||
ms.lightlevel = LittleShort((short)sectors[i].lightlevel);
|
||||
ms.special = LittleShort(sectors[i].special);
|
||||
ms.tag = LittleShort(tagManager.GetFirstSectorTag(§ors[i]));
|
||||
ms.floorheight = LittleShort(short(level.sectors[i].GetPlaneTexZ(sector_t::floor)));
|
||||
ms.ceilingheight = LittleShort(short(level.sectors[i].GetPlaneTexZ(sector_t::ceiling)));
|
||||
uppercopy (ms.floorpic, GetTextureName (level.sectors[i].GetTexture(sector_t::floor)));
|
||||
uppercopy (ms.ceilingpic, GetTextureName (level.sectors[i].GetTexture(sector_t::ceiling)));
|
||||
ms.lightlevel = LittleShort((short)level.sectors[i].lightlevel);
|
||||
ms.special = LittleShort(level.sectors[i].special);
|
||||
ms.tag = LittleShort(tagManager.GetFirstSectorTag(&level.sectors[i]));
|
||||
fwrite (&ms, sizeof(ms), 1, file);
|
||||
}
|
||||
return numsectors * sizeof(ms);
|
||||
return level.sectors.Size() * sizeof(ms);
|
||||
}
|
||||
|
||||
static int WriteREJECT (FILE *file)
|
||||
|
|
|
@ -980,18 +980,18 @@ void P_CreateLinkedPortals()
|
|||
id = 1;
|
||||
if (orgs.Size() != 0)
|
||||
{
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
if (sectors[i].GetPortalType(j) == PORTS_LINKEDPORTAL)
|
||||
if (sec.GetPortalType(j) == PORTS_LINKEDPORTAL)
|
||||
{
|
||||
secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane;
|
||||
secplane_t &plane = j == 0 ? sec.floorplane : sec.ceilingplane;
|
||||
if (plane.isSlope())
|
||||
{
|
||||
// The engine cannot deal with portals on a sloped plane.
|
||||
sectors[i].ClearPortal(j);
|
||||
Printf("Portal on %s of sector %d is sloped and will be disabled\n", j == 0 ? "floor" : "ceiling", i);
|
||||
sec.ClearPortal(j);
|
||||
Printf("Portal on %s of sector %d is sloped and will be disabled\n", j == 0 ? "floor" : "ceiling", sec.sectornum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1015,14 +1015,14 @@ void P_CreateLinkedPortals()
|
|||
|
||||
Displacements.Create(id);
|
||||
// Check for leftover sectors that connect to a portal
|
||||
for (int i = 0; i<numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
if (sectors[i].GetPortalType(j) == PORTS_LINKEDPORTAL && sectors[i].PortalGroup == 0)
|
||||
if (sec.GetPortalType(j) == PORTS_LINKEDPORTAL && sec.PortalGroup == 0)
|
||||
{
|
||||
auto p = sectors[i].GetPortal(j);
|
||||
CollectSectors(p->mOrigin->PortalGroup, §ors[i]);
|
||||
auto p = sec.GetPortal(j);
|
||||
CollectSectors(p->mOrigin->PortalGroup, &sec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1048,10 +1048,10 @@ void P_CreateLinkedPortals()
|
|||
(dispxy.pos.X != -dispyx.pos.X || dispxy.pos.Y != -dispyx.pos.Y))
|
||||
{
|
||||
int sec1 = -1, sec2 = -1;
|
||||
for (int i = 0; i < numsectors && (sec1 == -1 || sec2 == -1); i++)
|
||||
for (unsigned i = 0; i < level.sectors.Size() && (sec1 == -1 || sec2 == -1); i++)
|
||||
{
|
||||
if (sec1 == -1 && sectors[i].PortalGroup == x) sec1 = i;
|
||||
if (sec2 == -1 && sectors[i].PortalGroup == y) sec2 = i;
|
||||
if (sec1 == -1 && level.sectors[i].PortalGroup == x) sec1 = i;
|
||||
if (sec2 == -1 && level.sectors[i].PortalGroup == y) sec2 = i;
|
||||
}
|
||||
Printf("Link offset mismatch between sectors %d and %d\n", sec1, sec2);
|
||||
bogus = true;
|
||||
|
@ -1065,13 +1065,13 @@ void P_CreateLinkedPortals()
|
|||
}
|
||||
}
|
||||
// and now print a message for everything that still wasn't processed.
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
if (sectors[i].PortalGroup == 0)
|
||||
if (sec.PortalGroup == 0)
|
||||
{
|
||||
Printf("Unable to assign sector %d to any group. Possibly self-referencing\n", i);
|
||||
Printf("Unable to assign sector %d to any group. Possibly self-referencing\n", sec.sectornum);
|
||||
}
|
||||
else if (sectors[i].PortalGroup == -1) sectors[i].PortalGroup = 0;
|
||||
else if (sec.PortalGroup == -1) sec.PortalGroup = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1088,41 +1088,41 @@ void P_CreateLinkedPortals()
|
|||
rejectmatrix = NULL;
|
||||
}
|
||||
// finally we must flag all planes which are obstructed by the sector's own ceiling or floor.
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
sectors[i].CheckPortalPlane(sector_t::floor);
|
||||
sectors[i].CheckPortalPlane(sector_t::ceiling);
|
||||
sec.CheckPortalPlane(sector_t::floor);
|
||||
sec.CheckPortalPlane(sector_t::ceiling);
|
||||
// set a flag on each line connecting to a plane portal sector. This is used to reduce the amount of checks in P_CheckSight.
|
||||
if (sectors[i].PortalIsLinked(sector_t::floor) || sectors[i].PortalIsLinked(sector_t::ceiling))
|
||||
if (sec.PortalIsLinked(sector_t::floor) || sec.PortalIsLinked(sector_t::ceiling))
|
||||
{
|
||||
for(auto ln : sectors[i].Lines)
|
||||
for(auto ln : sec.Lines)
|
||||
{
|
||||
ln->flags |= ML_PORTALCONNECT;
|
||||
}
|
||||
}
|
||||
if (sectors[i].PortalIsLinked(sector_t::ceiling) && sectors[i].PortalIsLinked(sector_t::floor))
|
||||
if (sec.PortalIsLinked(sector_t::ceiling) && sec.PortalIsLinked(sector_t::floor))
|
||||
{
|
||||
double cz = sectors[i].GetPortalPlaneZ(sector_t::ceiling);
|
||||
double fz = sectors[i].GetPortalPlaneZ(sector_t::floor);
|
||||
double cz = sec.GetPortalPlaneZ(sector_t::ceiling);
|
||||
double fz = sec.GetPortalPlaneZ(sector_t::floor);
|
||||
if (cz < fz)
|
||||
{
|
||||
// This is a fatal condition. We have to remove one of the two portals. Choose the one that doesn't match the current plane
|
||||
Printf("Error in sector %d: Ceiling portal at z=%f is below floor portal at z=%f\n", i, cz, fz);
|
||||
double cp = -sectors[i].ceilingplane.fD();
|
||||
double fp = sectors[i].floorplane.fD();
|
||||
Printf("Error in sector %d: Ceiling portal at z=%f is below floor portal at z=%f\n", sec.sectornum, cz, fz);
|
||||
double cp = -sec.ceilingplane.fD();
|
||||
double fp = sec.floorplane.fD();
|
||||
if (cp < fp || fz == fp)
|
||||
{
|
||||
sectors[i].ClearPortal(sector_t::ceiling);
|
||||
sec.ClearPortal(sector_t::ceiling);
|
||||
}
|
||||
else
|
||||
{
|
||||
sectors[i].ClearPortal(sector_t::floor);
|
||||
sec.ClearPortal(sector_t::floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
// mark all sector planes that check out ok for everything.
|
||||
if (sectors[i].PortalIsLinked(sector_t::floor)) sectors[i].planes[sector_t::floor].Flags |= PLANEF_LINKED;
|
||||
if (sectors[i].PortalIsLinked(sector_t::ceiling)) sectors[i].planes[sector_t::ceiling].Flags |= PLANEF_LINKED;
|
||||
if (sec.PortalIsLinked(sector_t::floor)) sec.planes[sector_t::floor].Flags |= PLANEF_LINKED;
|
||||
if (sec.PortalIsLinked(sector_t::ceiling)) sec.planes[sector_t::ceiling].Flags |= PLANEF_LINKED;
|
||||
}
|
||||
if (linkedPortals.Size() > 0)
|
||||
{
|
||||
|
|
|
@ -50,9 +50,6 @@ extern vertexdata_t* vertexdatas;
|
|||
extern int numsegs;
|
||||
extern seg_t* segs;
|
||||
|
||||
extern int numsectors;
|
||||
extern sector_t* sectors;
|
||||
|
||||
extern int numsubsectors;
|
||||
extern subsector_t* subsectors;
|
||||
|
||||
|
|
|
@ -744,6 +744,12 @@ void InitThingdef()
|
|||
pstruct = NewNativeStruct("Sector", nullptr);
|
||||
pstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(NewNativeStruct("line", nullptr), false)), false), myoffsetof(sector_t, Lines), VARF_Native);
|
||||
|
||||
// Add the sector array to LevelLocals.
|
||||
pstruct->Size = sizeof(sector_t);
|
||||
pstruct->Align = alignof(sector_t);
|
||||
parray = NewArray(pstruct, MAXPLAYERS);
|
||||
lstruct->AddNativeField("sectors", NewPointer(NewResizableArray(pstruct), false), myoffsetof(FLevelLocals, sectors), VARF_Native);
|
||||
|
||||
parray = NewArray(TypeBool, MAXPLAYERS);
|
||||
playerf = new PField("playeringame", parray, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&playeringame);
|
||||
GlobalSymbols.AddSymbol(playerf);
|
||||
|
|
|
@ -1463,12 +1463,12 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, side_t *&va
|
|||
|
||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, sector_t *&value, sector_t **defval)
|
||||
{
|
||||
return SerializePointer(arc, key, value, defval, sectors);
|
||||
return SerializePointer(arc, key, value, defval, &level.sectors[0]);
|
||||
}
|
||||
|
||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, const sector_t *&value, const sector_t **defval)
|
||||
{
|
||||
return SerializePointer<const sector_t>(arc, key, value, defval, sectors);
|
||||
return SerializePointer<const sector_t>(arc, key, value, defval, &level.sectors[0]);
|
||||
}
|
||||
|
||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, player_t *&value, player_t **defval)
|
||||
|
|
|
@ -563,10 +563,13 @@ public:
|
|||
void Clear()
|
||||
{
|
||||
if (this->Array) delete[] this->Array;
|
||||
this->Count = 0;
|
||||
this->Array = NULL;
|
||||
}
|
||||
void Alloc(unsigned int amount)
|
||||
{
|
||||
Clear();
|
||||
// intentionally first deletes and then reallocates.
|
||||
if (this->Array) delete[] this->Array;
|
||||
this->Array = new T[amount];
|
||||
this->Count = amount;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue