diff --git a/src/editor/editloop.cpp b/src/editor/editloop.cpp index 1ee42d0e67..5c26eda303 100644 --- a/src/editor/editloop.cpp +++ b/src/editor/editloop.cpp @@ -109,11 +109,11 @@ enum class EditorActionType { }; enum EditorOverlays { - cNone, - cUnpassable, - cNoBuildingAllowed, - cElevation, - cOpaque + NoOverlays, + Unpassable, + NoBuildingAllowed, + Elevation, + Opaque }; struct EditorAction { EditorActionType Type; @@ -851,7 +851,7 @@ static void DrawIntoButtonArea() static void DrawInfoHighlightedOverlay() { - if (overlaysDropdown->getSelected() == EditorOverlays::cElevation) { + if (overlaysDropdown->getSelected() == EditorOverlays::Elevation) { CLabel(GetGameFont()) .Draw(overlaysDropdown->getX() + overlaysDropdown->getWidth() + 5, 2, @@ -1548,13 +1548,13 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar) } break; case ']': /// Increace highlighted elevation level - if (overlaysDropdown->getSelected() == EditorOverlays::cElevation + if (overlaysDropdown->getSelected() == EditorOverlays::Elevation && Editor.HighlightElevationLevel < 255) { Editor.HighlightElevationLevel++; } break; case '[': /// Decreace highlighted elevation level - if (overlaysDropdown->getSelected() == EditorOverlays::cElevation + if (overlaysDropdown->getSelected() == EditorOverlays::Elevation && Editor.HighlightElevationLevel > 0) { Editor.HighlightElevationLevel--; } @@ -2153,20 +2153,20 @@ void EditorMainLoop() auto overlaysDropdownListener = std::make_unique([&overlaysListStrings](const std::string&) { const int selected = overlaysDropdown->getSelected(); switch (selected) { - case EditorOverlays::cNone: + case EditorOverlays::NoOverlays: Editor.OverlayHighlighter = nullptr; return; - case EditorOverlays::cUnpassable: + case EditorOverlays::Unpassable: Editor.OverlayHighlighter = OverlayUnpassable; return; - case EditorOverlays::cNoBuildingAllowed: + case EditorOverlays::NoBuildingAllowed: Editor.OverlayHighlighter = OverlayNoBuildingAllowed; return; - case EditorOverlays::cElevation: + case EditorOverlays::Elevation: Editor.HighlightElevationLevel = 1; Editor.OverlayHighlighter = OverlayElevation; return; - case EditorOverlays::cOpaque: + case EditorOverlays::Opaque: Editor.OverlayHighlighter = OverlayOpaque; return; default: diff --git a/src/game/replay.cpp b/src/game/replay.cpp index ae8a8b0512..8ad93426d3 100644 --- a/src/game/replay.cpp +++ b/src/game/replay.cpp @@ -570,7 +570,7 @@ static int CclReplayLog(lua_State *l) */ bool IsReplayGame() { - return ReplayGameType != EReplayType::None; + return ReplayGameType != EReplayType::NoReplay; } /** @@ -632,7 +632,7 @@ void CleanReplayLog() // } GameObserve = false; NetPlayers = 0; - ReplayGameType = EReplayType::None; + ReplayGameType = EReplayType::NoReplay; } /** diff --git a/src/include/missile.h b/src/include/missile.h index 22274514ce..3740447802 100644 --- a/src/include/missile.h +++ b/src/include/missile.h @@ -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 ** @@ -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 @@ -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 diff --git a/src/include/replay.h b/src/include/replay.h index 4d2a2b7205..d651487789 100644 --- a/src/include/replay.h +++ b/src/include/replay.h @@ -42,7 +42,7 @@ ----------------------------------------------------------------------------*/ enum class EReplayType { - None, /// No replay + NoReplay, /// No replay SinglePlayer, /// Single player replay MultiPlayer /// Multi player replay }; /// Replay types diff --git a/src/include/tileset.h b/src/include/tileset.h index b0625c46cc..e501f3fafd 100644 --- a/src/include/tileset.h +++ b/src/include/tileset.h @@ -372,11 +372,11 @@ class CTilesetGraphicGenerator return image; } private: - enum class SrcImageOption { cNone = 0, cBaseGraphics = 1, cNewGraphics = 2 }; + enum class ESrcImageOption { NoGraphics = 0, BaseGraphics = 1, NewGraphics = 2 }; private: uint16_t checkForLayers(lua_State *luaStack) const; - std::vector parseSrcRange(lua_State *luaStack, SrcImageOption &isImg) const; + std::vector parseSrcRange(lua_State *luaStack, ESrcImageOption &isImg) const; auto parseLayer(lua_State *luaStack, const bool isSingleLayer = false) const; std::set parseArgsAsColors(lua_State *luaStack, const int firstArgPos = 2) const; uint32_t getPixel(const void *const pixel, const uint8_t bpp) const; diff --git a/src/include/unittype.h b/src/include/unittype.h index ed9a472472..34213b2e06 100644 --- a/src/include/unittype.h +++ b/src/include/unittype.h @@ -60,9 +60,6 @@ #include #include -// Fix problems with defined None in X.h included though SDL.h -#undef None - /*---------------------------------------------------------------------------- -- Declarations ----------------------------------------------------------------------------*/ @@ -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 @@ -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 @@ -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 diff --git a/src/map/script_tileset.cpp b/src/map/script_tileset.cpp index 4e851d91dd..a5516ab57a 100644 --- a/src/map/script_tileset.cpp +++ b/src/map/script_tileset.cpp @@ -769,28 +769,29 @@ uint16_t CTilesetGraphicGenerator::checkForLayers(lua_State *luaStack) const ** @param isImg if 'img' tag is exist then it will be setted by this function to true, false otherwise ** @return vector of parsed indexes **/ -std::vector CTilesetGraphicGenerator::parseSrcRange(lua_State *luaStack, SrcImageOption &isImg) const +std::vector CTilesetGraphicGenerator::parseSrcRange(lua_State *luaStack, ESrcImageOption &isImg) const { - isImg = SrcImageOption::cNone; + isImg = ESrcImageOption::NoGraphics; if (lua_istable(luaStack, -1)) { - - lua_rawgeti(luaStack, -1, 1); /// #1< + lua_rawgeti(luaStack, -1, 1); /// #1< /// check if "img"/"img-base" tag is present if (lua_isstring_strict(luaStack, -1)) { - const std::string parsingValue { LuaToString(luaStack, -1) }; + const auto parsingValue = LuaToString(luaStack, -1); if (parsingValue == "img") { - isImg = SrcImageOption::cNewGraphics; + isImg = ESrcImageOption::NewGraphics; } else if (parsingValue == "img-base") { - isImg = SrcImageOption::cBaseGraphics; + isImg = ESrcImageOption::BaseGraphics; + } else { + ErrorPrint("Unknown tag '%s'", parsingValue.data()); } } - lua_pop(luaStack, 1); /// #1> + lua_pop(luaStack, 1); /// #1> } else if (!lua_isnumber(luaStack, -1)) { LuaError(luaStack, "incorrect argument"); } - return { CTilesetParser::parseTilesRange(luaStack, isImg != SrcImageOption::cNone ? 2 : 1) }; + return { CTilesetParser::parseTilesRange(luaStack, isImg != ESrcImageOption::NoGraphics ? 2 : 1) }; } /** @@ -822,36 +823,32 @@ auto CTilesetGraphicGenerator::parseLayer(lua_State *luaStack, const bool isSing } } - SrcImageOption isImg = SrcImageOption::cNone; + ESrcImageOption isImg = ESrcImageOption::NoGraphics; std::vector srcIndexes { parseSrcRange(luaStack, isImg) }; if (needToPopSrcBack) { lua_pop(luaStack, 1); /// #1> } - const bool isUntouchedSrcGraphicsOnly = (isSingleLayer /* there is an only layer */ - && isImg != SrcImageOption::cNewGraphics /* this leyer consist of indexes of base graphics */ - && !withModifier) /* there are no any modifiers */ - ? true - : false; + const bool isUntouchedSrcGraphicsOnly = + isSingleLayer && isImg != ESrcImageOption::NewGraphics && !withModifier; std::vector parsedIndexes; sequence_of_images parsedImages; for (auto const srcIndex : srcIndexes) { - if (isImg == SrcImageOption::cNone + if (isImg == ESrcImageOption::NoGraphics && (srcIndex == 0 || SrcTileset->tiles[srcIndex].tile == 0)) { /// empty frame|separator parsedIndexes.push_back(0); continue; } const graphic_index frameIdx = - isImg != SrcImageOption::cNone ? srcIndex : SrcTileset->tiles[srcIndex].tile; + isImg != ESrcImageOption::NoGraphics ? srcIndex : SrcTileset->tiles[srcIndex].tile; if (isUntouchedSrcGraphicsOnly) { parsedIndexes.push_back(frameIdx); - } else { - const CGraphic *srcGraphic = isImg == SrcImageOption::cNewGraphics ? SrcImgGraphic - : SrcTilesetGraphic; + const CGraphic *srcGraphic = + isImg == ESrcImageOption::NewGraphics ? SrcImgGraphic : SrcTilesetGraphic; auto image { newBlankImage() }; srcGraphic->DrawFrame(frameIdx, 0, 0, image.get()); parsedImages.push_back(std::move(image)); diff --git a/src/missile/missile.cpp b/src/missile/missile.cpp index 13158ed7cd..008c2082ba 100644 --- a/src/missile/missile.cpp +++ b/src/missile/missile.cpp @@ -159,7 +159,7 @@ Missile::Init(const MissileType &mtype, const PixelPos &startPos, const PixelPos std::unique_ptr missile; switch (mtype.Class) { - case MissileClass::None: missile = std::make_unique(); break; + case MissileClass::Nothing: missile = std::make_unique(); break; case MissileClass::PointToPoint: missile = std::make_unique(); break; case MissileClass::PointToPointWithHit: missile = std::make_unique(); break; case MissileClass::PointToPointCycleOnce: missile = std::make_unique(); break; @@ -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 diff --git a/src/missile/script_missile.cpp b/src/missile/script_missile.cpp index e45c8f05a3..6921b60f21 100644 --- a/src/missile/script_missile.cpp +++ b/src/missile/script_missile.cpp @@ -63,7 +63,7 @@ static const std::map 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}, diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index e2a9e1ab95..dbd1bd581a 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -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]); } diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp index 0ad6f11474..986ce2adda 100644 --- a/src/unit/script_unittype.cpp +++ b/src/unit/script_unittype.cpp @@ -385,7 +385,7 @@ static void UpdateDefaultBoolFlags(CUnitType &type) static std::optional 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") { diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index 100006511e..15d7824d0d 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -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; }