With engine compiled for V7 limits, refuse loading maps exceeding them.

Also, correct the loadboard() return value checks in premap.c to be
aware of a returned -2 ("wrong map version").

git-svn-id: https://svn.eduke32.com/eduke32@2694 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-05-25 18:39:19 +00:00
parent 000cfffe32
commit 5af2088c06
2 changed files with 26 additions and 13 deletions

View file

@ -8996,6 +8996,8 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
//
// flags: 1, 2: former parameter "fromwhere"
// 4: don't call polymer_loadboard
// returns: -1: file not found
// -2: invalid version
int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum)
{
@ -9012,10 +9014,18 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
{ mapversion = 7; return(-1); }
kread(fil,&mapversion,4); mapversion = B_LITTLE32(mapversion);
{
int32_t ok = (mapversion==7);
#ifdef YAX_ENABLE
if (mapversion != 9)
ok |= (mapversion==9);
#endif
if (mapversion != 7 && mapversion != 8) { kclose(fil); return(-2); }
#if MAXSECTORS==MAXSECTORSV8
// v8 engine
ok |= (mapversion==8);
#endif
if (!ok) { kclose(fil); return(-2); }
}
#ifdef NEDMALLOC
nedtrimthreadcache(0, 0);
@ -9023,11 +9033,9 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
initspritelists();
// TODO: need checking for engine compiled with V7 limits, so we
// load V8+ maps ONLY if they don't exceed them.
#define MYMAXSECTORS (mapversion==7?MAXSECTORSV7:MAXSECTORSV8)
#define MYMAXWALLS (mapversion==7?MAXWALLSV7:MAXWALLSV8)
#define MYMAXSPRITES (mapversion==7?MAXSPRITESV7:MAXSPRITESV8)
#define MYMAXSECTORS (MAXSECTORS==MAXSECTORSV7||mapversion==7 ? MAXSECTORSV7 : MAXSECTORSV8)
#define MYMAXWALLS (MAXSECTORS==MAXSECTORSV7||mapversion==7 ? MAXWALLSV7 : MAXWALLSV8)
#define MYMAXSPRITES (MAXSECTORS==MAXSECTORSV7||mapversion==7 ? MAXSPRITESV7 : MAXSPRITESV8)
Bmemset(show2dsector, 0, sizeof(show2dsector));
Bmemset(show2dsprite, 0, sizeof(show2dsprite));

View file

@ -1975,9 +1975,10 @@ int32_t G_EnterLevel(int32_t g)
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
{
if (loadboard(boardfilename,0,&g_player[0].ps->pos.x, &g_player[0].ps->pos.y,
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1)
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found!\n",boardfilename);
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",boardfilename);
//G_GameExit(tempbuf);
return 1;
}
@ -1987,9 +1988,11 @@ int32_t G_EnterLevel(int32_t g)
G_SetupFilenameBasedMusic(levname, boardfilename, ud.m_level_number);
}
else if (loadboard(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,0,&g_player[0].ps->pos.x,
&g_player[0].ps->pos.y, &g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1)
&g_player[0].ps->pos.y, &g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map %s not found!\n",MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",
MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
//G_GameExit(tempbuf);
return 1;
}
@ -2006,9 +2009,11 @@ int32_t G_EnterLevel(int32_t g)
levname[i+1] = 0;
if (loadboard(levname,1,&g_player[0].ps->pos.x, &g_player[0].ps->pos.y,
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1)
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found!\n",MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",
MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
//G_GameExit(tempbuf);
return 1;
}