1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-04 23:17:41 +02:00

Merge branch 'develop' of https://github.com/vcmi/vcmi into RMG

This commit is contained in:
DjWarmonger 2014-06-26 20:12:37 +02:00
commit e51e2190fd
18 changed files with 165 additions and 169 deletions

View File

@ -207,7 +207,7 @@ void CMapHandler::borderAndTerrainBitmapInit()
terBitmapNum = 17; terBitmapNum = 17;
else if(i==(sizes.x) && j==(sizes.y)) else if(i==(sizes.x) && j==(sizes.y))
terBitmapNum = 18; terBitmapNum = 18;
else if(j == -1 && i > -1 && i < sizes.y) else if(j == -1 && i > -1 && i < sizes.x)
terBitmapNum = rand.nextInt(22, 23); terBitmapNum = rand.nextInt(22, 23);
else if(i == -1 && j > -1 && j < sizes.y) else if(i == -1 && j > -1 && j < sizes.y)
terBitmapNum = rand.nextInt(33, 34); terBitmapNum = rand.nextInt(33, 34);

View File

@ -68,7 +68,7 @@
], ],
"combat_value": 1013, "combat_value": 1013,
"reward" : { "reward" : {
"value": 20000 "value": 20000,
"resources": "resources":
{ {
"wood" : 8, "wood" : 8,
@ -664,7 +664,7 @@
] ]
} }
} }
} },
"derelictShip" : { "derelictShip" : {
"index" :24, "index" :24,
"handler": "bank", "handler": "bank",
@ -863,9 +863,9 @@
"gold" : 20000 "gold" : 20000
}, },
"artifacts": [ "artifacts": [
{ "class" : "TREASURE" } { "class" : "TREASURE" },
{ "class" : "MINOR" } { "class" : "MINOR" },
{ "class" : "MAJOR" } { "class" : "MAJOR" },
{ "class" : "RELIC" } { "class" : "RELIC" }
] ]
} }
@ -886,9 +886,9 @@
"gold" : 30000 "gold" : 30000
}, },
"artifacts": [ "artifacts": [
{ "class" : "MINOR" } { "class" : "MINOR" },
{ "class" : "MAJOR" } { "class" : "MAJOR" },
{ "class" : "RELIC" } { "class" : "RELIC" },
{ "class" : "RELIC" } { "class" : "RELIC" }
] ]
} }
@ -908,11 +908,10 @@
{ {
"gold" : 40000 "gold" : 40000
}, },
"artifacts": [ 0, 0, 1, 3 ]
"artifacts": [ "artifacts": [
{ "class" : "MAJOR" } { "class" : "MAJOR" },
{ "class" : "RELIC" } { "class" : "RELIC" },
{ "class" : "RELIC" } { "class" : "RELIC" },
{ "class" : "RELIC" } { "class" : "RELIC" }
] ]
} }
@ -932,11 +931,10 @@
{ {
"gold" : 50000 "gold" : 50000
}, },
"artifacts": [ 0, 0, 0, 4 ]
"artifacts": [ "artifacts": [
{ "class" : "RELIC" } { "class" : "RELIC" },
{ "class" : "RELIC" } { "class" : "RELIC" },
{ "class" : "RELIC" } { "class" : "RELIC" },
{ "class" : "RELIC" } { "class" : "RELIC" }
] ]
} }

View File

