From df42230b457d5a236b6e4b189b649924d2177cfb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Oct 2020 13:14:32 +0200 Subject: [PATCH] - Exhumed: converted all #define constants to enums. --- source/exhumed/src/aistuff.h | 33 +++++++++++++++++++++------------ source/exhumed/src/anims.cpp | 2 +- source/exhumed/src/anubis.cpp | 2 +- source/exhumed/src/bubbles.cpp | 7 +++++-- source/exhumed/src/bullet.cpp | 2 +- source/exhumed/src/engine.h | 22 +++++++++------------- source/exhumed/src/exhumed.h | 2 +- source/exhumed/src/fish.cpp | 7 +++++-- source/exhumed/src/lavadude.cpp | 2 +- source/exhumed/src/light.cpp | 2 +- source/exhumed/src/lighting.cpp | 13 ++++++++----- source/exhumed/src/lion.cpp | 2 +- source/exhumed/src/move.cpp | 7 +++++-- source/exhumed/src/object.cpp | 22 ++++++++++++---------- source/exhumed/src/player.h | 11 +++++++---- source/exhumed/src/queen.cpp | 9 ++++++--- source/exhumed/src/rat.cpp | 2 +- source/exhumed/src/rex.cpp | 2 +- source/exhumed/src/roach.cpp | 2 +- source/exhumed/src/runlist.cpp | 8 +++++--- source/exhumed/src/scorp.cpp | 2 +- source/exhumed/src/sequence.cpp | 11 +++++++---- source/exhumed/src/set.cpp | 2 +- source/exhumed/src/snake.cpp | 2 +- source/exhumed/src/sound.h | 17 +++++++++-------- source/exhumed/src/spider.cpp | 2 +- source/exhumed/src/view.cpp | 2 +- source/exhumed/src/wasp.cpp | 2 +- 28 files changed, 115 insertions(+), 84 deletions(-) diff --git a/source/exhumed/src/aistuff.h b/source/exhumed/src/aistuff.h index bb7c09b9c..d97e58162 100644 --- a/source/exhumed/src/aistuff.h +++ b/source/exhumed/src/aistuff.h @@ -101,7 +101,7 @@ void FuncFishLimb(int a, int b, int c); // grenade -#define kMaxGrenades 50 +enum { kMaxGrenades = 50 }; void InitGrenades(); int BuildGrenade(int nPlayer); @@ -111,7 +111,7 @@ void FuncGrenade(int, int, int); // gun -#define kMaxWeapons 7 +enum { kMaxWeapons = 7 }; enum { @@ -255,7 +255,7 @@ void SetQuake(short nSprite, int nVal); // mummy -#define kMaxMummies 150 +enum { kMaxMummies = 150 }; void InitMummy(); int BuildMummy(int val, int x, int y, int z, int nSector, int nAngle); @@ -263,9 +263,12 @@ void FuncMummy(int nSector, int edx, int nRun); // object -#define kMaxPoints 1024 -#define kMaxSlides 128 -#define kMaxElevs 1024 +enum +{ + kMaxPoints = 1024, + kMaxSlides = 128, + kMaxElevs = 1024 +}; enum kStatus { @@ -366,8 +369,11 @@ void FuncRoach(int a, int nDamage, int nRun); // runlist -#define kMaxRuns 25600 -#define kMaxChannels 4096 +enum +{ + kMaxRuns = 25600, + kMaxChannels = 4096 +}; struct RunStruct { @@ -438,7 +444,7 @@ void FuncSet(int, int, int); // snake -#define kSnakeSprites 8 // or rename to kSnakeParts? +enum { kSnakeSprites = 8 }; // or rename to kSnakeParts? // 32bytes struct Snake @@ -480,8 +486,11 @@ void FuncSpider(int a, int b, int nRun); // switch -#define kMaxLinks 1024 -#define kMaxSwitches 1024 +enum +{ + kMaxLinks = 1024, + kMaxSwitches = 1024 +}; void InitLink(); void InitSwitch(); @@ -516,7 +525,7 @@ void FuncWasp(int eax, int edx, int nRun); -#define kMessageMask 0x7F0000 +enum { kMessageMask = 0x7F0000 }; inline int GrabTimeSlot(int nVal) { return -1; } END_PS_NS diff --git a/source/exhumed/src/anims.cpp b/source/exhumed/src/anims.cpp index cde6124eb..8ee5a664e 100644 --- a/source/exhumed/src/anims.cpp +++ b/source/exhumed/src/anims.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxAnims 400 +enum { kMaxAnims = 400 }; short nMagicSeq = -1; short nPreMagicSeq = -1; diff --git a/source/exhumed/src/anubis.cpp b/source/exhumed/src/anubis.cpp index 13339edc0..ce5d72735 100644 --- a/source/exhumed/src/anubis.cpp +++ b/source/exhumed/src/anubis.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxAnubis 80 +enum { kMaxAnubis = 80 }; struct Anubis { diff --git a/source/exhumed/src/bubbles.cpp b/source/exhumed/src/bubbles.cpp index 2dd9c97c4..588415613 100644 --- a/source/exhumed/src/bubbles.cpp +++ b/source/exhumed/src/bubbles.cpp @@ -26,8 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxBubbles 200 -#define kMaxMachines 125 +enum +{ + kMaxBubbles = 200, + kMaxMachines = 125 +}; struct Bubble { diff --git a/source/exhumed/src/bullet.cpp b/source/exhumed/src/bullet.cpp index d7e1cd82f..03188dbf3 100644 --- a/source/exhumed/src/bullet.cpp +++ b/source/exhumed/src/bullet.cpp @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxBullets 500 +enum { kMaxBullets = 500 }; short BulletFree[kMaxBullets]; diff --git a/source/exhumed/src/engine.h b/source/exhumed/src/engine.h index 90b44e929..b9e39dc10 100644 --- a/source/exhumed/src/engine.h +++ b/source/exhumed/src/engine.h @@ -24,22 +24,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxSprites 4096 -#define kMaxSectors 1024 -#define kMaxWalls 8192 -#define kMaxVoxels 4096 - enum { - kStatIgnited = 404 + kStatIgnited = 404, + kMaxSprites = 4096, + kMaxSectors = 1024, + kMaxWalls = 8192, + kMaxVoxels = 4096, + kMaxPalookups = 256, + kMaxStatus = 1024, + kMap20 = 20, + kAngleMask = 0x7FF }; -#define kMaxPalookups 256 -#define kMaxStatus 1024 -//#define MAXPSKYTILES 256 - - int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask); void precache(); void resettiming(); @@ -52,7 +50,6 @@ bool CDplaying(); void StopCD(); // init -#define kMap20 20 enum { kSectUnderwater = 0x2000, @@ -123,7 +120,6 @@ int RandomSize(int nSize); // trigdat -#define kAngleMask 0x7FF int GetMyAngle(int x, int y); diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index e552e6e63..e5f8fbc33 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kTimerTicks 120 +enum { kTimerTicks = 120 }; enum basepal_t { BASEPAL = 0, diff --git a/source/exhumed/src/fish.cpp b/source/exhumed/src/fish.cpp index 0624d8024..1c735049e 100644 --- a/source/exhumed/src/fish.cpp +++ b/source/exhumed/src/fish.cpp @@ -25,8 +25,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxFishes 128 -#define kMaxChunks 128 +enum +{ + kMaxFishes = 128, + kMaxChunks = 128 +}; short FishCount = 0; diff --git a/source/exhumed/src/lavadude.cpp b/source/exhumed/src/lavadude.cpp index e60e10a93..6ff14454e 100644 --- a/source/exhumed/src/lavadude.cpp +++ b/source/exhumed/src/lavadude.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxLavas 20 +enum { kMaxLavas = 20 }; struct Lava { diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index 11e85b7a4..5ebbe88bb 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxGrads 12 +enum { kMaxGrads = 12 }; const char *GradList[kMaxGrads] = { "normal.rmp", diff --git a/source/exhumed/src/lighting.cpp b/source/exhumed/src/lighting.cpp index 45b33e4d4..aafc239df 100644 --- a/source/exhumed/src/lighting.cpp +++ b/source/exhumed/src/lighting.cpp @@ -26,11 +26,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxFlashes 2000 -#define kMaxFlickerMask 25 -#define kMaxGlows 50 -#define kMaxFlickers 100 -#define kMaxFlows 375 +enum +{ + kMaxFlashes = 2000, + kMaxFlickerMask = 25, + kMaxGlows = 50, + kMaxFlickers = 100, + kMaxFlows = 375, +}; struct Flash { diff --git a/source/exhumed/src/lion.cpp b/source/exhumed/src/lion.cpp index ace647f38..c783e7206 100644 --- a/source/exhumed/src/lion.cpp +++ b/source/exhumed/src/lion.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxLions 40 +enum { kMaxLions = 40 }; short LionCount = -1; short MoveHook[kMaxLions]; diff --git a/source/exhumed/src/move.cpp b/source/exhumed/src/move.cpp index 72d36cc27..62236b25a 100644 --- a/source/exhumed/src/move.cpp +++ b/source/exhumed/src/move.cpp @@ -42,8 +42,11 @@ short nBodySprite[50]; int hihit, sprceiling, sprfloor, lohit; -#define kMaxPushBlocks 100 -#define kMaxMoveChunks 75 +enum +{ + kMaxPushBlocks = 100, + kMaxMoveChunks = 75 +}; // think this belongs in init.c? BlockInfo sBlockInfo[kMaxPushBlocks]; diff --git a/source/exhumed/src/object.cpp b/source/exhumed/src/object.cpp index 264512de6..8153aa50e 100644 --- a/source/exhumed/src/object.cpp +++ b/source/exhumed/src/object.cpp @@ -30,16 +30,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxBobs 200 -#define kMaxDrips 50 -#define kMaxMoveSects 50 -#define kMaxObjects 128 -#define kMaxWallFace 4096 -#define kMaxSlideData 128 -#define kMaxPoints 1024 -#define kMaxTraps 40 -#define kMaxTrails 20 -#define kMaxTrailPoints 100 +enum +{ + kMaxBobs = 200, + kMaxDrips = 50, + kMaxMoveSects = 50, + kMaxObjects = 128, + kMaxWallFace = 4096, + kMaxSlideData = 128, + kMaxTraps = 40, + kMaxTrails = 20, + kMaxTrailPoints = 100, +}; static short ObjectSeq[] = { diff --git a/source/exhumed/src/player.h b/source/exhumed/src/player.h index 924dadb90..6855ff67e 100644 --- a/source/exhumed/src/player.h +++ b/source/exhumed/src/player.h @@ -33,10 +33,13 @@ void RestartPlayer(short nPlayer); void FuncPlayer(int nSector, int nSprite, int nRun); -#define kMaxPlayers 8 -#define kDefaultLives 3 -#define kMaxPlayerLives 5 -#define kMaxHealth 800 +enum +{ + kMaxPlayers = 8, + kDefaultLives = 3, + kMaxPlayerLives = 5, + kMaxHealth = 800 +} extern int nLocalPlayer; diff --git a/source/exhumed/src/queen.cpp b/source/exhumed/src/queen.cpp index c896044a2..594c72407 100644 --- a/source/exhumed/src/queen.cpp +++ b/source/exhumed/src/queen.cpp @@ -27,9 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxQueens 1 -#define kMaxEggs 10 -#define kMaxTails 7 +enum +{ + kMaxQueens = 1, + kMaxEggs = 10, + kMaxTails = 7 +}; short QueenCount = 0; diff --git a/source/exhumed/src/rat.cpp b/source/exhumed/src/rat.cpp index f12737186..fc0ed5e26 100644 --- a/source/exhumed/src/rat.cpp +++ b/source/exhumed/src/rat.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxRats 50 +enum { kMaxRats = 50 }; short nMinChunk; short nPlayerPic; diff --git a/source/exhumed/src/rex.cpp b/source/exhumed/src/rex.cpp index ff5982f12..be458b9f0 100644 --- a/source/exhumed/src/rex.cpp +++ b/source/exhumed/src/rex.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxRex 50 +enum { kMaxRex = 50 }; short RexCount = 0; short RexChan[kMaxRex]; diff --git a/source/exhumed/src/roach.cpp b/source/exhumed/src/roach.cpp index 5fe655683..2c743abad 100644 --- a/source/exhumed/src/roach.cpp +++ b/source/exhumed/src/roach.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxRoach 100 +enum { kMaxRoach = 100 }; int16_t RoachCount = -1; diff --git a/source/exhumed/src/runlist.cpp b/source/exhumed/src/runlist.cpp index 2fdb20557..34986ed1a 100644 --- a/source/exhumed/src/runlist.cpp +++ b/source/exhumed/src/runlist.cpp @@ -25,9 +25,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -//#define kFuncMax 0x260000 // the number 38 stored in the high word of an int -#define kFuncMax 39 -#define kMaxRunStack 200 +enum +{ + kFuncMax = 39, + kMaxRunStack = 200 +}; short RunCount = -1; diff --git a/source/exhumed/src/scorp.cpp b/source/exhumed/src/scorp.cpp index e081733ee..7972fa3b7 100644 --- a/source/exhumed/src/scorp.cpp +++ b/source/exhumed/src/scorp.cpp @@ -29,7 +29,7 @@ BEGIN_PS_NS Selkis Boss AI code */ -#define kMaxScorpions 5 +enum { kMaxScorpions = 5 }; short ScorpCount = -1; diff --git a/source/exhumed/src/sequence.cpp b/source/exhumed/src/sequence.cpp index 2345df6a9..a627f73a3 100644 --- a/source/exhumed/src/sequence.cpp +++ b/source/exhumed/src/sequence.cpp @@ -32,10 +32,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxSequences 4096 -#define kMaxSEQFiles 78 -#define kMaxSEQFrames 18000 -#define kMaxSEQChunks 21000 +enum +{ + kMaxSequences = 4096, + kMaxSEQFiles = 78, + kMaxSEQFrames = 18000, + kMaxSEQChunks = 21000 +}; short sequences = 0; short frames = 0; diff --git a/source/exhumed/src/set.cpp b/source/exhumed/src/set.cpp index 7d4f48a94..1f59ccdc1 100644 --- a/source/exhumed/src/set.cpp +++ b/source/exhumed/src/set.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxSets 10 +enum { kMaxSets = 10}; short SetCount = 0; diff --git a/source/exhumed/src/snake.cpp b/source/exhumed/src/snake.cpp index 2e8afceb8..57e0c019f 100644 --- a/source/exhumed/src/snake.cpp +++ b/source/exhumed/src/snake.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxSnakes 50 +enum { kMaxSnakes = 50 }; int nSnakeCount = 0; int nSnakesFree; diff --git a/source/exhumed/src/sound.h b/source/exhumed/src/sound.h index 6920c88db..e2507b1dd 100644 --- a/source/exhumed/src/sound.h +++ b/source/exhumed/src/sound.h @@ -22,14 +22,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxSoundFiles 80 -#define kMaxSounds 200 -#define kMaxSoundNameLen 8 -#define kMaxActiveSounds 8 - -#define kCreepyCount 150 - -#define MUSIC_ID (-65536) +enum +{ + kMaxSoundFiles = 80, + kMaxSounds = 200, + kMaxSoundNameLen = 8, + kMaxActiveSounds = 8, + kCreepyCount = 150, + MUSIC_ID = (-65536) +}; enum { kSound0 = 0, diff --git a/source/exhumed/src/spider.cpp b/source/exhumed/src/spider.cpp index a346ea7fa..757b8cbd9 100644 --- a/source/exhumed/src/spider.cpp +++ b/source/exhumed/src/spider.cpp @@ -27,7 +27,7 @@ BEGIN_PS_NS short SpiderCount = 0; -#define kMaxSpiders 100 +enum { kMaxSpiders = 100 }; struct Spider { diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 0c0f2da2b..f293f7153 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -59,7 +59,7 @@ short enemy; short nEnemyPal = 0; -#define MAXINTERPOLATIONS MAXSPRITES +enum { MAXINTERPOLATIONS = MAXSPRITES }; int32_t g_interpolationCnt; int32_t oldipos[MAXINTERPOLATIONS]; int32_t* curipos[MAXINTERPOLATIONS]; diff --git a/source/exhumed/src/wasp.cpp b/source/exhumed/src/wasp.cpp index 0eae08078..ac4b30426 100644 --- a/source/exhumed/src/wasp.cpp +++ b/source/exhumed/src/wasp.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -#define kMaxWasps 100 +enum { kMaxWasps = 100 }; static short nWaspVelShift = 0; short nWaspCount;