Too much stuff for one commit.

engine:
* sector-like sprite clipping now works with x- xor y-flipped actual sprites

mapster32:
* corruption checker has been hooked up to loading/saving routines to inform/warn the user
* also warn if mouse pointer is over corrupt wall which is shown in pink then: you should not move such a wall!
* faster map loading by deferring polymer_loadboard to 3d mode entrance (also removes some 'glGetTexLevelParameteriv returned GL_FALSE' warnings)
* more logical maphack light handling, the logic is still a bit dodgy though
* some menu and misc. function fixup
* redundancy elimination...

API:
* added consts various for 'char *filename' parameters
* loadboard() now accepts bit 4 for flags (formerly 'fromwhere')

git-svn-id: https://svn.eduke32.com/eduke32@1760 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-01-16 00:23:39 +00:00
parent 8d01b7f403
commit 51eb2c7cd3
11 changed files with 749 additions and 537 deletions

View file

@ -435,13 +435,14 @@ int32_t preinitengine(void); // a partial setup of the engine used for launch
int32_t initengine(void);
void uninitengine(void);
void initspritelists(void);
int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
int32_t loadmaphack(char *filename);
int32_t clipmapinfo_load(char *filename);
int32_t saveboard(char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
int32_t loadpics(char *filename, int32_t askedsize);
int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
int32_t loadmaphack(const char *filename);
void delete_maphack_lights();
int32_t clipmapinfo_load(const char *filename);
int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
int32_t loadpics(const char *filename, int32_t askedsize);
void loadtile(int16_t tilenume);
int32_t qloadkvx(int32_t voxindex, char *filename);
int32_t qloadkvx(int32_t voxindex, const char *filename);
int32_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
void makepalookup(int32_t palnum, char *remapbuf, int8_t r, int8_t g, int8_t b, char dastat);
@ -491,6 +492,7 @@ void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUT
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day);
void setfirstwall(int16_t sectnum, int16_t newfirstwall);
int32_t checksectorpointer(int16_t i, int16_t sectnum);
void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) ATTRIBUTE((nonnull(1,2,3)));
int32_t krand(void);
@ -563,7 +565,7 @@ int32_t changespritesect(int16_t spritenum, int16_t newsectnum);
int32_t changespritestat(int16_t spritenum, int16_t newstatnum);
int32_t setsprite(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2)));
int32_t screencapture(char *filename, char inverseit) ATTRIBUTE((nonnull(1)));
int32_t screencapture(const char *filename, char inverseit) ATTRIBUTE((nonnull(1)));
int32_t getclosestcol(int32_t r, int32_t g, int32_t b);
@ -648,7 +650,7 @@ void hicinit(void);
// effect bitset: 1 = greyscale, 2 = invert
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect);
// flags bitset: 1 = don't compress
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags);
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags);
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]);
int32_t hicclearsubst(int32_t picnum, int32_t palnum);
@ -688,7 +690,7 @@ int32_t md_definehud (int32_t modelid, int32_t tilex, double xadd, double yadd,
int32_t md_undefinetile(int32_t tile);
int32_t md_undefinemodel(int32_t modelid);
int32_t loaddefinitionsfile(char *fn);
int32_t loaddefinitionsfile(const char *fn);
extern int32_t mapversion; // if loadboard() fails with -2 return, try loadoldboard(). if it fails with -2, board is dodgy
int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);

View file

@ -106,6 +106,15 @@ extern void ExtEditWallData(int16_t wallnum);
extern void ExtEditSpriteData(int16_t spritenum);
extern const char *ExtGetSectorType(int32_t lotag);
extern int32_t LoadBoard(const char *filename, uint32_t flags);
extern const char *SaveBoard(const char *fn, uint32_t flags);
#define CORRUPT_SECTOR (1<<17)
#define CORRUPT_WALL (1<<18)
#define CORRUPT_SPRITE (1<<19)
#define CORRUPT_MASK (CORRUPT_SECTOR|CORRUPT_WALL|CORRUPT_SPRITE)
#define MAXCORRUPTTHINGS 64
extern int32_t numcorruptthings, corruptthings[MAXCORRUPTTHINGS];
extern int32_t autocorruptcheck;
extern int32_t CheckMapCorruption(int32_t printfromlev);

File diff suppressed because it is too large Load diff

View file

