- renamed wallnum and sectnum functions.

These were creating a lot of search noise because local variables had the same name.
This commit is contained in:
Christoph Oelckers 2022-11-15 12:03:44 +01:00
parent a2683559ce
commit b7a7584059
36 changed files with 73 additions and 73 deletions

View file

@ -571,7 +571,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
{ {
auto sectp = &sector[*sectnum]; auto sectp = &sector[*sectnum];
updatesector(DVector2(pos->X * inttoworld, pos->Y * inttoworld), &sectp); updatesector(DVector2(pos->X * inttoworld, pos->Y * inttoworld), &sectp);
*sectnum = sectp ? ::sectnum(sectp) : -1; *sectnum = sectp ? ::sectindex(sectp) : -1;
} }
return clipReturn; return clipReturn;
} }
@ -591,7 +591,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
DVector2 v(vec.X* inttoworld, vec.Y* inttoworld); DVector2 v(vec.X* inttoworld, vec.Y* inttoworld);
sectortype* sect = &sector[*sectnum]; sectortype* sect = &sector[*sectnum];
updatesector(v, &sect, rad * inttoworld); updatesector(v, &sect, rad * inttoworld);
*sectnum = ::sectnum(sect); *sectnum = ::sectindex(sect);
} }
pos->X = vec.X; pos->X = vec.X;

View file

