0
0
Fork 0
mirror of https://github.com/ZDoom/Raze.git synced 2025-04-07 08:22:01 +00:00

- added a name to tilenum function so that we can define picnums by name in scripted actors.

This commit is contained in:
Christoph Oelckers 2022-01-23 21:30:00 +01:00
parent e206a71448
commit f194fb6c90
6 changed files with 25 additions and 1 deletions
source
core
games
blood/src
duke/src
exhumed/src
sw/src

View file

@ -5,6 +5,7 @@
#include "image.h"
#include "i_time.h"
#include "intvec.h"
#include "name.h"
// picanm[].sf:
// |bit(1<<7)
@ -294,6 +295,21 @@ struct BuildTiles
TArray<FString> addedArt;
TArray<FString> maptilesadded;
TMap<int, FGameTexture*> cameratextures;
TMap<FName, int> nametoindex;
void addName(const char* name, int index)
{
nametoindex.Insert(name, index);
}
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 Init(); // This cannot be a constructor because it needs the texture manager running.
~BuildTiles()

View file

@ -316,7 +316,11 @@ static bool PointerCheck(PType *symtype, PType *checktype)
DEFINE_PROPERTY(pic, S, CoreActor)
{
PROP_STRING_PARM(str, 0);
defaults->spr.picnum = 0; // todo
defaults->spr.picnum = TileFiles.tileForName(str);
if (defaults->spr.picnum == -1)
{
I_Error("Unknown texture name '%s'", str);
}
bag.Info->ActorInfo()->DefaultCstat |= DEFF_PICNUM;
}

View file

@ -499,6 +499,7 @@ static void SetTileNames()
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
#include "namelist.h"
// Oh Joy! Plasma Pak changes the tile number of the title screen, but we preferably want mods that use the original one to display it.

View file

@ -296,6 +296,7 @@ static void SetTileNames()
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
if (!isRR())
{

View file

@ -493,6 +493,7 @@ static void SetTileNames()
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
#include "namelist.h"
}

View file

@ -215,6 +215,7 @@ static void SetTileNames()
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
#include "namelist.h"
}