From 1ab930ea285a999b017a057426142b1c7eca7d09 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Thu, 9 Apr 2015 07:52:28 +0000 Subject: [PATCH] Defs: Add "undefinetile" and "undefinetilerange". git-svn-id: https://svn.eduke32.com/eduke32@5127 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/defs.c | 61 +++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 22bc29d22..f5f7311b5 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -85,6 +85,7 @@ enum scripttoken_t T_LOADGRP, T_DUMMYTILE,T_DUMMYTILERANGE, T_SETUPTILE,T_SETUPTILERANGE, + T_UNDEFINETILE,T_UNDEFINETILERANGE, T_ANIMTILERANGE, T_CACHESIZE, T_IMPORTTILE, @@ -217,6 +218,19 @@ static void tile_from_truecolpic(int32_t tile, const palette_t *picptr, int32_t } } +static void undefinetile(int32_t tile) +{ + tilesiz[tile].x = 0; + tilesiz[tile].y = 0; + picsiz[tile] = 0; + // CACHE1D_FREE + walock[tile] = 1; + waloff[tile] = 0; + DO_FREE_AND_NULL(faketiledata[tile]); + faketile[tile>>3] &= ~pow2char[tile&7]; + Bmemset(&picanm[tile], 0, sizeof(picanm_t)); +} + #undef USE_DEF_PROGRESS #if defined _WIN32 || defined HAVE_GTK2 # define USE_DEF_PROGRESS @@ -283,6 +297,8 @@ static int32_t defsparser(scriptfile *script) { "dummytilerange", T_DUMMYTILERANGE }, { "setuptile", T_SETUPTILE }, { "setuptilerange", T_SETUPTILERANGE }, + { "undefinetile", T_UNDEFINETILE }, + { "undefinetilrange",T_UNDEFINETILERANGE }, { "animtilerange", T_ANIMTILERANGE }, { "cachesize", T_CACHESIZE }, { "dummytilefrompic",T_IMPORTTILE }, @@ -725,6 +741,14 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&xsiz)) break; if (scriptfile_getsymbol(script,&ysiz)) break; + if ((unsigned)tile >= (unsigned)MAXUSERTILES) break; + + if ((int16_t) xsiz == 0 || (int16_t) ysiz == 0) + { + undefinetile(tile); + break; + } + if (xsiz > 0 && ysiz > 0) { set_tilesiz(tile, xsiz, ysiz); @@ -746,9 +770,16 @@ static int32_t defsparser(scriptfile *script) if (check_tile_range("dummytilerange", &tile1, &tile2, script, cmdtokptr)) break; - if (xsiz <= 0 || ysiz <= 0) + if (xsiz < 0 || ysiz < 0) break; // TODO: message + if ((int16_t) xsiz == 0 || (int16_t) ysiz == 0) + { + for (i=tile1; i<=tile2; i++) + undefinetile(i); + break; + } + for (i=tile1; i<=tile2; i++) { set_tilesiz(i, xsiz, ysiz); @@ -759,6 +790,34 @@ static int32_t defsparser(scriptfile *script) break; } + case T_UNDEFINETILE: + { + int32_t tile; + + if (scriptfile_getsymbol(script,&tile)) break; + + if ((unsigned)tile >= (unsigned)MAXUSERTILES) break; + + undefinetile(tile); + + break; + } + case T_UNDEFINETILERANGE: + { + int32_t tile1, tile2; + + if (scriptfile_getnumber(script,&tile1)) break; + if (scriptfile_getnumber(script,&tile2)) break; + + if (check_tile_range("undefinetilerange", &tile1, &tile2, script, cmdtokptr)) + break; + + for (int32_t i = tile1; i <= tile2; i++) + undefinetile(i); + + break; + } + case T_DEFINEMODEL: { char *modelfn;