@ -271,7 +271,7 @@ void MarkSectorSeen(sectortype* sec)
{ {
if (sec) if (sec)
{ {
show2dsector.Set(sectnum(sec)); show2dsector.Set(sectindex(sec));
for (auto& wal : wallsofsector(sec)) for (auto& wal : wallsofsector(sec))
{ {
if (!wal.twoSided()) continue; if (!wal.twoSided()) continue;
@ -281,7 +281,7 @@ void MarkSectorSeen(sectortype* sec)
auto osec = wal.nextSector(); auto osec = wal.nextSector();
if (osec->lotag == 32767) continue; if (osec->lotag == 32767) continue;
if (osec->ceilingz >= osec->floorz) continue; if (osec->ceilingz >= osec->floorz) continue;
show2dsector.Set(sectnum(osec)); show2dsector.Set(sectindex(osec));
} }
} }
} }
@ -404,7 +404,7 @@ static void drawredlines(const DVector2& cpos, const DVector2& cangvect, const D
if (osec->ceilingz == z1 && osec->floorz == z2) if (osec->ceilingz == z1 && osec->floorz == z2)
if (((wal.cstat | wal.nextWall()->cstat) & (CSTAT_WALL_MASKED | CSTAT_WALL_1WAY)) == 0) continue; if (((wal.cstat | wal.nextWall()->cstat) & (CSTAT_WALL_MASKED | CSTAT_WALL_1WAY)) == 0) continue;
if (ShowRedLine(wallnum(&wal), i)) if (ShowRedLine(wallindex(&wal), i))
{ {
auto v1 = OutAutomapVector(wal.pos - cpos, cangvect, gZoom, xydim); auto v1 = OutAutomapVector(wal.pos - cpos, cangvect, gZoom, xydim);
auto v2 = OutAutomapVector(wal.point2Wall()->pos - cpos, cangvect, gZoom, xydim); auto v2 = OutAutomapVector(wal.point2Wall()->pos - cpos, cangvect, gZoom, xydim);
@ -431,7 +431,7 @@ static void drawwhitelines(const DVector2& cpos, const DVector2& cangvect, const
if (wal.nextwall >= 0) continue; if (wal.nextwall >= 0) continue;
if (!gFullMap && !tileGetTexture(wal.picnum)->isValid()) continue; if (!gFullMap && !tileGetTexture(wal.picnum)->isValid()) continue;
if (isSWALL() && !gFullMap && !show2dwall[wallnum(&wal)]) if (isSWALL() && !gFullMap && !show2dwall[wallindex(&wal)])
continue; continue;
auto v1 = OutAutomapVector(wal.pos - cpos, cangvect, gZoom, xydim); auto v1 = OutAutomapVector(wal.pos - cpos, cangvect, gZoom, xydim);

View file

@ -474,12 +474,12 @@ inline TArrayView<walltype> wallsofsector(int sec)
} }
// these are mainly meant as refactoring aids to mark function calls to work on. // these are mainly meant as refactoring aids to mark function calls to work on.
inline int wallnum(const walltype* wal) inline int wallindex(const walltype* wal)
{ {
return wall.IndexOf(wal); return wall.IndexOf(wal);
} }
inline int sectnum(const sectortype* sect) inline int sectindex(const sectortype* sect)
{ {
return sector.IndexOf(sect); return sector.IndexOf(sect);
} }

View file

@ -41,25 +41,25 @@ void setsectinterpolate(sectortype* sectnum);
inline void StartInterpolation(walltype* wall, int type) inline void StartInterpolation(walltype* wall, int type)
{ {
assert(type == Interp_Wall_X || type == Interp_Wall_Y || type == Interp_Wall_PanX || type == Interp_Wall_PanY); assert(type == Interp_Wall_X || type == Interp_Wall_Y || type == Interp_Wall_PanX || type == Interp_Wall_PanY);
return StartInterpolation(wallnum(wall), type); return StartInterpolation(wallindex(wall), type);
} }
inline void StartInterpolation(sectortype* sect, int type) inline void StartInterpolation(sectortype* sect, int type)
{ {
assert(type == Interp_Sect_Floorz || type == Interp_Sect_Ceilingz || type == Interp_Sect_Floorheinum || type == Interp_Sect_Ceilingheinum || assert(type == Interp_Sect_Floorz || type == Interp_Sect_Ceilingz || type == Interp_Sect_Floorheinum || type == Interp_Sect_Ceilingheinum ||
type == Interp_Sect_FloorPanX || type == Interp_Sect_FloorPanY || type == Interp_Sect_CeilingPanX || type == Interp_Sect_CeilingPanY); type == Interp_Sect_FloorPanX || type == Interp_Sect_FloorPanY || type == Interp_Sect_CeilingPanX || type == Interp_Sect_CeilingPanY);
return StartInterpolation(sectnum(sect), type); return StartInterpolation(sectindex(sect), type);
} }
inline void StopInterpolation(walltype* wall, int type) inline void StopInterpolation(walltype* wall, int type)
{ {
assert(type == Interp_Wall_X || type == Interp_Wall_Y || type == Interp_Wall_PanX || type == Interp_Wall_PanY); assert(type == Interp_Wall_X || type == Interp_Wall_Y || type == Interp_Wall_PanX || type == Interp_Wall_PanY);
return StopInterpolation(wallnum(wall), type); return StopInterpolation(wallindex(wall), type);
} }
inline void StopInterpolation(sectortype* sect, int type) inline void StopInterpolation(sectortype* sect, int type)
{ {
assert(type == Interp_Sect_Floorz || type == Interp_Sect_Ceilingz || type == Interp_Sect_Floorheinum || type == Interp_Sect_Ceilingheinum || assert(type == Interp_Sect_Floorz || type == Interp_Sect_Ceilingz || type == Interp_Sect_Floorheinum || type == Interp_Sect_Ceilingheinum ||
type == Interp_Sect_FloorPanX || type == Interp_Sect_FloorPanY || type == Interp_Sect_CeilingPanX || type == Interp_Sect_CeilingPanY); type == Interp_Sect_FloorPanX || type == Interp_Sect_FloorPanY || type == Interp_Sect_CeilingPanX || type == Interp_Sect_CeilingPanY);
return StopInterpolation(sectnum(sect), type); return StopInterpolation(sectindex(sect), type);
} }

View file

@ -281,7 +281,7 @@ void validateSprite(spritetype& spri, int sectnum, int index)
updatesector(pos.XY(), &sectp); updatesector(pos.XY(), &sectp);
bugged = sectp == nullptr; bugged = sectp == nullptr;
if (!DPrintf(DMSG_WARNING, "Sprite #%d (%.0f,%.0f) with invalid sector %d was corrected to sector %d\n", index, pos.X, pos.Y, sectnum, ::sectnum(sectp))) if (!DPrintf(DMSG_WARNING, "Sprite #%d (%.0f,%.0f) with invalid sector %d was corrected to sector %d\n", index, pos.X, pos.Y, sectnum, ::sectindex(sectp)))
{ {
if (bugged) Printf("Sprite #%d (%.0f,%.0f) with invalid sector %d\n", index, pos.X, pos.Y, sectnum); if (bugged) Printf("Sprite #%d (%.0f,%.0f) with invalid sector %d\n", index, pos.X, pos.Y, sectnum);
} }
@ -445,12 +445,12 @@ void validateStartSector(const char* filename, const DVector3& pos, sectortype**
if (!sect) updatesector(pos, &sect); if (!sect) updatesector(pos, &sect);
if (sect || noabort) if (sect || noabort)
{ {
Printf(PRINT_HIGH, "Error in map %s: Start sector %d out of range. Max. sector is %d\n", filename, sectnum(*cursect), numsectors); Printf(PRINT_HIGH, "Error in map %s: Start sector %d out of range. Max. sector is %d\n", filename, sectindex(*cursect), numsectors);
*cursect = sect? sect : &sector[0]; *cursect = sect? sect : &sector[0];
} }
else else
{ {
I_Error("Unable to start map %s: Start sector %d out of range. Max. sector is %d. No valid location at start spot\n", filename, sectnum(*cursect), numsectors); I_Error("Unable to start map %s: Start sector %d out of range. Max. sector is %d. No valid location at start spot\n", filename, sectindex(*cursect), numsectors);
} }
} }

View file

@ -319,7 +319,7 @@ void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sector
ResetProfilingData(); ResetProfilingData();
// Get this before everything else // Get this before everything else
FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectnum(sect), angle, horizon, rollang, fov); FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectindex(sect), angle, horizon, rollang, fov);
r_viewpoint.TicFrac = !cl_capfps ? interpfrac : 1.; r_viewpoint.TicFrac = !cl_capfps ? interpfrac : 1.;
screen->mLights->Clear(); screen->mLights->Clear();
@ -369,7 +369,7 @@ void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortyp
// now render the main view // now render the main view
float ratio = camtex->GetDisplayWidth() / camtex->GetDisplayHeight(); float ratio = camtex->GetDisplayWidth() / camtex->GetDisplayHeight();
FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectnum(sect), angle, horizon, rollang); FRenderViewpoint r_viewpoint = SetupViewpoint(playersprite, position, sectindex(sect), angle, horizon, rollang);
r_viewpoint.TicFrac = !cl_capfps ? interpfrac : 1.; r_viewpoint.TicFrac = !cl_capfps ? interpfrac : 1.;
RenderViewpoint(r_viewpoint, &rect, r_viewpoint.FieldOfView.Degrees(), ratio, ratio, false, false); RenderViewpoint(r_viewpoint, &rect, r_viewpoint.FieldOfView.Degrees(), ratio, ratio, false, false);

