Ignore bogus POF counts

Instead of blacklisting two specific bad N_save_pof_names values, ignore
all N_save_pof_names that would overrun the Save_pof_names array.

This allows Rebirth to load broken levels such as "Hazard Zone"[1].  In
the case of Hazard Zone, the POF count is simply missing, so the first
two characters of the first POF name were taken as a count.  This led to
a massive overrun of the Save_pof_names array.

[1]:
```
sha1sum hazard.msn hazard.rdl
25abe7ba1aca91f0bd09551e65cfadeabfcb73df  hazard.msn
f5e6761b674b595550b27733fd83eeb2eff5e8f8  hazard.rdl
```
This commit is contained in:
Kp 2017-07-15 21:50:22 +00:00
parent d4f1c894aa
commit 8b713978fc

View file

@ -160,7 +160,6 @@ static int is_real_level(const char *filename)
int Gamesave_num_players=0;
#if defined(DXX_BUILD_DESCENT_I)
int N_save_pof_names=25;
#define MAX_POLYGON_MODELS_NEW 167
static array<char[FILENAME_LEN], MAX_POLYGON_MODELS_NEW> Save_pof_names;
@ -184,7 +183,6 @@ static int convert_polymod(int polymod) {
return (polymod >= N_polygon_models) ? polymod % N_polygon_models : polymod;
}
#elif defined(DXX_BUILD_DESCENT_II)
int N_save_pof_names;
static array<char[FILENAME_LEN], MAX_POLYGON_MODELS> Save_pof_names;
#endif
@ -897,11 +895,11 @@ static int load_game_data(PHYSFS_File *LoadFile)
Current_level_name.next()[0]=0;
if (game_top_fileinfo_version >= 19) { //load pof names
N_save_pof_names = PHYSFSX_readShort(LoadFile);
if (N_save_pof_names != 0x614d && N_save_pof_names != 0x5547) { // "Ma"de w/DMB beta/"GU"ILE
Assert(N_save_pof_names < MAX_POLYGON_MODELS);
const unsigned N_save_pof_names = PHYSFSX_readShort(LoadFile);
if (N_save_pof_names < MAX_POLYGON_MODELS)
PHYSFS_read(LoadFile,Save_pof_names,N_save_pof_names,FILENAME_LEN);
}
else
LevelError("Level contains bogus N_save_pof_names %#x; ignoring", N_save_pof_names);
}
//===================== READ PLAYER INFO ==========================