1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00

Fixed issue that allowed to build multiple boats in town. Renamed state() to sth more sensible.

This commit is contained in:
Michał W. Urbańczyk 2013-07-21 10:08:32 +00:00
parent e45d174ba5
commit e9d51a2670
7 changed files with 11 additions and 10 deletions

View File

@ -3771,7 +3771,7 @@ int3 SectorMap::firstTileToGet(HeroPtr h, crint3 dst)
shipyards.erase(boost::remove_if(shipyards, [=](const IShipyard *shipyard) -> bool
{
return shipyard->state() != 0 || retreiveTile(shipyard->bestLocation()) != sectorToReach->id;
return shipyard->shipyardStatus() != 0 || retreiveTile(shipyard->bestLocation()) != sectorToReach->id;
}),shipyards.end());
if(!shipyards.size())

View File

@ -604,7 +604,8 @@ void CCastleBuildings::buildingClicked(BuildingID building)
break;
case BuildingID::SHIPYARD:
LOCPLINT->showShipyardDialog(town);
if(town->shipyardStatus() == IBoatGenerator::GOOD)
LOCPLINT->showShipyardDialog(town);
break;
case BuildingID::FORT:

View File

@ -1497,7 +1497,7 @@ void CPlayerInterface::waitWhileDialog(bool unlockPim /*= true*/)
void CPlayerInterface::showShipyardDialog(const IShipyard *obj)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
auto state = obj->state();
auto state = obj->shipyardStatus();
std::vector<si32> cost;
obj->getBoatCost(cost);
CShipyardWindow *csw = new CShipyardWindow(cost, state, obj->getBoatType(), [=]{ cb->buildBoat(obj); });
@ -2316,7 +2316,7 @@ void CPlayerInterface::showQuestLog()
void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
{
if(obj->state() != IBoatGenerator::GOOD)
if(obj->shipyardStatus() != IBoatGenerator::GOOD)
{
MetaString txt;
obj->getProblemText(txt);

View File

@ -1347,7 +1347,7 @@ void CGameState::init(StartInfo * si)
vti->builtBuildings.insert(BuildingID::DWELL_LVL_2);
}
if (vstd::contains(vti->builtBuildings, BuildingID::SHIPYARD) && vti->state()==IBoatGenerator::TILE_BLOCKED)
if (vstd::contains(vti->builtBuildings, BuildingID::SHIPYARD) && vti->shipyardStatus()==IBoatGenerator::TILE_BLOCKED)
vti->builtBuildings.erase(BuildingID::SHIPYARD);//if we have harbor without water - erase it (this is H3 behaviour)
//init hordes

View File

@ -6744,7 +6744,7 @@ int3 IBoatGenerator::bestLocation() const
return int3 (-1,-1,-1);
}
IBoatGenerator::EGeneratorState IBoatGenerator::state() const
IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const
{
int3 tile = bestLocation();
const TerrainTile *t = IObjectInterface::cb->getTile(tile);
@ -6772,7 +6772,7 @@ IBoatGenerator::IBoatGenerator(const CGObjectInstance *O)
void IBoatGenerator::getProblemText(MetaString &out, const CGHeroInstance *visitor) const
{
switch(state())
switch(shipyardStatus())
{
case BOAT_ALREADY_BUILT:
out.addTxt(MetaString::GENERAL_TXT, 51);
@ -6848,7 +6848,7 @@ void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const
if(!cb->gameState()->getPlayerRelations(tempOwner, h->tempOwner))
cb->setOwner(this, h->tempOwner);
auto s = state();
auto s = shipyardStatus();
if(s != IBoatGenerator::GOOD)
{
InfoWindow iw;

View File

@ -140,7 +140,7 @@ public:
int3 bestLocation() const; //returns location when the boat should be placed
enum EGeneratorState {GOOD, BOAT_ALREADY_BUILT, TILE_BLOCKED, NO_WATER};
EGeneratorState state() const; //0 - can buid, 1 - there is already a boat at dest tile, 2 - dest tile is blocked, 3 - no water
EGeneratorState shipyardStatus() const; //0 - can buid, 1 - there is already a boat at dest tile, 2 - dest tile is blocked, 3 - no water
void getProblemText(MetaString &out, const CGHeroInstance *visitor = nullptr) const;
};

View File

@ -4931,7 +4931,7 @@ bool CGameHandler::buildBoat( ObjectInstanceID objid )
{
const IShipyard *obj = IShipyard::castFrom(getObj(objid));
if(obj->state() != IBoatGenerator::GOOD)
if(obj->shipyardStatus() != IBoatGenerator::GOOD)
{
complain("Cannot build boat in this shipyard!");
return false;