diff --git a/source/build/include/build.h b/source/build/include/build.h index dc1d5f73e..bd6627d9e 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -715,9 +715,6 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16 int32_t engineLoadMHK(const char *filename); void G_LoadMapHack(const char* filename); void engineClearLightsFromMHK(); -#ifdef HAVE_CLIPSHAPE_FEATURE -int32_t engineLoadClipMaps(void); -#endif int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum); int32_t qloadkvx(int32_t voxindex, const char *filename); @@ -943,7 +940,6 @@ static FORCE_INLINE CONSTEXPR int32_t E_SpriteIsValid(const int32_t i) return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS); } -int clipshape_idx_for_sprite(uspriteptr_t curspr, int curidx); void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z); void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z); diff --git a/source/build/include/clip.h b/source/build/include/clip.h index 22e88654d..2d2d7330e 100644 --- a/source/build/include/clip.h +++ b/source/build/include/clip.h @@ -14,55 +14,6 @@ #define MAXCLIPSECTORS 512 #define MAXCLIPNUM 2048 #define CLIPCURBHEIGHT (1<<8) -#ifdef HAVE_CLIPSHAPE_FEATURE - -#define CM_MAX 256 // must be a power of 2 - -// sectoidx bits -#undef CM_NONE -#define CM_NONE (CM_MAX<<1) -#define CM_SOME (CM_NONE-1) -#define CM_OUTER (CM_MAX) // sector surrounds clipping sector - -// sprite -> sector tag mappings -#define CM_XREPEAT floorpal -#define CM_YREPEAT floorxpanning -#define CM_XOFFSET ceilingshade -#define CM_YOFFSET floorshade -#define CM_CSTAT hitag -#define CM_ANG extra -#define CM_FLOORZ(Sec) (*(int32_t *)§or[Sec].ceilingxpanning) // ceilingxpanning,ceilingypanning,floorpicnum -#define CM_CEILINGZ(Sec) (*(int32_t *)§or[Sec].visibility) // visibility,fogpal,lotag - -// backup of original normalized coordinates -#define CM_WALL_X(Wal) (*(int32_t *)&wall[Wal].picnum) // picnum, overpicnum -#define CM_WALL_Y(Wal) (*(int32_t *)&wall[Wal].lotag) // lotag, hitag - -// don't rotate when applying clipping, for models with rotational symmetry -#define CM_NOROT(Spri) (sprite[Spri].cstat&2) -#define CM_NOROTS(Sect) (sector[Sect].CM_CSTAT&2) - -extern vec2_t hitscangoal; - -typedef struct -{ - int16_t qbeg, qend; // indices into sectq - int16_t picnum, next; - int32_t maxdist; -} clipinfo_t; - -typedef struct -{ - int16_t numsectors, numwalls; - usectorptr_t sector; - uwallptr_t wall; -} mapinfo_t; - -extern int32_t quickloadboard; -extern void engineInitClipMaps(); -extern void engineSetClipMap(mapinfo_t *bak, mapinfo_t *newmap); - -#endif // HAVE_CLIPSHAPE_FEATURE typedef struct { int32_t x1, y1, x2, y2; diff --git a/source/build/include/common.h b/source/build/include/common.h index da7b52afc..b71e5dd77 100644 --- a/source/build/include/common.h +++ b/source/build/include/common.h @@ -64,8 +64,6 @@ static inline void realloc_copy(char **fn, const char *buf) int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens); -int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char *ext); - void COMMON_clearbackground(int32_t numcols, int32_t numrows); diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 2e2d9c869..e9a3774c6 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -1045,13 +1045,4 @@ inline FVector3 GetSoundPos(const vec3_t *pos) #define WITHKPLIB - -#if DEBUGGINGAIDS>=2 -# define DEBUG_MAIN_ARRAYS -#endif - -#if !defined DEBUG_MAIN_ARRAYS -# define HAVE_CLIPSHAPE_FEATURE -#endif - #endif // compat_h_ diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 9d16ff5a6..7e95be61b 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -19,36 +19,12 @@ int16_t clipsectorlist[MAXCLIPSECTORS]; static int16_t origclipsectorlist[MAXCLIPSECTORS]; static uint8_t clipsectormap[(MAXSECTORS+7)>>3]; static uint8_t origclipsectormap[(MAXSECTORS+7)>>3]; -#ifdef HAVE_CLIPSHAPE_FEATURE -static int16_t clipspritelist[MAXCLIPNUM]; // sector-like sprite clipping -#endif static int16_t clipobjectval[MAXCLIPNUM]; static uint8_t clipignore[(MAXCLIPNUM+7)>>3]; -////// sector-like clipping for sprites ////// -void engineSetClipMap(mapinfo_t *bak, mapinfo_t *newmap) -{ - if (bak) - { - bak->numsectors = numsectors; - bak->numwalls = numwalls; - bak->sector = (usectortype *) sector; - bak->wall = (uwalltype *) wall; - } - if (newmap) - { - numsectors = newmap->numsectors; - numwalls = newmap->numwalls; - sector = const_cast((sectortype const *)newmap->sector); - wall = const_cast((walltype const *)newmap->wall); - } -} - -static mapinfo_t origmapinfo, clipmapinfo; int32_t quickloadboard=0; -static clipinfo_t clipinfo[CM_MAX]; static int32_t numclipmaps; static int32_t numclipsects; // number in sectq[] @@ -79,460 +55,11 @@ void engineInitClipMaps() // two's complement trick, -1 = 0xff Bmemset(&pictoidx, -1, sizeof(pictoidx)); - Bmemset(&clipmapinfo, 0, sizeof(mapinfo_t)); numsectors = 0; numwalls = 0; } -// loads the clip maps. -// this should be called before any real map is loaded. -int32_t engineLoadClipMaps(void) -{ - int32_t i, k, w; - - int32_t lwcp = 0; - size_t fi; - size_t const g_clipMapFilesNum = g_clipMapFiles.Size(); - - int32_t *fisec = NULL; - int32_t *fispr = NULL; - - int32_t ournumsectors=0, ournumwalls=0, ournumsprites=0; - - engineInitClipMaps(); - - loadsector = (usectortype *) Xmalloc(MAXSECTORS * sizeof(sectortype)); - loadwall = (uwalltype *) Xmalloc(MAXWALLS * sizeof(walltype)); - loadsprite = (uspritetype *) Xmalloc(MAXSPRITES * sizeof(spritetype)); - - if (g_clipMapFilesNum) - { - fisec = (int32_t *) Xcalloc(g_clipMapFilesNum, sizeof(int32_t)); - fispr = (int32_t *) Xcalloc(g_clipMapFilesNum, sizeof(int32_t)); - } - - quickloadboard = 1; - for (fi = 0; fi < g_clipMapFilesNum; ++fi) - { - int16_t ang, cs; - vec3_t tmppos; - - fisec[fi] = ournumsectors; - fispr[fi] = ournumsprites; - - i = engineLoadBoard(g_clipMapFiles[fi], 8, &tmppos, &ang, &cs); - if (i<0) - continue; - // Numsprites will now be set! - - Printf("Loading clip map: %s\n", g_clipMapFiles[fi].GetChars()); - - if (ournumsectors+numsectors>MAXSECTORS || - ournumwalls+numwalls>MAXWALLS || - ournumsprites+Numsprites>MAXSPRITES) - { - Printf("clip map: warning: exceeded limits when loading %s, aborting.\n", g_clipMapFiles[fi].GetChars()); - break; - } - - Bmemcpy(loadsector+ournumsectors, sector, numsectors*sizeof(sectortype)); - Bmemcpy(loadwall+ournumwalls, wall, numwalls*sizeof(walltype)); - Bmemcpy(loadsprite+ournumsprites, sprite, Numsprites*sizeof(spritetype)); - for (i=ournumsectors; i=0) - loadwall[i].point2 += ournumwalls; - if (loadwall[i].nextwall>=0) - { - loadwall[i].nextwall += ournumwalls; - loadwall[i].nextsector += ournumsectors; - } - } - for (i=ournumsprites; i=0) - loadsprite[i].sectnum += ournumsectors; - ournumsectors += numsectors; - ournumwalls += numwalls; - ournumsprites += Numsprites; - - ++lwcp; - } - quickloadboard = 0; - - if (ournumsectors==0 || ournumwalls==0 || ournumsprites==0) // nothing loaded - { - engineInitClipMaps(); - - Xfree(fisec); - Xfree(fispr); - - return -1; - } - - // shrink - loadsector = (usectortype *) Xrealloc(loadsector, ournumsectors*sizeof(sectortype)); - loadwall = (uwalltype *) Xrealloc(loadwall, ournumwalls*sizeof(walltype)); - - Bmemcpy(sector, loadsector, ournumsectors*sizeof(sectortype)); - Bmemcpy(wall, loadwall, ournumwalls*sizeof(walltype)); - Bmemcpy(sprite, loadsprite, ournumsprites*sizeof(spritetype)); - numsectors = ournumsectors; - numwalls = ournumwalls; - - // vvvv don't use headsprite[sect,stat]! vvvv - - sectoidx = (int16_t *) Xmalloc(numsectors*sizeof(sectoidx[0])); - - for (i=0; i=0 && sectoidx[wall[w].nextsector]==CM_OUTER) - { - wall[k].nextwall = wall[k].nextsector = -1; - wall[w].nextwall = wall[w].nextsector = -1; - } - } - } - - { - int16_t ns, outersect; - int32_t pn, scnt, x, y, z, maxdist; - - sectq = (int16_t *) Xmalloc(numsectors*sizeof(sectq[0])); - tempictoidx = (int16_t *) Xmalloc(MAXTILES*sizeof(tempictoidx[0])); - - for (i=0; i=MAXTILES || k<0 || k>=numsectors || (sectoidx[k]&CM_OUTER)) - continue; - - if (numclipmaps >= CM_MAX) - { - Printf("warning: reached max clip map number %d, not processing any more\n", CM_MAX); - break; - } - - // chain - if (pictoidx[pn]>=0) - { - if (sectoidx[k]&CM_SOME) - { - for (fi = 0; fi < g_clipMapFilesNum; ++fi) - if (k>=fisec[fi]) - break; - Printf("clip map \"%s\": error: tried to chain picnum %d (sprite %d) in sector %d which" - " already belongs to picnum %d.\n", g_clipMapFiles[fi].GetChars(), pn, i-fispr[fi], k-fisec[fi], - clipinfo[sectoidx[k]].picnum); - engineInitClipMaps(); - - Xfree(fisec); - Xfree(fispr); - - return 2; - } - - // new one is front - clipinfo[numclipmaps].next = pictoidx[pn]; - pictoidx[pn] = numclipmaps; - } - else - { - clipinfo[numclipmaps].next = -1; - pictoidx[pn] = numclipmaps; - } - - if (!CM_NOROT(i)) - { - if (sprite[i].ang!=1536 && sprite[i].ang!=512) - { - for (fi = 0; fi < g_clipMapFilesNum; ++fi) - if (i>=fispr[fi]) - break; - Printf("clip map \"%s\": warning: sprite %d pointing neither northward nor southward. %s will be wrong.\n", - g_clipMapFiles[fi].GetChars(), i-fispr[fi], (sprite[i].cstat&48)==32 ? "Scaling and flipping" : "X-flipping"); - } - } - - clipinfo[numclipmaps].picnum = pn; - - // collect sectors - scnt = numclipsects; - sectq[numclipsects++] = k; - sectoidx[k] = numclipmaps; - - clipinfo[numclipmaps].qbeg = scnt; - - outersect = -1; - - do - { - k = sectq[scnt]; - - for (w=sector[k].wallptr; w=0) - { - if (sectoidx[ns]==CM_NONE) - { - sectoidx[ns] = numclipmaps; - sectq[numclipsects++] = ns; - } - else if (sectoidx[ns]&CM_OUTER) - { - if (outersect>=0 && ns!=outersect) - { - for (fi = 0; fi < g_clipMapFilesNum; ++fi) - if (ns>=fisec[fi]) - break; - Printf("clip map \"%s\": error: encountered more than one outer sector (%d and %d)" - " for sprite %d.\n", g_clipMapFiles[fi].GetChars(), outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]); - engineInitClipMaps(); - - Xfree(fisec); - Xfree(fispr); - - return 3; - } - - outersect = ns; - sectoidx[outersect] |= numclipmaps; - } - else if (sectoidx[ns]!=numclipmaps) - { - for (fi = 0; fi < g_clipMapFilesNum; ++fi) - if (ns>=fisec[fi]) - break; - Printf("clip map \"%s\": error: encountered sector %d belonging to index %d" - " while collecting sectors for sprite %d (index %d).\n", - g_clipMapFiles[fi].GetChars(), ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps); - engineInitClipMaps(); - - Xfree(fisec); - Xfree(fispr); - - return 4; - } - } - } - } while (++scnt < numclipsects); - - if (outersect==-1) - { - Printf("clip map: INTERNAL ERROR: outersect==-1!\n"); - engineInitClipMaps(); - - Xfree(fisec); - Xfree(fispr); - - return 5; - } - - sectq[numclipsects++] = outersect; // last is outer - clipinfo[numclipmaps].qend = numclipsects-1; - - // normalize - maxdist = 0; - - for (scnt=clipinfo[numclipmaps].qbeg; scnt<=clipinfo[numclipmaps].qend; scnt++) - { - k = sectq[scnt]; - - x = sprite[i].x; - y = sprite[i].y; - z = sprite[i].z; - - sector[k].floorz -= z; - sector[k].ceilingz -= z; - - if (scnt==clipinfo[numclipmaps].qbeg) - { - // backup sprite tags since we'll discard sprites later - sector[k].CM_XREPEAT = sprite[i].xrepeat; - sector[k].CM_YREPEAT = sprite[i].yrepeat; - sector[k].CM_XOFFSET = sprite[i].xoffset; - sector[k].CM_YOFFSET = sprite[i].yoffset; - sector[k].CM_CSTAT = sprite[i].cstat; - sector[k].CM_ANG = sprite[i].ang; - } - - // backup floor and ceiling z - CM_FLOORZ(k) = sector[k].floorz; - CM_CEILINGZ(k) = sector[k].ceilingz; - - for (w=sector[k].wallptr; w maxdist) - maxdist = klabs(wall[w].x); - if (klabs(wall[w].y) > maxdist) - maxdist = klabs(wall[w].y); - } - else - { - int32_t tmp = ksqrt(uhypsq(wall[w].x, wall[w].y)); - if (tmp > maxdist) - maxdist = tmp; - } - } - - // aliasing - if (wall[w].lotag>0 || wall[w].hitag>0) - { - int32_t ii; - - if (wall[w].lotag>0 && wall[w].hitag>0) - { - if (wall[w].lotag > wall[w].hitag) - swapshort(&wall[w].lotag, &wall[w].hitag); - - for (ii=wall[w].lotag; ii0) - { - if (wall[w].lotag=0) - pictoidx[i]=tempictoidx[i]; - } - - DO_FREE_AND_NULL(loadsprite); - DO_FREE_AND_NULL(tempictoidx); - - // don't let other code be distracted by the temporary map we constructed - numsectors = 0; - numwalls = 0; - initspritelists(); - - if (lwcp > 0) - Printf("Loaded clip map%s.\n", lwcp==1 ? "" : "s"); - - Xfree(fisec); - Xfree(fispr); - - return 0; -} - - -int clipshape_idx_for_sprite(uspriteptr_t const curspr, int curidx) -{ - // per-sprite init - curidx = (curidx < 0) ? pictoidx[curspr->picnum] : clipinfo[curidx].next; - - while (curidx >= 0 && (curspr->cstat & 32) != (sector[sectq[clipinfo[curidx].qbeg]].CM_CSTAT & 32)) - curidx = clipinfo[curidx].next; - - return curidx; -} - ////////// CLIPMOVE ////////// int32_t clipmoveboxtracenum = 3; @@ -615,132 +142,6 @@ static inline void addclipsect(int const sectnum) clipmove_warned |= 1; } -#ifdef HAVE_CLIPSHAPE_FEATURE -int32_t clipsprite_try(uspriteptr_t const spr, int32_t xmin, int32_t ymin, int32_t xmax, int32_t ymax) -{ - // try and see whether this sprite's picnum has sector-like clipping data - int32_t i = pictoidx[spr->picnum]; - // handle sector-like floor sprites separately - while (i>=0 && (spr->cstat&32) != (clipmapinfo.sector[sectq[clipinfo[i].qbeg]].CM_CSTAT&32)) - i = clipinfo[i].next; - - if (i>=0) - { - int32_t maxcorrection = clipinfo[i].maxdist; - const int32_t k = sectq[clipinfo[i].qbeg]; - - if ((spr->cstat&CSTAT_SPRITE_ALIGNMENT)!=CSTAT_SPRITE_ALIGNMENT_FLOOR) - { - int32_t const tempint1 = clipmapinfo.sector[k].CM_XREPEAT; - maxcorrection = divideu32_noinline(maxcorrection * (int32_t) spr->xrepeat, tempint1); - } - else - { - int32_t const tempint1 = clipmapinfo.sector[k].CM_XREPEAT; - int32_t const tempint2 = clipmapinfo.sector[k].CM_YREPEAT; - maxcorrection = max(divideu32_noinline(maxcorrection * (int32_t) spr->xrepeat, tempint1), - divideu32_noinline(maxcorrection * (int32_t) spr->yrepeat, tempint2)); - } - - maxcorrection -= MAXCLIPDIST; - - if ((spr->x < xmin - maxcorrection) || (spr->y < ymin - maxcorrection) || - (spr->x > xmax + maxcorrection) || (spr->y > ymax + maxcorrection)) - return 1; - - if (clipspritenum < MAXCLIPNUM) - clipspritelist[clipspritenum++] = spr-(uspritetype *)sprite; - //Printf("%d: clip sprite[%d]\n",clipspritenum,j); - return 1; - } - - return 0; -} - -// return: -1 if curspr has x-flip xor y-flip (in the horizontal map plane!), 1 else -int32_t clipsprite_initindex(int32_t curidx, uspriteptr_t const curspr, int32_t *clipsectcnt, const vec3_t *vect) -{ - int32_t k, daz = curspr->z; - int32_t scalex, scaley, scalez, flipx, flipy; - int32_t flipmul=1; - - const int32_t j = sectq[clipinfo[curidx].qbeg]; - const int32_t tempint1 = sector[j].CM_XREPEAT; - const int32_t tempint2 = sector[j].CM_YREPEAT; - - const int32_t rotang = (curspr->ang - sector[j].CM_ANG)&2047; - const int32_t dorot = !CM_NOROTS(j); - - if ((curspr->cstat&CSTAT_SPRITE_ALIGNMENT)!=CSTAT_SPRITE_ALIGNMENT_FLOOR) // face/wall sprite - { - scalex = scaley = divscale22(curspr->xrepeat, tempint1); - scalez = divscale22(curspr->yrepeat, tempint2); - - flipx = 1-((curspr->cstat&4)>>1); - flipy = 1; - } - else - { - scalex = divscale22(curspr->xrepeat, tempint1); - scaley = divscale22(curspr->yrepeat, tempint2); - scalez = scalex; - - flipx = 1-((curspr->cstat&4)>>1); - flipy = 1-((curspr->cstat&8)>>2); - } - - if (dorot) - { - flipmul = flipx*flipy; - if (flipmul==-1) - wall = (walltype *) loadwallinv; - } - - if ((curspr->cstat&128) != (sector[j].CM_CSTAT&128)) - daz += (((curspr->cstat&128)>>6)-1)*((tilesiz[curspr->picnum].y*curspr->yrepeat)<<1); - - *clipsectcnt = clipsectnum = 0; - // init sectors for this index - for (k=clipinfo[curidx].qbeg; k<=clipinfo[curidx].qend; k++) - { - int32_t const j = sectq[k]; - auto const sec = §or[j]; - - int32_t const startwall = sec->wallptr, endwall = startwall+sec->wallnum; - - sec->floorz = daz + mulscale22(scalez, CM_FLOORZ(j)); - sec->ceilingz = daz + mulscale22(scalez, CM_CEILINGZ(j)); - //Printf("sec %d: f=%d, c=%d\n", j, sec->floorz, sec->ceilingz); - - for (int w=startwall; wx = mulscale22(scalex, CM_WALL_X(w)); - wal->y = mulscale22(scaley, CM_WALL_Y(w)); - - if (dorot) - { - wal->x *= flipx; - wal->y *= flipy; - rotatepoint(zerovec, wal->pos, rotang, &wal->pos); - } - - wal->x += curspr->x; - wal->y += curspr->y; - } - - if (inside(vect->x, vect->y, j)==1) - addclipsect(j); - } - - // add outer sector if not inside inner ones - if (clipsectnum==0) - addclipsect(sectq[k-1]); - - return flipmul; -} - -#endif static void addclipline(int32_t dax1, int32_t day1, int32_t dax2, int32_t day2, int16_t daoval, int nofix) { @@ -1117,37 +518,6 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int do { -#ifdef HAVE_CLIPSHAPE_FEATURE - if (clipsectcnt>=clipsectnum) - { - // one bunch of sectors completed (either the very first - // one or a sector-like sprite one), prepare the next - - //Printf("init sprite %d\n", clipspritecnt); - if (!curspr) - { - // init sector-like sprites for clipping - origclipsectnum = clipsectnum; - Bmemcpy(origclipsectorlist, clipsectorlist, clipsectnum*sizeof(clipsectorlist[0])); - Bmemcpy(origclipsectormap, clipsectormap, (numsectors+7)>>3); - - // replace sector and wall with clip map - engineSetClipMap(&origmapinfo, &clipmapinfo); - } - - curspr = (uspriteptr_t)&sprite[clipspritelist[clipspritecnt]]; - clipshapeidx = clipshape_idx_for_sprite(curspr, clipshapeidx); - - if (clipshapeidx < 0) - { - clipspritecnt++; - continue; - } - - clipsprite_initindex(clipshapeidx, curspr, &clipsectcnt, pos); - } -#endif - int const dasect = clipsectorlist[clipsectcnt++]; //if (curspr) // Printf("sprite %d/%d: sect %d/%d (%d)\n", clipspritecnt,clipspritenum, clipsectcnt,clipsectnum,dasect); @@ -1182,39 +552,6 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int int clipyou = 0; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - { - if (wal->nextsector>=0) - { - auto const sec2 = (usectorptr_t)§or[wal->nextsector]; - - clipmove_tweak_pos(pos, diff.x, diff.y, p1.x, p1.y, p2.x, p2.y, &v.x, &v.y); - -#define CLIPMV_SPR_F_DAZ2 getcorrectflorzofslope(wal->nextsector, v.x, v.y) -#define CLIPMV_SPR_F_BASEZ getcorrectflorzofslope(sectq[clipinfo[clipshapeidx].qend], v.x, v.y) - - if ((sec2->floorstat&1) == 0) - { - if (CLIPMV_SPR_F_DAZ2-(flordist-1) <= pos->z && pos->z <= CLIPMV_SPR_F_BASEZ+(flordist-1)) - clipyou = 1; - } - - if (clipyou == 0) - { -#define CLIPMV_SPR_C_DAZ2 getcorrectceilzofslope(wal->nextsector, v.x, v.y) -#define CLIPMV_SPR_C_BASEZ getcorrectceilzofslope(sectq[clipinfo[clipshapeidx].qend], v.x, v.y) - - if ((sec2->ceilingstat & 1) == 0) - { - if (CLIPMV_SPR_C_BASEZ-(ceildist-1) <= pos->z && pos->z <= CLIPMV_SPR_C_DAZ2+(ceildist-1)) - clipyou = 1; - } - } - } - } - else -#endif if (wal->nextsector < 0 || (wal->cstat&dawalclipmask)) { clipyou = 1; @@ -1289,10 +626,6 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int if (dasprclipmask==0) continue; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - continue; // next sector of this index -#endif for (native_t j=headspritesect[dasect]; j>=0; j=nextspritesect[j]) { auto const spr = (uspriteptr_t)&sprite[j]; @@ -1301,10 +634,6 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int if ((cstat&dasprclipmask) == 0) continue; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (clipsprite_try(spr, clipMin.x, clipMin.y, clipMax.x, clipMax.y)) - continue; -#endif vec2_t p1 = *(vec2_t const *)spr; switch (cstat & (CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ALIGNMENT_FLOOR)) @@ -1405,18 +734,6 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int } } while (clipsectcnt < clipsectnum || clipspritecnt < clipspritenum); -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - { - // restore original map - engineSetClipMap(NULL, &origmapinfo); - - clipsectnum = origclipsectnum; - Bmemcpy(clipsectorlist, origclipsectorlist, clipsectnum*sizeof(clipsectorlist[0])); - Bmemcpy(clipsectormap, origclipsectormap, (numsectors+7)>>3); - } -#endif - int32_t hitwalls[4], hitwall; int32_t clipReturn = 0; @@ -1746,72 +1063,12 @@ void getzrange(const vec3_t *pos, int16_t sectnum, Bmemset(clipsectormap, 0, (numsectors+7)>>3); bitmap_set(clipsectormap, sectnum); -#ifdef HAVE_CLIPSHAPE_FEATURE - if (0) - { -beginagain: - // replace sector and wall with clip map - engineSetClipMap(&origmapinfo, &clipmapinfo); - clipsectcnt = clipsectnum; // should be a nop, "safety"... - } -#endif #ifdef YAX_ENABLE restart_grand: #endif do //Collect sectors inside your square first { -#ifdef HAVE_CLIPSHAPE_FEATURE - if (clipsectcnt>=clipsectnum) - { - // one set of clip-sprite sectors completed, prepare the next - - curspr = (uspriteptr_t)&sprite[clipspritelist[clipspritecnt]]; - curidx = clipshape_idx_for_sprite(curspr, curidx); - - if (curidx < 0) - { - // didn't find matching clipping sectors for sprite - clipspritecnt++; - continue; - } - - clipsprite_initindex(curidx, curspr, &clipsectcnt, pos); - - for (bssize_t i=0; ivec2; - if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE) - getsectordist(closest, k, &closest); - getzsofslope(k,closest.x,closest.y,&daz,&daz2); - - int32_t fz, cz; - closest = pos->vec2; - if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE) - getsectordist(closest, sectq[clipinfo[curidx].qend], &closest); - getzsofslope(sectq[clipinfo[curidx].qend],closest.x,closest.y,&cz,&fz); - - const int hitwhat = (curspr-(uspritetype *)sprite)+49152; - - if ((sector[k].ceilingstat&1)==0) - { - if (pos->z < cz && cz < *florz) { *florz = cz; *florhit = hitwhat; } - if (pos->z > daz && daz > *ceilz) { *ceilz = daz; *ceilhit = hitwhat; } - } - if ((sector[k].floorstat&1)==0) - { - if (pos->z < daz2 && daz2 < *florz) { *florz = daz2; *florhit = hitwhat; } - if (pos->z > fz && fz > *ceilz) { *ceilz = fz; *ceilhit = hitwhat; } - } - } - } -#endif ////////// Walls ////////// auto const startsec = (usectorptr_t)§or[clipsectorlist[clipsectcnt]]; @@ -1843,16 +1100,6 @@ restart_grand: if (wall[j].cstat&dawalclipmask) continue; // XXX? auto const sec = (usectorptr_t)§or[k]; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - { - if (k==sectq[clipinfo[curidx].qend]) - continue; - if ((sec->ceilingstat&1) && (sec->floorstat&1)) - continue; - } - else -#endif if (editstatus == 0) { if (((sec->ceilingstat&1) == 0) && (pos->z <= sec->ceilingz+(3<<8))) continue; @@ -1889,29 +1136,6 @@ restart_grand: else getzsofslope(k, closest.x,closest.y, &daz,&daz2); -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - { - int32_t fz,cz, hitwhat=(curspr-(uspritetype *)sprite)+49152; - - closest = pos->vec2; - if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE) - getsectordist(closest, sectq[clipinfo[curidx].qend], &closest); - getzsofslope(sectq[clipinfo[curidx].qend],closest.x,closest.y,&cz,&fz); - - if ((sec->ceilingstat&1)==0) - { - if (pos->z < cz && cz < *florz) { *florz = cz; *florhit = hitwhat; } - if (pos->z > daz && daz > *ceilz) { *ceilz = daz; *ceilhit = hitwhat; } - } - if ((sec->floorstat&1)==0) - { - if (pos->z < daz2 && daz2 < *florz) { *florz = daz2; *florhit = hitwhat; } - if (pos->z > fz && fz > *ceilz) { *ceilz = fz; *ceilhit = hitwhat; } - } - } - else -#endif { #ifdef YAX_ENABLE int16_t cb, fb; @@ -1935,14 +1159,6 @@ restart_grand: } while (clipsectcnt < clipsectnum || clipspritecnt < clipspritenum); -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - { - engineSetClipMap(NULL, &origmapinfo); // restore original map - clipsectnum = clipspritenum = 0; // skip the next for loop and check afterwards - } -#endif - ////////// Sprites ////////// if (dasprclipmask) @@ -1957,10 +1173,6 @@ restart_grand: { int32_t clipyou = 0; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (clipsprite_try((uspriteptr_t)&sprite[j], xmin,ymin, xmax,ymax)) - continue; -#endif vec2_t v1 = sprite[j].pos.vec2; switch (cstat & CSTAT_SPRITE_ALIGNMENT_MASK) @@ -2041,11 +1253,6 @@ restart_grand: } } -#ifdef HAVE_CLIPSHAPE_FEATURE - if (clipspritenum>0) - goto beginagain; -#endif - #ifdef YAX_ENABLE if (numyaxbunches > 0) { @@ -2264,19 +1471,6 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t * if (inside(x1,y1,sec-(usectortype *)sector) == 1) hit_set(hit, curspr->sectnum, -1, curspr-(uspritetype *)sprite, x1, y1, z1); } -#ifdef HAVE_CLIPSHAPE_FEATURE - else - { - for (i=clipinfo[curidx].qbeg; isectnum, -1, curspr-(uspritetype *)sprite, x1, y1, z1); - break; - } - } - } -#endif } } @@ -2322,46 +1516,10 @@ restart_grand: { int32_t dasector, z, startwall, endwall; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (tempshortcnt >= tempshortnum) - { - // one bunch of sectors completed, prepare the next - if (!curspr) - engineSetClipMap(&origmapinfo, &clipmapinfo); // replace sector and wall with clip map - - curspr = (uspriteptr_t)&sprite[clipspritelist[clipspritecnt]]; - curidx = clipshape_idx_for_sprite(curspr, curidx); - - if (curidx < 0) - { - clipspritecnt++; - continue; - } - - tmp[0] = (intptr_t)curidx; - tmp[1] = (intptr_t)curspr; - tmpptr = tmp; - - clipsprite_initindex(curidx, curspr, &i, sv); // &i is dummy - tempshortnum = (int16_t)clipsectnum; - tempshortcnt = 0; - } -#endif dasector = clipsectorlist[tempshortcnt]; auto const sec = (usectorptr_t)§or[dasector]; i = 1; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - { - if (dasector == sectq[clipinfo[curidx].qend]) - { - i = -1; - tmp[2] = 1; - } - else tmp[2] = 0; - } -#endif if (enginecompatibility_mode != ENGINECOMPATIBILITY_19950829) { if (hitscan_trysector(sv, sec, hit, vx,vy,vz, sec->ceilingstat, sec->ceilingheinum, sec->ceilingz, -i, tmpptr)) @@ -2443,26 +1601,6 @@ restart_grand: } } } -#ifdef HAVE_CLIPSHAPE_FEATURE - else - { - if (wal->cstat&dawalclipmask) - { - hit_set(hit, curspr->sectnum, -1, curspr-(uspritetype *)sprite, intx, inty, intz); - continue; - } - - int32_t cz, fz, daz2; - getzsofslope(nextsector,intx,inty,&daz,&daz2); - getzsofslope(sectq[clipinfo[curidx].qend],intx,inty,&cz,&fz); - // ceil cz daz daz2 fz floor - if ((cz <= intz && intz <= daz) || (daz2 <= intz && intz <= fz)) - { - hit_set(hit, curspr->sectnum, -1, curspr-(uspritetype *)sprite, intx, inty, intz); - continue; - } - } -#endif int zz; for (zz = tempshortnum - 1; zz >= 0; zz--) if (clipsectorlist[zz] == nextsector) break; @@ -2474,10 +1612,6 @@ restart_grand: if (dasprclipmask==0) continue; -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - continue; -#endif for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) { auto const spr = (uspriteptr_t)&sprite[z]; @@ -2488,18 +1622,6 @@ restart_grand: if ((cstat&dasprclipmask) == 0) continue; -#ifdef HAVE_CLIPSHAPE_FEATURE - // try and see whether this sprite's picnum has sector-like clipping data - i = pictoidx[spr->picnum]; - // handle sector-like floor sprites separately - while (i>=0 && (cstat&32) != (clipmapinfo.sector[sectq[clipinfo[i].qbeg]].CM_CSTAT&32)) - i = clipinfo[i].next; - if (i>=0 && clipspritenumx; y1 = spr->y; z1 = spr->z; switch (cstat&CSTAT_SPRITE_ALIGNMENT) { @@ -2599,11 +1721,6 @@ restart_grand: } while (++tempshortcnt < tempshortnum || clipspritecnt < clipspritenum); -#ifdef HAVE_CLIPSHAPE_FEATURE - if (curspr) - engineSetClipMap(NULL, &origmapinfo); -#endif - #ifdef YAX_ENABLE if (numyaxbunches == 0 || editstatus) return 0; diff --git a/source/build/src/common.cpp b/source/build/src/common.cpp index 6b8a4d083..8fe80ee55 100644 --- a/source/build/src/common.cpp +++ b/source/build/src/common.cpp @@ -12,23 +12,6 @@ // def/clipmap handling -#ifdef HAVE_CLIPSHAPE_FEATURE -TArray g_clipMapFiles; -#endif - -void SetClipshapes() -{ -#ifdef HAVE_CLIPSHAPE_FEATURE - // pre-form the default 10 clipmaps - for (int j = '0'; j <= '9'; ++j) - { - char clipshape[16] = "_clipshape0.map"; - - clipshape[10] = j; - g_clipMapFiles.Push(clipshape); - } -#endif -} ////////// @@ -49,21 +32,3 @@ int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens) return T_ERROR; } -////////// - - -// Copy FN to WBUF and append an extension if it's not there, which is checked -// case-insensitively. -// Returns: 1 if not all characters could be written to WBUF, 0 else. -int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char *ext) -{ - const int32_t slen=Bstrlen(fn), extslen=Bstrlen(ext); - const int32_t haveext = (slen>=extslen && Bstrcasecmp(&fn[slen-extslen], ext)==0); - - Bassert((intptr_t)wbuf != (intptr_t)fn); // no aliasing - - // If 'fn' has no extension suffixed, append one. - return (snprintf(wbuf, wbufsiz, "%s%s", fn, haveext ? "" : ext) >= wbufsiz); -} - - diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index a4d675863..34475ee7d 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -2018,9 +2018,6 @@ int32_t enginePreInit(void) #endif -#ifdef HAVE_CLIPSHAPE_FEATURE - engineInitClipMaps(); -#endif preinitcalled = 1; return 0; } @@ -3532,9 +3529,6 @@ static int32_t engineFinishLoadBoard(const vec3_t *dapos, int16_t *dacursectnum, //Must be after loading sectors, etc! updatesector(dapos->x, dapos->y, dacursectnum); -#ifdef HAVE_CLIPSHAPE_FEATURE - if (!quickloadboard) -#endif { Bmemset(spriteext, 0, sizeof(spriteext_t)*MAXSPRITES); #ifndef NEW_MAP_FORMAT diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 863947d63..dd9bf633f 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -105,7 +105,6 @@ FStartupInfo GameStartupInfo; FMemArena dump; // this is for memory blocks than cannot be deallocated without some huge effort. Put them in here so that they do not register on shutdown. InputState inputState; -void SetClipshapes(); int ShowStartupWindow(TArray &); FString GetGameFronUserFiles(); void InitFileSystem(TArray&); @@ -731,7 +730,6 @@ int RunGame() execLogfile(logfile); } I_DetectOS(); - SetClipshapes(); userConfig.ProcessOptions(); G_LoadConfig(); ShutdownENet();