1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed gcc/clang warnings

This commit is contained in:
Ivan Savenko 2015-12-04 01:06:02 +02:00
parent c2f4991e99
commit faa7cbff18
13 changed files with 41 additions and 33 deletions

View File

@ -154,7 +154,7 @@ void foreach_neighbour(const int3 &pos, std::function<void(const int3& pos)> foo
{
CCallback * cbp = cb.get(); // avoid costly retrieval of thread-specific pointer
for(const int3 &dir : dirs)
for(const int3 &dir : int3::getDirs())
{
const int3 n = pos + dir;
if(cbp->isInTheMap(n))
@ -164,7 +164,7 @@ void foreach_neighbour(const int3 &pos, std::function<void(const int3& pos)> foo
void foreach_neighbour(CCallback * cbp, const int3 &pos, std::function<void(CCallback * cbp, const int3& pos)> foo)
{
for(const int3 &dir : dirs)
for(const int3 &dir : int3::getDirs())
{
const int3 n = pos + dir;
if(cbp->isInTheMap(n))

View File

@ -1028,6 +1028,10 @@ TSubgoal GatherArmy::whatToDoToAchieve()
return fh->chooseSolution (getAllPossibleSubgoals()); //find dwelling. use current hero to prevent him from doing nothing.
}
static const BuildingID unitsSource[] = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3,
BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7};
TGoalVec GatherArmy::getAllPossibleSubgoals()
{
//get all possible towns, heroes and dwellings we may use

View File

@ -1303,6 +1303,20 @@ bool VCAI::tryBuildNextStructure(const CGTownInstance * t, std::vector<BuildingI
return false;//Nothing to build
}
//Set of buildings for different goals. Does not include any prerequisites.
static const BuildingID essential[] = {BuildingID::TAVERN, BuildingID::TOWN_HALL};
static const BuildingID goldSource[] = {BuildingID::TOWN_HALL, BuildingID::CITY_HALL, BuildingID::CAPITOL};
static const BuildingID unitsSource[] = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3,
BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7};
static const BuildingID unitsUpgrade[] = { BuildingID::DWELL_LVL_1_UP, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP,
BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP};
static const BuildingID unitGrowth[] = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::HORDE_1,
BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR};
static const BuildingID spells[] = {BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3,
BuildingID::MAGES_GUILD_4, BuildingID::MAGES_GUILD_5};
static const BuildingID extra[] = {BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3,
BuildingID::SPECIAL_4, BuildingID::SHIPYARD}; // all remaining buildings
void VCAI::buildStructure(const CGTownInstance * t)
{
//TODO make *real* town development system
@ -2467,7 +2481,7 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)
{
int3 ourPos = h->convertPosition(h->pos, false);
std::map<int3, int> dstToRevealedTiles;
for(crint3 dir : dirs)
for(crint3 dir : int3::getDirs())
if(cb->isInTheMap(hpos+dir))
if (ourPos != dir) //don't stand in place
if (isSafeToVisit(h, hpos + dir) && isAccessibleForHero (hpos + dir, h))

View File

@ -113,20 +113,6 @@ struct SectorMap
int3 findFirstVisitableTile(HeroPtr h, crint3 dst);
};
//Set of buildings for different goals. Does not include any prerequisites.
const BuildingID essential[] = {BuildingID::TAVERN, BuildingID::TOWN_HALL};
const BuildingID goldSource[] = {BuildingID::TOWN_HALL, BuildingID::CITY_HALL, BuildingID::CAPITOL};
const BuildingID unitsSource[] = { BuildingID::DWELL_LVL_1, BuildingID::DWELL_LVL_2, BuildingID::DWELL_LVL_3,
BuildingID::DWELL_LVL_4, BuildingID::DWELL_LVL_5, BuildingID::DWELL_LVL_6, BuildingID::DWELL_LVL_7};
const BuildingID unitsUpgrade[] = { BuildingID::DWELL_LVL_1_UP, BuildingID::DWELL_LVL_2_UP, BuildingID::DWELL_LVL_3_UP,
BuildingID::DWELL_LVL_4_UP, BuildingID::DWELL_LVL_5_UP, BuildingID::DWELL_LVL_6_UP, BuildingID::DWELL_LVL_7_UP};
const BuildingID unitGrowth[] = { BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::HORDE_1,
BuildingID::HORDE_1_UPGR, BuildingID::HORDE_2, BuildingID::HORDE_2_UPGR};
const BuildingID spells[] = {BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3,
BuildingID::MAGES_GUILD_4, BuildingID::MAGES_GUILD_5};
const BuildingID extra[] = {BuildingID::RESOURCE_SILO, BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3,
BuildingID::SPECIAL_4, BuildingID::SHIPYARD}; // all remaining buildings
class VCAI : public CAdventureAI
{
public:

View File

@ -52,7 +52,7 @@ public:
/// CModListContainer overrides
void resetRepositories() override;
void addRepository(QVariantMap data) override;
void modChanged(QString modID);
void modChanged(QString modID) override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;

View File

@ -467,7 +467,7 @@ static JsonNode loadModSettings(std::string path)
JsonNode addMeta(JsonNode config, std::string meta)
{
config.setMeta(meta);
return std::move(config);
return config;
}
CModInfo::CModInfo(std::string identifier,const JsonNode & local, const JsonNode & config):

View File

@ -131,6 +131,12 @@ public:
{
h & x & y & z;
}
static std::array<int3, 8> getDirs()
{
return { { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) } };
}
};
inline std::ostream & operator<<(std::ostream & str, const int3 & sth)
@ -154,9 +160,6 @@ struct ShashInt3
}
};
static const int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) };
template<typename Container>
int3 findClosestTile (Container & container, int3 dest)
{
@ -175,4 +178,4 @@ int3 findClosestTile (Container & container, int3 dest)
}
}
return result;
}
}

