1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Remove excess pointer from market interface

This commit is contained in:
nordsoft
2023-04-27 00:18:43 +04:00
committed by Nordsoft91
parent ac09f78c67
commit 59bc9326e9
10 changed files with 48 additions and 85 deletions

View File

@@ -149,9 +149,10 @@ TSubgoal CollectRes::whatToDoToTrade()
markets.erase(boost::remove_if(markets, [](const IMarket * market) -> bool
{
if (!(market->o->ID == Obj::TOWN && market->o->tempOwner == ai->playerID))
auto * o = dynamic_cast<const CGObjectInstance *>(market);
if(o && !(o->ID == Obj::TOWN && o->tempOwner == ai->playerID))
{
if (!ai->isAccessible(market->o->visitablePos()))
if(!ai->isAccessible(o->visitablePos()))
return true;
}
return false;
@@ -182,9 +183,10 @@ TSubgoal CollectRes::whatToDoToTrade()
if (howManyCanWeBuy >= value)
{
auto backObj = cb->getTopObj(m->o->visitablePos()); //it'll be a hero if we have one there; otherwise marketplace
auto * o = dynamic_cast<const CGObjectInstance *>(m);
auto backObj = cb->getTopObj(o->visitablePos()); //it'll be a hero if we have one there; otherwise marketplace
assert(backObj);
auto objid = m->o->id.getNum();
auto objid = o->id.getNum();
if (backObj->tempOwner != ai->playerID) //top object not owned
{
return sptr(VisitObj(objid)); //just go there