void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool ceiling) { int v; if (lineid == 0 && tag == 0) { // invalid set of parameters return; } extsector_t::midtex::plane &scrollplane = ceiling? sector->e->Midtex.Ceiling : sector->e->Midtex.Floor; // 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]; memset(found_lines, 0, sizeof (BYTE) * ((numlines+7)/8)); memset(found_sectors, 0, sizeof (BYTE) * ((numsectors+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 // from the marker arrays. for (unsigned i=0; i < scrollplane.AttachedLines.Size(); i++) { int line = int(scrollplane.AttachedLines[i] - lines); found_lines[line>>3] |= 1 << (line&7); } for (unsigned i=0; i < scrollplane.AttachedSectors.Size(); i++) { int sec = int(scrollplane.AttachedSectors[i] - sectors); found_sectors[sec>>3] |= 1 << (sec&7); } scrollplane.AttachedLines.Clear(); scrollplane.AttachedSectors.Clear(); if (tag == 0) { for(int line = -1; (line = P_FindLineFromID(lineid,line)) >= 0; ) { line_t *ln = &lines[line]; if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX)) { // Only consider two-sided lines with the 3DMIDTEX flag continue; } found_lines[line>>3] |= 1 << (line&7); } } else { for(int sec = -1; (sec = P_FindSectorFromTag(tag, sec)) >= 0; )
void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling) { extsector_t::linked::plane &scrollplane = ceiling? control->e->Linked.Ceiling : control->e->Linked.Floor; for(int line = -1; (line = P_FindLineFromID(id, line)) >= 0; ) { line_t *ld = &lines[line]; if (ld->special == Static_Init && ld->args[1] == Init_SectorLink) { int movetype = ld->args[3]; // Make sure we have only valid combinations movetype &= LINK_FLAGMASK; if ((movetype & LINK_FLOORMIRROR) == LINK_FLOORMIRRORFLAG) movetype &= ~LINK_FLOORMIRRORFLAG; if ((movetype & LINK_CEILINGMIRROR) == LINK_CEILINGMIRRORFLAG) movetype &= ~LINK_CEILINGMIRRORFLAG; if (movetype != 0 && ld->frontsector != NULL && ld->frontsector != control) { AddSingleSector(scrollplane, ld->frontsector, movetype); } } } }