Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/engine/math_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ namespace fheroes2
return point.x >= x && point.y >= y && point.x < ( x + width ) && point.y < ( y + height );
}

// Check whether rectangles are intersecting each other
constexpr bool operator&( const RectBase2D & rect ) const
{
return x <= rect.x + rect.width && rect.x <= x + width && y <= rect.y + rect.height && rect.y <= y + height;
}

// Find intersection rectangle
constexpr RectBase2D operator^( const RectBase2D & rect ) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/battle/battle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ void Battle::Arena::ApplyActionCatapult( Command & cmd )
return false;
}

const std::vector<CastleDefenseStructure> & allowedTargets = Catapult::getAllowedTargets();
const std::vector<CastleDefenseStructure> allowedTargets = Catapult::getAllowedTargets();

if ( std::find( allowedTargets.begin(), allowedTargets.end(), target ) == allowedTargets.end() ) {
return false;
Expand Down
8 changes: 3 additions & 5 deletions src/fheroes2/battle/battle_catapult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ int Battle::Catapult::GetDamage( Rand::PCG32 & randomGenerator ) const
return 1;
}

const std::vector<Battle::CastleDefenseStructure> & Battle::Catapult::getAllowedTargets()
std::vector<Battle::CastleDefenseStructure> Battle::Catapult::getAllowedTargets()
{
static const std::vector<CastleDefenseStructure> allowedTargets{ CastleDefenseStructure::WALL1, CastleDefenseStructure::WALL2, CastleDefenseStructure::WALL3,
CastleDefenseStructure::WALL4, CastleDefenseStructure::TOWER1, CastleDefenseStructure::TOWER2,
CastleDefenseStructure::BRIDGE, CastleDefenseStructure::CENTRAL_TOWER };
return allowedTargets;
return { CastleDefenseStructure::WALL1, CastleDefenseStructure::WALL2, CastleDefenseStructure::WALL3, CastleDefenseStructure::WALL4,
CastleDefenseStructure::TOWER1, CastleDefenseStructure::TOWER2, CastleDefenseStructure::BRIDGE, CastleDefenseStructure::CENTRAL_TOWER };
}

fheroes2::Point Battle::Catapult::GetTargetPosition( const CastleDefenseStructure target, const bool hit )
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/battle/battle_catapult.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Battle

Catapult & operator=( const Catapult & ) = delete;

static const std::vector<CastleDefenseStructure> & getAllowedTargets();
static std::vector<CastleDefenseStructure> getAllowedTargets();
static CastleDefenseStructure GetTarget( const std::map<CastleDefenseStructure, int> & stateOfCatapultTargets, Rand::PCG32 & randomGenerator );
static fheroes2::Point GetTargetPosition( const CastleDefenseStructure target, const bool hit );

Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/editor/editor_secondary_skill_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace Editor
return false;
}

const std::vector<int32_t> & existingSkills = GameStatic::getSecondarySkillsForWitchsHut();
const std::vector<int32_t> existingSkills = GameStatic::getSecondarySkillsForWitchsHut();

// Create a container of active and disabled skills.
std::vector<std::pair<Skill::Secondary, bool>> skills;
Expand Down
10 changes: 4 additions & 6 deletions src/fheroes2/game/game_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,12 @@ const Skill::SecondarySkillValuesPerLevel * GameStatic::GetSecondarySkillValuesP
return nullptr;
}

const std::vector<int32_t> & GameStatic::getSecondarySkillsForWitchsHut()
std::vector<int32_t> GameStatic::getSecondarySkillsForWitchsHut()
{
// Every skill except Leadership and Necromancy.
static const std::vector<int32_t> skills{ Skill::Secondary::PATHFINDING, Skill::Secondary::ARCHERY, Skill::Secondary::LOGISTICS, Skill::Secondary::SCOUTING,
Skill::Secondary::DIPLOMACY, Skill::Secondary::NAVIGATION, Skill::Secondary::WISDOM, Skill::Secondary::MYSTICISM,
Skill::Secondary::LUCK, Skill::Secondary::BALLISTICS, Skill::Secondary::EAGLE_EYE, Skill::Secondary::ESTATES };

return skills;
return { Skill::Secondary::PATHFINDING, Skill::Secondary::ARCHERY, Skill::Secondary::LOGISTICS, Skill::Secondary::SCOUTING,
Skill::Secondary::DIPLOMACY, Skill::Secondary::NAVIGATION, Skill::Secondary::WISDOM, Skill::Secondary::MYSTICISM,
Skill::Secondary::LUCK, Skill::Secondary::BALLISTICS, Skill::Secondary::EAGLE_EYE, Skill::Secondary::ESTATES };
}