View File

@ -292,7 +292,7 @@ CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory(CBinaryReader & r
std::vector< std::vector<ui8> > CCampaignHandler::getFile(const std::string & name, bool headerOnly)
{
CCompressedStream stream(std::move(CResourceHandler::get()->load(ResourceID(name, EResType::CAMPAIGN))), true);
CCompressedStream stream(CResourceHandler::get()->load(ResourceID(name, EResType::CAMPAIGN)), true);
std::vector< std::vector<ui8> > ret;
do
@ -363,7 +363,7 @@ std::vector<CGHeroInstance *> CCampaignScenario::getLostCrossoverHeroes() const
}
}
}
return std::move(lostCrossoverHeroes);
return lostCrossoverHeroes;
}
bool CScenarioTravel::STravelBonus::isBonusForHero() const

View File

@ -20,7 +20,7 @@ std::unique_ptr<CMap> CMapService::loadMap(const std::string & name)
getMapPatcher(name)->patchMapHeader(header);
header.release();
return std::move(map);
return map;
}
std::unique_ptr<CMapHeader> CMapService::loadMapHeader(const std::string & name)
@ -28,7 +28,7 @@ std::unique_ptr<CMapHeader> CMapService::loadMapHeader(const std::string & name)
auto stream = getStreamFromFS(name);
std::unique_ptr<CMapHeader> header = getMapLoader(stream)->loadMapHeader();
getMapPatcher(name)->patchMapHeader(header);
return std::move(header);
return header;
}
std::unique_ptr<CMap> CMapService::loadMap(const ui8 * buffer, int size, const std::string & name)
@ -40,7 +40,7 @@ std::unique_ptr<CMap> CMapService::loadMap(const ui8 * buffer, int size, const s
getMapPatcher(name)->patchMapHeader(header);
header.release();
return std::move(map);
return map;
}
std::unique_ptr<CMapHeader> CMapService::loadMapHeader(const ui8 * buffer, int size, const std::string & name)
@ -48,7 +48,7 @@ std::unique_ptr<CMapHeader> CMapService::loadMapHeader(const ui8 * buffer, int s
auto stream = getStreamFromMem(buffer, size);
std::unique_ptr<CMapHeader> header = getMapLoader(stream)->loadMapHeader();
getMapPatcher(name)->patchMapHeader(header);
return std::move(header);
return header;
}
std::unique_ptr<CInputStream> CMapService::getStreamFromFS(const std::string & name)

View File

@ -17,7 +17,7 @@ static const int3 dirs4[] = {int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0)}
void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3& pos)> foo)
{
for(const int3 &dir : dirs)
for(const int3 &dir : int3::getDirs())
{
int3 n = pos + dir;
if(map->isInTheMap(n))

View File

@ -2336,7 +2336,8 @@ ObjectInfo CRmgTemplateZone::getRandomObject(CMapGenerator* gen, CTreasurePileIn
}
assert (0); //we should never be here
}
//FIXME: control reaches end of non-void function. Missing return?
return ObjectInfo(); // unreachable
}
void CRmgTemplateZone::addAllPossibleObjects(CMapGenerator* gen)

View File

@ -640,7 +640,7 @@ std::string CSpell::AnimationInfo::selectProjectile(const double angle) const
}
}
return std::move(res);
return res;
}
///CSpell::TargetInfo

View File

@ -1665,7 +1665,7 @@ std::list<PlayerColor> CGameHandler::generatePlayerTurnOrder() const
if(!player.second.human)
playerTurnOrder.push_back(player.first);
}
return std::move(playerTurnOrder);
return playerTurnOrder;
}
void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town )