mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
A couple of Mapster changes related to saving.
- new mapster32.cfg and OSD variable 'fixmaponsave_sprites', telling the editor whether to 'fix' the sprite sectnums on saving and entering 3D mode. Note that a) sprite sectnums are never fixed when 'script_expertmode' is enabled, as before, and b) sprites that have out-of-bounds sectnums are still fixed if a proper sector is found - if saving and some sprite sectnums have thus been tweaked, inform the mapper on the status line and print the changes in the OSD - fix update issue similar to an earlier one: when 'saving as', the astub.c- based file name is now updated too, so saving with Ctrl-S now saves into the one save with 'save as' (and not the old one) - don't attempt to recheck wall pointers from scratch (when saving and running with -check) if it's a TROR map git-svn-id: https://svn.eduke32.com/eduke32@2110 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e18ef2ccc8
commit
b2d789731a
4 changed files with 101 additions and 44 deletions
|
@ -151,7 +151,7 @@ extern void AlignWallPoint2(int32_t w0);
|
|||
extern int32_t AutoAlignWalls(int32_t w0, uint32_t flags, int32_t nrecurs);
|
||||
|
||||
extern void SetFirstWall(int32_t sectnum, int32_t wallnum);
|
||||
extern void fixspritesectors(void);
|
||||
extern int32_t fixspritesectors(void);
|
||||
extern void clearkeys(void);
|
||||
|
||||
extern int32_t ExtInit(void);
|
||||
|
@ -161,8 +161,9 @@ extern void ExtPreCheckKeys(void);
|
|||
extern void ExtAnalyzeSprites(void);
|
||||
extern void ExtCheckKeys(void);
|
||||
extern void ExtPreLoadMap(void);
|
||||
extern void ExtSetupMapFilename(const char *mapname);
|
||||
extern void ExtLoadMap(const char *mapname);
|
||||
extern void ExtPreSaveMap(void);
|
||||
extern int32_t ExtPreSaveMap(void);
|
||||
extern void ExtSaveMap(const char *mapname);
|
||||
extern const char *ExtGetSectorCaption(int16_t sectnum);
|
||||
extern const char *ExtGetWallCaption(int16_t wallnum);
|
||||
|
@ -188,6 +189,7 @@ extern int32_t autocorruptcheck;
|
|||
extern int32_t corruptcheck_noalreadyrefd;
|
||||
extern int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing);
|
||||
|
||||
extern int32_t fixmaponsave_sprites;
|
||||
extern int32_t m32_script_expertmode; // if true, make read-only vars writable
|
||||
|
||||
extern void showsectordata(int16_t sectnum, int16_t small);
|
||||
|
|
|
@ -143,6 +143,7 @@ typedef struct
|
|||
|
||||
static int32_t backup_highlighted_map(mapinfofull_t *mapinfo);
|
||||
static int32_t restore_highlighted_map(mapinfofull_t *mapinfo);
|
||||
static void SaveBoardAndPrintMessage(const char *fn);
|
||||
static const char *GetSaveBoardFilename(void);
|
||||
|
||||
/*
|
||||
|
@ -185,7 +186,7 @@ int8_t sideview_reversehrot = 0;
|
|||
char lastpm16buf[156];
|
||||
|
||||
//static int32_t checksectorpointer_warn = 0;
|
||||
static int32_t saveboard_savedtags=0;
|
||||
static int32_t saveboard_savedtags, saveboard_fixedsprites;
|
||||
|
||||
char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck);
|
||||
static int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls);
|
||||
|
@ -206,7 +207,7 @@ static void copysector(int16_t soursector, int16_t destsector, int16_t deststart
|
|||
int32_t drawtilescreen(int32_t pictopleft, int32_t picbox);
|
||||
void overheadeditor(void);
|
||||
static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line);
|
||||
void fixspritesectors(void);
|
||||
int32_t fixspritesectors(void);
|
||||
static int32_t movewalls(int32_t start, int32_t offs);
|
||||
int32_t loadnames(const char *namesfile, int8_t root);
|
||||
void updatenumsprites(void);
|
||||
|
@ -6829,7 +6830,6 @@ CANCEL:
|
|||
}
|
||||
else if (bad == 2)
|
||||
{
|
||||
const char *f;
|
||||
char *slash;
|
||||
|
||||
keystatus[0x1c] = 0;
|
||||
|
@ -6839,25 +6839,15 @@ CANCEL:
|
|||
slash = Bstrrchr(selectedboardfilename,'/');
|
||||
Bstrcpy(slash ? slash+1 : selectedboardfilename, boardfilename);
|
||||
|
||||
_printmessage16("Saving board...");
|
||||
showframe(1);
|
||||
|
||||
f = SaveBoard(selectedboardfilename, 0);
|
||||
|
||||
if (f)
|
||||
printmessage16("Saved board %sto %s.",
|
||||
saveboard_savedtags?"and tags ":"", f);
|
||||
else
|
||||
printmessage16("Saving board failed.");
|
||||
SaveBoardAndPrintMessage(selectedboardfilename);
|
||||
|
||||
Bstrcpy(boardfilename, selectedboardfilename);
|
||||
ExtSetupMapFilename(boardfilename);
|
||||
}
|
||||
bad = 0;
|
||||
}
|
||||
else if (ch == 's' || ch == 'S') //S
|
||||
{
|
||||
const char *f;
|
||||
|
||||
bad = 0;
|
||||
|
||||
if (CheckMapCorruption(4, 0)>=4)
|
||||
|
@ -6867,16 +6857,7 @@ CANCEL:
|
|||
break;
|
||||
}
|
||||
|
||||
_printmessage16("Saving board...");
|
||||
showframe(1);
|
||||
|
||||
f = SaveBoard(NULL, 0);
|
||||
|
||||
if (f)
|
||||
printmessage16("Saved board %sto %s.",
|
||||
saveboard_savedtags?"and tags ":"", f);
|
||||
else
|
||||
printmessage16("Saving board failed.");
|
||||
SaveBoardAndPrintMessage(NULL);
|
||||
|
||||
showframe(1);
|
||||
}
|
||||
|
@ -7059,6 +7040,33 @@ static int32_t ask_above_or_below(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void SaveBoardAndPrintMessage(const char *fn)
|
||||
{
|
||||
const char *f;
|
||||
|
||||
_printmessage16("Saving board...");
|
||||
showframe(1);
|
||||
|
||||
f = SaveBoard(fn, 0);
|
||||
|
||||
if (f)
|
||||
{
|
||||
if (saveboard_fixedsprites)
|
||||
printmessage16("Saved board %sto %s (changed sectnums of %d sprites).",
|
||||
saveboard_savedtags?"and tags ":"", f, saveboard_fixedsprites);
|
||||
else
|
||||
printmessage16("Saved board %sto %s.", saveboard_savedtags?"and tags ":"", f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (saveboard_fixedsprites)
|
||||
printmessage16("Saving board failed (changed sectnums of %d sprites).",
|
||||
saveboard_fixedsprites);
|
||||
else
|
||||
printmessage16("Saving board failed.");
|
||||
}
|
||||
}
|
||||
|
||||
// get the file name of the file that would be written if SaveBoard(NULL, 0) was called
|
||||
static const char *GetSaveBoardFilename(void)
|
||||
{
|
||||
|
@ -7080,7 +7088,7 @@ static const char *GetSaveBoardFilename(void)
|
|||
return f;
|
||||
}
|
||||
|
||||
// flags: 1:no ExSaveMap (backup.map) and no taglabels saving
|
||||
// flags: 1:no ExtSaveMap (backup.map) and no taglabels saving
|
||||
const char *SaveBoard(const char *fn, uint32_t flags)
|
||||
{
|
||||
const char *f;
|
||||
|
@ -7104,7 +7112,7 @@ const char *SaveBoard(const char *fn, uint32_t flags)
|
|||
f++;
|
||||
}
|
||||
|
||||
ExtPreSaveMap();
|
||||
saveboard_fixedsprites = ExtPreSaveMap();
|
||||
ret = saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
|
||||
if ((flags&1)==0)
|
||||
{
|
||||
|
@ -7635,16 +7643,20 @@ static int32_t deletesector(int16_t sucksect)
|
|||
return(0);
|
||||
}
|
||||
|
||||
void fixspritesectors(void)
|
||||
int32_t fixspritesectors(void)
|
||||
{
|
||||
int32_t i, j, dax, day, cz, fz;
|
||||
int32_t numfixedsprites = 0, printfirsttime = 0;
|
||||
|
||||
for (i=numsectors-1; i>=0; i--)
|
||||
if (sector[i].wallnum <= 0 || sector[i].wallptr >= numwalls)
|
||||
{
|
||||
deletesector(i);
|
||||
initprintf("Deleted sector %d which had corrupt .wallnum or .wallptr\n", i);
|
||||
}
|
||||
|
||||
if (m32_script_expertmode)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
for (i=0; i<MAXSPRITES; i++)
|
||||
if (sprite[i].statnum < MAXSTATUS)
|
||||
|
@ -7663,12 +7675,25 @@ void fixspritesectors(void)
|
|||
|
||||
if (cz <= sprite[i].z && sprite[i].z <= fz)
|
||||
{
|
||||
if (fixmaponsave_sprites || (sprite[i].sectnum < 0 || sprite[i].sectnum >= numsectors))
|
||||
{
|
||||
numfixedsprites++;
|
||||
|
||||
if (printfirsttime == 0)
|
||||
{
|
||||
initprintf("--------------------\n");
|
||||
printfirsttime = 1;
|
||||
}
|
||||
initprintf("Changed sectnum of sprite %d from %d to %d\n", i, sprite[i].sectnum, j);
|
||||
changespritesect(i, j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return numfixedsprites;
|
||||
}
|
||||
|
||||
static int32_t movewalls(int32_t start, int32_t offs)
|
||||
|
|
|
@ -266,6 +266,8 @@ int32_t loadsetup(const char *fn)
|
|||
if (readconfig(fp, "autocorruptchecksec", val, VL) > 0) autocorruptcheck = max(0, atoi_safe(val));
|
||||
if (readconfig(fp, "corruptcheck_noalreadyrefd", val, VL) > 0)
|
||||
corruptcheck_noalreadyrefd = !!atoi_safe(val);
|
||||
if (readconfig(fp, "fixmaponsave_sprites", val, VL) > 0)
|
||||
fixmaponsave_sprites = !!atoi_safe(val);
|
||||
|
||||
if (readconfig(fp, "showheightindicators", val, VL) > 0)
|
||||
showheightindicators = clamp(atoi_safe(val), 0, 2);
|
||||
|
@ -474,6 +476,9 @@ int32_t writesetup(const char *fn)
|
|||
"; (toggled with 'corruptcheck noalreadyrefd')\n"
|
||||
"corruptcheck_noalreadyrefd = %d\n"
|
||||
"\n"
|
||||
"; Fix sprite sectnums when saving a map or entering 3D mode\n"
|
||||
"fixmaponsave_sprites = %d\n"
|
||||
"\n"
|
||||
"; Height indicators (0:none, 1:only 2-sided&different, 2:all)\n"
|
||||
"showheightindicators = %d\n"
|
||||
"\n"
|
||||
|
@ -573,7 +578,7 @@ int32_t writesetup(const char *fn)
|
|||
msens, unrealedlook, pk_uedaccel, quickmapcycling,
|
||||
sideview_reversehrot,
|
||||
revertCTRL,scrollamount,pk_turnaccel,pk_turndecel,autosave,autocorruptcheck,
|
||||
corruptcheck_noalreadyrefd, showheightindicators,showambiencesounds,
|
||||
corruptcheck_noalreadyrefd, fixmaponsave_sprites, showheightindicators,showambiencesounds,
|
||||
autogray,showinnergray,
|
||||
graphicsmode,
|
||||
MixRate,AmbienceToggle,ParentalLock, !!m32_osd_tryscript,
|
||||
|
|
|
@ -69,7 +69,8 @@ static char *setupfilename = "mapster32.cfg";
|
|||
static char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp";
|
||||
static char *g_grpNamePtr = defaultduke3dgrp;
|
||||
char *g_defNamePtr = defsfilename;
|
||||
static int32_t fixmapbeforesaving = 0;
|
||||
int32_t fixmaponsave_sprites = 1;
|
||||
static int32_t fixmaponsave_walls = 0;
|
||||
static int32_t lastsave = -180*60;
|
||||
static int32_t NoAutoLoad = 0;
|
||||
static int32_t spnoclip=1;
|
||||
|
@ -803,6 +804,15 @@ static void MultiPskyInit(void)
|
|||
parallaxyscale = 32768;
|
||||
}
|
||||
|
||||
|
||||
void ExtSetupMapFilename(const char *mapname)
|
||||
{
|
||||
Bstrcpy(levelname, mapname);
|
||||
|
||||
Bsprintf(tempbuf, "Mapster32 - %s", mapname);
|
||||
wm_setapptitle(tempbuf);
|
||||
}
|
||||
|
||||
void ExtLoadMap(const char *mapname)
|
||||
{
|
||||
int32_t i;
|
||||
|
@ -811,7 +821,7 @@ void ExtLoadMap(const char *mapname)
|
|||
getmessageleng = 0;
|
||||
getmessagetimeoff = 0;
|
||||
|
||||
Bstrcpy(levelname,mapname);
|
||||
ExtSetupMapFilename(mapname);
|
||||
|
||||
// old-fashioned multi-psky handling
|
||||
|
||||
|
@ -851,11 +861,9 @@ void ExtLoadMap(const char *mapname)
|
|||
parallaxtype=0;
|
||||
|
||||
//////////
|
||||
Bsprintf(tempbuf, "Mapster32 - %s",mapname);
|
||||
#if M32_UNDO
|
||||
map_undoredo_free();
|
||||
#endif
|
||||
wm_setapptitle(tempbuf);
|
||||
}
|
||||
|
||||
void ExtSaveMap(const char *mapname)
|
||||
|
@ -8331,14 +8339,16 @@ static void InitCustomColors(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ExtPreSaveMap(void)
|
||||
int32_t ExtPreSaveMap(void)
|
||||
{
|
||||
fixspritesectors(); //Do this before saving!
|
||||
int32_t numfixedsprites;
|
||||
|
||||
numfixedsprites = fixspritesectors(); //Do this before saving!
|
||||
updatesectorz(startposx,startposy,startposz,&startsectnum);
|
||||
if (startsectnum < 0)
|
||||
updatesector(startposx,startposy,&startsectnum);
|
||||
|
||||
if (fixmapbeforesaving)
|
||||
if (fixmaponsave_walls)
|
||||
{
|
||||
int32_t i, startwall, j, endwall;
|
||||
|
||||
|
@ -8348,6 +8358,9 @@ void ExtPreSaveMap(void)
|
|||
for (j=startwall; j<numwalls; j++)
|
||||
if (wall[j].point2 < startwall)
|
||||
startwall = wall[j].point2;
|
||||
if (sector[i].wallptr != startwall)
|
||||
initprintf("Warning: set sector %d's wallptr to %d (was %d)\n", i,
|
||||
sector[i].wallptr, startwall);
|
||||
sector[i].wallptr = startwall;
|
||||
}
|
||||
|
||||
|
@ -8355,6 +8368,11 @@ void ExtPreSaveMap(void)
|
|||
sector[i].wallnum = sector[i+1].wallptr-sector[i].wallptr;
|
||||
sector[numsectors-1].wallnum = numwalls - sector[numsectors-1].wallptr;
|
||||
|
||||
#ifdef YAX_ENABLE
|
||||
// setting redwalls from scratch would very likely wreak havoc with TROR maps
|
||||
if (numyaxbunches > 0)
|
||||
return numfixedsprites;
|
||||
#endif
|
||||
for (i=0; i<numwalls; i++)
|
||||
{
|
||||
wall[i].nextsector = -1;
|
||||
|
@ -8368,6 +8386,8 @@ void ExtPreSaveMap(void)
|
|||
checksectorpointer(j, i);
|
||||
}
|
||||
}
|
||||
|
||||
return numfixedsprites;
|
||||
}
|
||||
|
||||
static void G_ShowParameterHelp(void)
|
||||
|
@ -8614,15 +8634,15 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
|||
}
|
||||
if (!Bstrcasecmp(c+1,"check"))
|
||||
{
|
||||
initprintf("Map pointer checking on saving enabled\n");
|
||||
fixmapbeforesaving = 1;
|
||||
initprintf("Map wall checking on save enabled\n");
|
||||
fixmaponsave_walls = 1;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (!Bstrcasecmp(c+1,"nocheck"))
|
||||
{
|
||||
initprintf("Map pointer checking disabled\n");
|
||||
fixmapbeforesaving = 0;
|
||||
initprintf("Map wall checking on save disabled\n");
|
||||
fixmaponsave_walls = 0;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
@ -8954,6 +8974,11 @@ static int32_t osdcmd_vars_pk(const osdfuncparm_t *parm)
|
|||
else
|
||||
OSD_Printf("M32 Script expert mode DISABLED.\n");
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->name, "fixmaponsave_sprites"))
|
||||
{
|
||||
OSD_Printf("Fix sprite sectnums on map saving: %s\n",
|
||||
(fixmaponsave_sprites = !fixmaponsave_sprites) ? "enabled":"disabled");
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->name, "show_heightindicators"))
|
||||
{
|
||||
static const char *how[3] = {"none", "two-sided walls only", "all"};
|
||||
|
|
Loading…
Reference in a new issue