int GameStatic::GetBattleMoatReduceDefense()
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/game/game_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace GameStatic
const Skill::FactionProperties * GetFactionProperties( const int race );
const Skill::SecondarySkillValuesPerLevel * GetSecondarySkillValuesPerLevel( const int skill );

const std::vector<int32_t> & getSecondarySkillsForWitchsHut();
std::vector<int32_t> getSecondarySkillsForWitchsHut();

uint32_t getMovementPointBonus( const MP2::MapObjectType objectType );

Expand Down
8 changes: 0 additions & 8 deletions src/fheroes2/maps/maps_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,6 @@ namespace Maps

void ClearFog( const PlayerColorsSet colors );

// WARNING!
// Use this method only for map generation!
// This method does not reset pathfinding state.
void removeFogForPlayers( const PlayerColorsSet colors )
{
_fogColors &= ~colors;
}

const std::array<uint32_t, 3> & metadata() const
{
return _metadata;
Expand Down
40 changes: 1 addition & 39 deletions src/fheroes2/resource/resource.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***************************************************************************
* fheroes2: https://github.com/ihhub/fheroes2 *
* Copyright (C) 2019 - 2024 *
* Copyright (C) 2019 - 2025 *
* *
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 *
* Copyright (C) 2009 by Andrey Afletdinov <[email protected]> *
Expand Down Expand Up @@ -217,26 +217,6 @@ Funds Funds::operator-( const Funds & pm ) const
return res;
}

Funds Funds::operator/( const int32_t div ) const
{
if ( div == 0 ) {
assert( 0 );
return {};
}

Funds res;

res.wood = wood / div;
res.mercury = mercury / div;
res.ore = ore / div;
res.sulfur = sulfur / div;
res.crystal = crystal / div;
res.gems = gems / div;
res.gold = gold / div;

return res;
}

Funds & Funds::operator-=( const Funds & pm )
{
wood -= pm.wood;
Expand Down Expand Up @@ -315,24 +295,6 @@ Funds & Funds::operator*=( uint32_t mul )
return *this;
}

Funds & Funds::operator/=( const int32_t div )
{
if ( div == 0 ) {
assert( 0 );
return *this;
}

wood /= div;
mercury /= div;
ore /= div;
sulfur /= div;
crystal /= div;
gems /= div;
gold /= div;

return *this;
}

bool Funds::operator==( const Funds & other ) const
{
return std::tie( wood, mercury, ore, sulfur, crystal, gems, gold )
Expand Down
2 changes: 0 additions & 2 deletions src/fheroes2/resource/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ struct Funds
Funds operator+( const Funds & pm ) const;
Funds operator*( uint32_t mul ) const;
Funds operator-( const Funds & pm ) const;
Funds operator/( const int32_t div ) const;
Funds & operator+=( const Funds & pm );
Funds & operator*=( uint32_t mul );
Funds & operator/=( const int32_t div );
Funds & operator-=( const Funds & pm );
Funds & operator=( const Cost & cost );

Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/world/world_loadmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ bool World::loadResurrectionMap( const std::string & filename )
return false;
}

const std::vector<int32_t> & skills = GameStatic::getSecondarySkillsForWitchsHut();
const std::vector<int32_t> skills = GameStatic::getSecondarySkillsForWitchsHut();

return std::all_of( metadata.selectedItems.begin(), metadata.selectedItems.end(),
[&skills]( const int32_t skillId ) { return std::find( skills.begin(), skills.end(), skillId ) != skills.end(); } );
Expand Down
Loading