@ -110,8 +110,6 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
heroClass->name = node["name"].String(); heroClass->name = node["name"].String();
heroClass->affinity = vstd::find_pos(affinityStr, node["affinity"].String()); heroClass->affinity = vstd::find_pos(affinityStr, node["affinity"].String());
if (heroClass->affinity >= 2) //FIXME: MODS COMPATIBILITY
heroClass->affinity = 0;
for(const std::string & pSkill : PrimarySkill::names) for(const std::string & pSkill : PrimarySkill::names)
{ {
@ -125,15 +123,11 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
heroClass->secSkillProbability.push_back(node["secondarySkills"][secSkill].Float()); heroClass->secSkillProbability.push_back(node["secondarySkills"][secSkill].Float());
} }
//FIXME: MODS COMPATIBILITY VLC->modh->identifiers.requestIdentifier ("creature", node["commander"],
if (!node["commander"].isNull()) [=](si32 commanderID)
{ {
VLC->modh->identifiers.requestIdentifier ("creature", node["commander"], heroClass->commander = VLC->creh->creatures[commanderID];
[=](si32 commanderID) });
{
heroClass->commander = VLC->creh->creatures[commanderID];
});
}
heroClass->defaultTavernChance = node["defaultTavern"].Float(); heroClass->defaultTavernChance = node["defaultTavern"].Float();
for(auto & tavern : node["tavern"].Struct()) for(auto & tavern : node["tavern"].Struct())

View File

@ -94,6 +94,7 @@ set(lib_SRCS
registerTypes/TypesClientPacks2.cpp registerTypes/TypesClientPacks2.cpp
registerTypes/TypesMapObjects1.cpp registerTypes/TypesMapObjects1.cpp
registerTypes/TypesMapObjects2.cpp registerTypes/TypesMapObjects2.cpp
registerTypes/TypesMapObjects3.cpp
registerTypes/TypesPregamePacks.cpp registerTypes/TypesPregamePacks.cpp
registerTypes/TypesServerPacks.cpp registerTypes/TypesServerPacks.cpp
) )

View File

