Michał W. Urbańczyk 15 年之前
父節點
當前提交
221728c680
共有 2 個文件被更改,包括 8 次插入6 次删除
  1. 7 5
      lib/IGameCallback.cpp
  2. 1 1
      lib/IGameCallback.h

+ 7 - 5
lib/IGameCallback.cpp

@@ -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

+ 1 - 1
lib/IGameCallback.h

@@ -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