From d368d734d3694c06fe8bfb573db922cfb8c5fab8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 14 Oct 2020 00:58:21 +0200 Subject: [PATCH] - prototyping some refactoring helpers. --- source/build/include/build.h | 19 +++++++++++++++++++ source/games/duke/src/types.h | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/source/build/include/build.h b/source/build/include/build.h index 988a47cdd..9f06f968f 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -246,6 +246,25 @@ extern usermaphack_t g_loadedMapHack; EXTERN spriteext_t *spriteext; EXTERN spritesmooth_t *spritesmooth; +// Wrapper that makes an array of pointers look like an array of references. (Refactoring helper.) + +template +class ReferenceArray +{ + T* data[size]; +public: + T& operator[](size_t index) + { + assert(index < size); + return *data[index]; + } + + void set(int pos, T* spr) + { + data[pos] = spr; + } +}; + EXTERN sectortype *sector; EXTERN walltype *wall; EXTERN spritetype *sprite; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index bb51312d8..450f7cc4f 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -30,6 +30,15 @@ struct weaponhit int temp_data[6]; }; +// This is how a Duke actor should later be exposed to scripting. The object definition parts are disabled for now so that this can be used already to transition the code. +class DDukeActor //: public DBuildActor +{ +public: + //DECLARE_CLASS(DDukeActor, DBuildActor) + spritetype s; + weaponhit h; +}; + struct animwalltype { short wallnum, tag;