1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Queries refactoring

* Moved SUMMON_BOAT special case to mechanics
* Partially moved Town portal logic to mechanics class
* Added generic query reply to CCallback
* Redesigned Queries so that base API do not depends on CGameHandler
* Got rid of CGameHandler::castSpellRequest
* Removed CGameHandler::castSpell
* Added new Query type for town portal dialog (not used yet)
This commit is contained in:
AlexVinS
2017-06-06 07:53:51 +03:00
parent f463dc2fa3
commit 3d1a84875e
32 changed files with 729 additions and 295 deletions

View File

@@ -3,6 +3,7 @@
#include "NetPacksBase.h"
#include "battle/BattleAction.h"
#include "JsonNode.h"
#include "mapObjects/CGHeroInstance.h"
#include "ConstTransitivePtr.h"
#include "int3.h"
@@ -1141,12 +1142,6 @@ struct BlockingDialog : public Query
soundID = 0;
};
void addResourceComponents(TResources resources)
{
for(TResources::nziterator i(resources); i.valid(); i++)
components.push_back(Component(Component::RESOURCE, i->resType, i->resVal, 0));
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & queryID & text & components & player & flags & soundID;
@@ -1205,6 +1200,24 @@ struct TeleportDialog : public Query
}
};
struct MapObjectSelectDialog : public Query
{
PlayerColor player;
Component icon;
MetaString title;
MetaString description;
std::vector<ObjectInstanceID> objects;
MapObjectSelectDialog(){};
void applyCl(CClient * cl);
template <typename Handler> void serialize(Handler & h, const int version)
{
h & queryID & player & icon & title & description & objects;
}
};
struct BattleInfo;
struct BattleStart : public CPackForClient
{
@@ -2058,16 +2071,16 @@ struct BuildBoat : public CPackForServer
struct QueryReply : public CPackForServer
{
QueryReply():answer(0){};
QueryReply(QueryID QID, ui32 Answer):qid(QID),answer(Answer){};
QueryReply(){};
QueryReply(QueryID QID, const JsonNode & Reply):qid(QID), reply(Reply){};
QueryID qid;
ui32 answer; //hero and artifact id
PlayerColor player;
JsonNode reply;
bool applyGh(CGameHandler *gh);
template <typename Handler> void serialize(Handler &h, const int version)
{
h & qid & answer & player;
h & qid & player & reply;
}
};