@ -629,6 +629,9 @@ int32_t kopen4load(const char *filename, char searchfirst)
char bad, *gfileptr;
intptr_t i;
if (filename==NULL)
return -1;
while (filehan[newhandle] != -1)
{
newhandle--;

View file

@ -1908,7 +1908,7 @@ static int32_t defsparser(scriptfile *script)
}
int32_t loaddefinitionsfile(char *fn)
int32_t loaddefinitionsfile(const char *fn)
{
scriptfile *script;
int32_t f = flushlogwindow;

View file

@ -168,6 +168,10 @@ qlz_state_decompress *state_decompress = NULL;
int32_t whitecol;
#ifdef POLYMER
static int16_t maphacklightcnt=0;
static int16_t maphacklight[PR_MAXLIGHTS];
#endif
////////// editor side view //////////
int32_t m32_sideview = 0;
@ -230,7 +234,7 @@ static int16_t pictoidx[MAXTILES]; // maps tile num to clipinfo[] index
static int16_t *tempictoidx;
static sectortype *loadsector;
static walltype *loadwall;
static walltype *loadwall, *loadwallinv;
static spritetype *loadsprite;
// sectoidx bits
@ -273,6 +277,7 @@ static void clipmapinfo_init()
if (loadsector) { Bfree(loadsector); loadsector=NULL; }
if (loadwall) { Bfree(loadwall); loadwall=NULL; }
if (loadwallinv) { Bfree(loadwallinv); loadwallinv=NULL; }
if (loadsprite) { Bfree(loadsprite); loadsprite=NULL; }
clipmapinfo.numsectors = clipmapinfo.numwalls = 0;
@ -285,7 +290,7 @@ static void clipmapinfo_init()
// loads the clip maps 0 through 9.
// this should be called before any real map is loaded.
int32_t clipmapinfo_load(char *filename)
int32_t clipmapinfo_load(const char *filename)
{
int32_t i,k,w, px,py,pz;
int16_t ang,cs;
@ -635,6 +640,56 @@ int32_t clipmapinfo_load(char *filename)
Bmemcpy(loadsector, sector, ournumsectors*sizeof(sectortype));
Bmemcpy(loadwall, wall, ournumwalls*sizeof(walltype));
// loadwallinv will contain all walls with inverted orientation for x/y-flip handling
loadwallinv = Bmalloc(ournumwalls*sizeof(walltype));
if (!loadwallinv)
{
clipmapinfo_init();
return 1;
}
{
int32_t j, loopstart, loopend, numloopwalls;
// invert walls!
loopstart = 0;
for (j=0; j<ournumwalls; j++)
{
wall[j].nextsector = wall[j].nextwall = -1;
if (wall[j].point2 < j)
{
loopend = j+1;
numloopwalls = loopend-loopstart;
if (numloopwalls<3)
{
loopstart = loopend;
continue;
}
for (k=0; k<numloopwalls; k++)
{
wall[loopstart+k].x = loadwall[loopstart + (numloopwalls+1-k)%numloopwalls].x;
wall[loopstart+k].y = loadwall[loopstart + (numloopwalls+1-k)%numloopwalls].y;
CM_WALL_X(loopstart+k) = wall[loopstart+k].x;
CM_WALL_Y(loopstart+k) = wall[loopstart+k].y;
}
loopstart = loopend;
}
}
// reconstruct wall connections
for (i=0; i<ournumsectors; i++)
{
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
checksectorpointer(j, i);
}
}
Bmemcpy(loadwallinv, wall, ournumwalls*sizeof(walltype));
clipmapinfo.numsectors = numsectors;
clipmapinfo.sector = loadsector;
clipmapinfo.numwalls = numwalls;
@ -652,6 +707,7 @@ int32_t clipmapinfo_load(char *filename)
// don't let other code be distracted by the temporary map we constructed
numsectors = 0;
numwalls = 0;
initspritelists();
initprintf("Loaded clip map%s %s.\n", lwcp==loadedwhich+1?"":"s", loadedwhich);
@ -661,6 +717,61 @@ int32_t clipmapinfo_load(char *filename)
////// //////
int32_t checksectorpointer(int16_t i, int16_t sectnum)
{
int32_t j, k, startwall, endwall, x1, y1, x2, y2, numnewwalls=0;
#if 0
if (checksectorpointer_warn && (i<0 || i>=max(numwalls,newnumwalls)))
{
char buf[128];
Bsprintf(buf, "WARN: checksectorpointer called with i=%d but (new)numwalls=%d", i, max(numwalls,newnumwalls));
OSD_Printf("%s\n", buf);
printmessage16("%s", buf);
return 0;
}
#endif
x1 = wall[i].x;
y1 = wall[i].y;
x2 = (wall[wall[i].point2]).x;
y2 = (wall[wall[i].point2]).y;
if (wall[i].nextwall >= 0) //Check for early exit
{
k = wall[i].nextwall;
if (wall[k].x == x2 && wall[k].y == y2)
if ((wall[wall[k].point2]).x == x1 && (wall[wall[k].point2]).y == y1)
return(0);
}
wall[i].nextsector = -1;
wall[i].nextwall = -1;
for (j=0; j<numsectors; j++)
{
startwall = sector[j].wallptr;
endwall = startwall + sector[j].wallnum - 1;
for (k=startwall; k<=endwall; k++)
{
if (wall[k].x == x2 && wall[k].y == y2)
if ((wall[wall[k].point2]).x == x1 && (wall[wall[k].point2]).y == y1)
if (j != sectnum)
{
if (sectnum != -2) // -2 means dry run
{
wall[i].nextsector = j;
wall[i].nextwall = k;
wall[k].nextsector = sectnum;
wall[k].nextwall = i;
}
numnewwalls++;
}
}
}
return(numnewwalls);
}
#if defined(_MSC_VER) && !defined(NOASM)
//
@ -7087,14 +7198,19 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
//
// loadboard
//
int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz,
// flags: 1, 2: former parameter "fromwhere"
// 4: don't call polymer_loadboard
int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum)
{
int16_t fil, i, numsprites, dq[MAXSPRITES], dnum = 0;
char myflags = flags&(~3);
flags &= 3;
i = strlen(filename)-1;
if (filename[i] == 255) { filename[i] = 0; fromwhere = 1; } // JBF 20040119: "compatibility"
if ((fil = kopen4load(filename,fromwhere)) == -1)
if (filename[i] == 255) { filename[i] = 0; flags = 1; } // JBF 20040119: "compatibility"
if ((fil = kopen4load(filename,flags)) == -1)
{ mapversion = 7L; return(-1); }
kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion);
@ -7261,7 +7377,10 @@ int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *dapo
# ifdef POLYMER
if (rendmode == 4)
polymer_loadboard();
{
if ((myflags&4)==0)
polymer_loadboard();
}
#endif
#endif
}
@ -7728,12 +7847,26 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d
return(0);
}
#ifdef POLYMER
void delete_maphack_lights()
{
int32_t i;
for (i=0; i<maphacklightcnt; i++)
{
polymer_deletelight(maphacklight[i]);
maphacklight[i] = -1;
}
maphacklightcnt = 0;
}
#else
void delete_maphack_lights() {}
#endif
//
// loadmaphack
//
#if defined(POLYMOST) && defined(USE_OPENGL)
int32_t loadmaphack(char *filename)
int32_t loadmaphack(const char *filename)
{
enum
{
@ -7781,6 +7914,11 @@ int32_t loadmaphack(char *filename)
int32_t whichsprite = -1;
static char fn[BMAX_PATH];
#ifdef POLYMER
for (i=0; i<PR_MAXLIGHTS; i++)
maphacklight[i] = -1;
#endif
if (filename)
{
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
@ -7955,6 +8093,7 @@ int32_t loadmaphack(char *filename)
case T_LIGHT: // light sector x y z range r g b radius faderadius angle horiz minshade maxshade priority tilenum
{
int32_t value;
int16_t lightid;
#pragma pack(push,1)
_prlight light;
#pragma pack(pop)
@ -7992,7 +8131,11 @@ int32_t loadmaphack(char *filename)
light.tilenum = value;
if (rendmode == 4)
polymer_addlight(&light);
{
lightid = polymer_addlight(&light);
if (lightid>=0)
maphacklight[maphacklightcnt++] = lightid;
}
break;
}
@ -8015,7 +8158,7 @@ int32_t loadmaphack(char *filename) { UNREFERENCED_PARAMETER(filename); return -
//
// saveboard
//
int32_t saveboard(char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum)
{
int16_t fil, i, j, numsprites, ts;
@ -8028,7 +8171,10 @@ int32_t saveboard(char *filename, int32_t *daposx, int32_t *daposy, int32_t *dap
spritetype *spri;
if ((fil = Bopen(filename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
{
initprintf("Couldn't open \"%s\" for writing: %s\n", filename, strerror(errno));
return(-1);
}
for (j=0; j<MAXSPRITES; j++)if ((unsigned)sprite[j].statnum>MAXSTATUS)
{
@ -8362,7 +8508,7 @@ void nextpage(void)
//
// loadpics
//
int32_t loadpics(char *filename, int32_t askedsize)
int32_t loadpics(const char *filename, int32_t askedsize)
{
int32_t offscount, localtilestart, localtileend, dasiz;
int16_t fil, i, j, k;
@ -8613,7 +8759,7 @@ void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, in
// qloadkvx
//
#ifdef SUPERBUILD
int32_t qloadkvx(int32_t voxindex, char *filename)
int32_t qloadkvx(int32_t voxindex, const char *filename)
{
int32_t i, fil, dasiz, lengcnt, lengtot;
char *ptr;
@ -9602,7 +9748,11 @@ static int32_t clipsprite_initindex(int32_t curidx, spritetype *curspr, int32_t
rotang = (curspr->ang - sector[j].CM_ANG)&2047;
dorot = !CM_NOROTS(j);
if (dorot)
{
flipmul = flipx*flipy;
if (flipmul==-1)
wall = loadwallinv;
}
if ((curspr->cstat&128) != (sector[j].CM_CSTAT&128))
daz += (((curspr->cstat&128)>>6)-1)*(((int32_t)tilesizy[curspr->picnum]*(int32_t)curspr->yrepeat)<<1);
@ -9633,9 +9783,6 @@ static int32_t clipsprite_initindex(int32_t curidx, spritetype *curspr, int32_t
wal->x += curspr->x;
wal->y += curspr->y;
if (flipmul==-1)
wal->x = vect->x - (wal->x-vect->x);
}
if (inside(vect->x, vect->y, j)==1)
@ -9679,7 +9826,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
int32_t hitwall, cnt, clipyou;
spritetype *curspr=NULL; // non-NULL when handling sprite with sector-like clipping
int32_t curidx=-1, warned=0, clipspritecnt, mulxdir=1;
int32_t curidx=-1, warned=0, clipspritecnt;
if (((xvect|yvect) == 0) || (*sectnum < 0)) return(0);
retval = 0;
@ -9741,7 +9888,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
continue;
}
mulxdir = clipsprite_initindex(curidx, curspr, &clipsectcnt, vect);
clipsprite_initindex(curidx, curspr, &clipsectcnt, vect);
}
@ -9775,7 +9922,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
{
int32_t basez;
if (rintersect(vect->x,vect->y,0, gx*mulxdir,gy,0, x1,y1, x2,y2, &dax,&day,&daz) == 0)
if (rintersect(vect->x,vect->y,0, gx,gy,0, x1,y1, x2,y2, &dax,&day,&daz) == 0)
dax = vect->x, day = vect->y;
daz = getflorzofslope((int16_t)dasect,dax,day);
daz2 = getflorzofslope(wal->nextsector,dax,day);
@ -9826,20 +9973,10 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
if (!curspr)
objtype = (int16_t)j+32768;
else
{
objtype = (int16_t)(curspr-sprite)+49152;
if (mulxdir==-1)
{
x1 = vect->x - (x1-vect->x);
x2 = vect->x - (x2-vect->x);
swaplong(&x1,&x2);
swaplong(&y1,&y2);
dx *= -1;
}
}
//Add 2 boxes at endpoints
bsz = walldist; if (gx*mulxdir < 0) bsz = -bsz;
bsz = walldist; if (gx < 0) bsz = -bsz;
addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,objtype);
addclipline(x2-bsz,y2-bsz,x2-bsz,y2+bsz,objtype);
bsz = walldist; if (gy < 0) bsz = -bsz;
@ -12802,10 +12939,25 @@ void draw2dscreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int32_t z
int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize)
{
int32_t stx, i, x, y, charxsiz, ocol = col, obackcol = backcol;
int32_t ymin=0, ymax=7;
char *fontptr, *letptr, *ptr;
char smallbuf[4];
stx = xpos;
if (ypos<0)
{
ymin = 0-ypos;
if (ymin>7)
return 0;
}
else if (ypos+7 >= ydim)
{
ymax = ydim-ypos-1;
if (ymax<0)
return 0;
}
if (fontsize & 2) printext16(xpos+1, ypos+1, 0, -1, name, (fontsize & ~2) | 4);
if (fontsize & 1) { fontptr = smalltextfont; charxsiz = 4; }
else { fontptr = textfont; charxsiz = 8; }
@ -12880,20 +13032,30 @@ int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, con
}
}
letptr = &fontptr[name[i]<<3];
ptr = (char *)(bytesperline*(ypos+7)+(stx-(fontsize&1))+frameplace);
for (y=7; y>=0; y--)
if (stx<0)
{
for (x=charxsiz-1; x>=0; x--)
stx += charxsiz;
continue;
}
letptr = &fontptr[name[i]<<3];
ptr = (char *)(bytesperline*ypos + (stx-(fontsize&1)) + frameplace);
for (y=ymin; y<=ymax; y++)
{
for (x=0; x<charxsiz; x++)
{
if (stx+x >= xdim)
break;
if (letptr[y]&pow2char[7-(fontsize&1)-x])
ptr[x] = (uint8_t)col;
else if (backcol >= 0)
ptr[x] = (uint8_t)backcol;
}
ptr -= bytesperline;
ptr += bytesperline;
}
stx += charxsiz;
if (stx >= xdim)
break;
}
enddrawing(); //}}}
@ -13021,7 +13183,7 @@ void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const
//
// screencapture
//
int32_t screencapture_tga(char *filename, char inverseit)
int32_t screencapture_tga(const char *filename, char inverseit)
{
int32_t i,j;
char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 };
@ -13203,7 +13365,7 @@ static void writepcxline(char *buf, int32_t bytes, int32_t step, BFILE *fp)
if (bytes&1) writepcxbyte(0, 1, fp);
}
int32_t screencapture_pcx(char *filename, char inverseit)
int32_t screencapture_pcx(const char *filename, char inverseit)
{
int32_t i,j,bpl;
char *ptr, head[128];
@ -13339,7 +13501,7 @@ int32_t screencapture_pcx(char *filename, char inverseit)
return(0);
}
int32_t screencapture(char *filename, char inverseit)
int32_t screencapture(const char *filename, char inverseit)
{
if (captureformat == 0) return screencapture_tga(filename,inverseit);
else return screencapture_pcx(filename,inverseit);

View file

@ -117,7 +117,7 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect)
// hicsetsubsttex(picnum,pal,filen,alphacut)
// Specifies a replacement graphic file for an ART tile.
//
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags)
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags)
{
hicreplctyp *hr, *hrn;
@ -296,7 +296,7 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
#include "inttypes.h"
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect) { }
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut) { return 0; }
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut) { return 0; }
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]) { return 0; }
int32_t hicclearsubst(int32_t picnum, int32_t palnum) { return 0; }

View file

@ -57,12 +57,6 @@ Notes:
* The clipping will not change with rendering modes or options.
Known bugs:
-----------
* Flipping doesn't work correctly
Predicted bugs:
---------------

View file

@ -101,6 +101,9 @@ int32_t showambiencesounds=2;
int32_t autocorruptcheck = 0;
static int32_t corruptchecktimer;
static int32_t curcorruptthing=-1;
int32_t numcorruptthings=0, corruptthings[MAXCORRUPTTHINGS];
static uint32_t templenrepquot;
static void fixxrepeat(int16_t i, uint32_t lenrepquot)
@ -192,6 +195,17 @@ static int16_t tilemarked[(MAXTILES+7)>>3];
#ifdef POLYMER
static int16_t spritelightid[MAXSPRITES];
_prlight *spritelightptr[MAXSPRITES];
static void DeletePolymerLights()
{
int32_t i;
for (i=0; i<MAXSPRITES; i++)
if (spritelightptr[i] != NULL)
{
polymer_deletelight(spritelightid[i]);
spritelightptr[i] = NULL;
}
}
#endif
extern int32_t graphicsmode;
@ -5508,12 +5522,7 @@ static void Keys3d(void)
S_ClearSoundLocks();
#ifdef POLYMER
for (i=0; i<MAXSPRITES; i++)
if (spritelightptr[i] != NULL)
{
polymer_deletelight(spritelightid[i]);
spritelightptr[i] = NULL;
}
DeletePolymerLights();
#endif
}
@ -5540,12 +5549,7 @@ static void Keys3d(void)
message("Map shade preview %s", shadepreview?"enabled":"disabled");
#ifdef POLYMER
for (i=0; i<MAXSPRITES; i++)
if (spritelightptr[i] != NULL)
{
polymer_deletelight(spritelightid[i]);
spritelightptr[i] = NULL;
}
DeletePolymerLights();
#endif
}
@ -6593,7 +6597,7 @@ static void Keys3d(void)
static void DoSpriteSearch(int32_t dir) // <0: backwards, >=0: forwards
{
char did_wrap = 0;
char did_wrap = 0, outofgrid=0;
int32_t i, j, k = 0;
dir = 1-2*(dir<0);
@ -6672,12 +6676,20 @@ static void DoSpriteSearch(int32_t dir) // <0: backwards, >=0: forwards
}
// found matching sprite
pos.x = sprite[gs_cursprite].x;
pos.y = sprite[gs_cursprite].y;
ang = sprite[gs_cursprite].ang;
if (pos.x >= -editorgridextent && pos.x <= editorgridextent &&
pos.y >= -editorgridextent && pos.y <= editorgridextent)
{
pos.x = sprite[gs_cursprite].x;
pos.y = sprite[gs_cursprite].y;
if (pos.z >= -editorgridextent<<4 && pos.z <= editorgridextent<<4)
pos.z = sprite[gs_cursprite].z;
ang = sprite[gs_cursprite].ang;
}
else
outofgrid = 1;
printmessage16("%s Sprite seach%s: found sprite %d", dir<0 ? "<" : ">",
did_wrap ? " (wrap)" : "", gs_cursprite);
printmessage16("%s Sprite seach%s: found sprite %d%s", dir<0 ? "<" : ">",
did_wrap ? " (wrap)" : "", gs_cursprite, outofgrid?"(outside grid)":"");
did_wrap = 0;
return;
@ -6694,19 +6706,20 @@ static void Keys2d(void)
int32_t i=0, j, k;
int32_t smooshy, changedir;
static int32_t repeatcnt[2] = {0,0}; // was repeatcountx, repeatcounty
int32_t tcursectornum;
// for(i=0;i<0x50;i++) if(keystatus[i]==1) Bsprintf(tempbuf,"key %d",i); printmessage16(tempbuf);
cursectornum = -1;
tcursectornum = -1;
for (i=0; i<numsectors; i++)
{
if (inside(mousxplc,mousyplc,i) == 1)
{
cursectornum = i;
tcursectornum = i;
break;
}
}
searchsector = cursectornum;
searchsector = tcursectornum;
if (eitherCTRL && PRESSED_KEYSC(Z)) // CTRL+Z
{
@ -6731,16 +6744,16 @@ static void Keys2d(void)
drawgradient();
showspritedata(pointhighlight&16383, 0);
}
else if (linehighlight >= 0 /* && ((bstatus&1) || sectorofwall(linehighlight)==cursectornum)*/)
else if (linehighlight >= 0 /* && ((bstatus&1) || sectorofwall(linehighlight)==tcursectornum)*/)
{
drawgradient();
showwalldata(linehighlight, 0);
}
}
else if (cursectornum >= 0)
else if (tcursectornum >= 0)
{
drawgradient();
showsectordata(cursectornum, 0);
showsectordata(tcursectornum, 0);
}
}
else if (!(keystatus[KEYSC_F5]|keystatus[KEYSC_F6]|keystatus[KEYSC_F7]|keystatus[KEYSC_F8]) && !eitherSHIFT)
@ -6750,7 +6763,7 @@ static void Keys2d(void)
/*
static int32_t opointhighlight, olinehighlight, ocursectornum;
if (pointhighlight == opointhighlight && linehighlight == olinehighlight && cursectornum == ocursectornum)
if (pointhighlight == opointhighlight && linehighlight == olinehighlight && tcursectornum == ocursectornum)
*/
if (omx == mousxplc && omy == mousyplc)
{
@ -6766,7 +6779,7 @@ static void Keys2d(void)
/*
opointhighlight = pointhighlight;
olinehighlight = linehighlight;
ocursectornum = cursectornum;
ocursectornum = tcursectornum;
*/
@ -6782,10 +6795,10 @@ static void Keys2d(void)
if (sprite[i].picnum==SECTOREFFECTOR)
_printmessage16("^10%s", SectorEffectorText(i));
}
else if (linehighlight >= 0 && ((bstatus&1) || sectorofwall(linehighlight)==cursectornum))
else if (linehighlight >= 0 && ((bstatus&1) || sectorofwall(linehighlight)==tcursectornum))
showwalldata(linehighlight, 1);
else if (cursectornum >= 0)
showsectordata(cursectornum, 1);
else if (tcursectornum >= 0)
showsectordata(tcursectornum, 1);
}
}
@ -7032,7 +7045,70 @@ static void Keys2d(void)
if (tsign)
{
if (wallsprite==0)
if (numcorruptthings>0)
{
int32_t wrap=0, x, y, z;
if (curcorruptthing<0 || curcorruptthing>=numcorruptthings)
curcorruptthing = 0;
else
{
curcorruptthing += tsign;
wrap = (curcorruptthing<0 || curcorruptthing>=numcorruptthings);
curcorruptthing += numcorruptthings;
curcorruptthing %= numcorruptthings;
}
k = corruptthings[curcorruptthing];
j = -1;
switch (k&CORRUPT_MASK)
{
case 0:
printmessage16("MAP LIMITS EXCEEDED!");
break;
case CORRUPT_SECTOR:
i = k&(MAXSECTORS-1);
j = 0;
x = wall[sector[i].wallptr].x;
y = wall[sector[i].wallptr].y;
z = pos.z;
break;
case CORRUPT_WALL:
i = k&(MAXWALLS-1);
j = 1;
x = wall[i].x;
y = wall[i].y;
z = pos.z;
break;
case CORRUPT_SPRITE:
i = k&(MAXSPRITES-1);
j = 2;
x = sprite[i].x;
y = sprite[i].y;
z = sprite[i].z;
break;
default:
k = 0;
break;
}
if (k)
{
static const char *secwalspr[3] = {"sector", "wall", "sprite"};
if (x>=-editorgridextent && x<=editorgridextent &&
y>=-editorgridextent && y<=editorgridextent)
{
pos.x = x;
pos.y = y;
pos.z = z;
}
else x=editorgridextent+1;
printmessage16("%s Corrupt %s %d%s", tsign<0?"<":">", secwalspr[j], i,
(x==editorgridextent+1) ? " (outside grid)" : (wrap ? " (wrap)" : ""));
}
}
else if (wallsprite==0)
SearchSectors(tsign);
else if (wallsprite==1)
{
@ -7047,6 +7123,7 @@ static void Keys2d(void)
{
pos.x = wall[i].x - (wall[i].x-POINT2(i).x)/2;
pos.y = wall[i].y - (wall[i].y-POINT2(i).y)/2;
pos.z = getflorzofslope(sectorofwall(i), pos.x, pos.y);
printmessage16("%s Wall search: found", tsign<0?"<":">");
return;
}
@ -9138,25 +9215,13 @@ void app_crashhandler(void)
{
if (levelname[0])
{
char *f;
fixspritesectors(); //Do this before saving!
updatesector(startposx,startposy,&startsectnum);
if (pathsearchmode)
f = levelname;
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = Bstrrchr(levelname, '/');
if (!f) f = levelname; else f++;
}
f=strstr(levelname,".map");
char *f = strstr(levelname,".map");
if (f)
Bstrcpy(f,"_crash.map");
else Bstrcat(f,"_crash.map");
ExtPreSaveMap();
saveboard(levelname,&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap(levelname);
SaveBoard(f, 1);
}
}
#endif
@ -9737,16 +9802,6 @@ static void Keys2d3d(void)
if (eitherCTRL) //CTRL
{
char *f;
if (pathsearchmode) f = levelname;
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = Bstrrchr(levelname, '/');
if (!f) f = levelname; else f++;
}
if (PRESSED_KEYSC(P)) // Ctrl-P: Map playtesting
{
if (qsetmode != 200)
@ -9758,56 +9813,50 @@ static void Keys2d3d(void)
if (levelname[0])
{
keystatus[KEYSC_S] = 0;
fixspritesectors(); //Do this before saving!
updatesector(startposx,startposy,&startsectnum);
ExtPreSaveMap();
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap(f);
message("Board saved");
asksave = 0;
lastsave=totalclock;
i = CheckMapCorruption(4);
if (i<4)
{
SaveBoard(levelname, 0);
message("Board saved");
asksave = 0;
lastsave=totalclock;
}
else
message("Map is heavily corrupted, not saving. See OSD for details.");
}
}
if (keystatus[KEYSC_L]) // L
{
extern int32_t grponlymode;
extern void loadmhk();
if (totalclock < (lastsave + 120*10) || !AskIfSure("Are you sure you want to load the last saved map?"))
{
int32_t sposx=pos.x,sposy=pos.y,sposz=pos.z,sang=ang;
char *f;
if (pathsearchmode) f = levelname;
else
{
// virtual filesystem mode can't save to directories so drop the file into
// the current directory
f = Bstrrchr(levelname, '/');
if (!f) f = levelname; else f++;
}
lastsave=totalclock;
highlightcnt = -1;
// sectorhighlightstat = -1;
// newnumwalls = -1;
// joinsector[0] = -1;
// circlewall = -1;
// circlepoints = 7;
for (i=MAXSECTORS-1; i>=0; i--) sector[i].extra = -1;
for (i=MAXWALLS-1; i>=0; i--) wall[i].extra = -1;
for (i=MAXSPRITES-1; i>=0; i--) sprite[i].extra = -1;
if (LoadBoard(f, 0))
message("Invalid map format.");
ExtPreLoadMap();
i = loadboard(f,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
loadmhk();
if (i == -2) i = loadoldboard(f,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
if (i < 0) printmessage16("Invalid map format.");
else
{
ExtLoadMap(f);
if (mapversion < 7) message("Map %s loaded successfully and autoconverted to V7!",f);
else message("Map %s loaded successfully",f);
}
updatenumsprites();
startposx = pos.x;
startposy = pos.y;
startposz = pos.z;
startang = ang;
startsectnum = cursectnum;
pos.x=sposx; pos.y=sposy; pos.z=sposz; ang=sang;
keystatus[KEYSC_L]=0;
updatesectorz(pos.x, pos.y, pos.z, &cursectnum);
keystatus[KEYSC_L] = 0;
}
}
}
@ -9917,7 +9966,8 @@ void ExtCheckKeys(void)
if (autocorruptcheck>0 && totalclock > corruptchecktimer)
{
CheckMapCorruption(0);
if (CheckMapCorruption(3)>=4)
message("Corruption detected. See OSD for details.");
corruptchecktimer = totalclock + 120*autocorruptcheck;
}
}
@ -9934,12 +9984,17 @@ void ExtCheckKeys(void)
{
if (asksave == 3)
{
fixspritesectors(); //Do this before saving!
// updatesector(startposx,startposy,&startsectnum);
ExtPreSaveMap();
saveboard("autosave.map",&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap("autosave.map");
message("Board autosaved to AUTOSAVE.MAP");
if (CheckMapCorruption(6)>=4)
{
SaveBoard("autosave_corrupt.map", 1);
message("Board autosaved to AUTOSAVE_CORRUPT.MAP");
}
else
{
SaveBoard("autosave.map", 0);
message("Board autosaved to AUTOSAVE.MAP");
}
asksave = 4;
}
autosavetimer = totalclock+120*autosave;
@ -9955,14 +10010,13 @@ void ExtCheckKeys(void)
//// port of a.m32's corruptchk ////
// returns value from 0 (all OK) to 5 (panic!)
#define CORRUPTCHK_PRINT(errlev, fmt, ...) do \
#define CORRUPTCHK_PRINT(errlev, what, fmt, ...) do \
{ \
bad = max(bad, errlev); \
if (numcorruptthings<MAXCORRUPTTHINGS) \
corruptthings[numcorruptthings++] = what; \
if (errlev >= printfromlev) \
{ \
OSD_Printf(fmt "\n", ## __VA_ARGS__); \
if (qsetmode!=200) printmessage16(fmt, ## __VA_ARGS__); \
} \
} while (0)
int32_t CheckMapCorruption(int32_t printfromlev)
@ -9972,11 +10026,13 @@ int32_t CheckMapCorruption(int32_t printfromlev)
int32_t errlevel=0, bad=0;
numcorruptthings = 0;
if (numsectors>MAXSECTORS)
CORRUPTCHK_PRINT(5, "PANIC!!! SECTOR LIMIT EXCEEDED (MAXSECTORS=%d)!!!", MAXSECTORS);
CORRUPTCHK_PRINT(5, 0, "PANIC!!! SECTOR LIMIT EXCEEDED (MAXSECTORS=%d)!!!", MAXSECTORS);
if (numwalls>MAXWALLS)
CORRUPTCHK_PRINT(5, "PANIC!!! WALL LIMIT EXCEEDED (MAXWALLS=%d)!!!", MAXWALLS);
CORRUPTCHK_PRINT(5, 0, "PANIC!!! WALL LIMIT EXCEEDED (MAXWALLS=%d)!!!", MAXWALLS);
if (numsectors>MAXSECTORS || numwalls>MAXWALLS)
return bad;
@ -9989,21 +10045,21 @@ int32_t CheckMapCorruption(int32_t printfromlev)
numw = sector[i].wallnum;
if (w0 < 0 || w0 > numwalls)
CORRUPTCHK_PRINT(4, "SECTOR[%d].WALLPTR=%d out of range (numwalls=%d)", i, w0, numw);
CORRUPTCHK_PRINT(4, CORRUPT_SECTOR|i, "SECTOR[%d].WALLPTR=%d out of range (numwalls=%d)", i, w0, numw);
if (w0 != ewall)
CORRUPTCHK_PRINT(4, "SECTOR[%d].WALLPTR=%d inconsistent, expected %d", i, w0, ewall);
CORRUPTCHK_PRINT(4, CORRUPT_SECTOR|i, "SECTOR[%d].WALLPTR=%d inconsistent, expected %d", i, w0, ewall);
if (numw <= 1)
CORRUPTCHK_PRINT(5, "PANIC!!! SECTOR[%d].WALLNUM=%d INVALID!!!", i, numw);
CORRUPTCHK_PRINT(5, CORRUPT_SECTOR|i, "PANIC!!! SECTOR[%d].WALLNUM=%d INVALID!!!", i, numw);
else if (numw==2)
CORRUPTCHK_PRINT(3, "SECTOR[%d].WALLNUM=2, expected at least 3", i);
CORRUPTCHK_PRINT(3, CORRUPT_SECTOR|i, "SECTOR[%d].WALLNUM=2, expected at least 3", i);
ewall += numw;
endwall = w0 + numw;
if (endwall > numwalls)
CORRUPTCHK_PRINT(4, "SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d", i, endwall, numwalls);
CORRUPTCHK_PRINT(4, CORRUPT_SECTOR|i, "SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d", i, endwall, numwalls);
if (bad)
errlevel = max(errlevel, bad);
@ -10016,37 +10072,37 @@ int32_t CheckMapCorruption(int32_t printfromlev)
bad = 0;
if (wall[j].point2 < w0 || wall[j].point2 > endwall)
CORRUPTCHK_PRINT(4, "WALL[%d].POINT2=%d out of range [%d, %d]",
CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].POINT2=%d out of range [%d, %d]",
j, wall[j].point2, w0, endwall);
nw = wall[j].nextwall;
ns = wall[j].nextsector;
if (nw >= numwalls)
CORRUPTCHK_PRINT(4, "WALL[%d].NEXTWALL=%d out of range: numwalls=%d",
CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTWALL=%d out of range: numwalls=%d",
j, nw, numwalls);
if (ns >= numsectors)
CORRUPTCHK_PRINT(4, "WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d",
CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d",
j, ns, numsectors);
if (ns == i)
CORRUPTCHK_PRINT(4, "WALL[%d].NEXTSECTOR is its own sector", j);
CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR is its own sector", j);
if (nw>=w0 && nw<=endwall)
CORRUPTCHK_PRINT(4, "WALL[%d].NEXTWALL is its own sector's wall", j);
CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTWALL is its own sector's wall", j);
if (bad)
errlevel = max(errlevel, bad);
else
if (!bad)
{
if (ns>=0 || (ns^nw)<0)
{
if ((ns^nw)<0 || nw<sector[ns].wallptr || nw>=sector[ns].wallptr+sector[ns].wallnum)
CORRUPTCHK_PRINT(4, "WALL[%d].NEXTSECTOR=%d and .NEXTWALL=%d inconsistent",
CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR=%d and .NEXTWALL=%d inconsistent",
j, ns, nw);
}
}
errlevel = max(errlevel, bad);
}
}
}
@ -10058,19 +10114,22 @@ int32_t CheckMapCorruption(int32_t printfromlev)
continue;
if (sprite[i].sectnum<0 || sprite[i].sectnum>=numsectors)
CORRUPTCHK_PRINT(2, "SPRITE[%d].SECTNUM=%d. Expect problems!", i, sprite[i].sectnum);
CORRUPTCHK_PRINT(2, CORRUPT_SPRITE|i, "SPRITE[%d].SECTNUM=%d. Expect problems!", i, sprite[i].sectnum);
if (sprite[i].picnum<0 || sprite[i].picnum>=MAXTILES)
{
sprite[i].picnum = 0;
CORRUPTCHK_PRINT(0, "SPRITE[%d].PICNUM=%d out of range, resetting to 0", i, sprite[i].picnum);
CORRUPTCHK_PRINT(0, CORRUPT_SPRITE|i, "SPRITE[%d].PICNUM=%d out of range, resetting to 0", i, sprite[i].picnum);
}
}
errlevel = max(errlevel, bad);
if (errlevel)
OSD_Printf("--\n");
{
if (printfromlev<=errlevel)
OSD_Printf("-- corruption level: %d\n", errlevel);
}
return errlevel;
}
@ -10126,9 +10185,9 @@ static void SearchSectors(int32_t dir) // <0: backwards, >=0: forwards
pos.x = wall[sector[ii].wallptr].x;
pos.y = wall[sector[ii].wallptr].y;
printmessage16("%s Sector search: found", dir<0?"<":">");
cursectornum = ii;
return;
}
cursectornum += dir;
}
}
printmessage16("%s Sector search: none found", dir<0?"<":">");

View file

@ -2864,7 +2864,7 @@ dodefault:
int32_t col=Gv_GetVarX(*insptr++), odrawlinepat=drawlinepat;
int32_t xofs=0, yofs=0, eccen=16384;
if (tw==CON_DRAWCIRCLE16B)
if (tw==CON_DRAWCIRCLE16B || tw==CON_DRAWCIRCLE16Z)
{
screencoords(&x1,&y1, x1-pos.x,y1-pos.y, zoom);
if (m32_sideview)

View file

@ -78,7 +78,7 @@ static int32_t lastmessagetime=-1;
static char tempbuf[1024];
static int32_t numsprite[MAXSPRITES], multisprite[MAXSPRITES];
static char lo[64];
static char levelname[255];
static char levelname[BMAX_PATH];
static int16_t curwall=0, curwallnum=0;
static int16_t /*cursearchsprite=0,*/ cursearchspritenum=0, cursector_lotag=0, cursectornum=0;
static int16_t search_lotag=0,search_hitag=0;