diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 2d8eb0ff2..3366b5bca 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -72,6 +72,8 @@ enum rendmode_t { #define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3)) #define MAXTILES 30720 +#define MAXUSERTILES (MAXTILES-16) // reserve 16 tiles at the end + #define MAXVOXELS 4096 #define MAXSTATUS 1024 #define MAXPLAYERS 16 diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 7914f4715..8ddb6a8cb 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -94,7 +94,7 @@ enum scripttoken_t }; static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0; -int32_t nextvoxid = 0; +static int32_t nextvoxid = 0; #ifdef USE_OPENGL extern float alphahackarray[MAXTILES]; @@ -146,7 +146,7 @@ static int32_t check_tile_range(const char *defcmd, int32_t *tilebeg, int32_t *t swaplong(tilebeg, tileend); } - if ((unsigned)*tilebeg >= MAXTILES || (unsigned)*tileend >= MAXTILES) + if ((unsigned)*tilebeg >= MAXUSERTILES || (unsigned)*tileend >= MAXUSERTILES) { initprintf("Error: %s: Invalid tile range on line %s:%d\n", defcmd, script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -159,7 +159,7 @@ static int32_t check_tile_range(const char *defcmd, int32_t *tilebeg, int32_t *t static int32_t check_tile(const char *defcmd, int32_t tile, const scriptfile *script, const char *cmdtokptr) { - if ((unsigned)tile >= MAXTILES) + if ((unsigned)tile >= MAXUSERTILES) { initprintf("Error: %s: Invalid tile number on line %s:%d\n", defcmd, script->filename, scriptfile_getlinum(script,cmdtokptr)); @@ -469,7 +469,7 @@ static int32_t defsparser(scriptfile *script) int32_t tile, tmp; if (scriptfile_getsymbol(script,&tile)) break; - if (tile >= MAXTILES)break; + if ((unsigned)tile >= MAXUSERTILES) break; if (scriptfile_getsymbol(script,&h_xsize[tile])) break; // XXX if (scriptfile_getsymbol(script,&h_ysize[tile])) break; if (scriptfile_getsymbol(script,&tmp)) break; @@ -585,7 +585,7 @@ static int32_t defsparser(scriptfile *script) } } - if ((unsigned)tile >= MAXTILES) + if ((unsigned)tile >= MAXUSERTILES) { initprintf("Error: missing or invalid 'tile number' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,texturetokptr)); @@ -1807,7 +1807,7 @@ static int32_t defsparser(scriptfile *script) } } - if ((unsigned)tile >= MAXTILES) break; // message is printed later + if ((unsigned)tile >= MAXUSERTILES) break; // message is printed later if ((unsigned)pal >= MAXPALOOKUPS - RESERVEDPALS) { initprintf("Error: missing or invalid 'palette number' for texture definition near " @@ -1886,7 +1886,7 @@ static int32_t defsparser(scriptfile *script) } } - if ((unsigned)tile >= MAXTILES) break; // message is printed later + if ((unsigned)tile >= MAXUSERTILES) break; // message is printed later if (!fn) { initprintf("Error: missing 'file name' for texture definition near line %s:%d\n", @@ -1923,7 +1923,7 @@ static int32_t defsparser(scriptfile *script) break; } } - if ((unsigned)tile >= MAXTILES) + if ((unsigned)tile >= MAXUSERTILES) { initprintf("Error: missing or invalid 'tile number' for texture definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,texturetokptr)); @@ -2050,7 +2050,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getnumber(script,&e)) break; b = max(b, 0); - e = min(e, MAXTILES-1); + e = min(e, MAXUSERTILES-1); for (i=b; i<=e; i++) picanm[i].sf |= (tokn==T_TEXHITSCANRANGE) ? diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 233a24fa3..22417d0fe 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -11027,7 +11027,7 @@ int32_t loadpics(const char *filename, int32_t askedsize) kread(fil,&localtilestart,4); localtilestart = B_LITTLE32(localtilestart); kread(fil,&localtileend,4); localtileend = B_LITTLE32(localtileend); - if ((uint32_t)localtilestart >= MAXTILES || (uint32_t)localtileend >= MAXTILES) + if ((uint32_t)localtilestart >= MAXUSERTILES || (uint32_t)localtileend >= MAXUSERTILES) { initprintf("loadpics: Invalid localtilestart or localtileend in %s\n", artfilename); kclose(fil); diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 4c0764756..8ecefd524 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -102,6 +102,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TILE_TILT (MAXTILES-2) #define TILE_ANIM (MAXTILES-4) #define TILE_VIEWSCR (MAXTILES-5) +EDUKE32_STATIC_ASSERT(5 <= MAXTILES-MAXUSERTILES); // sprites with these statnums should be considered for fixing (bitmap) #define ROTFIXSPR_STATNUMP(k) ((k)==STAT_DEFAULT || (k)==STAT_STANDABLE || (k)==STAT_FX || \