2014-03-17 22:51:07 +03:00
|
|
|
/*
|
|
|
|
* IGameCallback.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2008-12-27 03:01:59 +02:00
|
|
|
#include "IGameCallback.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2014-04-19 20:44:21 +03:00
|
|
|
/*#include "CGameState.h"
|
2013-04-07 13:48:07 +03:00
|
|
|
#include "mapping/CMap.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CObjectHandler.h"
|
2011-05-03 06:14:18 +03:00
|
|
|
#include "CHeroHandler.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "StartInfo.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CArtHandler.h"
|
|
|
|
#include "CSpellHandler.h"
|
2012-09-05 15:49:23 +03:00
|
|
|
#include "VCMI_Lib.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CTownHandler.h"
|
2014-04-19 20:44:21 +03:00
|
|
|
#include "BattleState.h"*/
|
2011-05-03 06:14:18 +03:00
|
|
|
#include "NetPacks.h"
|
2014-04-19 20:44:21 +03:00
|
|
|
/*#include "CBuildingHandler.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "GameConstants.h"
|
2012-09-05 15:49:23 +03:00
|
|
|
#include "CModHandler.h"
|
2013-02-19 01:37:22 +03:00
|
|
|
#include "CDefObjInfoHandler.h"
|
2013-03-06 21:49:56 +03:00
|
|
|
#include "CBonusTypeHandler.h"
|
2013-02-19 01:37:22 +03:00
|
|
|
|
2014-04-19 20:44:21 +03:00
|
|
|
#include "Connection.h"*/
|
2008-12-27 03:01:59 +02:00
|
|
|
|
2011-05-10 01:20:47 +03:00
|
|
|
//TODO make clean
|
2014-04-19 20:44:21 +03:00
|
|
|
/*#define ERROR_SILENT_RET_VAL_IF(cond, txt, retVal) do {if(cond){return retVal;}} while(0)
|
2013-04-09 17:31:36 +03:00
|
|
|
#define ERROR_VERBOSE_OR_NOT_RET_VAL_IF(cond, verbose, txt, retVal) do {if(cond){if(verbose)logGlobal->errorStream() << BOOST_CURRENT_FUNCTION << ": " << txt; return retVal;}} while(0)
|
|
|
|
#define ERROR_RET_IF(cond, txt) do {if(cond){logGlobal->errorStream() << BOOST_CURRENT_FUNCTION << ": " << txt; return;}} while(0)
|
2014-04-19 20:44:21 +03:00
|
|
|
#define ERROR_RET_VAL_IF(cond, txt, retVal) do {if(cond){logGlobal->errorStream() << BOOST_CURRENT_FUNCTION << ": " << txt; return retVal;}} while(0)*/
|
2011-05-28 04:02:28 +03:00
|
|
|
|
2013-02-11 02:24:57 +03:00
|
|
|
const CGObjectInstance * IGameCallback::putNewObject(Obj ID, int subID, int3 pos)
|
2011-05-28 04:02:28 +03:00
|
|
|
{
|
|
|
|
NewObject no;
|
|
|
|
no.ID = ID; //creature
|
|
|
|
no.subID= subID;
|
|
|
|
no.pos = pos;
|
|
|
|
commitPackage(&no);
|
2011-07-05 09:14:07 +03:00
|
|
|
return getObj(no.id); //id field will be filled during applying on gs
|
2011-05-28 04:02:28 +03:00
|
|
|
}
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
const CGCreature * IGameCallback::putNewMonster(CreatureID creID, int count, int3 pos)
|
2011-05-28 04:02:28 +03:00
|
|
|
{
|
2013-02-07 20:34:50 +03:00
|
|
|
const CGObjectInstance *m = putNewObject(Obj::MONSTER, creID, pos);
|
2011-05-28 04:02:28 +03:00
|
|
|
setObjProperty(m->id, ObjProperty::MONSTER_COUNT, count);
|
|
|
|
setObjProperty(m->id, ObjProperty::MONSTER_POWER, (si64)1000*count);
|
|
|
|
return dynamic_cast<const CGCreature*>(m);
|
|
|
|
}
|
2013-05-28 00:46:04 +03:00
|
|
|
|
|
|
|
bool IGameCallback::isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, const CGHeroInstance *hero)
|
|
|
|
{
|
|
|
|
//only server knows
|
|
|
|
assert(0);
|
|
|
|
return false;
|
|
|
|
}
|