- implemented the switch parser and set up the external definitions.

This commit is contained in:
Christoph Oelckers 2022-12-10 20:14:39 +01:00
parent 03aedda7da
commit 0d9fe83cba
19 changed files with 268 additions and 139 deletions

View file

@ -484,6 +484,101 @@ void FMapInfoParser::ParseBreakCeiling()
// //
//========================================================================== //==========================================================================
void FMapInfoParser::ParseSwitches()
{
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
SwitchDef sd{};
if (switches.Size() == 0) switches.Push(sd); // entry 0 is a non-switch
sc.MustGetString();
static const char* types[] = { "switch", "comboswitch", "multiswitch", "accessswitch", nullptr };
int type = sc.MatchString(types);
int count = type == 2 ? 4 : 2;
sd.type = type + 1;
bool more = false;
int state = 0;
ParseAssign();
for (int i = 0; i < count; i++)
{
next:
sc.MustGetString();
auto thisframe = TexMan.CheckForTexture(sc.String, ETextureType::Any);
if (!thisframe.isValid())
{
sc.ScriptMessage("Unknown texture '%s' in switch definition", sc.String);
}
sd.states[state++] = thisframe;
if (!sc.CheckString(","))
{
more = false;
if (i < count - 1)
{
sc.ScriptMessage("Insufficient arguments in switch definition");
goto next;
}
}
else more = true;
}
if (more)
{
do
{
sc.MustGetString();
if (more)
{
// check if this is a sound
auto sound = S_FindSound(sc.String);
if (sound == NO_SOUND) more = false;
sd.soundid = sound;
}
if (!more)
{
if (sc.Compare("shootable"))
{
sd.flags |= SwitchDef::shootable;
}
else if (sc.Compare("oneway"))
{
sd.flags |= SwitchDef::oneway;
}
else if (sc.Compare("resettable"))
{
sd.flags |= SwitchDef::resettable;
}
else if (sc.Compare("nofilter"))
{
sd.flags |= SwitchDef::nofilter;
}
else
{
sc.ScriptMessage("%s: Unknown switch flag ", sc.String);
}
}
more = false;
} while (sc.CheckString(","));
}
unsigned ndx = switches.Push(sd);
if (sd.flags & SwitchDef::oneway)
{
count = 1;
}
for (int i = 0; i < count; i++)
{
AccessExtInfo(sd.states[i]).switchindex = ndx;
AccessExtInfo(sd.states[i]).switchphase = i;
}
}
}
//==========================================================================
//
//
//
//==========================================================================
void FMapInfoParser::ParseTextureFlags() void FMapInfoParser::ParseTextureFlags()
{ {
int num = -1; int num = -1;
@ -1621,6 +1716,10 @@ void FMapInfoParser::ParseMapInfo (int lump, MapRecord &gamedefaults, MapRecord
{ {
ParseBreakCeiling(); ParseBreakCeiling();
} }
else if (sc.Compare("switches"))
{
ParseSwitches();
}
else if (sc.Compare("textureflags")) else if (sc.Compare("textureflags"))
{ {
ParseTextureFlags(); ParseTextureFlags();

View file

@ -95,6 +95,7 @@ struct FMapInfoParser
void ParseBreakCeiling(); void ParseBreakCeiling();
void ParseTextureFlags(); void ParseTextureFlags();
void ParseSurfaceTypes(); void ParseSurfaceTypes();
void ParseSwitches();
void ParseConstants(); void ParseConstants();
void ParseMapInfo (int lump, MapRecord &gamedefaults, MapRecord &defaultinfo); void ParseMapInfo (int lump, MapRecord &gamedefaults, MapRecord &defaultinfo);

View file

@ -498,6 +498,7 @@ struct spritetypebase
} }
const FTextureID spritetexture() const; const FTextureID spritetexture() const;
void setspritetexture(FTextureID tex);
}; };

View file

@ -29,6 +29,12 @@ inline const FTextureID spritetypebase::spritetexture() const
return tileGetTextureID(picnum); return tileGetTextureID(picnum);
} }
inline void spritetypebase::setspritetexture(FTextureID tex)
{
picnum = legacyTileNum(tex);
}
inline void walltype::setwalltexture(FTextureID tex) inline void walltype::setwalltexture(FTextureID tex)
{ {
wallpicnum = legacyTileNum(tex); wallpicnum = legacyTileNum(tex);

View file

@ -3,6 +3,7 @@
#include <stdint.h> #include <stdint.h>
#include "gamefuncs.h" #include "gamefuncs.h"
#include "tiletexture.h" #include "tiletexture.h"
#include "s_soundinternal.h"
// extended texture info for which there is no room in the texture manager. // extended texture info for which there is no room in the texture manager.
@ -55,16 +56,47 @@ struct TileOffs
int16_t xsize, ysize, xoffs, yoffs; int16_t xsize, ysize, xoffs, yoffs;
}; };
// probably only useful for Duke. We'll see
struct SwitchDef
{
enum
{
shootable = 1,
oneway = 2,
resettable = 4,
nofilter = 8,
};
enum
{
None = 0, // no switch, so that all non-switches can use an empty entry to avoid validation checks
Regular = 1,
Combo = 2,
Multi = 3,
Access = 4
};
uint8_t type;
uint8_t flags;
FSoundID soundid;
FTextureID states[4];
};
inline TArray<SwitchDef> switches;
struct TexExtInfo struct TexExtInfo
{ {
// TexAnim *texanim // todo: extended texture animation like ZDoom's ANIMDEFS. uint16_t animindex; // not used yet - for ZDoom-style animations.
uint16_t switchindex;
uint8_t surftype; // Contents depend on the game, e.g. this holds Blood's surfType. Other games have hard coded handling for similar effects. uint8_t surftype; // Contents depend on the game, e.g. this holds Blood's surfType. Other games have hard coded handling for similar effects.
uint8_t tileshade; // Blood's shade.dat union
{
uint8_t switchphase; // For Duke: index of texture in switch sequence.
uint8_t tileshade; // Blood's shade.dat
};
int16_t tiletovox; // engine-side voxel index int16_t tiletovox; // engine-side voxel index
picanm_t picanm; // tile-based animation data. picanm_t picanm; // tile-based animation data.
uint32_t flags; // contents are game dependent. uint32_t flags; // contents are game dependent.
TileOffs hiofs; TileOffs hiofs;
}; };
inline TArray<TexExtInfo> texExtInfo; inline TArray<TexExtInfo> texExtInfo;
inline int firstarttile, maxarttile; // we need this for conversion between tile numbers and texture IDs inline int firstarttile, maxarttile; // we need this for conversion between tile numbers and texture IDs
@ -110,6 +142,16 @@ inline TexExtInfo& AccessExtInfo(FTextureID tex) // this is for modifying and sh
return texExtInfo[index]; return texExtInfo[index];
} }
inline bool isaccessswitch(FTextureID texid)
{
return switches[GetExtInfo(texid).switchindex].type == SwitchDef::Access;
}
inline bool isshootableswitch(FTextureID texid)
{
return switches[GetExtInfo(texid).switchindex].flags & SwitchDef::shootable;
}
inline int tilehasvoxel(FTextureID texid) inline int tilehasvoxel(FTextureID texid)
{ {
if (r_voxels) if (r_voxels)

View file

@ -2489,8 +2489,7 @@ void handle_se24(DDukeActor *actor, bool scroll, double mult)
continue; continue;
} }
if (actorflag(a2, SFLAG_SE24_NOCARRY) || if (actorflag(a2, SFLAG_SE24_NOCARRY) || wallswitchcheck(a2) || GetExtInfo(a2->spr.spritetexture()).switchindex > 0)
wallswitchcheck(a2))
continue; continue;
if (a2->spr.pos.Z > a2->floorz - 16) if (a2->spr.pos.Z > a2->floorz - 16)

View file

@ -291,8 +291,6 @@ void initactorflags_d()
TILE_SMALLSMOKE = DTILE_SMALLSMOKE; TILE_SMALLSMOKE = DTILE_SMALLSMOKE;
TILE_BLOODPOOL = DTILE_BLOODPOOL; TILE_BLOODPOOL = DTILE_BLOODPOOL;
TILE_CLOUDYSKIES = DTILE_CLOUDYSKIES; TILE_CLOUDYSKIES = DTILE_CLOUDYSKIES;
TILE_ACCESSSWITCH = DTILE_ACCESSSWITCH;
TILE_ACCESSSWITCH2 = DTILE_ACCESSSWITCH2;
TILE_MIRRORBROKE = DTILE_MIRRORBROKE; TILE_MIRRORBROKE = DTILE_MIRRORBROKE;
TILE_LOADSCREEN = DTILE_LOADSCREEN; TILE_LOADSCREEN = DTILE_LOADSCREEN;
TILE_CROSSHAIR = DTILE_CROSSHAIR; TILE_CROSSHAIR = DTILE_CROSSHAIR;

View file

@ -291,8 +291,6 @@ void initactorflags_r()
TILE_SMALLSMOKE = RTILE_SMALLSMOKE; TILE_SMALLSMOKE = RTILE_SMALLSMOKE;
TILE_BLOODPOOL = RTILE_BLOODPOOL; TILE_BLOODPOOL = RTILE_BLOODPOOL;
TILE_CLOUDYSKIES = RTILE_CLOUDYSKIES; TILE_CLOUDYSKIES = RTILE_CLOUDYSKIES;
TILE_ACCESSSWITCH = RTILE_ACCESSSWITCH;
TILE_ACCESSSWITCH2 = RTILE_ACCESSSWITCH2;
TILE_MIRRORBROKE = RTILE_MIRRORBROKE; TILE_MIRRORBROKE = RTILE_MIRRORBROKE;
TILE_HEN = RTILE_HEN; TILE_HEN = RTILE_HEN;
TILE_LOADSCREEN = RTILE_LOADSCREEN; TILE_LOADSCREEN = RTILE_LOADSCREEN;

View file

@ -56,6 +56,7 @@ x(TECHLIGHTBUST4, 123)
x(WALLLIGHT4, 124) x(WALLLIGHT4, 124)
x(WALLLIGHTBUST4, 125) x(WALLLIGHTBUST4, 125)
x(ACCESSSWITCH, 130) x(ACCESSSWITCH, 130)
x(ACCESSSWITCHON, 131)
x(SLOTDOOR, 132) x(SLOTDOOR, 132)
x(SLOTDOORON, 133) x(SLOTDOORON, 133)
x(LIGHTSWITCH, 134) x(LIGHTSWITCH, 134)
@ -94,6 +95,7 @@ x(TECHSWITCHON, 167)
x(DIPSWITCH3, 168) x(DIPSWITCH3, 168)
x(DIPSWITCH3ON, 169) x(DIPSWITCH3ON, 169)
x(ACCESSSWITCH2, 170) x(ACCESSSWITCH2, 170)
x(ACCESSSWITCH2ON, 171)
x(REFLECTWATERTILE, 180) x(REFLECTWATERTILE, 180)
x(FLOORSLIME, 200) x(FLOORSLIME, 200)
x(FLOORSLIME1, 201) x(FLOORSLIME1, 201)

View file

@ -63,6 +63,7 @@ x(WALLLIGHTBUST4, 77)
x(MOTOAMMO, 78) x(MOTOAMMO, 78)
x(BUTTON1, 80) x(BUTTON1, 80)
x(ACCESSSWITCH, 82) x(ACCESSSWITCH, 82)
x(ACCESSSWITCHON, 83)
x(SLOTDOOR, 84) x(SLOTDOOR, 84)
x(SLOTDOORON, 85) x(SLOTDOORON, 85)
x(LIGHTSWITCH, 86) x(LIGHTSWITCH, 86)
@ -103,6 +104,7 @@ x(TECHSWITCHON, 126)
x(DIPSWITCH3, 127) x(DIPSWITCH3, 127)
x(DIPSWITCH3ON, 128) x(DIPSWITCH3ON, 128)
x(ACCESSSWITCH2, 129) x(ACCESSSWITCH2, 129)
x(ACCESSSWITCH2ON, 130)
x(REFLECTWATERTILE, 131) x(REFLECTWATERTILE, 131)
x(FLOORSLIME, 132) x(FLOORSLIME, 132)
x(FLOORSLIME1, 133) x(FLOORSLIME1, 133)
@ -415,7 +417,7 @@ x(PLUG, 1272)
x(OOZFILTER, 1273) x(OOZFILTER, 1273)
x(FLOORPLASMA, 1276) x(FLOORPLASMA, 1276)
x(HANDPRINTSWITCH, 1278) x(HANDPRINTSWITCH, 1278)
x(HANDPRINTSWITCHON, 1278) x(HANDPRINTSWITCHON, 1279)
x(BOTTLE10, 1280) x(BOTTLE10, 1280)
x(BOTTLE11, 1281) x(BOTTLE11, 1281)
x(BOTTLE12, 1282) x(BOTTLE12, 1282)
@ -708,7 +710,8 @@ y(RRTILE2175, 2175)
y(RRTILE2176, 2176) y(RRTILE2176, 2176)
y(RRTILE2178, 2178) y(RRTILE2178, 2178)
y(RRTILE2186, 2186) y(RRTILE2186, 2186)
y(RRTILE2214, 2214) y(CONTESTSWITCH, 2214)
y(CONTESTSWITCHON, 2215)
x(WAITTOBESEATED, 2215) x(WAITTOBESEATED, 2215)
x(OJ, 2217) x(OJ, 2217)
x(HURTRAIL, 2221) x(HURTRAIL, 2221)
@ -786,9 +789,11 @@ y(RRTILE2654, 2654)
y(RRTILE2656, 2656) y(RRTILE2656, 2656)
y(RRTILE2676, 2676) y(RRTILE2676, 2676)
y(RRTILE2689, 2689) y(RRTILE2689, 2689)
y(RRTILE2697, 2697) y(ALERTSWITCH, 2697)
y(ALERTSWITCHON, 2698)
y(MUDDYPATH, 2702) y(MUDDYPATH, 2702)
y(RRTILE2707, 2707) y(HANDLESWITCH, 2707)
y(HANDLESWITCHON, 2708)
y(RRTILE2732, 2732) y(RRTILE2732, 2732)
x(HATRACK, 2717) x(HATRACK, 2717)
x(DESKLAMP, 2719) x(DESKLAMP, 2719)
@ -1392,7 +1397,9 @@ y(RRTILE8622, 8622)
y(RRTILE8623, 8623) y(RRTILE8623, 8623)
y(RRTILE8640, 8640) y(RRTILE8640, 8640)
y(RRTILE8651, 8651) y(RRTILE8651, 8651)
y(RRTILE8660, 8660) y(BELLSWITCH, 8660)
y(BELLSWITCHON, 8661)
y(BELLSWITCHOFF, 8662)
x(ENDGAME, 8677) x(ENDGAME, 8677)
x(ENDGAME2, 8678) x(ENDGAME2, 8678)
y(SNAKERIVERSIGN, 8679) y(SNAKERIVERSIGN, 8679)

View file

@ -18,8 +18,6 @@ extern int TILE_WATERBUBBLE;
extern int TILE_SMALLSMOKE; extern int TILE_SMALLSMOKE;
extern int TILE_BLOODPOOL; extern int TILE_BLOODPOOL;
extern int TILE_CLOUDYSKIES; extern int TILE_CLOUDYSKIES;
extern int TILE_ACCESSSWITCH;
extern int TILE_ACCESSSWITCH2;
extern int TILE_HEN; extern int TILE_HEN;
extern int TILE_MIRRORBROKE; extern int TILE_MIRRORBROKE;
extern int TILE_LOADSCREEN; extern int TILE_LOADSCREEN;

View file

@ -341,7 +341,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int
hit.actor()->spr.picnum == RTILE_DIPSWITCH2ON || hit.actor()->spr.picnum == RTILE_DIPSWITCH2ON ||
hit.actor()->spr.picnum == RTILE_DIPSWITCH3 || hit.actor()->spr.picnum == RTILE_DIPSWITCH3 ||
hit.actor()->spr.picnum == RTILE_DIPSWITCH3ON || hit.actor()->spr.picnum == RTILE_DIPSWITCH3ON ||
(isRRRA() && hit.actor()->spr.picnum == RTILE_RRTILE8660) || (isRRRA() && hit.actor()->spr.picnum == RTILE_BELLSWITCH) ||
hit.actor()->spr.picnum == RTILE_HANDSWITCH || hit.actor()->spr.picnum == RTILE_HANDSWITCH ||
hit.actor()->spr.picnum == RTILE_HANDSWITCHON)) hit.actor()->spr.picnum == RTILE_HANDSWITCHON))
{ {
@ -364,7 +364,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int
hit.hitWall->wallpicnum == RTILE_DIPSWITCH2ON || hit.hitWall->wallpicnum == RTILE_DIPSWITCH2ON ||
hit.hitWall->wallpicnum == RTILE_DIPSWITCH3 || hit.hitWall->wallpicnum == RTILE_DIPSWITCH3 ||
hit.hitWall->wallpicnum == RTILE_DIPSWITCH3ON || hit.hitWall->wallpicnum == RTILE_DIPSWITCH3ON ||
(isRRRA() && hit.hitWall->wallpicnum == RTILE_RRTILE8660) || (isRRRA() && hit.hitWall->wallpicnum == RTILE_BELLSWITCH) ||
hit.hitWall->wallpicnum == RTILE_HANDSWITCH || hit.hitWall->wallpicnum == RTILE_HANDSWITCH ||
hit.hitWall->wallpicnum == RTILE_HANDSWITCHON)) hit.hitWall->wallpicnum == RTILE_HANDSWITCHON))
{ {

View file

@ -225,7 +225,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_MULTISWITCH2_3: case RTILE_MULTISWITCH2_3:
case RTILE_MULTISWITCH2_4: case RTILE_MULTISWITCH2_4:
case RTILE_IRONWHEELSWITCH: case RTILE_IRONWHEELSWITCH:
case RTILE_RRTILE8660: case RTILE_BELLSWITCH:
if (!isRRRA()) break; if (!isRRRA()) break;
[[fallthrough]]; [[fallthrough]];
case RTILE_DIPSWITCH2: case RTILE_DIPSWITCH2:
@ -260,11 +260,11 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_POWERSWITCH2ON: case RTILE_POWERSWITCH2ON:
case RTILE_CHICKENPLANTBUTTON: case RTILE_CHICKENPLANTBUTTON:
case RTILE_CHICKENPLANTBUTTONON: case RTILE_CHICKENPLANTBUTTONON:
case RTILE_RRTILE2214: case RTILE_CONTESTSWITCH:
case RTILE_RRTILE2697: case RTILE_ALERTSWITCH:
case RTILE_RRTILE2697 + 1: case RTILE_ALERTSWITCHON:
case RTILE_RRTILE2707: case RTILE_HANDLESWITCH:
case RTILE_RRTILE2707 + 1: case RTILE_HANDLESWITCHON:
goOn1: goOn1:
if (check_activator_motion(lotag)) return 0; if (check_activator_motion(lotag)) return 0;
break; break;
@ -310,10 +310,10 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
other->spr.picnum = RTILE_MULTISWITCH2; other->spr.picnum = RTILE_MULTISWITCH2;
break; break;
case RTILE_RRTILE2214: case RTILE_CONTESTSWITCH:
other->spr.picnum++; other->spr.picnum++;
break; break;
case RTILE_RRTILE8660: case RTILE_BELLSWITCH:
if (!isRRRA()) break; if (!isRRRA()) break;
[[fallthrough]]; [[fallthrough]];
case RTILE_ACCESSSWITCH: case RTILE_ACCESSSWITCH:
@ -332,8 +332,8 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_DIPSWITCH2: case RTILE_DIPSWITCH2:
case RTILE_DIPSWITCH3: case RTILE_DIPSWITCH3:
case RTILE_CHICKENPLANTBUTTON: case RTILE_CHICKENPLANTBUTTON:
case RTILE_RRTILE2697: case RTILE_ALERTSWITCH:
case RTILE_RRTILE2707: case RTILE_HANDLESWITCH:
if (other->spr.picnum == RTILE_DIPSWITCH3) if (other->spr.picnum == RTILE_DIPSWITCH3)
if (other->spr.hitag == 999) if (other->spr.hitag == 999)
{ {
@ -347,7 +347,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
} }
if (other->spr.picnum == RTILE_CHICKENPLANTBUTTON) if (other->spr.picnum == RTILE_CHICKENPLANTBUTTON)
ud.chickenplant = 0; ud.chickenplant = 0;
if (other->spr.picnum == RTILE_RRTILE8660) if (other->spr.picnum == RTILE_BELLSWITCH)
{ {
BellTime = 132; BellTime = 132;
BellSprite = other; BellSprite = other;
@ -368,8 +368,8 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_DIPSWITCH2ON: case RTILE_DIPSWITCH2ON:
case RTILE_DIPSWITCH3ON: case RTILE_DIPSWITCH3ON:
case RTILE_CHICKENPLANTBUTTONON: case RTILE_CHICKENPLANTBUTTONON:
case RTILE_RRTILE2697 + 1: case RTILE_ALERTSWITCHON:
case RTILE_RRTILE2707 + 1: case RTILE_HANDLESWITCHON:
if (other->spr.picnum == RTILE_CHICKENPLANTBUTTONON) if (other->spr.picnum == RTILE_CHICKENPLANTBUTTONON)
ud.chickenplant = 1; ud.chickenplant = 1;
if (other->spr.hitag != 999) if (other->spr.hitag != 999)
@ -414,7 +414,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
if (wal.wallpicnum > (RTILE_MULTISWITCH2_4)) if (wal.wallpicnum > (RTILE_MULTISWITCH2_4))
wal.wallpicnum = RTILE_MULTISWITCH2; wal.wallpicnum = RTILE_MULTISWITCH2;
break; break;
case RTILE_RRTILE8660: case RTILE_BELLSWITCH:
if (!isRRRA()) break; if (!isRRRA()) break;
[[fallthrough]]; [[fallthrough]];
case RTILE_ACCESSSWITCH: case RTILE_ACCESSSWITCH:
@ -431,8 +431,8 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_HANDSWITCH: case RTILE_HANDSWITCH:
case RTILE_DIPSWITCH2: case RTILE_DIPSWITCH2:
case RTILE_DIPSWITCH3: case RTILE_DIPSWITCH3:
case RTILE_RRTILE2697: case RTILE_ALERTSWITCH:
case RTILE_RRTILE2707: case RTILE_HANDLESWITCH:
wal.wallpicnum++; wal.wallpicnum++;
break; break;
case RTILE_HANDSWITCHON: case RTILE_HANDSWITCHON:
@ -447,8 +447,8 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_SPACEDOORSWITCHON: case RTILE_SPACEDOORSWITCHON:
case RTILE_DIPSWITCH2ON: case RTILE_DIPSWITCH2ON:
case RTILE_DIPSWITCH3ON: case RTILE_DIPSWITCH3ON:
case RTILE_RRTILE2697 + 1: case RTILE_ALERTSWITCHON:
case RTILE_RRTILE2707 + 1: case RTILE_HANDLESWITCHON:
wal.wallpicnum--; wal.wallpicnum--;
break; break;
} }
@ -496,7 +496,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_MULTISWITCH2_3: case RTILE_MULTISWITCH2_3:
case RTILE_MULTISWITCH2_4: case RTILE_MULTISWITCH2_4:
case RTILE_IRONWHEELSWITCH: case RTILE_IRONWHEELSWITCH:
case RTILE_RRTILE8660: case RTILE_BELLSWITCH:
if (!isRRRA()) break; if (!isRRRA()) break;
[[fallthrough]]; [[fallthrough]];
case RTILE_DIPSWITCH2: case RTILE_DIPSWITCH2:
@ -531,14 +531,14 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
case RTILE_HANDSWITCHON: case RTILE_HANDSWITCHON:
case RTILE_PULLSWITCH: case RTILE_PULLSWITCH:
case RTILE_PULLSWITCHON: case RTILE_PULLSWITCHON:
case RTILE_RRTILE2697: case RTILE_ALERTSWITCH:
case RTILE_RRTILE2697 + 1: case RTILE_ALERTSWITCHON:
case RTILE_RRTILE2707: case RTILE_HANDLESWITCH:
case RTILE_RRTILE2707 + 1: case RTILE_HANDLESWITCHON:
goOn2: goOn2:
if (isRRRA()) if (isRRRA())
{ {
if (picnum == RTILE_RRTILE8660 && act) if (picnum == RTILE_BELLSWITCH && act)
{ {
BellTime = 132; BellTime = 132;
BellSprite = act; BellSprite = act;

View file

@ -194,9 +194,15 @@ bool initspriteforspawn(DDukeActor* act)
act->temp_angle = nullAngle; act->temp_angle = nullAngle;
act->temp_pos = DVector3(0, 0, 0); act->temp_pos = DVector3(0, 0, 0);
if (wallswitchcheck(act) && (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) auto ext = GetExtInfo(act->spr.spritetexture());
if (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL && (wallswitchcheck(act) || ext.switchindex > 0))
{ {
if (act->spr.picnum != TILE_ACCESSSWITCH && act->spr.picnum != TILE_ACCESSSWITCH2 && act->spr.pal) // this is a bit more complicated than needed thanks to some bugs in the original code that must be retained for the multiplayer filter.
// Not all switches were properly included here.
bool shouldfilter = wallswitchcheck(act) || !(switches[ext.switchindex].flags & SwitchDef::nofilter);
if (shouldfilter && act->spr.pal > 0)
{ {
if ((ud.multimode < 2) || (ud.multimode > 1 && ud.coop == 1)) if ((ud.multimode < 2) || (ud.multimode > 1 && ud.coop == 1))
{ {
@ -205,11 +211,11 @@ bool initspriteforspawn(DDukeActor* act)
act->spr.lotag = act->spr.hitag = 0; act->spr.lotag = act->spr.hitag = 0;
return false; return false;
} }
act->spr.pal = 0;
} }
act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL; act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
if (act->spr.pal && act->spr.picnum != TILE_ACCESSSWITCH && act->spr.picnum != TILE_ACCESSSWITCH2)
act->spr.pal = 0;
return false; return false;
} }
if (!actorflag(act, SFLAG_NOFALLER) && (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK)) if (!actorflag(act, SFLAG_NOFALLER) && (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK))

View file

@ -4,47 +4,10 @@ include "constants.mi"
textureflags textureflags
{ {
// switches that are not really switches.
TFLAG_WALLSWITCH = TFLAG_WALLSWITCH =
HANDPRINTSWITCH, HANDPRINTSWITCH,
HANDPRINTSWITCHON, 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
// Raze does not use this because the game never handled it well. // Raze does not use this because the game never handled it well.
TFLAG_ADULT = TFLAG_ADULT =
@ -138,4 +101,28 @@ surfacetypes
TSURF_PLASMA = FLOORPLASMA TSURF_PLASMA = FLOORPLASMA
TSURF_SCROLLSKY = CLOUDYSKIES TSURF_SCROLLSKY = CLOUDYSKIES
TSURF_METALDUCTS = PANNEL1, PANNEL2 TSURF_METALDUCTS = PANNEL1, PANNEL2
} }
switches
{
comboswitch = "DIPSWITCH", "DIPSWITCHON", shootable
comboswitch = "TECHSWITCH", "TECHSWITCHON"
comboswitch = "ALIENSWITCH", "ALIENSWITCHON"
accessswitch = "ACCESSSWITCH", "ACCESSSWITCHON", nofilter, oneway
accessswitch = "ACCESSSWITCH2", "ACCESSSWITCH2", nofilter, oneway
switch = "DIPSWITCH2", "DIPSWITCH2ON", shootable
switch = "DIPSWITCH3", "DIPSWITCH3ON", shootable
multiswitch = "MULTISWITCH", "MULTISWITCH_2", "MULTISWITCH_3", "MULTISWITCH_4"
switch = "PULLSWITCH", "PULLSWITCHON"
switch = "HANDSWITCH", "HANDSWITCHON", shootable
switch = "SLOTDOOR", "SLOTDOORON"
switch = "LIGHTSWITCH", "LIGHTSWITCHON"
switch = "SPACELIGHTSWITCH", "SPACELIGHTSWITCHON"
switch = "SPACEDOORSWITCH", "SPACEDOORSWITCHON"
switch = "FRANKENSTINESWITCH", "FRANKENSTINESWITCHON"
switch = "LIGHTSWITCH2", "LIGHTSWITCH2ON"
switch = "POWERSWITCH1", "POWERSWITCH1ON"
switch = "LOCKSWITCH1", "LOCKSWITCH1ON"
switch = "POWERSWITCH2", "POWERSWITCH2ON"
}

View file

@ -2,15 +2,6 @@ include "constants.mi"
textureflags textureflags
{ {
TFLAG_WALLSWITCH =
MULTISWITCH2,
MULTISWITCH2_2,
MULTISWITCH2_3,
MULTISWITCH2_4,
IRONWHEELSWITCH,
IRONWHEELSWITCHON
TFLAG_BLOCKDOOR = TFLAG_BLOCKDOOR =
RRTILE1996, RRTILE1996,
RRTILE2382, RRTILE2382,
@ -42,3 +33,10 @@ surfacetypes
TSURF_OIL = OIL1, OIL2 TSURF_OIL = OIL1, OIL2
TSURF_DEEPMUD = DEEPMUD TSURF_DEEPMUD = DEEPMUD
} }
switches
{
multiswitch = "MULTISWITCH2", "MULTISWITCH2_2", "MULTISWITCH2_3", "MULTISWITCH2_4"
switch = "IRONWHEELSWITCH", "IRONWHEELSWITCHON", oneway
switch = "BELLSWITCH", "BELLSWITCHON", oneway, shootable, nofilter
}

View file

@ -5,47 +5,7 @@ textureflags
TFLAG_WALLSWITCH = TFLAG_WALLSWITCH =
HANDPRINTSWITCH, HANDPRINTSWITCH,
HANDPRINTSWITCHON, 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
TFLAG_DOORWALL = TFLAG_DOORWALL =
DOORTILE1, DOORTILE1,
@ -174,3 +134,30 @@ surfacetypes
TSURF_SPECIALWATER = WATERTILE2 TSURF_SPECIALWATER = WATERTILE2
} }
switches
{
comboswitch = "DIPSWITCH", "DIPSWITCHON", shootable
comboswitch = "TECHSWITCH", "TECHSWITCHON"
comboswitch = "ALIENSWITCH", "ALIENSWITCHON"
accessswitch = "ACCESSSWITCH", "ACCESSSWITCHON", nofilter, oneway
accessswitch = "ACCESSSWITCH2", "ACCESSSWITCH2ON", nofilter, oneway
switch = "DIPSWITCH2", "DIPSWITCH2ON", shootable
switch = "DIPSWITCH3", "DIPSWITCH3ON", shootable, resettable
multiswitch = "MULTISWITCH", "MULTISWITCH_2", "MULTISWITCH_3", "MULTISWITCH_4"
switch = "PULLSWITCH", "PULLSWITCHON"
switch = "HANDSWITCH", "HANDSWITCHON", shootable
switch = "SLOTDOOR", "SLOTDOORON"
switch = "LIGHTSWITCH", "LIGHTSWITCHON"
switch = "SPACELIGHTSWITCH", "SPACELIGHTSWITCHON"
switch = "SPACEDOORSWITCH", "SPACEDOORSWITCHON"
switch = "FRANKENSTINESWITCH", "FRANKENSTINESWITCHON"
switch = "LIGHTSWITCH2", "LIGHTSWITCH2ON"
switch = "POWERSWITCH1", "POWERSWITCH1ON"
switch = "LOCKSWITCH1", "LOCKSWITCH1ON"
switch = "POWERSWITCH2", "POWERSWITCH2ON"
switch = "CHICKENPLANTBUTTON", "CHICKENPLANTBUTTONON" // this one uses its own class.
switch = "CONTESTSWITCH", "CONTESTSWITCHON", oneway, nofilter
switch = "ALERTSWITCH", "ALERTSWITCHON", nofilter
switch = "HANDLESWITCH", "HANDLESWITCHON", nofilter
}

View file

@ -81,7 +81,7 @@ $conreserve LN_BNCH 72
$conreserve GBELEV02 73 $conreserve GBELEV02 73
$conreserve FROG1 74 $conreserve FROG1 74
$conreserve TRUCK_LP 75 $conreserve TRUCK_LP 75
$conreserve SWITCH1 76 $conreserve SWITCH_ON 76
$conreserve E1L3 77 $conreserve E1L3 77
$conreserve LN_HOTDM 78 $conreserve LN_HOTDM 78
$conreserve FLUSH 79 $conreserve FLUSH 79

View file

@ -474,9 +474,9 @@ struct DukeUserDefs native
native readonly int coop; native readonly int coop;
native readonly int respawn_monsters, respawn_items, respawn_inventory, recstat, monsters_off, brightness; native readonly int respawn_monsters, respawn_items, respawn_inventory, recstat, monsters_off, brightness;
native readonly int ffire, multimode; native readonly int ffire, multimode;
native readonly int player_skill, marker, chickenplant; native readonly int player_skill, marker;
native int earthquaketime; native int earthquaketime, chickenplant;
native uint8 ufospawnsminion; native uint8 ufospawnsminion;
native int16 bomb_tag; native int16 bomb_tag;
native DukeActor cameraactor; native DukeActor cameraactor;