Skip to content

Commit

Permalink
<X.h> (included though <SDL.h>) has #defines None :(
Browse files Browse the repository at this point in the history
Rename all our `None`.
  • Loading branch information
Jarod42 committed Nov 11, 2023
1 parent 05bbc3b commit a9a7b67
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/game/replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static int CclReplayLog(lua_State *l)
*/
bool IsReplayGame()
{
return ReplayGameType != EReplayType::None;
return ReplayGameType != EReplayType::NoReplay;
}

/**
Expand Down Expand Up @@ -632,7 +632,7 @@ void CleanReplayLog()
// }
GameObserve = false;
NetPlayers = 0;
ReplayGameType = EReplayType::None;
ReplayGameType = EReplayType::NoReplay;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/include/missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
**
** Class of the missile-type, defines the basic effects of the
** missile. Look at the different class identifiers for more
** information (::MissileClass::None, ...).
** information (::MissileClass::Nothing, ...).
**
** MissileType::NumBounces
**
Expand Down Expand Up @@ -323,7 +323,7 @@ class LuaCallback;
*/
enum class MissileClass
{
None, /// Missile does nothing
Nothing, /// Missile does nothing
PointToPoint, /// Missile flies from x,y to x1,y1
PointToPointWithHit, /// Missile flies from x,y to x1,y1 then shows hit animation.
PointToPointCycleOnce, /// Missile flies from x,y to x1,y1 and animates ONCE from start to finish and back
Expand Down Expand Up @@ -384,7 +384,7 @@ class MissileType
bool IgnoreWalls = true; /// missile ignores Wall units on it's way
bool KillFirstUnit = false; /// missile kills first unit blocking it's way

MissileClass Class = MissileClass::None; /// missile class
MissileClass Class = MissileClass::Nothing; /// missile class
int NumBounces = 0; /// number of bounces
int ParabolCoefficient = 2048; /// parabol coefficient in parabolic missile
int StartDelay = 0; /// missile start delay
Expand Down
2 changes: 1 addition & 1 deletion src/include/replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
----------------------------------------------------------------------------*/

enum class EReplayType {
None, /// No replay
NoReplay, /// No replay
SinglePlayer, /// Single player replay
MultiPlayer /// Multi player replay
}; /// Replay types
Expand Down
11 changes: 4 additions & 7 deletions src/include/unittype.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
#include <algorithm>
#include <map>

// Fix problems with defined None in X.h included though SDL.h
#undef None

/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -512,7 +509,7 @@ class CBuildRestrictionLuaCallback : public CBuildRestriction

enum class EMouseAction
{
None = 0, /// Nothing
NoAction = 0, /// Nothing
Attack = 1, /// Attack
Move = 2, /// Move
Harvest = 3, /// Harvest resources
Expand All @@ -522,7 +519,7 @@ enum class EMouseAction

enum class ECanTargetFlag
{
None = 0,
NulFlag = 0,
Land = 1, /// Can attack land units
Sea = 2, /// Can attack sea units
Air = 4, /// Can attack air units
Expand Down Expand Up @@ -659,9 +656,9 @@ class CUnitType
// TODO: not used
int AnnoyComputerFactor = 0; /// How much this annoys the computer
int AiAdjacentRange = -1; /// Min radius for AI build surroundings checking
EMouseAction MouseAction = EMouseAction::None; /// Right click action
EMouseAction MouseAction = EMouseAction::NoAction; /// Right click action
uint8_t RotationSpeed = 128; /// Max unit.Direction change per frame. 128 is maximum
ECanTargetFlag CanTarget = ECanTargetFlag::None; /// Which units can it attack
ECanTargetFlag CanTarget = ECanTargetFlag::NulFlag; /// Which units can it attack

bool Flip = false; /// Flip image when facing left
bool LandUnit = false; /// Land animated
Expand Down
4 changes: 2 additions & 2 deletions src/missile/missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Missile::Init(const MissileType &mtype, const PixelPos &startPos, const PixelPos
std::unique_ptr<Missile> missile;

switch (mtype.Class) {
case MissileClass::None: missile = std::make_unique<MissileNone>(); break;
case MissileClass::Nothing: missile = std::make_unique<MissileNone>(); break;
case MissileClass::PointToPoint: missile = std::make_unique<MissilePointToPoint>(); break;
case MissileClass::PointToPointWithHit: missile = std::make_unique<MissilePointToPointWithHit>(); break;
case MissileClass::PointToPointCycleOnce: missile = std::make_unique<MissilePointToPointCycleOnce>(); break;
Expand Down Expand Up @@ -318,7 +318,7 @@ void FireMissile(CUnit &unit, CUnit *goal, const Vec2i &goalPos)

// No missile hits immediately!
if (
unit.Type->Missile.Missile->Class == MissileClass::None
unit.Type->Missile.Missile->Class == MissileClass::Nothing
|| (unit.Type->Animations && unit.Type->Animations->Attack && unit.Type->Animations->RangedAttack && !unit.IsAttackRanged(goal, goalPos)) // treat melee attacks from units that have both attack and ranged attack animations as having missile class none
) {
// No goal, take target coordinates
Expand Down
2 changes: 1 addition & 1 deletion src/missile/script_missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static const std::map<std::string_view, MissileClass> MissileClassNames = {
{"missile-class-flame-shield", MissileClass::FlameShield},
{"missile-class-hit", MissileClass::Hit},
{"missile-class-land-mine", MissileClass::LandMine},
{"missile-class-none", MissileClass::None},
{"missile-class-none", MissileClass::Nothing},
{"missile-class-parabolic", MissileClass::Parabolic},
{"missile-class-point-to-point", MissileClass::PointToPoint},
{"missile-class-point-to-point-bounce", MissileClass::PointToPointBounce},
Expand Down
2 changes: 1 addition & 1 deletion src/ui/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ static void InputKey(int key)
#ifdef DEBUG
if (starts_with(Input, "ffw ")) {
#else
if (starts_with(Input, "ffw ") && ReplayGameType != EReplayType::None) {
if (starts_with(Input, "ffw ") && ReplayGameType != EReplayType::NoReplay) {
#endif
FastForwardCycle = atoi(&Input[4]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/unit/script_unittype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ static void UpdateDefaultBoolFlags(CUnitType &type)
static std::optional<EMouseAction> ToEMouseAction(std::string_view s)
{
if (s == "none") {
return EMouseAction::None;
return EMouseAction::NoAction;
} else if (s == "attack") {
return EMouseAction::Attack;
} else if (s == "move") {
Expand Down
8 changes: 4 additions & 4 deletions src/unit/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3260,17 +3260,17 @@ bool CanTarget(const CUnitType &source, const CUnitType &dest)
{
if (dest.BoolFlag[SHOREBUILDING_INDEX].value) {
return (source.CanTarget & (ECanTargetFlag::Land | ECanTargetFlag::Sea))
!= ECanTargetFlag::None;
!= ECanTargetFlag::NulFlag;
}
return (source.CanTarget & ECanTargetFlag::Land) != ECanTargetFlag::None;
return (source.CanTarget & ECanTargetFlag::Land) != ECanTargetFlag::NulFlag;
}
case EMovement::Fly:
{
return (source.CanTarget & ECanTargetFlag::Air) != ECanTargetFlag::None;
return (source.CanTarget & ECanTargetFlag::Air) != ECanTargetFlag::NulFlag;
}
case EMovement::Naval:
{
return (source.CanTarget & ECanTargetFlag::Sea) != ECanTargetFlag::None;
return (source.CanTarget & ECanTargetFlag::Sea) != ECanTargetFlag::NulFlag;
}
default: return 0;
}
Expand Down

0 comments on commit a9a7b67

Please sign in to comment.