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

* refactoring

* fixed bug 1143
* some work on campaigns
This commit is contained in:
mateuszb 2013-02-05 18:48:46 +00:00
parent f8d7473f9a
commit bda92a4a73
7 changed files with 14 additions and 25 deletions

View File

@ -264,11 +264,6 @@ void CCallback::recruitHero(const CGObjectInstance *townOrTavern, const CGHeroIn
}
}
bool CCallback::getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret)
{
return gs->getPath(src,dest,hero, ret);
}
void CCallback::save( const std::string &fname )
{
cl->save(fname);

View File

@ -104,7 +104,6 @@ public:
CCallback(CGameState * GS, int Player, CClient *C);
//client-specific functionalities (pathfinding)
virtual bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret); //DEPRACATED!!!
virtual const CGPathNode *getPathInfo(int3 tile); //uses main, client pathfinder info
virtual bool getPath2(int3 dest, CGPath &ret); //uses main, client pathfinder info

View File

@ -3583,7 +3583,8 @@ void CBonusSelection::selectBonus( int id )
{
// Total redraw is needed because the border around the bonus images
// have to be undrawn/drawn.
if (id != sInfo.campState->currentBonusID())
if (!vstd::contains(sInfo.campState->chosenCampaignBonuses, sInfo.campState->currentMap)
|| id != sInfo.campState->currentBonusID())
{
sInfo.campState->chosenCampaignBonuses[sInfo.campState->currentMap] = id;
GH.totalRedraw();

View File

@ -1131,7 +1131,9 @@ void CGameState::init(StartInfo * si)
}
if (!found)
{
//TODO: create new hero of this type
CGHeroInstance * nh = new CGHeroInstance();
nh->initHero(hp->subID);
replaceHero(g, nh);
}
}
}
@ -1156,7 +1158,7 @@ void CGameState::init(StartInfo * si)
if(Xheroes.size() > hp->power - 1)
replaceHero(g, Xheroes[hp->power - 1]);
else
tlog2 << "Warning, to hero to replace!\n";
tlog2 << "Warning, no hero to replace!\n";
//we don't have to remove hero from Xheroes because it would destroy the order and duplicates shouldn't happen
}
}
@ -1933,13 +1935,6 @@ void CGameState::apply(CPack *pack)
applierGs->apps[typ]->applyOnGS(this,pack);
}
bool CGameState::getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret)
{
//the old pathfinder is not supported anymore!
assert(0);
return false;
}
void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src, int movement)
{
CPathfinder pathfinder(out, this, hero);
@ -2052,9 +2047,9 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
return int3(-1, -1, -1);
}
bool CGameState::isVisible(int3 pos, int player)
bool CGameState::isVisible(int3 pos, TPlayerColor player)
{
if(player == 255) //neutral player
if(player == GameConstants::NEUTRAL_PLAYER)
return false;
return getPlayerTeam(player)->fogOfWarMap[pos.x][pos.y][pos.z];
}
@ -2064,7 +2059,7 @@ bool CGameState::isVisible( const CGObjectInstance *obj, int player )
if(player == -1)
return true;
if(player == 255) //neutral player -> TODO ??? needed?
if(player == GameConstants::NEUTRAL_PLAYER) //-> TODO ??? needed?
return false;
//object is visible when at least one blocked tile is visible
for(int fx=0; fx<8; ++fx)

View File

@ -421,7 +421,6 @@ public:
PlayerRelations::PlayerRelations getPlayerRelations(TPlayerColor color1, TPlayerColor color2);
bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile
bool checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst) const; //check if src tile is visitable from dst tile
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;
std::vector<CGObjectInstance*> guardingCreatures (int3 pos) const;
@ -438,7 +437,7 @@ public:
void buildGlobalTeamPlayerTree();
void deserializationFix();
bool isVisible(int3 pos, int player);
bool isVisible(int3 pos, TPlayerColor player);
bool isVisible(const CGObjectInstance *obj, int player);
CGameState(); //c-tor

View File

@ -890,12 +890,12 @@ TeamState *CNonConstInfoCallback::getTeam(ui8 teamID)
return const_cast<TeamState*>(CGameInfoCallback::getTeam(teamID));
}
TeamState *CNonConstInfoCallback::getPlayerTeam(ui8 color)
TeamState *CNonConstInfoCallback::getPlayerTeam(TPlayerColor color)
{
return const_cast<TeamState*>(CGameInfoCallback::getPlayerTeam(color));
}
PlayerState * CNonConstInfoCallback::getPlayer( ui8 color, bool verbose )
PlayerState * CNonConstInfoCallback::getPlayer( TPlayerColor color, bool verbose )
{
return const_cast<PlayerState*>(CGameInfoCallback::getPlayer(color, verbose));
}

View File

@ -181,9 +181,9 @@ public:
class DLL_LINKAGE CNonConstInfoCallback : public CPrivilagedInfoCallback
{
public:
PlayerState *getPlayer(ui8 color, bool verbose = true);
PlayerState *getPlayer(TPlayerColor color, bool verbose = true);
TeamState *getTeam(ui8 teamID);//get team by team ID
TeamState *getPlayerTeam(ui8 color);// get team by player color
TeamState *getPlayerTeam(TPlayerColor color);// get team by player color
CGHeroInstance *getHero(int objid);
CGTownInstance *getTown(int objid);
TerrainTile * getTile(int3 pos);