mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-26 13:20:52 +00:00
- moved implementation of 'animtilerange' into buildtiles.cpp.
This commit is contained in:
parent
616838dd0a
commit
5c777eeb38
3 changed files with 53 additions and 45 deletions
|
@ -607,44 +607,12 @@ static int32_t defsparser(scriptfile *script)
|
||||||
break;
|
break;
|
||||||
case T_ANIMTILERANGE:
|
case T_ANIMTILERANGE:
|
||||||
{
|
{
|
||||||
int32_t tile1, tile2, spd, type;
|
SetAnim set;
|
||||||
|
if (scriptfile_getsymbol(script,&set.tile1)) break;
|
||||||
if (scriptfile_getsymbol(script,&tile1)) break;
|
if (scriptfile_getsymbol(script,&set.tile2)) break;
|
||||||
if (scriptfile_getsymbol(script,&tile2)) break;
|
if (scriptfile_getsymbol(script,&set.speed)) break;
|
||||||
if (scriptfile_getsymbol(script,&spd)) break;
|
if (scriptfile_getsymbol(script,&set.type)) break;
|
||||||
if (scriptfile_getsymbol(script,&type)) break;
|
processSetAnim("animtilerange", pos, set);
|
||||||
|
|
||||||
if (check_tile("animtilerange", tile1, script, pos))
|
|
||||||
break;
|
|
||||||
if (check_tile("animtilerange", tile2, script, pos))
|
|
||||||
break;
|
|
||||||
|
|
||||||
spd = clamp(spd, 0, 15);
|
|
||||||
if (type&~3)
|
|
||||||
{
|
|
||||||
pos.Message(MSG_ERROR, "animtilerange: animation type must be 0, 1, 2 or 3");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t num = tile2-tile1;
|
|
||||||
if (type == 3 && tile1 > tile2) // PICANM_ANIMTYPE_BACK
|
|
||||||
num = -num;
|
|
||||||
|
|
||||||
if ((unsigned)num > 255)
|
|
||||||
{
|
|
||||||
pos.Message(MSG_ERROR, "animtilerange: tile difference can be at most 255");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set anim speed
|
|
||||||
picanm[tile1].sf &= ~PICANM_ANIMSPEED_MASK;
|
|
||||||
picanm[tile1].sf |= spd;
|
|
||||||
// set anim type
|
|
||||||
picanm[tile1].sf &= ~PICANM_ANIMTYPE_MASK;
|
|
||||||
picanm[tile1].sf |= type<<PICANM_ANIMTYPE_SHIFT;
|
|
||||||
// set anim number
|
|
||||||
picanm[tile1].num = num;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case T_TILEFROMTEXTURE:
|
case T_TILEFROMTEXTURE:
|
||||||
|
@ -867,10 +835,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int32_t const texstatus = tileImportFromTexture(fn, tile, 255, 0);
|
int32_t const texstatus = tileImportFromTexture(fn, tile, 255, 0);
|
||||||
if (texstatus == -3)
|
|
||||||
pos.Message(MSG_ERROR, "No palette loaded, in importtile definition");
|
|
||||||
if (texstatus == -(3<<8))
|
|
||||||
pos.Message(MSG_ERROR, "\"%s\" has more than one tile, in importtile definition", fn.GetChars());
|
|
||||||
if (texstatus < 0)
|
if (texstatus < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1081,7 +1081,7 @@ bool PickTexture(int picnum, FGameTexture* tex, int paletteid, TexturePick& pick
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
bool ValidateTileRange(const char* cmd, int &begin, int& end, FScriptPosition pos)
|
bool ValidateTileRange(const char* cmd, int &begin, int& end, FScriptPosition pos, bool allowswap)
|
||||||
{
|
{
|
||||||
if (end < begin)
|
if (end < begin)
|
||||||
{
|
{
|
||||||
|
@ -1142,5 +1142,30 @@ void processTileImport(const char *cmd, FScriptPosition& pos, TileImport& imp)
|
||||||
if (imp.extra != INT_MAX) TileFiles.tiledata[imp.tile].picanm.extra = imp.extra;
|
if (imp.extra != INT_MAX) TileFiles.tiledata[imp.tile].picanm.extra = imp.extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Internal worker for tileSetAnim
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
void processSetAnim(const char* cmd, FScriptPosition& pos, SetAnim& imp)
|
||||||
|
{
|
||||||
|
if (!ValidateTilenum(cmd, imp.tile1, pos) ||
|
||||||
|
!ValidateTilenum(cmd, imp.tile2, pos))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (imp.type < 0 || imp.type > 3)
|
||||||
|
{
|
||||||
|
pos.Message(MSG_ERROR, "%s: animation type must be 0-3, got %d", cmd, imp.type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = imp.tile2 - imp.tile1;
|
||||||
|
if (imp.type == (PICANM_ANIMTYPE_BACK >> PICANM_ANIMTYPE_SHIFT) && imp.tile1 > imp.tile2)
|
||||||
|
count = -count;
|
||||||
|
|
||||||
|
TileFiles.setAnim(imp.tile1, imp.type, imp.speed, count);
|
||||||
|
}
|
||||||
|
|
||||||
TileSiz tilesiz;
|
TileSiz tilesiz;
|
||||||
PicAnm picanm;
|
PicAnm picanm;
|
||||||
|
|
|
@ -51,7 +51,7 @@ enum class ReplacementType : int
|
||||||
// accordingly.
|
// accordingly.
|
||||||
struct picanm_t
|
struct picanm_t
|
||||||
{
|
{
|
||||||
uint8_t num; // animate number
|
uint16_t num; // animate number
|
||||||
uint8_t sf; // anim. speed and flags
|
uint8_t sf; // anim. speed and flags
|
||||||
uint8_t extra;
|
uint8_t extra;
|
||||||
|
|
||||||
|
@ -344,6 +344,15 @@ struct BuildTiles
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setAnim(int tile, int type, int speed, int frames)
|
||||||
|
{
|
||||||
|
auto& anm = tiledata[tile].picanm;
|
||||||
|
anm.sf &= ~(PICANM_ANIMTYPE_MASK | PICANM_ANIMSPEED_MASK);
|
||||||
|
anm.sf |= clamp(speed, 0, 15) | (type << PICANM_ANIMTYPE_SHIFT);
|
||||||
|
anm.num = frames;
|
||||||
|
}
|
||||||
|
|
||||||
FGameTexture* ValidateCustomTile(int tilenum, ReplacementType type);
|
FGameTexture* ValidateCustomTile(int tilenum, ReplacementType type);
|
||||||
int32_t artLoadFiles(const char* filename);
|
int32_t artLoadFiles(const char* filename);
|
||||||
uint8_t* tileMakeWritable(int num);
|
uint8_t* tileMakeWritable(int num);
|
||||||
|
@ -374,7 +383,6 @@ void tileRemoveReplacement(int tile);
|
||||||
bool tileLoad(int tileNum);
|
bool tileLoad(int tileNum);
|
||||||
void artClearMapArt(void);
|
void artClearMapArt(void);
|
||||||
void artSetupMapArt(const char* filename);
|
void artSetupMapArt(const char* filename);
|
||||||
void tileSetAnim(int tile, const picanm_t& anm);
|
|
||||||
int tileSetHightileReplacement(int picnum, int palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags);
|
int tileSetHightileReplacement(int picnum, int palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags);
|
||||||
int tileSetSkybox(int picnum, int palnum, const char **facenames, int flags );
|
int tileSetSkybox(int picnum, int palnum, const char **facenames, int flags );
|
||||||
int tileDeleteReplacement(int picnum, int palnum);
|
int tileDeleteReplacement(int picnum, int palnum);
|
||||||
|
@ -503,6 +511,10 @@ inline FGameTexture* tileGetTexture(int tile, bool animate = false)
|
||||||
bool PickTexture(int picnum, FGameTexture* tex, int paletteid, TexturePick& pick);
|
bool PickTexture(int picnum, FGameTexture* tex, int paletteid, TexturePick& pick);
|
||||||
|
|
||||||
|
|
||||||
|
bool ValidateTileRange(const char* cmd, int& begin, int& end, FScriptPosition pos, bool allowswap = true);
|
||||||
|
bool ValidateTilenum(const char* cmd, int tile, FScriptPosition pos);
|
||||||
|
|
||||||
|
|
||||||
struct TileImport
|
struct TileImport
|
||||||
{
|
{
|
||||||
FString fn;
|
FString fn;
|
||||||
|
@ -519,3 +531,10 @@ struct TileImport
|
||||||
};
|
};
|
||||||
|
|
||||||
void processTileImport(const char* cmd, FScriptPosition& pos, TileImport& imp);
|
void processTileImport(const char* cmd, FScriptPosition& pos, TileImport& imp);
|
||||||
|
|
||||||
|
struct SetAnim
|
||||||
|
{
|
||||||
|
int tile1, tile2, speed, type;
|
||||||
|
};
|
||||||
|
|
||||||
|
void processSetAnim(const char* cmd, FScriptPosition& pos, SetAnim& imp);
|
||||||
|
|
Loading…
Reference in a new issue