mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
@@ -721,6 +721,11 @@ bool CGameInfoCallback::isPlayerMakingTurn(PlayerColor player) const
|
|||||||
return gs->actingPlayers.count(player);
|
return gs->actingPlayers.count(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGameInfoCallback::CGameInfoCallback():
|
||||||
|
gs(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CGameInfoCallback::CGameInfoCallback(CGameState * GS):
|
CGameInfoCallback::CGameInfoCallback(CGameState * GS):
|
||||||
gs(GS)
|
gs(GS)
|
||||||
{
|
{
|
||||||
|
@@ -134,7 +134,7 @@ class DLL_LINKAGE CGameInfoCallback : public IGameInfoCallback
|
|||||||
protected:
|
protected:
|
||||||
CGameState * gs;//todo: replace with protected const getter, only actual Server and Client objects should hold game state
|
CGameState * gs;//todo: replace with protected const getter, only actual Server and Client objects should hold game state
|
||||||
|
|
||||||
CGameInfoCallback() = default;
|
CGameInfoCallback();
|
||||||
CGameInfoCallback(CGameState * GS);
|
CGameInfoCallback(CGameState * GS);
|
||||||
bool hasAccess(std::optional<PlayerColor> playerId) const;
|
bool hasAccess(std::optional<PlayerColor> playerId) const;
|
||||||
|
|
||||||
|
@@ -20,6 +20,19 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
AObjectTypeHandler::AObjectTypeHandler() = default;
|
||||||
|
|
||||||
|
AObjectTypeHandler::~AObjectTypeHandler()
|
||||||
|
{
|
||||||
|
// FIXME: currently on Android there is a weird crash in destructor of 'base' member
|
||||||
|
// this code attempts to localize and fix this crash
|
||||||
|
if (base)
|
||||||
|
{
|
||||||
|
base->clear();
|
||||||
|
base.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string AObjectTypeHandler::getJsonKey() const
|
std::string AObjectTypeHandler::getJsonKey() const
|
||||||
{
|
{
|
||||||
return modScope + ':' + subTypeName;
|
return modScope + ':' + subTypeName;
|
||||||
@@ -55,7 +68,8 @@ static ui32 loadJsonOrMax(const JsonNode & input)
|
|||||||
|
|
||||||
void AObjectTypeHandler::init(const JsonNode & input)
|
void AObjectTypeHandler::init(const JsonNode & input)
|
||||||
{
|
{
|
||||||
base = input["base"];
|
if (!input["base"].isNull())
|
||||||
|
base = std::make_unique<JsonNode>(input["base"]);
|
||||||
|
|
||||||
if (!input["rmg"].isNull())
|
if (!input["rmg"].isNull())
|
||||||
{
|
{
|
||||||
@@ -72,7 +86,8 @@ void AObjectTypeHandler::init(const JsonNode & input)
|
|||||||
for (auto entry : input["templates"].Struct())
|
for (auto entry : input["templates"].Struct())
|
||||||
{
|
{
|
||||||
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
||||||
JsonUtils::inherit(entry.second, base);
|
if (base)
|
||||||
|
JsonUtils::inherit(entry.second, *base);
|
||||||
|
|
||||||
auto * tmpl = new ObjectTemplate;
|
auto * tmpl = new ObjectTemplate;
|
||||||
tmpl->id = Obj(type);
|
tmpl->id = Obj(type);
|
||||||
@@ -171,7 +186,8 @@ void AObjectTypeHandler::addTemplate(const std::shared_ptr<const ObjectTemplate>
|
|||||||
void AObjectTypeHandler::addTemplate(JsonNode config)
|
void AObjectTypeHandler::addTemplate(JsonNode config)
|
||||||
{
|
{
|
||||||
config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not null
|
config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not null
|
||||||
JsonUtils::inherit(config, base);
|
if (base)
|
||||||
|
JsonUtils::inherit(config, *base);
|
||||||
auto * tmpl = new ObjectTemplate;
|
auto * tmpl = new ObjectTemplate;
|
||||||
tmpl->id = Obj(type);
|
tmpl->id = Obj(type);
|
||||||
tmpl->subid = subtype;
|
tmpl->subid = subtype;
|
||||||
|
@@ -27,7 +27,7 @@ class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
|
|||||||
|
|
||||||
RandomMapInfo rmgInfo;
|
RandomMapInfo rmgInfo;
|
||||||
|
|
||||||
JsonNode base; /// describes base template
|
std::unique_ptr<JsonNode> base; /// describes base template
|
||||||
|
|
||||||
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
||||||
|
|
||||||
@@ -54,7 +54,8 @@ protected:
|
|||||||
virtual void initTypeData(const JsonNode & input);
|
virtual void initTypeData(const JsonNode & input);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~AObjectTypeHandler() = default;
|
AObjectTypeHandler();
|
||||||
|
virtual ~AObjectTypeHandler();
|
||||||
|
|
||||||
si32 getIndex() const;
|
si32 getIndex() const;
|
||||||
si32 getSubIndex() const;
|
si32 getSubIndex() const;
|
||||||
|
@@ -443,7 +443,6 @@ void CObjectClassesHandler::generateExtraMonolithsForRMG(ObjectClass * container
|
|||||||
//deep copy of noncopyable object :?
|
//deep copy of noncopyable object :?
|
||||||
auto newPortal = std::make_shared<CDefaultObjectTypeHandler<CGMonolith>>();
|
auto newPortal = std::make_shared<CDefaultObjectTypeHandler<CGMonolith>>();
|
||||||
newPortal->rmgInfo = portal->getRMGInfo();
|
newPortal->rmgInfo = portal->getRMGInfo();
|
||||||
newPortal->base = portal->base; //not needed?
|
|
||||||
newPortal->templates = portal->getTemplates();
|
newPortal->templates = portal->getTemplates();
|
||||||
newPortal->sounds = portal->getSounds();
|
newPortal->sounds = portal->getSounds();
|
||||||
newPortal->aiValue = portal->getAiValue();
|
newPortal->aiValue = portal->getAiValue();
|
||||||
|
@@ -49,7 +49,11 @@ CModInfo::CModInfo(const std::string & identifier, const JsonNode & local, const
|
|||||||
validation(PENDING),
|
validation(PENDING),
|
||||||
config(addMeta(config, identifier))
|
config(addMeta(config, identifier))
|
||||||
{
|
{
|
||||||
verificationInfo.name = config["name"].String();
|
if (!config["name"].String().empty())
|
||||||
|
verificationInfo.name = config["name"].String();
|
||||||
|
else
|
||||||
|
verificationInfo.name = identifier;
|
||||||
|
|
||||||
verificationInfo.version = CModVersion::fromString(config["version"].String());
|
verificationInfo.version = CModVersion::fromString(config["version"].String());
|
||||||
verificationInfo.parent = identifier.substr(0, identifier.find_last_of('.'));
|
verificationInfo.parent = identifier.substr(0, identifier.find_last_of('.'));
|
||||||
if(verificationInfo.parent == identifier)
|
if(verificationInfo.parent == identifier)
|
||||||
@@ -189,6 +193,7 @@ bool CModInfo::checkModGameplayAffecting() const
|
|||||||
|
|
||||||
const ModVerificationInfo & CModInfo::getVerificationInfo() const
|
const ModVerificationInfo & CModInfo::getVerificationInfo() const
|
||||||
{
|
{
|
||||||
|
assert(!verificationInfo.name.empty());
|
||||||
return verificationInfo;
|
return verificationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -148,6 +148,9 @@ void CConnection::flushBuffers()
|
|||||||
if(!enableBufferedWrite)
|
if(!enableBufferedWrite)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!socket)
|
||||||
|
throw std::runtime_error("Can't write to closed socket!");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
asio::write(*socket, connectionBuffers->writeBuffer);
|
asio::write(*socket, connectionBuffers->writeBuffer);
|
||||||
@@ -164,6 +167,9 @@ void CConnection::flushBuffers()
|
|||||||
|
|
||||||
int CConnection::write(const void * data, unsigned size)
|
int CConnection::write(const void * data, unsigned size)
|
||||||
{
|
{
|
||||||
|
if (!socket)
|
||||||
|
throw std::runtime_error("Can't write to closed socket!");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(enableBufferedWrite)
|
if(enableBufferedWrite)
|
||||||
|
@@ -489,11 +489,6 @@ void CGameHandler::handleReceivedPack(CPackForServer * pack)
|
|||||||
vstd::clear_pointer(pack);
|
vstd::clear_pointer(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CGameHandler::CGameHandler()
|
|
||||||
: turnTimerHandler(*this)
|
|
||||||
{}
|
|
||||||
|
|
||||||
CGameHandler::CGameHandler(CVCMIServer * lobby)
|
CGameHandler::CGameHandler(CVCMIServer * lobby)
|
||||||
: lobby(lobby)
|
: lobby(lobby)
|
||||||
, heroPool(std::make_unique<HeroPoolProcessor>(this))
|
, heroPool(std::make_unique<HeroPoolProcessor>(this))
|
||||||
@@ -518,6 +513,7 @@ CGameHandler::~CGameHandler()
|
|||||||
{
|
{
|
||||||
delete spellEnv;
|
delete spellEnv;
|
||||||
delete gs;
|
delete gs;
|
||||||
|
gs = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::reinitScripting()
|
void CGameHandler::reinitScripting()
|
||||||
|
@@ -92,8 +92,7 @@ public:
|
|||||||
bool isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2);
|
bool isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2);
|
||||||
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
|
void giveSpells(const CGTownInstance *t, const CGHeroInstance *h);
|
||||||
|
|
||||||
CGameHandler();
|
explicit CGameHandler(CVCMIServer * lobby);
|
||||||
CGameHandler(CVCMIServer * lobby);
|
|
||||||
~CGameHandler();
|
~CGameHandler();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user