mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Moved ArtifactLocation to a separate file
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "ArtifactUtils.h"
|
||||
#include "CArtHandler.h"
|
||||
#include "networkPacks/NetPacksBase.h"
|
||||
#include "networkPacks/ArtifactLocation.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "../mapObjects/ObjectTemplate.h"
|
||||
#include "../modding/ModScope.h"
|
||||
#include "../networkPacks/Component.h"
|
||||
#include "../networkPacks/NetPacksBase.h"
|
||||
#include "../networkPacks/ArtifactLocation.h"
|
||||
#include "../spells/CSpellHandler.h"
|
||||
|
||||
#include <boost/crc.hpp>
|
||||
|
||||
76
lib/networkPacks/ArtifactLocation.h
Normal file
76
lib/networkPacks/ArtifactLocation.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* ArtifactLocation.h, 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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../ConstTransitivePtr.h"
|
||||
#include "../constants/EntityIdentifiers.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CGHeroInstance;
|
||||
class CStackInstance;
|
||||
class CArmedInstance;
|
||||
class CArtifactSet;
|
||||
class CBonusSystemNode;
|
||||
struct ArtSlotInfo;
|
||||
|
||||
using TArtHolder = std::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance>>;
|
||||
|
||||
struct ArtifactLocation
|
||||
{
|
||||
TArtHolder artHolder;//TODO: identify holder by id
|
||||
ArtifactPosition slot = ArtifactPosition::PRE_FIRST;
|
||||
|
||||
ArtifactLocation()
|
||||
: artHolder(ConstTransitivePtr<CGHeroInstance>())
|
||||
{
|
||||
}
|
||||
template<typename T>
|
||||
ArtifactLocation(const T * ArtHolder, ArtifactPosition Slot)
|
||||
: artHolder(const_cast<T *>(ArtHolder)) //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
|
||||
, slot(Slot)
|
||||
{
|
||||
}
|
||||
ArtifactLocation(TArtHolder ArtHolder, const ArtifactPosition & Slot)
|
||||
: artHolder(std::move(std::move(ArtHolder)))
|
||||
, slot(Slot)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool isHolder(const T *t) const
|
||||
{
|
||||
if(auto ptrToT = std::get<ConstTransitivePtr<T>>(artHolder))
|
||||
{
|
||||
return ptrToT == t;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DLL_LINKAGE void removeArtifact(); // BE CAREFUL, this operation modifies holder (gs)
|
||||
|
||||
DLL_LINKAGE const CArmedInstance *relatedObj() const; //hero or the stack owner
|
||||
DLL_LINKAGE PlayerColor owningPlayer() const;
|
||||
DLL_LINKAGE CArtifactSet *getHolderArtSet();
|
||||
DLL_LINKAGE CBonusSystemNode *getHolderNode();
|
||||
DLL_LINKAGE CArtifactSet *getHolderArtSet() const;
|
||||
DLL_LINKAGE const CBonusSystemNode *getHolderNode() const;
|
||||
|
||||
DLL_LINKAGE const CArtifactInstance *getArt() const;
|
||||
DLL_LINKAGE CArtifactInstance *getArt();
|
||||
DLL_LINKAGE const ArtSlotInfo *getSlot() const;
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & artHolder;
|
||||
h & slot;
|
||||
}
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "PacksForClient.h"
|
||||
#include "PacksForClientBattle.h"
|
||||
#include "PacksForServer.h"
|
||||
#include "NetPacksLobby.h"
|
||||
#include "PacksForLobby.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
@@ -9,26 +9,12 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../ConstTransitivePtr.h"
|
||||
#include "../GameConstants.h"
|
||||
|
||||
class CClient;
|
||||
class CGameHandler;
|
||||
class CLobbyScreen;
|
||||
class CServerHandler;
|
||||
class CVCMIServer;
|
||||
#include "../constants/EntityIdentifiers.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CGameState;
|
||||
class CConnection;
|
||||
class CStackBasicDescriptor;
|
||||
class CGHeroInstance;
|
||||
class CStackInstance;
|
||||
class CArmedInstance;
|
||||
class CArtifactSet;
|
||||
class CBonusSystemNode;
|
||||
struct ArtSlotInfo;
|
||||
|
||||
class ICPackVisitor;
|
||||
|
||||
@@ -65,7 +51,7 @@ protected:
|
||||
struct DLL_LINKAGE CPackForClient : public CPack
|
||||
{
|
||||
protected:
|
||||
virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE Query : public CPackForClient
|
||||
@@ -85,7 +71,7 @@ struct DLL_LINKAGE CPackForServer : public CPack
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE CPackForLobby : public CPack
|
||||
@@ -93,59 +79,7 @@ struct DLL_LINKAGE CPackForLobby : public CPack
|
||||
virtual bool isForServer() const;
|
||||
|
||||
protected:
|
||||
virtual void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
};
|
||||
|
||||
using TArtHolder = std::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance>>;
|
||||
|
||||
struct ArtifactLocation
|
||||
{
|
||||
TArtHolder artHolder;//TODO: identify holder by id
|
||||
ArtifactPosition slot = ArtifactPosition::PRE_FIRST;
|
||||
|
||||
ArtifactLocation()
|
||||
: artHolder(ConstTransitivePtr<CGHeroInstance>())
|
||||
{
|
||||
}
|
||||
template<typename T>
|
||||
ArtifactLocation(const T * ArtHolder, ArtifactPosition Slot)
|
||||
: artHolder(const_cast<T *>(ArtHolder)) //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
|
||||
, slot(Slot)
|
||||
{
|
||||
}
|
||||
ArtifactLocation(TArtHolder ArtHolder, const ArtifactPosition & Slot)
|
||||
: artHolder(std::move(std::move(ArtHolder)))
|
||||
, slot(Slot)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool isHolder(const T *t) const
|
||||
{
|
||||
if(auto ptrToT = std::get<ConstTransitivePtr<T>>(artHolder))
|
||||
{
|
||||
return ptrToT == t;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DLL_LINKAGE void removeArtifact(); // BE CAREFUL, this operation modifies holder (gs)
|
||||
|
||||
DLL_LINKAGE const CArmedInstance *relatedObj() const; //hero or the stack owner
|
||||
DLL_LINKAGE PlayerColor owningPlayer() const;
|
||||
DLL_LINKAGE CArtifactSet *getHolderArtSet();
|
||||
DLL_LINKAGE CBonusSystemNode *getHolderNode();
|
||||
DLL_LINKAGE CArtifactSet *getHolderArtSet() const;
|
||||
DLL_LINKAGE const CBonusSystemNode *getHolderNode() const;
|
||||
|
||||
DLL_LINKAGE const CArtifactInstance *getArt() const;
|
||||
DLL_LINKAGE CArtifactInstance *getArt();
|
||||
DLL_LINKAGE const ArtSlotInfo *getSlot() const;
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & artHolder;
|
||||
h & slot;
|
||||
}
|
||||
void visitBasic(ICPackVisitor & cpackVisitor) override;
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "PacksForClientBattle.h"
|
||||
#include "PacksForServer.h"
|
||||
#include "StackLocation.h"
|
||||
#include "NetPacksLobby.h"
|
||||
#include "PacksForLobby.h"
|
||||
#include "NetPackVisitor.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "CArtHandler.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* NetPacks.h, part of VCMI engine
|
||||
* PacksForClient.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@@ -9,11 +9,12 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "NetPacksBase.h"
|
||||
#include "ArtifactLocation.h"
|
||||
#include "Component.h"
|
||||
#include "EOpenWindowMode.h"
|
||||
#include "EInfoWindowMode.h"
|
||||
#include "EOpenWindowMode.h"
|
||||
#include "EntityChanges.h"
|
||||
#include "NetPacksBase.h"
|
||||
|
||||
#include "../CCreatureSet.h"
|
||||
#include "../MetaString.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* NetPacks.h, part of VCMI engine
|
||||
* PacksForClientBattle.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@@ -14,8 +14,12 @@
|
||||
#include "../MetaString.h"
|
||||
#include "../battle/BattleAction.h"
|
||||
|
||||
class CClient;
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CGHeroInstance;
|
||||
class CArmedInstance;
|
||||
class IBattleState;
|
||||
class BattleInfo;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* NetPacksLobby.h, part of VCMI engine
|
||||
* PacksForLobby.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* NetPacks.h, part of VCMI engine
|
||||
* PacksForServer.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@@ -9,7 +9,9 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ArtifactLocation.h"
|
||||
#include "NetPacksBase.h"
|
||||
|
||||
#include "../int3.h"
|
||||
#include "../battle/BattleAction.h"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "../networkPacks/PacksForClient.h"
|
||||
#include "../networkPacks/PacksForClientBattle.h"
|
||||
#include "../networkPacks/PacksForServer.h"
|
||||
#include "../networkPacks/NetPacksLobby.h"
|
||||
#include "../networkPacks/PacksForLobby.h"
|
||||
#include "../VCMI_Lib.h"
|
||||
#include "../CArtHandler.h"
|
||||
#include "../CCreatureSet.h"
|
||||
|
||||
Reference in New Issue
Block a user