mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
Converted attributes to use c++17 functionality
This commit is contained in:
parent
2150eabfc5
commit
63b197b78a
@ -136,7 +136,7 @@ ui64 FuzzyHelper::evaluateDanger(const CGObjectInstance * obj)
|
|||||||
{
|
{
|
||||||
if(!vstd::contains(ai->memory->alreadyVisited, obj))
|
if(!vstd::contains(ai->memory->alreadyVisited, obj))
|
||||||
return 0;
|
return 0;
|
||||||
FALLTHROUGH;
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
case Obj::MONSTER:
|
case Obj::MONSTER:
|
||||||
case Obj::HERO:
|
case Obj::HERO:
|
||||||
|
20
Global.h
20
Global.h
@ -71,22 +71,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
|
|||||||
#define VCMI_MOBILE
|
#define VCMI_MOBILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Each compiler uses own way to supress fall through warning. Try to find it.
|
|
||||||
// TODO: replace with c++17 [[fallthrough]]
|
|
||||||
#ifdef __has_cpp_attribute
|
|
||||||
# if __has_cpp_attribute(fallthrough)
|
|
||||||
# define FALLTHROUGH [[fallthrough]];
|
|
||||||
# elif __has_cpp_attribute(gnu::fallthrough)
|
|
||||||
# define FALLTHROUGH [[gnu::fallthrough]];
|
|
||||||
# elif __has_cpp_attribute(clang::fallthrough)
|
|
||||||
# define FALLTHROUGH [[clang::fallthrough]];
|
|
||||||
# else
|
|
||||||
# define FALLTHROUGH
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define FALLTHROUGH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
/* Commonly used C++, Boost headers */
|
/* Commonly used C++, Boost headers */
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
@ -256,10 +240,6 @@ using TLockGuardRec = std::lock_guard<std::recursive_mutex>;
|
|||||||
template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
|
template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
|
||||||
#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr)))
|
#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr)))
|
||||||
|
|
||||||
// should be used for variables that becomes unused in release builds (e.g. only used for assert checks)
|
|
||||||
// TODO: replace with c++17 [[maybe_unused]]
|
|
||||||
#define MAYBE_UNUSED(VAR) ((void)VAR)
|
|
||||||
|
|
||||||
// old iOS SDKs compatibility
|
// old iOS SDKs compatibility
|
||||||
#ifdef VCMI_IOS
|
#ifdef VCMI_IOS
|
||||||
#include <AvailabilityVersions.h>
|
#include <AvailabilityVersions.h>
|
||||||
|
@ -80,7 +80,6 @@ void CHeroSwitcher::clickLeft(tribool down, bool previousState)
|
|||||||
#if 0
|
#if 0
|
||||||
owner->update(hero, true);
|
owner->update(hero, true);
|
||||||
#else
|
#else
|
||||||
MAYBE_UNUSED(owner);
|
|
||||||
const CGHeroInstance * buf = hero;
|
const CGHeroInstance * buf = hero;
|
||||||
GH.popInts(1);
|
GH.popInts(1);
|
||||||
GH.pushIntT<CHeroWindow>(buf);
|
GH.pushIntT<CHeroWindow>(buf);
|
||||||
|
@ -65,7 +65,7 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, std::shared_ptr<IIn
|
|||||||
break;
|
break;
|
||||||
case POS_UP_DOWN:
|
case POS_UP_DOWN:
|
||||||
name = std::make_shared<CLabel>(pos.w/2, -12, font, ETextAlignment::CENTER, Colors::WHITE, data->getNameText());
|
name = std::make_shared<CLabel>(pos.w/2, -12, font, ETextAlignment::CENTER, Colors::WHITE, data->getNameText());
|
||||||
FALLTHROUGH;
|
[[fallthrough]];
|
||||||
case POS_DOWN:
|
case POS_DOWN:
|
||||||
value = std::make_shared<CLabel>(pos.w/2, pos.h+8, font, ETextAlignment::CENTER, Colors::WHITE, data->getValueText());
|
value = std::make_shared<CLabel>(pos.w/2, pos.h+8, font, ETextAlignment::CENTER, Colors::WHITE, data->getValueText());
|
||||||
break;
|
break;
|
||||||
|
@ -133,8 +133,7 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
|
|||||||
|
|
||||||
const auto screens = qGuiApp->screens();
|
const auto screens = qGuiApp->screens();
|
||||||
const auto currentScreen = screenIndex < screens.size() ? screens[screenIndex] : qGuiApp->primaryScreen();
|
const auto currentScreen = screenIndex < screens.size() ? screens[screenIndex] : qGuiApp->primaryScreen();
|
||||||
const auto screenSize = currentScreen->size();
|
[[maybe_unused]] const auto screenSize = currentScreen->size();
|
||||||
MAYBE_UNUSED(screenSize);
|
|
||||||
|
|
||||||
for(const auto & entry : resolutions)
|
for(const auto & entry : resolutions)
|
||||||
{
|
{
|
||||||
|
@ -514,10 +514,9 @@ void CCreatureSet::putStack(const SlotID & slot, CStackInstance * stack)
|
|||||||
|
|
||||||
void CCreatureSet::joinStack(const SlotID & slot, CStackInstance * stack)
|
void CCreatureSet::joinStack(const SlotID & slot, CStackInstance * stack)
|
||||||
{
|
{
|
||||||
const CCreature *c = getCreature(slot);
|
[[maybe_unused]] const CCreature *c = getCreature(slot);
|
||||||
assert(c == stack->type);
|
assert(c == stack->type);
|
||||||
assert(c);
|
assert(c);
|
||||||
MAYBE_UNUSED(c);
|
|
||||||
|
|
||||||
//TODO move stuff
|
//TODO move stuff
|
||||||
changeStackCount(slot, stack->count);
|
changeStackCount(slot, stack->count);
|
||||||
|
@ -1805,10 +1805,9 @@ void CGameState::initTowns()
|
|||||||
vti->builtBuildings.erase(BuildingID::SHIPYARD);//if we have harbor without water - erase it (this is H3 behaviour)
|
vti->builtBuildings.erase(BuildingID::SHIPYARD);//if we have harbor without water - erase it (this is H3 behaviour)
|
||||||
|
|
||||||
//Early check for #1444-like problems
|
//Early check for #1444-like problems
|
||||||
for(const auto & building : vti->builtBuildings)
|
for([[maybe_unused]] const auto & building : vti->builtBuildings)
|
||||||
{
|
{
|
||||||
assert(vti->getTown()->buildings.at(building) != nullptr);
|
assert(vti->getTown()->buildings.at(building) != nullptr);
|
||||||
MAYBE_UNUSED(building);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//town events
|
//town events
|
||||||
@ -2223,7 +2222,7 @@ void CGameState::updateRumor()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
rumor.type = RumorState::TYPE_RAND;
|
rumor.type = RumorState::TYPE_RAND;
|
||||||
FALLTHROUGH
|
[[fallthrough]];
|
||||||
|
|
||||||
case RumorState::TYPE_RAND:
|
case RumorState::TYPE_RAND:
|
||||||
auto vector = VLC->generaltexth->findStringsWithPrefix("core.randtvrn");
|
auto vector = VLC->generaltexth->findStringsWithPrefix("core.randtvrn");
|
||||||
|
@ -803,7 +803,7 @@ void DestinationActionRule::process(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// don't break - next case shared for both land and sail layers
|
/// don't break - next case shared for both land and sail layers
|
||||||
FALLTHROUGH
|
[[fallthrough]];
|
||||||
|
|
||||||
case EPathfindingLayer::SAIL:
|
case EPathfindingLayer::SAIL:
|
||||||
if(destination.isNodeObjectVisitable())
|
if(destination.isNodeObjectVisitable())
|
||||||
|
@ -296,7 +296,6 @@ std::vector<BattleHex> CStack::meleeAttackHexes(const battle::Unit * attacker, c
|
|||||||
res.push_back(otherDefenderPos);
|
res.push_back(otherDefenderPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MAYBE_UNUSED(mask);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1463,9 +1463,8 @@ void NewObject::applyGs(CGameState *gs)
|
|||||||
testObject.pos = pos;
|
testObject.pos = pos;
|
||||||
testObject.appearance = VLC->objtypeh->getHandlerFor(ID, subID)->getTemplates(ETerrainId::WATER).front();
|
testObject.appearance = VLC->objtypeh->getHandlerFor(ID, subID)->getTemplates(ETerrainId::WATER).front();
|
||||||
|
|
||||||
const int3 previousXAxisTile = int3(pos.x - 1, pos.y, pos.z);
|
[[maybe_unused]] const int3 previousXAxisTile = int3(pos.x - 1, pos.y, pos.z);
|
||||||
assert(gs->isInTheMap(previousXAxisTile) && (testObject.visitablePos() == previousXAxisTile));
|
assert(gs->isInTheMap(previousXAxisTile) && (testObject.visitablePos() == previousXAxisTile));
|
||||||
MAYBE_UNUSED(previousXAxisTile);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1689,10 +1688,9 @@ void RebalanceStacks::applyGs(CGameState * gs)
|
|||||||
|
|
||||||
if(srcCount == count) //moving whole stack
|
if(srcCount == count) //moving whole stack
|
||||||
{
|
{
|
||||||
if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> merge
|
if([[maybe_unused]] const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> merge
|
||||||
{
|
{
|
||||||
assert(c == srcType);
|
assert(c == srcType);
|
||||||
MAYBE_UNUSED(c);
|
|
||||||
auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT);
|
auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT);
|
||||||
auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT);
|
auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT);
|
||||||
auto * artHere = alHere.getArt();
|
auto * artHere = alHere.getArt();
|
||||||
@ -1744,10 +1742,9 @@ void RebalanceStacks::applyGs(CGameState * gs)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> rebalance
|
if([[maybe_unused]] const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> rebalance
|
||||||
{
|
{
|
||||||
assert(c == srcType);
|
assert(c == srcType);
|
||||||
MAYBE_UNUSED(c);
|
|
||||||
if (stackExp)
|
if (stackExp)
|
||||||
{
|
{
|
||||||
ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot);
|
ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot);
|
||||||
@ -1912,14 +1909,13 @@ void BulkMoveArtifacts::applyGs(CGameState * gs)
|
|||||||
void AssembledArtifact::applyGs(CGameState *gs)
|
void AssembledArtifact::applyGs(CGameState *gs)
|
||||||
{
|
{
|
||||||
CArtifactSet * artSet = al.getHolderArtSet();
|
CArtifactSet * artSet = al.getHolderArtSet();
|
||||||
const CArtifactInstance *transformedArt = al.getArt();
|
[[maybe_unused]] const CArtifactInstance *transformedArt = al.getArt();
|
||||||
assert(transformedArt);
|
assert(transformedArt);
|
||||||
bool combineEquipped = !ArtifactUtils::isSlotBackpack(al.slot);
|
bool combineEquipped = !ArtifactUtils::isSlotBackpack(al.slot);
|
||||||
assert(vstd::contains_if(transformedArt->assemblyPossibilities(artSet, combineEquipped), [=](const CArtifact * art)->bool
|
assert(vstd::contains_if(transformedArt->assemblyPossibilities(artSet, combineEquipped), [=](const CArtifact * art)->bool
|
||||||
{
|
{
|
||||||
return art->getId() == builtArt->getId();
|
return art->getId() == builtArt->getId();
|
||||||
}));
|
}));
|
||||||
MAYBE_UNUSED(transformedArt);
|
|
||||||
|
|
||||||
auto * combinedArt = new CCombinedArtifactInstance(builtArt);
|
auto * combinedArt = new CCombinedArtifactInstance(builtArt);
|
||||||
gs->map->addNewArtifactInstance(combinedArt);
|
gs->map->addNewArtifactInstance(combinedArt);
|
||||||
|
@ -38,9 +38,8 @@ public:
|
|||||||
std::unique_ptr<ui8[]> data(new ui8[getSize()]);
|
std::unique_ptr<ui8[]> data(new ui8[getSize()]);
|
||||||
|
|
||||||
seek(0);
|
seek(0);
|
||||||
auto readSize = read(data.get(), getSize());
|
[[maybe_unused]] auto readSize = read(data.get(), getSize());
|
||||||
assert(readSize == getSize());
|
assert(readSize == getSize());
|
||||||
MAYBE_UNUSED(readSize);
|
|
||||||
|
|
||||||
return std::make_pair(std::move(data), getSize());
|
return std::make_pair(std::move(data), getSize());
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,8 @@ void WaterProxy::process()
|
|||||||
paintZoneTerrain(zone, generator.rand, map, zone.getTerrainType());
|
paintZoneTerrain(zone, generator.rand, map, zone.getTerrainType());
|
||||||
|
|
||||||
//check terrain type
|
//check terrain type
|
||||||
for(const auto & t : zone.area().getTilesVector())
|
for([[maybe_unused]] const auto & t : zone.area().getTilesVector())
|
||||||
{
|
{
|
||||||
MAYBE_UNUSED(t);
|
|
||||||
assert(map.isOnMap(t));
|
assert(map.isOnMap(t));
|
||||||
assert(map.map().getTile(t).terType->getId() == zone.getTerrainType());
|
assert(map.map().getTile(t).terType->getId() == zone.getTerrainType());
|
||||||
}
|
}
|
||||||
|
@ -419,11 +419,10 @@ std::string MapSettings::getHeroName(int townObjectIdx)
|
|||||||
std::string MapSettings::getMonsterName(int monsterObjectIdx)
|
std::string MapSettings::getMonsterName(int monsterObjectIdx)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
if(auto monster = dynamic_cast<CGCreature*>(controller.map()->objects[monsterObjectIdx].get()))
|
if([[maybe_unused]] auto monster = dynamic_cast<CGCreature*>(controller.map()->objects[monsterObjectIdx].get()))
|
||||||
{
|
{
|
||||||
//TODO: get proper name
|
//TODO: get proper name
|
||||||
//name = hero->name;
|
//name = hero->name;
|
||||||
MAYBE_UNUSED(monster);
|
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -4643,7 +4643,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
|||||||
sendAndApply(&message);
|
sendAndApply(&message);
|
||||||
//don't break - we share code with next case
|
//don't break - we share code with next case
|
||||||
}
|
}
|
||||||
FALLTHROUGH
|
[[fallthrough]];
|
||||||
case EActionType::WAIT:
|
case EActionType::WAIT:
|
||||||
{
|
{
|
||||||
auto wrapper = wrapAction(ba);
|
auto wrapper = wrapAction(ba);
|
||||||
|
Loading…
Reference in New Issue
Block a user