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

* much better callback function declaration (previous version inspired me to write a new coding guideline)

This commit is contained in:
mateuszb 2012-11-14 21:19:32 +00:00
parent 13a5a820d0
commit 100dad889a
4 changed files with 11 additions and 6 deletions

View File

@ -1889,7 +1889,7 @@ void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int
* @return int3(-1, -1, -1) if the tile is unguarded, or the position of
* the monster guarding the tile.
*/
const std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
{
std::vector<CGObjectInstance*> guards;
const int3 originalPos = pos;

View File

@ -423,7 +423,7 @@ public:
bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret); //calculates path between src and dest; returns pointer to newly allocated CPath or NULL if path does not exists
void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or NULL if path does not exists
int3 guardingCreaturePosition (int3 pos) const;
const std::vector<CGObjectInstance*> guardingCreatures (int3 pos) const;
std::vector<CGObjectInstance*> guardingCreatures (int3 pos) const;
int victoryCheck(ui8 player) const; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else
int lossCheck(ui8 player) const; //checks if given player is loser; -1 if std loss, 1 if special, 0 else
ui8 checkForStandardWin() const; //returns color of player that accomplished standard victory conditions or 255 if no winner

View File

@ -386,10 +386,15 @@ int3 CGameInfoCallback::guardingCreaturePosition (int3 pos) const
return gs->guardingCreaturePosition(pos);
}
const std::vector<CGObjectInstance*> CGameInfoCallback::getGuardingCreatures (int3 pos) const
std::vector<const CGObjectInstance*> CGameInfoCallback::getGuardingCreatures (int3 pos) const
{
ERROR_RET_VAL_IF(!isVisible(pos), "Tile is not visible!", std::vector<CGObjectInstance*>());
return gs->guardingCreatures (pos);
ERROR_RET_VAL_IF(!isVisible(pos), "Tile is not visible!", std::vector<const CGObjectInstance*>());
std::vector<const CGObjectInstance*> ret;
BOOST_FOREACH(auto cr, gs->guardingCreatures(pos))
{
ret.push_back(cr);
}
return ret;
}
bool CGameInfoCallback::getHeroInfo( const CGObjectInstance *hero, InfoAboutHero &dest ) const

View File

@ -116,7 +116,7 @@ public:
//map
int3 guardingCreaturePosition (int3 pos) const;
const std::vector<CGObjectInstance*> getGuardingCreatures (int3 pos) const;
std::vector<const CGObjectInstance*> getGuardingCreatures (int3 pos) const;
const CMapHeader * getMapHeader()const;
int3 getMapSize() const; //returns size of map - z is 1 for one - level map and 2 for two level map
const TerrainTile * getTile(int3 tile, bool verbose = true) const;