View file

@ -67,7 +67,7 @@ void CreateVertexMap()
vertexscan(&wall[i], [&](walltype* wal) vertexscan(&wall[i], [&](walltype* wal)
{ {
int w = wallnum(wal); int w = wallindex(wal);
if (processed[w]) return; // broken wall setups can trigger this. if (processed[w]) return; // broken wall setups can trigger this.
walls.Push(w); walls.Push(w);
processed.Set(w); processed.Set(w);

View file

@ -421,7 +421,7 @@ void HWDrawInfo::CreateScene(bool portal)
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1); if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1);
else mDrawer.Init(this, mClipper, vp.Pos, 0, 0); else mDrawer.Init(this, mClipper, vp.Pos, 0, 0);
int drawsect = sectnum(drawsectp); int drawsect = sectindex(drawsectp);
mDrawer.RenderScene(&drawsect, 1, false); mDrawer.RenderScene(&drawsect, 1, false);
for (int i = 0; i < eff.geocnt; i++) for (int i = 0; i < eff.geocnt; i++)
@ -452,7 +452,7 @@ void HWDrawInfo::CreateScene(bool portal)
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1); if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1);
else mDrawer.Init(this, mClipper, vp.Pos, 0, 0); else mDrawer.Init(this, mClipper, vp.Pos, 0, 0);
drawsect = sectnum(drawsectp); drawsect = sectindex(drawsectp);
mDrawer.RenderScene(&drawsect, 1, false); mDrawer.RenderScene(&drawsect, 1, false);
for (int i = 0; i < eff.geocnt; i++) for (int i = 0; i < eff.geocnt; i++)

View file

@ -223,7 +223,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
} }
#ifdef _DEBUG #ifdef _DEBUG
if (sectnum(sec) == gl_breaksec) if (sectindex(sec) == gl_breaksec)
{ {
int a = 0; int a = 0;
} }
@ -303,7 +303,7 @@ void HWFlat::PutFlat(HWDrawInfo *di, int whichplane)
void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section_, int which) void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section_, int which)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (sectnum(sec) == gl_breaksec) if (sectindex(sec) == gl_breaksec)
{ {
int a = 0; int a = 0;
} }

View file

