mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
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:
parent
8d01b7f403
commit
51eb2c7cd3
11 changed files with 749 additions and 537 deletions
|
@ -435,13 +435,14 @@ int32_t preinitengine(void); // a partial setup of the engine used for launch
|
||||||
int32_t initengine(void);
|
int32_t initengine(void);
|
||||||
void uninitengine(void);
|
void uninitengine(void);
|
||||||
void initspritelists(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 loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
|
||||||
int32_t loadmaphack(char *filename);
|
int32_t loadmaphack(const char *filename);
|
||||||
int32_t clipmapinfo_load(char *filename);
|
void delete_maphack_lights();
|
||||||
int32_t saveboard(char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
|
int32_t clipmapinfo_load(const char *filename);
|
||||||
int32_t loadpics(char *filename, int32_t askedsize);
|
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);
|
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);
|
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 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);
|
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);
|
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
|
||||||
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day);
|
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day);
|
||||||
void setfirstwall(int16_t sectnum, int16_t newfirstwall);
|
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)));
|
void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) ATTRIBUTE((nonnull(1,2,3)));
|
||||||
int32_t krand(void);
|
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 changespritestat(int16_t spritenum, int16_t newstatnum);
|
||||||
int32_t setsprite(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2)));
|
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);
|
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
|
// effect bitset: 1 = greyscale, 2 = invert
|
||||||
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect);
|
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect);
|
||||||
// flags bitset: 1 = don't compress
|
// 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 hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]);
|
||||||
int32_t hicclearsubst(int32_t picnum, int32_t palnum);
|
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_undefinetile(int32_t tile);
|
||||||
int32_t md_undefinemodel(int32_t modelid);
|
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
|
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);
|
int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
|
||||||
|
|
|
@ -106,6 +106,15 @@ extern void ExtEditWallData(int16_t wallnum);
|
||||||
extern void ExtEditSpriteData(int16_t spritenum);
|
extern void ExtEditSpriteData(int16_t spritenum);
|
||||||
extern const char *ExtGetSectorType(int32_t lotag);
|
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 autocorruptcheck;
|
||||||
extern int32_t CheckMapCorruption(int32_t printfromlev);
|
extern int32_t CheckMapCorruption(int32_t printfromlev);
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ int8_t sideview_reversehrot = 0;
|
||||||
|
|
||||||
char lastpm16buf[156];
|
char lastpm16buf[156];
|
||||||
|
|
||||||
static int32_t checksectorpointer_warn = 0;
|
//static int32_t checksectorpointer_warn = 0;
|
||||||
|
|
||||||
char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck);
|
char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck);
|
||||||
static int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls);
|
static int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls);
|
||||||
|
@ -217,7 +217,6 @@ static void flipwalls(int16_t numwalls, int16_t newnumwalls);
|
||||||
static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day);
|
static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day);
|
||||||
static void deletepoint(int16_t point);
|
static void deletepoint(int16_t point);
|
||||||
static int32_t deletesector(int16_t sucksect);
|
static int32_t deletesector(int16_t sucksect);
|
||||||
int32_t checksectorpointer(int16_t i, int16_t sectnum);
|
|
||||||
void fixrepeats(int16_t i);
|
void fixrepeats(int16_t i);
|
||||||
static int16_t loopinside(int32_t x, int32_t y, int16_t startwall);
|
static int16_t loopinside(int32_t x, int32_t y, int16_t startwall);
|
||||||
int32_t fillsector(int16_t sectnum, char fillcolor);
|
int32_t fillsector(int16_t sectnum, char fillcolor);
|
||||||
|
@ -237,11 +236,11 @@ void AutoAlignWalls(int32_t nWall0, int32_t ply);
|
||||||
int32_t gettile(int32_t tilenum);
|
int32_t gettile(int32_t tilenum);
|
||||||
|
|
||||||
static int32_t menuselect(void);
|
static int32_t menuselect(void);
|
||||||
static int32_t menuselect_pk(int32_t); //PK
|
static int32_t menuselect_auto(int32_t); //PK
|
||||||
|
|
||||||
static int32_t getfilenames(const char *path, const char *kind);
|
static int32_t getfilenames(const char *path, const char *kind);
|
||||||
static void clearfilenames(void);
|
static void clearfilenames(void);
|
||||||
void loadmhk();
|
void loadmhk(int32_t domessage);
|
||||||
extern int32_t map_revision;
|
extern int32_t map_revision;
|
||||||
extern int32_t map_undoredo(int32_t dir);
|
extern int32_t map_undoredo(int32_t dir);
|
||||||
extern void map_undoredo_free(void);
|
extern void map_undoredo_free(void);
|
||||||
|
@ -466,15 +465,7 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
if (k>0)
|
if (k>0)
|
||||||
initprintf("There was an error loading the sprite clipping 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;
|
if (LoadBoard(boardfilename, 1))
|
||||||
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
||||||
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
|
||||||
|
|
||||||
ExtPreLoadMap();
|
|
||||||
i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
||||||
loadmhk();
|
|
||||||
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
||||||
if (i < 0)
|
|
||||||
{
|
{
|
||||||
initspritelists();
|
initspritelists();
|
||||||
pos.x = 32768;
|
pos.x = 32768;
|
||||||
|
@ -485,18 +476,6 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
numwalls = 0;
|
numwalls = 0;
|
||||||
cursectnum = -1;
|
cursectnum = -1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ExtLoadMap(boardfilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
updatenumsprites();
|
|
||||||
|
|
||||||
startposx = pos.x;
|
|
||||||
startposy = pos.y;
|
|
||||||
startposz = pos.z;
|
|
||||||
startang = ang;
|
|
||||||
startsectnum = cursectnum; // TX 20050225: moved to loadboard
|
|
||||||
|
|
||||||
totalclock = 0;
|
totalclock = 0;
|
||||||
|
|
||||||
|
@ -549,6 +528,7 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
|
|
||||||
setbrightness(GAMMA_CALC,palette,0);
|
setbrightness(GAMMA_CALC,palette,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CANCEL:
|
CANCEL:
|
||||||
quitflag = 0;
|
quitflag = 0;
|
||||||
while (quitflag == 0)
|
while (quitflag == 0)
|
||||||
|
@ -638,8 +618,10 @@ CANCEL:
|
||||||
|
|
||||||
if (asksave)
|
if (asksave)
|
||||||
{
|
{
|
||||||
|
i = CheckMapCorruption(4);
|
||||||
|
|
||||||
begindrawing(); //{{{
|
begindrawing(); //{{{
|
||||||
printext256(0,8,whitecol,0,"Save changes?",0);
|
printext256(0,8,whitecol,0,i<4?"Save changes?":"Map is heavily corrupt. Save changes?",0);
|
||||||
showframe(1); //}}}
|
showframe(1); //}}}
|
||||||
|
|
||||||
while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]|keystatus[0x2e]) == 0)
|
while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]|keystatus[0x2e]) == 0)
|
||||||
|
@ -649,29 +631,16 @@ CANCEL:
|
||||||
|
|
||||||
if (keystatus[0x15] || keystatus[0x1c]) // Y or ENTER
|
if (keystatus[0x15] || keystatus[0x1c]) // Y or ENTER
|
||||||
{
|
{
|
||||||
char *f;
|
keystatus[0x15] = keystatus[0x1c] = 0;
|
||||||
keystatus[0x15] = 0;
|
|
||||||
keystatus[0x1c] = 0;
|
SaveBoard(NULL, 0);
|
||||||
fixspritesectors();
|
|
||||||
updatesector(startposx,startposy,&startsectnum);
|
|
||||||
ExtPreSaveMap();
|
|
||||||
if (pathsearchmode) f = boardfilename;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// virtual filesystem mode can't save to directories so drop the file into
|
|
||||||
// the current directory
|
|
||||||
f = Bstrrchr(boardfilename, '/');
|
|
||||||
if (!f) f = boardfilename; else f++;
|
|
||||||
}
|
|
||||||
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
|
||||||
ExtSaveMap(f);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (keystatus[1]||keystatus[0x2e])
|
while (keystatus[1]||keystatus[0x2e])
|
||||||
{
|
{
|
||||||
keystatus[1] = 0;
|
keystatus[1] = keystatus[0x2e] = 0;
|
||||||
keystatus[0x2e] = 0;
|
|
||||||
quitevent = 0;
|
quitevent = 0;
|
||||||
goto CANCEL;
|
goto CANCEL;
|
||||||
}
|
}
|
||||||
|
@ -703,12 +672,13 @@ void showmouse(void)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int32_t mhk=0;
|
static int32_t mhk=0;
|
||||||
void loadmhk()
|
void loadmhk(int32_t domessage)
|
||||||
{
|
{
|
||||||
char *p; char levname[BMAX_PATH];
|
char *p; char levname[BMAX_PATH];
|
||||||
|
|
||||||
if (!mhk)
|
if (!mhk)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bstrcpy(levname, boardfilename);
|
Bstrcpy(levname, boardfilename);
|
||||||
p = Bstrrchr(levname,'.');
|
p = Bstrrchr(levname,'.');
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -720,9 +690,20 @@ void loadmhk()
|
||||||
p[3]='k';
|
p[3]='k';
|
||||||
p[4]=0;
|
p[4]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadmaphack(levname))
|
if (!loadmaphack(levname))
|
||||||
|
{
|
||||||
|
if (domessage)
|
||||||
|
message("Loaded map hack file '%s'",levname);
|
||||||
|
else
|
||||||
initprintf("Loaded map hack file '%s'\n",levname);
|
initprintf("Loaded map hack file '%s'\n",levname);
|
||||||
else mhk=2;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mhk=2;
|
||||||
|
if (domessage)
|
||||||
|
message("No maphack found for map '%s'",boardfilename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void editinput(void)
|
void editinput(void)
|
||||||
|
@ -897,13 +878,14 @@ void editinput(void)
|
||||||
{
|
{
|
||||||
Bmemset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
Bmemset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
||||||
Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID));
|
Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID));
|
||||||
|
delete_maphack_lights();
|
||||||
mhk = 0;
|
mhk = 0;
|
||||||
initprintf("Maphacks disabled\n");
|
message("Maphacks disabled");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loadmhk();
|
|
||||||
mhk = 1;
|
mhk = 1;
|
||||||
|
loadmhk(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
keystatus[0x43] = 0;
|
keystatus[0x43] = 0;
|
||||||
|
@ -1403,7 +1385,7 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo)
|
||||||
|
|
||||||
// reconstruct wall connections
|
// reconstruct wall connections
|
||||||
numsectors=newnumsectors; // needed now for checksectorpointer
|
numsectors=newnumsectors; // needed now for checksectorpointer
|
||||||
checksectorpointer_warn = 0;
|
// checksectorpointer_warn = 0;
|
||||||
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap));
|
||||||
for (i=onumsectors; i<newnumsectors; i++)
|
for (i=onumsectors; i<newnumsectors; i++)
|
||||||
{
|
{
|
||||||
|
@ -1413,7 +1395,7 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo)
|
||||||
}
|
}
|
||||||
for (i=numwalls; i<newnumwalls; i++)
|
for (i=numwalls; i<newnumwalls; i++)
|
||||||
wall[i].x -= editorgridextent<<2;
|
wall[i].x -= editorgridextent<<2;
|
||||||
checksectorpointer_warn = 1;
|
// checksectorpointer_warn = 1;
|
||||||
|
|
||||||
// insert sprites
|
// insert sprites
|
||||||
for (i=0; i<mapinfo->numsprites; i++)
|
for (i=0; i<mapinfo->numsprites; i++)
|
||||||
|
@ -1677,6 +1659,8 @@ void m32_setkeyfilter(int32_t on)
|
||||||
after_handleevents_hook = 0;
|
after_handleevents_hook = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t ask_if_sure(const char *query, int32_t quit_is_yes);
|
||||||
|
|
||||||
void overheadeditor(void)
|
void overheadeditor(void)
|
||||||
{
|
{
|
||||||
char buffer[80], *dabuffer, ch;
|
char buffer[80], *dabuffer, ch;
|
||||||
|
@ -2110,11 +2094,23 @@ void overheadeditor(void)
|
||||||
drawline16(searchx,0, searchx,8, editorcolors[15]);
|
drawline16(searchx,0, searchx,8, editorcolors[15]);
|
||||||
drawline16(0,searchy, 8,searchy, editorcolors[15]);
|
drawline16(0,searchy, 8,searchy, editorcolors[15]);
|
||||||
|
|
||||||
// draw mouse pointer
|
////// draw mouse pointer
|
||||||
col = editorcolors[15 - 3*gridlock];
|
col = editorcolors[15 - 3*gridlock];
|
||||||
if (joinsector[0] >= 0)
|
if (joinsector[0] >= 0)
|
||||||
col = editorcolors[11];
|
col = editorcolors[11];
|
||||||
|
|
||||||
|
if (numcorruptthings>0 && (pointhighlight&16384)==0)
|
||||||
|
{
|
||||||
|
for (i=0; i<numcorruptthings; i++)
|
||||||
|
if ((corruptthings[i]&CORRUPT_MASK)==CORRUPT_WALL &&
|
||||||
|
(corruptthings[i]&(MAXWALLS-1))==pointhighlight)
|
||||||
|
{
|
||||||
|
col = editorcolors[13];
|
||||||
|
printext16(searchx+6,searchy-6-8,editorcolors[13],editorcolors[0],"corrupt wall",0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((keystatus[0x36] || keystatus[0xb8]) && !eitherCTRL) // RSHIFT || RALT
|
if ((keystatus[0x36] || keystatus[0xb8]) && !eitherCTRL) // RSHIFT || RALT
|
||||||
{
|
{
|
||||||
if (keystatus[0x27] || keystatus[0x28]) // ' and ;
|
if (keystatus[0x27] || keystatus[0x28]) // ' and ;
|
||||||
|
@ -2136,7 +2132,7 @@ void overheadeditor(void)
|
||||||
drawline16base(searchx,searchy, +2,+0, +9,+0, col);
|
drawline16base(searchx,searchy, +2,+0, +9,+0, col);
|
||||||
drawline16base(searchx,searchy, +2,+1, +9,+1, col);
|
drawline16base(searchx,searchy, +2,+1, +9,+1, col);
|
||||||
|
|
||||||
//Draw the white pixel closest to mouse cursor on linehighlight
|
////// Draw the white pixel closest to mouse cursor on linehighlight
|
||||||
if (linehighlight>=0 && !m32_sideview)
|
if (linehighlight>=0 && !m32_sideview)
|
||||||
{
|
{
|
||||||
getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day);
|
getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day);
|
||||||
|
@ -4699,54 +4695,26 @@ SKIP:
|
||||||
{
|
{
|
||||||
nextmap:
|
nextmap:
|
||||||
// bad = 0;
|
// bad = 0;
|
||||||
i = menuselect_pk(keystatus[0x2a] ? 0:1); // Left Shift: prev map
|
i = menuselect_auto(keystatus[0x2a] ? 0:1); // Left Shift: prev map
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
if (i == -2)
|
if (i == -1)
|
||||||
printmessage16("No .MAP files found.");
|
message("No more map files.");
|
||||||
|
else if (i == -2)
|
||||||
|
message("No .MAP files found.");
|
||||||
else if (i == -3)
|
else if (i == -3)
|
||||||
printmessage16("Load map first!");
|
message("Load map first!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bstrcpy(boardfilename, selectedboardfilename);
|
if (LoadBoard(NULL, 4))
|
||||||
|
goto nextmap;
|
||||||
highlightcnt = -1;
|
|
||||||
Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights
|
|
||||||
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
|
||||||
|
|
||||||
sectorhighlightstat = -1;
|
sectorhighlightstat = -1;
|
||||||
newnumwalls = -1;
|
|
||||||
joinsector[0] = -1;
|
joinsector[0] = -1;
|
||||||
circlewall = -1;
|
circlewall = -1;
|
||||||
circlepoints = 7;
|
circlepoints = 7;
|
||||||
|
|
||||||
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
|
||||||
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
||||||
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
|
||||||
|
|
||||||
ExtPreLoadMap();
|
|
||||||
i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
||||||
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
||||||
oposz = pos.z;
|
oposz = pos.z;
|
||||||
if (i < 0)
|
|
||||||
{
|
|
||||||
// printmessage16("Invalid map format.");
|
|
||||||
goto nextmap;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ExtLoadMap(boardfilename);
|
|
||||||
|
|
||||||
if (mapversion < 7) printmessage16("Map %s loaded successfully and autoconverted to V7!",boardfilename);
|
|
||||||
else printmessage16("Map %s loaded successfully.",boardfilename);
|
|
||||||
}
|
|
||||||
updatenumsprites();
|
|
||||||
startposx = pos.x; //this is same
|
|
||||||
startposy = pos.y;
|
|
||||||
startposz = pos.z;
|
|
||||||
startang = ang;
|
|
||||||
startsectnum = cursectnum;
|
|
||||||
}
|
}
|
||||||
showframe(1);
|
showframe(1);
|
||||||
keystatus[0x1c] = 0;
|
keystatus[0x1c] = 0;
|
||||||
|
@ -4757,7 +4725,6 @@ nextmap:
|
||||||
}
|
}
|
||||||
// ^^^ PK ------------------------------------
|
// ^^^ PK ------------------------------------
|
||||||
|
|
||||||
CANCEL:
|
|
||||||
if (keystatus[1] && joinsector[0] >= 0)
|
if (keystatus[1] && joinsector[0] >= 0)
|
||||||
{
|
{
|
||||||
keystatus[1]=0;
|
keystatus[1]=0;
|
||||||
|
@ -4765,6 +4732,7 @@ CANCEL:
|
||||||
printmessage16("No sectors joined.");
|
printmessage16("No sectors joined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CANCEL:
|
||||||
if (keystatus[1])
|
if (keystatus[1])
|
||||||
{
|
{
|
||||||
m32_setkeyfilter(0);
|
m32_setkeyfilter(0);
|
||||||
|
@ -4779,10 +4747,8 @@ CANCEL:
|
||||||
if (handleevents())
|
if (handleevents())
|
||||||
{
|
{
|
||||||
if (quitevent)
|
if (quitevent)
|
||||||
{
|
|
||||||
quitevent = 0;
|
quitevent = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
idle();
|
idle();
|
||||||
|
|
||||||
ch = bgetchar();
|
ch = bgetchar();
|
||||||
|
@ -4796,19 +4762,10 @@ CANCEL:
|
||||||
else if (ch == 'n' || ch == 'N') //N
|
else if (ch == 'n' || ch == 'N') //N
|
||||||
{
|
{
|
||||||
bad = 0;
|
bad = 0;
|
||||||
_printmessage16("Are you sure you want to start a new board? (Y/N)");
|
|
||||||
showframe(1);
|
|
||||||
bflushchars(); ch = 0;
|
|
||||||
while (keystatus[1] == 0)
|
|
||||||
{
|
|
||||||
if (handleevents())
|
|
||||||
quitevent = 0;
|
|
||||||
|
|
||||||
idle();
|
if (!ask_if_sure("Are you sure you want to start a new board? (Y/N)", 0))
|
||||||
|
break;
|
||||||
ch = bgetchar();
|
else
|
||||||
|
|
||||||
if (ch == 'Y' || ch == 'y')
|
|
||||||
{
|
{
|
||||||
int32_t bakstat=-1;
|
int32_t bakstat=-1;
|
||||||
mapinfofull_t bakmap;
|
mapinfofull_t bakmap;
|
||||||
|
@ -4855,11 +4812,7 @@ CANCEL:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ')
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// printmessage16("");
|
// printmessage16("");
|
||||||
showframe(1);
|
showframe(1);
|
||||||
}
|
}
|
||||||
|
@ -4877,40 +4830,22 @@ CANCEL:
|
||||||
int32_t bakstat=-1;
|
int32_t bakstat=-1;
|
||||||
mapinfofull_t bakmap;
|
mapinfofull_t bakmap;
|
||||||
|
|
||||||
Bstrcpy(boardfilename, selectedboardfilename);
|
|
||||||
|
|
||||||
if (highlightsectorcnt > 0)
|
if (highlightsectorcnt > 0)
|
||||||
bakstat = backup_highlighted_map(&bakmap);
|
bakstat = backup_highlighted_map(&bakmap);
|
||||||
// __old_mapcopy_2__
|
// __old_mapcopy_2__
|
||||||
highlightcnt = -1;
|
if (LoadBoard(NULL, 4))
|
||||||
Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights
|
|
||||||
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
|
||||||
|
|
||||||
sectorhighlightstat = -1;
|
|
||||||
newnumwalls = -1;
|
|
||||||
joinsector[0] = -1;
|
|
||||||
circlewall = -1;
|
|
||||||
circlepoints = 7;
|
|
||||||
|
|
||||||
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
|
||||||
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
|
||||||
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
|
||||||
|
|
||||||
ExtPreLoadMap();
|
|
||||||
i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
||||||
loadmhk();
|
|
||||||
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
|
||||||
oposz = pos.z;
|
|
||||||
if (i < 0)
|
|
||||||
{
|
{
|
||||||
printmessage16("Invalid map format.");
|
printmessage16("Invalid map format.");
|
||||||
|
|
||||||
if (bakstat==0)
|
if (bakstat==0)
|
||||||
mapinfofull_free(&bakmap);
|
mapinfofull_free(&bakmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ExtLoadMap(boardfilename);
|
sectorhighlightstat = -1;
|
||||||
|
joinsector[0] = -1;
|
||||||
|
circlewall = -1;
|
||||||
|
circlepoints = 7;
|
||||||
|
oposz = pos.z;
|
||||||
|
|
||||||
if (bakstat==0)
|
if (bakstat==0)
|
||||||
{
|
{
|
||||||
|
@ -4918,23 +4853,15 @@ CANCEL:
|
||||||
if (bakstat == -1)
|
if (bakstat == -1)
|
||||||
message("Can't copy highlighted portion of old map: limits exceeded.");
|
message("Can't copy highlighted portion of old map: limits exceeded.");
|
||||||
}
|
}
|
||||||
// __old_mapcopy_2__
|
|
||||||
if (mapversion < 7) printmessage16("Map %s loaded successfully and autoconverted to V7!",boardfilename);
|
|
||||||
else printmessage16("Map %s loaded successfully.",boardfilename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatenumsprites();
|
|
||||||
startposx = pos.x; //this is same
|
|
||||||
startposy = pos.y;
|
|
||||||
startposz = pos.z;
|
|
||||||
startang = ang;
|
|
||||||
startsectnum = cursectnum;
|
|
||||||
}
|
}
|
||||||
showframe(1);
|
showframe(1);
|
||||||
keystatus[0x1c] = 0;
|
keystatus[0x1c] = 0;
|
||||||
}
|
}
|
||||||
else if (ch == 'a' || ch == 'A') //A
|
else if (ch == 'a' || ch == 'A') //A
|
||||||
{
|
{
|
||||||
|
int32_t corrupt = CheckMapCorruption(4);
|
||||||
|
|
||||||
bad = 0;
|
bad = 0;
|
||||||
|
|
||||||
Bstrcpy(selectedboardfilename, boardfilename);
|
Bstrcpy(selectedboardfilename, boardfilename);
|
||||||
|
@ -4951,7 +4878,8 @@ CANCEL:
|
||||||
bflushchars();
|
bflushchars();
|
||||||
while (bad == 0)
|
while (bad == 0)
|
||||||
{
|
{
|
||||||
_printmessage16("Save as: ^011%s%s", boardfilename, (totalclock&32)?"_":"");
|
_printmessage16("%sSave as: ^011%s%s", corrupt>=4?"(map corrupt) ":"",
|
||||||
|
boardfilename, (totalclock&32)?"_":"");
|
||||||
showframe(1);
|
showframe(1);
|
||||||
|
|
||||||
if (handleevents())
|
if (handleevents())
|
||||||
|
@ -4987,7 +4915,9 @@ CANCEL:
|
||||||
}
|
}
|
||||||
else if (bad == 2)
|
else if (bad == 2)
|
||||||
{
|
{
|
||||||
char *f; int32_t res;
|
const char *f;
|
||||||
|
char *slash;
|
||||||
|
|
||||||
keystatus[0x1c] = 0;
|
keystatus[0x1c] = 0;
|
||||||
|
|
||||||
boardfilename[i] = '.';
|
boardfilename[i] = '.';
|
||||||
|
@ -4996,52 +4926,43 @@ CANCEL:
|
||||||
boardfilename[i+3] = 'p';
|
boardfilename[i+3] = 'p';
|
||||||
boardfilename[i+4] = 0;
|
boardfilename[i+4] = 0;
|
||||||
|
|
||||||
if (Bstrrchr(selectedboardfilename,'/'))
|
slash = Bstrrchr(selectedboardfilename,'/');
|
||||||
Bstrcpy(Bstrrchr(selectedboardfilename, '/')+1, boardfilename);
|
Bstrcpy(slash ? slash+1 : selectedboardfilename, boardfilename);
|
||||||
else
|
|
||||||
Bstrcpy(selectedboardfilename, boardfilename);
|
_printmessage16("Saving board...");
|
||||||
if (pathsearchmode) f = selectedboardfilename;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// virtual filesystem mode can't save to directories so drop the file into
|
|
||||||
// the current directory
|
|
||||||
f = Bstrrchr(selectedboardfilename, '/');
|
|
||||||
if (!f) f = selectedboardfilename; else f++;
|
|
||||||
}
|
|
||||||
_printmessage16("Saving to %s...",f);
|
|
||||||
showframe(1);
|
showframe(1);
|
||||||
|
|
||||||
fixspritesectors(); //Do this before saving!
|
f = SaveBoard(selectedboardfilename, 0);
|
||||||
updatesector(startposx,startposy,&startsectnum);
|
|
||||||
ExtPreSaveMap();
|
if (f)
|
||||||
res=saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
printmessage16("Saved board to %s.", f);
|
||||||
ExtSaveMap(f);
|
else
|
||||||
printmessage16((res==0)?"Board saved.":"Saving board failed.");
|
printmessage16("Saving board failed.");
|
||||||
|
|
||||||
Bstrcpy(boardfilename, selectedboardfilename);
|
Bstrcpy(boardfilename, selectedboardfilename);
|
||||||
}
|
}
|
||||||
bad = 0;
|
bad = 0;
|
||||||
}
|
}
|
||||||
else if (ch == 's' || ch == 'S') //S
|
else if (ch == 's' || ch == 'S') //S
|
||||||
{
|
{
|
||||||
char *f;
|
const char *f;
|
||||||
int32_t res;
|
|
||||||
bad = 0;
|
bad = 0;
|
||||||
|
|
||||||
|
if (CheckMapCorruption(4)>=4)
|
||||||
|
if (!ask_if_sure("Map is corrupt. Are you sure you want to save?", 0))
|
||||||
|
break;
|
||||||
|
|
||||||
_printmessage16("Saving board...");
|
_printmessage16("Saving board...");
|
||||||
showframe(1);
|
showframe(1);
|
||||||
fixspritesectors(); //Do this before saving!
|
|
||||||
updatesector(startposx,startposy,&startsectnum);
|
f = SaveBoard(NULL, 0);
|
||||||
if (pathsearchmode) f = boardfilename;
|
|
||||||
|
if (f)
|
||||||
|
printmessage16("Saved board to %s.", f);
|
||||||
else
|
else
|
||||||
{
|
printmessage16("Saving board failed.");
|
||||||
// virtual filesystem mode can't save to directories so drop the file into
|
|
||||||
// the current directory
|
|
||||||
f = Bstrrchr(boardfilename, '/');
|
|
||||||
if (!f) f = boardfilename; else f++;
|
|
||||||
}
|
|
||||||
ExtPreSaveMap();
|
|
||||||
res=saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
|
||||||
ExtSaveMap(f);
|
|
||||||
printmessage16((res==0)?"Board saved.":"Saving board failed.");
|
|
||||||
showframe(1);
|
showframe(1);
|
||||||
}
|
}
|
||||||
else if (ch == 't' || ch == 'T')
|
else if (ch == 't' || ch == 'T')
|
||||||
|
@ -5063,58 +4984,16 @@ CANCEL:
|
||||||
else if (ch == 'q' || ch == 'Q') //Q
|
else if (ch == 'q' || ch == 'Q') //Q
|
||||||
{
|
{
|
||||||
bad = 0;
|
bad = 0;
|
||||||
_printmessage16("Are you sure you want to quit?");
|
|
||||||
showframe(1);
|
|
||||||
bflushchars();
|
|
||||||
while ((keystatus[1]|keystatus[0x2e]) == 0)
|
|
||||||
{
|
|
||||||
if (handleevents())
|
|
||||||
{
|
|
||||||
if (quitevent) quitevent = 0;
|
|
||||||
}
|
|
||||||
idle();
|
|
||||||
|
|
||||||
ch = bgetchar();
|
if (ask_if_sure("Are you sure you want to quit?", 0))
|
||||||
|
|
||||||
if (ch == 'y' || ch == 'Y')
|
|
||||||
{
|
{
|
||||||
//QUIT!
|
//QUIT!
|
||||||
|
|
||||||
_printmessage16("Save changes?");
|
int32_t corrupt = CheckMapCorruption(4);
|
||||||
showframe(1);
|
|
||||||
while ((keystatus[1]|keystatus[0x2e]) == 0)
|
|
||||||
{
|
|
||||||
if (handleevents())
|
|
||||||
{
|
|
||||||
if (quitevent) break; // like saying no
|
|
||||||
}
|
|
||||||
idle();
|
|
||||||
|
|
||||||
ch = bgetchar();
|
if (ask_if_sure(corrupt<4?"Save changes?":"Map corrupt. Save changes?", corrupt<4?0:1))
|
||||||
|
SaveBoard(NULL, 0);
|
||||||
|
|
||||||
if (ch == 'y' || ch == 'Y')
|
|
||||||
{
|
|
||||||
char *f;
|
|
||||||
fixspritesectors(); //Do this before saving!
|
|
||||||
updatesector(startposx,startposy,&startsectnum);
|
|
||||||
ExtPreSaveMap();
|
|
||||||
if (pathsearchmode) f = boardfilename;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// virtual filesystem mode can't save to directories so drop the file into
|
|
||||||
// the current directory
|
|
||||||
f = Bstrrchr(boardfilename, '/');
|
|
||||||
if (!f) f = boardfilename; else f++;
|
|
||||||
}
|
|
||||||
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
|
||||||
ExtSaveMap(f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ')
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (keystatus[1] || keystatus[0x2e])
|
while (keystatus[1] || keystatus[0x2e])
|
||||||
{
|
{
|
||||||
keystatus[1] = 0;
|
keystatus[1] = 0;
|
||||||
|
@ -5124,6 +5003,7 @@ CANCEL:
|
||||||
showframe(1);
|
showframe(1);
|
||||||
goto CANCEL;
|
goto CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearfilenames();
|
clearfilenames();
|
||||||
uninittimer();
|
uninittimer();
|
||||||
uninitinput();
|
uninitinput();
|
||||||
|
@ -5131,9 +5011,7 @@ CANCEL:
|
||||||
uninitengine();
|
uninitengine();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// printmessage16("");
|
// printmessage16("");
|
||||||
showframe(1);
|
showframe(1);
|
||||||
}
|
}
|
||||||
|
@ -5185,6 +5063,140 @@ CANCEL:
|
||||||
VM_OnEvent(EVENT_ENTER3DMODE, -1);
|
VM_OnEvent(EVENT_ENTER3DMODE, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t ask_if_sure(const char *query, int32_t quit_is_yes)
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
if (!query)
|
||||||
|
_printmessage16("Are you sure?");
|
||||||
|
else
|
||||||
|
_printmessage16("%s", query);
|
||||||
|
showframe(1);
|
||||||
|
bflushchars();
|
||||||
|
while ((keystatus[1]|keystatus[0x2e]) == 0)
|
||||||
|
{
|
||||||
|
if (handleevents())
|
||||||
|
{
|
||||||
|
if (quitevent)
|
||||||
|
{
|
||||||
|
if (quit_is_yes)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
quitevent = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
idle();
|
||||||
|
|
||||||
|
ch = bgetchar();
|
||||||
|
|
||||||
|
if (ch == 'y' || ch == 'Y')
|
||||||
|
return 1;
|
||||||
|
else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ')
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// flags: 1:no ExSaveMap (backup.map)
|
||||||
|
const char *SaveBoard(const char *fn, uint32_t flags)
|
||||||
|
{
|
||||||
|
const char *f;
|
||||||
|
int32_t ret;
|
||||||
|
|
||||||
|
if (!fn)
|
||||||
|
fn = boardfilename;
|
||||||
|
|
||||||
|
if (pathsearchmode)
|
||||||
|
f = fn;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// virtual filesystem mode can't save to directories so drop the file into
|
||||||
|
// the current directory
|
||||||
|
f = Bstrrchr(fn, '/');
|
||||||
|
if (!f)
|
||||||
|
f = fn;
|
||||||
|
else
|
||||||
|
f++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixspritesectors(); //Do this before saving!
|
||||||
|
updatesector(startposx,startposy,&startsectnum);
|
||||||
|
ExtPreSaveMap();
|
||||||
|
ret = saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
||||||
|
if ((flags&1)==0)
|
||||||
|
ExtSaveMap(f);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
return f;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// flags: 1: for running on Mapster32 init
|
||||||
|
// 4: passed to loadboard flags (no polymer_loadboard); implies no maphack loading
|
||||||
|
int32_t LoadBoard(const char *filename, uint32_t flags)
|
||||||
|
{
|
||||||
|
int32_t i;
|
||||||
|
|
||||||
|
if (!filename)
|
||||||
|
filename = selectedboardfilename;
|
||||||
|
|
||||||
|
if (filename != boardfilename)
|
||||||
|
Bstrcpy(boardfilename, filename);
|
||||||
|
|
||||||
|
if ((flags&1)==0)
|
||||||
|
{
|
||||||
|
highlightcnt = -1;
|
||||||
|
Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights
|
||||||
|
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
|
||||||
|
|
||||||
|
newnumwalls = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sectorhighlightstat = -1;
|
||||||
|
/// joinsector[0] = -1;
|
||||||
|
/// circlewall = -1;
|
||||||
|
/// circlepoints = 7;
|
||||||
|
|
||||||
|
for (i=0; i<MAXSECTORS; i++) sector[i].extra = -1;
|
||||||
|
for (i=0; i<MAXWALLS; i++) wall[i].extra = -1;
|
||||||
|
for (i=0; i<MAXSPRITES; i++) sprite[i].extra = -1;
|
||||||
|
|
||||||
|
ExtPreLoadMap();
|
||||||
|
i = loadboard(boardfilename,(flags&4)|(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
||||||
|
if ((flags&4)==0)
|
||||||
|
loadmhk(0);
|
||||||
|
if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
// printmessage16("Invalid map format.");
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExtLoadMap(boardfilename);
|
||||||
|
|
||||||
|
if (mapversion < 7) message("Map %s loaded successfully and autoconverted to V7!",boardfilename);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = CheckMapCorruption(4);
|
||||||
|
message("Loaded map %s %s",boardfilename, i==0?"successfully":
|
||||||
|
(i<4 ? "(moderate corruption)" : "(HEAVY corruption)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatenumsprites();
|
||||||
|
startposx = pos.x; //this is same
|
||||||
|
startposy = pos.y;
|
||||||
|
startposz = pos.z;
|
||||||
|
startang = ang;
|
||||||
|
startsectnum = cursectnum;
|
||||||
|
|
||||||
|
/// oposz = pos.z;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
|
void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
|
||||||
{
|
{
|
||||||
bclamp(&pos.x, -editorgridextent, editorgridextent);
|
bclamp(&pos.x, -editorgridextent, editorgridextent);
|
||||||
|
@ -5594,58 +5606,6 @@ static int32_t movewalls(int32_t start, int32_t offs)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
|
||||||
{
|
|
||||||
int32_t j, k, startwall, endwall, x1, y1, x2, y2, numnewwalls=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;
|
|
||||||
}
|
|
||||||
|
|
||||||
x1 = wall[i].x;
|
|
||||||
y1 = wall[i].y;
|
|
||||||
x2 = POINT2(i).x;
|
|
||||||
y2 = POINT2(i).y;
|
|
||||||
|
|
||||||
if (wall[i].nextwall >= 0) //Check for early exit
|
|
||||||
{
|
|
||||||
k = wall[i].nextwall;
|
|
||||||
if (wall[k].x == x2 && wall[k].y == y2)
|
|
||||||
if (POINT2(k).x == x1 && POINT2(k).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 (POINT2(k).x == x1 && POINT2(k).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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void fixrepeats(int16_t i)
|
void fixrepeats(int16_t i)
|
||||||
{
|
{
|
||||||
int32_t dist = wallength(i);
|
int32_t dist = wallength(i);
|
||||||
|
@ -6018,12 +5978,14 @@ static int32_t getfilenames(const char *path, const char *kind)
|
||||||
// copied off menuselect
|
// copied off menuselect
|
||||||
|
|
||||||
static const char *g_oldpath=NULL;
|
static const char *g_oldpath=NULL;
|
||||||
static int32_t menuselect_pk(int32_t direction) // 20080104: jump to next (direction!=0) or prev (direction==0) file
|
static int32_t menuselect_auto(int32_t direction) // 20080104: jump to next (direction!=0) or prev (direction==0) file
|
||||||
{
|
{
|
||||||
const char *chptr;
|
const char *boardbasename;
|
||||||
|
|
||||||
if (!g_oldpath) return -3;
|
if (!g_oldpath)
|
||||||
else Bmemcpy(selectedboardfilename, g_oldpath, BMAX_PATH);
|
return -3; // not inited
|
||||||
|
else
|
||||||
|
Bmemcpy(selectedboardfilename, g_oldpath, BMAX_PATH);
|
||||||
|
|
||||||
if (pathsearchmode)
|
if (pathsearchmode)
|
||||||
Bcanonicalisefilename(selectedboardfilename, 1); // clips off the last token and compresses relative path
|
Bcanonicalisefilename(selectedboardfilename, 1); // clips off the last token and compresses relative path
|
||||||
|
@ -6031,25 +5993,35 @@ static int32_t menuselect_pk(int32_t direction) // 20080104: jump to next (direc
|
||||||
Bcorrectfilename(selectedboardfilename, 1);
|
Bcorrectfilename(selectedboardfilename, 1);
|
||||||
|
|
||||||
getfilenames(selectedboardfilename, "*.map");
|
getfilenames(selectedboardfilename, "*.map");
|
||||||
|
if (numfiles==0)
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
boardbasename = Bstrrchr(boardfilename,'/'); // PK
|
||||||
|
if (!boardbasename)
|
||||||
|
boardbasename=boardfilename;
|
||||||
|
else
|
||||||
|
boardbasename++;
|
||||||
|
|
||||||
chptr = Bstrrchr(boardfilename,'/'); // PK
|
|
||||||
if (!chptr) chptr=boardfilename; else chptr++;
|
|
||||||
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
||||||
{
|
if (!Bstrcmp(findfileshigh->name,boardbasename))
|
||||||
if (!Bstrcmp(findfileshigh->name,chptr)) break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (!findfileshigh) findfileshigh=findfiles;
|
if (!findfileshigh)
|
||||||
|
findfileshigh=findfiles;
|
||||||
|
|
||||||
if (direction)
|
if (direction)
|
||||||
{
|
{
|
||||||
if (findfileshigh->next)
|
if (findfileshigh->next)
|
||||||
findfileshigh=findfileshigh->next;
|
findfileshigh=findfileshigh->next;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (findfileshigh->prev)
|
if (findfileshigh->prev)
|
||||||
findfileshigh=findfileshigh->prev;
|
findfileshigh=findfileshigh->prev;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bstrcat(selectedboardfilename, findfileshigh->name);
|
Bstrcat(selectedboardfilename, findfileshigh->name);
|
||||||
|
@ -6062,12 +6034,12 @@ static int32_t menuselect(void)
|
||||||
{
|
{
|
||||||
int32_t listsize;
|
int32_t listsize;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
char ch, buffer[96], /*PK*/ *chptr;
|
char ch, buffer[96], /*PK*/ *boardbasename;
|
||||||
static char oldpath[BMAX_PATH];
|
static char oldpath[BMAX_PATH];
|
||||||
CACHE1D_FIND_REC *dir;
|
CACHE1D_FIND_REC *dir;
|
||||||
int32_t bakpathsearchmode = pathsearchmode;
|
int32_t bakpathsearchmode = pathsearchmode;
|
||||||
|
|
||||||
g_oldpath=oldpath; //PK: need it in menuselect_pk
|
g_oldpath=oldpath; //PK: need it in menuselect_auto
|
||||||
|
|
||||||
Bstrcpy(selectedboardfilename, oldpath);
|
Bstrcpy(selectedboardfilename, oldpath);
|
||||||
if (pathsearchmode)
|
if (pathsearchmode)
|
||||||
|
@ -6078,13 +6050,18 @@ static int32_t menuselect(void)
|
||||||
getfilenames(selectedboardfilename, "*.map");
|
getfilenames(selectedboardfilename, "*.map");
|
||||||
|
|
||||||
// PK 20080103: start with last selected map
|
// PK 20080103: start with last selected map
|
||||||
chptr = Bstrrchr(boardfilename,'/');
|
boardbasename = Bstrrchr(boardfilename,'/');
|
||||||
if (!chptr) chptr=boardfilename; else chptr++;
|
if (!boardbasename)
|
||||||
|
boardbasename=boardfilename;
|
||||||
|
else
|
||||||
|
boardbasename++;
|
||||||
|
|
||||||
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
for (; findfileshigh; findfileshigh=findfileshigh->next)
|
||||||
{
|
if (!Bstrcmp(findfileshigh->name,boardbasename))
|
||||||
if (!Bstrcmp(findfileshigh->name,chptr)) break;
|
break;
|
||||||
}
|
|
||||||
if (!findfileshigh) findfileshigh=findfiles;
|
if (!findfileshigh)
|
||||||
|
findfileshigh=findfiles;
|
||||||
|
|
||||||
begindrawing();
|
begindrawing();
|
||||||
_printmessage16("Select map file with arrow keys and enter.");
|
_printmessage16("Select map file with arrow keys and enter.");
|
||||||
|
@ -6100,9 +6077,9 @@ static int32_t menuselect(void)
|
||||||
CLEARLINES2D(0, ydim16, 0);
|
CLEARLINES2D(0, ydim16, 0);
|
||||||
|
|
||||||
if (pathsearchmode)
|
if (pathsearchmode)
|
||||||
Bstrcpy(buffer,"Local filesystem mode; press F for game filesystem.");
|
Bstrcpy(buffer,"Local filesystem mode. Ctrl-F: game filesystem");
|
||||||
else
|
else
|
||||||
Bsprintf(buffer,"Game filesystem %smode; press F for local filesystem or G for %s.",
|
Bsprintf(buffer,"Game filesystem %smode. Ctrl-F: local filesystem, Ctrl-G: %s",
|
||||||
grponlymode?"GRP-only ":"", grponlymode?"all files":"GRP contents only");
|
grponlymode?"GRP-only ":"", grponlymode?"all files":"GRP contents only");
|
||||||
|
|
||||||
printext16(halfxdim16-(8*Bstrlen(buffer)/2), 4, editorcolors[12],editorcolors[0],buffer,0);
|
printext16(halfxdim16-(8*Bstrlen(buffer)/2), 4, editorcolors[12],editorcolors[0],buffer,0);
|
||||||
|
@ -6183,6 +6160,7 @@ static int32_t menuselect(void)
|
||||||
idle();
|
idle();
|
||||||
|
|
||||||
ch = bgetchar();
|
ch = bgetchar();
|
||||||
|
|
||||||
{
|
{
|
||||||
// JBF 20040208: seek to first name matching pressed character
|
// JBF 20040208: seek to first name matching pressed character
|
||||||
CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs;
|
CACHE1D_FIND_REC *seeker = currentlist ? findfiles : finddirs;
|
||||||
|
@ -6220,13 +6198,18 @@ static int32_t menuselect(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char ch2;
|
char ch2;
|
||||||
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')))
|
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
||||||
|
(ch >= '0' && ch <= '9') || (ch=='_')))
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
if (ch >= 'a') ch -= ('a'-'A');
|
if (ch >= 'a') ch -= ('a'-'A');
|
||||||
|
#endif
|
||||||
while (seeker)
|
while (seeker)
|
||||||
{
|
{
|
||||||
ch2 = seeker->name[0];
|
ch2 = seeker->name[0];
|
||||||
|
#ifdef _WIN32
|
||||||
if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A');
|
if (ch2 >= 'a' && ch2 <= 'z') ch2 -= ('a'-'A');
|
||||||
|
#endif
|
||||||
if (ch2 == ch) break;
|
if (ch2 == ch) break;
|
||||||
seeker = seeker->next;
|
seeker = seeker->next;
|
||||||
}
|
}
|
||||||
|
@ -6245,7 +6228,7 @@ static int32_t menuselect(void)
|
||||||
if (keystatus[0xd0]) ch = 80; // down arr
|
if (keystatus[0xd0]) ch = 80; // down arr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch == 'f' || ch == 'F')
|
if (ch==6) // Ctrl-F
|
||||||
{
|
{
|
||||||
currentlist = 0;
|
currentlist = 0;
|
||||||
pathsearchmode = 1-pathsearchmode;
|
pathsearchmode = 1-pathsearchmode;
|
||||||
|
@ -6259,7 +6242,7 @@ static int32_t menuselect(void)
|
||||||
getfilenames(selectedboardfilename, "*.map");
|
getfilenames(selectedboardfilename, "*.map");
|
||||||
Bstrcpy(oldpath,selectedboardfilename);
|
Bstrcpy(oldpath,selectedboardfilename);
|
||||||
}
|
}
|
||||||
else if (ch == 'g' || ch == 'G')
|
else if (ch==7) // Ctrl-G
|
||||||
{
|
{
|
||||||
if (!pathsearchmode)
|
if (!pathsearchmode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -629,6 +629,9 @@ int32_t kopen4load(const char *filename, char searchfirst)
|
||||||
char bad, *gfileptr;
|
char bad, *gfileptr;
|
||||||
intptr_t i;
|
intptr_t i;
|
||||||
|
|
||||||
|
if (filename==NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
while (filehan[newhandle] != -1)
|
while (filehan[newhandle] != -1)
|
||||||
{
|
{
|
||||||
newhandle--;
|
newhandle--;
|
||||||
|
|
|
@ -1908,7 +1908,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t loaddefinitionsfile(char *fn)
|
int32_t loaddefinitionsfile(const char *fn)
|
||||||
{
|
{
|
||||||
scriptfile *script;
|
scriptfile *script;
|
||||||
int32_t f = flushlogwindow;
|
int32_t f = flushlogwindow;
|
||||||
|
|
|
@ -168,6 +168,10 @@ qlz_state_decompress *state_decompress = NULL;
|
||||||
|
|
||||||
int32_t whitecol;
|
int32_t whitecol;
|
||||||
|
|
||||||
|
#ifdef POLYMER
|
||||||
|
static int16_t maphacklightcnt=0;
|
||||||
|
static int16_t maphacklight[PR_MAXLIGHTS];
|
||||||
|
#endif
|
||||||
|
|
||||||
////////// editor side view //////////
|
////////// editor side view //////////
|
||||||
int32_t m32_sideview = 0;
|
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 int16_t *tempictoidx;
|
||||||
|
|
||||||
static sectortype *loadsector;
|
static sectortype *loadsector;
|
||||||
static walltype *loadwall;
|
static walltype *loadwall, *loadwallinv;
|
||||||
static spritetype *loadsprite;
|
static spritetype *loadsprite;
|
||||||
|
|
||||||
// sectoidx bits
|
// sectoidx bits
|
||||||
|
@ -273,6 +277,7 @@ static void clipmapinfo_init()
|
||||||
|
|
||||||
if (loadsector) { Bfree(loadsector); loadsector=NULL; }
|
if (loadsector) { Bfree(loadsector); loadsector=NULL; }
|
||||||
if (loadwall) { Bfree(loadwall); loadwall=NULL; }
|
if (loadwall) { Bfree(loadwall); loadwall=NULL; }
|
||||||
|
if (loadwallinv) { Bfree(loadwallinv); loadwallinv=NULL; }
|
||||||
if (loadsprite) { Bfree(loadsprite); loadsprite=NULL; }
|
if (loadsprite) { Bfree(loadsprite); loadsprite=NULL; }
|
||||||
|
|
||||||
clipmapinfo.numsectors = clipmapinfo.numwalls = 0;
|
clipmapinfo.numsectors = clipmapinfo.numwalls = 0;
|
||||||
|
@ -285,7 +290,7 @@ static void clipmapinfo_init()
|
||||||
|
|
||||||
// loads the clip maps 0 through 9.
|
// loads the clip maps 0 through 9.
|
||||||
// this should be called before any real map is loaded.
|
// 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;
|
int32_t i,k,w, px,py,pz;
|
||||||
int16_t ang,cs;
|
int16_t ang,cs;
|
||||||
|
@ -635,6 +640,56 @@ int32_t clipmapinfo_load(char *filename)
|
||||||
Bmemcpy(loadsector, sector, ournumsectors*sizeof(sectortype));
|
Bmemcpy(loadsector, sector, ournumsectors*sizeof(sectortype));
|
||||||
Bmemcpy(loadwall, wall, ournumwalls*sizeof(walltype));
|
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.numsectors = numsectors;
|
||||||
clipmapinfo.sector = loadsector;
|
clipmapinfo.sector = loadsector;
|
||||||
clipmapinfo.numwalls = numwalls;
|
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
|
// don't let other code be distracted by the temporary map we constructed
|
||||||
numsectors = 0;
|
numsectors = 0;
|
||||||
numwalls = 0;
|
numwalls = 0;
|
||||||
|
initspritelists();
|
||||||
|
|
||||||
initprintf("Loaded clip map%s %s.\n", lwcp==loadedwhich+1?"":"s", loadedwhich);
|
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)
|
#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
|
// 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 *daang, int16_t *dacursectnum)
|
||||||
{
|
{
|
||||||
int16_t fil, i, numsprites, dq[MAXSPRITES], dnum = 0;
|
int16_t fil, i, numsprites, dq[MAXSPRITES], dnum = 0;
|
||||||
|
char myflags = flags&(~3);
|
||||||
|
|
||||||
|
flags &= 3;
|
||||||
|
|
||||||
i = strlen(filename)-1;
|
i = strlen(filename)-1;
|
||||||
if (filename[i] == 255) { filename[i] = 0; fromwhere = 1; } // JBF 20040119: "compatibility"
|
if (filename[i] == 255) { filename[i] = 0; flags = 1; } // JBF 20040119: "compatibility"
|
||||||
if ((fil = kopen4load(filename,fromwhere)) == -1)
|
if ((fil = kopen4load(filename,flags)) == -1)
|
||||||
{ mapversion = 7L; return(-1); }
|
{ mapversion = 7L; return(-1); }
|
||||||
|
|
||||||
kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion);
|
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
|
# ifdef POLYMER
|
||||||
if (rendmode == 4)
|
if (rendmode == 4)
|
||||||
|
{
|
||||||
|
if ((myflags&4)==0)
|
||||||
polymer_loadboard();
|
polymer_loadboard();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -7728,12 +7847,26 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d
|
||||||
return(0);
|
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
|
// loadmaphack
|
||||||
//
|
//
|
||||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||||
int32_t loadmaphack(char *filename)
|
int32_t loadmaphack(const char *filename)
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -7781,6 +7914,11 @@ int32_t loadmaphack(char *filename)
|
||||||
int32_t whichsprite = -1;
|
int32_t whichsprite = -1;
|
||||||
static char fn[BMAX_PATH];
|
static char fn[BMAX_PATH];
|
||||||
|
|
||||||
|
#ifdef POLYMER
|
||||||
|
for (i=0; i<PR_MAXLIGHTS; i++)
|
||||||
|
maphacklight[i] = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
{
|
{
|
||||||
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
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
|
case T_LIGHT: // light sector x y z range r g b radius faderadius angle horiz minshade maxshade priority tilenum
|
||||||
{
|
{
|
||||||
int32_t value;
|
int32_t value;
|
||||||
|
int16_t lightid;
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
_prlight light;
|
_prlight light;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
@ -7992,7 +8131,11 @@ int32_t loadmaphack(char *filename)
|
||||||
light.tilenum = value;
|
light.tilenum = value;
|
||||||
|
|
||||||
if (rendmode == 4)
|
if (rendmode == 4)
|
||||||
polymer_addlight(&light);
|
{
|
||||||
|
lightid = polymer_addlight(&light);
|
||||||
|
if (lightid>=0)
|
||||||
|
maphacklight[maphacklightcnt++] = lightid;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8015,7 +8158,7 @@ int32_t loadmaphack(char *filename) { UNREFERENCED_PARAMETER(filename); return -
|
||||||
//
|
//
|
||||||
// saveboard
|
// 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 *daang, int16_t *dacursectnum)
|
||||||
{
|
{
|
||||||
int16_t fil, i, j, numsprites, ts;
|
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;
|
spritetype *spri;
|
||||||
|
|
||||||
if ((fil = Bopen(filename,BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
|
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);
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
for (j=0; j<MAXSPRITES; j++)if ((unsigned)sprite[j].statnum>MAXSTATUS)
|
for (j=0; j<MAXSPRITES; j++)if ((unsigned)sprite[j].statnum>MAXSTATUS)
|
||||||
{
|
{
|
||||||
|
@ -8362,7 +8508,7 @@ void nextpage(void)
|
||||||
//
|
//
|
||||||
// loadpics
|
// loadpics
|
||||||
//
|
//
|
||||||
int32_t loadpics(char *filename, int32_t askedsize)
|
int32_t loadpics(const char *filename, int32_t askedsize)
|
||||||
{
|
{
|
||||||
int32_t offscount, localtilestart, localtileend, dasiz;
|
int32_t offscount, localtilestart, localtileend, dasiz;
|
||||||
int16_t fil, i, j, k;
|
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
|
// qloadkvx
|
||||||
//
|
//
|
||||||
#ifdef SUPERBUILD
|
#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;
|
int32_t i, fil, dasiz, lengcnt, lengtot;
|
||||||
char *ptr;
|
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;
|
rotang = (curspr->ang - sector[j].CM_ANG)&2047;
|
||||||
dorot = !CM_NOROTS(j);
|
dorot = !CM_NOROTS(j);
|
||||||
if (dorot)
|
if (dorot)
|
||||||
|
{
|
||||||
flipmul = flipx*flipy;
|
flipmul = flipx*flipy;
|
||||||
|
if (flipmul==-1)
|
||||||
|
wall = loadwallinv;
|
||||||
|
}
|
||||||
|
|
||||||
if ((curspr->cstat&128) != (sector[j].CM_CSTAT&128))
|
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);
|
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->x += curspr->x;
|
||||||
wal->y += curspr->y;
|
wal->y += curspr->y;
|
||||||
|
|
||||||
if (flipmul==-1)
|
|
||||||
wal->x = vect->x - (wal->x-vect->x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inside(vect->x, vect->y, j)==1)
|
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;
|
int32_t hitwall, cnt, clipyou;
|
||||||
|
|
||||||
spritetype *curspr=NULL; // non-NULL when handling sprite with sector-like clipping
|
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);
|
if (((xvect|yvect) == 0) || (*sectnum < 0)) return(0);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
@ -9741,7 +9888,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
||||||
continue;
|
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;
|
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;
|
dax = vect->x, day = vect->y;
|
||||||
daz = getflorzofslope((int16_t)dasect,dax,day);
|
daz = getflorzofslope((int16_t)dasect,dax,day);
|
||||||
daz2 = getflorzofslope(wal->nextsector,dax,day);
|
daz2 = getflorzofslope(wal->nextsector,dax,day);
|
||||||
|
@ -9826,20 +9973,10 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
|
||||||
if (!curspr)
|
if (!curspr)
|
||||||
objtype = (int16_t)j+32768;
|
objtype = (int16_t)j+32768;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
objtype = (int16_t)(curspr-sprite)+49152;
|
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
|
//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(x1-bsz,y1-bsz,x1-bsz,y1+bsz,objtype);
|
||||||
addclipline(x2-bsz,y2-bsz,x2-bsz,y2+bsz,objtype);
|
addclipline(x2-bsz,y2-bsz,x2-bsz,y2+bsz,objtype);
|
||||||
bsz = walldist; if (gy < 0) bsz = -bsz;
|
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 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 stx, i, x, y, charxsiz, ocol = col, obackcol = backcol;
|
||||||
|
int32_t ymin=0, ymax=7;
|
||||||
char *fontptr, *letptr, *ptr;
|
char *fontptr, *letptr, *ptr;
|
||||||
char smallbuf[4];
|
char smallbuf[4];
|
||||||
|
|
||||||
stx = xpos;
|
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 & 2) printext16(xpos+1, ypos+1, 0, -1, name, (fontsize & ~2) | 4);
|
||||||
if (fontsize & 1) { fontptr = smalltextfont; charxsiz = 4; }
|
if (fontsize & 1) { fontptr = smalltextfont; charxsiz = 4; }
|
||||||
else { fontptr = textfont; charxsiz = 8; }
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stx<0)
|
||||||
|
{
|
||||||
|
stx += charxsiz;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
letptr = &fontptr[name[i]<<3];
|
letptr = &fontptr[name[i]<<3];
|
||||||
ptr = (char *)(bytesperline*(ypos+7)+(stx-(fontsize&1))+frameplace);
|
ptr = (char *)(bytesperline*ypos + (stx-(fontsize&1)) + frameplace);
|
||||||
for (y=7; y>=0; y--)
|
for (y=ymin; y<=ymax; y++)
|
||||||
{
|
{
|
||||||
for (x=charxsiz-1; x>=0; x--)
|
for (x=0; x<charxsiz; x++)
|
||||||
{
|
{
|
||||||
|
if (stx+x >= xdim)
|
||||||
|
break;
|
||||||
if (letptr[y]&pow2char[7-(fontsize&1)-x])
|
if (letptr[y]&pow2char[7-(fontsize&1)-x])
|
||||||
ptr[x] = (uint8_t)col;
|
ptr[x] = (uint8_t)col;
|
||||||
else if (backcol >= 0)
|
else if (backcol >= 0)
|
||||||
ptr[x] = (uint8_t)backcol;
|
ptr[x] = (uint8_t)backcol;
|
||||||
}
|
}
|
||||||
ptr -= bytesperline;
|
ptr += bytesperline;
|
||||||
}
|
}
|
||||||
stx += charxsiz;
|
stx += charxsiz;
|
||||||
|
if (stx >= xdim)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
enddrawing(); //}}}
|
enddrawing(); //}}}
|
||||||
|
|
||||||
|
@ -13021,7 +13183,7 @@ void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const
|
||||||
//
|
//
|
||||||
// screencapture
|
// screencapture
|
||||||
//
|
//
|
||||||
int32_t screencapture_tga(char *filename, char inverseit)
|
int32_t screencapture_tga(const char *filename, char inverseit)
|
||||||
{
|
{
|
||||||
int32_t i,j;
|
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 };
|
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);
|
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;
|
int32_t i,j,bpl;
|
||||||
char *ptr, head[128];
|
char *ptr, head[128];
|
||||||
|
@ -13339,7 +13501,7 @@ int32_t screencapture_pcx(char *filename, char inverseit)
|
||||||
return(0);
|
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);
|
if (captureformat == 0) return screencapture_tga(filename,inverseit);
|
||||||
else return screencapture_pcx(filename,inverseit);
|
else return screencapture_pcx(filename,inverseit);
|
||||||
|
|
|
@ -117,7 +117,7 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect)
|
||||||
// hicsetsubsttex(picnum,pal,filen,alphacut)
|
// hicsetsubsttex(picnum,pal,filen,alphacut)
|
||||||
// Specifies a replacement graphic file for an ART tile.
|
// 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;
|
hicreplctyp *hr, *hrn;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
|
|
||||||
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect) { }
|
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 hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]) { return 0; }
|
||||||
int32_t hicclearsubst(int32_t picnum, int32_t palnum) { return 0; }
|
int32_t hicclearsubst(int32_t picnum, int32_t palnum) { return 0; }
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,6 @@ Notes:
|
||||||
* The clipping will not change with rendering modes or options.
|
* The clipping will not change with rendering modes or options.
|
||||||
|
|
||||||
|
|
||||||
Known bugs:
|
|
||||||
-----------
|
|
||||||
|
|
||||||
* Flipping doesn't work correctly
|
|
||||||
|
|
||||||
|
|
||||||
Predicted bugs:
|
Predicted bugs:
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,9 @@ int32_t showambiencesounds=2;
|
||||||
|
|
||||||
int32_t autocorruptcheck = 0;
|
int32_t autocorruptcheck = 0;
|
||||||
static int32_t corruptchecktimer;
|
static int32_t corruptchecktimer;
|
||||||
|
static int32_t curcorruptthing=-1;
|
||||||
|
|
||||||
|
int32_t numcorruptthings=0, corruptthings[MAXCORRUPTTHINGS];
|
||||||
|
|
||||||
static uint32_t templenrepquot;
|
static uint32_t templenrepquot;
|
||||||
static void fixxrepeat(int16_t i, uint32_t lenrepquot)
|
static void fixxrepeat(int16_t i, uint32_t lenrepquot)
|
||||||
|
@ -192,6 +195,17 @@ static int16_t tilemarked[(MAXTILES+7)>>3];
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
static int16_t spritelightid[MAXSPRITES];
|
static int16_t spritelightid[MAXSPRITES];
|
||||||
_prlight *spritelightptr[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
|
#endif
|
||||||
extern int32_t graphicsmode;
|
extern int32_t graphicsmode;
|
||||||
|
|
||||||
|
@ -5508,12 +5522,7 @@ static void Keys3d(void)
|
||||||
S_ClearSoundLocks();
|
S_ClearSoundLocks();
|
||||||
|
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
for (i=0; i<MAXSPRITES; i++)
|
DeletePolymerLights();
|
||||||
if (spritelightptr[i] != NULL)
|
|
||||||
{
|
|
||||||
polymer_deletelight(spritelightid[i]);
|
|
||||||
spritelightptr[i] = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5540,12 +5549,7 @@ static void Keys3d(void)
|
||||||
message("Map shade preview %s", shadepreview?"enabled":"disabled");
|
message("Map shade preview %s", shadepreview?"enabled":"disabled");
|
||||||
|
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
for (i=0; i<MAXSPRITES; i++)
|
DeletePolymerLights();
|
||||||
if (spritelightptr[i] != NULL)
|
|
||||||
{
|
|
||||||
polymer_deletelight(spritelightid[i]);
|
|
||||||
spritelightptr[i] = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6593,7 +6597,7 @@ static void Keys3d(void)
|
||||||
|
|
||||||
static void DoSpriteSearch(int32_t dir) // <0: backwards, >=0: forwards
|
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;
|
int32_t i, j, k = 0;
|
||||||
|
|
||||||
dir = 1-2*(dir<0);
|
dir = 1-2*(dir<0);
|
||||||
|
@ -6672,12 +6676,20 @@ static void DoSpriteSearch(int32_t dir) // <0: backwards, >=0: forwards
|
||||||
}
|
}
|
||||||
|
|
||||||
// found matching sprite
|
// found matching sprite
|
||||||
|
if (pos.x >= -editorgridextent && pos.x <= editorgridextent &&
|
||||||
|
pos.y >= -editorgridextent && pos.y <= editorgridextent)
|
||||||
|
{
|
||||||
pos.x = sprite[gs_cursprite].x;
|
pos.x = sprite[gs_cursprite].x;
|
||||||
pos.y = sprite[gs_cursprite].y;
|
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;
|
ang = sprite[gs_cursprite].ang;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
outofgrid = 1;
|
||||||
|
|
||||||
printmessage16("%s Sprite seach%s: found sprite %d", dir<0 ? "<" : ">",
|
printmessage16("%s Sprite seach%s: found sprite %d%s", dir<0 ? "<" : ">",
|
||||||
did_wrap ? " (wrap)" : "", gs_cursprite);
|
did_wrap ? " (wrap)" : "", gs_cursprite, outofgrid?"(outside grid)":"");
|
||||||
did_wrap = 0;
|
did_wrap = 0;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -6694,19 +6706,20 @@ static void Keys2d(void)
|
||||||
int32_t i=0, j, k;
|
int32_t i=0, j, k;
|
||||||
int32_t smooshy, changedir;
|
int32_t smooshy, changedir;
|
||||||
static int32_t repeatcnt[2] = {0,0}; // was repeatcountx, repeatcounty
|
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);
|
// 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++)
|
for (i=0; i<numsectors; i++)
|
||||||
{
|
{
|
||||||
if (inside(mousxplc,mousyplc,i) == 1)
|
if (inside(mousxplc,mousyplc,i) == 1)
|
||||||
{
|
{
|
||||||
cursectornum = i;
|
tcursectornum = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchsector = cursectornum;
|
searchsector = tcursectornum;
|
||||||
|
|
||||||
if (eitherCTRL && PRESSED_KEYSC(Z)) // CTRL+Z
|
if (eitherCTRL && PRESSED_KEYSC(Z)) // CTRL+Z
|
||||||
{
|
{
|
||||||
|
@ -6731,16 +6744,16 @@ static void Keys2d(void)
|
||||||
drawgradient();
|
drawgradient();
|
||||||
showspritedata(pointhighlight&16383, 0);
|
showspritedata(pointhighlight&16383, 0);
|
||||||
}
|
}
|
||||||
else if (linehighlight >= 0 /* && ((bstatus&1) || sectorofwall(linehighlight)==cursectornum)*/)
|
else if (linehighlight >= 0 /* && ((bstatus&1) || sectorofwall(linehighlight)==tcursectornum)*/)
|
||||||
{
|
{
|
||||||
drawgradient();
|
drawgradient();
|
||||||
showwalldata(linehighlight, 0);
|
showwalldata(linehighlight, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cursectornum >= 0)
|
else if (tcursectornum >= 0)
|
||||||
{
|
{
|
||||||
drawgradient();
|
drawgradient();
|
||||||
showsectordata(cursectornum, 0);
|
showsectordata(tcursectornum, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(keystatus[KEYSC_F5]|keystatus[KEYSC_F6]|keystatus[KEYSC_F7]|keystatus[KEYSC_F8]) && !eitherSHIFT)
|
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;
|
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)
|
if (omx == mousxplc && omy == mousyplc)
|
||||||
{
|
{
|
||||||
|
@ -6766,7 +6779,7 @@ static void Keys2d(void)
|
||||||
/*
|
/*
|
||||||
opointhighlight = pointhighlight;
|
opointhighlight = pointhighlight;
|
||||||
olinehighlight = linehighlight;
|
olinehighlight = linehighlight;
|
||||||
ocursectornum = cursectornum;
|
ocursectornum = tcursectornum;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -6782,10 +6795,10 @@ static void Keys2d(void)
|
||||||
if (sprite[i].picnum==SECTOREFFECTOR)
|
if (sprite[i].picnum==SECTOREFFECTOR)
|
||||||
_printmessage16("^10%s", SectorEffectorText(i));
|
_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);
|
showwalldata(linehighlight, 1);
|
||||||
else if (cursectornum >= 0)
|
else if (tcursectornum >= 0)
|
||||||
showsectordata(cursectornum, 1);
|
showsectordata(tcursectornum, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7032,7 +7045,70 @@ static void Keys2d(void)
|
||||||
|
|
||||||
if (tsign)
|
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);
|
SearchSectors(tsign);
|
||||||
else if (wallsprite==1)
|
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.x = wall[i].x - (wall[i].x-POINT2(i).x)/2;
|
||||||
pos.y = wall[i].y - (wall[i].y-POINT2(i).y)/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?"<":">");
|
printmessage16("%s Wall search: found", tsign<0?"<":">");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9138,25 +9215,13 @@ void app_crashhandler(void)
|
||||||
{
|
{
|
||||||
if (levelname[0])
|
if (levelname[0])
|
||||||
{
|
{
|
||||||
char *f;
|
char *f = strstr(levelname,".map");
|
||||||
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");
|
|
||||||
if (f)
|
if (f)
|
||||||
Bstrcpy(f,"_crash.map");
|
Bstrcpy(f,"_crash.map");
|
||||||
else Bstrcat(f,"_crash.map");
|
else Bstrcat(f,"_crash.map");
|
||||||
ExtPreSaveMap();
|
|
||||||
saveboard(levelname,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
SaveBoard(f, 1);
|
||||||
ExtSaveMap(levelname);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -9737,16 +9802,6 @@ static void Keys2d3d(void)
|
||||||
|
|
||||||
if (eitherCTRL) //CTRL
|
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 (PRESSED_KEYSC(P)) // Ctrl-P: Map playtesting
|
||||||
{
|
{
|
||||||
if (qsetmode != 200)
|
if (qsetmode != 200)
|
||||||
|
@ -9758,56 +9813,50 @@ static void Keys2d3d(void)
|
||||||
if (levelname[0])
|
if (levelname[0])
|
||||||
{
|
{
|
||||||
keystatus[KEYSC_S] = 0;
|
keystatus[KEYSC_S] = 0;
|
||||||
fixspritesectors(); //Do this before saving!
|
|
||||||
updatesector(startposx,startposy,&startsectnum);
|
i = CheckMapCorruption(4);
|
||||||
ExtPreSaveMap();
|
if (i<4)
|
||||||
saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
{
|
||||||
ExtSaveMap(f);
|
SaveBoard(levelname, 0);
|
||||||
|
|
||||||
message("Board saved");
|
message("Board saved");
|
||||||
asksave = 0;
|
asksave = 0;
|
||||||
lastsave=totalclock;
|
lastsave=totalclock;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
message("Map is heavily corrupted, not saving. See OSD for details.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (keystatus[KEYSC_L]) // L
|
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?"))
|
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;
|
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;
|
lastsave=totalclock;
|
||||||
highlightcnt = -1;
|
|
||||||
// sectorhighlightstat = -1;
|
// sectorhighlightstat = -1;
|
||||||
// newnumwalls = -1;
|
// newnumwalls = -1;
|
||||||
// joinsector[0] = -1;
|
// joinsector[0] = -1;
|
||||||
// circlewall = -1;
|
// circlewall = -1;
|
||||||
// circlepoints = 7;
|
// circlepoints = 7;
|
||||||
|
|
||||||
for (i=MAXSECTORS-1; i>=0; i--) sector[i].extra = -1;
|
if (LoadBoard(f, 0))
|
||||||
for (i=MAXWALLS-1; i>=0; i--) wall[i].extra = -1;
|
message("Invalid map format.");
|
||||||
for (i=MAXSPRITES-1; i>=0; i--) sprite[i].extra = -1;
|
|
||||||
|
|
||||||
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;
|
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)
|
if (autocorruptcheck>0 && totalclock > corruptchecktimer)
|
||||||
{
|
{
|
||||||
CheckMapCorruption(0);
|
if (CheckMapCorruption(3)>=4)
|
||||||
|
message("Corruption detected. See OSD for details.");
|
||||||
corruptchecktimer = totalclock + 120*autocorruptcheck;
|
corruptchecktimer = totalclock + 120*autocorruptcheck;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9934,12 +9984,17 @@ void ExtCheckKeys(void)
|
||||||
{
|
{
|
||||||
if (asksave == 3)
|
if (asksave == 3)
|
||||||
{
|
{
|
||||||
fixspritesectors(); //Do this before saving!
|
if (CheckMapCorruption(6)>=4)
|
||||||
// updatesector(startposx,startposy,&startsectnum);
|
{
|
||||||
ExtPreSaveMap();
|
SaveBoard("autosave_corrupt.map", 1);
|
||||||
saveboard("autosave.map",&startposx,&startposy,&startposz,&startang,&startsectnum);
|
message("Board autosaved to AUTOSAVE_CORRUPT.MAP");
|
||||||
ExtSaveMap("autosave.map");
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SaveBoard("autosave.map", 0);
|
||||||
message("Board autosaved to AUTOSAVE.MAP");
|
message("Board autosaved to AUTOSAVE.MAP");
|
||||||
|
}
|
||||||
|
|
||||||
asksave = 4;
|
asksave = 4;
|
||||||
}
|
}
|
||||||
autosavetimer = totalclock+120*autosave;
|
autosavetimer = totalclock+120*autosave;
|
||||||
|
@ -9955,14 +10010,13 @@ void ExtCheckKeys(void)
|
||||||
|
|
||||||
//// port of a.m32's corruptchk ////
|
//// port of a.m32's corruptchk ////
|
||||||
// returns value from 0 (all OK) to 5 (panic!)
|
// 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); \
|
bad = max(bad, errlev); \
|
||||||
|
if (numcorruptthings<MAXCORRUPTTHINGS) \
|
||||||
|
corruptthings[numcorruptthings++] = what; \
|
||||||
if (errlev >= printfromlev) \
|
if (errlev >= printfromlev) \
|
||||||
{ \
|
|
||||||
OSD_Printf(fmt "\n", ## __VA_ARGS__); \
|
OSD_Printf(fmt "\n", ## __VA_ARGS__); \
|
||||||
if (qsetmode!=200) printmessage16(fmt, ## __VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int32_t CheckMapCorruption(int32_t printfromlev)
|
int32_t CheckMapCorruption(int32_t printfromlev)
|
||||||
|
@ -9972,11 +10026,13 @@ int32_t CheckMapCorruption(int32_t printfromlev)
|
||||||
|
|
||||||
int32_t errlevel=0, bad=0;
|
int32_t errlevel=0, bad=0;
|
||||||
|
|
||||||
|
numcorruptthings = 0;
|
||||||
|
|
||||||
if (numsectors>MAXSECTORS)
|
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)
|
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)
|
if (numsectors>MAXSECTORS || numwalls>MAXWALLS)
|
||||||
return bad;
|
return bad;
|
||||||
|
@ -9989,21 +10045,21 @@ int32_t CheckMapCorruption(int32_t printfromlev)
|
||||||
numw = sector[i].wallnum;
|
numw = sector[i].wallnum;
|
||||||
|
|
||||||
if (w0 < 0 || w0 > numwalls)
|
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)
|
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)
|
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)
|
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;
|
ewall += numw;
|
||||||
|
|
||||||
endwall = w0 + numw;
|
endwall = w0 + numw;
|
||||||
if (endwall > numwalls)
|
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)
|
if (bad)
|
||||||
errlevel = max(errlevel, bad);
|
errlevel = max(errlevel, bad);
|
||||||
|
@ -10016,37 +10072,37 @@ int32_t CheckMapCorruption(int32_t printfromlev)
|
||||||
bad = 0;
|
bad = 0;
|
||||||
|
|
||||||
if (wall[j].point2 < w0 || wall[j].point2 > endwall)
|
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);
|
j, wall[j].point2, w0, endwall);
|
||||||
|
|
||||||
nw = wall[j].nextwall;
|
nw = wall[j].nextwall;
|
||||||
ns = wall[j].nextsector;
|
ns = wall[j].nextsector;
|
||||||
|
|
||||||
if (nw >= numwalls)
|
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);
|
j, nw, numwalls);
|
||||||
|
|
||||||
if (ns >= numsectors)
|
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);
|
j, ns, numsectors);
|
||||||
|
|
||||||
if (ns == i)
|
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)
|
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)
|
if (!bad)
|
||||||
errlevel = max(errlevel, bad);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (ns>=0 || (ns^nw)<0)
|
if (ns>=0 || (ns^nw)<0)
|
||||||
{
|
{
|
||||||
if ((ns^nw)<0 || nw<sector[ns].wallptr || nw>=sector[ns].wallptr+sector[ns].wallnum)
|
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);
|
j, ns, nw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errlevel = max(errlevel, bad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10058,19 +10114,22 @@ int32_t CheckMapCorruption(int32_t printfromlev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sprite[i].sectnum<0 || sprite[i].sectnum>=numsectors)
|
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)
|
if (sprite[i].picnum<0 || sprite[i].picnum>=MAXTILES)
|
||||||
{
|
{
|
||||||
sprite[i].picnum = 0;
|
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);
|
errlevel = max(errlevel, bad);
|
||||||
|
|
||||||
if (errlevel)
|
if (errlevel)
|
||||||
OSD_Printf("--\n");
|
{
|
||||||
|
if (printfromlev<=errlevel)
|
||||||
|
OSD_Printf("-- corruption level: %d\n", errlevel);
|
||||||
|
}
|
||||||
|
|
||||||
return 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.x = wall[sector[ii].wallptr].x;
|
||||||
pos.y = wall[sector[ii].wallptr].y;
|
pos.y = wall[sector[ii].wallptr].y;
|
||||||
printmessage16("%s Sector search: found", dir<0?"<":">");
|
printmessage16("%s Sector search: found", dir<0?"<":">");
|
||||||
|
cursectornum = ii;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cursectornum += dir;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printmessage16("%s Sector search: none found", dir<0?"<":">");
|
printmessage16("%s Sector search: none found", dir<0?"<":">");
|
||||||
|
|
|
@ -2864,7 +2864,7 @@ dodefault:
|
||||||
int32_t col=Gv_GetVarX(*insptr++), odrawlinepat=drawlinepat;
|
int32_t col=Gv_GetVarX(*insptr++), odrawlinepat=drawlinepat;
|
||||||
int32_t xofs=0, yofs=0, eccen=16384;
|
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);
|
screencoords(&x1,&y1, x1-pos.x,y1-pos.y, zoom);
|
||||||
if (m32_sideview)
|
if (m32_sideview)
|
||||||
|
|
|
@ -78,7 +78,7 @@ static int32_t lastmessagetime=-1;
|
||||||
static char tempbuf[1024];
|
static char tempbuf[1024];
|
||||||
static int32_t numsprite[MAXSPRITES], multisprite[MAXSPRITES];
|
static int32_t numsprite[MAXSPRITES], multisprite[MAXSPRITES];
|
||||||
static char lo[64];
|
static char lo[64];
|
||||||
static char levelname[255];
|
static char levelname[BMAX_PATH];
|
||||||
static int16_t curwall=0, curwallnum=0;
|
static int16_t curwall=0, curwallnum=0;
|
||||||
static int16_t /*cursearchsprite=0,*/ cursearchspritenum=0, cursector_lotag=0, cursectornum=0;
|
static int16_t /*cursearchsprite=0,*/ cursearchspritenum=0, cursector_lotag=0, cursectornum=0;
|
||||||
static int16_t search_lotag=0,search_hitag=0;
|
static int16_t search_lotag=0,search_hitag=0;
|
||||||
|
|
Loading…
Reference in a new issue