diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 23eaa330f..dfdfcba42 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -602,6 +602,7 @@ file( GLOB HEADER_FILES common/rendering/hwrenderer/data/*.h common/rendering/hwrenderer/postprocessing/*.h common/rendering/hwrenderer/utility/*.h + dukerr/*.h build/src/*.h platform/win32/*.h @@ -978,6 +979,7 @@ install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_PATH} COMPONENT "Game executable") +source_group("DukeRR" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/dukerr/.+") source_group("Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+") source_group("Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/.+") source_group("Core\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+") diff --git a/source/common/ns.h b/source/common/ns.h index 8ad103b2d..83681e827 100644 --- a/source/common/ns.h +++ b/source/common/ns.h @@ -2,10 +2,13 @@ #ifndef NO_NAMESPACE -#define BEGIN_DUKE_NS namespace Duke { +#define BEGIN_DUKERR_NS namespace DukeRR { +#define END_DUKERR_NS } + +#define BEGIN_DUKE_NS namespace DukeRR{} namespace Duke { using namespace DukeRR; #define END_DUKE_NS } -#define BEGIN_RR_NS namespace Redneck { +#define BEGIN_RR_NS namespace DukeRR{} namespace Redneck { using namespace DukeRR; #define END_RR_NS } #define BEGIN_BLD_NS namespace Blood { @@ -18,7 +21,10 @@ #define END_PS_NS } #else - + +#define BEGIN_DUKERR_NS +#define END_DUKERR_NS + #define BEGIN_DUKE_NS #define END_DUKE_NS diff --git a/source/duke3d/src/actors.h b/source/duke3d/src/actors.h index c648fe411..3702862eb 100644 --- a/source/duke3d/src/actors.h +++ b/source/duke3d/src/actors.h @@ -25,163 +25,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" # include "namesdyn.h" +#include "dukerr/actors.h" BEGIN_DUKE_NS - -#define MAXSLEEPDIST 16384 -#define SLEEPTIME 1536 -#define ACTOR_FLOOR_OFFSET (1<<8) -#define ZOFFSET2 (16<<8) -#define ZOFFSET3 (8<<8) -#define ZOFFSET4 (12<<8) -#define ZOFFSET5 (32<<8) -#define ZOFFSET6 (4<<8) - -#define ACTOR_MAXFALLINGZVEL 6144 -#define ACTOR_ONWATER_ADDZ (24<<8) - -// KEEPINSYNC lunatic/con_lang.lua -#define STAT_DEFAULT 0 -#define STAT_ACTOR 1 -#define STAT_ZOMBIEACTOR 2 -#define STAT_EFFECTOR 3 -#define STAT_PROJECTILE 4 -#define STAT_MISC 5 -#define STAT_STANDABLE 6 -#define STAT_LOCATOR 7 -#define STAT_ACTIVATOR 8 -#define STAT_TRANSPORT 9 -#define STAT_PLAYER 10 -#define STAT_FX 11 -#define STAT_FALLER 12 -#define STAT_DUMMYPLAYER 13 -#define STAT_LIGHT 14 -#define STAT_NETALLOC (MAXSTATUS-1) - - -// Defines the motion characteristics of an actor -enum amoveflags_t -{ - face_player = 1, - geth = 2, - getv = 4, - random_angle = 8, - face_player_slow = 16, - spin = 32, - face_player_smart = 64, - fleeenemy = 128, - jumptoplayer_only = 256, - jumptoplayer_bits = 257, // NOTE: two bits set! - seekplayer = 512, - furthestdir = 1024, - dodgebullet = 4096 -}; - -// Defines for 'useractor' keyword -enum uactortypes_t -{ - notenemy, - enemy, - enemystayput -}; - -// These macros are there to give names to the t_data[]/T*/vm.g_t[] indices -// when used with actors. Greppability of source code is certainly a virtue. -#define AC_COUNT(t) ((t)[0]) /* the actor's count */ -/* The ID of the actor's current move. In C-CON, the bytecode offset to the - * move composite: */ -#define AC_MOVE_ID(t) ((t)[1]) -#define AC_ACTION_COUNT(t) ((t)[2]) /* the actor's action count */ -#define AC_CURFRAME(t) ((t)[3]) /* the actor's current frame offset */ -/* The ID of the actor's current action. In C-CON, the bytecode offset to the - * action composite: */ -#define AC_ACTION_ID(t) ((t)[4]) -#define AC_AI_ID(t) ((t)[5]) /* the ID of the actor's current ai */ - -enum actionparams -{ - ACTION_STARTFRAME = 0, - ACTION_NUMFRAMES, - ACTION_VIEWTYPE, - ACTION_INCVAL, - ACTION_DELAY, - ACTION_FLAGS, - ACTION_PARAM_COUNT, -}; - -enum actionflags -{ - AF_VIEWPOINT = 1u<<0u, -}; - -#ifdef LUNATIC -struct action -{ - // These members MUST be in this exact order because FFI cdata of this type - // can be initialized by passing a table with numeric indices (con.action). - int16_t startframe, numframes; - int16_t viewtype, incval, delay; - uint16_t flags; -}; - -struct move -{ - // These members MUST be in this exact order. - int16_t hvel, vvel; -}; - -#pragma pack(push,1) -typedef struct { int32_t id; struct move mv; } con_move_t; -typedef struct { int32_t id; struct action ac; } con_action_t; -#pragma pack(pop) -#endif - -// Select an actor's actiontics and movflags locations depending on -// whether we compile the Lunatic build. -// : sprite pointer -// : actor_t pointer -#ifdef LUNATIC -# define AC_ACTIONTICS(spr, a) ((a)->actiontics) -# define AC_MOVFLAGS(spr, a) ((a)->movflags) -#else -# define AC_ACTIONTICS(spr, a) ((spr)->lotag) -# define AC_MOVFLAGS(spr, a) ((spr)->hitag) -#endif - // (+ 40 16 16 4 8 6 8 6 4 20) #pragma pack(push, 1) -typedef struct -{ - int32_t t_data[10]; // 40b sometimes used to hold offsets to con code - -#ifdef LUNATIC - // total: 18b - struct move mv; - struct action ac; - // Gets incremented by TICSPERFRAME on each A_Execute() call: - uint16_t actiontics; - // Movement flags, sprite[i].hitag in C-CON: - uint16_t movflags; -#endif - - int32_t flags; // 4b - vec3_t bpos; // 12b - int32_t floorz, ceilingz; // 8b - vec2_t lastv; // 8b - int16_t picnum, ang, extra, owner; // 8b - int16_t movflag, tempang, timetosleep; // 6b - int16_t stayput; // 2b - - uint8_t cgg, lasttransport; // 2b - // NOTE: 'dispicnum' is updated every frame, not in sync with game tics! - int16_t dispicnum; // 2b - -#ifdef POLYMER - int16_t lightId, lightmaxrange; // 4b - _prlight *lightptr; // 4b/8b aligned on 96 bytes - uint8_t lightcount, filler[3]; -#endif -} actor_t; // note: fields in this struct DO NOT have to be in this order, // however if you add something to this struct, please make sure @@ -206,26 +54,6 @@ typedef struct netactor_s t_data_8, t_data_9; -#ifdef LUNATIC - - int32_t - hvel, - vvel; - - - int32_t - startframe, - numframes; - - int32_t - viewtype, - incval, - delay; - - int32_t - actiontics; -#endif - int32_t flags; @@ -256,10 +84,6 @@ typedef struct netactor_s dispicnum; -#if defined LUNATIC - int32_t movflags; -#endif - // note: lightId, lightcount, lightmaxrange are not synchronized between client and server int32_t @@ -351,86 +175,6 @@ typedef struct netactor_s } netactor_t; #pragma pack(pop) -typedef struct -{ -#if !defined LUNATIC - intptr_t *execPtr; // pointer to CON script for this tile, formerly actorscrptr - intptr_t *loadPtr; // pointer to load time CON script, formerly actorLoadEventScrPtr or something -#endif - projectile_t *proj; - projectile_t *defproj; - uint32_t flags; // formerly SpriteFlags, ActorType - int32_t cacherange; // formerly SpriteCache -} tiledata_t; - - -// KEEPINSYNC lunatic/con_lang.lua -enum sflags_t -{ - SFLAG_SHADOW = 0x00000001, - SFLAG_NVG = 0x00000002, - SFLAG_NOSHADE = 0x00000004, - SFLAG_PROJECTILE = 0x00000008, - SFLAG_DECAL = 0x00000010, - SFLAG_BADGUY = 0x00000020, - SFLAG_NOPAL = 0x00000040, - SFLAG_NOEVENTCODE = 0x00000080, - SFLAG_NOLIGHT = 0x00000100, - SFLAG_USEACTIVATOR = 0x00000200, - SFLAG_NULL = 0x00000400, // null sprite in multiplayer - SFLAG_NOCLIP = 0x00000800, // clipmove it with cliptype 0 - SFLAG_NOFLOORSHADOW = 0x00001000, // for temp. internal use, per-tile flag not checked - SFLAG_SMOOTHMOVE = 0x00002000, - SFLAG_NOTELEPORT = 0x00004000, - SFLAG_BADGUYSTAYPUT = 0x00008000, - SFLAG_CACHE = 0x00010000, - // rotation-fixed wrt a pivot point to prevent position diverging due to - // roundoff error accumulation: - SFLAG_ROTFIXED = 0x00020000, - SFLAG_HARDCODED_BADGUY = 0x00040000, - SFLAG_DIDNOSE7WATER = 0x00080000, // used temporarily - SFLAG_NODAMAGEPUSH = 0x00100000, - SFLAG_NOWATERDIP = 0x00200000, - SFLAG_HURTSPAWNBLOOD = 0x00400000, - SFLAG_GREENSLIMEFOOD = 0x00800000, - SFLAG_REALCLIPDIST = 0x01000000, - SFLAG_WAKEUPBADGUYS = 0x02000000, - SFLAG_DAMAGEEVENT = 0x04000000, - SFLAG_NOWATERSECTOR = 0x08000000, - SFLAG_QUEUEDFORDELETE = 0x10000000, -}; - -// Custom projectiles "workslike" flags. -// XXX: Currently not predefined from CON. -enum pflags_t -{ - PROJECTILE_HITSCAN = 0x00000001, - PROJECTILE_RPG = 0x00000002, - PROJECTILE_BOUNCESOFFWALLS = 0x00000004, - PROJECTILE_BOUNCESOFFMIRRORS = 0x00000008, - PROJECTILE_KNEE = 0x00000010, - PROJECTILE_WATERBUBBLES = 0x00000020, - PROJECTILE_TIMED = 0x00000040, - PROJECTILE_BOUNCESOFFSPRITES = 0x00000080, - PROJECTILE_SPIT = 0x00000100, - PROJECTILE_COOLEXPLOSION1 = 0x00000200, - PROJECTILE_BLOOD = 0x00000400, - PROJECTILE_LOSESVELOCITY = 0x00000800, - PROJECTILE_NOAIM = 0x00001000, - PROJECTILE_RANDDECALSIZE = 0x00002000, - PROJECTILE_EXPLODEONTIMER = 0x00004000, - PROJECTILE_RPG_IMPACT = 0x00008000, - PROJECTILE_RADIUS_PICNUM = 0x00010000, - PROJECTILE_ACCURATE_AUTOAIM = 0x00020000, - PROJECTILE_FORCEIMPACT = 0x00040000, - PROJECTILE_REALCLIPDIST = 0x00080000, - PROJECTILE_ACCURATE = 0x00100000, - PROJECTILE_NOSETOWNERSHADE = 0x00200000, - PROJECTILE_RPG_IMPACT_DAMAGE = 0x00400000, - PROJECTILE_MOVED = 0x80000000, // internal flag, do not document - PROJECTILE_TYPE_MASK = PROJECTILE_HITSCAN | PROJECTILE_RPG | PROJECTILE_KNEE | PROJECTILE_BLOOD, -}; - extern tiledata_t g_tile[MAXTILES]; extern actor_t actor[MAXSPRITES]; extern int32_t block_deletesprite; @@ -463,83 +207,65 @@ void G_MoveWorld(void); void G_RefreshLights(void); void G_StopInterpolation(const int32_t *posptr); +inline int A_CheckEnemyTile(int tileNum); +inline int A_SetSprite(int spriteNum, uint32_t cliptype); +inline int32_t A_MoveSprite(int spriteNum, vec3_t const* change, uint32_t cliptype); + +inline int G_CheckForSpaceCeiling(int sectnum); +inline int G_CheckForSpaceFloor(int sectnum); + +inline int A_CheckEnemySprite(void const* s); + // PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly void Sect_ToggleInterpolation(int sectnum, int setInterpolation); -static FORCE_INLINE void Sect_ClearInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 0); } -static FORCE_INLINE void Sect_SetInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 1); } - -#ifdef LUNATIC -int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset); -#endif - -#if KRANDDEBUG -# define ACTOR_INLINE __fastcall -# define ACTOR_INLINE_HEADER extern __fastcall -#else -# define ACTOR_INLINE EXTERN_INLINE -# define ACTOR_INLINE_HEADER EXTERN_INLINE_HEADER -#endif +inline void Sect_ClearInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 0); } +inline void Sect_SetInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 1); } extern int32_t A_MoveSpriteClipdist(int32_t spritenum, vec3_t const * change, uint32_t cliptype, int32_t clipdist); -ACTOR_INLINE_HEADER int A_CheckEnemyTile(int tileNum); -ACTOR_INLINE_HEADER int A_SetSprite(int spriteNum, uint32_t cliptype); -ACTOR_INLINE_HEADER int32_t A_MoveSprite(int spriteNum, vec3_t const * change, uint32_t cliptype); - -EXTERN_INLINE_HEADER int G_CheckForSpaceCeiling(int sectnum); -EXTERN_INLINE_HEADER int G_CheckForSpaceFloor(int sectnum); - -EXTERN_INLINE_HEADER int A_CheckEnemySprite(void const * s); -#if defined actors_c_ || !defined DISABLE_INLINING - -# if !KRANDDEBUG || (KRANDDEBUG && defined actors_c_) - -ACTOR_INLINE int A_CheckEnemyTile(int const tileNum) +inline int A_CheckEnemyTile(int const tileNum) { return ((g_tile[tileNum].flags & (SFLAG_HARDCODED_BADGUY | SFLAG_BADGUY)) != 0); } -ACTOR_INLINE int A_SetSprite(int const spriteNum, uint32_t cliptype) +inline int A_SetSprite(int const spriteNum, uint32_t cliptype) { vec3_t const davect = { (sprite[spriteNum].xvel * (sintable[(sprite[spriteNum].ang + 512) & 2047])) >> 14, (sprite[spriteNum].xvel * (sintable[sprite[spriteNum].ang & 2047])) >> 14, sprite[spriteNum].zvel }; return (A_MoveSprite(spriteNum, &davect, cliptype) == 0); } -ACTOR_INLINE int A_SetSpriteNoZ(int const spriteNum, uint32_t cliptype) +inline int A_SetSpriteNoZ(int const spriteNum, uint32_t cliptype) { vec3_t const davect = { (sprite[spriteNum].xvel * (sintable[(sprite[spriteNum].ang + 512) & 2047])) >> 14, (sprite[spriteNum].xvel * (sintable[sprite[spriteNum].ang & 2047])) >> 14, 0 }; return (A_MoveSprite(spriteNum, &davect, cliptype) == 0); } -ACTOR_INLINE int32_t A_MoveSprite(int const spriteNum, vec3_t const * const change, uint32_t cliptype) +inline int32_t A_MoveSprite(int const spriteNum, vec3_t const * const change, uint32_t cliptype) { return A_MoveSpriteClipdist(spriteNum, change, cliptype, -1); } -# endif - -EXTERN_INLINE int G_CheckForSpaceCeiling(int const sectnum) +inline int G_CheckForSpaceCeiling(int const sectnum) { return ((sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 && (sector[sectnum].ceilingpicnum==MOONSKY1 || sector[sectnum].ceilingpicnum==BIGORBIT1)); } -EXTERN_INLINE int G_CheckForSpaceFloor(int const sectnum) +inline int G_CheckForSpaceFloor(int const sectnum) { return ((sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0 && (sector[sectnum].floorpicnum==MOONSKY1 || sector[sectnum].floorpicnum==BIGORBIT1)); } -EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite) +inline int A_CheckEnemySprite(void const * const pSprite) { return A_CheckEnemyTile(((uspriteptr_t) pSprite)->picnum); } + END_DUKE_NS #endif - -#endif diff --git a/source/duke3d/src/player.h b/source/duke3d/src/player.h index 0bf261bb3..19bdabdec 100644 --- a/source/duke3d/src/player.h +++ b/source/duke3d/src/player.h @@ -292,7 +292,11 @@ extern intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound for wea extern intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Color for polymer muzzle flash #endif -typedef struct { +// is referenced by shared code so it needs to be in the shared namespace. +END_DUKE_NS +BEGIN_DUKERR_NS +struct projectile_t +{ int32_t workslike, cstat; // 8b int32_t hitradius, range, flashcolor; // 12b int16_t spawns, sound, isound, vel; // 8b @@ -306,7 +310,10 @@ typedef struct { uint8_t clipdist; // 1b int8_t filler[2]; // 2b int32_t userdata; // 4b -} projectile_t; +}; + +END_DUKERR_NS +BEGIN_DUKE_NS // KEEPINSYNC lunatic/_defs_game.lua typedef struct { diff --git a/source/dukerr/actors.h b/source/dukerr/actors.h new file mode 100644 index 000000000..b66de458f --- /dev/null +++ b/source/dukerr/actors.h @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2010 EDuke32 developers and contributors + +This file is part of EDuke32. + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +//------------------------------------------------------------------------- + +#ifndef __actors_h_ +#define __actors_h_ + +#include "player.h" +# include "namesdyn.h" + +BEGIN_DUKERR_NS + +#define MAXSLEEPDIST 16384 +#define SLEEPTIME 1536 +#define ACTOR_FLOOR_OFFSET (1<<8) +#define ZOFFSET (1<<8) +#define ZOFFSET2 (16<<8) +#define ZOFFSET3 (8<<8) +#define ZOFFSET4 (12<<8) +#define ZOFFSET5 (32<<8) +#define ZOFFSET6 (4<<8) + +#define ACTOR_MAXFALLINGZVEL 6144 +#define ACTOR_ONWATER_ADDZ (24<<8) + +// KEEPINSYNC lunatic/con_lang.lua +#define STAT_DEFAULT 0 +#define STAT_ACTOR 1 +#define STAT_ZOMBIEACTOR 2 +#define STAT_EFFECTOR 3 +#define STAT_PROJECTILE 4 +#define STAT_MISC 5 +#define STAT_STANDABLE 6 +#define STAT_LOCATOR 7 +#define STAT_ACTIVATOR 8 +#define STAT_TRANSPORT 9 +#define STAT_PLAYER 10 +#define STAT_FX 11 +#define STAT_FALLER 12 +#define STAT_DUMMYPLAYER 13 +#define STAT_LIGHT 14 +#define STAT_RAROR 15 +#define STAT_NETALLOC (MAXSTATUS-1) + + +// Defines the motion characteristics of an actor +enum amoveflags_t +{ + face_player = 1, + geth = 2, + getv = 4, + random_angle = 8, + face_player_slow = 16, + spin = 32, + face_player_smart = 64, + fleeenemy = 128, + jumptoplayer_only = 256, + jumptoplayer_bits = 257, // NOTE: two bits set! + seekplayer = 512, + furthestdir = 1024, + dodgebullet = 4096, + justjump2 = 8192, + windang = 16384, + antifaceplayerslow = 32768 +}; + +// Defines for 'useractor' keyword +enum uactortypes_t +{ + notenemy, + enemy, + enemystayput +}; + +// These macros are there to give names to the t_data[]/T*/vm.g_t[] indices +// when used with actors. Greppability of source code is certainly a virtue. +#define AC_COUNT(t) ((t)[0]) /* the actor's count */ +/* The ID of the actor's current move. In C-CON, the bytecode offset to the + * move composite: */ +#define AC_MOVE_ID(t) ((t)[1]) +#define AC_ACTION_COUNT(t) ((t)[2]) /* the actor's action count */ +#define AC_CURFRAME(t) ((t)[3]) /* the actor's current frame offset */ +/* The ID of the actor's current action. In C-CON, the bytecode offset to the + * action composite: */ +#define AC_ACTION_ID(t) ((t)[4]) +#define AC_AI_ID(t) ((t)[5]) /* the ID of the actor's current ai */ + +enum actionparams +{ + ACTION_STARTFRAME = 0, + ACTION_NUMFRAMES, + ACTION_VIEWTYPE, + ACTION_INCVAL, + ACTION_DELAY, + ACTION_FLAGS, + ACTION_PARAM_COUNT, +}; + +enum actionflags +{ + AF_VIEWPOINT = 1u<<0u, +}; + +// Select an actor's actiontics and movflags locations depending on +// whether we compile the Lunatic build. +// : sprite pointer +// : actor_t pointer +# define AC_ACTIONTICS(spr, a) ((spr)->lotag) +# define AC_MOVFLAGS(spr, a) ((spr)->hitag) + +// (+ 40 16 16 4 8 6 8 6 4 20) +#pragma pack(push, 1) +struct actor_t +{ + int32_t t_data[10]; // 40b sometimes used to hold offsets to con code + + int32_t flags; // 4b + vec3_t bpos; // 12b + int32_t floorz, ceilingz; // 8b + vec2_t lastv; // 8b + int16_t picnum, ang, extra, owner; // 8b + int16_t movflag, tempang, timetosleep; // 6b + int16_t stayput; // 2b + + uint8_t cgg, lasttransport; // 2b + // NOTE: 'dispicnum' is updated every frame, not in sync with game tics! + int16_t dispicnum; // 2b + +#ifdef POLYMER + int16_t lightId, lightmaxrange; // 4b + _prlight *lightptr; // 4b/8b aligned on 96 bytes + uint8_t lightcount, filler[3]; +#endif +}; + +#pragma pack(pop) + +struct projectile_t; + +struct tiledata_t +{ + intptr_t *execPtr; // pointer to CON script for this tile, formerly actorscrptr + intptr_t *loadPtr; // pointer to load time CON script, formerly actorLoadEventScrPtr or something + projectile_t *proj; + projectile_t *defproj; + uint32_t flags; // formerly SpriteFlags, ActorType + int32_t cacherange; // formerly SpriteCache +}; + + +// KEEPINSYNC lunatic/con_lang.lua +enum sflags_t +{ + SFLAG_SHADOW = 0x00000001, + SFLAG_NVG = 0x00000002, + SFLAG_NOSHADE = 0x00000004, + SFLAG_PROJECTILE = 0x00000008, + SFLAG_DECAL = 0x00000010, + SFLAG_BADGUY = 0x00000020, + SFLAG_NOPAL = 0x00000040, + SFLAG_NOEVENTCODE = 0x00000080, + SFLAG_NOLIGHT = 0x00000100, + SFLAG_USEACTIVATOR = 0x00000200, + SFLAG_NULL = 0x00000400, // null sprite in multiplayer + SFLAG_NOCLIP = 0x00000800, // clipmove it with cliptype 0 + SFLAG_NOFLOORSHADOW = 0x00001000, // for temp. internal use, per-tile flag not checked + SFLAG_SMOOTHMOVE = 0x00002000, + SFLAG_NOTELEPORT = 0x00004000, + SFLAG_BADGUYSTAYPUT = 0x00008000, + SFLAG_CACHE = 0x00010000, + // rotation-fixed wrt a pivot point to prevent position diverging due to + // roundoff error accumulation: + SFLAG_ROTFIXED = 0x00020000, + SFLAG_HARDCODED_BADGUY = 0x00040000, + SFLAG_DIDNOSE7WATER = 0x00080000, // used temporarily + SFLAG_NODAMAGEPUSH = 0x00100000, + SFLAG_NOWATERDIP = 0x00200000, + SFLAG_HURTSPAWNBLOOD = 0x00400000, + SFLAG_GREENSLIMEFOOD = 0x00800000, + SFLAG_REALCLIPDIST = 0x01000000, + SFLAG_WAKEUPBADGUYS = 0x02000000, + SFLAG_DAMAGEEVENT = 0x04000000, + SFLAG_NOWATERSECTOR = 0x08000000, + SFLAG_QUEUEDFORDELETE = 0x10000000, + SFLAG_BADGUY_TILE = 0x20000000, // these are from RedNukem and had to be renumbered. + SFLAG_KILLCOUNT = 0x40000000, + SFLAG_NOCANSEECHECK = 0x80000000, +}; + +// Custom projectiles "workslike" flags. +// XXX: Currently not predefined from CON. +enum pflags_t +{ + PROJECTILE_HITSCAN = 0x00000001, + PROJECTILE_RPG = 0x00000002, + PROJECTILE_BOUNCESOFFWALLS = 0x00000004, + PROJECTILE_BOUNCESOFFMIRRORS = 0x00000008, + PROJECTILE_KNEE = 0x00000010, + PROJECTILE_WATERBUBBLES = 0x00000020, + PROJECTILE_TIMED = 0x00000040, + PROJECTILE_BOUNCESOFFSPRITES = 0x00000080, + PROJECTILE_SPIT = 0x00000100, + PROJECTILE_COOLEXPLOSION1 = 0x00000200, + PROJECTILE_BLOOD = 0x00000400, + PROJECTILE_LOSESVELOCITY = 0x00000800, + PROJECTILE_NOAIM = 0x00001000, + PROJECTILE_RANDDECALSIZE = 0x00002000, + PROJECTILE_EXPLODEONTIMER = 0x00004000, + PROJECTILE_RPG_IMPACT = 0x00008000, + PROJECTILE_RADIUS_PICNUM = 0x00010000, + PROJECTILE_ACCURATE_AUTOAIM = 0x00020000, + PROJECTILE_FORCEIMPACT = 0x00040000, + PROJECTILE_REALCLIPDIST = 0x00080000, + PROJECTILE_ACCURATE = 0x00100000, + PROJECTILE_NOSETOWNERSHADE = 0x00200000, + PROJECTILE_RPG_IMPACT_DAMAGE = 0x00400000, + PROJECTILE_MOVED = 0x80000000, // internal flag, do not document + PROJECTILE_TYPE_MASK = PROJECTILE_HITSCAN | PROJECTILE_RPG | PROJECTILE_KNEE | PROJECTILE_BLOOD, +}; + + +END_DUKE_NS + +#endif + diff --git a/source/rr/src/actors.cpp b/source/rr/src/actors.cpp index 3735d6388..24f7a3cd2 100644 --- a/source/rr/src/actors.cpp +++ b/source/rr/src/actors.cpp @@ -420,7 +420,7 @@ int32_t A_MoveSprite(int32_t spriteNum, vec3_t const * const change, uint32_t cl { // Handle potential stayput condition (map-provided or hard-coded). if (newSectnum < 0 - || ((actor[spriteNum].actorstayput >= 0 && actor[spriteNum].actorstayput != newSectnum) + || ((actor[spriteNum].stayput >= 0 && actor[spriteNum].stayput != newSectnum) || (!RR && ((pSprite->picnum == BOSS2 && pSprite->pal == 0 && sector[newSectnum].lotag != ST_3) || ((pSprite->picnum == BOSS1 || pSprite->picnum == BOSS2) && sector[newSectnum].lotag == ST_1_ABOVE_WATER) || (sector[newSectnum].lotag == ST_1_ABOVE_WATER diff --git a/source/rr/src/actors.h b/source/rr/src/actors.h index ff7ca7616..da3ad1d5a 100644 --- a/source/rr/src/actors.h +++ b/source/rr/src/actors.h @@ -25,131 +25,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" # include "namesdyn.h" +#include "dukerr/actors.h" BEGIN_RR_NS -#define MAXSLEEPDIST 16384 -#define SLEEPTIME 1536 -#define ZOFFSET (1<<8) -#define ZOFFSET2 (16<<8) -#define ZOFFSET3 (8<<8) -#define ZOFFSET4 (12<<8) -#define ZOFFSET5 (32<<8) -#define ZOFFSET6 (4<<8) - -#define ACTOR_MAXFALLINGZVEL 6144 -#define ACTOR_ONWATER_ADDZ (24<<8) - -// KEEPINSYNC lunatic/con_lang.lua -#define STAT_DEFAULT 0 -#define STAT_ACTOR 1 -#define STAT_ZOMBIEACTOR 2 -#define STAT_EFFECTOR 3 -#define STAT_PROJECTILE 4 -#define STAT_MISC 5 -#define STAT_STANDABLE 6 -#define STAT_LOCATOR 7 -#define STAT_ACTIVATOR 8 -#define STAT_TRANSPORT 9 -#define STAT_PLAYER 10 -#define STAT_FX 11 -#define STAT_FALLER 12 -#define STAT_DUMMYPLAYER 13 -#define STAT_LIGHT 14 -#define STAT_RAROR 15 -#define STAT_NETALLOC MAXSTATUS-1 - - -// Defines the motion characteristics of an actor -enum amoveflags_t -{ - face_player = 1, - geth = 2, - getv = 4, - random_angle = 8, - face_player_slow = 16, - spin = 32, - face_player_smart = 64, - fleeenemy = 128, - jumptoplayer_only = 256, - jumptoplayer_bits = 257, // NOTE: two bits set! - seekplayer = 512, - furthestdir = 1024, - dodgebullet = 4096, - justjump2 = 8192, - windang = 16384, - antifaceplayerslow = 32768 -}; - -// Defines for 'useractor' keyword -enum uactortypes_t -{ - notenemy, - enemy, - enemystayput -}; - -// These macros are there to give names to the t_data[]/T*/vm.g_t[] indices -// when used with actors. Greppability of source code is certainly a virtue. -#define AC_COUNT(t) ((t)[0]) /* the actor's count */ -/* The ID of the actor's current move. In C-CON, the bytecode offset to the - * move composite: */ -#define AC_MOVE_ID(t) ((t)[1]) -#define AC_ACTION_COUNT(t) ((t)[2]) /* the actor's action count */ -#define AC_CURFRAME(t) ((t)[3]) /* the actor's current frame offset */ -/* The ID of the actor's current action. In C-CON, the bytecode offset to the - * action composite: */ -#define AC_ACTION_ID(t) ((t)[4]) -#define AC_AI_ID(t) ((t)[5]) /* the ID of the actor's current ai */ - -enum actionparams -{ - ACTION_STARTFRAME = 0, - ACTION_NUMFRAMES, - ACTION_VIEWTYPE, - ACTION_INCVAL, - ACTION_DELAY, - ACTION_FLAGS, - ACTION_PARAM_COUNT, -}; - -enum actionflags -{ - AF_VIEWPOINT = 1u<<0u, -}; - -// Select an actor's actiontics and movflags locations depending on -// whether we compile the Lunatic build. -// : sprite pointer -// : actor_t pointer -# define AC_ACTIONTICS(spr, a) ((spr)->lotag) -# define AC_MOVFLAGS(spr, a) ((spr)->hitag) - // (+ 40 16 16 4 8 6 8 6 4 20) #pragma pack(push, 1) -typedef struct -{ - int32_t t_data[10]; // 40b sometimes used to hold offsets to con code - - int32_t flags; // 4b - vec3_t bpos; // 12b - int32_t floorz, ceilingz; // 8b - vec2_t lastv; // 8b - int16_t picnum, ang, extra, owner; // 8b - int16_t movflag, tempang, timetosleep; // 6b - int16_t actorstayput; // 2b - - uint8_t cgg, lasttransport; // 2b - // NOTE: 'dispicnum' is updated every frame, not in sync with game tics! - int16_t dispicnum; // 2b - -#ifdef POLYMER - int16_t lightId, lightmaxrange; // 4b - _prlight *lightptr; // 4b/8b aligned on 96 bytes - uint8_t lightcount, filler[3]; -#endif -} actor_t; - // this struct needs to match the beginning of actor_t above typedef struct { @@ -161,7 +42,7 @@ typedef struct vec2_t lastv; // 8b int16_t picnum, ang, extra, owner; // 8b int16_t movflag, tempang, timetosleep; // 6b - int16_t actorstayput; + int16_t stayput; uint8_t cgg, lasttransport; @@ -169,84 +50,6 @@ typedef struct int16_t netIndex; } netactor_t; #pragma pack(pop) - -typedef struct -{ - intptr_t *execPtr; // pointer to CON script for this tile, formerly actorscrptr - intptr_t *loadPtr; // pointer to load time CON script, formerly actorLoadEventScrPtr or something - uint32_t flags; // formerly SpriteFlags, ActorType - int32_t cacherange; // formerly SpriteCache -} tiledata_t; - - -// KEEPINSYNC lunatic/con_lang.lua -enum sflags_t -{ - SFLAG_SHADOW = 0x00000001, - SFLAG_NVG = 0x00000002, - SFLAG_NOSHADE = 0x00000004, - SFLAG_PROJECTILE = 0x00000008, - SFLAG_DECAL = 0x00000010, - SFLAG_BADGUY = 0x00000020, - SFLAG_NOPAL = 0x00000040, - SFLAG_NOEVENTCODE = 0x00000080, - SFLAG_NOLIGHT = 0x00000100, - SFLAG_USEACTIVATOR = 0x00000200, - SFLAG_NULL = 0x00000400, // null sprite in multiplayer - SFLAG_NOCLIP = 0x00000800, // clipmove it with cliptype 0 - SFLAG_NOFLOORSHADOW = 0x00001000, // for temp. internal use, per-tile flag not checked - SFLAG_SMOOTHMOVE = 0x00002000, - SFLAG_NOTELEPORT = 0x00004000, - SFLAG_BADGUYSTAYPUT = 0x00008000, - SFLAG_CACHE = 0x00010000, - // rotation-fixed wrt a pivot point to prevent position diverging due to - // roundoff error accumulation: - SFLAG_ROTFIXED = 0x00020000, - SFLAG_HARDCODED_BADGUY = 0x00040000, - SFLAG_DIDNOSE7WATER = 0x00080000, // used temporarily - SFLAG_NODAMAGEPUSH = 0x00100000, - SFLAG_NOWATERDIP = 0x00200000, - SFLAG_HURTSPAWNBLOOD = 0x00400000, - SFLAG_GREENSLIMEFOOD = 0x00800000, - SFLAG_REALCLIPDIST = 0x01000000, - SFLAG_WAKEUPBADGUYS = 0x02000000, - SFLAG_DAMAGEEVENT = 0x04000000, - SFLAG_BADGUY_TILE = 0x08000000, - SFLAG_KILLCOUNT = 0x10000000, - SFLAG_NOCANSEECHECK = 0x20000000, -}; - -// Custom projectiles "workslike" flags. -// XXX: Currently not predefined from CON. -enum pflags_t -{ - PROJECTILE_HITSCAN = 0x00000001, - PROJECTILE_RPG = 0x00000002, - PROJECTILE_BOUNCESOFFWALLS = 0x00000004, - PROJECTILE_BOUNCESOFFMIRRORS = 0x00000008, - PROJECTILE_KNEE = 0x00000010, - PROJECTILE_WATERBUBBLES = 0x00000020, - PROJECTILE_TIMED = 0x00000040, - PROJECTILE_BOUNCESOFFSPRITES = 0x00000080, - PROJECTILE_SPIT = 0x00000100, - PROJECTILE_COOLEXPLOSION1 = 0x00000200, - PROJECTILE_BLOOD = 0x00000400, - PROJECTILE_LOSESVELOCITY = 0x00000800, - PROJECTILE_NOAIM = 0x00001000, - PROJECTILE_RANDDECALSIZE = 0x00002000, - PROJECTILE_EXPLODEONTIMER = 0x00004000, - PROJECTILE_RPG_IMPACT = 0x00008000, - PROJECTILE_RADIUS_PICNUM = 0x00010000, - PROJECTILE_ACCURATE_AUTOAIM = 0x00020000, - PROJECTILE_FORCEIMPACT = 0x00040000, - PROJECTILE_REALCLIPDIST = 0x00080000, - PROJECTILE_ACCURATE = 0x00100000, - PROJECTILE_NOSETOWNERSHADE = 0x00200000, - PROJECTILE_RPG_IMPACT_DAMAGE = 0x00400000, - PROJECTILE_MOVED = 0x80000000, // internal flag, do not document - PROJECTILE_TYPE_MASK = PROJECTILE_HITSCAN | PROJECTILE_RPG | PROJECTILE_KNEE | PROJECTILE_BLOOD, -}; - extern tiledata_t g_tile[MAXTILES]; extern actor_t actor[MAXSPRITES]; extern int32_t block_deletesprite; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 3e0ff6cc1..c64c68900 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -1549,7 +1549,7 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1 actor[i].ceilingz = actor[s_ow].ceilingz; } - actor[i].actorstayput = actor[i].extra = -1; + actor[i].stayput = actor[i].extra = -1; #ifdef POLYMER actor[i].lightId = -1; #endif @@ -1632,7 +1632,7 @@ int A_Spawn(int spriteNum, int tileNum) pActor->floorz = sector[pSprite->sectnum].floorz; pActor->ceilingz = sector[pSprite->sectnum].ceilingz; - pActor->actorstayput = pActor->extra = -1; + pActor->stayput = pActor->extra = -1; #ifdef POLYMER pActor->lightId = -1; @@ -1743,7 +1743,7 @@ default_case: A_Fall(newSprite); if (A_CheckSpriteFlags(newSprite, SFLAG_BADGUYSTAYPUT)) - pActor->actorstayput = pSprite->sectnum; + pActor->stayput = pSprite->sectnum; if (!RR || A_CheckSpriteFlags(newSprite, SFLAG_KILLCOUNT)) g_player[myconnectindex].ps->max_actors_killed++; @@ -2896,7 +2896,7 @@ rrbloodpool_fallthrough: case COMMANDERSTAYPUT__STATIC: case BOSS4STAYPUT__STATIC: if (RR) goto default_case; - pActor->actorstayput = pSprite->sectnum; + pActor->stayput = pSprite->sectnum; fallthrough__; case BOSS1__STATIC: case BOSS2__STATIC: @@ -3058,7 +3058,7 @@ rrbloodpool_fallthrough: case CHEERSTAYPUT__STATICRR: case SBMOVE__STATICRR: if ((RRRA && pSprite->picnum == SBMOVE) || (!RRRA && (pSprite->picnum == SBSWIPE || pSprite->picnum == CHEERSTAYPUT))) goto default_case; - pActor->actorstayput = pSprite->sectnum; + pActor->stayput = pSprite->sectnum; fallthrough__; case BOULDER__STATICRR: case BOULDER1__STATICRR: diff --git a/source/rr/src/gameexec.cpp b/source/rr/src/gameexec.cpp index 25c8da986..64068e736 100644 --- a/source/rr/src/gameexec.cpp +++ b/source/rr/src/gameexec.cpp @@ -1389,7 +1389,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pActor->timetosleep = SLEEPTIME; continue; - case CON_IFACTORNOTSTAYPUT: VM_CONDITIONAL(vm.pActor->actorstayput == -1); continue; + case CON_IFACTORNOTSTAYPUT: VM_CONDITIONAL(vm.pActor->stayput == -1); continue; case CON_IFCANSEE: { @@ -1911,7 +1911,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } else P_AddKills(pPlayer, *insptr); insptr++; - vm.pActor->actorstayput = -1; + vm.pActor->stayput = -1; continue; case CON_LOTSOFGLASS: diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index c0fbc8aa3..0ce6d9675 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -826,7 +826,7 @@ void P_ResetPlayer(int playerNum) actor[pPlayer->i].cgg = 0; actor[pPlayer->i].movflag = 0; actor[pPlayer->i].tempang = 0; - actor[pPlayer->i].actorstayput = -1; + actor[pPlayer->i].stayput = -1; actor[pPlayer->i].dispicnum = 0; actor[pPlayer->i].owner = pPlayer->i; actor[pPlayer->i].t_data[4] = 0;