From 81f6899e72f184902e678ce6dd0931154d058e87 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Jan 2023 10:26:07 +0100 Subject: [PATCH] - C++20 constant fixes. Use of enums is deprecated in floating point calculations. --- source/games/blood/src/aiunicult.h | 4 +++- source/games/blood/src/nnexts.h | 7 ++++--- source/games/duke/src/constants.h | 10 ++++------ source/games/duke/src/player.cpp | 2 +- source/games/sw/src/game.h | 8 +++++--- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/games/blood/src/aiunicult.h b/source/games/blood/src/aiunicult.h index 89338235c..31d6d9727 100644 --- a/source/games/blood/src/aiunicult.h +++ b/source/games/blood/src/aiunicult.h @@ -36,11 +36,13 @@ enum kGenDudeTransformStatus = -222, kGenDudeUpdTimeRate = 10, kGenDudeMaxMeleeDist = 2048, - kGenDudeMaxMeleeDistf = 128, kGenDudeMinDispesion = 200, kGenDudeMaxDispersion = 3500, }; +constexpr double kGenDudeMaxMeleeDistf = 128; + + enum { kGenDudeSeqIdleL = 0, kGenDudeSeqDeathDefault = 1, diff --git a/source/games/blood/src/nnexts.h b/source/games/blood/src/nnexts.h index aa6ed8223..18bd1b578 100644 --- a/source/games/blood/src/nnexts.h +++ b/source/games/blood/src/nnexts.h @@ -67,14 +67,14 @@ enum kModernTypeFlag64 = 0x0040, kMaxRandomizeRetries = 16, - kPercFull = 100, kCondRange = 100, }; +constexpr int kPercFull = 100; + enum { kPatrolStateSize = 42, - kPatrolAlarmSeeDistSq = 625*625, kPatrolAlarmHearDist = 10000, kMaxPatrolSpotValue = 500, kMinPatrolTurnDelay = 8, @@ -83,7 +83,6 @@ enum kDudeFlagStealth = 0x0001, kDudeFlagCrouch = 0x0002, - kSlopeDist = 0x20, kEffectGenCallbackBase = 200, kTriggerSpriteScreen = 0x0001, kTriggerSpriteAim = 0x0002, @@ -92,6 +91,8 @@ enum kMaxAllowedPowerup = kMaxPowerUps }; +constexpr double kPatrolAlarmSeeDistSq = 625 * 625; +constexpr double kSlopeDist = 0x20; constexpr double kMaxPatrolVelocity = FixedToFloat(500000); // ~7.63 constexpr double kMaxPatrolCrouchVelocity = (kMaxPatrolVelocity / 2); diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 2169c3a2c..3b94d2bb1 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -4,12 +4,10 @@ // all game constants got collected here. -enum -{ - TICRATE = 120, - REALGAMETICSPERSEC = 30, // The number of game state updates per second: - TICSPERFRAME = (TICRATE/REALGAMETICSPERSEC) // (This used to be TICRATE/GAMETICSPERSEC, which was 120/26 = 4.615~ truncated to 4 by integer division.) -}; +constexpr int TICRATE = 120; +constexpr int REALGAMETICSPERSEC = 30; // The number of game state updates per second: +constexpr int TICSPERFRAME = (TICRATE / REALGAMETICSPERSEC); // (This used to be TICRATE/GAMETICSPERSEC, which was 120/26 = 4.615~ truncated to 4 by integer division.) + // tile names which are identical for all games. enum diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 3aabae408..68a975c05 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -228,7 +228,7 @@ double hitawall(player_struct* p, walltype** hitw) DDukeActor* aim(DDukeActor* actor, int abase) { - DAngle aang = DAngle90 * (AUTO_AIM_ANGLE / 512.); + DAngle aang = DAngle90 * (+AUTO_AIM_ANGLE / 512.); bool gotshrinker, gotfreezer; static const int aimstats[] = { STAT_PLAYER, STAT_DUMMYPLAYER, STAT_ACTOR, STAT_ZOMBIEACTOR }; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index c6f11ee87..11c6b024b 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1521,9 +1521,6 @@ extern int lockspeed; // Various scattered constants enum { - synctics = 3, - ACTORMOVETICS = (synctics << 1), - TICSPERMOVEMENT = synctics, ACTOR_GRAVITY = 8, // subtract value from clipdist on getzrange calls STAT_DAMAGE_LIST_SIZE = 20, @@ -1535,6 +1532,11 @@ enum }; +constexpr int synctics = 3; +constexpr int ACTORMOVETICS = (synctics << 1); +constexpr int TICSPERMOVEMENT = synctics; + + constexpr double GETZRANGE_CLIP_ADJ = 0.5;