mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix build
This commit is contained in:
parent
6cb1f6ff11
commit
52050d0ef1
@ -51,7 +51,7 @@ TSubgoal Win::whatToDoToAchieve()
|
||||
switch(goal.condition)
|
||||
{
|
||||
case EventCondition::HAVE_ARTIFACT:
|
||||
return sptr(GetArtOfType(goal.objectType));
|
||||
return sptr(GetArtOfType(goal.objectType.as<ArtifactID>()));
|
||||
case EventCondition::DESTROY:
|
||||
{
|
||||
if(goal.object)
|
||||
@ -78,7 +78,7 @@ TSubgoal Win::whatToDoToAchieve()
|
||||
// goal.object = optional, town in which building should be built
|
||||
// Represents "Improve town" condition from H3 (but unlike H3 it consists from 2 separate conditions)
|
||||
|
||||
if(goal.objectType == BuildingID::GRAIL)
|
||||
if(goal.objectType.as<BuildingID>() == BuildingID::GRAIL)
|
||||
{
|
||||
if(auto h = ai->getHeroWithGrail())
|
||||
{
|
||||
@ -149,9 +149,9 @@ TSubgoal Win::whatToDoToAchieve()
|
||||
case EventCondition::HAVE_RESOURCES:
|
||||
//TODO mines? piles? marketplace?
|
||||
//save?
|
||||
return sptr(CollectRes(static_cast<EGameResID>(goal.objectType), goal.value));
|
||||
return sptr(CollectRes(goal.objectType.as<GameResID>(), goal.value));
|
||||
case EventCondition::HAVE_CREATURES:
|
||||
return sptr(GatherTroops(goal.objectType, goal.value));
|
||||
return sptr(GatherTroops(goal.objectType.as<CreatureID>(), goal.value));
|
||||
case EventCondition::TRANSPORT:
|
||||
{
|
||||
//TODO. merge with bring Grail to town? So AI will first dig grail, then transport it using this goal and builds it
|
||||
|
@ -639,7 +639,7 @@ void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
|
||||
mySpell = spell;
|
||||
if(mySpell)
|
||||
{
|
||||
int32_t whichSchool = 0; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
|
||||
SpellSchool whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
|
||||
schoolLevel = owner->myHero->getSpellSchoolLevel(mySpell, &whichSchool);
|
||||
auto spellCost = owner->myInt->cb->getSpellCost(mySpell, owner->myHero);
|
||||
|
||||
@ -648,7 +648,7 @@ void CSpellWindow::SpellArea::setSpell(const CSpell * spell)
|
||||
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool : owner->selectedTab], schoolLevel);
|
||||
schoolBorder = std::make_shared<CAnimImage>(owner->schoolBorders[owner->selectedTab >= 4 ? whichSchool.getNum() : owner->selectedTab], schoolLevel);
|
||||
}
|
||||
|
||||
ColorRGBA firstLineColor, secondLineColor;
|
||||
|
@ -149,7 +149,9 @@ std::vector<int> *CTradeWindow::getItemsIds(bool Left)
|
||||
break;
|
||||
|
||||
case ARTIFACT_TYPE:
|
||||
ids = new std::vector<int>(market->availableItemsIds(mode));
|
||||
ids = new std::vector<int>;
|
||||
for (auto const & item : market->availableItemsIds(mode))
|
||||
ids->push_back(item.getNum());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -635,7 +637,7 @@ void CMarketplaceWindow::artifactsChanged(bool Left)
|
||||
std::vector<TradeItemBuy> available = market->availableItemsIds(mode);
|
||||
std::set<std::shared_ptr<CTradeableItem>> toRemove;
|
||||
for(auto item : items[0])
|
||||
if(!vstd::contains(available, item->id))
|
||||
if(!vstd::contains(available, ArtifactID(item->id)))
|
||||
toRemove.insert(item);
|
||||
|
||||
removeItems(toRemove);
|
||||
|
@ -1159,7 +1159,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
|
||||
std::vector<TradeItemBuy> goods = market->availableItemsIds(EMarketMode::RESOURCE_SKILL);
|
||||
|
||||
for(int i=0; i<goods.size(); i++)//prepare clickable items
|
||||
items.push_back(std::make_shared<CItem>(this, goods[i], 54+i*104, 234));
|
||||
items.push_back(std::make_shared<CItem>(this, goods[i].as<SecondarySkill>(), 54+i*104, 234));
|
||||
|
||||
cancel = std::make_shared<CButton>(Point(200, 313), AnimationPath::builtin("IOKAY.DEF"), CGI->generaltexth->zelp[632], [&](){ close(); }, EShortcut::GLOBAL_ACCEPT);
|
||||
statusbar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
|
||||
@ -1579,7 +1579,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
|
||||
counter = 0;
|
||||
for(auto & it : tgi.bestCreature)
|
||||
{
|
||||
if(it.second >= 0)
|
||||
if(it.second != CreatureID::NONE)
|
||||
bestCreatures.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("TWCRPORT"), it.second+2, 0, 255 + 66 * counter, 479));
|
||||
counter++;
|
||||
}
|
||||
|
@ -532,4 +532,14 @@ std::string SecondarySkill::entityType()
|
||||
return "secondarySkill";
|
||||
}
|
||||
|
||||
std::string BuildingID::encode(int32_t index)
|
||||
{
|
||||
return std::to_string(index);
|
||||
}
|
||||
|
||||
si32 BuildingID::decode(const std::string & identifier)
|
||||
{
|
||||
return std::stoi(identifier);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -413,15 +413,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class BuildingID : public IdentifierWithEnum<BuildingID, BuildingIDBase>
|
||||
class DLL_LINKAGE BuildingID : public IdentifierWithEnum<BuildingID, BuildingIDBase>
|
||||
{
|
||||
public:
|
||||
using IdentifierWithEnum<BuildingID, BuildingIDBase>::IdentifierWithEnum;
|
||||
|
||||
static BuildingID TOWN_HALL_LEVEL(uint level)
|
||||
static BuildingID HALL_LEVEL(uint level)
|
||||
{
|
||||
assert(level < 4);
|
||||
return BuildingID(Type::TOWN_HALL + level);
|
||||
return BuildingID(Type::VILLAGE_HALL + level);
|
||||
}
|
||||
static BuildingID FORT_LEVEL(uint level)
|
||||
{
|
||||
@ -431,7 +431,6 @@ public:
|
||||
|
||||
static std::string encode(int32_t index);
|
||||
static si32 decode(const std::string & identifier);
|
||||
|
||||
};
|
||||
|
||||
class MapObjectBaseID : public IdentifierBase
|
||||
|
@ -52,10 +52,10 @@ public:
|
||||
num += change;
|
||||
}
|
||||
|
||||
// constexpr operator int32_t () const
|
||||
// {
|
||||
// return num;
|
||||
// }
|
||||
constexpr operator int32_t () const
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt)
|
||||
{
|
||||
|
@ -1779,7 +1779,7 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
|
||||
for(const auto & it : elem->Slots())
|
||||
{
|
||||
CreatureID toCmp = it.second->type->getId(); //ID of creature we should compare with the best one
|
||||
if(bestCre == -1 || bestCre.toEntity(VLC)->getAIValue() < toCmp.toEntity(VLC)->getAIValue())
|
||||
if(bestCre == CreatureID::NONE || bestCre.toEntity(VLC)->getAIValue() < toCmp.toEntity(VLC)->getAIValue())
|
||||
{
|
||||
bestCre = toCmp;
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ void CMapLoaderH3M::readVictoryLossConditions()
|
||||
EventExpression::OperatorAll oper;
|
||||
EventCondition cond(EventCondition::HAVE_BUILDING);
|
||||
cond.position = reader->readInt3();
|
||||
cond.objectType = BuildingID::TOWN_HALL_LEVEL(reader->readUInt8());
|
||||
cond.objectType = BuildingID::HALL_LEVEL(reader->readUInt8() + 1);
|
||||
oper.expressions.emplace_back(cond);
|
||||
cond.objectType = BuildingID::FORT_LEVEL(reader->readUInt8());
|
||||
oper.expressions.emplace_back(cond);
|
||||
|
@ -128,7 +128,7 @@ JsonNode AbstractSettings::conditionToJson(const EventCondition & event)
|
||||
JsonNode result;
|
||||
result["condition"].Integer() = event.condition;
|
||||
result["value"].Integer() = event.value;
|
||||
result["objectType"].Integer() = event.objectType;
|
||||
result["objectType"].String() = event.objectType.toString();
|
||||
result["objectInstanceName"].String() = event.objectInstanceName;
|
||||
{
|
||||
auto & position = result["position"].Vector();
|
||||
|
@ -156,7 +156,7 @@ void LoseConditions::update()
|
||||
case 0: {
|
||||
EventExpression::OperatorNone noneOf;
|
||||
EventCondition cond(EventCondition::CONTROL);
|
||||
cond.objectType = Obj::TOWN;
|
||||
cond.objectType = Obj(Obj::TOWN);
|
||||
assert(loseTypeWidget);
|
||||
int townIdx = loseTypeWidget->currentData().toInt();
|
||||
cond.position = controller->map()->objects[townIdx]->pos;
|
||||
@ -171,7 +171,7 @@ void LoseConditions::update()
|
||||
case 1: {
|
||||
EventExpression::OperatorNone noneOf;
|
||||
EventCondition cond(EventCondition::CONTROL);
|
||||
cond.objectType = Obj::HERO;
|
||||
cond.objectType = Obj(Obj::HERO);
|
||||
assert(loseTypeWidget);
|
||||
int townIdx = loseTypeWidget->currentData().toInt();
|
||||
cond.position = controller->map()->objects[townIdx]->pos;
|
||||
|
@ -219,7 +219,7 @@ void VictoryConditions::update()
|
||||
case 0: {
|
||||
EventCondition cond(EventCondition::HAVE_ARTIFACT);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = victoryTypeWidget->currentData().toInt();
|
||||
cond.objectType = ArtifactID(victoryTypeWidget->currentData().toInt());
|
||||
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.281");
|
||||
specialVictory.onFulfill.appendTextID("core.genrltxt.280");
|
||||
specialVictory.trigger = EventExpression(cond);
|
||||
@ -229,7 +229,7 @@ void VictoryConditions::update()
|
||||
case 1: {
|
||||
EventCondition cond(EventCondition::HAVE_CREATURES);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = victoryTypeWidget->currentData().toInt();
|
||||
cond.objectType = CreatureID(victoryTypeWidget->currentData().toInt());
|
||||
cond.value = victoryValueWidget->text().toInt();
|
||||
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.277");
|
||||
specialVictory.onFulfill.appendTextID("core.genrltxt.276");
|
||||
@ -240,7 +240,7 @@ void VictoryConditions::update()
|
||||
case 2: {
|
||||
EventCondition cond(EventCondition::HAVE_RESOURCES);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = victoryTypeWidget->currentData().toInt();
|
||||
cond.objectType = GameResID(victoryTypeWidget->currentData().toInt());
|
||||
cond.value = victoryValueWidget->text().toInt();
|
||||
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.279");
|
||||
specialVictory.onFulfill.appendTextID("core.genrltxt.278");
|
||||
@ -251,7 +251,7 @@ void VictoryConditions::update()
|
||||
case 3: {
|
||||
EventCondition cond(EventCondition::HAVE_BUILDING);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = victoryTypeWidget->currentData().toInt();
|
||||
cond.objectType = BuildingID(victoryTypeWidget->currentData().toInt());
|
||||
int townIdx = victorySelectWidget->currentData().toInt();
|
||||
if(townIdx > -1)
|
||||
cond.position = controller->map()->objects[townIdx]->pos;
|
||||
@ -264,7 +264,7 @@ void VictoryConditions::update()
|
||||
case 4: {
|
||||
EventCondition cond(EventCondition::CONTROL);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = Obj::TOWN;
|
||||
cond.objectType = Obj(Obj::TOWN);
|
||||
int townIdx = victoryTypeWidget->currentData().toInt();
|
||||
cond.position = controller->map()->objects[townIdx]->pos;
|
||||
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.250");
|
||||
@ -276,7 +276,7 @@ void VictoryConditions::update()
|
||||
case 5: {
|
||||
EventCondition cond(EventCondition::DESTROY);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = Obj::HERO;
|
||||
cond.objectType = Obj(Obj::HERO);
|
||||
int heroIdx = victoryTypeWidget->currentData().toInt();
|
||||
cond.position = controller->map()->objects[heroIdx]->pos;
|
||||
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.253");
|
||||
@ -288,7 +288,7 @@ void VictoryConditions::update()
|
||||
case 6: {
|
||||
EventCondition cond(EventCondition::TRANSPORT);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = victoryTypeWidget->currentData().toInt();
|
||||
cond.objectType = ArtifactID(victoryTypeWidget->currentData().toInt());
|
||||
int townIdx = victorySelectWidget->currentData().toInt();
|
||||
if(townIdx > -1)
|
||||
cond.position = controller->map()->objects[townIdx]->pos;
|
||||
@ -301,7 +301,7 @@ void VictoryConditions::update()
|
||||
case 7: {
|
||||
EventCondition cond(EventCondition::DESTROY);
|
||||
assert(victoryTypeWidget);
|
||||
cond.objectType = Obj::MONSTER;
|
||||
cond.objectType = Obj(Obj::MONSTER);
|
||||
int monsterIdx = victoryTypeWidget->currentData().toInt();
|
||||
cond.position = controller->map()->objects[monsterIdx]->pos;
|
||||
specialVictory.effect.toOtherMessage.appendTextID("core.genrltxt.287");
|
||||
|
@ -29,7 +29,6 @@ VCMI_REGISTER_CORE_SCRIPT_API(GameCbProxy, "Game");
|
||||
const std::vector<GameCbProxy::CustomRegType> GameCbProxy::REGISTER_CUSTOM =
|
||||
{
|
||||
{"getDate", LuaMethodWrapper<GameCb, decltype(&GameCb::getDate), &GameCb::getDate>::invoke, false},
|
||||
{"isAllowed", LuaMethodWrapper<GameCb, decltype(&GameCb::isAllowed), &GameCb::isAllowed>::invoke, false},
|
||||
{"getPlayer", LuaMethodWrapper<GameCb, decltype(&GameCb::getPlayer), &GameCb::getPlayer>::invoke, false},
|
||||
|
||||
{"getHero", LuaMethodWrapper<GameCb, decltype(&GameCb::getHero), &GameCb::getHero>::invoke, false},
|
||||
|
@ -17,7 +17,10 @@ class IGameInfoCallbackMock : public IGameInfoCallback
|
||||
public:
|
||||
//various
|
||||
MOCK_CONST_METHOD1(getDate, int(Date));
|
||||
MOCK_CONST_METHOD2(isAllowed, bool(int32_t, int32_t));
|
||||
|
||||
MOCK_CONST_METHOD1(isAllowed, bool(SpellID));
|
||||
MOCK_CONST_METHOD1(isAllowed, bool(ArtifactID));
|
||||
MOCK_CONST_METHOD1(isAllowed, bool(SecondarySkill));
|
||||
|
||||
//player
|
||||
MOCK_CONST_METHOD1(getPlayer, const Player *(PlayerColor));
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
MOCK_CONST_METHOD0(getTreeVersion, int64_t());
|
||||
|
||||
MOCK_CONST_METHOD0(getCasterUnitId, int32_t());
|
||||
MOCK_CONST_METHOD2(getSpellSchoolLevel, int32_t(const spells::Spell *, int32_t *));
|
||||
MOCK_CONST_METHOD2(getSpellSchoolLevel, int32_t(const spells::Spell *, SpellSchool *));
|
||||
MOCK_CONST_METHOD1(getEffectLevel, int32_t(const spells::Spell *));
|
||||
MOCK_CONST_METHOD3(getSpellBonus, int64_t(const spells::Spell *, int64_t, const battle::Unit *));
|
||||
MOCK_CONST_METHOD2(getSpecificSpellBonus, int64_t(const spells::Spell *, int64_t));
|
||||
|
Loading…
Reference in New Issue
Block a user