mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- encapsulate setuptile(range) parsing in separate functions.
This commit is contained in:
parent
0b79649dc2
commit
5c2335bbeb
2 changed files with 31 additions and 32 deletions
|
@ -611,41 +611,13 @@ static int32_t defsparser(scriptfile *script)
|
|||
}
|
||||
break;
|
||||
case T_SETUPTILE:
|
||||
{
|
||||
int tile, tmp;
|
||||
|
||||
if (scriptfile_getsymbol(script,&tile)) break;
|
||||
if (check_tile("setuptile", tile, script, pos))
|
||||
break;
|
||||
auto& tiled = TileFiles.tiledata[tile];
|
||||
if (scriptfile_getsymbol(script,&tiled.hiofs.xsize)) break; // XXX
|
||||
if (scriptfile_getsymbol(script, &tiled.hiofs.ysize)) break;
|
||||
if (scriptfile_getsymbol(script, &tiled.hiofs.xoffs)) break;
|
||||
if (scriptfile_getsymbol(script, &tiled.hiofs.yoffs)) break;
|
||||
parseSetupTile(*script, pos);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_SETUPTILERANGE:
|
||||
{
|
||||
int tile1,tile2;
|
||||
TileOffs t;
|
||||
|
||||
if (scriptfile_getsymbol(script,&tile1)) break;
|
||||
if (scriptfile_getsymbol(script,&tile2)) break;
|
||||
if (scriptfile_getnumber(script,&t.xsize)) break;
|
||||
if (scriptfile_getnumber(script,&t.ysize)) break;
|
||||
if (scriptfile_getsymbol(script,&t.xoffs)) break;
|
||||
if (scriptfile_getsymbol(script,&t.yoffs)) break;
|
||||
|
||||
if (check_tile_range("setuptilerange", &tile1, &tile2, script, pos))
|
||||
break;
|
||||
|
||||
for (int i=tile1; i<=tile2; i++)
|
||||
{
|
||||
TileFiles.tiledata[i].hiofs = t;
|
||||
}
|
||||
|
||||
parseSetupTileRange(*script, pos);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_ANIMTILERANGE:
|
||||
parseAnimTileRange(*script, pos);
|
||||
break;
|
||||
|
|
|
@ -35,6 +35,33 @@
|
|||
**
|
||||
*/
|
||||
|
||||
void parseSetupTile(FScanner& sc, FScriptPosition& pos)
|
||||
{
|
||||
int tile;
|
||||
if (!sc.GetNumber(tile, true)) return;
|
||||
if (!ValidateTilenum("setuptile", tile, pos)) return;
|
||||
auto& tiled = TileFiles.tiledata[tile];
|
||||
if (!sc.GetNumber(tiled.hiofs.xsize, true)) return;
|
||||
if (!sc.GetNumber(tiled.hiofs.ysize, true)) return;
|
||||
if (!sc.GetNumber(tiled.hiofs.xoffs, true)) return;
|
||||
if (!sc.GetNumber(tiled.hiofs.yoffs, true)) return;
|
||||
}
|
||||
|
||||
void parseSetupTileRange(FScanner& sc, FScriptPosition& pos)
|
||||
{
|
||||
int tilestart, tileend;
|
||||
if (!sc.GetNumber(tilestart, true)) return;
|
||||
if (!sc.GetNumber(tileend, true)) return;
|
||||
if (!ValidateTileRange("setuptilerange", tilestart, tileend, pos)) return;
|
||||
|
||||
TileOffs hiofs;
|
||||
if (!sc.GetNumber(hiofs.xsize, true)) return;
|
||||
if (!sc.GetNumber(hiofs.ysize, true)) return;
|
||||
if (!sc.GetNumber(hiofs.xoffs, true)) return;
|
||||
if (!sc.GetNumber(hiofs.yoffs, true)) return;
|
||||
|
||||
for (int i = tilestart; i <= tileend; i++) TileFiles.tiledata[i].hiofs = hiofs;
|
||||
}
|
||||
|
||||
void parseAnimTileRange(FScanner& sc, FScriptPosition& pos)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue