- exported the tile flag setters to .def.

This commit is contained in:
Christoph Oelckers 2022-11-25 16:52:08 +01:00
parent 5a2819239c
commit 67e807de26
19 changed files with 247 additions and 206 deletions

View file

@ -2263,6 +2263,34 @@ static void parseSpawnClasses(FScanner& sc, FScriptPosition& pos)
sc.SetCMode(false);
}
static void parseTileFlags(FScanner& sc, FScriptPosition& pos)
{
int num = -1;
sc.SetCMode(true);
sc.GetNumber(num, true);
if (!sc.CheckString("{"))
{
pos.Message(MSG_ERROR, "tileflags:'{' expected, unable to continue");
sc.SetCMode(false);
return;
}
while (!sc.CheckString("}"))
{
sc.MustGetString();
int tile = TileFiles.tileForName(sc.String);
if (tile == -1)
{
pos.Message(MSG_ERROR, "tileflags:Unknown tile name '%s'", sc.String);
}
else
{
TileFiles.tiledata[tile].tileflags |= num;
}
}
sc.SetCMode(false);
}
//===========================================================================
//
//
@ -2356,6 +2384,7 @@ static const dispatch basetokens[] =
{ "defineqav", parseDefineQAV },
{ "spawnclasses", parseSpawnClasses },
{ "tileflag", parseTileFlags },
{ nullptr, nullptr },
};

View file

@ -964,6 +964,7 @@ static void InitTextures()
gi->LoadGameTextures(); // loads game-side data that must be present before processing the .def files.
LoadDefinitions();
InitFont(); // InitFonts may only be called once all texture data has been initialized.
TileFiles.SetAliases();
lookups.postLoadTables();
highTileSetup();

View file

@ -346,6 +346,19 @@ void BuildTiles::LoadArtSet(const char* filename)
}
}
//===========================================================================
//
//
//
//===========================================================================
void BuildTiles::SetAliases()
{
TMap<FName, int>::Iterator it(nametoindex);
TMap<FName, int>::Pair* pair;
while (it.NextPair(pair))
TexMan.AddAlias(pair->Key.GetChars(), tileGetTexture(pair->Value));
}
//==========================================================================
//

View file

@ -323,6 +323,9 @@ struct BuildTiles
return *nmm;
}
void SetAliases();
void Init(); // This cannot be a constructor because it needs the texture manager running.
~BuildTiles()
{

View file

@ -497,22 +497,6 @@ void GameInterface::DrawBackground()
DrawTexture(twod, TexMan.GetGameTexture(tex), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
}
#define x(a, b) registerName(#a, b);
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.
// So let's make this remapping depend on the CRC.
if (tileGetCRC32(2518) == 1170870757 && (tileGetCRC32(2046) != 290208654 || tileWidth(2518) == 0)) registerName("titlescreen", 2046);
else registerName("titlescreen", 2518);
}
#undef x
void ReadAllRFS();
@ -608,7 +592,6 @@ void GameInterface::app_init()
levelLoadDefaults();
//---------
SetTileNames();
C_InitConback(TexMan.CheckForTexture("BACKTILE", ETextureType::Any), true, 0.25);
Printf(PRINT_NONOTIFY, "Initializing view subsystem\n");

View file

@ -42,6 +42,21 @@ uint8_t surfType[kMaxTiles];
int8_t tileShade[kMaxTiles];
short voxelIndex[kMaxTiles];
#define x(a, b) registerName(#a, b);
static void SetTileNames()
{
auto registerName = [](const char* name, int 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.
// So let's make this remapping depend on the CRC.
if (tileGetCRC32(2518) == 1170870757 && (tileGetCRC32(2046) != 290208654 || tileWidth(2518) == 0)) registerName("titlescreen", 2046);
else registerName("titlescreen", 2518);
}
#undef x
//---------------------------------------------------------------------------
//
//
@ -74,6 +89,7 @@ void GameInterface::LoadGameTextures()
if (voxelIndex[i] >= 0 && voxelIndex[i] < MAXVOXELS)
voxreserve.Set(voxelIndex[i]);
}
SetTileNames();
}
//---------------------------------------------------------------------------

View file

@ -24,6 +24,8 @@ struct GameInterface : public ::GameInterface
const char* Name() override { return "Duke"; }
void app_init() override;
void loadPalette();
void LoadGameTextures();
void clearlocalinputstate() override;
bool GenerateSavePic() override;
void PlayHudSound() override;

View file

@ -40,113 +40,6 @@ BEGIN_DUKE_NS
void initactorflags_d()
{
settileflag(TFLAG_WALLSWITCH, {
HANDPRINTSWITCH,
HANDPRINTSWITCHON,
ALIENSWITCH,
ALIENSWITCHON,
MULTISWITCH,
MULTISWITCH_2,
MULTISWITCH_3,
MULTISWITCH_4,
ACCESSSWITCH,
ACCESSSWITCH2,
PULLSWITCH,
PULLSWITCHON,
HANDSWITCH,
HANDSWITCHON,
SLOTDOOR,
SLOTDOORON,
LIGHTSWITCH,
LIGHTSWITCHON,
SPACELIGHTSWITCH,
SPACELIGHTSWITCHON,
SPACEDOORSWITCH,
SPACEDOORSWITCHON,
FRANKENSTINESWITCH,
FRANKENSTINESWITCHON,
LIGHTSWITCH2,
LIGHTSWITCH2ON,
POWERSWITCH1,
POWERSWITCH1ON,
LOCKSWITCH1,
LOCKSWITCH1ON,
POWERSWITCH2,
POWERSWITCH2ON,
DIPSWITCH,
DIPSWITCHON,
DIPSWITCH2,
DIPSWITCH2ON,
TECHSWITCH,
TECHSWITCHON,
DIPSWITCH3,
DIPSWITCH3ON });
settileflag(TFLAG_ADULT, {
FEM1,
FEM2,
FEM3,
FEM4,
FEM5,
FEM6,
FEM7,
FEM8,
FEM9,
FEM10,
MAN,
MAN2,
WOMAN,
NAKED1,
PODFEM1,
FEMMAG1,
FEMMAG2,
FEMPIC1,
FEMPIC2,
FEMPIC3,
FEMPIC4,
FEMPIC5,
FEMPIC6,
FEMPIC7,
BLOODYPOLE,
FEM6PAD,
STATUE,
STATUEFLASH,
OOZ,
OOZ2,
WALLBLOOD1,
WALLBLOOD2,
WALLBLOOD3,
WALLBLOOD4,
WALLBLOOD5,
WALLBLOOD7,
WALLBLOOD8,
SUSHIPLATE1,
SUSHIPLATE2,
SUSHIPLATE3,
SUSHIPLATE4,
FETUS,
FETUSJIB,
FETUSBROKE,
HOTMEAT,
FOODOBJECT16,
DOLPHIN1,
DOLPHIN2,
TOUGHGAL,
TAMPON,
XXXSTACY,
4946,
4947,
693,
2254,
4560,
4561,
4562,
4498,
4957 });
settileflag(TFLAG_ELECTRIC, { HURTRAIL });
settileflag(TFLAG_CLEARINVENTORY, { HURTRAIL, FLOORSLIME, FLOORPLASMA });
settileflag(TFLAG_SLIME, { FLOORSLIME, FLOORSLIME + 1, FLOORSLIME + 2 });
gs.actorinfo[COMMANDER].gutsoffset = -24;

View file

@ -34,82 +34,6 @@ BEGIN_DUKE_NS
void initactorflags_r()
{
settileflag(TFLAG_WALLSWITCH, {
HANDPRINTSWITCH,
HANDPRINTSWITCHON,
ALIENSWITCH,
ALIENSWITCHON,
MULTISWITCH,
MULTISWITCH_2,
MULTISWITCH_3,
MULTISWITCH_4,
ACCESSSWITCH,
ACCESSSWITCH2,
PULLSWITCH,
PULLSWITCHON,
HANDSWITCH,
HANDSWITCHON,
SLOTDOOR,
SLOTDOORON,
LIGHTSWITCH,
LIGHTSWITCHON,
SPACELIGHTSWITCH,
SPACELIGHTSWITCHON,
SPACEDOORSWITCH,
SPACEDOORSWITCHON,
FRANKENSTINESWITCH,
FRANKENSTINESWITCHON,
LIGHTSWITCH2,
LIGHTSWITCH2ON,
POWERSWITCH1,
POWERSWITCH1ON,
LOCKSWITCH1,
LOCKSWITCH1ON,
POWERSWITCH2,
POWERSWITCH2ON,
DIPSWITCH,
DIPSWITCHON,
DIPSWITCH2,
DIPSWITCH2ON,
TECHSWITCH,
TECHSWITCHON,
DIPSWITCH3,
DIPSWITCH3ON,
CHICKENPLANTBUTTON,
CHICKENPLANTBUTTONON });
if (isRRRA()) settileflag(TFLAG_WALLSWITCH, {
MULTISWITCH2,
MULTISWITCH2_2,
MULTISWITCH2_3,
MULTISWITCH2_4,
IRONWHEELSWITCH,
IRONWHEELSWITCHON });
settileflag(TFLAG_ADULT, {
FEM10,
NAKED1,
FEMMAG1,
FEMMAG2,
STATUE,
STATUEFLASH,
OOZ,
WALLBLOOD1,
WALLBLOOD2,
WALLBLOOD3,
WALLBLOOD4,
WALLBLOOD5,
SUSHIPLATE1,
SUSHIPLATE2,
SUSHIPLATE3,
SUSHIPLATE4,
DOLPHIN1,
DOLPHIN2,
TOUGHGAL });
settileflag(TFLAG_ELECTRIC, { HURTRAIL });
settileflag(TFLAG_CLEARINVENTORY, { HURTRAIL, FLOORSLIME, FLOORPLASMA });
settileflag(TFLAG_SLIME, { FLOORSLIME, FLOORSLIME + 1, FLOORSLIME + 2 });
for (auto& fa : gs.actorinfo)
{
fa.falladjustz = 24;

View file

@ -296,7 +296,6 @@ static void SetTileNames()
{
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
if (!isRR())
@ -311,6 +310,11 @@ static void SetTileNames()
#undef x
#undef y
void GameInterface::LoadGameTextures()
{
SetTileNames();
}
void GameInterface::loadPalette()
{
@ -382,7 +386,6 @@ void GameInterface::app_init()
screenpeek = myconnectindex;
SetTileNames();
C_InitConback(TexMan.CheckForTexture("MENUSCREEN", ETextureType::Any), false, 0.75);
if (ud.multimode > 1)

View file

@ -93,6 +93,8 @@ x(DIPSWITCH3ON, 169)
x(ACCESSSWITCH2, 170)
x(REFLECTWATERTILE, 180)
x(FLOORSLIME, 200)
x(FLOORSLIME1, 201)
x(FLOORSLIME2, 202)
x(BIGFORCE, 230)
x(EPISODE, 247)
x(MASKWALL9, 255)

View file

@ -105,6 +105,8 @@ x(DIPSWITCH3ON, 128)
x(ACCESSSWITCH2, 129)
x(REFLECTWATERTILE, 131)
x(FLOORSLIME, 132)
x(FLOORSLIME1, 133)
x(FLOORSLIME2, 134)
x(BIGFORCE, 135)
x(EPISODE, 137)
x(MASKWALL1, 138)

View file

@ -534,13 +534,17 @@ static void SetTileNames()
{
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
#include "namelist.h"
}
#undef x
void GameInterface::LoadGameTextures()
{
SetTileNames();
}
//---------------------------------------------------------------------------
//
//
@ -564,7 +568,6 @@ void GameInterface::app_init()
nTotalPlayers += nNetPlayerCount;
}
SetTileNames();
defineSky(DEFAULTPSKY, 2, nullptr, 256, 1.f);
InitFX();

View file

@ -209,6 +209,7 @@ struct GameInterface : public ::GameInterface
{
const char* Name() override { return "Exhumed"; }
void app_init() override;
void LoadGameTextures();
void clearlocalinputstate() override;
void loadPalette() override;
bool GenerateSavePic() override;

View file

@ -213,7 +213,6 @@ static void SetTileNames()
{
auto registerName = [](const char* name, int index)
{
TexMan.AddAlias(name, tileGetTexture(index));
TileFiles.addName(name, index);
};
#include "namelist.h"
@ -223,6 +222,7 @@ static void SetTileNames()
void GameInterface::LoadGameTextures()
{
LoadKVXFromScript("swvoxfil.txt"); // Load voxels from script file
SetTileNames();
}
//---------------------------------------------------------------------------
@ -279,7 +279,6 @@ void GameInterface::app_init()
if (!SW_SHAREWARE)
LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information
SetTileNames();
userConfig.AddDefs.reset();
InitFX();
}

View file

@ -0,0 +1,8 @@
// Global constants for all Duke based games.
// Tile flags.
define TFLAG_WALLSWITCH 1
define TFLAG_ADULT 2
define TFLAG_ELECTRIC 4
define TFLAG_CLEARINVENTORY 8
define TFLAG_SLIME 16

View file

@ -0,0 +1,100 @@
include "engine/defines.def"
tileflag TFLAG_WALLSWITCH {
HANDPRINTSWITCH
HANDPRINTSWITCHON
ALIENSWITCH
ALIENSWITCHON
MULTISWITCH
MULTISWITCH_2
MULTISWITCH_3
MULTISWITCH_4
ACCESSSWITCH
ACCESSSWITCH2
PULLSWITCH
PULLSWITCHON
HANDSWITCH
HANDSWITCHON
SLOTDOOR
SLOTDOORON
LIGHTSWITCH
LIGHTSWITCHON
SPACELIGHTSWITCH
SPACELIGHTSWITCHON
SPACEDOORSWITCH
SPACEDOORSWITCHON
FRANKENSTINESWITCH
FRANKENSTINESWITCHON
LIGHTSWITCH2
LIGHTSWITCH2ON
POWERSWITCH1
POWERSWITCH1ON
LOCKSWITCH1
LOCKSWITCH1ON
POWERSWITCH2
POWERSWITCH2ON
DIPSWITCH
DIPSWITCHON
DIPSWITCH2
DIPSWITCH2ON
TECHSWITCH
TECHSWITCHON
DIPSWITCH3
DIPSWITCH3ON }
tileflag TFLAG_ADULT {
FEM1
FEM2
FEM3
FEM4
FEM5
FEM6
FEM7
FEM8
FEM9
FEM10
MAN
MAN2
WOMAN
NAKED1
PODFEM1
FEMMAG1
FEMMAG2
FEMPIC1
FEMPIC2
FEMPIC3
FEMPIC4
FEMPIC5
FEMPIC6
FEMPIC7
BLOODYPOLE
FEM6PAD
STATUE
STATUEFLASH
OOZ
OOZ2
WALLBLOOD1
WALLBLOOD2
WALLBLOOD3
WALLBLOOD4
WALLBLOOD5
WALLBLOOD7
WALLBLOOD8
SUSHIPLATE1
SUSHIPLATE2
SUSHIPLATE3
SUSHIPLATE4
FETUS
FETUSJIB
FETUSBROKE
HOTMEAT
FOODOBJECT16
DOLPHIN1
DOLPHIN2
TOUGHGAL
TAMPON
XXXSTACY }
tileflag TFLAG_ELECTRIC { HURTRAIL }
tileflag TFLAG_CLEARINVENTORY { HURTRAIL FLOORSLIME FLOORPLASMA }
tileflag TFLAG_SLIME { FLOORSLIME FLOORSLIME1 FLOORSLIME2 }

View file

@ -11,3 +11,12 @@ spawnclasses
2465 = RedneckCactusDebris2
7424 = RedneckRabbitSpawner
}
tileflag TFLAG_WALLSWITCH {
MULTISWITCH2
MULTISWITCH2_2
MULTISWITCH2_3
MULTISWITCH2_4
IRONWHEELSWITCH
IRONWHEELSWITCHON }

View file

@ -1,3 +1,5 @@
include "engine/defines.def"
spawnclasses
{
2 = DukeActivator
@ -70,3 +72,51 @@ spawnclasses
}
tileflag TFLAG_WALLSWITCH {
HANDPRINTSWITCH
HANDPRINTSWITCHON
ALIENSWITCH
ALIENSWITCHON
MULTISWITCH
MULTISWITCH_2
MULTISWITCH_3
MULTISWITCH_4
ACCESSSWITCH
ACCESSSWITCH2
PULLSWITCH
PULLSWITCHON
HANDSWITCH
HANDSWITCHON
SLOTDOOR
SLOTDOORON
LIGHTSWITCH
LIGHTSWITCHON
SPACELIGHTSWITCH
SPACELIGHTSWITCHON
SPACEDOORSWITCH
SPACEDOORSWITCHON
FRANKENSTINESWITCH
FRANKENSTINESWITCHON
LIGHTSWITCH2
LIGHTSWITCH2ON
POWERSWITCH1
POWERSWITCH1ON
LOCKSWITCH1
LOCKSWITCH1ON
POWERSWITCH2
POWERSWITCH2ON
DIPSWITCH
DIPSWITCHON
DIPSWITCH2
DIPSWITCH2ON
TECHSWITCH
TECHSWITCHON
DIPSWITCH3
DIPSWITCH3ON
CHICKENPLANTBUTTON
CHICKENPLANTBUTTONON }
tileflag TFLAG_ELECTRIC { HURTRAIL }
tileflag TFLAG_CLEARINVENTORY { HURTRAIL FLOORSLIME FLOORPLASMA }
tileflag TFLAG_SLIME { FLOORSLIME FLOORSLIME1 FLOORSLIME2 }