mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-21 12:06:49 +02:00
Fixed compilation with MSVC.
This commit is contained in:
parent
d2ae847ecf
commit
7d1e54baa7
@ -542,7 +542,7 @@ std::vector<JsonNode> CSpellHandler::loadLegacyData(size_t dataSize)
|
|||||||
return legacyData;
|
return legacyData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CSpellHandler::getTypeName()
|
const std::string CSpellHandler::getTypeName() const
|
||||||
{
|
{
|
||||||
return "spell";
|
return "spell";
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::vector<bool> getDefaultAllowed() const override;
|
std::vector<bool> getDefaultAllowed() const override;
|
||||||
|
|
||||||
const std::string getTypeName() override;
|
const std::string getTypeName() const override;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
@ -49,53 +49,53 @@ public:
|
|||||||
template <class _ObjectID, class _Object> class CHandlerBase: public IHandlerBase
|
template <class _ObjectID, class _Object> class CHandlerBase: public IHandlerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~CHandlerBase()
|
virtual ~CHandlerBase()
|
||||||
{
|
{
|
||||||
for(auto & o : objects)
|
for(auto & o : objects)
|
||||||
{
|
{
|
||||||
o.dellNull();
|
o.dellNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void loadObject(std::string scope, std::string name, const JsonNode & data) override
|
void loadObject(std::string scope, std::string name, const JsonNode & data) override
|
||||||
{
|
{
|
||||||
auto type_name = getTypeName();
|
auto type_name = getTypeName();
|
||||||
auto object = loadFromJson(data);
|
auto object = loadFromJson(data);
|
||||||
object->id = _ObjectID(objects.size());
|
object->id = _ObjectID(objects.size());
|
||||||
|
|
||||||
objects.push_back(object);
|
objects.push_back(object);
|
||||||
|
|
||||||
VLC->modh->identifiers.registerObject(scope, type_name, name, object->id);
|
VLC->modh->identifiers.registerObject(scope, type_name, name, object->id);
|
||||||
}
|
}
|
||||||
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override
|
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override
|
||||||
{
|
{
|
||||||
auto type_name = getTypeName();
|
auto type_name = getTypeName();
|
||||||
auto object = loadFromJson(data);
|
auto object = loadFromJson(data);
|
||||||
object->id = _ObjectID(index);
|
object->id = _ObjectID(index);
|
||||||
|
|
||||||
|
|
||||||
assert(objects[index] == nullptr); // ensure that this id was not loaded before
|
assert(objects[index] == nullptr); // ensure that this id was not loaded before
|
||||||
objects[index] = object;
|
objects[index] = object;
|
||||||
|
|
||||||
VLC->modh->identifiers.registerObject(scope,type_name, name, object->id);
|
VLC->modh->identifiers.registerObject(scope,type_name, name, object->id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstTransitivePtr<_Object> operator[] (const _ObjectID id) const
|
ConstTransitivePtr<_Object> operator[] (const _ObjectID id) const
|
||||||
{
|
{
|
||||||
const auto raw_id = id.toEnum();
|
const auto raw_id = id.toEnum();
|
||||||
|
|
||||||
if (raw_id < 0 || raw_id >= objects.size())
|
if (raw_id < 0 || raw_id >= objects.size())
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << getTypeName() << " id " << static_cast<si64>(raw_id) << "is invalid";
|
logGlobal->errorStream() << getTypeName() << " id " << static_cast<si64>(raw_id) << "is invalid";
|
||||||
throw std::runtime_error ("internal error");
|
throw std::runtime_error ("internal error");
|
||||||
}
|
}
|
||||||
|
|
||||||
return objects[raw_id];
|
return objects[raw_id];
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual _Object * loadFromJson(const JsonNode & json) = 0;
|
virtual _Object * loadFromJson(const JsonNode & json) = 0;
|
||||||
virtual const std::string getTypeName() = 0;
|
virtual const std::string getTypeName() const = 0;
|
||||||
public: //todo: make private
|
public: //todo: make private
|
||||||
std::vector<ConstTransitivePtr<_Object>> objects;
|
std::vector<ConstTransitivePtr<_Object>> objects;
|
||||||
};
|
};
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "RegisterTypes.h"
|
#include "RegisterTypes.h"
|
||||||
|
|
||||||
#include "mapping/CMapInfo.h"
|
#include "../mapping/CMapInfo.h"
|
||||||
#include "StartInfo.h"
|
#include "../StartInfo.h"
|
||||||
#include "BattleState.h"
|
#include "../BattleState.h"
|
||||||
#include "CGameState.h"
|
#include "../CGameState.h"
|
||||||
#include "mapping/CMap.h"
|
#include "../mapping/CMap.h"
|
||||||
#include "CModHandler.h"
|
#include "../CModHandler.h"
|
||||||
#include "CObjectHandler.h"
|
#include "../CObjectHandler.h"
|
||||||
#include "CCreatureHandler.h"
|
#include "../CCreatureHandler.h"
|
||||||
#include "VCMI_Lib.h"
|
#include "../VCMI_Lib.h"
|
||||||
#include "CArtHandler.h"
|
#include "../CArtHandler.h"
|
||||||
#include "CHeroHandler.h"
|
#include "../CHeroHandler.h"
|
||||||
#include "CSpellHandler.h"
|
#include "../CSpellHandler.h"
|
||||||
#include "CTownHandler.h"
|
#include "../CTownHandler.h"
|
||||||
#include "mapping/CCampaignHandler.h"
|
#include "../mapping/CCampaignHandler.h"
|
||||||
#include "NetPacks.h"
|
#include "../NetPacks.h"
|
||||||
#include "CDefObjInfoHandler.h"
|
#include "../CDefObjInfoHandler.h"
|
||||||
|
|
||||||
|
|
||||||
template void registerTypesMapObjects1<CISer<CConnection>>(CISer<CConnection>& s);
|
template void registerTypesMapObjects1<CISer<CConnection>>(CISer<CConnection>& s);
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "RegisterTypes.h"
|
#include "RegisterTypes.h"
|
||||||
|
|
||||||
#include "mapping/CMapInfo.h"
|
#include "../mapping/CMapInfo.h"
|
||||||
#include "StartInfo.h"
|
#include "../StartInfo.h"
|
||||||
#include "BattleState.h"
|
#include "../BattleState.h"
|
||||||
#include "CGameState.h"
|
#include "../CGameState.h"
|
||||||
#include "mapping/CMap.h"
|
#include "../mapping/CMap.h"
|
||||||
#include "CModHandler.h"
|
#include "../CModHandler.h"
|
||||||
#include "CObjectHandler.h"
|
#include "../CObjectHandler.h"
|
||||||
#include "CCreatureHandler.h"
|
#include "../CCreatureHandler.h"
|
||||||
#include "VCMI_Lib.h"
|
#include "../VCMI_Lib.h"
|
||||||
#include "CArtHandler.h"
|
#include "../CArtHandler.h"
|
||||||
#include "CHeroHandler.h"
|
#include "../CHeroHandler.h"
|
||||||
#include "CSpellHandler.h"
|
#include "../CSpellHandler.h"
|
||||||
#include "CTownHandler.h"
|
#include "../CTownHandler.h"
|
||||||
#include "mapping/CCampaignHandler.h"
|
#include "../mapping/CCampaignHandler.h"
|
||||||
#include "NetPacks.h"
|
#include "../NetPacks.h"
|
||||||
#include "CDefObjInfoHandler.h"
|
#include "../CDefObjInfoHandler.h"
|
||||||
|
|
||||||
|
|
||||||
template void registerTypesMapObjects2<CISer<CConnection>>(CISer<CConnection>& s);
|
template void registerTypesMapObjects2<CISer<CConnection>>(CISer<CConnection>& s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user