@ -272,24 +272,12 @@ void CTownHandler::loadBuildingRequirements(CTown &town, CBuilding & building, c
{ {
if (source.isNull()) if (source.isNull())
return; return;
if (source.Vector()[0].getType() == JsonNode::DATA_FLOAT)
{
// MODS COMPATIBILITY
CBuilding::TRequired::OperatorAll required;
for(const JsonNode &building : source.Vector()) BuildingRequirementsHelper hlp;
required.expressions.push_back(BuildingID(building.Float())); hlp.building = &building;
hlp.faction = town.faction;
building.requirements = CBuilding::TRequired(required); hlp.json = source;
} requirementsToLoad.push_back(hlp);
else
{
BuildingRequirementsHelper hlp;
hlp.building = &building;
hlp.faction = town.faction;
hlp.json = source;
requirementsToLoad.push_back(hlp);
}
} }
void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const JsonNode & source) void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const JsonNode & source)
@ -308,56 +296,49 @@ void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const
ret->resources = TResources(source["cost"]); ret->resources = TResources(source["cost"]);
ret->produce = TResources(source["produce"]); ret->produce = TResources(source["produce"]);
//for compatibility with older town mods //MODS COMPATIBILITY FOR 0.96
if(!ret->produce.nonZero()) if(!ret->produce.nonZero())
{ {
if (ret->bid == BuildingID::VILLAGE_HALL) ret->produce[Res::GOLD] = 500; switch (ret->bid) {
break; case BuildingID::VILLAGE_HALL: ret->produce[Res::GOLD] = 500;
if (ret->bid == BuildingID::TOWN_HALL) ret->produce[Res::GOLD] = 1000; break; case BuildingID::TOWN_HALL : ret->produce[Res::GOLD] = 1000;
break; case BuildingID::CITY_HALL : ret->produce[Res::GOLD] = 2000;
if (ret->bid == BuildingID::CITY_HALL) ret->produce[Res::GOLD] = 2000; break; case BuildingID::CAPITOL : ret->produce[Res::GOLD] = 4000;
break; case BuildingID::GRAIL : ret->produce[Res::GOLD] = 5000;
if (ret->bid == BuildingID::CAPITOL) ret->produce[Res::GOLD] = 4000; break; case BuildingID::RESOURCE_SILO :
if (ret->bid == BuildingID::GRAIL) ret->produce[Res::GOLD] = 5000;
//
if (ret->bid == BuildingID::RESOURCE_SILO)
{
if ((ret->town->primaryRes != Res::WOOD) && (ret->town->primaryRes != Res::ORE) && (ret->town->primaryRes != Res::GOLD))
ret->produce[ret->town->primaryRes] = 1;
else
{
if (ret->town->primaryRes == Res::GOLD) ret->produce[ret->town->primaryRes] = 500;
else
{ {
ret->produce[Res::WOOD] = 1; switch (ret->town->primaryRes)
ret->produce[Res::ORE] = 1; {
case Res::GOLD:
ret->produce[ret->town->primaryRes] = 500;
break;
case Res::WOOD_AND_ORE:
ret->produce[Res::WOOD] = 1;
ret->produce[Res::ORE] = 1;
break;
default:
ret->produce[ret->town->primaryRes] = 1;
break;
}
} }
} }
}
} }
loadBuildingRequirements(town, *ret, source["requires"]); loadBuildingRequirements(town, *ret, source["requires"]);
if (!source["upgrades"].isNull()) if (!source["upgrades"].isNull())
{ {
//MODS COMPATIBILITY // building id and upgrades can't be the same
if (source["upgrades"].getType() == JsonNode::DATA_FLOAT) if(stringID == source["upgrades"].String())
ret->upgrade = BuildingID(source["upgrades"].Float());
else
{ {
// building id and upgrades can't be the same throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") %
if(stringID == source["upgrades"].String()) stringID % town.faction->name));
{
throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") %
stringID % town.faction->name));
}
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["upgrades"], [=](si32 identifier)
{
ret->upgrade = BuildingID(identifier);
});
} }
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["upgrades"], [=](si32 identifier)
{
ret->upgrade = BuildingID(identifier);
});
} }
else else
ret->upgrade = BuildingID::NONE; ret->upgrade = BuildingID::NONE;
@ -381,7 +362,6 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
{ {
auto ret = new CStructure; auto ret = new CStructure;
//Note: MODS COMPATIBILITY CODE
ret->building = nullptr; ret->building = nullptr;
ret->buildable = nullptr; ret->buildable = nullptr;
@ -399,17 +379,10 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
} }
else else
{ {
if (source["builds"].getType() == JsonNode::DATA_FLOAT) VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
{ {
ret->buildable = town.buildings[BuildingID(source["builds"].Float())]; ret->buildable = town.buildings[BuildingID(identifier)];
} });
else
{
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, source["builds"], [=, &town](si32 identifier) mutable
{
ret->buildable = town.buildings[BuildingID(identifier)];
});
}
} }
ret->identifier = stringID; ret->identifier = stringID;
@ -457,16 +430,10 @@ void CTownHandler::loadTownHall(CTown &town, const JsonNode & source)
auto & dst = dstBox[k]; auto & dst = dstBox[k];
auto & src = srcBox[k]; auto & src = srcBox[k];
//MODS COMPATIBILITY VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, src, [&](si32 identifier)
if (src.getType() == JsonNode::DATA_FLOAT)
dst = BuildingID(src.Float());
else
{ {
VLC->modh->identifiers.requestIdentifier("building." + town.faction->identifier, src, [&](si32 identifier) dst = BuildingID(identifier);
{ });
dst = BuildingID(identifier);
});
}
} }
} }
} }
@ -673,20 +640,6 @@ CFaction * CTownHandler::loadFromJson(const JsonNode &source, std::string identi
faction->name = source["name"].String(); faction->name = source["name"].String();
faction->identifier = identifier; faction->identifier = identifier;
//FIXME: MODS COMPATIBILITY
if (!source["commander"].isNull())
{
VLC->modh->identifiers.requestIdentifier ("creature", source["commander"],
[=](si32 commanderID)
{
for (auto ptr : VLC->heroh->classes.heroClasses)
{
if (ptr->commander == nullptr && ptr->faction == faction->index)
ptr->commander = VLC->creh->creatures[commanderID];
}
});
}
faction->creatureBg120 = source["creatureBackground"]["120px"].String(); faction->creatureBg120 = source["creatureBackground"]["120px"].String();
faction->creatureBg130 = source["creatureBackground"]["130px"].String(); faction->creatureBg130 = source["creatureBackground"]["130px"].String();

View File

@ -91,8 +91,6 @@
<Unit filename="CCreatureHandler.h" /> <Unit filename="CCreatureHandler.h" />
<Unit filename="CCreatureSet.cpp" /> <Unit filename="CCreatureSet.cpp" />
<Unit filename="CCreatureSet.h" /> <Unit filename="CCreatureSet.h" />
<Unit filename="CDefObjInfoHandler.cpp" />
<Unit filename="CDefObjInfoHandler.h" />
<Unit filename="CGameInfoCallback.cpp" /> <Unit filename="CGameInfoCallback.cpp" />
<Unit filename="CGameInfoCallback.h" /> <Unit filename="CGameInfoCallback.h" />
<Unit filename="CGameInterface.cpp" /> <Unit filename="CGameInterface.cpp" />
@ -105,8 +103,6 @@
<Unit filename="CHeroHandler.h" /> <Unit filename="CHeroHandler.h" />
<Unit filename="CModHandler.cpp" /> <Unit filename="CModHandler.cpp" />
<Unit filename="CModHandler.h" /> <Unit filename="CModHandler.h" />
<Unit filename="CObjectHandler.cpp" />
<Unit filename="CObjectHandler.h" />
<Unit filename="CObstacleInstance.cpp" /> <Unit filename="CObstacleInstance.cpp" />
<Unit filename="CObstacleInstance.h" /> <Unit filename="CObstacleInstance.h" />
<Unit filename="CRandomGenerator.cpp" /> <Unit filename="CRandomGenerator.cpp" />
@ -185,6 +181,37 @@
<Unit filename="logging/CBasicLogConfigurator.h" /> <Unit filename="logging/CBasicLogConfigurator.h" />
<Unit filename="logging/CLogger.cpp" /> <Unit filename="logging/CLogger.cpp" />
<Unit filename="logging/CLogger.h" /> <Unit filename="logging/CLogger.h" />
<Unit filename="mapObjects/CArmedInstance.cpp" />
<Unit filename="mapObjects/CArmedInstance.h" />
<Unit filename="mapObjects/CBank.cpp" />
<Unit filename="mapObjects/CBank.h" />
<Unit filename="mapObjects/CGHeroInstance.cpp" />
<Unit filename="mapObjects/CGHeroInstance.h" />
<Unit filename="mapObjects/CGMarket.cpp" />
<Unit filename="mapObjects/CGMarket.h" />
<Unit filename="mapObjects/CGPandoraBox.cpp" />
<Unit filename="mapObjects/CGPandoraBox.h" />
<Unit filename="mapObjects/CGTownInstance.cpp" />
<Unit filename="mapObjects/CGTownInstance.h" />
<Unit filename="mapObjects/CObjectClassesHandler.cpp" />
<Unit filename="mapObjects/CObjectClassesHandler.h" />
<Unit filename="mapObjects/CObjectHandler.cpp" />
<Unit filename="mapObjects/CObjectHandler.h" />
<Unit filename="mapObjects/CQuest.cpp" />
<Unit filename="mapObjects/CQuest.h" />
<Unit filename="mapObjects/CRewardableConstructor.cpp" />
<Unit filename="mapObjects/CRewardableConstructor.h" />
<Unit filename="mapObjects/CRewardableObject.cpp" />
<Unit filename="mapObjects/CRewardableObject.h" />
<Unit filename="mapObjects/CommonConstructors.cpp" />
<Unit filename="mapObjects/CommonConstructors.h" />
<Unit filename="mapObjects/JsonRandom.cpp" />
<Unit filename="mapObjects/JsonRandom.h" />
<Unit filename="mapObjects/MapObjects.h" />
<Unit filename="mapObjects/MiscObjects.cpp" />
<Unit filename="mapObjects/MiscObjects.h" />
<Unit filename="mapObjects/ObjectTemplate.cpp" />
<Unit filename="mapObjects/ObjectTemplate.h" />
<Unit filename="mapping/CCampaignHandler.cpp" /> <Unit filename="mapping/CCampaignHandler.cpp" />
<Unit filename="mapping/CCampaignHandler.h" /> <Unit filename="mapping/CCampaignHandler.h" />
<Unit filename="mapping/CMap.cpp" /> <Unit filename="mapping/CMap.cpp" />
@ -205,6 +232,7 @@
<Unit filename="registerTypes/TypesClientPacks2.cpp" /> <Unit filename="registerTypes/TypesClientPacks2.cpp" />
<Unit filename="registerTypes/TypesMapObjects1.cpp" /> <Unit filename="registerTypes/TypesMapObjects1.cpp" />
<Unit filename="registerTypes/TypesMapObjects2.cpp" /> <Unit filename="registerTypes/TypesMapObjects2.cpp" />
<Unit filename="registerTypes/TypesMapObjects3.cpp" />
<Unit filename="registerTypes/TypesPregamePacks.cpp" /> <Unit filename="registerTypes/TypesPregamePacks.cpp" />
<Unit filename="registerTypes/TypesServerPacks.cpp" /> <Unit filename="registerTypes/TypesServerPacks.cpp" />
<Unit filename="rmg/CMapGenOptions.cpp" /> <Unit filename="rmg/CMapGenOptions.cpp" />

View File

@ -228,6 +228,7 @@
<ClCompile Include="registerTypes\TypesClientPacks2.cpp" /> <ClCompile Include="registerTypes\TypesClientPacks2.cpp" />
<ClCompile Include="registerTypes\TypesMapObjects1.cpp" /> <ClCompile Include="registerTypes\TypesMapObjects1.cpp" />
<ClCompile Include="registerTypes\TypesMapObjects2.cpp" /> <ClCompile Include="registerTypes\TypesMapObjects2.cpp" />
<ClCompile Include="registerTypes\TypesMapObjects3.cpp" />
<ClCompile Include="registerTypes\TypesPregamePacks.cpp" /> <ClCompile Include="registerTypes\TypesPregamePacks.cpp" />
<ClCompile Include="registerTypes\TypesServerPacks.cpp" /> <ClCompile Include="registerTypes\TypesServerPacks.cpp" />
<ClCompile Include="rmg\CMapGenerator.cpp" /> <ClCompile Include="rmg\CMapGenerator.cpp" />

View File

@ -203,6 +203,7 @@
<ClCompile Include="mapObjects\ObjectTemplate.cpp"> <ClCompile Include="mapObjects\ObjectTemplate.cpp">
<Filter>mapObjects</Filter> <Filter>mapObjects</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="registerTypes\TypesMapObjects3.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="CCreatureSet.h"> <ClInclude Include="CCreatureSet.h">

View File

@ -10,10 +10,10 @@
#include "StdInc.h" #include "StdInc.h"
#include "CGTownInstance.h" #include "CGTownInstance.h"
#include "CObjectClassesHandler.h"
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../CGeneralTextHandler.h" #include "../CGeneralTextHandler.h"
#include "../mapObjects/CObjectClassesHandler.h"
using namespace boost::assign; using namespace boost::assign;

View File

@ -20,7 +20,7 @@ class JsonNode;
class CRandomGenerator; class CRandomGenerator;
/// Structure that describes placement rules for this object in random map /// Structure that describes placement rules for this object in random map
struct RandomMapInfo struct DLL_LINKAGE RandomMapInfo
{ {
/// How valuable this object is, 1k = worthless, 10k = Utopia-level /// How valuable this object is, 1k = worthless, 10k = Utopia-level
ui32 value; ui32 value;
@ -47,7 +47,7 @@ struct RandomMapInfo
} }
}; };
class IObjectInfo class DLL_LINKAGE IObjectInfo
{ {
public: public:
struct CArmyStructure struct CArmyStructure
@ -93,7 +93,7 @@ public:
class CGObjectInstance; class CGObjectInstance;
class DLL_EXPORT AObjectTypeHandler : public boost::noncopyable class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
{ {
RandomMapInfo rmgInfo; RandomMapInfo rmgInfo;

View File

@ -15,7 +15,7 @@
* *
*/ */
class CRandomRewardObjectInfo : public IObjectInfo class DLL_LINKAGE CRandomRewardObjectInfo : public IObjectInfo
{ {
JsonNode parameters; JsonNode parameters;
public: public:
@ -42,7 +42,7 @@ public:
void init(const JsonNode & objectConfig); void init(const JsonNode & objectConfig);
}; };
class CRewardableConstructor : public AObjectTypeHandler class DLL_LINKAGE CRewardableConstructor : public AObjectTypeHandler
{ {
CRandomRewardObjectInfo objectInfo; CRandomRewardObjectInfo objectInfo;

View File

@ -128,7 +128,7 @@ public:
} }
}; };
class CVisitInfo class DLL_LINKAGE CVisitInfo
{ {
public: public:
CRewardLimiter limiter; CRewardLimiter limiter;

View File

@ -90,8 +90,8 @@ namespace JsonRandom
for (auto & entry : value["slot"].Vector()) for (auto & entry : value["slot"].Vector())
allowedPositions.insert(VLC->arth->stringToSlot(entry.String())); allowedPositions.insert(VLC->arth->stringToSlot(entry.String()));
if (value["minValue"].isNull()) minValue = value["minValue"].Float(); if (!value["minValue"].isNull()) minValue = value["minValue"].Float();
if (value["maxValue"].isNull()) maxValue = value["maxValue"].Float(); if (!value["maxValue"].isNull()) maxValue = value["maxValue"].Float();
return VLC->arth->pickRandomArtifact(rng, [=](ArtifactID artID) -> bool return VLC->arth->pickRandomArtifact(rng, [=](ArtifactID artID) -> bool
{ {
@ -206,7 +206,12 @@ namespace JsonRandom
return ret; return ret;
} }
std::vector<Bonus> loadBonuses(const JsonNode & value) std::vector<Component> loadComponents(const JsonNode & value)
{
//TODO
}
std::vector<Bonus> DLL_LINKAGE loadBonuses(const JsonNode & value)
{ {
std::vector<Bonus> ret; std::vector<Bonus> ret;
for (const JsonNode & entry : value.Vector()) for (const JsonNode & entry : value.Vector())
@ -218,8 +223,4 @@ namespace JsonRandom
return ret; return ret;
} }
std::vector<Component> loadComponents(const JsonNode & value)
{
//TODO
}
} }

View File

@ -45,6 +45,6 @@ namespace JsonRandom
std::vector<CStackBasicDescriptor> loadCreatures(const JsonNode & value, CRandomGenerator & rng); std::vector<CStackBasicDescriptor> loadCreatures(const JsonNode & value, CRandomGenerator & rng);
std::vector<RandomStackInfo> evaluateCreatures(const JsonNode & value); std::vector<RandomStackInfo> evaluateCreatures(const JsonNode & value);
std::vector<Bonus> loadBonuses(const JsonNode & value); std::vector<Bonus> DLL_LINKAGE loadBonuses(const JsonNode & value);
std::vector<Component> loadComponents(const JsonNode & value); std::vector<Component> loadComponents(const JsonNode & value);
} }

View File

@ -18,15 +18,6 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjectTypes<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesMapObjectTypes<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesMapObjectTypes<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesMapObjectTypes<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesMapObjectTypes<CSaveFile>(CSaveFile & s);
template void registerTypesMapObjectTypes<CLoadFile>(CLoadFile & s);
template void registerTypesMapObjectTypes<CTypeList>(CTypeList & s);
template void registerTypesMapObjectTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);
template void registerTypesMapObjects1<CISer<CConnection>>(CISer<CConnection>& s); template void registerTypesMapObjects1<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesMapObjects1<COSer<CConnection>>(COSer<CConnection>& s); template void registerTypesMapObjects1<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesMapObjects1<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s); template void registerTypesMapObjects1<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);

