mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-26 10:44:17 +00:00
- moved tileForName out of BuildTiles.
Just pulling one change out of the big upcoming refactor commit.
This commit is contained in:
parent
630276f7e0
commit
58db09969c
9 changed files with 26 additions and 26 deletions
|
@ -247,7 +247,7 @@ void FActorInfo::ResolveTextures(const char* clsname, DCoreActor* defaults)
|
|||
SpriteSet.Resize(SpriteSetNames.Size());
|
||||
for (unsigned i = 0; i < SpriteSet.Size(); i++)
|
||||
{
|
||||
SpriteSet[i] = TileFiles.tileForName(SpriteSetNames[i]);
|
||||
SpriteSet[i] = tileForName(SpriteSetNames[i]);
|
||||
// This should later be enabled to user content.
|
||||
//if (SpriteSet[i] == -1) Printf(TEXTCOLOR_RED "Unknown texture '%s' in sprite set for class %s\n", SpriteSetNames[i].GetChars(), clsname);
|
||||
}
|
||||
|
|
|
@ -2370,7 +2370,7 @@ static void parseTileFlags(FScanner& sc, FScriptPosition& pos)
|
|||
while (!sc.CheckString("}"))
|
||||
{
|
||||
sc.MustGetString();
|
||||
int tile = TileFiles.tileForName(sc.String);
|
||||
int tile = tileForName(sc.String);
|
||||
if (tile == -1)
|
||||
{
|
||||
pos.Message(MSG_ERROR, "tileflags:Unknown tile name '%s'", sc.String);
|
||||
|
|
|
@ -293,7 +293,7 @@ void FMapInfoParser::ParseSpawnClasses()
|
|||
sc.MustGetString();
|
||||
const char* p = sc.String;
|
||||
if (*p == '*') { fullbright |= 1; p++; }
|
||||
basetex = TileFiles.tileForName(p);
|
||||
basetex = tileForName(p);
|
||||
if (basetex < 0) sc.ScriptMessage("Unknown texture '%s' in definition for spawn ID # %d", sc.String, num);
|
||||
if (sc.CheckString(","))
|
||||
{
|
||||
|
@ -302,7 +302,7 @@ void FMapInfoParser::ParseSpawnClasses()
|
|||
if (*p)
|
||||
{
|
||||
if (*p == '*') { fullbright |= 2; p++; }
|
||||
brokentex = TileFiles.tileForName(p);
|
||||
brokentex = tileForName(p);
|
||||
if (brokentex < 0) sc.ScriptMessage("Unknown texture '%s' in definition for spawn ID # %d", sc.String, num);
|
||||
}
|
||||
if (sc.CheckString(","))
|
||||
|
@ -363,7 +363,7 @@ void FMapInfoParser::ParseBreakWall()
|
|||
|
||||
sc.MustGetString();
|
||||
FString basename = sc.String; // save for printing error messages.
|
||||
basetile = TileFiles.tileForName(sc.String);
|
||||
basetile = tileForName(sc.String);
|
||||
if (basetile < 0)
|
||||
{
|
||||
sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String, basetile);
|
||||
|
@ -371,7 +371,7 @@ void FMapInfoParser::ParseBreakWall()
|
|||
}
|
||||
ParseAssign();
|
||||
sc.MustGetString();
|
||||
breaktile = TileFiles.tileForName(sc.String);
|
||||
breaktile = tileForName(sc.String);
|
||||
if (*sc.String && breaktile < 0) sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String, breaktile);
|
||||
if (sc.CheckString(","))
|
||||
{
|
||||
|
@ -428,7 +428,7 @@ void FMapInfoParser::ParseBreakCeiling()
|
|||
|
||||
sc.MustGetString();
|
||||
FString basename = sc.String; // save for printing error messages.
|
||||
basetile = TileFiles.tileForName(sc.String);
|
||||
basetile = tileForName(sc.String);
|
||||
if (basetile < 0)
|
||||
{
|
||||
sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String, basetile);
|
||||
|
@ -436,7 +436,7 @@ void FMapInfoParser::ParseBreakCeiling()
|
|||
}
|
||||
ParseAssign();
|
||||
sc.MustGetString();
|
||||
breaktile = TileFiles.tileForName(sc.String);
|
||||
breaktile = tileForName(sc.String);
|
||||
if (*sc.String && breaktile < 0) sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String, breaktile);
|
||||
if (sc.CheckString(","))
|
||||
{
|
||||
|
@ -500,7 +500,7 @@ void FMapInfoParser::ParseTextureFlags()
|
|||
do
|
||||
{
|
||||
sc.MustGetString();
|
||||
int tile = TileFiles.tileForName(sc.String);
|
||||
int tile = tileForName(sc.String);
|
||||
|
||||
if (tile == -1)
|
||||
{
|
||||
|
|
|
@ -124,7 +124,7 @@ void defineSky(int tilenum, int lognumtiles, const int16_t *tileofs, int yoff, f
|
|||
|
||||
void defineSky(const char* tilename, int lognumtiles, const int16_t* tileofs, int yoff, float yscale, int yoff2)
|
||||
{
|
||||
int tile = TileFiles.tileForName(tilename);
|
||||
int tile = tileForName(tilename);
|
||||
if (tile >= 0)
|
||||
defineSky(tile, lognumtiles, tileofs, yoff, yscale, yoff2);
|
||||
}
|
||||
|
|
|
@ -308,15 +308,6 @@ struct BuildTiles
|
|||
}
|
||||
}
|
||||
|
||||
int tileForName(const char* name)
|
||||
{
|
||||
FName nm(name, true);
|
||||
if (nm == NAME_None) return -1;
|
||||
auto nmm = nametoindex.CheckKey(nm);
|
||||
if (!nmm) return -1;
|
||||
return *nmm;
|
||||
}
|
||||
|
||||
void SetAliases();
|
||||
|
||||
|
||||
|
@ -369,6 +360,15 @@ void tileDelete(int tile);
|
|||
|
||||
extern BuildTiles TileFiles;
|
||||
|
||||
inline int tileForName(const char* name)
|
||||
{
|
||||
FName nm(name, true);
|
||||
if (nm == NAME_None) return -1;
|
||||
auto nmm = TileFiles.nametoindex.CheckKey(nm);
|
||||
if (!nmm) return -1;
|
||||
return *nmm;
|
||||
}
|
||||
|
||||
// Some hacks to allow accessing the no longer existing arrays as if they still were arrays to avoid changing hundreds of lines of code.
|
||||
struct PicAnm
|
||||
{
|
||||
|
|
|
@ -493,7 +493,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, checktexture, sector_checktexture)
|
|||
void sector_settexturename(sectortype* sec, int place, int intname)
|
||||
{
|
||||
if (!sec) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
int tilenum = TileFiles.tileForName(FName(ENamedName(intname)).GetChars());
|
||||
int tilenum = tileForName(FName(ENamedName(intname)).GetChars());
|
||||
(place == 0 ? sec->ceilingpicnum : sec->floorpicnum) = tilenum;
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, settexturename, sector_settexturename)
|
||||
|
@ -721,7 +721,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, twosided, wall_twosided)
|
|||
void wall_settexturename(walltype* sec, int place, int intname)
|
||||
{
|
||||
if (!sec) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
int tilenum = TileFiles.tileForName(FName(ENamedName(intname)).GetChars());
|
||||
int tilenum = tileForName(FName(ENamedName(intname)).GetChars());
|
||||
(place ? sec->overpicnum : sec->wallpicnum) = tilenum;
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_walltype, settexturename, wall_settexturename)
|
||||
|
|
|
@ -78,7 +78,7 @@ static int ccmd_spawn(CCmdFuncPtr parm)
|
|||
}
|
||||
else
|
||||
{
|
||||
picnum = TileFiles.tileForName(parm->parms[0]);
|
||||
picnum = tileForName(parm->parms[0]);
|
||||
if (picnum < 0)
|
||||
{
|
||||
picnum = getlabelvalue(parm->parms[0]);
|
||||
|
|
|
@ -552,7 +552,7 @@ void CallStandingOn(DDukeActor* actor, player_struct* p)
|
|||
CCMD(changewalltexture)
|
||||
{
|
||||
if (argv.argc() < 2) return;
|
||||
int tile = TileFiles.tileForName(argv[1]);
|
||||
int tile = tileForName(argv[1]);
|
||||
if (tile < 0) tile = (int)strtol(argv[1], nullptr, 10);
|
||||
HitInfoBase hit;
|
||||
hitscan(ps[0].actor->spr.pos, ps[0].cursector, DVector3(ps[0].actor->spr.Angles.Yaw.ToVector(), 0) * 1024, hit, CLIPMASK1);
|
||||
|
|
|
@ -37,7 +37,7 @@ int PicForName(int intname)
|
|||
|
||||
for (auto& p : classes)
|
||||
{
|
||||
classnameToTile.Insert(FName(p.first), TileFiles.tileForName(p.second));
|
||||
classnameToTile.Insert(FName(p.first), tileForName(p.second));
|
||||
}
|
||||
}
|
||||
auto p = classnameToTile.CheckKey(FName(ENamedName(intname)));
|
||||
|
@ -558,7 +558,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, hitasprite, hitasprite)
|
|||
void DukeActor_detonate(DDukeActor* origin, int intname)
|
||||
{
|
||||
// all callers use "EXPLOSION2", so ignore the parameter for now. This should be fixed once EXPLOSION2 gets scriptified.
|
||||
int picnum = TileFiles.tileForName("EXPLOSION2");
|
||||
int picnum = tileForName("EXPLOSION2");
|
||||
detonate(origin, picnum);
|
||||
}
|
||||
|
||||
|
@ -747,7 +747,7 @@ DEFINE_ACTION_FUNCTION(DDukeActor, checktype) // for temporary checking of types
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(DDukeActor);
|
||||
PARAM_STRING(name);
|
||||
ACTION_RETURN_BOOL(self->spr.picnum == TileFiles.tileForName(name));
|
||||
ACTION_RETURN_BOOL(self->spr.picnum == tileForName(name));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue