mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fixed #541
This commit is contained in:
parent
2b899d5777
commit
221728c680
@ -26,23 +26,25 @@ CGameState *const IGameCallback::gameState ()
|
||||
{
|
||||
return gs;
|
||||
}
|
||||
const CGObjectInstance* IGameCallback::getObj(int objid)
|
||||
const CGObjectInstance* IGameCallback::getObj(int objid, bool verbose)
|
||||
{
|
||||
if(objid < 0 || objid >= gs->map->objects.size())
|
||||
{
|
||||
tlog1 << "Cannot get object with id " << objid << std::endl;
|
||||
if(verbose)
|
||||
tlog1 << "Cannot get object with id " << objid << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
else if (!gs->map->objects[objid])
|
||||
{
|
||||
tlog1 << "Cannot get object with id " << objid << ". Object was removed.\n";
|
||||
if(verbose)
|
||||
tlog1 << "Cannot get object with id " << objid << ". Object was removed.\n";
|
||||
return NULL;
|
||||
}
|
||||
return gs->map->objects[objid];
|
||||
}
|
||||
const CGHeroInstance* IGameCallback::getHero(int objid)
|
||||
{
|
||||
const CGObjectInstance *obj = getObj(objid);
|
||||
const CGObjectInstance *obj = getObj(objid, false);
|
||||
if(obj)
|
||||
return dynamic_cast<const CGHeroInstance*>(obj);
|
||||
else
|
||||
@ -50,7 +52,7 @@ const CGHeroInstance* IGameCallback::getHero(int objid)
|
||||
}
|
||||
const CGTownInstance* IGameCallback::getTown(int objid)
|
||||
{
|
||||
const CGObjectInstance *obj = getObj(objid);
|
||||
const CGObjectInstance *obj = getObj(objid, false);
|
||||
if(obj)
|
||||
return dynamic_cast<const CGTownInstance*>(gs->map->objects[objid]);
|
||||
else
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
virtual int getOwner(int heroID);
|
||||
virtual int getResource(int player, int which);
|
||||
virtual int getDate(int mode=0); ////mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
|
||||
virtual const CGObjectInstance* getObj(int objid);
|
||||
virtual const CGObjectInstance* getObj(int objid, bool verbose = true);
|
||||
virtual const CGHeroInstance* getHero(int objid);
|
||||
virtual const CGTownInstance* getTown(int objid);
|
||||
virtual const CGHeroInstance* getSelectedHero(int player); //NULL if no hero is selected
|
||||
|
Loading…
Reference in New Issue
Block a user