mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Fix sonar warnings, convert spaces -> tabs
This commit is contained in:
@ -48,8 +48,8 @@ CreditsScreen::CreditsScreen(Rect rect)
|
||||
size_t firstQuote = text.find('\"') + 1;
|
||||
text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote);
|
||||
|
||||
auto translateCredits = [&text](std::map<std::string, std::string> replacements){
|
||||
for(auto & item : replacements)
|
||||
const auto & translateCredits = [&text](const std::map<std::string, std::string> & replacements){
|
||||
for(const auto & item : replacements)
|
||||
boost::replace_first(text, "{" + item.second + ":}", "{" + LIBRARY->generaltexth->translate(item.first) + ":}");
|
||||
};
|
||||
translateCredits({
|
||||
|
@ -470,7 +470,7 @@ std::shared_ptr<CAnimation> MapRendererObjects::getOverlayAnimation(const CGObje
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<IImage> MapRendererObjects::getImageToRender(IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation>& animation) const
|
||||
std::shared_ptr<IImage> MapRendererObjects::getImageToRender(const IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation>& animation) const
|
||||
{
|
||||
if(!animation)
|
||||
return nullptr;
|
||||
|
@ -82,7 +82,7 @@ class MapRendererObjects
|
||||
std::shared_ptr<CAnimation> getAnimation(const AnimationPath & filename, bool generateMovementGroups, bool enableOverlay);
|
||||
std::shared_ptr<IImage> getImage(const ImagePath & filename) const;
|
||||
|
||||
std::shared_ptr<IImage> getImageToRender(IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation> & animation) const;
|
||||
std::shared_ptr<IImage> getImageToRender(const IMapRendererContext & context, const CGObjectInstance * obj, const std::shared_ptr<CAnimation> & animation) const;
|
||||
|
||||
void renderImage(IMapRendererContext & context, Canvas & target, const int3 & coordinates, const CGObjectInstance * object, const std::shared_ptr<IImage> & image);
|
||||
void renderObject(IMapRendererContext & context, Canvas & target, const int3 & coordinates, const CGObjectInstance * obj);
|
||||
|
@ -92,7 +92,7 @@ int MapRendererBaseContext::attackedMonsterDirection(const CGObjectInstance * wa
|
||||
if(wanderingMonster->ID != Obj::MONSTER)
|
||||
return -1;
|
||||
|
||||
for(auto & battle : GAME->interface()->cb->getActiveBattles())
|
||||
for(const auto & battle : GAME->interface()->cb->getActiveBattles())
|
||||
if(wanderingMonster->pos == battle.second->getBattle()->getLocation())
|
||||
return battle.second->getBattle()->getSideHero(BattleSide::ATTACKER)->moveDir;
|
||||
|
||||
|
@ -161,7 +161,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
|
||||
for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i)
|
||||
{
|
||||
bool isSmallBox = (secSkillSlider && i%2 == 1);
|
||||
Rect r = Rect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), isSmallBox ? 120 : 136, 42);
|
||||
Rect r(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), isSmallBox ? 120 : 136, 42);
|
||||
secSkills.emplace_back(std::make_shared<CSecSkillPlace>(r.topLeft(), CSecSkillPlace::ImageSize::MEDIUM));
|
||||
|
||||
int x = (i % 2) ? 212 : 68;
|
||||
|
@ -72,7 +72,7 @@ bool isLegacySpellSchool(SpellSchool school)
|
||||
return getAnimFrameFromSchool(school) != -1;
|
||||
}
|
||||
|
||||
CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner)
|
||||
CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, const std::function<void()> & funcL, int helpTextId, CSpellWindow * _owner)
|
||||
{
|
||||
addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
|
||||
pos = myRect;
|
||||
@ -82,7 +82,7 @@ CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, std::functio
|
||||
owner = _owner;
|
||||
}
|
||||
|
||||
CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, std::function<void()> funcL, std::string textId, CSpellWindow * _owner)
|
||||
CSpellWindow::InteractiveArea::InteractiveArea(const Rect & myRect, const std::function<void()> & funcL, std::string textId, CSpellWindow * _owner)
|
||||
{
|
||||
addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
|
||||
pos = myRect;
|
||||
@ -632,7 +632,7 @@ void CSpellWindow::keyPressed(EShortcut key)
|
||||
case EShortcut::MOVE_DOWN:
|
||||
{
|
||||
bool down = key == EShortcut::MOVE_DOWN;
|
||||
static const SpellSchool schoolsOrder[] = { SpellSchool::AIR, SpellSchool::EARTH, SpellSchool::FIRE, SpellSchool::WATER, SpellSchool::ANY };
|
||||
static const std::array schoolsOrder = { SpellSchool::AIR, SpellSchool::EARTH, SpellSchool::FIRE, SpellSchool::WATER, SpellSchool::ANY };
|
||||
int index = -1;
|
||||
while(schoolsOrder[++index] != selectedTab);
|
||||
index += (down ? 1 : -1);
|
||||
|
@ -66,8 +66,8 @@ class CSpellWindow : public CWindowObject, public IVideoHolder
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
void hover(bool on) override;
|
||||
|
||||
InteractiveArea(const Rect &myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);
|
||||
InteractiveArea(const Rect &myRect, std::function<void()> funcL, std::string textId, CSpellWindow * _owner);
|
||||
InteractiveArea(const Rect &myRect, const std::function<void()> & funcL, int helpTextId, CSpellWindow * _owner);
|
||||
InteractiveArea(const Rect &myRect, const std::function<void()> & funcL, std::string textId, CSpellWindow * _owner);
|
||||
};
|
||||
|
||||
std::shared_ptr<CPicture> leftCorner;
|
||||
|
@ -504,10 +504,10 @@ void CCreatureHandler::loadCommanders()
|
||||
++level;
|
||||
}
|
||||
|
||||
for (auto ability : config["abilityRequirements"].Vector())
|
||||
for (const auto & abilityRequirements : config["abilityRequirements"].Vector())
|
||||
{
|
||||
std::pair <std::vector<std::shared_ptr<Bonus> >, std::pair <ui8, ui8> > a;
|
||||
JsonNode & abilities = ability["ability"];
|
||||
const JsonNode & abilities = abilityRequirements["ability"];
|
||||
|
||||
if (abilities[0].isString()) // old format with single bonus
|
||||
{
|
||||
@ -519,8 +519,8 @@ void CCreatureHandler::loadCommanders()
|
||||
a.first.push_back(parseBonusWithCompatibility(ability));
|
||||
}
|
||||
|
||||
a.second.first = static_cast<ui8>(ability["skills"][0].Float());
|
||||
a.second.second = static_cast<ui8>(ability["skills"][1].Float());
|
||||
a.second.first = static_cast<ui8>(abilityRequirements["skills"][0].Float());
|
||||
a.second.second = static_cast<ui8>(abilityRequirements["skills"][1].Float());
|
||||
skillRequirements.push_back (a);
|
||||
}
|
||||
}
|
||||
|
@ -851,7 +851,7 @@ void CGameInfoCallback::getTilesInRange(std::unordered_set<int3> & tiles,
|
||||
}
|
||||
}
|
||||
|
||||
void CGameInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std::optional<PlayerColor> Player, int level, std::function<bool(const TerrainTile *)> filter) const
|
||||
void CGameInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std::optional<PlayerColor> Player, int level, const std::function<bool(const TerrainTile *)> & filter) const
|
||||
{
|
||||
if(Player.has_value() && !Player->isValidPlayer())
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
//used for random spawns
|
||||
void getFreeTiles(std::vector<int3> &tiles) const;
|
||||
void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player = std::optional<PlayerColor>(), int3::EDistanceFormula formula = int3::DIST_2D) const override;
|
||||
void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const override;
|
||||
void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter) const override;
|
||||
|
||||
void getAllowedSpells(std::vector<SpellID> &out, std::optional<ui16> level = std::nullopt) const;
|
||||
|
||||
|
@ -27,9 +27,9 @@ EditorCallback::EditorCallback(const CMap * map)
|
||||
: map(map)
|
||||
{}
|
||||
|
||||
void EditorCallback::setMap(const CMap * map)
|
||||
void EditorCallback::setMap(const CMap * newMap)
|
||||
{
|
||||
this->map = map;
|
||||
map = newMap;
|
||||
}
|
||||
|
||||
CGameState & EditorCallback::gameState()
|
||||
@ -97,7 +97,7 @@ void EditorCallback::getTilesInRange(std::unordered_set<int3> &, const int3 &, i
|
||||
THROW_EDITOR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
void EditorCallback::getAllTiles(std::unordered_set<int3> &, std::optional<PlayerColor>, int, std::function<bool(const TerrainTile *)>) const
|
||||
void EditorCallback::getAllTiles(std::unordered_set<int3> &, std::optional<PlayerColor>, int, const std::function<bool(const TerrainTile *)> &) const
|
||||
{
|
||||
THROW_EDITOR_UNSUPPORTED;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
std::vector<const CGObjectInstance*> getGuardingCreatures(int3 pos) const override;
|
||||
|
||||
void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player, int3::EDistanceFormula formula) const override;
|
||||
void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const override;
|
||||
void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter) const override;
|
||||
|
||||
std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const override;
|
||||
std::vector<ObjectInstanceID> getTeleportChannelEntrances(TeleportChannelID id, PlayerColor player) const override;
|
||||
|
@ -152,7 +152,7 @@ public:
|
||||
virtual void getTilesInRange(std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player = std::optional<PlayerColor>(), int3::EDistanceFormula formula = int3::DIST_2D) const = 0;
|
||||
|
||||
/// returns all tiles on given level (-1 - both levels, otherwise number of level)
|
||||
virtual void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const = 0;
|
||||
virtual void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter) const = 0;
|
||||
|
||||
virtual std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const = 0;
|
||||
virtual std::vector<ObjectInstanceID> getTeleportChannelEntrances(TeleportChannelID id, PlayerColor Player = PlayerColor::UNFLAGGABLE) const = 0;
|
||||
|
@ -332,15 +332,12 @@ ui64 CCreatureSet::getArmyStrength(int fortLevel) const
|
||||
for(const auto & elem : stacks)
|
||||
{
|
||||
ui64 powerToAdd = elem.second->getPower();
|
||||
if(fortLevel > 0)
|
||||
{
|
||||
if(!elem.second->hasBonusOfType(BonusType::FLYING))
|
||||
if(fortLevel > 0 && !elem.second->hasBonusOfType(BonusType::FLYING))
|
||||
{
|
||||
powerToAdd /= fortLevel;
|
||||
if(!elem.second->hasBonusOfType(BonusType::SHOOTER))
|
||||
powerToAdd /= fortLevel;
|
||||
}
|
||||
}
|
||||
ret += powerToAdd;
|
||||
}
|
||||
return ret;
|
||||
@ -365,12 +362,12 @@ std::string CCreatureSet::getRoughAmount(const SlotID & slot, int mode) const
|
||||
/// "Pack" - 0, "A pack of" - 1, "a pack of" - 2
|
||||
CCreature::CreatureQuantityId quantity = CCreature::getQuantityID(getStackCount(slot));
|
||||
|
||||
if((int)quantity)
|
||||
if(static_cast<int>(quantity) != 0)
|
||||
{
|
||||
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||
return CCreature::getQuantityRangeStringForId(quantity);
|
||||
|
||||
return LIBRARY->generaltexth->arraytxt[(174 + mode) + 3 * (int)quantity];
|
||||
return LIBRARY->generaltexth->arraytxt[(174 + mode) + 3 * static_cast<int>(quantity)];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -546,7 +543,6 @@ std::unique_ptr<CStackInstance> CCreatureSet::detachStack(const SlotID & slot)
|
||||
assert(hasStackAtSlot(slot));
|
||||
std::unique_ptr<CStackInstance> ret = std::move(stacks[slot]);
|
||||
|
||||
//if(CArmedInstance *armedObj = castToArmyObj())
|
||||
if(ret)
|
||||
{
|
||||
ret->setArmy(nullptr); //detaches from current armyobj
|
||||
|
@ -202,12 +202,12 @@ std::string CStackInstance::getQuantityTXT(bool capitalized) const
|
||||
{
|
||||
CCreature::CreatureQuantityId quantity = getQuantityID();
|
||||
|
||||
if((int)quantity)
|
||||
if(static_cast<int>(quantity))
|
||||
{
|
||||
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||
return CCreature::getQuantityRangeStringForId(quantity);
|
||||
|
||||
return LIBRARY->generaltexth->arraytxt[174 + (int)quantity * 3 - 1 - capitalized];
|
||||
return LIBRARY->generaltexth->arraytxt[174 + static_cast<int>(quantity) * 3 - 1 - capitalized];
|
||||
}
|
||||
else
|
||||
return "";
|
||||
|
@ -55,15 +55,6 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
template<typename Serializer>
|
||||
void registerTypes(Serializer &s)
|
||||
{
|
||||
static_assert(std::is_abstract_v<IObjectInterface>, "If this type is no longer abstract consider registering it for serialization with ID 1");
|
||||
static_assert(std::is_abstract_v<CGTeleport>, "If this type is no longer abstract consider registering it for serialization with ID 3");
|
||||
static_assert(std::is_abstract_v<IQuestObject>, "If this type is no longer abstract consider registering it for serialization with ID 11");
|
||||
static_assert(std::is_abstract_v<CArtifactSet>, "If this type is no longer abstract consider registering it for serialization with ID 29");
|
||||
// static_assert(std::is_abstract_v<CPackForClient>, "If this type is no longer abstract consider registering it for serialization with ID 83");
|
||||
// static_assert(std::is_abstract_v<Query>, "If this type is no longer abstract consider registering it for serialization with ID 153");
|
||||
// static_assert(std::is_abstract_v<CGarrisonOperationPack>, "If this type is no longer abstract consider registering it for serialization with ID 161");
|
||||
// static_assert(std::is_abstract_v<CArtifactOperationPack>, "If this type is no longer abstract consider registering it for serialization with ID 168");
|
||||
|
||||
s.template registerType<CGObjectInstance>(2);
|
||||
s.template registerType<CGMonolith>(4);
|
||||
s.template registerType<CGSubterraneanGate>(5);
|
||||
@ -86,7 +77,6 @@ void registerTypes(Serializer &s)
|
||||
s.template registerType<CGUniversity>(23);
|
||||
s.template registerType<CGHeroPlaceholder>(24);
|
||||
s.template registerType<CArmedInstance>(25);
|
||||
// s.template registerType<CBonusSystemNode>(26);
|
||||
s.template registerType<CCreatureSet>(27);
|
||||
s.template registerType<CGHeroInstance>(28);
|
||||
s.template registerType<CGDwelling>(30);
|
||||
|
@ -145,7 +145,7 @@ void Helper::saveTemplate(std::map<std::string, std::shared_ptr<CRmgTemplate>> t
|
||||
}
|
||||
|
||||
auto byteData = JsonNode(data).toBytes();
|
||||
QByteArray byteDataArray = QByteArray(reinterpret_cast<const char*>(byteData.data()), static_cast<int>(byteData.size()));
|
||||
QByteArray byteDataArray(reinterpret_cast<const char*>(byteData.data()), static_cast<int>(byteData.size()));
|
||||
QFile file(filename);
|
||||
|
||||
if(file.open(QIODevice::WriteOnly))
|
||||
|
@ -22,8 +22,10 @@ bool GeometryAlgorithm::edgesIntersect(const Node& a, const Node& b, const Node&
|
||||
return x1 * y2 - y1 * x2;
|
||||
};
|
||||
|
||||
double dx1 = b.x - a.x, dy1 = b.y - a.y;
|
||||
double dx2 = d.x - c.x, dy2 = d.y - c.y;
|
||||
double dx1 = b.x - a.x;
|
||||
double dy1 = b.y - a.y;
|
||||
double dx2 = d.x - c.x;
|
||||
double dy2 = d.y - c.y;
|
||||
|
||||
double delta = cross(dx1, dy1, dx2, dy2);
|
||||
if (std::abs(delta) < 1e-10) return false; // Parallel
|
||||
|
@ -9,21 +9,22 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../StdInc.h"
|
||||
|
||||
class GeometryAlgorithm
|
||||
{
|
||||
public:
|
||||
struct Node
|
||||
{
|
||||
double x, y;
|
||||
double dx = 0, dy = 0;
|
||||
double x;
|
||||
double y;
|
||||
double dx = 0;
|
||||
double dy = 0;
|
||||
int id;
|
||||
};
|
||||
|
||||
struct Edge
|
||||
{
|
||||
int from, to;
|
||||
int from;
|
||||
int to;
|
||||
};
|
||||
|
||||
static double distance(double x1, double y1, double x2, double y2);
|
||||
|
@ -235,29 +235,27 @@ int BonusBearerProxy::getBonuses(lua_State * L)
|
||||
TConstBonusListPtr ret;
|
||||
|
||||
const bool hasSelector = S.isFunction(2);
|
||||
const bool hasRangeSelector = S.isFunction(3);
|
||||
//const bool hasRangeSelector = S.isFunction(3);
|
||||
|
||||
if(hasSelector)
|
||||
{
|
||||
auto selector = [](const Bonus * b)
|
||||
{
|
||||
return false; //TODO: BonusBearerProxy::getBonuses selector
|
||||
};
|
||||
|
||||
if(hasRangeSelector)
|
||||
{
|
||||
//TODO: BonusBearerProxy::getBonuses rangeSelector
|
||||
//if(hasRangeSelector)
|
||||
//{
|
||||
// //TODO: BonusBearerProxy::getBonuses rangeSelector
|
||||
// auto rangeSelector = [](const Bonus * b)
|
||||
// {
|
||||
// return false;
|
||||
// };
|
||||
|
||||
ret = object->getBonuses(selector);
|
||||
}
|
||||
else
|
||||
// ret = object->getBonuses(rangeSelector);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
auto selector = [](const Bonus * b)
|
||||
{
|
||||
return false; //TODO: BonusBearerProxy::getBonuses selector
|
||||
};
|
||||
ret = object->getBonuses(selector);
|
||||
}
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
MOCK_CONST_METHOD2(getTileDigStatus, EDiggingStatus(int3 tile, bool verbose));
|
||||
MOCK_CONST_METHOD1(calculatePaths, void(const std::shared_ptr<PathfinderConfig> & config));
|
||||
MOCK_CONST_METHOD6(getTilesInRange, void( std::unordered_set<int3> & tiles, const int3 & pos, int radius, ETileVisibility mode, std::optional<PlayerColor> player, int3::EDistanceFormula formula));
|
||||
MOCK_CONST_METHOD4(getAllTiles, void(std::unordered_set<int3> & tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter));
|
||||
MOCK_CONST_METHOD4(getAllTiles, void(std::unordered_set<int3> & tiles, std::optional<PlayerColor> player, int level, const std::function<bool(const TerrainTile *)> & filter));
|
||||
MOCK_CONST_METHOD2(getVisibleTeleportObjects, std::vector<ObjectInstanceID>(std::vector<ObjectInstanceID> ids, PlayerColor player));
|
||||
MOCK_CONST_METHOD2(getTeleportChannelEntrances, std::vector<ObjectInstanceID>(TeleportChannelID id, PlayerColor Player));
|
||||
MOCK_CONST_METHOD2(getTeleportChannelExits, std::vector<ObjectInstanceID>(TeleportChannelID id, PlayerColor Player));
|
||||
|
Reference in New Issue
Block a user