diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 22b6636b5..ab69effb3 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ September 6, 2009 (Changes by Graf Zahl) +- changed line_t's sidenum into sidedef pointers. - changed side_t's linenum into a linedef pointer. - Added PinkSilver's SetActorVelocity code submission (with optimizations.) diff --git a/src/d_net.cpp b/src/d_net.cpp index 8a1d10e4c..80c8de130 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2188,7 +2188,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) { DImpactDecal::StaticCreate (s, trace.X, trace.Y, trace.Z, - sides + trace.Line->sidenum[trace.Side], NULL); + trace.Line->sidedef[trace.Side], NULL); } } } diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 06f42a302..a4de80938 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -175,10 +175,9 @@ void DBaseDecal::SerializeChain (FArchive &arc, DBaseDecal **first) void DBaseDecal::GetXY (side_t *wall, fixed_t &ox, fixed_t &oy) const { line_t *line = wall->linedef; - DWORD wallnum = DWORD(wall - sides); vertex_t *v1, *v2; - if (line->sidenum[0] == wallnum) + if (line->sidedef[0] == wall) { v1 = line->v1; v2 = line->v2; @@ -235,7 +234,7 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor FTextureID tex; line = wall->linedef; - if (line->sidenum[0] == DWORD(wall - sides)) + if (line->sidedef[0] == wall) { front = line->frontsector; back = line->backsector; @@ -307,7 +306,7 @@ fixed_t DBaseDecal::GetRealZ (const side_t *wall) const const line_t *line = wall->linedef; const sector_t *front, *back; - if (line->sidenum[0] == DWORD(wall - sides)) + if (line->sidedef[0] == wall) { front = line->frontsector; back = line->backsector; @@ -359,10 +358,9 @@ fixed_t DBaseDecal::GetRealZ (const side_t *wall) const void DBaseDecal::CalcFracPos (side_t *wall, fixed_t x, fixed_t y) { line_t *line = line = wall->linedef; - DWORD wallnum = DWORD(wall - sides); vertex_t *v1, *v2; - if (line->sidenum[0] == wallnum) + if (line->sidedef[0] == wall) { v1 = line->v1; v2 = line->v2; @@ -393,7 +391,7 @@ void DBaseDecal::CalcFracPos (side_t *wall, fixed_t x, fixed_t y) static void GetWallStuff (side_t *wall, vertex_t *&v1, fixed_t &ldx, fixed_t &ldy) { line_t *line = line = wall->linedef; - if (line->sidenum[0] == DWORD(wall - sides)) + if (line->sidedef[0] == wall) { v1 = line->v1; ldx = line->dx; @@ -415,18 +413,17 @@ static fixed_t Length (fixed_t dx, fixed_t dy) static side_t *NextWall (const side_t *wall) { line_t *line = line = wall->linedef;; - DWORD wallnum = DWORD(wall - sides); - if (line->sidenum[0] == wallnum) + if (line->sidedef[0] == wall) { - if (line->sidenum[1] != NO_SIDE) + if (line->sidedef[1] != NULL) { - return sides + line->sidenum[1]; + return line->sidedef[1]; } } - else if (line->sidenum[1] == wallnum) + else if (line->sidedef[1] == wall) { - return sides + line->sidenum[0]; + return line->sidedef[0]; } return NULL; } @@ -775,7 +772,7 @@ void ADecal::BeginPlay () if (trace.HitType == TRACE_HitWall) { decal = new DBaseDecal (this); - wall = sides + trace.Line->sidenum[trace.Side]; + wall = trace.Line->sidedef[trace.Side]; decal->StickToWall (wall, trace.X, trace.Y, trace.ffloor); tpl->ApplyToDecal (decal, wall); // Spread decal to nearby walls if it does not all fit on this one diff --git a/src/g_strife/a_strifeitems.cpp b/src/g_strife/a_strifeitems.cpp index 15bb4fbd2..06674a1ae 100644 --- a/src/g_strife/a_strifeitems.cpp +++ b/src/g_strife/a_strifeitems.cpp @@ -32,8 +32,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemoveForceField) { line->flags &= ~(ML_BLOCKING|ML_BLOCKEVERYTHING); line->special = 0; - sides[line->sidenum[0]].SetTexture(side_t::mid, FNullTextureID()); - sides[line->sidenum[1]].SetTexture(side_t::mid, FNullTextureID()); + line->sidedef[0]->SetTexture(side_t::mid, FNullTextureID()); + line->sidedef[1]->SetTexture(side_t::mid, FNullTextureID()); } } } diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index 112defcda..3e50368cf 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -120,7 +120,7 @@ void FNodeBuilder::MakeSegsFromSides () for (i = 0; i < Level.NumLines; ++i) { - if (Level.Lines[i].sidenum[0] != NO_SIDE) + if (Level.Lines[i].sidedef[0] != NULL) { CreateSeg (i, 0); } @@ -129,10 +129,10 @@ void FNodeBuilder::MakeSegsFromSides () Printf ("Linedef %d does not have a front side.\n", i); } - if (Level.Lines[i].sidenum[1] != NO_SIDE) + if (Level.Lines[i].sidedef[1] != NULL) { j = CreateSeg (i, 1); - if (Level.Lines[i].sidenum[0] != NO_SIDE) + if (Level.Lines[i].sidedef[0] != NULL) { Segs[j-1].partner = j; Segs[j].partner = j-1; @@ -169,7 +169,8 @@ int FNodeBuilder::CreateSeg (int linenum, int sidenum) seg.v1 = (int)(size_t)Level.Lines[linenum].v2; } seg.linedef = linenum; - seg.sidedef = Level.Lines[linenum].sidenum[sidenum]; + side_t *sd = Level.Lines[linenum].sidedef[sidenum]; + seg.sidedef = sd != NULL? int(sd - sides) : int(NO_SIDE); seg.nextforvert = Vertices[seg.v1].segs; seg.nextforvert2 = Vertices[seg.v2].segs2; diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index e408891bf..94df21d8c 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -56,8 +56,8 @@ bool P_Scroll3dMidtex(sector_t *sector, int crush, fixed_t move, bool ceiling) { line_t *l = scrollplane.AttachedLines[i]; - sides[l->sidenum[0]].AddTextureYOffset(side_t::mid, move); - sides[l->sidenum[1]].AddTextureYOffset(side_t::mid, move); + l->sidedef[0]->AddTextureYOffset(side_t::mid, move); + l->sidedef[1]->AddTextureYOffset(side_t::mid, move); } // Second step: Check all sectors whether the move is ok. @@ -87,8 +87,8 @@ void P_Start3dMidtexInterpolations(TArray &list, sector_t *sec { line_t *l = scrollplane.AttachedLines[i]; - list.Push(sides[l->sidenum[0]].SetInterpolation(side_t::mid)); - list.Push(sides[l->sidenum[1]].SetInterpolation(side_t::mid)); + list.Push(l->sidedef[0]->SetInterpolation(side_t::mid)); + list.Push(l->sidedef[1]->SetInterpolation(side_t::mid)); } } @@ -215,11 +215,10 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c //============================================================================ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, fixed_t *ptexbot) { - side_t *side = &sides[line->sidenum[sideno]]; - FTextureID texnum = side->GetTexture(side_t::mid); - - if (line->sidenum[0]==NO_SIDE || line->sidenum[1]==NO_SIDE || !texnum.isValid()) return false; + if (line->sidedef[0]==NULL || line->sidedef[1]==NULL) return false; + side_t *side = line->sidedef[sideno]; + FTextureID texnum = side->GetTexture(side_t::mid); FTexture * tex= TexMan(texnum); if (!tex) return false; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 9cb2afe92..2ffd2663f 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2163,9 +2163,9 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name) { side_t *sidedef; - if (lines[linenum].sidenum[side] == NO_SIDE) + sidedef = lines[linenum].sidedef[side]; + if (sidedef == NULL) continue; - sidedef = sides + lines[linenum].sidenum[side]; switch (position) { @@ -2883,15 +2883,15 @@ int DLevelScript::SideFromID(int id, int side) if (id == 0) { if (activationline == NULL) return -1; - if (activationline->sidenum[side] == NO_SIDE) return -1; - return sides[activationline->sidenum[side]].Index; + if (activationline->sidedef[side] == NULL) return -1; + return activationline->sidedef[side]->Index; } else { int line = P_FindLineFromID(id, -1); if (line == -1) return -1; - if (lines[line].sidenum[side] == NO_SIDE) return -1; - return sides[lines[line].sidenum[side]].Index; + if (lines[line].sidedef[side] == NULL) return -1; + return lines[line].sidedef[side]->Index; } } @@ -5416,7 +5416,7 @@ int DLevelScript::RunScript () case PCD_GETLINEROWOFFSET: if (activationline) { - PushToStack (sides[activationline->sidenum[0]].GetTextureYOffset(side_t::mid) >> FRACBITS); + PushToStack (activationline->sidedef[0]->GetTextureYOffset(side_t::mid) >> FRACBITS); } else { diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index ee1d44264..4e44e1c26 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -539,8 +539,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec) } j = int(intptr_t(sides[i].linedef)); - lines[j].sidenum[0] = i; - lines[j].sidenum[1] = walls[i].nextwall; + lines[j].sidedef[0] = (side_t*)(intptr_t)i; + lines[j].sidedef[1] = (side_t*)(intptr_t)walls[i].nextwall; lines[j].v1 = FindVertex (walls[i].x, walls[i].y); lines[j].v2 = FindVertex (walls[walls[i].point2].x, walls[walls[i].point2].y); lines[j].frontsector = sides[i].sector; @@ -621,19 +621,25 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec) CalcPlane (slope, sectors[i].ceilingplane); } int linenum = int(intptr_t(sides[bsec->wallptr].linedef)); + int sidenum = int(intptr_t(lines[linenum].sidedef[1])); if (bsec->floorstat & 64) { // floor is aligned to first wall - R_AlignFlat (linenum, lines[linenum].sidenum[1] == (DWORD)bsec->wallptr, 0); + R_AlignFlat (linenum, sidenum == (DWORD)bsec->wallptr, 0); } if (bsec->ceilingstat & 64) { // ceiling is aligned to first wall - R_AlignFlat (linenum, lines[linenum].sidenum[1] == (DWORD)bsec->wallptr, 0); + R_AlignFlat (linenum, sidenum == (DWORD)bsec->wallptr, 0); } } for(i = 0; i < numsides; i++) { sides[i].linedef = &lines[intptr_t(sides[i].linedef)]; } + for(i = 0; i < numlines; i++) + { + lines[i].sidedef[0] = &sides[intptr_t(lines[i].sidedef[0])]; + lines[i].sidedef[1] = &sides[intptr_t(lines[i].sidedef[1])]; + } } //========================================================================== diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 1166d47f0..090065fb4 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -264,7 +264,7 @@ void DDoor::DoorSound (bool raise) const if (line->backsector == NULL) continue; - FTexture *tex = TexMan[sides[line->sidenum[0]].GetTexture(side_t::top)]; + FTexture *tex = TexMan[line->sidedef[0]->GetTexture(side_t::top)]; texname = tex? tex->Name : NULL; if (texname != NULL && texname[0] == 'D' && texname[1] == 'O' && texname[2] == 'R') { @@ -383,14 +383,14 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, return false; // if the wrong side of door is pushed, give oof sound - if (line->sidenum[1] == NO_SIDE) // killough + if (line->sidedef[1] == NULL) // killough { S_Sound (thing, CHAN_VOICE, "*usefail", 1, ATTN_NORM); return false; } // get the sector on the second side of activating linedef - sec = sides[line->sidenum[1]].sector; + sec = line->sidedef[1]->sector; secnum = int(sec-sectors); // if door already has a thinker, use it @@ -596,10 +596,10 @@ void DAnimatedDoor::Tick () // IF DOOR NEEDS TO ANIMATE TO NEXT FRAME... m_Timer = m_Speed; - sides[m_Line1->sidenum[0]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); - sides[m_Line1->sidenum[1]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); - sides[m_Line2->sidenum[0]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); - sides[m_Line2->sidenum[1]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line1->sidedef[0]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line1->sidedef[1]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line2->sidedef[0]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line2->sidedef[1]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); } } break; @@ -631,10 +631,10 @@ void DAnimatedDoor::Tick () // IF DOOR NEEDS TO ANIMATE TO NEXT FRAME... m_Timer = m_Speed; - sides[m_Line1->sidenum[0]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); - sides[m_Line1->sidenum[1]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); - sides[m_Line2->sidenum[0]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); - sides[m_Line2->sidenum[1]].SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line1->sidedef[0]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line1->sidedef[1]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line2->sidedef[0]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); + m_Line2->sidedef[1]->SetTexture(side_t::mid, ani.TextureFrames[m_Frame]); } } break; @@ -686,7 +686,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay) // The DMovingCeiling constructor automatically sets up an interpolation for us. // Stop it, since the ceiling is moving instantly here. StopInterpolation(); - m_WhichDoorIndex = P_FindSlidingDoorType (sides[line->sidenum[0]].GetTexture(side_t::top)); + m_WhichDoorIndex = P_FindSlidingDoorType (line->sidedef[0]->GetTexture(side_t::top)); if (m_WhichDoorIndex < 0) { Printf ("EV_SlidingDoor: Textures are not defined for sliding door!"); @@ -702,16 +702,17 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay) if (sec->lines[i] == line) continue; - if (sides[sec->lines[i]->sidenum[0]].GetTexture(side_t::top) == sides[line->sidenum[0]].GetTexture(side_t::top)) + if (sec->lines[i]->sidedef[0]->GetTexture(side_t::top) == line->sidedef[0]->GetTexture(side_t::top)) { m_Line2 = sec->lines[i]; break; } } - picnum = sides[m_Line1->sidenum[0]].GetTexture(side_t::top); - sides[m_Line1->sidenum[0]].SetTexture(side_t::mid, picnum); - sides[m_Line2->sidenum[0]].SetTexture(side_t::mid, picnum); + + picnum = m_Line1->sidedef[0]->GetTexture(side_t::top); + m_Line1->sidedef[0]->SetTexture(side_t::mid, picnum); + m_Line2->sidedef[0]->SetTexture(side_t::mid, picnum); // don't forget texture scaling here! FTexture *tex = TexMan[picnum]; @@ -770,7 +771,7 @@ bool EV_SlidingDoor (line_t *line, AActor *actor, int tag, int speed, int delay) } return false; } - if (P_FindSlidingDoorType (sides[line->sidenum[0]].GetTexture(side_t::top)) >= 0) + if (P_FindSlidingDoorType (line->sidedef[0]->GetTexture(side_t::top)) >= 0) { new DAnimatedDoor (sec, line, speed, delay); return true; @@ -793,7 +794,7 @@ bool EV_SlidingDoor (line_t *line, AActor *actor, int tag, int speed, int delay) { continue; } - if (P_FindSlidingDoorType (sides[line->sidenum[0]].GetTexture(side_t::top)) >= 0) + if (P_FindSlidingDoorType (line->sidedef[0]->GetTexture(side_t::top)) >= 0) { rtn = true; new DAnimatedDoor (sec, line, speed, delay); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 0553209e8..1289b6f04 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -141,19 +141,19 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun for (i = 0; i < sec->linecount; i++) { check = sec->lines[i]; - if (check->sidenum[1] == NO_SIDE || + if (check->sidedef[1] == NULL || !(check->flags & ML_TWOSIDED)) { continue; } // Early out for intra-sector lines - if (sides[check->sidenum[0]].sector==sides[check->sidenum[1]].sector) continue; + if (check->sidedef[0]->sector == check->sidedef[1]->sector) continue; - if ( sides[ check->sidenum[0] ].sector == sec) - other = sides[ check->sidenum[1] ].sector; + if ( check->sidedef[0]->sector == sec) + other = check->sidedef[1]->sector; else - other = sides[ check->sidenum[0] ].sector; + other = check->sidedef[0]->sector; // check for closed door if ((sec->floorplane.ZatPoint (check->v1->x, check->v1->y) >= diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 0c10d9cae..a49843327 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1868,7 +1868,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int int wallnum = scroller->GetWallNum (); if (wallnum >= 0 && sides[wallnum].linedef->id == id && - sides[wallnum].linedef->sidenum[sidechoice] == (DWORD)wallnum && + int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum && Where == scroller->GetScrollParts()) { scroller->Destroy (); @@ -1887,7 +1887,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int { if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 && sides[collect.RefNum].linedef->id == id && - sides[collect.RefNum].linedef->sidenum[sidechoice] == (DWORD)collect.RefNum && + int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum && Where == ((DScroller *)collect.Obj)->GetScrollParts()) { ((DScroller *)collect.Obj)->SetRate (dx, dy); @@ -1902,17 +1902,18 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int // Now create scrollers for any walls that don't already have them. while ((linenum = P_FindLineFromID (id, linenum)) >= 0) { - unsigned int i; - for (i = 0; i < numcollected; i++) + if (lines[linenum].sidedef[sidechoice] != NULL) { - if ((DWORD)Collection[i].RefNum == lines[linenum].sidenum[sidechoice]) - break; - } - if (i == numcollected) - { - if (lines[linenum].sidenum[sidechoice] != NO_SIDE) + int sidenum = int(lines[linenum].sidedef[sidechoice] - sides); + unsigned int i; + for (i = 0; i < numcollected; i++) { - new DScroller (DScroller::sc_side, dx, dy, -1, lines[linenum].sidenum[sidechoice], 0, Where); + if (Collection[i].RefNum == sidenum) + break; + } + if (i == numcollected) + { + new DScroller (DScroller::sc_side, dx, dy, -1, sidenum, 0, Where); } } } @@ -2262,9 +2263,9 @@ FUNC(LS_Line_SetTextureOffset) for(int line = -1; (line = P_FindLineFromID (arg0, line)) >= 0; ) { - if (lines[line].sidenum[arg3] != NO_SIDE) + side_t *side = lines[line].sidedef[arg3]; + if (side != NULL) { - side_t *side = &sides[lines[line].sidenum[arg3]]; if ((arg4&8)==0) { @@ -2313,10 +2314,9 @@ FUNC(LS_Line_SetTextureScale) for(int line = -1; (line = P_FindLineFromID (arg0, line)) >= 0; ) { - if (lines[line].sidenum[arg3] != NO_SIDE) + side_t *side = lines[line].sidedef[arg3]; + if (side != NULL) { - side_t *side = &sides[lines[line].sidenum[arg3]]; - if ((arg4&8)==0) { // set @@ -2796,8 +2796,8 @@ FUNC(LS_ClearForceField) { line->flags &= ~(ML_BLOCKING|ML_BLOCKEVERYTHING); line->special = 0; - sides[line->sidenum[0]].SetTexture(side_t::mid, FNullTextureID()); - sides[line->sidenum[1]].SetTexture(side_t::mid, FNullTextureID()); + line->sidedef[0]->SetTexture(side_t::mid, FNullTextureID()); + line->sidedef[1]->SetTexture(side_t::mid, FNullTextureID()); } } } @@ -2811,11 +2811,11 @@ FUNC(LS_GlassBreak) bool quest1, quest2; ln->flags &= ~(ML_BLOCKING|ML_BLOCKEVERYTHING); - switched = P_ChangeSwitchTexture (&sides[ln->sidenum[0]], false, 0, &quest1); + switched = P_ChangeSwitchTexture (ln->sidedef[0], false, 0, &quest1); ln->special = 0; - if (ln->sidenum[1] != NO_SIDE) + if (ln->sidedef[1] != NULL) { - switched |= P_ChangeSwitchTexture (&sides[ln->sidenum[1]], false, 0, &quest2); + switched |= P_ChangeSwitchTexture (ln->sidedef[1], false, 0, &quest2); } else { diff --git a/src/p_map.cpp b/src/p_map.cpp index b445d6453..af299eb26 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3400,7 +3400,7 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a DImpactDecal::StaticCreate (bloodType, bleedtrace.X, bleedtrace.Y, bleedtrace.Z, - sides + bleedtrace.Line->sidenum[bleedtrace.Side], + bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor); } @@ -5025,7 +5025,7 @@ void SpawnShootDecal (AActor *t1, const FTraceResults &trace) if (decalbase != NULL) { DImpactDecal::StaticCreate (decalbase->GetDecal (), - trace.X, trace.Y, trace.Z, sides + trace.Line->sidenum[trace.Side], trace.ffloor); + trace.X, trace.Y, trace.Z, trace.Line->sidedef[trace.Side], trace.ffloor); } } diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 664fd3cf8..2d8e8a515 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -139,7 +139,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, sector_t *front, *back; fixed_t fc, ff, bc, bf; - if (linedef->sidenum[1] == NO_SIDE) + if (linedef->sidedef[1] == NULL) { // single sided line open.range = 0; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f3f076b95..3968f4201 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1176,9 +1176,9 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if (line != NULL && cl_missiledecals) { int side = P_PointOnLineSide (mo->x, mo->y, line); - if (line->sidenum[side] == NO_SIDE) + if (line->sidedef[side] == NULL) side ^= 1; - if (line->sidenum[side] != NO_SIDE) + if (line->sidedef[side] != NULL) { FDecalBase *base = mo->DecalGenerator; if (base != NULL) @@ -1212,9 +1212,9 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) F3DFloor * ffloor=NULL; #ifdef _3DFLOORS - if (line->sidenum[side^1]!=NO_SIDE) + if (line->sidedef[side^1] != NULL) { - sector_t * backsector=sides[line->sidenum[side^1]].sector; + sector_t * backsector = line->sidedef[side^1]->sector; extsector_t::xfloor &xf = backsector->e->XFloor; // find a 3D-floor to stick to for(unsigned int i=0;iGetDecal (), - x, y, z, sides + line->sidenum[side], ffloor); + x, y, z, line->sidedef[side], ffloor); } } } @@ -1729,7 +1729,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) if (mo->BlockingLine != NULL && mo->player && mo->waterlevel && mo->waterlevel < 3 && (mo->player->cmd.ucmd.forwardmove | mo->player->cmd.ucmd.sidemove) && - mo->BlockingLine->sidenum[1] != NO_SIDE) + mo->BlockingLine->sidedef[1] != NULL) { mo->velz = WATER_JUMP_SPEED; } diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 48247843b..f93ab503b 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -260,7 +260,7 @@ manual_plat: if (change) { if (line) - sec->SetTexture(sector_t::floor, sides[line->sidenum[0]].sector->GetTexture(sector_t::floor)); + sec->SetTexture(sector_t::floor, line->sidedef[0]->sector->GetTexture(sector_t::floor)); if (change == 1) sec->special &= SECRET_MASK; // Stop damage and other stuff, if any } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 33f5ee510..f5edb99a3 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -371,10 +371,10 @@ void P_SerializeWorld (FArchive &arc) for (j = 0; j < 2; j++) { - if (li->sidenum[j] == NO_SIDE) + if (li->sidedef[j] == NULL) continue; - side_t *si = &sides[li->sidenum[j]]; + side_t *si = li->sidedef[j]; arc << si->textures[side_t::top] << si->textures[side_t::mid] << si->textures[side_t::bottom] diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 6f02ea470..dd98faa25 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -476,8 +476,8 @@ fixed_t sector_t::FindShortestTextureAround () const { if (lines[i]->flags & ML_TWOSIDED) { - CheckShortestTex (sides[lines[i]->sidenum[0]].GetTexture(side_t::bottom), minsize); - CheckShortestTex (sides[lines[i]->sidenum[1]].GetTexture(side_t::bottom), minsize); + CheckShortestTex (lines[i]->sidedef[0]->GetTexture(side_t::bottom), minsize); + CheckShortestTex (lines[i]->sidedef[1]->GetTexture(side_t::bottom), minsize); } } return minsize < FIXED_MAX ? minsize : TexMan[0]->GetHeight() * FRACUNIT; @@ -502,8 +502,8 @@ fixed_t sector_t::FindShortestUpperAround () const { if (lines[i]->flags & ML_TWOSIDED) { - CheckShortestTex (sides[lines[i]->sidenum[0]].GetTexture(side_t::top), minsize); - CheckShortestTex (sides[lines[i]->sidenum[1]].GetTexture(side_t::top), minsize); + CheckShortestTex (lines[i]->sidedef[0]->GetTexture(side_t::top), minsize); + CheckShortestTex (lines[i]->sidedef[1]->GetTexture(side_t::top), minsize); } } return minsize < FIXED_MAX ? minsize : TexMan[0]->GetHeight() * FRACUNIT; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index b409e591b..f844b01ea 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -188,9 +188,6 @@ TArray deathmatchstarts (16); FMapThing playerstarts[MAXPLAYERS]; static void P_AllocateSideDefs (int count); -static void P_SetSideNum (DWORD *sidenum_p, WORD sidenum); - - //=========================================================================== @@ -583,7 +580,7 @@ static void SetTexture (side_t *side, int position, const char *name8) { for(int j = 0; j < 2; j++) { - if (lines[i].sidenum[j] == (DWORD)(side - sides)) + if (lines[i].sidedef[j] == side) { Printf("Unknown %s texture '%s' on %s side of linedef %d\n", positionnames[position], name, sidenames[j], i); @@ -703,7 +700,7 @@ void P_FloodZone (sector_t *sec, int zonenum) line_t *check = sec->lines[i]; sector_t *other; - if (check->sidenum[1] == NO_SIDE || (check->flags & ML_ZONEBOUNDARY)) + if (check->sidedef[1] == NULL || (check->flags & ML_ZONEBOUNDARY)) continue; if (check->frontsector == sec) @@ -790,12 +787,12 @@ void P_LoadZSegs (FileReaderZ &data) segs[i].v1 = &vertexes[v1]; segs[i].v2 = &vertexes[v2]; segs[i].linedef = ldef = &lines[line]; - segs[i].sidedef = &sides[ldef->sidenum[side]]; + segs[i].sidedef = ldef->sidedef[side]; segs[i].PartnerSeg = NULL; - segs[i].frontsector = sides[ldef->sidenum[side]].sector; - if (ldef->flags & ML_TWOSIDED && ldef->sidenum[side^1] != NO_SIDE) + segs[i].frontsector = ldef->sidedef[side]->sector; + if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL) { - segs[i].backsector = sides[ldef->sidenum[side^1]].sector; + segs[i].backsector = ldef->sidedef[side^1]->sector; } else { @@ -860,11 +857,11 @@ void P_LoadGLZSegs (FileReaderZ &data, DWORD id) line_t *ldef; seg->linedef = ldef = &lines[line]; - seg->sidedef = &sides[ldef->sidenum[side]]; - seg->frontsector = sides[ldef->sidenum[side]].sector; - if (ldef->flags & ML_TWOSIDED && ldef->sidenum[side^1] != NO_SIDE) + seg->sidedef = ldef->sidedef[side]; + seg->frontsector = ldef->sidedef[side]->sector; + if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL) { - seg->backsector = sides[ldef->sidenum[side^1]].sector; + seg->backsector = ldef->sidedef[side^1]->sector; } else { @@ -1152,17 +1149,17 @@ void P_LoadSegs (MapData * map) ldef = &lines[linedef]; li->linedef = ldef; side = LittleShort(ml->side); - if ((unsigned)ldef->sidenum[side] >= (unsigned)numsides) + if ((unsigned)(ldef->sidedef[side] - sides) >= (unsigned)numsides) { throw i * 4 + 2; } - li->sidedef = &sides[ldef->sidenum[side]]; - li->frontsector = sides[ldef->sidenum[side]].sector; + li->sidedef = ldef->sidedef[side]; + li->frontsector = ldef->sidedef[side]->sector; // killough 5/3/98: ignore 2s flag if second sidedef missing: - if (ldef->flags & ML_TWOSIDED && ldef->sidenum[side^1] != NO_SIDE) + if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL) { - li->backsector = sides[ldef->sidenum[side^1]].sector; + li->backsector = ldef->sidedef[side^1]->sector; } else { @@ -1718,20 +1715,20 @@ void P_SetLineID (line_t *ld) void P_SaveLineSpecial (line_t *ld) { - if (*ld->sidenum == NO_SIDE) + if (ld->sidedef[0] == NULL) return; + DWORD sidenum = DWORD(ld->sidedef[0]-sides); // killough 4/4/98: support special sidedef interpretation below - if ((ld->sidenum[0] != NO_SIDE) && - // [RH] Save Static_Init only if it's interested in the textures - (ld->special != Static_Init || ld->args[1] == Init_Color)) + // [RH] Save Static_Init only if it's interested in the textures + if (ld->special != Static_Init || ld->args[1] == Init_Color) { - sidetemp[*ld->sidenum].a.special = ld->special; - sidetemp[*ld->sidenum].a.tag = ld->args[0]; + sidetemp[sidenum].a.special = ld->special; + sidetemp[sidenum].a.tag = ld->args[0]; } else { - sidetemp[*ld->sidenum].a.special = 0; + sidetemp[sidenum].a.special = 0; } } @@ -1739,8 +1736,8 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) { bool additive = false; - ld->frontsector = ld->sidenum[0]!=NO_SIDE ? sides[ld->sidenum[0]].sector : 0; - ld->backsector = ld->sidenum[1]!=NO_SIDE ? sides[ld->sidenum[1]].sector : 0; + ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL; + ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL; float dx = FIXED2FLOAT(ld->v2->x - ld->v1->x); float dy = FIXED2FLOAT(ld->v2->y - ld->v1->y); int linenum = int(ld-lines); @@ -1753,16 +1750,16 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) // [RH] Set some new sidedef properties int len = (int)(sqrtf (dx*dx + dy*dy) + 0.5f); - if (ld->sidenum[0] != NO_SIDE) + if (ld->sidedef[0] != NULL) { - sides[ld->sidenum[0]].linedef = ld; - sides[ld->sidenum[0]].TexelLength = len; + ld->sidedef[0]->linedef = ld; + ld->sidedef[0]->TexelLength = len; } - if (ld->sidenum[1] != NO_SIDE) + if (ld->sidedef[1] != NULL) { - sides[ld->sidenum[1]].linedef = ld; - sides[ld->sidenum[1]].TexelLength = len; + ld->sidedef[1]->linedef = ld; + ld->sidedef[1]->TexelLength = len; } switch (ld->special) @@ -1814,7 +1811,24 @@ void P_FinishLoadingLineDefs () { for (int i = 0; i < numlines; i++) { - P_FinishLoadingLineDef(&lines[i], sidetemp[lines[i].sidenum[0]].a.alpha); + P_FinishLoadingLineDef(&lines[i], sidetemp[lines[i].sidedef[0]-sides].a.alpha); + } +} + +static void P_SetSideNum (side_t **sidenum_p, WORD sidenum) +{ + if (sidenum == NO_INDEX) + { + *sidenum_p = NULL; + } + else if (sidecount < numsides) + { + sidetemp[sidecount].a.map = sidenum; + *sidenum_p = &sides[sidecount++]; + } + else + { + I_Error ("%d sidedefs is not enough\n", sidecount); } } @@ -1886,8 +1900,8 @@ void P_LoadLineDefs (MapData * map) ld->v2 = &vertexes[LittleShort(mld->v2)]; //ld->id = -1; ID has been assigned in P_TranslateLineDef - P_SetSideNum (&ld->sidenum[0], LittleShort(mld->sidenum[0])); - P_SetSideNum (&ld->sidenum[1], LittleShort(mld->sidenum[1])); + P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0])); + P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1])); P_AdjustLine (ld); P_SaveLineSpecial (ld); @@ -1963,8 +1977,8 @@ void P_LoadLineDefs2 (MapData * map) ld->Alpha = FRACUNIT; // [RH] Opaque by default ld->id = -1; - P_SetSideNum (&ld->sidenum[0], LittleShort(mld->sidenum[0])); - P_SetSideNum (&ld->sidenum[1], LittleShort(mld->sidenum[1])); + P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0])); + P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1])); P_AdjustLine (ld); P_SetLineID(ld); @@ -2013,22 +2027,6 @@ static void P_AllocateSideDefs (int count) sidecount = 0; } -static void P_SetSideNum (DWORD *sidenum_p, WORD sidenum) -{ - if (sidenum == NO_INDEX) - { - *sidenum_p = NO_SIDE; - } - else if (sidecount < numsides) - { - sidetemp[sidecount].a.map = sidenum; - *sidenum_p = sidecount++; - } - else - { - I_Error ("%d sidedefs is not enough\n", sidecount); - } -} // [RH] Group sidedefs into loops so that we can easily determine // what walls any particular wall neighbors. @@ -2057,7 +2055,7 @@ static void P_LoopSidedefs () // For each vertex, build a list of sidedefs that use that vertex // as their left edge. line_t *line = sides[i].linedef; - int lineside = (line->sidenum[0] != (DWORD)i); + int lineside = (line->sidedef[0] != &sides[i]); int vert = int((lineside ? line->v2 : line->v1) - vertexes); sidetemp[i].b.lineside = lineside; @@ -2082,7 +2080,7 @@ static void P_LoopSidedefs () // instead of as part of another loop if (line->frontsector == line->backsector) { - right = line->sidenum[!sidetemp[i].b.lineside]; + right = DWORD(line->sidedef[!sidetemp[i].b.lineside] - sides); } else { diff --git a/src/p_spec.cpp b/src/p_spec.cpp index e1145fdf3..d70129d0f 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -234,7 +234,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType) { if (activationType == SPAC_Use || activationType == SPAC_Impact) { - P_ChangeSwitchTexture (&sides[line->sidenum[0]], repeat, special); + P_ChangeSwitchTexture (line->sidedef[0], repeat, special); } } // some old WADs use this method to create walls that change the texture when shot. @@ -247,7 +247,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType) line->args[0] && // only if there's a tag (which is stored in the first arg) P_FindSectorFromTag (line->args[0], -1) == -1) // only if no sector is tagged to this linedef { - P_ChangeSwitchTexture (&sides[line->sidenum[0]], repeat, special); + P_ChangeSwitchTexture (line->sidedef[0], repeat, special); line->special = 0; } // end of changed code @@ -778,14 +778,14 @@ DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags for (linenum = -1; (linenum = P_FindLineFromID (target, linenum)) >= 0; ) { - if (flags & WLF_SIDE1 && lines[linenum].sidenum[0]!=NO_SIDE) + if (flags & WLF_SIDE1 && lines[linenum].sidedef[0] != NULL) { - sides[lines[linenum].sidenum[0]].Flags |= wallflags; + lines[linenum].sidedef[0]->Flags |= wallflags; } - if (flags & WLF_SIDE2 && lines[linenum].sidenum[1]!=NO_SIDE) + if (flags & WLF_SIDE2 && lines[linenum].sidedef[1] != NULL) { - sides[lines[linenum].sidenum[1]].Flags |= wallflags; + lines[linenum].sidedef[1]->Flags |= wallflags; } } ChangeStatNum(STAT_LIGHTTRANSFER); @@ -810,14 +810,14 @@ void DWallLightTransfer::DoTransfer (BYTE lightlevel, int target, BYTE flags) { line_t * line = &lines[linenum]; - if (flags & WLF_SIDE1 && line->sidenum[0]!=NO_SIDE) + if (flags & WLF_SIDE1 && line->sidedef[0] != NULL) { - sides[line->sidenum[0]].SetLight(lightlevel); + line->sidedef[0]->SetLight(lightlevel); } - if (flags & WLF_SIDE2 && line->sidenum[1]!=NO_SIDE) + if (flags & WLF_SIDE2 && line->sidedef[1] != NULL) { - sides[line->sidenum[1]].SetLight(lightlevel); + line->sidedef[1]->SetLight(lightlevel); } } } @@ -981,7 +981,7 @@ void P_SpawnSpecials (void) // killough 3/7/98: // support for drawn heights coming from different sector case Transfer_Heights: - sec = sides[lines[i].sidenum[0]].sector; + sec = lines[i].frontsector; if (lines[i].args[1] & 2) { sec->MoreFlags |= SECF_FAKEFLOORONLY; @@ -1017,19 +1017,19 @@ void P_SpawnSpecials (void) // killough 3/16/98: Add support for setting // floor lighting independently (e.g. lava) case Transfer_FloorLight: - new DLightTransfer (sides[*lines[i].sidenum].sector, lines[i].args[0], true); + new DLightTransfer (lines[i].frontsector, lines[i].args[0], true); break; // killough 4/11/98: Add support for setting // ceiling lighting independently case Transfer_CeilingLight: - new DLightTransfer (sides[*lines[i].sidenum].sector, lines[i].args[0], false); + new DLightTransfer (lines[i].frontsector, lines[i].args[0], false); break; // [Graf Zahl] Add support for setting lighting // per wall independently case Transfer_WallLight: - new DWallLightTransfer (sides[*lines[i].sidenum].sector, lines[i].args[0], lines[i].args[1]); + new DWallLightTransfer (lines[i].frontsector, lines[i].args[0], lines[i].args[1]); break; case Sector_Attach3dMidtex: @@ -1290,7 +1290,7 @@ DScroller::DScroller (fixed_t dx, fixed_t dy, const line_t *l, m_Parts = scrollpos; if ((m_Control = control) != -1) m_LastHeight = sectors[control].CenterFloor() + sectors[control].CenterCeiling(); - m_Affectee = *l->sidenum; + m_Affectee = int(l->sidedef[0] - sides); sides[m_Affectee].Flags |= WALLF_NOAUTODECALS; m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; @@ -1347,7 +1347,7 @@ static void P_SpawnScrollers(void) { // if 1, then displacement // if 2, then accelerative (also if 3) - control = int(sides[*l->sidenum].sector - sectors); + control = int(l->sidedef[0]->sector - sectors); if (l->args[1] & 2) accel = 1; } @@ -1400,36 +1400,41 @@ static void P_SpawnScrollers(void) case Scroll_Texture_Offsets: // killough 3/2/98: scroll according to sidedef offsets - s = lines[i].sidenum[0]; + s = int(lines[i].sidedef[0] - sides); new DScroller (DScroller::sc_side, -sides[s].GetTextureXOffset(side_t::mid), sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0])); break; case Scroll_Texture_Left: + s = int(lines[i].sidedef[0] - sides); new DScroller (DScroller::sc_side, l->args[0] * (FRACUNIT/64), 0, - -1, lines[i].sidenum[0], accel, SCROLLTYPE(l->args[1])); + -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Right: + s = int(lines[i].sidedef[0] - sides); new DScroller (DScroller::sc_side, l->args[0] * (-FRACUNIT/64), 0, - -1, lines[i].sidenum[0], accel, SCROLLTYPE(l->args[1])); + -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Up: + s = int(lines[i].sidedef[0] - sides); new DScroller (DScroller::sc_side, 0, l->args[0] * (FRACUNIT/64), - -1, lines[i].sidenum[0], accel, SCROLLTYPE(l->args[1])); + -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Down: + s = int(lines[i].sidedef[0] - sides); new DScroller (DScroller::sc_side, 0, l->args[0] * (-FRACUNIT/64), - -1, lines[i].sidenum[0], accel, SCROLLTYPE(l->args[1])); + -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Both: + s = int(lines[i].sidedef[0] - sides); if (l->args[0] == 0) { dx = (l->args[1] - l->args[2]) * (FRACUNIT/64); dy = (l->args[4] - l->args[3]) * (FRACUNIT/64); - new DScroller (DScroller::sc_side, dx, dy, -1, lines[i].sidenum[0], accel); + new DScroller (DScroller::sc_side, dx, dy, -1, s, accel); } break; diff --git a/src/p_spec.h b/src/p_spec.h index f2473f3f1..dbf330082 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -195,7 +195,7 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag); // inline side_t *getSide (int currentSector, int line, int side) { - return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ]; + return (sectors[currentSector].lines[line])->sidedef[side]; } // @@ -206,7 +206,7 @@ inline side_t *getSide (int currentSector, int line, int side) // inline sector_t *getSector (int currentSector, int line, int side) { - return sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector; + return (sectors[currentSector].lines[line])->sidedef[side]->sector; } diff --git a/src/p_switch.cpp b/src/p_switch.cpp index cd2b65413..4e312a166 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -465,12 +465,12 @@ static int TryFindSwitch (side_t *side, int Where) bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) { // Activated from an empty side -> always succeed - if (line->sidenum[sideno] == NO_SIDE) return true; + side_t *side = line->sidedef[sideno]; + if (side == NULL) return true; fixed_t checktop; fixed_t checkbot; - side_t *side = &sides[line->sidenum[sideno]]; - sector_t *front = sides[line->sidenum[sideno]].sector; + sector_t *front = side->sector; FLineOpening open; // 3DMIDTEX forces CHECKSWITCHRANGE because otherwise it might cause problems. @@ -492,7 +492,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) checky = dll.y + FixedMul(dll.dy, inter); // one sided line - if (line->sidenum[1] == NO_SIDE) + if (line->sidedef[1] == NULL) { onesided: fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky); diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index ca75de03d..8fe870e82 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -397,7 +397,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO int i; line_t *l; - if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidenum[1] == NO_SIDE) + if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL) return false; for (i = -1; (i = P_FindLineFromID (id, i)) >= 0; ) @@ -476,8 +476,8 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO // Height of thing above ground fixed_t z; - z = thing->z - sides[line->sidenum[1]].sector->floorplane.ZatPoint (thing->x, thing->y) - + sides[l->sidenum[0]].sector->floorplane.ZatPoint (x, y); + z = thing->z - line->backsector->floorplane.ZatPoint (thing->x, thing->y) + + l->frontsector->floorplane.ZatPoint (x, y); // Attempt to teleport, aborting if blocked // Adjust z position to be same height above ground as before. diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index dedef053c..b9c41b724 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -599,7 +599,7 @@ struct UDMFParser memset(ld, 0, sizeof(*ld)); ld->Alpha = FRACUNIT; ld->id = -1; - ld->sidenum[0] = ld->sidenum[1] = NO_SIDE; + ld->sidedef[0] = ld->sidedef[1] = NULL; if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX; if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX; if (level.flags2 & LEVEL2_CHECKSWITCHRANGE) ld->flags |= ML_CHECKSWITCHRANGE; @@ -635,11 +635,11 @@ struct UDMFParser continue; case NAME_Sidefront: - ld->sidenum[0] = CheckInt(key); + ld->sidedef[0] = (side_t*)(intptr_t)(1 + CheckInt(key)); continue; case NAME_Sideback: - ld->sidenum[1] = CheckInt(key); + ld->sidedef[1] = (side_t*)(intptr_t)(1 + CheckInt(key)); continue; case NAME_Arg0: @@ -1281,9 +1281,9 @@ struct UDMFParser ParsedLines[i].v1 = &vertexes[v1i]; ParsedLines[i].v2 = &vertexes[v2i]; - if (ParsedLines[i].sidenum[0] != NO_SIDE) + if (ParsedLines[i].sidedef[0] != NULL) sidecount++; - if (ParsedLines[i].sidenum[1] != NO_SIDE) + if (ParsedLines[i].sidedef[1] != NULL) sidecount++; linemap.Push(i+skipped); i++; @@ -1302,13 +1302,13 @@ struct UDMFParser for(int sd = 0; sd < 2; sd++) { - if (lines[line].sidenum[sd] != NO_SIDE) + if (lines[line].sidedef[sd] != NULL) { - int mapside = lines[line].sidenum[sd]; + int mapside = int(intptr_t(lines[line].sidedef[sd]))-1; sides[side] = ParsedSides[mapside]; sides[side].linedef = &lines[line]; sides[side].sector = §ors[intptr_t(sides[side].sector)]; - lines[line].sidenum[sd] = side; + lines[line].sidedef[sd] = &sides[side]; P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside], lines[line].special, lines[line].args[0], &tempalpha[sd]); diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index 9261ee904..db758631f 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -121,8 +121,8 @@ static int WriteLINEDEFS (FILE *file) { mld.args[j] = (BYTE)lines[i].args[j]; } - mld.sidenum[0] = LittleShort(WORD(lines[i].sidenum[0])); - mld.sidenum[1] = LittleShort(WORD(lines[i].sidenum[1])); + mld.sidenum[0] = LittleShort(WORD(lines[i].sidedef[0] - sides)); + mld.sidenum[1] = LittleShort(WORD(lines[i].sidedef[1] - sides)); fwrite (&mld, sizeof(mld), 1, file); } return numlines * sizeof(mld); @@ -184,7 +184,7 @@ static int WriteSEGS (FILE *file) ms.v1 = LittleShort(short(segs[i].v1 - vertexes)); ms.v2 = LittleShort(short(segs[i].v2 - vertexes)); ms.linedef = LittleShort(short(segs[i].linedef - lines)); - ms.side = DWORD(segs[i].sidedef - sides) == segs[i].linedef->sidenum[0] ? 0 : LittleShort((short)1); + ms.side = segs[i].sidedef == segs[i].linedef->sidedef[0] ? 0 : LittleShort((short)1); ms.angle = LittleShort(short(R_PointToAngle2 (segs[i].v1->x, segs[i].v1->y, segs[i].v2->x, segs[i].v2->y)>>16)); fwrite (&ms, sizeof(ms), 1, file); } diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index ffb8a1f4f..bf09603e3 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -648,7 +648,7 @@ void R_AddLine (seg_t *line) } else { // The seg is only part of the wall. - if (line->linedef->sidenum[0] != DWORD(line->sidedef - sides)) + if (line->linedef->sidedef[0] != line->sidedef) { swap (v1, v2); } diff --git a/src/r_defs.h b/src/r_defs.h index b4361adc3..cf287de20 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -872,7 +872,8 @@ struct line_t int id; // <--- same as tag or set with Line_SetIdentification int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) int firstid, nextid; - DWORD sidenum[2]; // sidenum[1] will be NO_SIDE if one sided + side_t *sidedef[2]; + //DWORD sidenum[2]; // sidenum[1] will be NO_SIDE if one sided fixed_t bbox[4]; // bounding box, for the extent of the LineDef. slopetype_t slopetype; // To aid move clipping. sector_t *frontsector, *backsector; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 9be0b0b5d..b2dc9ac40 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1290,7 +1290,7 @@ void R_DrawSkyPlane (visplane_t *pl) const line_t *l = &lines[(pl->sky & ~PL_SKYFLAT)-1]; // Sky transferred from first sidedef - const side_t *s = *l->sidenum + sides; + const side_t *s = l->sidedef[0]; int pos; // Texture comes from upper texture of reference sidedef diff --git a/src/r_polymost.cpp b/src/r_polymost.cpp index 57a315391..f5f82950a 100644 --- a/src/r_polymost.cpp +++ b/src/r_polymost.cpp @@ -1202,7 +1202,7 @@ void RP_AddLine (seg_t *line) } else { // The seg is only part of the wall. - if (line->linedef->sidenum[0] != DWORD(line->sidedef - sides)) + if (line->linedef->sidedef[0] != line->sidedef) { swap (v1, v2); }