- several smaller texture (un)definition commands.

This commit is contained in:
Christoph Oelckers 2021-04-13 18:17:54 +02:00
parent 8c5a9c23c3
commit 01f93f4cca
3 changed files with 93 additions and 76 deletions

View file

@ -389,90 +389,20 @@ static int32_t defsparser(scriptfile *script)
parseCopyTile(*script, pos); parseCopyTile(*script, pos);
break; break;
case T_IMPORTTILE: case T_IMPORTTILE:
{ parseImportTile(*script, pos);
int32_t tile;
FString fn;
if (scriptfile_getsymbol(script,&tile)) break;
if (scriptfile_getstring(script,&fn)) break;
if (check_tile("importtile", tile, script, pos))
break;
int32_t const texstatus = tileImportFromTexture(fn, tile, 255, 0);
if (texstatus < 0)
break;
picanm[tile] = {};
break; break;
}
case T_DUMMYTILE: case T_DUMMYTILE:
{ parseDummyTile(*script, pos);
int32_t tile, xsiz, ysiz;
if (scriptfile_getsymbol(script,&tile)) break;
if (scriptfile_getsymbol(script,&xsiz)) break;
if (scriptfile_getsymbol(script,&ysiz)) break;
if (check_tile("dummytile", tile, script, pos))
break;
tileSetDummy(tile, xsiz, ysiz);
break; break;
}
case T_DUMMYTILERANGE: case T_DUMMYTILERANGE:
{ parseDummyTileRange(*script, pos);
int32_t tile1,tile2,xsiz,ysiz,i;
if (scriptfile_getsymbol(script,&tile1)) break;
if (scriptfile_getsymbol(script,&tile2)) break;
if (scriptfile_getnumber(script,&xsiz)) break;
if (scriptfile_getnumber(script,&ysiz)) break;
if (check_tile_range("dummytilerange", &tile1, &tile2, script, pos))
break;
if (xsiz < 0 || ysiz < 0)
break; // TODO: message
for (i=tile1; i<=tile2; i++)
{
tileSetDummy(i, xsiz, ysiz);
}
break; break;
}
case T_UNDEFINETILE: case T_UNDEFINETILE:
{ parseUndefineTile(*script, pos);
int32_t tile;
if (scriptfile_getsymbol(script,&tile)) break;
if (check_tile("undefinetile", tile, script, pos))
break;
tileDelete(tile);
break; break;
}
case T_UNDEFINETILERANGE: case T_UNDEFINETILERANGE:
{ parseUndefineTileRange(*script, pos);
int32_t tile1, tile2;
if (scriptfile_getsymbol(script,&tile1)) break;
if (scriptfile_getsymbol(script,&tile2)) break;
if (check_tile_range("undefinetilerange", &tile1, &tile2, script, pos))
break;
for (bssize_t i = tile1; i <= tile2; i++)
tileDelete(i);
break; break;
}
case T_DEFINEMODEL: case T_DEFINEMODEL:
{ {

View file

@ -46,7 +46,7 @@ FString gVolumeSubtitles[MAXVOLUMES];
int32_t gVolumeFlags[MAXVOLUMES]; int32_t gVolumeFlags[MAXVOLUMES];
int gDefaultVolume = 0, gDefaultSkill = 1; int gDefaultVolume = 0, gDefaultSkill = 1;
MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts. MapRecord mapList[512];
MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.) MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.)
MapRecord* lastLevel; // Same here, for the last level. MapRecord* lastLevel; // Same here, for the last level.
unsigned int numUsedSlots; unsigned int numUsedSlots;

View file

@ -317,6 +317,93 @@ void parseCopyTile(FScanner& sc, FScriptPosition& pos)
// //
//=========================================================================== //===========================================================================
void parseImportTile(FScanner& sc, FScriptPosition& pos)
{
int tile;
if (!sc.GetNumber(tile, true)) return;
if (!sc.GetString()) return;
if (!ValidateTilenum("importtile", tile, pos)) return;
int texstatus = tileImportFromTexture(sc.String, tile, 255, 0);
if (texstatus >= 0) TileFiles.tiledata[tile].picanm = {};
}
//===========================================================================
//
//
//
//===========================================================================
void parseDummyTile(FScanner& sc, FScriptPosition& pos)
{
int tile, xsiz, ysiz;
if (!sc.GetNumber(tile, true)) return;
if (!sc.GetNumber(xsiz, true)) return;
if (!sc.GetNumber(ysiz, true)) return;
if (!ValidateTilenum("dummytile", tile, pos)) return;
tileSetDummy(tile, xsiz, ysiz);
}
//===========================================================================
//
//
//
//===========================================================================
void parseDummyTileRange(FScanner& sc, FScriptPosition& pos)
{
int tile1, tile2, xsiz, ysiz;
if (!sc.GetNumber(tile1, true)) return;
if (!sc.GetNumber(tile2, true)) return;
if (!sc.GetNumber(xsiz, true)) return;
if (!sc.GetNumber(ysiz, true)) return;
if (!ValidateTileRange("dummytilerange", tile1, tile2, pos)) return;
if (xsiz < 0 || ysiz < 0) return;
for (int i = tile1; i <= tile2; i++) tileSetDummy(i, xsiz, ysiz);
}
//===========================================================================
//
//
//
//===========================================================================
void parseUndefineTile(FScanner& sc, FScriptPosition& pos)
{
int tile;
if (!sc.GetNumber(tile, true)) return;
if (ValidateTilenum("undefinetile", tile, pos))
tileDelete(tile);
}
//===========================================================================
//
//
//
//===========================================================================
void parseUndefineTileRange(FScanner& sc, FScriptPosition& pos)
{
int tile1, tile2;
if (!sc.GetNumber(tile1, true)) return;
if (!sc.GetNumber(tile2, true)) return;
if (!ValidateTileRange("undefinetilerange", tile1, tile2, pos)) return;
for (int i = tile1; i <= tile2; i++) tileDelete(i);
}
//===========================================================================
//
//
//
//===========================================================================
void parseDefineSkybox(FScanner& sc, FScriptPosition& pos) void parseDefineSkybox(FScanner& sc, FScriptPosition& pos)
{ {
int tile, palette; int tile, palette;