View File

@ -0,0 +1,28 @@
#include "StdInc.h"
#include "RegisterTypes.h"
#include "../mapping/CMapInfo.h"
#include "../StartInfo.h"
#include "../BattleState.h"
#include "../CGameState.h"
#include "../mapping/CMap.h"
#include "../CModHandler.h"
#include "../mapObjects/CObjectHandler.h"
#include "../CCreatureHandler.h"
#include "../VCMI_Lib.h"
#include "../CArtHandler.h"
#include "../CHeroHandler.h"
#include "../CSpellHandler.h"
#include "../CTownHandler.h"
#include "../mapping/CCampaignHandler.h"
#include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjectTypes<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesMapObjectTypes<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesMapObjectTypes<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesMapObjectTypes<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesMapObjectTypes<CSaveFile>(CSaveFile & s);
template void registerTypesMapObjectTypes<CLoadFile>(CLoadFile & s);
template void registerTypesMapObjectTypes<CTypeList>(CTypeList & s);
template void registerTypesMapObjectTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -237,7 +237,7 @@ void CMapGenerator::createConnections()
int3 guardPos(-1,-1,-1); int3 guardPos(-1,-1,-1);
auto otherZoneTiles = zoneB->getTileInfo(); auto otherZoneTiles = zoneB->getTileInfo();
auto otherZoneCenter = zoneB->getPos(); //auto otherZoneCenter = zoneB->getPos();
for (auto tile : tiles) for (auto tile : tiles)
{ {

View File

@ -20,9 +20,8 @@
#include "../CSpellHandler.h" //for choosing random spells #include "../CSpellHandler.h" //for choosing random spells
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
//#include "../mapObjects/CGPandoraBox.h" #include "../mapObjects/CGPandoraBox.h"
//#include "../mapObjects/CRewardableObject.h" #include "../mapObjects/CRewardableObject.h"
#include "../mapObjects/MapObjects.h"
class CMap; class CMap;
class CMapEditManager; class CMapEditManager;
@ -125,9 +124,16 @@ void CTileInfo::setTerrainType(ETerrainType value)
terrain = value; terrain = value;
} }
CRmgTemplateZone::CRmgTemplateZone() : id(0), type(ETemplateZoneType::PLAYER_START), size(1), CRmgTemplateZone::CRmgTemplateZone() :
terrainType (ETerrainType::GRASS), townType(0), townsAreSameType(false), matchTerrainToTown(true), totalDensity(0), id(0),
zoneMonsterStrength(EMonsterStrength::ZONE_NORMAL) type(ETemplateZoneType::PLAYER_START),
size(1),
townsAreSameType(false),
matchTerrainToTown(true),
townType(0),
terrainType (ETerrainType::GRASS),
zoneMonsterStrength(EMonsterStrength::ZONE_NORMAL),
totalDensity(0)
{ {
townTypes = getDefaultTownTypes(); townTypes = getDefaultTownTypes();
terrainTypes = getDefaultTerrainTypes(); terrainTypes = getDefaultTerrainTypes();
@ -308,6 +314,11 @@ std::vector<CTreasureInfo> CRmgTemplateZone::getTreasureInfo()
return treasureInfo; return treasureInfo;
} }
std::set<int3>* CRmgTemplateZone::getFreePaths()
{
return &freePaths;
}
float3 CRmgTemplateZone::getCenter() const float3 CRmgTemplateZone::getCenter() const
{ {
return center; return center;
@ -318,6 +329,7 @@ void CRmgTemplateZone::setCenter(const float3 &f)
center = float3 (std::min(std::max(f.x, 0.f), 1.f), std::min(std::max(f.y, 0.f), 1.f), f.z); center = float3 (std::min(std::max(f.x, 0.f), 1.f), std::min(std::max(f.y, 0.f), 1.f), f.z);
} }
bool CRmgTemplateZone::pointIsIn(int x, int y) bool CRmgTemplateZone::pointIsIn(int x, int y)
{ {
return true; return true;
@ -342,11 +354,6 @@ std::set<int3> CRmgTemplateZone::getTileInfo () const
return tileinfo; return tileinfo;
} }
std::set<int3>* CRmgTemplateZone::getFreePaths()
{
return &freePaths;
}
void CRmgTemplateZone::createBorder(CMapGenerator* gen) void CRmgTemplateZone::createBorder(CMapGenerator* gen)
{ {
for (auto tile : tileinfo) for (auto tile : tileinfo)
@ -377,7 +384,7 @@ void CRmgTemplateZone::fractalize(CMapGenerator* gen)
{ {
if (gen->isFree(tile)) if (gen->isFree(tile))
clearedTiles.push_back(tile); clearedTiles.push_back(tile);
else if (gen->isPossible(tile)); else if (gen->isPossible(tile))
possibleTiles.insert(tile); possibleTiles.insert(tile);
} }
if (clearedTiles.empty()) //this should come from zone connections if (clearedTiles.empty()) //this should come from zone connections
@ -660,7 +667,6 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
int3 zoneCenter = getPos(); int3 zoneCenter = getPos();
int3 closestTile = int3(-1,-1,-1); int3 closestTile = int3(-1,-1,-1);
float minDistance = 1e10; float minDistance = 1e10;
for (auto treasure : treasures) for (auto treasure : treasures)
{ {
if (zoneCenter.dist2d(treasure.first) < minDistance) if (zoneCenter.dist2d(treasure.first) < minDistance)
@ -1040,8 +1046,8 @@ bool CRmgTemplateZone::findPlaceForObject(CMapGenerator* gen, CGObjectInstance*
//si32 min_dist = sqrt(tileinfo.size()/density); //si32 min_dist = sqrt(tileinfo.size()/density);
int best_distance = 0; int best_distance = 0;
bool result = false; bool result = false;
si32 w = gen->map->width; //si32 w = gen->map->width;
si32 h = gen->map->height; //si32 h = gen->map->height;
//logGlobal->infoStream() << boost::format("Min dist for density %f is %d") % density % min_dist; //logGlobal->infoStream() << boost::format("Min dist for density %f is %d") % density % min_dist;
@ -1190,9 +1196,8 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object,
for (auto tile : tiles) for (auto tile : tiles)
{ {
//crunching path may fail if center of teh zone is dirrectly over wide object //crunching path may fail if center of teh zone is dirrectly over wide object
if (crunchPath (gen, tile, findClosestTile(freePaths, tile), id, &freePaths)) //required objects will contitute our core free paths if (crunchPath (gen, tile, getPos(), id)) //make sure object is accessible before surrounding it with blocked tiles
{ {
//make sure object is accessible before surrounding it with blocked tiles
guardTile = tile; guardTile = tile;
break; break;
} }
@ -1213,14 +1218,8 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object,
gen->setOccupied (guardTile, ETileType::USED); gen->setOccupied (guardTile, ETileType::USED);
} }
else //make sure no other stuff spawns next to unguarded object else
{ gen->setOccupied (guardTile, ETileType::FREE);
for (auto tile : tiles)
{
if (!gen->isBlocked(tile))
gen->setOccupied (tile, ETileType::FREE);
}
}
return true; return true;
} }
@ -1280,6 +1279,7 @@ ObjectInfo CRmgTemplateZone::getRandomObject (CMapGenerator* gen, ui32 value)
if (r <= t.first) if (r <= t.first)
return t.second; return t.second;
} }
//FIXME: control reaches end of non-void function. Missing return?
} }
void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen) void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)