mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Merge pull request #4025 from IvanSavenko/shared_ptr_lib
[1.6] Use shared_ptr for library entities
This commit is contained in:
commit
5d6470e527
@ -152,8 +152,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
|
|||||||
{
|
{
|
||||||
for(auto & creatureID : creLevel.second)
|
for(auto & creatureID : creLevel.second)
|
||||||
{
|
{
|
||||||
auto creature = VLC->creh->objects[creatureID];
|
if(ai->ah->freeResources().canAfford(creatureID.toCreature()->getFullRecruitCost()))
|
||||||
if(ai->ah->freeResources().canAfford(creature->getFullRecruitCost()))
|
|
||||||
objs.push_back(obj); //TODO: reserve resources?
|
objs.push_back(obj); //TODO: reserve resources?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,6 @@ const IGameSettings * CGameInfo::settings() const
|
|||||||
return globalServices->settings();
|
return globalServices->settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameInfo::updateEntity(Metatype metatype, int32_t index, const JsonNode & data)
|
|
||||||
{
|
|
||||||
logGlobal->error("CGameInfo::updateEntity call is not expected.");
|
|
||||||
}
|
|
||||||
|
|
||||||
spells::effects::Registry * CGameInfo::spellEffects()
|
spells::effects::Registry * CGameInfo::spellEffects()
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -73,8 +73,6 @@ public:
|
|||||||
const ObstacleService * obstacles() const override;
|
const ObstacleService * obstacles() const override;
|
||||||
const IGameSettings * settings() const override;
|
const IGameSettings * settings() const override;
|
||||||
|
|
||||||
void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) override;
|
|
||||||
|
|
||||||
const spells::effects::Registry * spellEffects() const override;
|
const spells::effects::Registry * spellEffects() const override;
|
||||||
spells::effects::Registry * spellEffects() override;
|
spells::effects::Registry * spellEffects() override;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ const CCreature & BattleProjectileController::getShooter(const CStack * stack) c
|
|||||||
if(creature->animation.missleFrameAngles.empty())
|
if(creature->animation.missleFrameAngles.empty())
|
||||||
{
|
{
|
||||||
logAnim->error("Mod error: Creature '%s' on the Archer's tower is not a shooter. Mod should be fixed. Trying to use archer's data instead...", creature->getNameSingularTranslated());
|
logAnim->error("Mod error: Creature '%s' on the Archer's tower is not a shooter. Mod should be fixed. Trying to use archer's data instead...", creature->getNameSingularTranslated());
|
||||||
creature = CGI->creh->objects[CreatureID::ARCHER];
|
creature = CreatureID(CreatureID::ARCHER).toCreature();
|
||||||
}
|
}
|
||||||
|
|
||||||
return *creature;
|
return *creature;
|
||||||
|
@ -188,7 +188,7 @@ BattleSiegeController::BattleSiegeController(BattleInterface & owner, const CGTo
|
|||||||
|
|
||||||
const CCreature *BattleSiegeController::getTurretCreature() const
|
const CCreature *BattleSiegeController::getTurretCreature() const
|
||||||
{
|
{
|
||||||
return CGI->creh->objects[town->town->clientInfo.siegeShooter];
|
return town->town->clientInfo.siegeShooter.toCreature();
|
||||||
}
|
}
|
||||||
|
|
||||||
Point BattleSiegeController::getTurretCreaturePosition( BattleHex position ) const
|
Point BattleSiegeController::getTurretCreaturePosition( BattleHex position ) const
|
||||||
|
@ -446,7 +446,7 @@ int OptionsTab::SelectionWindow::calcLines(FactionID faction)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for(auto & elemh : allowedHeroes)
|
for(auto & elemh : allowedHeroes)
|
||||||
{
|
{
|
||||||
CHero * type = VLC->heroh->objects[elemh];
|
const CHero * type = elemh.toHeroType();
|
||||||
if(type->heroClass->faction == faction)
|
if(type->heroClass->faction == faction)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -603,7 +603,7 @@ void OptionsTab::SelectionWindow::genContentHeroes()
|
|||||||
|
|
||||||
for(auto & elem : allowedHeroes)
|
for(auto & elem : allowedHeroes)
|
||||||
{
|
{
|
||||||
CHero * type = VLC->heroh->objects[elem];
|
const CHero * type = elem.toHeroType();
|
||||||
|
|
||||||
if(type->heroClass->faction == selectedFaction)
|
if(type->heroClass->faction == selectedFaction)
|
||||||
{
|
{
|
||||||
|
@ -114,12 +114,12 @@ RandomMapTab::RandomMapTab():
|
|||||||
GH.windows().createAndPushWindow<TeamAlignments>(*this);
|
GH.windows().createAndPushWindow<TeamAlignments>(*this);
|
||||||
});
|
});
|
||||||
|
|
||||||
for(auto road : VLC->roadTypeHandler->objects)
|
for(const auto & road : VLC->roadTypeHandler->objects)
|
||||||
{
|
{
|
||||||
std::string cbRoadType = "selectRoad_" + road->getJsonKey();
|
std::string cbRoadType = "selectRoad_" + road->getJsonKey();
|
||||||
addCallback(cbRoadType, [&, road](bool on)
|
addCallback(cbRoadType, [&, roadID = road->getId()](bool on)
|
||||||
{
|
{
|
||||||
mapGenOptions->setRoadEnabled(road->getId(), on);
|
mapGenOptions->setRoadEnabled(roadID, on);
|
||||||
updateMapInfoByHost();
|
updateMapInfoByHost();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ void RandomMapTab::setMapGenOptions(std::shared_ptr<CMapGenOptions> opts)
|
|||||||
else
|
else
|
||||||
w->setTextOverlay(readText(variables["randomTemplate"]), EFonts::FONT_SMALL, Colors::WHITE);
|
w->setTextOverlay(readText(variables["randomTemplate"]), EFonts::FONT_SMALL, Colors::WHITE);
|
||||||
}
|
}
|
||||||
for(auto r : VLC->roadTypeHandler->objects)
|
for(const auto & r : VLC->roadTypeHandler->objects)
|
||||||
{
|
{
|
||||||
// Workaround for vcmi-extras bug
|
// Workaround for vcmi-extras bug
|
||||||
std::string jsonKey = r->getJsonKey();
|
std::string jsonKey = r->getJsonKey();
|
||||||
|
@ -222,15 +222,15 @@ std::string CComponent::getDescription() const
|
|||||||
case ComponentType::CREATURE:
|
case ComponentType::CREATURE:
|
||||||
return "";
|
return "";
|
||||||
case ComponentType::ARTIFACT:
|
case ComponentType::ARTIFACT:
|
||||||
return VLC->artifacts()->getById(data.subType.as<ArtifactID>())->getDescriptionTranslated();
|
return CGI->artifacts()->getById(data.subType.as<ArtifactID>())->getDescriptionTranslated();
|
||||||
case ComponentType::SPELL_SCROLL:
|
case ComponentType::SPELL_SCROLL:
|
||||||
{
|
{
|
||||||
auto description = VLC->arth->objects[ArtifactID::SPELL_SCROLL]->getDescriptionTranslated();
|
auto description = ArtifactID(ArtifactID::SPELL_SCROLL).toEntity(CGI)->getDescriptionTranslated();
|
||||||
ArtifactUtils::insertScrrollSpellName(description, data.subType.as<SpellID>());
|
ArtifactUtils::insertScrrollSpellName(description, data.subType.as<SpellID>());
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
case ComponentType::SPELL:
|
case ComponentType::SPELL:
|
||||||
return VLC->spells()->getById(data.subType.as<SpellID>())->getDescriptionTranslated(data.value.value_or(0));
|
return CGI->spells()->getById(data.subType.as<SpellID>())->getDescriptionTranslated(data.value.value_or(0));
|
||||||
case ComponentType::MORALE:
|
case ComponentType::MORALE:
|
||||||
return CGI->generaltexth->heroscrn[ 4 - (data.value.value_or(0)>0) + (data.value.value_or(0)<0)];
|
return CGI->generaltexth->heroscrn[ 4 - (data.value.value_or(0)>0) + (data.value.value_or(0)<0)];
|
||||||
case ComponentType::LUCK:
|
case ComponentType::LUCK:
|
||||||
|
@ -272,7 +272,7 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc
|
|||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
background->colorize(Town->tempOwner);
|
background->colorize(Town->tempOwner);
|
||||||
|
|
||||||
const CCreature * creature = CGI->creh->objects.at(Town->creatures.at(level).second.back());
|
const CCreature * creature = Town->creatures.at(level).second.back().toCreature();
|
||||||
|
|
||||||
title = std::make_shared<CLabel>(80, 30, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, creature->getNamePluralTranslated());
|
title = std::make_shared<CLabel>(80, 30, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, creature->getNamePluralTranslated());
|
||||||
animation = std::make_shared<CCreaturePic>(30, 44, creature, true, true);
|
animation = std::make_shared<CCreaturePic>(30, 44, creature, true, true);
|
||||||
@ -1049,10 +1049,9 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance * Town, int Level, boo
|
|||||||
}
|
}
|
||||||
addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
|
addUsedEvents(LCLICK | SHOW_POPUP | HOVER);
|
||||||
|
|
||||||
ui32 creatureID = town->creatures[level].second.back();
|
CreatureID creatureID = town->creatures[level].second.back();
|
||||||
creature = CGI->creh->objects[creatureID];
|
|
||||||
|
|
||||||
picture = std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), creature->getIconIndex(), 0, 8, 0);
|
picture = std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), creatureID.toEntity(VLC)->getIconIndex(), 0, 8, 0);
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
if(showAvailable)
|
if(showAvailable)
|
||||||
@ -1802,9 +1801,9 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
|
|||||||
const CCreature * CFortScreen::RecruitArea::getMyCreature()
|
const CCreature * CFortScreen::RecruitArea::getMyCreature()
|
||||||
{
|
{
|
||||||
if(!town->creatures.at(level).second.empty()) // built
|
if(!town->creatures.at(level).second.empty()) // built
|
||||||
return VLC->creh->objects[town->creatures.at(level).second.back()];
|
return town->creatures.at(level).second.back().toCreature();
|
||||||
if(!town->town->creatures.at(level).empty()) // there are creatures on this level
|
if(!town->town->creatures.at(level).empty()) // there are creatures on this level
|
||||||
return VLC->creh->objects[town->town->creatures.at(level).front()];
|
return town->town->creatures.at(level).front().toCreature();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1888,7 +1887,7 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner, const ImagePath & i
|
|||||||
for(size_t j=0; j<spellCount; j++)
|
for(size_t j=0; j<spellCount; j++)
|
||||||
{
|
{
|
||||||
if(i<owner->town->mageGuildLevel() && owner->town->spells[i].size()>j)
|
if(i<owner->town->mageGuildLevel() && owner->town->spells[i].size()>j)
|
||||||
spells.push_back(std::make_shared<Scroll>(positions[i][j], CGI->spellh->objects[owner->town->spells[i][j]]));
|
spells.push_back(std::make_shared<Scroll>(positions[i][j], owner->town->spells[i][j].toSpell()));
|
||||||
else
|
else
|
||||||
emptyScrolls.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("TPMAGES.DEF"), 1, 0, positions[i][j].x, positions[i][j].y));
|
emptyScrolls.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("TPMAGES.DEF"), 1, 0, positions[i][j].x, positions[i][j].y));
|
||||||
}
|
}
|
||||||
@ -1938,7 +1937,7 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, Art
|
|||||||
animBG = std::make_shared<CPicture>(ImagePath::builtin("TPSMITBK"), 64, 50);
|
animBG = std::make_shared<CPicture>(ImagePath::builtin("TPSMITBK"), 64, 50);
|
||||||
animBG->needRefresh = true;
|
animBG->needRefresh = true;
|
||||||
|
|
||||||
const CCreature * creature = CGI->creh->objects[creMachineID];
|
const CCreature * creature = creMachineID.toCreature();
|
||||||
anim = std::make_shared<CCreatureAnim>(64, 50, creature->animDefName);
|
anim = std::make_shared<CCreatureAnim>(64, 50, creature->animDefName);
|
||||||
anim->clipRect(113,125,200,150);
|
anim->clipRect(113,125,200,150);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void CHeroOverview::genControls()
|
|||||||
r = Rect(302, 3 * borderOffset + yOffset + 62, 292, 32);
|
r = Rect(302, 3 * borderOffset + yOffset + 62, 292, 32);
|
||||||
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
backgroundRectangles.push_back(std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor));
|
||||||
|
|
||||||
auto stacksCountChances = VLC->settings()->getVector(EGameSettings::HEROES_STARTING_STACKS_CHANCES);
|
auto stacksCountChances = CGI->settings()->getVector(EGameSettings::HEROES_STARTING_STACKS_CHANCES);
|
||||||
|
|
||||||
// army
|
// army
|
||||||
int space = (260 - 7 * 32) / 6;
|
int space = (260 - 7 * 32) / 6;
|
||||||
|
@ -290,11 +290,11 @@ void CSpellWindow::processSpells()
|
|||||||
|
|
||||||
//initializing castable spells
|
//initializing castable spells
|
||||||
mySpells.reserve(CGI->spellh->objects.size());
|
mySpells.reserve(CGI->spellh->objects.size());
|
||||||
for(const CSpell * spell : CGI->spellh->objects)
|
for(auto const & spell : CGI->spellh->objects)
|
||||||
{
|
{
|
||||||
bool searchTextFound = !searchBox || boost::algorithm::contains(boost::algorithm::to_lower_copy(spell->getNameTranslated()), boost::algorithm::to_lower_copy(searchBox->getText()));
|
bool searchTextFound = !searchBox || boost::algorithm::contains(boost::algorithm::to_lower_copy(spell->getNameTranslated()), boost::algorithm::to_lower_copy(searchBox->getText()));
|
||||||
if(!spell->isCreatureAbility() && myHero->canCastThisSpell(spell) && searchTextFound)
|
if(!spell->isCreatureAbility() && myHero->canCastThisSpell(spell.get()) && searchTextFound)
|
||||||
mySpells.push_back(spell);
|
mySpells.push_back(spell.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
SpellbookSpellSorter spellsorter;
|
SpellbookSpellSorter spellsorter;
|
||||||
|
@ -261,7 +261,7 @@ void CRecruitmentWindow::availableCreaturesChanged()
|
|||||||
|
|
||||||
//create new cards
|
//create new cards
|
||||||
for(auto & creature : boost::adaptors::reverse(dwelling->creatures[i].second))
|
for(auto & creature : boost::adaptors::reverse(dwelling->creatures[i].second))
|
||||||
cards.push_back(std::make_shared<CCreatureCard>(this, CGI->creh->objects[creature], amount));
|
cards.push_back(std::make_shared<CCreatureCard>(this, creature.toCreature(), amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int creatureWidth = 102;
|
const int creatureWidth = 102;
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
virtual bool isNativeTerrain(TerrainId terrain) const;
|
virtual bool isNativeTerrain(TerrainId terrain) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE Entity
|
class DLL_LINKAGE Entity : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using IconRegistar = std::function<void(int32_t index, int32_t group, const std::string & listName, const std::string & imageName)>;
|
using IconRegistar = std::function<void(int32_t index, int32_t group, const std::string & listName, const std::string & imageName)>;
|
||||||
|
@ -61,8 +61,6 @@ public:
|
|||||||
virtual const ObstacleService * obstacles() const = 0;
|
virtual const ObstacleService * obstacles() const = 0;
|
||||||
virtual const IGameSettings * settings() const = 0;
|
virtual const IGameSettings * settings() const = 0;
|
||||||
|
|
||||||
virtual void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) = 0;
|
|
||||||
|
|
||||||
virtual const spells::effects::Registry * spellEffects() const = 0;
|
virtual const spells::effects::Registry * spellEffects() const = 0;
|
||||||
virtual spells::effects::Registry * spellEffects() = 0;
|
virtual spells::effects::Registry * spellEffects() = 0;
|
||||||
//TODO: put map object types registry access here
|
//TODO: put map object types registry access here
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
BattleFieldInfo * BattleFieldHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
std::shared_ptr<BattleFieldInfo> BattleFieldHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
|
|
||||||
auto * info = new BattleFieldInfo(BattleField(index), identifier);
|
auto info = std::make_shared<BattleFieldInfo>(BattleField(index), identifier);
|
||||||
|
|
||||||
info->modScope = scope;
|
info->modScope = scope;
|
||||||
info->graphics = ImagePath::fromJson(json["graphics"]);
|
info->graphics = ImagePath::fromJson(json["graphics"]);
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
class BattleFieldHandler : public CHandlerBase<BattleField, BattleFieldInfo, BattleFieldInfo, BattleFieldService>
|
class BattleFieldHandler : public CHandlerBase<BattleField, BattleFieldInfo, BattleFieldInfo, BattleFieldService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual BattleFieldInfo * loadFromJson(
|
std::shared_ptr<BattleFieldInfo> loadFromJson(
|
||||||
const std::string & scope,
|
const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
|
@ -373,7 +373,7 @@ std::vector<JsonNode> CArtHandler::loadLegacyData()
|
|||||||
|
|
||||||
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
||||||
{
|
{
|
||||||
auto * object = loadFromJson(scope, data, name, objects.size());
|
auto object = loadFromJson(scope, data, name, objects.size());
|
||||||
|
|
||||||
object->iconIndex = object->getIndex() + 5;
|
object->iconIndex = object->getIndex() + 5;
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode
|
|||||||
|
|
||||||
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
||||||
{
|
{
|
||||||
auto * object = loadFromJson(scope, data, name, index);
|
auto object = loadFromJson(scope, data, name, index);
|
||||||
|
|
||||||
object->iconIndex = object->getIndex();
|
object->iconIndex = object->getIndex();
|
||||||
|
|
||||||
@ -400,12 +400,12 @@ const std::vector<std::string> & CArtHandler::getTypeNames() const
|
|||||||
return typeNames;
|
return typeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
CArtifact * CArtHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
std::shared_ptr<CArtifact> CArtHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
assert(!scope.empty());
|
assert(!scope.empty());
|
||||||
|
|
||||||
CArtifact * art = new CArtifact();
|
auto art = std::make_shared<CArtifact>();
|
||||||
if(!node["growing"].isNull())
|
if(!node["growing"].isNull())
|
||||||
{
|
{
|
||||||
for(auto bonus : node["growing"]["bonusesPerLevel"].Vector())
|
for(auto bonus : node["growing"]["bonusesPerLevel"].Vector())
|
||||||
@ -442,10 +442,10 @@ CArtifact * CArtHandler::loadFromJson(const std::string & scope, const JsonNode
|
|||||||
art->price = static_cast<ui32>(node["value"].Float());
|
art->price = static_cast<ui32>(node["value"].Float());
|
||||||
art->onlyOnWaterMap = node["onlyOnWaterMap"].Bool();
|
art->onlyOnWaterMap = node["onlyOnWaterMap"].Bool();
|
||||||
|
|
||||||
loadSlots(art, node);
|
loadSlots(art.get(), node);
|
||||||
loadClass(art, node);
|
loadClass(art.get(), node);
|
||||||
loadType(art, node);
|
loadType(art.get(), node);
|
||||||
loadComponents(art, node);
|
loadComponents(art.get(), node);
|
||||||
|
|
||||||
for(const auto & b : node["bonuses"].Vector())
|
for(const auto & b : node["bonuses"].Vector())
|
||||||
{
|
{
|
||||||
@ -663,7 +663,7 @@ std::set<ArtifactID> CArtHandler::getDefaultAllowed() const
|
|||||||
{
|
{
|
||||||
std::set<ArtifactID> allowedArtifacts;
|
std::set<ArtifactID> allowedArtifacts;
|
||||||
|
|
||||||
for (auto artifact : objects)
|
for (const auto & artifact : objects)
|
||||||
{
|
{
|
||||||
if (!artifact->isCombined())
|
if (!artifact->isCombined())
|
||||||
allowedArtifacts.insert(artifact->getId());
|
allowedArtifacts.insert(artifact->getId());
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "bonuses/Bonus.h"
|
#include "bonuses/Bonus.h"
|
||||||
#include "bonuses/CBonusSystemNode.h"
|
#include "bonuses/CBonusSystemNode.h"
|
||||||
|
#include "ConstTransitivePtr.h"
|
||||||
#include "GameConstants.h"
|
#include "GameConstants.h"
|
||||||
#include "IHandlerBase.h"
|
#include "IHandlerBase.h"
|
||||||
#include "serializer/Serializeable.h"
|
#include "serializer/Serializeable.h"
|
||||||
@ -163,7 +164,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CArtifact * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CArtifact> loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addSlot(CArtifact * art, const std::string & slotID) const;
|
void addSlot(CArtifact * art, const std::string & slotID) const;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "CGeneralTextHandler.h"
|
#include "CGeneralTextHandler.h"
|
||||||
#include "json/JsonUtils.h"
|
#include "json/JsonUtils.h"
|
||||||
#include "spells/CSpellHandler.h"
|
#include "spells/CSpellHandler.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
|
template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
|
||||||
|
|
||||||
|
@ -587,12 +587,12 @@ std::vector<JsonNode> CCreatureHandler::loadLegacyData()
|
|||||||
return h3Data;
|
return h3Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
std::shared_ptr<CCreature> CCreatureHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
assert(!scope.empty());
|
assert(!scope.empty());
|
||||||
|
|
||||||
auto * cre = new CCreature();
|
auto cre = std::make_shared<CCreature>();
|
||||||
|
|
||||||
if(node["hasDoubleWeek"].Bool())
|
if(node["hasDoubleWeek"].Bool())
|
||||||
{
|
{
|
||||||
@ -635,9 +635,9 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json
|
|||||||
if(!node["shots"].isNull())
|
if(!node["shots"].isNull())
|
||||||
cre->addBonus(node["shots"].Integer(), BonusType::SHOTS);
|
cre->addBonus(node["shots"].Integer(), BonusType::SHOTS);
|
||||||
|
|
||||||
loadStackExperience(cre, node["stackExperience"]);
|
loadStackExperience(cre.get(), node["stackExperience"]);
|
||||||
loadJsonAnimation(cre, node["graphics"]);
|
loadJsonAnimation(cre.get(), node["graphics"]);
|
||||||
loadCreatureJson(cre, node);
|
loadCreatureJson(cre.get(), node);
|
||||||
|
|
||||||
for(const auto & extraName : node["extraNames"].Vector())
|
for(const auto & extraName : node["extraNames"].Vector())
|
||||||
{
|
{
|
||||||
|
@ -209,7 +209,7 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CCreature * loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CCreature> loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::set<CreatureID> doubledCreatures; //they get double week
|
std::set<CreatureID> doubledCreatures; //they get double week
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "CArtHandler.h"
|
#include "CArtHandler.h"
|
||||||
#include "CArtifactInstance.h"
|
#include "CArtifactInstance.h"
|
||||||
#include "CCreatureHandler.h"
|
#include "CCreatureHandler.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
#include <vcmi/Entity.h>
|
#include <vcmi/Entity.h>
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
|
|||||||
int maxAIValue = 0;
|
int maxAIValue = 0;
|
||||||
const CCreature * mostStrong = nullptr;
|
const CCreature * mostStrong = nullptr;
|
||||||
|
|
||||||
for(auto creature : VLC->creh->objects)
|
for(const auto & creature : VLC->creh->objects)
|
||||||
{
|
{
|
||||||
if(creature->getFaction() == factionIndex && static_cast<int>(creature->getAIValue()) > maxAIValue)
|
if(creature->getFaction() == factionIndex && static_cast<int>(creature->getAIValue()) > maxAIValue)
|
||||||
{
|
{
|
||||||
|
@ -247,14 +247,14 @@ const std::vector<std::string> & CHeroClassHandler::getTypeNames() const
|
|||||||
return typeNames;
|
return typeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
std::shared_ptr<CHeroClass> CHeroClassHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
assert(!scope.empty());
|
assert(!scope.empty());
|
||||||
|
|
||||||
std::string affinityStr[2] = { "might", "magic" };
|
std::string affinityStr[2] = { "might", "magic" };
|
||||||
|
|
||||||
auto * heroClass = new CHeroClass();
|
auto heroClass = std::make_shared<CHeroClass>();
|
||||||
|
|
||||||
heroClass->id = HeroClassID(index);
|
heroClass->id = HeroClassID(index);
|
||||||
heroClass->identifier = identifier;
|
heroClass->identifier = identifier;
|
||||||
@ -277,10 +277,10 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
|
|||||||
heroClass->affinity = CHeroClass::MIGHT;
|
heroClass->affinity = CHeroClass::MIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillPrimarySkillData(node, heroClass, PrimarySkill::ATTACK);
|
fillPrimarySkillData(node, heroClass.get(), PrimarySkill::ATTACK);
|
||||||
fillPrimarySkillData(node, heroClass, PrimarySkill::DEFENSE);
|
fillPrimarySkillData(node, heroClass.get(), PrimarySkill::DEFENSE);
|
||||||
fillPrimarySkillData(node, heroClass, PrimarySkill::SPELL_POWER);
|
fillPrimarySkillData(node, heroClass.get(), PrimarySkill::SPELL_POWER);
|
||||||
fillPrimarySkillData(node, heroClass, PrimarySkill::KNOWLEDGE);
|
fillPrimarySkillData(node, heroClass.get(), PrimarySkill::KNOWLEDGE);
|
||||||
|
|
||||||
auto percentSumm = std::accumulate(heroClass->primarySkillLowLevel.begin(), heroClass->primarySkillLowLevel.end(), 0);
|
auto percentSumm = std::accumulate(heroClass->primarySkillLowLevel.begin(), heroClass->primarySkillLowLevel.end(), 0);
|
||||||
if(percentSumm <= 0)
|
if(percentSumm <= 0)
|
||||||
@ -432,12 +432,12 @@ const std::vector<std::string> & CHeroHandler::getTypeNames() const
|
|||||||
return typeNames;
|
return typeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHero * CHeroHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
std::shared_ptr<CHero> CHeroHandler::loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
assert(!scope.empty());
|
assert(!scope.empty());
|
||||||
|
|
||||||
auto * hero = new CHero();
|
auto hero = std::make_shared<CHero>();
|
||||||
hero->ID = HeroTypeID(index);
|
hero->ID = HeroTypeID(index);
|
||||||
hero->identifier = identifier;
|
hero->identifier = identifier;
|
||||||
hero->modScope = scope;
|
hero->modScope = scope;
|
||||||
@ -459,9 +459,9 @@ CHero * CHeroHandler::loadFromJson(const std::string & scope, const JsonNode & n
|
|||||||
hero->portraitLarge = node["images"]["large"].String();
|
hero->portraitLarge = node["images"]["large"].String();
|
||||||
hero->battleImage = AnimationPath::fromJson(node["battleImage"]);
|
hero->battleImage = AnimationPath::fromJson(node["battleImage"]);
|
||||||
|
|
||||||
loadHeroArmy(hero, node);
|
loadHeroArmy(hero.get(), node);
|
||||||
loadHeroSkills(hero, node);
|
loadHeroSkills(hero.get(), node);
|
||||||
loadHeroSpecialty(hero, node);
|
loadHeroSpecialty(hero.get(), node);
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier("heroClass", node["class"],
|
VLC->identifiers()->requestIdentifier("heroClass", node["class"],
|
||||||
[=](si32 classID)
|
[=](si32 classID)
|
||||||
@ -753,7 +753,7 @@ void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
{
|
{
|
||||||
size_t index = objects.size();
|
size_t index = objects.size();
|
||||||
static const int specialFramesCount = 2; // reserved for 2 special frames
|
static const int specialFramesCount = 2; // reserved for 2 special frames
|
||||||
auto * object = loadFromJson(scope, data, name, index);
|
auto object = loadFromJson(scope, data, name, index);
|
||||||
object->imageIndex = static_cast<si32>(index) + specialFramesCount;
|
object->imageIndex = static_cast<si32>(index) + specialFramesCount;
|
||||||
|
|
||||||
objects.emplace_back(object);
|
objects.emplace_back(object);
|
||||||
@ -766,7 +766,7 @@ void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
|
|
||||||
void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
||||||
{
|
{
|
||||||
auto * object = loadFromJson(scope, data, name, index);
|
auto object = loadFromJson(scope, data, name, index);
|
||||||
object->imageIndex = static_cast<si32>(index);
|
object->imageIndex = static_cast<si32>(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
|
||||||
|
@ -171,7 +171,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CHeroClass * loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CHeroClass> loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CHero * loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CHero> loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "modding/ModUtility.h"
|
#include "modding/ModUtility.h"
|
||||||
#include "modding/ModScope.h"
|
#include "modding/ModScope.h"
|
||||||
#include "constants/StringConstants.h"
|
#include "constants/StringConstants.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ const std::vector<std::string> & CSkillHandler::getTypeNames() const
|
|||||||
return typeNames;
|
return typeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSkill * CSkillHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
std::shared_ptr<CSkill> CSkillHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
assert(!scope.empty());
|
assert(!scope.empty());
|
||||||
@ -199,7 +200,7 @@ CSkill * CSkillHandler::loadFromJson(const std::string & scope, const JsonNode &
|
|||||||
|
|
||||||
major = json["obligatoryMajor"].Bool();
|
major = json["obligatoryMajor"].Bool();
|
||||||
minor = json["obligatoryMinor"].Bool();
|
minor = json["obligatoryMinor"].Bool();
|
||||||
auto * skill = new CSkill(SecondarySkill((si32)index), identifier, major, minor);
|
auto skill = std::make_shared<CSkill>(SecondarySkill((si32)index), identifier, major, minor);
|
||||||
skill->modScope = scope;
|
skill->modScope = scope;
|
||||||
|
|
||||||
skill->onlyOnWaterMap = json["onlyOnWaterMap"].Bool();
|
skill->onlyOnWaterMap = json["onlyOnWaterMap"].Bool();
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CSkill * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CSkill> loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -1036,11 +1036,11 @@ void CTownHandler::loadPuzzle(CFaction &faction, const JsonNode &source) const
|
|||||||
assert(faction.puzzleMap.size() == GameConstants::PUZZLE_MAP_PIECES);
|
assert(faction.puzzleMap.size() == GameConstants::PUZZLE_MAP_PIECES);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode & source, const std::string & identifier, size_t index)
|
std::shared_ptr<CFaction> CTownHandler::loadFromJson(const std::string & scope, const JsonNode & source, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
|
|
||||||
auto * faction = new CFaction();
|
auto faction = std::make_shared<CFaction>();
|
||||||
|
|
||||||
faction->index = static_cast<FactionID>(index);
|
faction->index = static_cast<FactionID>(index);
|
||||||
faction->modScope = scope;
|
faction->modScope = scope;
|
||||||
@ -1091,7 +1091,7 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
|
|||||||
if (!source["town"].isNull())
|
if (!source["town"].isNull())
|
||||||
{
|
{
|
||||||
faction->town = new CTown();
|
faction->town = new CTown();
|
||||||
faction->town->faction = faction;
|
faction->town->faction = faction.get();
|
||||||
loadTown(faction->town, source["town"]);
|
loadTown(faction->town, source["town"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1105,7 +1105,7 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
|
|||||||
|
|
||||||
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
||||||
{
|
{
|
||||||
auto * object = loadFromJson(scope, data, name, objects.size());
|
auto object = loadFromJson(scope, data, name, objects.size());
|
||||||
|
|
||||||
objects.emplace_back(object);
|
objects.emplace_back(object);
|
||||||
|
|
||||||
@ -1144,7 +1144,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
|
|
||||||
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
||||||
{
|
{
|
||||||
auto * object = loadFromJson(scope, data, name, index);
|
auto object = loadFromJson(scope, data, name, index);
|
||||||
|
|
||||||
if (objects.size() > index)
|
if (objects.size() > 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
|
||||||
@ -1260,7 +1260,7 @@ std::set<FactionID> CTownHandler::getDefaultAllowed() const
|
|||||||
{
|
{
|
||||||
std::set<FactionID> allowedFactions;
|
std::set<FactionID> allowedFactions;
|
||||||
|
|
||||||
for(auto town : objects)
|
for(const auto & town : objects)
|
||||||
if (town->town != nullptr && !town->special)
|
if (town->town != nullptr && !town->special)
|
||||||
allowedFactions.insert(town->getId());
|
allowedFactions.insert(town->getId());
|
||||||
|
|
||||||
@ -1273,7 +1273,7 @@ std::set<FactionID> CTownHandler::getAllowedFactions(bool withTown) const
|
|||||||
return getDefaultAllowed();
|
return getDefaultAllowed();
|
||||||
|
|
||||||
std::set<FactionID> result;
|
std::set<FactionID> result;
|
||||||
for(auto town : objects)
|
for(const auto & town : objects)
|
||||||
result.insert(town->getId());
|
result.insert(town->getId());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -352,7 +352,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CFaction * loadFromJson(const std::string & scope, const JsonNode & data, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CFaction> loadFromJson(const std::string & scope, const JsonNode & data, const std::string & identifier, size_t index) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "modding/IdentifierStorage.h"
|
#include "modding/IdentifierStorage.h"
|
||||||
#include "modding/ModScope.h"
|
#include "modding/ModScope.h"
|
||||||
#include "modding/CModHandler.h"
|
#include "modding/CModHandler.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../lib/ConstTransitivePtr.h"
|
|
||||||
#include "VCMI_Lib.h"
|
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class JsonNode;
|
class JsonNode;
|
||||||
@ -60,13 +57,7 @@ template <class _ObjectID, class _ObjectBase, class _Object, class _ServiceBase>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~CHandlerBase()
|
using ObjectPtr = std::shared_ptr<_Object>;
|
||||||
{
|
|
||||||
for(auto & o : objects)
|
|
||||||
{
|
|
||||||
o.dellNull();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Entity * getBaseByIndex(const int32_t index) const override
|
const Entity * getBaseByIndex(const int32_t index) const override
|
||||||
{
|
{
|
||||||
@ -95,23 +86,19 @@ public:
|
|||||||
|
|
||||||
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 object = loadFromJson(scope, data, name, objects.size());
|
objects.push_back(loadFromJson(scope, data, name, objects.size()));
|
||||||
|
|
||||||
objects.push_back(object);
|
|
||||||
|
|
||||||
for(const auto & type_name : getTypeNames())
|
for(const auto & type_name : getTypeNames())
|
||||||
registerObject(scope, type_name, name, object->getIndex());
|
registerObject(scope, type_name, name, objects.back()->getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
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 object = loadFromJson(scope, data, name, 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] = loadFromJson(scope, data, name, index);
|
||||||
|
|
||||||
for(const auto & type_name : getTypeNames())
|
for(const auto & type_name : getTypeNames())
|
||||||
registerObject(scope, type_name, name, object->getIndex());
|
registerObject(scope, type_name, name, objects[index]->getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
const _Object * operator[] (const _ObjectID id) const
|
const _Object * operator[] (const _ObjectID id) const
|
||||||
@ -124,25 +111,13 @@ public:
|
|||||||
return getObjectImpl(index);
|
return getObjectImpl(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateEntity(int32_t index, const JsonNode & data)
|
|
||||||
{
|
|
||||||
if(index < 0 || index >= objects.size())
|
|
||||||
{
|
|
||||||
logMod->error("%s id %d is invalid", getTypeNames()[0], index);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
objects.at(index)->updateFrom(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const
|
size_t size() const
|
||||||
{
|
{
|
||||||
return objects.size();
|
return objects.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual _Object * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) = 0;
|
virtual ObjectPtr loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) = 0;
|
||||||
virtual const std::vector<std::string> & getTypeNames() const = 0;
|
virtual const std::vector<std::string> & getTypeNames() const = 0;
|
||||||
|
|
||||||
template<typename ItemType>
|
template<typename ItemType>
|
||||||
@ -159,7 +134,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public: //todo: make private
|
public: //todo: make private
|
||||||
std::vector<ConstTransitivePtr<_Object>> objects;
|
std::vector<ObjectPtr> objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "BattleFieldHandler.h"
|
#include "BattleFieldHandler.h"
|
||||||
#include "json/JsonNode.h"
|
#include "json/JsonNode.h"
|
||||||
#include "modding/IdentifierStorage.h"
|
#include "modding/IdentifierStorage.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -84,11 +85,11 @@ bool ObstacleInfo::isAppropriate(const TerrainId terrainType, const BattleField
|
|||||||
return vstd::contains(allowedTerrains, terrainType);
|
return vstd::contains(allowedTerrains, terrainType);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObstacleInfo * ObstacleHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
std::shared_ptr<ObstacleInfo> ObstacleHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
|
|
||||||
auto * info = new ObstacleInfo(Obstacle(index), identifier);
|
auto info = std::make_shared<ObstacleInfo>(Obstacle(index), identifier);
|
||||||
|
|
||||||
info->animation = AnimationPath::fromJson(json["animation"]);
|
info->animation = AnimationPath::fromJson(json["animation"]);
|
||||||
info->width = json["width"].Integer();
|
info->width = json["width"].Integer();
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
class ObstacleHandler: public CHandlerBase<Obstacle, ObstacleInfo, ObstacleInfo, ObstacleService>
|
class ObstacleHandler: public CHandlerBase<Obstacle, ObstacleInfo, ObstacleInfo, ObstacleService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObstacleInfo * loadFromJson(const std::string & scope,
|
std::shared_ptr<ObstacleInfo> loadFromJson(const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
size_t index) override;
|
size_t index) override;
|
||||||
|
@ -13,17 +13,18 @@
|
|||||||
#include "CGeneralTextHandler.h"
|
#include "CGeneralTextHandler.h"
|
||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
#include "json/JsonNode.h"
|
#include "json/JsonNode.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
RiverTypeHandler::RiverTypeHandler()
|
RiverTypeHandler::RiverTypeHandler()
|
||||||
{
|
{
|
||||||
objects.push_back(new RiverType());
|
objects.emplace_back(new RiverType());
|
||||||
|
|
||||||
VLC->generaltexth->registerString("core", objects[0]->getNameTextID(), "");
|
VLC->generaltexth->registerString("core", objects[0]->getNameTextID(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
RiverType * RiverTypeHandler::loadFromJson(
|
std::shared_ptr<RiverType> RiverTypeHandler::loadFromJson(
|
||||||
const std::string & scope,
|
const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
@ -31,7 +32,7 @@ RiverType * RiverTypeHandler::loadFromJson(
|
|||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
|
|
||||||
auto * info = new RiverType;
|
auto info = std::make_shared<RiverType>();
|
||||||
|
|
||||||
info->id = RiverId(index);
|
info->id = RiverId(index);
|
||||||
info->identifier = identifier;
|
info->identifier = identifier;
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
class DLL_LINKAGE RiverTypeHandler : public CHandlerBase<RiverId, RiverType, RiverType, RiverTypeService>
|
class DLL_LINKAGE RiverTypeHandler : public CHandlerBase<RiverId, RiverType, RiverType, RiverTypeService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual RiverType * loadFromJson(
|
std::shared_ptr<RiverType> loadFromJson(
|
||||||
const std::string & scope,
|
const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
|
@ -13,17 +13,18 @@
|
|||||||
#include "CGeneralTextHandler.h"
|
#include "CGeneralTextHandler.h"
|
||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
#include "json/JsonNode.h"
|
#include "json/JsonNode.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
RoadTypeHandler::RoadTypeHandler()
|
RoadTypeHandler::RoadTypeHandler()
|
||||||
{
|
{
|
||||||
objects.push_back(new RoadType());
|
objects.emplace_back(new RoadType());
|
||||||
|
|
||||||
VLC->generaltexth->registerString("core", objects[0]->getNameTextID(), "");
|
VLC->generaltexth->registerString("core", objects[0]->getNameTextID(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
RoadType * RoadTypeHandler::loadFromJson(
|
std::shared_ptr<RoadType> RoadTypeHandler::loadFromJson(
|
||||||
const std::string & scope,
|
const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
@ -31,7 +32,7 @@ RoadType * RoadTypeHandler::loadFromJson(
|
|||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
|
|
||||||
auto * info = new RoadType;
|
auto info = std::make_shared<RoadType>();
|
||||||
|
|
||||||
info->id = RoadId(index);
|
info->id = RoadId(index);
|
||||||
info->identifier = identifier;
|
info->identifier = identifier;
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
class DLL_LINKAGE RoadTypeHandler : public CHandlerBase<RoadId, RoadType, RoadType, RoadTypeService>
|
class DLL_LINKAGE RoadTypeHandler : public CHandlerBase<RoadId, RoadType, RoadType, RoadTypeService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual RoadType * loadFromJson(
|
std::shared_ptr<RoadType> loadFromJson(
|
||||||
const std::string & scope,
|
const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
|
@ -14,14 +14,15 @@
|
|||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
#include "json/JsonNode.h"
|
#include "json/JsonNode.h"
|
||||||
#include "modding/IdentifierStorage.h"
|
#include "modding/IdentifierStorage.h"
|
||||||
|
#include "VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
TerrainType * TerrainTypeHandler::loadFromJson( const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
std::shared_ptr<TerrainType> TerrainTypeHandler::loadFromJson( const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
|
|
||||||
auto * info = new TerrainType;
|
auto info = std::make_shared<TerrainType>();
|
||||||
|
|
||||||
info->id = TerrainId(index);
|
info->id = TerrainId(index);
|
||||||
info->identifier = identifier;
|
info->identifier = identifier;
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
class DLL_LINKAGE TerrainTypeHandler : public CHandlerBase<TerrainId, TerrainType, TerrainType, TerrainTypeService>
|
class DLL_LINKAGE TerrainTypeHandler : public CHandlerBase<TerrainId, TerrainType, TerrainType, TerrainTypeService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual TerrainType * loadFromJson(
|
std::shared_ptr<TerrainType> loadFromJson(
|
||||||
const std::string & scope,
|
const std::string & scope,
|
||||||
const JsonNode & json,
|
const JsonNode & json,
|
||||||
const std::string & identifier,
|
const std::string & identifier,
|
||||||
|
@ -141,37 +141,6 @@ const IGameSettings * LibClasses::settings() const
|
|||||||
return settingsHandler.get();
|
return settingsHandler.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibClasses::updateEntity(Metatype metatype, int32_t index, const JsonNode & data)
|
|
||||||
{
|
|
||||||
switch(metatype)
|
|
||||||
{
|
|
||||||
case Metatype::ARTIFACT:
|
|
||||||
arth->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
case Metatype::CREATURE:
|
|
||||||
creh->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
case Metatype::FACTION:
|
|
||||||
townh->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
case Metatype::HERO_CLASS:
|
|
||||||
heroclassesh->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
case Metatype::HERO_TYPE:
|
|
||||||
heroh->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
case Metatype::SKILL:
|
|
||||||
skillh->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
case Metatype::SPELL:
|
|
||||||
spellh->updateEntity(index, data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logGlobal->error("Invalid Metatype id %d", static_cast<int32_t>(metatype));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LibClasses::loadFilesystem(bool extractArchives)
|
void LibClasses::loadFilesystem(bool extractArchives)
|
||||||
{
|
{
|
||||||
CStopWatch loadTime;
|
CStopWatch loadTime;
|
||||||
|
@ -72,8 +72,6 @@ public:
|
|||||||
const ObstacleService * obstacles() const override;
|
const ObstacleService * obstacles() const override;
|
||||||
const IGameSettings * settings() const override;
|
const IGameSettings * settings() const override;
|
||||||
|
|
||||||
void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) override;
|
|
||||||
|
|
||||||
const spells::effects::Registry * spellEffects() const override;
|
const spells::effects::Registry * spellEffects() const override;
|
||||||
spells::effects::Registry * spellEffects() override;
|
spells::effects::Registry * spellEffects() override;
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ SpellID CObstacleInstance::getTrigger() const
|
|||||||
|
|
||||||
void CObstacleInstance::serializeJson(JsonSerializeFormat & handler)
|
void CObstacleInstance::serializeJson(JsonSerializeFormat & handler)
|
||||||
{
|
{
|
||||||
auto obstacleInfo = getInfo();
|
|
||||||
auto hidden = false;
|
auto hidden = false;
|
||||||
auto needAnimationOffsetFix = obstacleType == CObstacleInstance::USUAL;
|
auto needAnimationOffsetFix = obstacleType == CObstacleInstance::USUAL;
|
||||||
int animationYOffset = 0;
|
int animationYOffset = 0;
|
||||||
@ -117,11 +116,7 @@ void CObstacleInstance::serializeJson(JsonSerializeFormat & handler)
|
|||||||
|
|
||||||
//We need only a subset of obstacle info for correct render
|
//We need only a subset of obstacle info for correct render
|
||||||
handler.serializeInt("position", pos);
|
handler.serializeInt("position", pos);
|
||||||
handler.serializeStruct("appearSound", obstacleInfo.appearSound);
|
|
||||||
handler.serializeStruct("appearAnimation", obstacleInfo.appearAnimation);
|
|
||||||
handler.serializeStruct("animation", obstacleInfo.animation);
|
|
||||||
handler.serializeInt("animationYOffset", animationYOffset);
|
handler.serializeInt("animationYOffset", animationYOffset);
|
||||||
|
|
||||||
handler.serializeBool("hidden", hidden);
|
handler.serializeBool("hidden", hidden);
|
||||||
handler.serializeBool("needAnimationOffsetFix", needAnimationOffsetFix);
|
handler.serializeBool("needAnimationOffsetFix", needAnimationOffsetFix);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ void CGameState::updateEntity(Metatype metatype, int32_t index, const JsonNode &
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
services->updateEntity(metatype, index, data);
|
logGlobal->error("This metatype update is not implemented");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../modding/IdentifierStorage.h"
|
#include "../modding/IdentifierStorage.h"
|
||||||
#include "../constants/StringConstants.h"
|
#include "../constants/StringConstants.h"
|
||||||
#include "../TerrainHandler.h"
|
#include "../TerrainHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "../CRandomGenerator.h"
|
#include "../CRandomGenerator.h"
|
||||||
#include "../RoadHandler.h"
|
#include "../RoadHandler.h"
|
||||||
#include "../RiverHandler.h"
|
#include "../RiverHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "../filesystem/Filesystem.h"
|
#include "../filesystem/Filesystem.h"
|
||||||
#include "../TerrainHandler.h"
|
#include "../TerrainHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
#include "CMap.h"
|
#include "CMap.h"
|
||||||
#include "CMapOperation.h"
|
#include "CMapOperation.h"
|
||||||
|
|
||||||
|
@ -296,9 +296,9 @@ void CMapFormatJson::serializeAllowedFactions(JsonSerializeFormat & handler, std
|
|||||||
|
|
||||||
if(handler.saving)
|
if(handler.saving)
|
||||||
{
|
{
|
||||||
for(auto faction : VLC->townh->objects)
|
for(auto const factionID : VLC->townh->getDefaultAllowed())
|
||||||
if(faction->town && vstd::contains(value, faction->getId()))
|
if(vstd::contains(value, factionID))
|
||||||
temp.insert(faction->getId());
|
temp.insert(factionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.serializeLIC("allowedFactions", &FactionID::decode, &FactionID::encode, VLC->townh->getDefaultAllowed(), temp);
|
handler.serializeLIC("allowedFactions", &FactionID::decode, &FactionID::encode, VLC->townh->getDefaultAllowed(), temp);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "../mapObjects/CGObjectInstance.h"
|
#include "../mapObjects/CGObjectInstance.h"
|
||||||
#include "../mapObjects/ObjectTemplate.h"
|
#include "../mapObjects/ObjectTemplate.h"
|
||||||
#include "../mapObjects/ObstacleSetHandler.h"
|
#include "../mapObjects/ObstacleSetHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "../filesystem/Filesystem.h"
|
#include "../filesystem/Filesystem.h"
|
||||||
#include "../json/JsonUtils.h"
|
#include "../json/JsonUtils.h"
|
||||||
#include "../spells/CSpellHandler.h"
|
#include "../spells/CSpellHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "../mapObjectConstructors/CObjectClassesHandler.h"
|
#include "../mapObjectConstructors/CObjectClassesHandler.h"
|
||||||
#include "../rmg/CRmgTemplateStorage.h"
|
#include "../rmg/CRmgTemplateStorage.h"
|
||||||
#include "../spells/CSpellHandler.h"
|
#include "../spells/CSpellHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -100,8 +100,9 @@ const CMapGenOptions& CMapGenerator::getMapGenOptions() const
|
|||||||
void CMapGenerator::initQuestArtsRemaining()
|
void CMapGenerator::initQuestArtsRemaining()
|
||||||
{
|
{
|
||||||
//TODO: Move to QuestArtifactPlacer?
|
//TODO: Move to QuestArtifactPlacer?
|
||||||
for (auto art : VLC->arth->objects)
|
for (auto artID : VLC->arth->getDefaultAllowed())
|
||||||
{
|
{
|
||||||
|
auto art = artID.toArtifact();
|
||||||
//Don't use parts of combined artifacts
|
//Don't use parts of combined artifacts
|
||||||
if (art->aClass == CArtifact::ART_TREASURE && VLC->arth->legalArtifact(art->getId()) && art->getPartOf().empty())
|
if (art->aClass == CArtifact::ART_TREASURE && VLC->arth->legalArtifact(art->getId()) && art->getPartOf().empty())
|
||||||
questArtifacts.push_back(art->getId());
|
questArtifacts.push_back(art->getId());
|
||||||
|
@ -176,7 +176,7 @@ void ZoneOptions::setTerrainTypes(const std::set<TerrainId> & value)
|
|||||||
std::set<TerrainId> ZoneOptions::getDefaultTerrainTypes() const
|
std::set<TerrainId> ZoneOptions::getDefaultTerrainTypes() const
|
||||||
{
|
{
|
||||||
std::set<TerrainId> terrains;
|
std::set<TerrainId> terrains;
|
||||||
for (auto terrain : VLC->terrainTypeHandler->objects)
|
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||||
{
|
{
|
||||||
if (terrain->isLand() && terrain->isPassable())
|
if (terrain->isLand() && terrain->isPassable())
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "../TerrainHandler.h"
|
#include "../TerrainHandler.h"
|
||||||
#include "../mapping/CMap.h"
|
#include "../mapping/CMap.h"
|
||||||
#include "../mapping/CMapEditManager.h"
|
#include "../mapping/CMapEditManager.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
#include "CMapGenOptions.h"
|
#include "CMapGenOptions.h"
|
||||||
#include "RmgMap.h"
|
#include "RmgMap.h"
|
||||||
#include "Zone.h"
|
#include "Zone.h"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "../mapping/CMapEditManager.h"
|
#include "../mapping/CMapEditManager.h"
|
||||||
#include "../mapping/CMap.h"
|
#include "../mapping/CMap.h"
|
||||||
#include "../CTownHandler.h"
|
#include "../CTownHandler.h"
|
||||||
|
#include "../VCMI_Lib.h"
|
||||||
#include "modificators/ObjectManager.h"
|
#include "modificators/ObjectManager.h"
|
||||||
#include "modificators/RoadPlacer.h"
|
#include "modificators/RoadPlacer.h"
|
||||||
#include "modificators/TreasurePlacer.h"
|
#include "modificators/TreasurePlacer.h"
|
||||||
|
@ -725,7 +725,7 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
|
|||||||
CreatureID creId = CreatureID::NONE;
|
CreatureID creId = CreatureID::NONE;
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
std::vector<CreatureID> possibleCreatures;
|
std::vector<CreatureID> possibleCreatures;
|
||||||
for(auto cre : VLC->creh->objects)
|
for(auto const & cre : VLC->creh->objects)
|
||||||
{
|
{
|
||||||
if(cre->special)
|
if(cre->special)
|
||||||
continue;
|
continue;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "../../mapObjects/ObjectTemplate.h"
|
#include "../../mapObjects/ObjectTemplate.h"
|
||||||
#include "../../mapping/CMap.h"
|
#include "../../mapping/CMap.h"
|
||||||
#include "../../mapping/CMapEditManager.h"
|
#include "../../mapping/CMapEditManager.h"
|
||||||
|
#include "../../VCMI_Lib.h"
|
||||||
#include "../RmgPath.h"
|
#include "../RmgPath.h"
|
||||||
#include "ObjectManager.h"
|
#include "ObjectManager.h"
|
||||||
#include "ObstaclePlacer.h"
|
#include "ObstaclePlacer.h"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "../../modding/IdentifierStorage.h"
|
#include "../../modding/IdentifierStorage.h"
|
||||||
#include "../../modding/ModScope.h"
|
#include "../../modding/ModScope.h"
|
||||||
#include "../../TerrainHandler.h"
|
#include "../../TerrainHandler.h"
|
||||||
|
#include "../../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "../../TerrainHandler.h"
|
#include "../../TerrainHandler.h"
|
||||||
#include "../../CRandomGenerator.h"
|
#include "../../CRandomGenerator.h"
|
||||||
#include "../../mapping/CMapEditManager.h"
|
#include "../../mapping/CMapEditManager.h"
|
||||||
|
#include "../../VCMI_Lib.h"
|
||||||
#include "../TileInfo.h"
|
#include "../TileInfo.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
@ -76,7 +76,7 @@ void TerrainPainter::initTerrainType()
|
|||||||
{
|
{
|
||||||
//Fill with all terain types by default
|
//Fill with all terain types by default
|
||||||
{
|
{
|
||||||
for (auto terrain : VLC->terrainTypeHandler->objects)
|
for (const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||||
{
|
{
|
||||||
if (terrain->isLand() && terrain->isPassable())
|
if (terrain->isLand() && terrain->isPassable())
|
||||||
{
|
{
|
||||||
|
@ -77,11 +77,9 @@ void TownPlacer::placeTowns(ObjectManager & manager)
|
|||||||
town->builtBuildings.insert(BuildingID::FORT);
|
town->builtBuildings.insert(BuildingID::FORT);
|
||||||
town->builtBuildings.insert(BuildingID::DEFAULT);
|
town->builtBuildings.insert(BuildingID::DEFAULT);
|
||||||
|
|
||||||
for(auto spell : VLC->spellh->objects) //add all regular spells to town
|
|
||||||
{
|
for(auto spellID : VLC->spellh->getDefaultAllowed()) //add all regular spells to town
|
||||||
if(!spell->isSpecial() && !spell->isCreatureAbility())
|
town->possibleSpells.push_back(spellID);
|
||||||
town->possibleSpells.push_back(spell->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto position = placeMainTown(manager, *town);
|
auto position = placeMainTown(manager, *town);
|
||||||
|
|
||||||
@ -202,11 +200,8 @@ void TownPlacer::addNewTowns(int count, bool hasFort, const PlayerColor & player
|
|||||||
town->builtBuildings.insert(BuildingID::FORT);
|
town->builtBuildings.insert(BuildingID::FORT);
|
||||||
town->builtBuildings.insert(BuildingID::DEFAULT);
|
town->builtBuildings.insert(BuildingID::DEFAULT);
|
||||||
|
|
||||||
for(auto spell : VLC->spellh->objects) //add all regular spells to town
|
for(auto spellID : VLC->spellh->getDefaultAllowed()) //add all regular spells to town
|
||||||
{
|
town->possibleSpells.push_back(spellID);
|
||||||
if(!spell->isSpecial() && !spell->isCreatureAbility())
|
|
||||||
town->possibleSpells.push_back(spell->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(totalTowns <= 0)
|
if(totalTowns <= 0)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
oi.maxPerZone = std::numeric_limits<ui32>::max();
|
oi.maxPerZone = std::numeric_limits<ui32>::max();
|
||||||
|
|
||||||
std::vector<const CCreature *> creatures; //native creatures for this zone
|
std::vector<const CCreature *> creatures; //native creatures for this zone
|
||||||
for(auto cre : VLC->creh->objects)
|
for(auto const & cre : VLC->creh->objects)
|
||||||
{
|
{
|
||||||
if(!cre->special && cre->getFaction() == zone.getTownType())
|
if(!cre->special && cre->getFaction() == zone.getTownType())
|
||||||
{
|
{
|
||||||
@ -221,12 +221,10 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
auto * obj = dynamic_cast<CGArtifact *>(factory->create(map.mapInstance->cb, nullptr));
|
auto * obj = dynamic_cast<CGArtifact *>(factory->create(map.mapInstance->cb, nullptr));
|
||||||
std::vector<SpellID> out;
|
std::vector<SpellID> out;
|
||||||
|
|
||||||
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
for(auto spellID : VLC->spellh->getDefaultAllowed())
|
||||||
{
|
{
|
||||||
if(map.isAllowedSpell(spell->id) && spell->getLevel() == i + 1)
|
if(map.isAllowedSpell(spellID) && spellID.toSpell()->getLevel() == i + 1)
|
||||||
{
|
out.push_back(spellID);
|
||||||
out.push_back(spell->id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
auto * a = ArtifactUtils::createScroll(*RandomGeneratorUtil::nextItem(out, zone.getRand()));
|
auto * a = ArtifactUtils::createScroll(*RandomGeneratorUtil::nextItem(out, zone.getRand()));
|
||||||
obj->storedArtifact = a;
|
obj->storedArtifact = a;
|
||||||
@ -354,10 +352,10 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
auto * obj = dynamic_cast<CGPandoraBox *>(factory->create(map.mapInstance->cb, nullptr));
|
auto * obj = dynamic_cast<CGPandoraBox *>(factory->create(map.mapInstance->cb, nullptr));
|
||||||
|
|
||||||
std::vector <const CSpell *> spells;
|
std::vector <const CSpell *> spells;
|
||||||
for(auto spell : VLC->spellh->objects)
|
for(auto spellID : VLC->spellh->getDefaultAllowed())
|
||||||
{
|
{
|
||||||
if(map.isAllowedSpell(spell->id) && spell->getLevel() == i)
|
if(map.isAllowedSpell(spellID) && spellID.toSpell()->getLevel() == i)
|
||||||
spells.push_back(spell.get());
|
spells.push_back(spellID.toSpell());
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomGeneratorUtil::randomShuffle(spells, zone.getRand());
|
RandomGeneratorUtil::randomShuffle(spells, zone.getRand());
|
||||||
@ -387,10 +385,10 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
auto * obj = dynamic_cast<CGPandoraBox *>(factory->create(map.mapInstance->cb, nullptr));
|
auto * obj = dynamic_cast<CGPandoraBox *>(factory->create(map.mapInstance->cb, nullptr));
|
||||||
|
|
||||||
std::vector <const CSpell *> spells;
|
std::vector <const CSpell *> spells;
|
||||||
for(auto spell : VLC->spellh->objects)
|
for(auto spellID : VLC->spellh->getDefaultAllowed())
|
||||||
{
|
{
|
||||||
if(map.isAllowedSpell(spell->id) && spell->hasSchool(SpellSchool(i)))
|
if(map.isAllowedSpell(spellID) && spellID.toSpell()->hasSchool(SpellSchool(i)))
|
||||||
spells.push_back(spell.get());
|
spells.push_back(spellID.toSpell());
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomGeneratorUtil::randomShuffle(spells, zone.getRand());
|
RandomGeneratorUtil::randomShuffle(spells, zone.getRand());
|
||||||
@ -419,10 +417,10 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
auto * obj = dynamic_cast<CGPandoraBox *>(factory->create(map.mapInstance->cb, nullptr));
|
auto * obj = dynamic_cast<CGPandoraBox *>(factory->create(map.mapInstance->cb, nullptr));
|
||||||
|
|
||||||
std::vector <const CSpell *> spells;
|
std::vector <const CSpell *> spells;
|
||||||
for(auto spell : VLC->spellh->objects)
|
for(auto spellID : VLC->spellh->getDefaultAllowed())
|
||||||
{
|
{
|
||||||
if(map.isAllowedSpell(spell->id))
|
if(map.isAllowedSpell(spellID))
|
||||||
spells.push_back(spell.get());
|
spells.push_back(spellID.toSpell());
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomGeneratorUtil::randomShuffle(spells, zone.getRand());
|
RandomGeneratorUtil::randomShuffle(spells, zone.getRand());
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "MapProxy.h"
|
#include "MapProxy.h"
|
||||||
#include "../../TerrainHandler.h"
|
#include "../../TerrainHandler.h"
|
||||||
|
#include "../../VCMI_Lib.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ const std::vector<std::string> & CSpellHandler::getTypeNames() const
|
|||||||
return typeNames;
|
return typeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
std::shared_ptr<CSpell> CSpellHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index)
|
||||||
{
|
{
|
||||||
assert(identifier.find(':') == std::string::npos);
|
assert(identifier.find(':') == std::string::npos);
|
||||||
assert(!scope.empty());
|
assert(!scope.empty());
|
||||||
@ -685,7 +685,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
|||||||
|
|
||||||
SpellID id(static_cast<si32>(index));
|
SpellID id(static_cast<si32>(index));
|
||||||
|
|
||||||
auto * spell = new CSpell();
|
auto spell = std::make_shared<CSpell>();
|
||||||
spell->id = id;
|
spell->id = id;
|
||||||
spell->identifier = identifier;
|
spell->identifier = identifier;
|
||||||
spell->modScope = scope;
|
spell->modScope = scope;
|
||||||
|
@ -355,7 +355,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::vector<std::string> & getTypeNames() const override;
|
const std::vector<std::string> & getTypeNames() const override;
|
||||||
CSpell * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
|
std::shared_ptr<CSpell> loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -36,7 +36,7 @@ ArmyWidget::ArmyWidget(CArmedInstance & a, QWidget *parent) :
|
|||||||
|
|
||||||
for(int c = 0; c < VLC->creh->objects.size(); ++c)
|
for(int c = 0; c < VLC->creh->objects.size(); ++c)
|
||||||
{
|
{
|
||||||
auto creature = VLC->creh->objects[c];
|
auto const & creature = VLC->creh->objects[c];
|
||||||
uiSlots[i]->insertItem(c + 1, creature->getNamePluralTranslated().c_str());
|
uiSlots[i]->insertItem(c + 1, creature->getNamePluralTranslated().c_str());
|
||||||
uiSlots[i]->setItemData(c + 1, creature->getIndex());
|
uiSlots[i]->setItemData(c + 1, creature->getIndex());
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ HeroSkillsWidget::HeroSkillsWidget(CGHeroInstance & h, QWidget *parent) :
|
|||||||
ui->labelKnowledge->setText(QString::fromStdString(NPrimarySkill::names[3]));
|
ui->labelKnowledge->setText(QString::fromStdString(NPrimarySkill::names[3]));
|
||||||
|
|
||||||
auto * delegate = new InspectorDelegate;
|
auto * delegate = new InspectorDelegate;
|
||||||
for(auto s : VLC->skillh->objects)
|
for(auto const & s : VLC->skillh->objects)
|
||||||
delegate->options.push_back({QString::fromStdString(s->getNameTranslated()), QVariant::fromValue(s->getId().getNum())});
|
delegate->options.push_back({QString::fromStdString(s->getNameTranslated()), QVariant::fromValue(s->getId().getNum())});
|
||||||
ui->skills->setItemDelegateForColumn(0, delegate);
|
ui->skills->setItemDelegateForColumn(0, delegate);
|
||||||
|
|
||||||
|
@ -44,14 +44,16 @@ void HeroSpellWidget::obtainData()
|
|||||||
void HeroSpellWidget::initSpellLists()
|
void HeroSpellWidget::initSpellLists()
|
||||||
{
|
{
|
||||||
QListWidget * spellLists[] = { ui->spellList1, ui->spellList2, ui->spellList3, ui->spellList4, ui->spellList5 };
|
QListWidget * spellLists[] = { ui->spellList1, ui->spellList2, ui->spellList3, ui->spellList4, ui->spellList5 };
|
||||||
auto spells = VLC->spellh->objects;
|
|
||||||
for (int i = 0; i < GameConstants::SPELL_LEVELS; i++)
|
for (int i = 0; i < GameConstants::SPELL_LEVELS; i++)
|
||||||
{
|
{
|
||||||
std::vector<ConstTransitivePtr<CSpell>> spellsByLevel;
|
std::vector<const CSpell*> spellsByLevel;
|
||||||
auto getSpellsByLevel = [i](auto spell) {
|
for (auto const & spellID : VLC->spellh->getDefaultAllowed())
|
||||||
return spell->getLevel() == i + 1 && !spell->isSpecial() && !spell->isCreatureAbility();
|
{
|
||||||
};
|
if (spellID.toSpell()->getLevel() == i + 1)
|
||||||
vstd::copy_if(spells, std::back_inserter(spellsByLevel), getSpellsByLevel);
|
spellsByLevel.push_back(spellID.toSpell());
|
||||||
|
}
|
||||||
|
|
||||||
spellLists[i]->clear();
|
spellLists[i]->clear();
|
||||||
for (auto spell : spellsByLevel)
|
for (auto spell : spellsByLevel)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,7 @@ void Initializer::initialize(CGHeroInstance * o)
|
|||||||
|
|
||||||
if(o->ID == Obj::HERO)
|
if(o->ID == Obj::HERO)
|
||||||
{
|
{
|
||||||
for(auto t : VLC->heroh->objects)
|
for(auto const & t : VLC->heroh->objects)
|
||||||
{
|
{
|
||||||
if(t->heroClass->getId() == HeroClassID(o->subID))
|
if(t->heroClass->getId() == HeroClassID(o->subID))
|
||||||
{
|
{
|
||||||
@ -171,7 +171,7 @@ void Initializer::initialize(CGTownInstance * o)
|
|||||||
if(lvl > 2) o->builtBuildings.insert(BuildingID::CASTLE);
|
if(lvl > 2) o->builtBuildings.insert(BuildingID::CASTLE);
|
||||||
if(lvl > 3) o->builtBuildings.insert(BuildingID::CAPITOL);
|
if(lvl > 3) o->builtBuildings.insert(BuildingID::CAPITOL);
|
||||||
|
|
||||||
for(auto spell : VLC->spellh->objects) //add all regular spells to town
|
for(auto const & spell : VLC->spellh->objects) //add all regular spells to town
|
||||||
{
|
{
|
||||||
if(!spell->isSpecial() && !spell->isCreatureAbility())
|
if(!spell->isSpecial() && !spell->isCreatureAbility())
|
||||||
o->possibleSpells.push_back(spell->id);
|
o->possibleSpells.push_back(spell->id);
|
||||||
@ -185,7 +185,7 @@ void Initializer::initialize(CGArtifact * o)
|
|||||||
if(o->ID == Obj::SPELL_SCROLL)
|
if(o->ID == Obj::SPELL_SCROLL)
|
||||||
{
|
{
|
||||||
std::vector<SpellID> out;
|
std::vector<SpellID> out;
|
||||||
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
for(auto const & spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
||||||
{
|
{
|
||||||
if(VLC->spellh->getDefaultAllowed().count(spell->id) != 0)
|
if(VLC->spellh->getDefaultAllowed().count(spell->id) != 0)
|
||||||
{
|
{
|
||||||
@ -357,7 +357,7 @@ void Inspector::updateProperties(CGArtifact * o)
|
|||||||
if(spellId != SpellID::NONE)
|
if(spellId != SpellID::NONE)
|
||||||
{
|
{
|
||||||
auto * delegate = new InspectorDelegate;
|
auto * delegate = new InspectorDelegate;
|
||||||
for(auto spell : VLC->spellh->objects)
|
for(auto const & spell : VLC->spellh->objects)
|
||||||
{
|
{
|
||||||
if(controller.map()->allowedSpells.count(spell->id) != 0)
|
if(controller.map()->allowedSpells.count(spell->id) != 0)
|
||||||
delegate->options.push_back({QObject::tr(spell->getNameTranslated().c_str()), QVariant::fromValue(int(spell->getId()))});
|
delegate->options.push_back({QObject::tr(spell->getNameTranslated().c_str()), QVariant::fromValue(int(spell->getId()))});
|
||||||
@ -699,7 +699,7 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari
|
|||||||
|
|
||||||
if(key == "Hero type")
|
if(key == "Hero type")
|
||||||
{
|
{
|
||||||
for(auto t : VLC->heroh->objects)
|
for(auto const & t : VLC->heroh->objects)
|
||||||
{
|
{
|
||||||
if(t->getId() == value.toInt())
|
if(t->getId() == value.toInt())
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,7 @@ void MainWindow::loadObjectsTree()
|
|||||||
{
|
{
|
||||||
auto *b = new QPushButton(QString::fromStdString(terrain->getNameTranslated()));
|
auto *b = new QPushButton(QString::fromStdString(terrain->getNameTranslated()));
|
||||||
ui->terrainLayout->addWidget(b);
|
ui->terrainLayout->addWidget(b);
|
||||||
connect(b, &QPushButton::clicked, this, [this, terrain]{ terrainButtonClicked(terrain->getId()); });
|
connect(b, &QPushButton::clicked, this, [this, terrainID=terrain->getId()]{ terrainButtonClicked(terrainID); });
|
||||||
|
|
||||||
//filter
|
//filter
|
||||||
QString displayName = QString::fromStdString(terrain->getNameTranslated());
|
QString displayName = QString::fromStdString(terrain->getNameTranslated());
|
||||||
@ -609,7 +609,7 @@ void MainWindow::loadObjectsTree()
|
|||||||
{
|
{
|
||||||
auto *b = new QPushButton(QString::fromStdString(road->getNameTranslated()));
|
auto *b = new QPushButton(QString::fromStdString(road->getNameTranslated()));
|
||||||
ui->roadLayout->addWidget(b);
|
ui->roadLayout->addWidget(b);
|
||||||
connect(b, &QPushButton::clicked, this, [this, road]{ roadOrRiverButtonClicked(road->getIndex(), true); });
|
connect(b, &QPushButton::clicked, this, [this, roadID=road->getIndex()]{ roadOrRiverButtonClicked(roadID, true); });
|
||||||
}
|
}
|
||||||
//add spacer to keep terrain button on the top
|
//add spacer to keep terrain button on the top
|
||||||
ui->roadLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
ui->roadLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
@ -618,7 +618,7 @@ void MainWindow::loadObjectsTree()
|
|||||||
{
|
{
|
||||||
auto *b = new QPushButton(QString::fromStdString(river->getNameTranslated()));
|
auto *b = new QPushButton(QString::fromStdString(river->getNameTranslated()));
|
||||||
ui->riverLayout->addWidget(b);
|
ui->riverLayout->addWidget(b);
|
||||||
connect(b, &QPushButton::clicked, this, [this, river]{ roadOrRiverButtonClicked(river->getIndex(), false); });
|
connect(b, &QPushButton::clicked, this, [this, riverID=river->getIndex()]{ roadOrRiverButtonClicked(riverID, false); });
|
||||||
}
|
}
|
||||||
//add spacer to keep terrain button on the top
|
//add spacer to keep terrain button on the top
|
||||||
ui->riverLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
ui->riverLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
|
@ -137,7 +137,7 @@ void MapController::repairMap(CMap * map) const
|
|||||||
|
|
||||||
map->allowedHeroes.insert(nih->getHeroType());
|
map->allowedHeroes.insert(nih->getHeroType());
|
||||||
|
|
||||||
auto type = VLC->heroh->objects[nih->subID];
|
auto const & type = VLC->heroh->objects[nih->subID];
|
||||||
assert(type->heroClass);
|
assert(type->heroClass);
|
||||||
//TODO: find a way to get proper type name
|
//TODO: find a way to get proper type name
|
||||||
if(obj->ID == Obj::HERO)
|
if(obj->ID == Obj::HERO)
|
||||||
@ -187,7 +187,7 @@ void MapController::repairMap(CMap * map) const
|
|||||||
if(art->ID == Obj::SPELL_SCROLL && !art->storedArtifact)
|
if(art->ID == Obj::SPELL_SCROLL && !art->storedArtifact)
|
||||||
{
|
{
|
||||||
std::vector<SpellID> out;
|
std::vector<SpellID> out;
|
||||||
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
for(auto const & spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
||||||
{
|
{
|
||||||
//if(map->isAllowedSpell(spell->id))
|
//if(map->isAllowedSpell(spell->id))
|
||||||
{
|
{
|
||||||
@ -239,7 +239,7 @@ void MapController::setMap(std::unique_ptr<CMap> cmap)
|
|||||||
|
|
||||||
void MapController::initObstaclePainters(CMap * map)
|
void MapController::initObstaclePainters(CMap * map)
|
||||||
{
|
{
|
||||||
for (auto terrain : VLC->terrainTypeHandler->objects)
|
for (auto const & terrain : VLC->terrainTypeHandler->objects)
|
||||||
{
|
{
|
||||||
auto terrainId = terrain->getId();
|
auto terrainId = terrain->getId();
|
||||||
_obstaclePainters[terrainId] = std::make_unique<EditorObstaclePlacer>(map);
|
_obstaclePainters[terrainId] = std::make_unique<EditorObstaclePlacer>(map);
|
||||||
|
@ -30,7 +30,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
|
|||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
||||||
for(auto objectPtr : VLC->skillh->objects)
|
for(auto const & objectPtr : VLC->skillh->objects)
|
||||||
{
|
{
|
||||||
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
||||||
@ -38,7 +38,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
|
|||||||
item->setCheckState(controller.map()->allowedAbilities.count(objectPtr->getId()) ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(controller.map()->allowedAbilities.count(objectPtr->getId()) ? Qt::Checked : Qt::Unchecked);
|
||||||
ui->listAbilities->addItem(item);
|
ui->listAbilities->addItem(item);
|
||||||
}
|
}
|
||||||
for(auto objectPtr : VLC->spellh->objects)
|
for(auto const & objectPtr : VLC->spellh->objects)
|
||||||
{
|
{
|
||||||
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
||||||
@ -46,7 +46,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
|
|||||||
item->setCheckState(controller.map()->allowedSpells.count(objectPtr->getId()) ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(controller.map()->allowedSpells.count(objectPtr->getId()) ? Qt::Checked : Qt::Unchecked);
|
||||||
ui->listSpells->addItem(item);
|
ui->listSpells->addItem(item);
|
||||||
}
|
}
|
||||||
for(auto objectPtr : VLC->arth->objects)
|
for(auto const & objectPtr : VLC->arth->objects)
|
||||||
{
|
{
|
||||||
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
||||||
@ -54,7 +54,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
|
|||||||
item->setCheckState(controller.map()->allowedArtifact.count(objectPtr->getId()) ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(controller.map()->allowedArtifact.count(objectPtr->getId()) ? Qt::Checked : Qt::Unchecked);
|
||||||
ui->listArts->addItem(item);
|
ui->listArts->addItem(item);
|
||||||
}
|
}
|
||||||
for(auto objectPtr : VLC->heroh->objects)
|
for(auto const & objectPtr : VLC->heroh->objects)
|
||||||
{
|
{
|
||||||
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
auto * item = new QListWidgetItem(QString::fromStdString(objectPtr->getNameTranslated()));
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
item->setData(Qt::UserRole, QVariant::fromValue(objectPtr->getIndex()));
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
#include "../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
||||||
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
||||||
#include "../lib/mapping/CMap.h"
|
#include "../lib/mapping/CMap.h"
|
||||||
|
#include "../lib/VCMI_Lib.h"
|
||||||
|
|
||||||
|
|
||||||
MinimapView::MinimapView(QWidget * parent):
|
MinimapView::MinimapView(QWidget * parent):
|
||||||
|
@ -48,7 +48,7 @@ PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent)
|
|||||||
//load factions
|
//load factions
|
||||||
for(auto idx : VLC->townh->getAllowedFactions())
|
for(auto idx : VLC->townh->getAllowedFactions())
|
||||||
{
|
{
|
||||||
const CFaction * faction = VLC->townh->objects.at(idx);
|
const auto & faction = VLC->townh->objects.at(idx);
|
||||||
auto * item = new QListWidgetItem(QString::fromStdString(faction->getNameTranslated()));
|
auto * item = new QListWidgetItem(QString::fromStdString(faction->getNameTranslated()));
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(idx.getNum()));
|
item->setData(Qt::UserRole, QVariant::fromValue(idx.getNum()));
|
||||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <vstd/StringUtils.h>
|
#include <vstd/StringUtils.h>
|
||||||
#include <vcmi/events/EventBus.h>
|
#include <vcmi/events/EventBus.h>
|
||||||
#include <vcmi/ServerCallback.h>
|
#include <vcmi/ServerCallback.h>
|
||||||
|
#include "vcmi/Services.h"
|
||||||
|
|
||||||
#include "LuaStack.h"
|
#include "LuaStack.h"
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "lib/modding/ModScope.h"
|
#include "lib/modding/ModScope.h"
|
||||||
|
#include "lib/VCMI_Lib.h"
|
||||||
|
|
||||||
#include "ScriptFixture.h"
|
#include "ScriptFixture.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user