@ -923,7 +923,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
#ifdef _DEBUG #ifdef _DEBUG
if (wallnum(wal) == 34) if (wallindex(wal) == 34)
{ {
int a = 0; int a = 0;
} }
@ -955,7 +955,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
if (gl_seamless) if (gl_seamless)
{ {
auto v = &vertices[vertexMap[wallnum(wal)]]; auto v = &vertices[vertexMap[wallindex(wal)]];
if (v->dirty) v->RecalcVertexHeights(); if (v->dirty) v->RecalcVertexHeights();
v = &vertices[vertexMap[wal->point2]]; v = &vertices[vertexMap[wal->point2]];
if (v->dirty) v->RecalcVertexHeights(); if (v->dirty) v->RecalcVertexHeights();

View file

@ -41,7 +41,7 @@ EXTERN_CVAR(Bool, gl_seamless)
void HWWall::SplitLeftEdge(FFlatVertex *&ptr) void HWWall::SplitLeftEdge(FFlatVertex *&ptr)
{ {
if (seg == nullptr) return; if (seg == nullptr) return;
vertex_t* vi = &vertices[vertexMap[wallnum(seg)]]; vertex_t* vi = &vertices[vertexMap[wallindex(seg)]];
if (vi->numheights) if (vi->numheights)
{ {
@ -129,7 +129,7 @@ int HWWall::CreateVertices(FFlatVertex *&ptr, bool split)
void HWWall::CountLeftEdge(unsigned &ptr) void HWWall::CountLeftEdge(unsigned &ptr)
{ {
vertex_t* vi = &vertices[vertexMap[wallnum(seg)]]; vertex_t* vi = &vertices[vertexMap[wallindex(seg)]];
if (vi->numheights) if (vi->numheights)
{ {

View file

@ -21,7 +21,7 @@ void M_Autosave();
template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def) template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def)
{ {
assert(arc.isReading() || w == nullptr || (w >= &sector[0] && w <= &sector.Last())); assert(arc.isReading() || w == nullptr || (w >= &sector[0] && w <= &sector.Last()));
int ndx = w ? sectnum(w) : -1; int ndx = w ? sectindex(w) : -1;
arc(keyname, ndx); arc(keyname, ndx);
w = !validSectorIndex(ndx) ? nullptr : &sector[ndx]; w = !validSectorIndex(ndx) ? nullptr : &sector[ndx];
return arc; return arc;
@ -29,7 +29,7 @@ template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname,
template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def) template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def)
{ {
int ndx = w ? wallnum(w) : -1; int ndx = w ? wallindex(w) : -1;
arc(keyname, ndx); arc(keyname, ndx);
w = !validWallIndex(ndx) ? nullptr : &wall[ndx]; w = !validWallIndex(ndx) ? nullptr : &wall[ndx];
return arc; return arc;

View file

@ -475,7 +475,7 @@ void SectionGeometry::CreatePlaneMesh(Section* section, int plane, const FVector
void SectionGeometry::MarkDirty(sectortype* sector) void SectionGeometry::MarkDirty(sectortype* sector)
{ {
for (auto section : sectionsPerSector[sectnum(sector)]) for (auto section : sectionsPerSector[sectindex(sector)])
{ {
sections[section].dirty = sector->dirty; sections[section].dirty = sector->dirty;
} }

View file

@ -44,8 +44,8 @@ public:
EventObject() = default; EventObject() = default;
explicit EventObject(std::nullptr_t) { index = -1; } explicit EventObject(std::nullptr_t) { index = -1; }
explicit EventObject(DBloodActor* actor_) { ActorP = actor_; assert(isActor()); } explicit EventObject(DBloodActor* actor_) { ActorP = actor_; assert(isActor()); }
explicit EventObject(sectortype* sect) { index = (sectnum(sect) << 8) | Sector; } explicit EventObject(sectortype* sect) { index = (sectindex(sect) << 8) | Sector; }
explicit EventObject(walltype* wall) { index = (wallnum(wall) << 8) | Wall; } explicit EventObject(walltype* wall) { index = (wallindex(wall) << 8) | Wall; }
bool isActor() const { return (index & 7) == Actor; } bool isActor() const { return (index & 7) == Actor; }
bool isSector() const { return (index & 7) == Sector; } bool isSector() const { return (index & 7) == Sector; }

View file

@ -547,7 +547,7 @@ BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int n
BitArray sectorMap(sector.Size()); // this gets returned to the caller. BitArray sectorMap(sector.Size()); // this gets returned to the caller.
sectorMap.Zero(); sectorMap.Zero();
sectorMap.Set(sectnum(pSector)); sectorMap.Set(sectindex(pSector));
double nDist4sq = nDist * nDist; // (nDist * 16)^2 - * 16 to account for Build's 28.4 fixed point format. double nDist4sq = nDist * nDist; // (nDist * 16)^2 - * 16 to account for Build's 28.4 fixed point format.
BFSSectorSearch search(pSector); BFSSectorSearch search(pSector);
@ -573,7 +573,7 @@ BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int n
} }
if (withinRange) // if new sector is within range, add it to the processing queue if (withinRange) // if new sector is within range, add it to the processing queue
{ {
sectorMap.Set(sectnum(pNextSector)); sectorMap.Set(sectindex(pNextSector));
search.Add(pNextSector); search.Add(pNextSector);
if (pWalls && wal.hasX()) if (pWalls && wal.hasX())
{ {

View file

@ -124,7 +124,7 @@ void InitMirrors(void)
continue; continue;
auto sectj = link2->sector(); auto sectj = link2->sector();
int j = sectnum(sectj); int j = sectindex(sectj);
if (sectj->ceilingpicnum != 504) if (sectj->ceilingpicnum != 504)
I_Error("Lower link sector %d doesn't have mirror picnum\n", j); I_Error("Lower link sector %d doesn't have mirror picnum\n", j);
mirror[mirrorcnt].type = 2; mirror[mirrorcnt].type = 2;

View file

@ -129,7 +129,7 @@ void SPRINSECT::Init(double nDist)
pEntry.pActors.Resize(collected.Size()); pEntry.pActors.Resize(collected.Size());
for (unsigned ii = 0; ii < collected.Size(); ii++) for (unsigned ii = 0; ii < collected.Size(); ii++)
pEntry.pActors[ii] = collected[ii]; pEntry.pActors[ii] = collected[ii];
pEntry.nSector = sectnum(&sect); pEntry.nSector = sectindex(&sect);
} }
} }
} }

View file

@ -183,7 +183,7 @@ void sfxPlay3DSound(const DVector3& pos, int soundId, sectortype* pSector)
if (sfx && sfx->LoopStart >= 0) flags |= CHANF_LOOP; if (sfx && sfx->LoopStart >= 0) flags |= CHANF_LOOP;
auto chan = soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, flags, sid, (0.8f / 80.f) * relvol, attenuation, nullptr, pitch / 65536.f); auto chan = soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, flags, sid, (0.8f / 80.f) * relvol, attenuation, nullptr, pitch / 65536.f);
if (chan) chan->UserData = sectnum(pSector); if (chan) chan->UserData = sectindex(pSector);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -949,7 +949,7 @@ void TranslateSector(sectortype* pSector, double wave1, double wave2, const DVec
if (gModernMap) if (gModernMap)
{ {
auto ptr = gSprNSect.GetSprPtr(sectnum(pSector)); auto ptr = gSprNSect.GetSprPtr(sectindex(pSector));
if (ptr) if (ptr)
{ {
for (auto& ac : *ptr) for (auto& ac : *ptr)
@ -997,7 +997,7 @@ void ZTranslateSector(sectortype* pSector, XSECTOR* pXSector, int a3, int a4)
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// get pointer to sprites near outside walls before translation // get pointer to sprites near outside walls before translation
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
auto ptr1 = (gModernMap && (dfz || dcz))? gSprNSect.GetSprPtr(sectnum(pSector)) : nullptr; auto ptr1 = (gModernMap && (dfz || dcz))? gSprNSect.GetSprPtr(sectindex(pSector)) : nullptr;
#endif #endif
if (dfz != 0) if (dfz != 0)
@ -2247,7 +2247,7 @@ static void UpdateBasePoints(sectortype* pSector)
if (gModernMap) if (gModernMap)
{ {
// must set basepoint for outside sprites as well // must set basepoint for outside sprites as well
auto ptr1 = gSprNSect.GetSprPtr(sectnum(pSector)); auto ptr1 = gSprNSect.GetSprPtr(sectindex(pSector));
if (ptr1) if (ptr1)
{ {
for (auto& ac : *ptr1) for (auto& ac : *ptr1)

View file

@ -102,7 +102,7 @@ sectortype* toSect(int index)
int fromSect(sectortype* sect) int fromSect(sectortype* sect)
{ {
return sect ? sectnum(sect) : -1; return sect ? sectindex(sect) : -1;
} }
walltype* toWall(int index) walltype* toWall(int index)
@ -112,7 +112,7 @@ walltype* toWall(int index)
int fromWall(walltype* sect) int fromWall(walltype* sect)
{ {
return sect ? wallnum(sect) : -1; return sect ? wallindex(sect) : -1;
} }
static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, int sPlayer, int lParm2) static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, int sPlayer, int lParm2)

View file

@ -56,7 +56,7 @@ void resetmys()
myang = ps[myconnectindex].angle.ang; myang = ps[myconnectindex].angle.ang;
myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz; myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz;
myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff; myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff;
mycursectnum = sectnum(ps[myconnectindex].cursector); mycursectnum = sectindex(ps[myconnectindex].cursector);
myjumpingcounter = ps[myconnectindex].jumping_counter; myjumpingcounter = ps[myconnectindex].jumping_counter;
myjumpingtoggle = ps[myconnectindex].jumping_toggle; myjumpingtoggle = ps[myconnectindex].jumping_toggle;
myonground = ps[myconnectindex].on_ground; myonground = ps[myconnectindex].on_ground;

View file

@ -868,8 +868,8 @@ static void SpawnPortals()
s1->portalflags = PORTAL_SECTOR_FLOOR; s1->portalflags = PORTAL_SECTOR_FLOOR;
s2->portalflags = PORTAL_SECTOR_CEILING; s2->portalflags = PORTAL_SECTOR_CEILING;
DVector2 diff = act->spr.pos.XY() - act2->spr.pos.XY(); DVector2 diff = act->spr.pos.XY() - act2->spr.pos.XY();
s1->portalnum = portalAdd(PORTAL_SECTOR_FLOOR, sectnum(s2), DVector3(-diff, hitag)); // uses delta.Z as temporary storage, not a real coordinate. s1->portalnum = portalAdd(PORTAL_SECTOR_FLOOR, sectindex(s2), DVector3(-diff, hitag)); // uses delta.Z as temporary storage, not a real coordinate.
s2->portalnum = portalAdd(PORTAL_SECTOR_CEILING, sectnum(s1), DVector3(diff, hitag)); s2->portalnum = portalAdd(PORTAL_SECTOR_CEILING, sectindex(s1), DVector3(diff, hitag));
processedTags.Push(act->spr.hitag); processedTags.Push(act->spr.hitag);
} }
else else

View file

@ -475,7 +475,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
if (dist == 0) if (dist == 0)
{ {
// Oh no, we got an incomplete definition. // Oh no, we got an incomplete definition.
if (sectnum(sectp) == 534 && currentLevel->levelNumber == 2007) // fix for bug in RR E2L7 Beaudry Mansion. if (sectindex(sectp) == 534 && currentLevel->levelNumber == 2007) // fix for bug in RR E2L7 Beaudry Mansion.
{ {
dist = 48; dist = 48;
speed = 32; speed = 32;

View file

@ -413,7 +413,7 @@ int getanimationindex(int animtype, sectortype* animtargetp)
int i, j; int i, j;
j = -1; j = -1;
int animtarget = sectnum(animtargetp); int animtarget = sectindex(animtargetp);
for (i = animates.Size() - 1; i >= 0; i--) for (i = animates.Size() - 1; i >= 0; i--)
if (animtype == animates[i].type && animtarget == animates[i].target) if (animtype == animates[i].type && animtarget == animates[i].target)
{ {
@ -459,13 +459,13 @@ static int dosetanimation(sectortype* animsect, int animtype, int animtarget, do
int setanimation(sectortype* animsect, int animtype, walltype* animtarget, double thegoal, double thevel) int setanimation(sectortype* animsect, int animtype, walltype* animtarget, double thegoal, double thevel)
{ {
assert(animtype == anim_vertexx || animtype == anim_vertexy); assert(animtype == anim_vertexx || animtype == anim_vertexy);
return dosetanimation(animsect, animtype, wallnum(animtarget), thegoal, thevel); return dosetanimation(animsect, animtype, wallindex(animtarget), thegoal, thevel);
} }
int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, double thegoal, double thevel) int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, double thegoal, double thevel)
{ {
assert(animtype == anim_ceilingz || animtype == anim_floorz); assert(animtype == anim_ceilingz || animtype == anim_floorz);
return dosetanimation(animsect, animtype, sectnum(animtarget), thegoal, thevel); return dosetanimation(animsect, animtype, sectindex(animtarget), thegoal, thevel);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -712,7 +712,7 @@ static void handle_st29(sectortype* sptr, DDukeActor* actor)
{ {
act2->sector()->extra = -act2->sector()->extra; act2->sector()->extra = -act2->sector()->extra;
act2->temp_data[0] = sectnum(sptr); act2->temp_data[0] = sectindex(sptr);
act2->temp_data[1] = 1; act2->temp_data[1] = 1;
} }
} }

View file

@ -1477,7 +1477,7 @@ void checksectors_d(int snum)
p->cursector->lotag = 0; p->cursector->lotag = 0;
FTA(9, p); FTA(9, p);
p->secret_rooms++; p->secret_rooms++;
SECRET_Trigger(sectnum(p->cursector)); SECRET_Trigger(sectindex(p->cursector));
return; return;
case -1: case -1:
p->cursector->lotag = 0; p->cursector->lotag = 0;

View file

@ -2385,7 +2385,7 @@ void checksectors_r(int snum)
p->cursector->lotag = 0; p->cursector->lotag = 0;
FTA(9, p); FTA(9, p);
p->secret_rooms++; p->secret_rooms++;
SECRET_Trigger(sectnum(p->cursector)); SECRET_Trigger(sectindex(p->cursector));
return; return;
case -1: case -1:
p->cursector->lotag = 0; p->cursector->lotag = 0;

View file

@ -53,7 +53,7 @@ BEGIN_DUKE_NS
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, PClassActor* clstype, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat) DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, PClassActor* clstype, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
{ {
// sector pointer must be strictly validated here or the engine will crash. // sector pointer must be strictly validated here or the engine will crash.
if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr; if (whatsectp == nullptr || !validSectorIndex(sectindex(whatsectp))) return nullptr;
// spawning out of range sprites will also crash. // spawning out of range sprites will also crash.
if (clstype == nullptr && (s_pn < 0 || s_pn >= MAXTILES)) return nullptr; if (clstype == nullptr && (s_pn < 0 || s_pn >= MAXTILES)) return nullptr;
@ -917,7 +917,7 @@ void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors)
} }
actor->SetOwner(nullptr); actor->SetOwner(nullptr);
actor->temp_data[0] = sectnum(s); actor->temp_data[0] = sectindex(s);
if (actor->spr.lotag != SE_30_TWO_WAY_TRAIN) if (actor->spr.lotag != SE_30_TWO_WAY_TRAIN)
actor->temp_data[3] = actor->spr.hitag; actor->temp_data[3] = actor->spr.hitag;

View file

@ -324,7 +324,7 @@ Collision CheckCloseRange(int nPlayer, DVector3& pos, sectortype* *ppSector)
c.setSprite(hit.actor()); c.setSprite(hit.actor());
} }
if (hit.hitWall) { if (hit.hitWall) {
c.setWall(wallnum(hit.hitWall)); c.setWall(wallindex(hit.hitWall));
} }
return c; return c;

View file

@ -1612,7 +1612,7 @@ short AnimGetGoal(int animtype, int animindex, DSWActor*);
int AnimSet(int animtype, int animindex, DSWActor* animactor, double thegoal, double thevel); int AnimSet(int animtype, int animindex, DSWActor* animactor, double thegoal, double thevel);
int AnimSet(int animtype, sectortype* animindex, double thegoal, double thevel) int AnimSet(int animtype, sectortype* animindex, double thegoal, double thevel)
{ {
return AnimSet(animtype, sectnum(animindex), nullptr, thegoal, thevel); return AnimSet(animtype, sectindex(animindex), nullptr, thegoal, thevel);
} }
short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECT* data); short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECT* data);

View file

@ -281,14 +281,14 @@ void so_addinterpolation(SECTOR_OBJECT* sop)
{ {
for (auto& wal : wallsofsector(*sectp)) for (auto& wal : wallsofsector(*sectp))
{ {
so_setpointinterpolation(interp, wallnum(&wal) | soi_wallx); so_setpointinterpolation(interp, wallindex(&wal) | soi_wallx);
so_setpointinterpolation(interp, wallnum(&wal) | soi_wally); so_setpointinterpolation(interp, wallindex(&wal) | soi_wally);
if (wal.twoSided()) if (wal.twoSided())
{ {
auto nextWall = wal.nextWall()->point2Wall(); auto nextWall = wal.nextWall()->point2Wall();
so_setpointinterpolation(interp, wallnum(nextWall) | soi_wallx); so_setpointinterpolation(interp, wallindex(nextWall) | soi_wallx);
so_setpointinterpolation(interp, wallnum(nextWall) | soi_wally); so_setpointinterpolation(interp, wallindex(nextWall) | soi_wally);
} }
} }
@ -305,8 +305,8 @@ void so_addinterpolation(SECTOR_OBJECT* sop)
if (!interp->hasvator) if (!interp->hasvator)
for (sectp = sop->sectp; *sectp; sectp++) for (sectp = sop->sectp; *sectp; sectp++)
{ {
so_setpointinterpolation(interp, sectnum(*sectp) | soi_floor); so_setpointinterpolation(interp, sectindex(*sectp) | soi_floor);
so_setpointinterpolation(interp, sectnum(*sectp) | soi_ceil); so_setpointinterpolation(interp, sectindex(*sectp) | soi_ceil);
} }
// interpolate midpoint, for aiming at a remote controlled SO // interpolate midpoint, for aiming at a remote controlled SO

View file

@ -359,7 +359,7 @@ void JS_InitMirrors(void)
if (!Found_Cam) if (!Found_Cam)
{ {
Printf("Did not find drawtotile for camera number %d\n", mirrorcnt); Printf("Did not find drawtotile for camera number %d\n", mirrorcnt);
Printf("wall(%d).hitag == %d\n", wallnum(&wal), wal.hitag); Printf("wall(%d).hitag == %d\n", wallindex(&wal), wal.hitag);
Printf("Map Coordinates: x = %d, y = %d\n", int(wal.pos.X), int(wal.pos.Y)); Printf("Map Coordinates: x = %d, y = %d\n", int(wal.pos.X), int(wal.pos.Y));
RESET_BOOL1(mirror[mirrorcnt].cameraActor); RESET_BOOL1(mirror[mirrorcnt].cameraActor);
} }

View file

@ -93,8 +93,8 @@ static int osdcmd_mirror(CCmdFuncPtr parm)
Printf("camspic is the tile number of the drawtotile in editart"); Printf("camspic is the tile number of the drawtotile in editart");
Printf("iscamera is whether or not this mirror is a camera type"); Printf("iscamera is whether or not this mirror is a camera type");
Printf(" "); Printf(" ");
Printf("mirror[%d].mirrorwall = %d", op1, wallnum(mirror[op1].mirrorWall)); Printf("mirror[%d].mirrorwall = %d", op1, wallindex(mirror[op1].mirrorWall));
Printf("mirror[%d].mirrorsector = %d", op1, sectnum(mirror[op1].mirrorSector)); Printf("mirror[%d].mirrorsector = %d", op1, sectindex(mirror[op1].mirrorSector));
Printf("mirror[%d].camera = %d", op1, mirror[op1].cameraActor->GetIndex()); Printf("mirror[%d].camera = %d", op1, mirror[op1].cameraActor->GetIndex());
Printf("mirror[%d].camsprite = %d", op1, mirror[op1].camspriteActor->GetIndex()); Printf("mirror[%d].camsprite = %d", op1, mirror[op1].camspriteActor->GetIndex());
Printf("mirror[%d].campic = %d", op1, mirror[op1].campic); Printf("mirror[%d].campic = %d", op1, mirror[op1].campic);

View file

@ -2746,7 +2746,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
if ((hit.hitpos.XY() - hitpos.XY()).LengthSquared() < 50 * 50) if ((hit.hitpos.XY() - hitpos.XY()).LengthSquared() < 50 * 50)
{ {
if (hit.hitWall) if (hit.hitWall)
actor->user.coll.setWall(wallnum(hit.hitWall)); actor->user.coll.setWall(wallindex(hit.hitWall));
else if (hit.actor()) else if (hit.actor())
actor->user.coll.setSprite(hit.actor()); actor->user.coll.setSprite(hit.actor());
else else

View file

@ -919,7 +919,7 @@ void CollectPortals()
{ {
if (!wal.twoSided()) continue; if (!wal.twoSided()) continue;
auto nsec = wal.nextSector(); auto nsec = wal.nextSector();
auto ns = sectnum(nsec); auto ns = sectindex(nsec);
if (floordone[ns] || nsec->floorpicnum != FAF_MIRROR_PIC) continue; if (floordone[ns] || nsec->floorpicnum != FAF_MIRROR_PIC) continue;
fp.sectors.Push(ns); fp.sectors.Push(ns);
floordone.Set(ns); floordone.Set(ns);
@ -937,7 +937,7 @@ void CollectPortals()
{ {
if (!wal.twoSided()) continue; if (!wal.twoSided()) continue;
auto nsec = wal.nextSector(); auto nsec = wal.nextSector();
auto ns = sectnum(nsec); auto ns = sectindex(nsec);
if (ceilingdone[ns] || nsec->ceilingpicnum != FAF_MIRROR_PIC) continue; if (ceilingdone[ns] || nsec->ceilingpicnum != FAF_MIRROR_PIC) continue;
fp.sectors.Push(ns); fp.sectors.Push(ns);
ceilingdone.Set(ns); ceilingdone.Set(ns);
@ -964,7 +964,7 @@ void CollectPortals()
if (tsect != nullptr &&tsect->floorpicnum == FAF_MIRROR_PIC) if (tsect != nullptr &&tsect->floorpicnum == FAF_MIRROR_PIC)
{ {
// got something! // got something!
fp.othersector = sectnum(tsect); fp.othersector = sectindex(tsect);
fp.offset = tpos - actor->spr.pos; fp.offset = tpos - actor->spr.pos;
goto nextfg; goto nextfg;
} }
@ -991,7 +991,7 @@ void CollectPortals()
if (tsect != nullptr && tsect->ceilingpicnum == FAF_MIRROR_PIC) if (tsect != nullptr && tsect->ceilingpicnum == FAF_MIRROR_PIC)
{ {
// got something! // got something!
fp.othersector = sectnum(tsect); fp.othersector = sectindex(tsect);
fp.offset = tpos - actor->spr.pos; fp.offset = tpos - actor->spr.pos;
goto nextcg; goto nextcg;
} }

View file

@ -224,7 +224,7 @@ void WallSetup(void)
} }
else else
{ {
Printf(PRINT_HIGH, "one-sided wall %d in loop setup\n", wallnum(&wal)); Printf(PRINT_HIGH, "one-sided wall %d in loop setup\n", wallindex(&wal));
} }
break; break;
} }
@ -238,7 +238,7 @@ void WallSetup(void)
} }
else else
{ {
Printf(PRINT_HIGH, "one-sided wall %d in loop setup\n", wallnum(&wal)); Printf(PRINT_HIGH, "one-sided wall %d in loop setup\n", wallindex(&wal));
} }
wal.lotag = 0; wal.lotag = 0;
break; break;
@ -1939,7 +1939,7 @@ void TriggerSecret(sectortype* sectp, PLAYER* pp)
if (pp == Player + myconnectindex) if (pp == Player + myconnectindex)
PlayerSound(DIGI_ANCIENTSECRET, v3df_dontpan | v3df_doppler | v3df_follow, pp); PlayerSound(DIGI_ANCIENTSECRET, v3df_dontpan | v3df_doppler | v3df_follow, pp);
SECRET_Trigger(sectnum(pp->cursector)); SECRET_Trigger(sectindex(pp->cursector));
PutStringInfo(pp, GStrings("TXTS_SECRET")); PutStringInfo(pp, GStrings("TXTS_SECRET"));
// always give to the first player // always give to the first player

View file

@ -2051,7 +2051,7 @@ void CallbackSOsink(ANIM* ap, void *data)
for (i = 0; sop->sectp[i] != nullptr; i++) for (i = 0; sop->sectp[i] != nullptr; i++)
{ {
if (ap->animtype == ANIM_Floorz && ap->animindex == sectnum(sop->sectp[i])) if (ap->animtype == ANIM_Floorz && ap->animindex == sectindex(sop->sectp[i]))
{ {
destsect = sop->sectp[i]; destsect = sop->sectp[i];
break; break;