mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Merge branch 'develop' into feature/nullkiller2
This commit is contained in:
@@ -3221,6 +3221,23 @@ bool CGameHandler::setFormation(ObjectInstanceID hid, EArmyFormation formation)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameHandler::setTownName(ObjectInstanceID tid, std::string & name)
|
||||
{
|
||||
const CGTownInstance *t = gameInfo().getTown(tid);
|
||||
if (!t)
|
||||
{
|
||||
logGlobal->error("Town doesn't exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
ChangeTownName ctn;
|
||||
ctn.tid = tid;
|
||||
ctn.name = name;
|
||||
sendAndApply(ctn);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameHandler::queryReply(QueryID qid, std::optional<int32_t> answer, PlayerColor player)
|
||||
{
|
||||
logGlobal->trace("Player %s attempts answering query %d with answer:", player, qid);
|
||||
@@ -3883,8 +3900,14 @@ void CGameHandler::castSpell(const spells::Caster * caster, SpellID spellID, con
|
||||
const CSpell * s = spellID.toSpell();
|
||||
s->adventureCast(spellEnv.get(), p);
|
||||
|
||||
if(const auto * hero = caster->getHeroCaster())
|
||||
useChargeBasedSpell(hero->id, spellID);
|
||||
// FIXME: hack to avoid attempts to use charges when spell is casted externally
|
||||
// For example, town gates map object in hota/wog
|
||||
// Proper fix would be to instead spend charges similar to existing caster::spendMana call
|
||||
if (dynamic_cast<const spells::ExternalCaster*>(caster) == nullptr)
|
||||
{
|
||||
if(const auto * hero = caster->getHeroCaster())
|
||||
useChargeBasedSpell(hero->id, spellID);
|
||||
}
|
||||
}
|
||||
|
||||
bool CGameHandler::swapStacks(const StackLocation & sl1, const StackLocation & sl2)
|
||||
|
||||
@@ -212,6 +212,7 @@ public:
|
||||
bool queryReply( QueryID qid, std::optional<int32_t> reply, PlayerColor player );
|
||||
bool buildBoat( ObjectInstanceID objid, PlayerColor player );
|
||||
bool setFormation( ObjectInstanceID hid, EArmyFormation formation );
|
||||
bool setTownName( ObjectInstanceID tid, std::string & name );
|
||||
bool tradeResources(const IMarket *market, ui32 amountToSell, PlayerColor player, GameResID toSell, GameResID toBuy);
|
||||
bool sacrificeCreatures(const IMarket * market, const CGHeroInstance * hero, const std::vector<SlotID> & slot, const std::vector<ui32> & count);
|
||||
bool sendResources(ui32 val, PlayerColor player, GameResID r1, PlayerColor r2);
|
||||
|
||||
@@ -362,6 +362,13 @@ void ApplyGhNetPackVisitor::visitSetFormation(SetFormation & pack)
|
||||
result = gh.setFormation(pack.hid, pack.formation);
|
||||
}
|
||||
|
||||
void ApplyGhNetPackVisitor::visitSetTownName(SetTownName & pack)
|
||||
{
|
||||
gh.throwIfWrongOwner(connection, &pack, pack.tid);
|
||||
|
||||
result = gh.setTownName(pack.tid, pack.name);
|
||||
}
|
||||
|
||||
void ApplyGhNetPackVisitor::visitHireHero(HireHero & pack)
|
||||
{
|
||||
gh.throwIfWrongPlayer(connection, &pack);
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
void visitBuyArtifact(BuyArtifact & pack) override;
|
||||
void visitTradeOnMarketplace(TradeOnMarketplace & pack) override;
|
||||
void visitSetFormation(SetFormation & pack) override;
|
||||
void visitSetTownName(SetTownName & pack) override;
|
||||
void visitHireHero(HireHero & pack) override;
|
||||
void visitBuildBoat(BuildBoat & pack) override;
|
||||
void visitQueryReply(QueryReply & pack) override;
|
||||
|
||||
Reference in New Issue
Block a user