mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Fixes quite a few nasty bugs with the new clipping code, including the crash. Clip shapes are now loaded from _clipshape0.map through _clipshape9.map (no break like when loading tiles, just see if each is present). Mapster32: insert some safety code for sprites with sectnum<0. Because this is still a bad thing, have the m32script corruption checker catch this and run it periodically from EVENT_DRAW2DSCREEN. Also draw such sprites in 2D mode with a blood-red color, and make them draggable. Remove set[sector,wall,sprite] commands.
git-svn-id: https://svn.eduke32.com/eduke32@1722 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4fa07ed4af
commit
a38307a54f
12 changed files with 260 additions and 104 deletions
|
@ -104,7 +104,6 @@ int32_t handleevents(void);
|
|||
extern inline void idle(void);
|
||||
extern inline void idle_waitevent(void);
|
||||
extern inline void idle_waitevent_timeout(uint32_t timeout);
|
||||
extern void debug_sleep(int32_t ms);
|
||||
|
||||
extern void (*keypresscallback)(int32_t,int32_t);
|
||||
extern void (*mousepresscallback)(int32_t,int32_t);
|
||||
|
|
|
@ -444,11 +444,11 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
if (j > k) { k = j; whitecol = i; }
|
||||
}
|
||||
|
||||
k = clipmapinfo_load("_clipshape_.map");
|
||||
k = clipmapinfo_load("_clipshape0.map");
|
||||
if (k==0)
|
||||
initprintf("Loaded sprite clipping map from \"_clipshape_.map\"\n");
|
||||
initprintf("Loaded sprite clipping map.\n");
|
||||
else if (k>0)
|
||||
initprintf("There was an error loading the sprite clipping map from \"_clipshape_.map\" (status %d).\n", k);
|
||||
initprintf("There was an error loading the sprite clipping map (status %d).\n", k);
|
||||
|
||||
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
||||
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
||||
|
@ -2433,7 +2433,10 @@ void overheadeditor(void)
|
|||
sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2)
|
||||
{
|
||||
if (!sub)
|
||||
show2dsprite[i>>3] |= (1<<(i&7));
|
||||
{
|
||||
if (sprite[i].sectnum >= 0) // don't allow to select sprites in null space
|
||||
show2dsprite[i>>3] |= (1<<(i&7));
|
||||
}
|
||||
else
|
||||
show2dsprite[i>>3] &= ~(1<<(i&7));
|
||||
}
|
||||
|
@ -2545,9 +2548,12 @@ void overheadeditor(void)
|
|||
|
||||
setsprite(j,(vec3_t *)&sprite[j]);
|
||||
|
||||
tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2);
|
||||
sprite[j].z = max(sprite[j].z,getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint);
|
||||
sprite[j].z = min(sprite[j].z,getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y));
|
||||
tempint = (tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2;
|
||||
if (sprite[j].sectnum>=0)
|
||||
{
|
||||
sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint);
|
||||
sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2559,8 +2565,11 @@ void overheadeditor(void)
|
|||
|
||||
tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2);
|
||||
|
||||
sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint);
|
||||
sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y));
|
||||
if (sprite[j].sectnum>=0)
|
||||
{
|
||||
sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint);
|
||||
sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y));
|
||||
}
|
||||
}
|
||||
|
||||
if ((pointhighlight&0xc000) == 0)
|
||||
|
@ -2631,7 +2640,7 @@ SKIP:
|
|||
// updatesector(mousxplc,mousyplc,&cursectorhighlight);
|
||||
cursectorhighlight = -1;
|
||||
for (i=0; i<highlightsectorcnt; i++)
|
||||
if (inside(mousxplc, mousyplc, highlightsector[i]))
|
||||
if (inside(mousxplc, mousyplc, highlightsector[i])==1)
|
||||
{
|
||||
cursectorhighlight = highlightsector[i];
|
||||
break;
|
||||
|
@ -2744,15 +2753,15 @@ SKIP:
|
|||
dragpoint(pointhighlight,dax,day);
|
||||
else if ((pointhighlight&0xc000) == 16384)
|
||||
{
|
||||
int32_t daspr = pointhighlight&16383;
|
||||
int32_t daspr=pointhighlight&16383, osec=sprite[daspr].sectnum;
|
||||
vec3_t vec, ovec;
|
||||
|
||||
Bmemcpy(&ovec, (vec3_t *)&sprite[daspr], sizeof(vec3_t));
|
||||
vec.x = dax;
|
||||
vec.y = day;
|
||||
vec.z = sprite[daspr].z;
|
||||
if (setsprite(daspr, &vec) == -1)
|
||||
Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t));
|
||||
if (setsprite(daspr, &vec) == -1 && osec>=0)
|
||||
Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t));
|
||||
/*
|
||||
daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2);
|
||||
|
||||
|
|
|
@ -215,6 +215,10 @@ static int16_t *sectoidx, *sectq; // [numsectors]
|
|||
static int16_t pictoidx[MAXTILES]; // maps tile num to clipinfo[] index
|
||||
static int16_t *tempictoidx;
|
||||
|
||||
static sectortype *loadsector;
|
||||
static walltype *loadwall;
|
||||
static spritetype *loadsprite;
|
||||
|
||||
// sectoidx bits
|
||||
#define CM_NONE (CM_MAX<<1)
|
||||
#define CM_SOME (CM_NONE-1)
|
||||
|
@ -243,10 +247,6 @@ static void clipmapinfo_init()
|
|||
{
|
||||
int32_t i;
|
||||
|
||||
if (clipmapinfo.sector) { Bfree(clipmapinfo.sector); clipmapinfo.sector=NULL; }
|
||||
if (clipmapinfo.wall) { Bfree(clipmapinfo.wall); clipmapinfo.wall=NULL; }
|
||||
clipmapinfo.numsectors = clipmapinfo.numwalls = 0;
|
||||
|
||||
numclipmaps = 0;
|
||||
numclipsects = 0;
|
||||
|
||||
|
@ -256,6 +256,14 @@ static void clipmapinfo_init()
|
|||
|
||||
for (i=0; i<MAXTILES; i++)
|
||||
pictoidx[i]=-1;
|
||||
|
||||
if (loadsector) { Bfree(loadsector); loadsector=NULL; }
|
||||
if (loadwall) { Bfree(loadwall); loadwall=NULL; }
|
||||
if (loadsprite) { Bfree(loadsprite); loadsprite=NULL; }
|
||||
|
||||
clipmapinfo.numsectors = clipmapinfo.numwalls = 0;
|
||||
clipmapinfo.sector=NULL;
|
||||
clipmapinfo.wall=NULL;
|
||||
}
|
||||
|
||||
int32_t clipmapinfo_load(char *filename)
|
||||
|
@ -263,16 +271,94 @@ int32_t clipmapinfo_load(char *filename)
|
|||
int32_t i,k,w, px,py,pz;
|
||||
int16_t ang,cs;
|
||||
|
||||
char fn[BMAX_PATH];
|
||||
int32_t slen, fi, fisec[10], fispr[10];
|
||||
int32_t ournumsectors=0, ournumwalls=0, ournumsprites=0, numsprites;
|
||||
|
||||
clipmapinfo_init();
|
||||
|
||||
loadsector = Bmalloc(MAXSECTORS * sizeof(sectortype));
|
||||
loadwall = Bmalloc(MAXWALLS * sizeof(walltype));
|
||||
loadsprite = Bmalloc(MAXSPRITES * sizeof(spritetype));
|
||||
|
||||
if (!loadsector || !loadwall || !loadsprite)
|
||||
{
|
||||
clipmapinfo_init();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bmemset(fisec, 0, sizeof(fisec));
|
||||
Bmemset(fispr, 0, sizeof(fispr));
|
||||
|
||||
Bstrcpy(fn, filename);
|
||||
slen = Bstrlen(fn);
|
||||
|
||||
quickloadboard = 1;
|
||||
i = loadboard(filename, 0, &px,&py,&pz, &ang,&cs);
|
||||
for (fi='0'; fi<='9'; fi++)
|
||||
{
|
||||
fisec[fi-'0'] = ournumsectors;
|
||||
fispr[fi-'0'] = ournumsprites;
|
||||
|
||||
fn[slen-5] = fi;
|
||||
i = loadboard(fn, 0, &px,&py,&pz, &ang,&cs);
|
||||
if (i<0)
|
||||
continue;
|
||||
|
||||
for (numsprites=0; numsprites<MAXSPRITES; numsprites++)
|
||||
if (sprite[numsprites].statnum == MAXSTATUS)
|
||||
break;
|
||||
|
||||
if (ournumsectors+numsectors>MAXSECTORS ||
|
||||
ournumwalls+numwalls>MAXWALLS ||
|
||||
ournumsprites+numsprites>MAXSPRITES)
|
||||
{
|
||||
initprintf("clip map: warning: exceeded limits when loading %s, aborting.\n", fn);
|
||||
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<ournumsectors+numsectors; i++)
|
||||
loadsector[i].wallptr += ournumwalls;
|
||||
for (i=ournumwalls; i<ournumwalls+numwalls; i++)
|
||||
{
|
||||
if (loadwall[i].point2>=0)
|
||||
loadwall[i].point2 += ournumwalls;
|
||||
if (loadwall[i].nextwall>=0)
|
||||
{
|
||||
loadwall[i].nextwall += ournumwalls;
|
||||
loadwall[i].nextsector += ournumsectors;
|
||||
}
|
||||
}
|
||||
for (i=ournumsprites; i<ournumsprites+numsprites; i++)
|
||||
if (loadsprite[i].sectnum>=0)
|
||||
loadsprite[i].sectnum += ournumsectors;
|
||||
ournumsectors += numsectors;
|
||||
ournumwalls += numwalls;
|
||||
ournumsprites += numsprites;
|
||||
}
|
||||
quickloadboard = 0;
|
||||
if (i<0)
|
||||
return i;
|
||||
|
||||
if (ournumsectors==0 || ournumwalls==0 || ournumsprites==0) // nothing loaded
|
||||
{
|
||||
clipmapinfo_init();
|
||||
return -1;
|
||||
}
|
||||
|
||||
loadsector = Brealloc(loadsector, ournumsectors*sizeof(sectortype));
|
||||
loadwall = Brealloc(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 = Bmalloc(numsectors*sizeof(sectoidx[0]));
|
||||
if (!sectoidx)
|
||||
if (!sectoidx || !sector || !wall)
|
||||
{
|
||||
clipmapinfo_init();
|
||||
return 1;
|
||||
|
@ -333,8 +419,12 @@ int32_t clipmapinfo_load(char *filename)
|
|||
{
|
||||
if (sectoidx[k]&CM_SOME)
|
||||
{
|
||||
initprintf("clip map: error: tried to chain picnum %d (sprite %d) in sector %d which"
|
||||
" already belongs to picnum %d.\n", pn, i, k, clipinfo[sectoidx[k]].picnum);
|
||||
for (fi=0; fi<9; fi++)
|
||||
if (k>=fisec[fi])
|
||||
break;
|
||||
initprintf("clip map %d: error: tried to chain picnum %d (sprite %d) in sector %d which"
|
||||
" already belongs to picnum %d.\n", fi, pn, i-fispr[fi], k-fisec[fi],
|
||||
clipinfo[sectoidx[k]].picnum);
|
||||
clipmapinfo_init();
|
||||
return 2;
|
||||
}
|
||||
|
@ -353,8 +443,11 @@ int32_t clipmapinfo_load(char *filename)
|
|||
{
|
||||
if (sprite[i].ang!=1536 && sprite[i].ang!=512)
|
||||
{
|
||||
initprintf("clip map: warning: sprite %d pointing neither northward nor southward. %s"
|
||||
" will be wrong.", i, (sprite[i].cstat&48)==32 ? "Scaling and flipping" : "X-flipping");
|
||||
for (fi=0; fi<9; fi++)
|
||||
if (i>=fispr[fi])
|
||||
break;
|
||||
initprintf("clip map %d: warning: sprite %d pointing neither northward nor southward. %s will be wrong.\n",
|
||||
fi, i-fispr[fi], (sprite[i].cstat&48)==32 ? "Scaling and flipping" : "X-flipping");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,8 +480,11 @@ int32_t clipmapinfo_load(char *filename)
|
|||
{
|
||||
if (outersect>=0 && ns!=outersect)
|
||||
{
|
||||
initprintf("clip map: error: encountered more than one outer sector"
|
||||
" (%d and %d) for sprite %d.\n", outersect, ns, i);
|
||||
for (fi=0; fi<9; fi++)
|
||||
if (ns>=fisec[fi])
|
||||
break;
|
||||
initprintf("clip map %d: error: encountered more than one outer sector (%d and %d)"
|
||||
" for sprite %d.\n", fi, outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]);
|
||||
clipmapinfo_init();
|
||||
return 3;
|
||||
}
|
||||
|
@ -398,9 +494,12 @@ int32_t clipmapinfo_load(char *filename)
|
|||
}
|
||||
else if (sectoidx[ns]!=numclipmaps)
|
||||
{
|
||||
initprintf("clip map: error: encountered sector %d belonging to index %d"
|
||||
for (fi=0; fi<9; fi++)
|
||||
if (ns>=fisec[fi])
|
||||
break;
|
||||
initprintf("clip map %d: error: encountered sector %d belonging to index %d"
|
||||
" while collecting sectors for sprite %d (index %d).\n",
|
||||
ns, sectoidx[ns], i, numclipmaps);
|
||||
fi, ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps);
|
||||
clipmapinfo_init();
|
||||
return 4;
|
||||
}
|
||||
|
@ -408,6 +507,13 @@ int32_t clipmapinfo_load(char *filename)
|
|||
}
|
||||
} while (++scnt < numclipsects);
|
||||
|
||||
if (outersect==-1)
|
||||
{
|
||||
initprintf("clip map: INTERNAL ERROR: outersect==-1!\n");
|
||||
clipmapinfo_init();
|
||||
return 5;
|
||||
}
|
||||
|
||||
sectq[numclipsects++] = outersect; // last is outer
|
||||
clipinfo[numclipmaps].qend = numclipsects-1;
|
||||
|
||||
|
@ -418,13 +524,13 @@ int32_t clipmapinfo_load(char *filename)
|
|||
{
|
||||
k = sectq[scnt];
|
||||
|
||||
sector[k].floorz -= z;
|
||||
sector[k].ceilingz -= z;
|
||||
|
||||
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
|
||||
|
@ -497,12 +603,14 @@ int32_t clipmapinfo_load(char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
// yes, too much copying, but better than ugly code
|
||||
Bmemcpy(loadsector, sector, ournumsectors*sizeof(sectortype));
|
||||
Bmemcpy(loadwall, wall, ournumwalls*sizeof(walltype));
|
||||
|
||||
clipmapinfo.numsectors = numsectors;
|
||||
clipmapinfo.sector = Bmalloc(numsectors * sizeof(sectortype));
|
||||
Bmemcpy(clipmapinfo.sector, sector, numsectors*sizeof(sectortype));
|
||||
clipmapinfo.sector = loadsector;
|
||||
clipmapinfo.numwalls = numwalls;
|
||||
clipmapinfo.wall = Bmalloc(numwalls * sizeof(walltype));
|
||||
Bmemcpy(clipmapinfo.wall, wall, numwalls*sizeof(walltype));
|
||||
clipmapinfo.wall = loadwall;
|
||||
|
||||
for (i=0; i<MAXTILES; i++)
|
||||
{
|
||||
|
@ -510,7 +618,8 @@ int32_t clipmapinfo_load(char *filename)
|
|||
pictoidx[i]=tempictoidx[i];
|
||||
}
|
||||
|
||||
Bfree(tempictoidx);
|
||||
Bfree(loadsprite); loadsprite=NULL;
|
||||
Bfree(tempictoidx); tempictoidx=NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -9597,7 +9706,11 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
|||
mulxdir = clipsprite_initindex(curidx, curspr, &clipsectcnt, vect);
|
||||
}
|
||||
|
||||
|
||||
dasect = clipsectorlist[clipsectcnt++];
|
||||
//if (curspr)
|
||||
// initprintf("sprite %d/%d: sect %d/%d (%d)\n", clipspritecnt,clipspritenum, clipsectcnt,clipsectnum,dasect);
|
||||
|
||||
sec = §or[dasect];
|
||||
startwall = sec->wallptr; endwall = startwall + sec->wallnum;
|
||||
for (j=startwall,wal=&wall[startwall]; j<endwall; j++,wal++)
|
||||
|
@ -9633,8 +9746,8 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
|||
sec2 = §or[wal->nextsector];
|
||||
if ((sec2->floorstat&1) == 0)
|
||||
// if (dasect==sectq[clipinfo[curidx].qend] || daz2 < daz-(1<<8))
|
||||
if (vect->z <= basez+(flordist-1))
|
||||
if (vect->z >= daz2-(flordist-1)) clipyou = 1;
|
||||
if (daz2-(flordist-1) <= vect->z && vect->z <= basez+(flordist-1))
|
||||
clipyou = 1;
|
||||
if (clipyou == 0)
|
||||
{
|
||||
daz = getceilzofslope((int16_t)dasect,dax,day);
|
||||
|
@ -9642,8 +9755,8 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
|||
basez = getceilzofslope(sectq[clipinfo[curidx].qend],dax,day);
|
||||
if ((sec2->ceilingstat&1) == 0)
|
||||
// if (dasect==sectq[clipinfo[curidx].qend] || daz2 > daz+(1<<8))
|
||||
if (vect->z >= basez-(ceildist-1))
|
||||
if (vect->z <= daz2+(ceildist-1)) clipyou = 1;
|
||||
if (basez-(ceildist-1) <= vect->z && vect->z <= daz2+(ceildist-1))
|
||||
clipyou = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9699,7 +9812,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
|||
day = walldist; if (dx < 0) day = -day;
|
||||
addclipline(x1+dax,y1+day,x2+dax,y2+day,objtype);
|
||||
}
|
||||
else
|
||||
else if (wal->nextsector>=0)
|
||||
{
|
||||
for (i=clipsectnum-1; i>=0; i--)
|
||||
if (wal->nextsector == clipsectorlist[i]) break;
|
||||
|
@ -9836,8 +9949,6 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
|||
break;
|
||||
}
|
||||
}
|
||||
//if (clipspritenum)
|
||||
// initprintf("sect %d/%d sprite %d/%d\n", clipsectcnt,clipsectnum, clipspritecnt,clipspritenum);
|
||||
}
|
||||
while (clipsectcnt < clipsectnum || clipspritecnt < clipspritenum);
|
||||
|
||||
|
@ -11213,11 +11324,6 @@ int32_t sectorofwall(int16_t theline)
|
|||
//
|
||||
int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
||||
{
|
||||
#if defined _WIN32 && defined DEBUGGINGAIDS
|
||||
if (sectnum<0 || sectnum>numsectors)
|
||||
debug_sleep(15000);
|
||||
#endif
|
||||
|
||||
if (!(sector[sectnum].ceilingstat&2)) return(sector[sectnum].ceilingz);
|
||||
|
||||
{
|
||||
|
@ -11238,11 +11344,6 @@ int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
|||
//
|
||||
int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
||||
{
|
||||
#if defined _WIN32 && defined DEBUGGINGAIDS
|
||||
if (sectnum<0 || sectnum>numsectors)
|
||||
debug_sleep(15000);
|
||||
#endif
|
||||
|
||||
if (!(sector[sectnum].floorstat&2)) return(sector[sectnum].floorz);
|
||||
|
||||
{
|
||||
|
@ -11267,11 +11368,6 @@ void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int
|
|||
walltype *wal, *wal2;
|
||||
sectortype *sec;
|
||||
|
||||
#if defined _WIN32 && defined DEBUGGINGAIDS
|
||||
if (sectnum<0 || sectnum>numsectors)
|
||||
debug_sleep(15000);
|
||||
#endif
|
||||
|
||||
sec = §or[sectnum];
|
||||
*ceilz = sec->ceilingz; *florz = sec->floorz;
|
||||
if ((sec->ceilingstat|sec->floorstat)&2)
|
||||
|
@ -12067,19 +12163,27 @@ void draw2dscreen(int32_t posxe, int32_t posye, int16_t ange, int32_t zoome, int
|
|||
faketimerhandler();
|
||||
|
||||
if ((zoome >= 256) || (editstatus == 0))
|
||||
for (i=0; i<numsectors; i++)
|
||||
for (j=headspritesect[i]; j>=0; j=nextspritesect[j])
|
||||
for (j=0; j<MAXSPRITES; j++)
|
||||
if (sprite[j].statnum<MAXSTATUS)
|
||||
// for (i=0; i<numsectors; i++)
|
||||
// for (j=headspritesect[i]; j>=0; j=nextspritesect[j])
|
||||
if ((editstatus == 1) || (show2dsprite[j>>3]&pow2char[j&7]))
|
||||
{
|
||||
col = 3;
|
||||
if (spritecol2d[sprite[j].picnum][0])
|
||||
col = spritecol2d[sprite[j].picnum][0];
|
||||
if ((sprite[j].cstat&1) > 0)
|
||||
if (sprite[j].sectnum<0)
|
||||
col = 4; // red
|
||||
else
|
||||
{
|
||||
col = 5;
|
||||
if (spritecol2d[sprite[j].picnum][1])
|
||||
col = spritecol2d[sprite[j].picnum][1];
|
||||
col = 3;
|
||||
if (spritecol2d[sprite[j].picnum][0])
|
||||
col = spritecol2d[sprite[j].picnum][0];
|
||||
else if ((sprite[j].cstat&1) > 0)
|
||||
{
|
||||
col = 5;
|
||||
if (spritecol2d[sprite[j].picnum][1])
|
||||
col = spritecol2d[sprite[j].picnum][1];
|
||||
}
|
||||
}
|
||||
|
||||
if (editstatus == 1)
|
||||
{
|
||||
if ((pointhighlight-16384) >= 0 && (j+16384 == pointhighlight || ((sprite[j].x == sprite[pointhighlight-16384].x) && (sprite[j].y == sprite[pointhighlight-16384].y))))
|
||||
|
|
|
@ -847,11 +847,6 @@ inline void idle(void)
|
|||
idle_waitevent();
|
||||
}
|
||||
|
||||
void debug_sleep(int32_t ms)
|
||||
{
|
||||
Sleep(ms);
|
||||
}
|
||||
|
||||
//
|
||||
// setjoydeadzone() -- sets the dead and saturation zones for the joystick
|
||||
//
|
||||
|
|
BIN
polymer/eduke32/samples/_clipshape0.map
Normal file
BIN
polymer/eduke32/samples/_clipshape0.map
Normal file
Binary file not shown.
|
@ -23,6 +23,9 @@ define SFACTORSTEPS 100
|
|||
// color of various drawing enhancements
|
||||
define PREVIEW_DRAW_COLOR 11
|
||||
|
||||
// 2d mode corruption checker interval, 120 = 1 second
|
||||
gamevar checkinterval 600 0
|
||||
|
||||
// whether to use overridden aspect/range values when entering 3d mode (software/Polymost).
|
||||
// tweak with keys 7,8,9,0 on the top row
|
||||
gamevar use_custom_aspect 0 0 // this is now the same as r_usenewaspect
|
||||
|
@ -75,6 +78,7 @@ definequote 22 SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d!!!
|
|||
definequote 23 WALL[%d].POINT2=%d out of range: sector[%d].wallptr=%d, endwall=%d!!!
|
||||
definequote 24 WALL[%d].NEXTWALL=%d out of range: numwalls=%d!!!
|
||||
definequote 25 WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d!!!
|
||||
definequote 26 SPRITE[%d].SECTNUM=%d. Expect problems!
|
||||
|
||||
define PRSCALE 1000
|
||||
define MAXSPECULAR 100000
|
||||
|
@ -631,16 +635,6 @@ defstate previewdoors2d
|
|||
}
|
||||
ends
|
||||
|
||||
onevent EVENT_DRAW2DSCREEN
|
||||
ifge cursectnum 0
|
||||
{
|
||||
state connectlocators
|
||||
state draw_prlightprojections
|
||||
}
|
||||
|
||||
state previewdoors2d
|
||||
endevent
|
||||
|
||||
|
||||
// LOCATORS auto-incrementer
|
||||
onevent EVENT_INSERTSPRITE2D
|
||||
|
@ -1073,8 +1067,40 @@ defstate corruptchk
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i allsprites
|
||||
{
|
||||
ifl .sectnum 0
|
||||
{
|
||||
qsprintf TQUOTE 26 i .sectnum
|
||||
quote TQUOTE printmessage16 TQUOTE
|
||||
}
|
||||
}
|
||||
ends
|
||||
|
||||
|
||||
gamevar d2d_lastcheck 0 0
|
||||
onevent EVENT_DRAW2DSCREEN
|
||||
var tmp
|
||||
|
||||
ifge cursectnum 0
|
||||
{
|
||||
state connectlocators
|
||||
state draw_prlightprojections
|
||||
}
|
||||
|
||||
state previewdoors2d
|
||||
|
||||
ifl checkinterval 120, set checkinterval 120
|
||||
set tmp totalclock, sub tmp checkinterval
|
||||
ifl d2d_lastcheck tmp
|
||||
{
|
||||
set d2d_lastcheck totalclock
|
||||
state corruptchk
|
||||
}
|
||||
endevent
|
||||
|
||||
|
||||
defstate mkterrain
|
||||
var w2 w3 idx bit tmp sec
|
||||
var warned
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
|
||||
Sprite picnums can be assigned to a bunch of connected sectors so that
|
||||
clipping against these sprites will work as if it is carried out on the
|
||||
associated sectors. For this, a file named _clipshape_.map must be present
|
||||
at program start time that must be built to certain rules:
|
||||
associated sectors. For this, files named _clipshapeX.map (where X is
|
||||
in 0..9) should be present at program start time. Every such map must be
|
||||
built to certain rules, and loading many of them has the same effect as
|
||||
loading a single map with all sectors/walls/sprites thrown together.
|
||||
|
||||
* Every sector that contains at least one white wall is considered an "outer" sector.
|
||||
Conversely, sectors with only red walls are "inner" (clipping) sectors.
|
||||
|
@ -25,21 +27,25 @@ at program start time that must be built to certain rules:
|
|||
orientation).
|
||||
|
||||
* The sprites in inner sectors should point northward and should not have any orientation-
|
||||
changing bits like x-flip or y-flip set. Setting centering is permitted, though.
|
||||
changing bits like x-flip or y-flip set. Setting centering and a custom size is permitted,
|
||||
though.
|
||||
|
||||
* A set of picnums can be aliased to a layer. This is useful if "secondary" picnums
|
||||
are going to be used as decoration, for example. For this, set lotags and/or hitags
|
||||
of any wall of an inner sector to the picnums to be aliased to values greater than 0.
|
||||
If only one of them is set, it is taken as one picnum, otherwise as a both-sided inclusive
|
||||
of any wall of an inner sector to the picnums to be aliased to layer containing the wall.
|
||||
If only one of them is set, it is taken as a picnum, otherwise as a both-sided inclusive
|
||||
range, the order doesn't matter. The pigcop tank is present as an example in
|
||||
samples/_clipshape_.map.
|
||||
samples/_clipshape_.map. If a picnum has multiple layers, it is advisable to set the same
|
||||
lotags/hitags for each layer. Note that you do not need to set tags unless you intend to
|
||||
have more than one picnum to share a clipping shape.
|
||||
|
||||
* The inner sectors of a given layer must be all interconnected (not necessarily directly)
|
||||
and for a layer there must be a unique outer sector.
|
||||
|
||||
* Making the floor or ceiling of a sector parallaxed will disable clipping on it in certain
|
||||
ways. Normally, there are four horizontal clipping planes (see the round table for an
|
||||
example). Making the ceiling parallaxed disables the upper two, and analogously for the floor.
|
||||
ways. Normally, there are four horizontal clipping planes per inner sector (see the round
|
||||
table for an example). Making the ceiling parallaxed disables the upper two, and analogously
|
||||
for the floor.
|
||||
|
||||
* Making a sprite transparent will disable rotation around its origin to match a given sprite's
|
||||
angle. Use it on models with rotational symmetry.
|
||||
|
@ -48,7 +54,6 @@ at program start time that must be built to certain rules:
|
|||
Notes:
|
||||
------
|
||||
|
||||
* Only clipmove and getzrange are changed, so that hitscan weapons will still behave the old way.
|
||||
* The clipping will not change with rendering modes or options.
|
||||
|
||||
|
||||
|
@ -56,8 +61,12 @@ Known bugs:
|
|||
-----------
|
||||
|
||||
* Flipping doesn't work correctly
|
||||
* The behaviour in Mapster32 and EDuke32 differs slightly, see the
|
||||
round table arrangement in the test area of _clipshape_.map
|
||||
|
||||
|
||||
Predicted bugs:
|
||||
---------------
|
||||
|
||||
* Clipping may not work across playing map sector boundaries, especially with large sprites.
|
||||
|
||||
|
||||
--Helixhorned
|
||||
|
|
|
@ -2082,7 +2082,7 @@ static void M32_MoveFX(void)
|
|||
S_StopEnvSound(s->lotag, i);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (s->sectnum>=0)
|
||||
{
|
||||
ht = s->hitag;
|
||||
|
||||
|
@ -9152,6 +9152,9 @@ void ExtPreCheckKeys(void) // just before drawrooms
|
|||
int32_t start_wall = sector[isec].wallptr;
|
||||
int32_t end_wall = start_wall + sector[isec].wallnum;
|
||||
|
||||
if (isec<0)
|
||||
continue;
|
||||
|
||||
for (w = start_wall; w < end_wall; w++)
|
||||
{
|
||||
if (!wallflag[w])
|
||||
|
@ -9517,6 +9520,9 @@ void ExtAnalyzeSprites(void)
|
|||
|
||||
if (shadepreview && !(tspr->cstat & 16))
|
||||
{
|
||||
if (tspr->sectnum<0)
|
||||
continue;
|
||||
|
||||
if (sector[tspr->sectnum].ceilingstat&1)
|
||||
{
|
||||
l = sector[tspr->sectnum].ceilingshade;
|
||||
|
@ -9804,6 +9810,9 @@ void ExtCheckKeys(void)
|
|||
int32_t start_wall = sector[isec].wallptr;
|
||||
int32_t end_wall = start_wall + sector[isec].wallnum;
|
||||
|
||||
if (isec<0)
|
||||
continue;
|
||||
|
||||
for (w = start_wall; w < end_wall; w++)
|
||||
{
|
||||
if (wallflag[w])
|
||||
|
@ -10448,7 +10457,7 @@ static void EditSpriteData(int16_t spritenum)
|
|||
if (editval)
|
||||
{
|
||||
printmessage16(edittext);
|
||||
i = getnumber16(edittext,sprite[spritenum].sectnum,MAXSECTORS-1,0);
|
||||
i = getnumber16(edittext,sprite[spritenum].sectnum,numsectors-1,0);
|
||||
if (i != sprite[spritenum].sectnum)
|
||||
changespritesect(spritenum,i);
|
||||
}
|
||||
|
|
|
@ -9859,11 +9859,11 @@ CLEAN_DIRECTORY:
|
|||
Bfree(ptr);
|
||||
}
|
||||
|
||||
i = clipmapinfo_load("_clipshape_.map");
|
||||
i = clipmapinfo_load("_clipshape0.map");
|
||||
if (i==0)
|
||||
initprintf("Loaded sprite clipping map from \"_clipshape_.map\"\n");
|
||||
initprintf("Loaded sprite clipping map.\n");
|
||||
else if (i>0)
|
||||
initprintf("There was an error loading the sprite clipping map from \"_clipshape_.map\" (status %d).\n", i);
|
||||
initprintf("There was an error loading the sprite clipping map (status %d).\n", i);
|
||||
|
||||
OSD_Exec("autoexec.cfg");
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ const char *keyw[] =
|
|||
"jump",
|
||||
"{",
|
||||
"}",
|
||||
|
||||
#if 0
|
||||
"setsector",
|
||||
"getsector",
|
||||
"setwall",
|
||||
|
@ -198,7 +198,7 @@ const char *keyw[] =
|
|||
"getsprite",
|
||||
"gettspr",
|
||||
"settspr",
|
||||
|
||||
#endif
|
||||
"gamearray",
|
||||
"setarray",
|
||||
"getarraysize",
|
||||
|
@ -2387,6 +2387,7 @@ repeatcase:
|
|||
return 1;
|
||||
|
||||
// *** more basic commands
|
||||
#if 0
|
||||
case CON_SETSECTOR:
|
||||
case CON_GETSECTOR:
|
||||
case CON_SETWALL:
|
||||
|
@ -2463,6 +2464,7 @@ repeatcase:
|
|||
C_GetNextVar();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case CON_GAMEVAR:
|
||||
// syntax: gamevar <var1> <initial value> <flags>
|
||||
|
|
|
@ -270,6 +270,7 @@ enum ScriptKeywords_t
|
|||
CON_LEFTBRACE,
|
||||
CON_RIGHTBRACE,
|
||||
|
||||
#if 0
|
||||
// more basic commands
|
||||
CON_SETSECTOR,
|
||||
CON_GETSECTOR,
|
||||
|
@ -279,6 +280,7 @@ enum ScriptKeywords_t
|
|||
CON_GETSPRITE, //+
|
||||
CON_GETTSPR,
|
||||
CON_SETTSPR,
|
||||
#endif
|
||||
|
||||
// arrays
|
||||
CON_GAMEARRAY,
|
||||
|
|
|
@ -55,7 +55,7 @@ instype *insptr;
|
|||
int32_t VM_Execute(int32_t once);
|
||||
static instype *x_sortingstateptr;
|
||||
|
||||
#include "m32structures.c"
|
||||
//#include "m32structures.c"
|
||||
|
||||
extern void message(const char *fmt, ...);
|
||||
|
||||
|
@ -492,6 +492,7 @@ skip_check:
|
|||
VM_Execute(0);
|
||||
continue;
|
||||
|
||||
#if 0
|
||||
// *** more basic commands
|
||||
case CON_SETSECTOR:
|
||||
case CON_GETSECTOR:
|
||||
|
@ -535,7 +536,7 @@ skip_check:
|
|||
VM_AccessTsprite((tw==CON_SETTSPR)|2|4, lVar1, lLabelID, lVar2);
|
||||
continue;
|
||||
}
|
||||
#if 0
|
||||
|
||||
case CON_SETSPRITE:
|
||||
insptr++;
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue