From 32ad16f84dd5c6534d72f5131c01d1c4dcdff697 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2022 09:36:03 +0100 Subject: [PATCH] - SW's first texture flag, yay! Removes two floorpicnum accesses --- source/games/sw/src/bunny.cpp | 41 +++++-------------- source/games/sw/src/copysect.cpp | 2 +- source/games/sw/src/game.h | 4 ++ source/games/sw/src/namelist.h | 12 ++++++ .../static/filter/shadowwarrior/constants.mi | 8 ++++ .../filter/shadowwarrior/rmapinfo.texflags | 17 ++++++++ wadsrc/static/zscript/games/sw/swgame.zs | 5 +++ 7 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 wadsrc/static/filter/shadowwarrior/constants.mi create mode 100644 wadsrc/static/filter/shadowwarrior/rmapinfo.texflags diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 508169a75..4d29e61a6 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -35,6 +35,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "sprite.h" #include "weapon.h" #include "misc.h" +#include "texinfo.h" BEGIN_SW_NS @@ -1306,26 +1307,16 @@ int DoBunnyMove(DSWActor* actor) if (RandomRange(1000) > 985 && actor->spr.pal != PALETTE_PLAYER1 && actor->user.track < 0) { - switch (actor->sector()->floorpicnum) + if (tileflags(actor->sector()->floortexture()) & TFLAG_BUNNYFRIENDLY) + { + NewStateGroup(actor, sg_BunnyStand); + } + else { - case 153: - case 154: - case 193: - case 219: - case 2636: - case 2689: - case 3561: - case 3562: - case 3563: - case 3564: - NewStateGroup(actor,sg_BunnyStand); - break; - default: actor->spr.Angles.Yaw = RandomAngle(); actor->user.jump_speed = -350; DoActorBeginJump(actor); actor->user.ActorActionFunc = DoActorMoveJump; - break; } } @@ -1375,24 +1366,14 @@ int DoBunnyEat(DSWActor* actor) DoActorSectorDamage(actor); - switch (actor->sector()->floorpicnum) + if (tileflags(actor->sector()->floortexture()) & TFLAG_BUNNYFRIENDLY) { - case 153: - case 154: - case 193: - case 219: - case 2636: - case 2689: - case 3561: - case 3562: - case 3563: - case 3564: if (RandomRange(1000) > 970) - NewStateGroup(actor,sg_BunnyRun); - break; - default: + NewStateGroup(actor, sg_BunnyRun); + } + else + { NewStateGroup(actor,sg_BunnyRun); - break; } return 0; } diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index 30b3cd84c..1d0052f1a 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -227,7 +227,7 @@ void CopySectorMatch(int match) dsectp->floorshade = ssectp->floorshade; dsectp->ceilingshade = ssectp->ceilingshade; - dsectp->floorpicnum = ssectp->floorpicnum; + dsectp->setfloortexture(ssectp->floortexture()); dsectp->setceilingtexture(ssectp->ceilingtexture()); dsectp->floorheinum = ssectp->floorheinum; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index d4ce319f6..2956b1bdf 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -882,6 +882,10 @@ enum SPRX_BOOL10 = (BIT(15)), }; +enum ETexFlags +{ + TFLAG_BUNNYFRIENDLY = 1, // bunnies like to stay in sectors with this as floor. +}; // User->Flags flags enum diff --git a/source/games/sw/src/namelist.h b/source/games/sw/src/namelist.h index c279c1f3d..c84c213cb 100644 --- a/source/games/sw/src/namelist.h +++ b/source/games/sw/src/namelist.h @@ -301,3 +301,15 @@ x(COMPASS_MID_TIC2, 2391) x(FAF_PORTAL, 341) x(FAF_PORTAL2, 342) x(SYBEXSCREEN, 5261) + +// stuff bunnies like +x(DARKGRASS, 153) +x(BRIGHTGRASS, 154) +x(MOSS, 193) +x(GRASSSTONE, 219) +x(GRASSQUARRY, 2636) +x(DRYGRASS, 2689) +x(LAWN, 3561) +x(SAND, 3562) +x(FLOWERLAWN, 3563) +x(THINGRASS, 3564) diff --git a/wadsrc/static/filter/shadowwarrior/constants.mi b/wadsrc/static/filter/shadowwarrior/constants.mi new file mode 100644 index 000000000..5e9286ae0 --- /dev/null +++ b/wadsrc/static/filter/shadowwarrior/constants.mi @@ -0,0 +1,8 @@ +// Global constants for SW + +constants +{ + // texture flags + TFLAG_BUNNYFRIENDLY = 1 +} + diff --git a/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags b/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags new file mode 100644 index 000000000..d40abf0fd --- /dev/null +++ b/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags @@ -0,0 +1,17 @@ +include "constants.mi" + + +textureflags +{ + TFLAG_BUNNYFRIENDLY = + DARKGRASS, + BRIGHTGRASS, + MOSS, + GRASSSTONE, + GRASSQUARRY, + DRYGRASS, + LAWN, + SAND, + FLOWERLAWN, + THINGRASS +} diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index a9f195741..8556bd136 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -117,6 +117,11 @@ struct SW native INVF_COUNT = 4 } + enum ETexFlags // texture flags + { + TFLAG_BUNNYFRIENDLY = 1, + }; + native static void PlaySound(int sound, int flags, int channel = CHAN_AUTO, int cflags = 0); native static void StopSound(); native static bool IsSoundPlaying(int channel); // soundEngine.IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE))