|
@@ -156,7 +156,7 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
|
|
sps.which = primarySkill;
|
|
|
sps.abs = false;
|
|
|
sps.val = 1;
|
|
|
- sendAndApply(&sps);
|
|
|
+ sendAndApply(sps);
|
|
|
|
|
|
HeroLevelUp hlu;
|
|
|
hlu.player = hero->tempOwner;
|
|
@@ -166,12 +166,12 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
|
|
|
|
|
if (hlu.skills.size() == 0)
|
|
|
{
|
|
|
- sendAndApply(&hlu);
|
|
|
+ sendAndApply(hlu);
|
|
|
levelUpHero(hero);
|
|
|
}
|
|
|
else if (hlu.skills.size() == 1 || !hero->getOwner().isValidPlayer())
|
|
|
{
|
|
|
- sendAndApply(&hlu);
|
|
|
+ sendAndApply(hlu);
|
|
|
levelUpHero(hero, hlu.skills.front());
|
|
|
}
|
|
|
else if (hlu.skills.size() > 1)
|
|
@@ -179,7 +179,7 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
|
|
auto levelUpQuery = std::make_shared<CHeroLevelUpDialogQuery>(this, hlu, hero);
|
|
|
hlu.queryID = levelUpQuery->queryID;
|
|
|
queries->addQuery(levelUpQuery);
|
|
|
- sendAndApply(&hlu);
|
|
|
+ sendAndApply(hlu);
|
|
|
//level up will be called on query reply
|
|
|
}
|
|
|
}
|
|
@@ -237,31 +237,31 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill)
|
|
|
case ECommander::SPELL_POWER:
|
|
|
scp.accumulatedBonus.type = BonusType::MAGIC_RESISTANCE;
|
|
|
scp.accumulatedBonus.val = difference (VLC->creh->skillLevels, c->secondarySkills, ECommander::RESISTANCE);
|
|
|
- sendAndApply (&scp); //additional pack
|
|
|
+ sendAndApply(scp); //additional pack
|
|
|
scp.accumulatedBonus.type = BonusType::CREATURE_SPELL_POWER;
|
|
|
scp.accumulatedBonus.val = difference (VLC->creh->skillLevels, c->secondarySkills, ECommander::SPELL_POWER) * 100; //like hero with spellpower = ability level
|
|
|
- sendAndApply (&scp); //additional pack
|
|
|
+ sendAndApply(scp); //additional pack
|
|
|
scp.accumulatedBonus.type = BonusType::CASTS;
|
|
|
scp.accumulatedBonus.val = difference (VLC->creh->skillLevels, c->secondarySkills, ECommander::CASTS);
|
|
|
- sendAndApply (&scp); //additional pack
|
|
|
+ sendAndApply(scp); //additional pack
|
|
|
scp.accumulatedBonus.type = BonusType::CREATURE_ENCHANT_POWER; //send normally
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
scp.accumulatedBonus.val = difference (VLC->creh->skillLevels, c->secondarySkills, skill);
|
|
|
- sendAndApply (&scp);
|
|
|
+ sendAndApply(scp);
|
|
|
|
|
|
scp.which = SetCommanderProperty::SECONDARY_SKILL;
|
|
|
scp.additionalInfo = skill;
|
|
|
scp.amount = c->secondarySkills.at(skill) + 1;
|
|
|
- sendAndApply (&scp);
|
|
|
+ sendAndApply(scp);
|
|
|
}
|
|
|
else if (skill >= 100)
|
|
|
{
|
|
|
scp.which = SetCommanderProperty::SPECIAL_SKILL;
|
|
|
scp.accumulatedBonus = *VLC->creh->skillRequirements.at(skill-100).first;
|
|
|
scp.additionalInfo = skill; //unnormalized
|
|
|
- sendAndApply (&scp);
|
|
|
+ sendAndApply(scp);
|
|
|
}
|
|
|
expGiven(hero);
|
|
|
}
|
|
@@ -306,12 +306,12 @@ void CGameHandler::levelUpCommander(const CCommanderInstance * c)
|
|
|
|
|
|
if (!skillAmount)
|
|
|
{
|
|
|
- sendAndApply(&clu);
|
|
|
+ sendAndApply(clu);
|
|
|
levelUpCommander(c);
|
|
|
}
|
|
|
else if (skillAmount == 1 || hero->tempOwner == PlayerColor::NEUTRAL) //choose skill automatically
|
|
|
{
|
|
|
- sendAndApply(&clu);
|
|
|
+ sendAndApply(clu);
|
|
|
levelUpCommander(c, *RandomGeneratorUtil::nextItem(clu.skills, getRandomGenerator()));
|
|
|
}
|
|
|
else if (skillAmount > 1) //apply and ask for secondary skill
|
|
@@ -319,7 +319,7 @@ void CGameHandler::levelUpCommander(const CCommanderInstance * c)
|
|
|
auto commanderLevelUp = std::make_shared<CCommanderLevelUpDialogQuery>(this, clu, hero);
|
|
|
clu.queryID = commanderLevelUp->queryID;
|
|
|
queries->addQuery(commanderLevelUp);
|
|
|
- sendAndApply(&clu);
|
|
|
+ sendAndApply(clu);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -357,7 +357,7 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
|
|
|
iw.player = hero->tempOwner;
|
|
|
iw.text.appendLocalString(EMetaText::GENERAL_TXT, 1); //can gain no more XP
|
|
|
iw.text.replaceTextID(hero->getNameTextID());
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
}
|
|
|
|
|
|
SetPrimSkill sps;
|
|
@@ -365,7 +365,7 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
|
|
|
sps.which = PrimarySkill::EXPERIENCE;
|
|
|
sps.abs = false;
|
|
|
sps.val = amountToGain;
|
|
|
- sendAndApply(&sps);
|
|
|
+ sendAndApply(sps);
|
|
|
|
|
|
//hero may level up
|
|
|
if (hero->commander && hero->commander->alive)
|
|
@@ -375,7 +375,7 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
|
|
|
scp.heroid = hero->id;
|
|
|
scp.which = SetCommanderProperty::EXPERIENCE;
|
|
|
scp.amount = amountToGain;
|
|
|
- sendAndApply (&scp);
|
|
|
+ sendAndApply(scp);
|
|
|
CBonusSystemNode::treeHasChanged();
|
|
|
}
|
|
|
|
|
@@ -389,7 +389,7 @@ void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill whi
|
|
|
sps.which = which;
|
|
|
sps.abs = abs;
|
|
|
sps.val = val;
|
|
|
- sendAndApply(&sps);
|
|
|
+ sendAndApply(sps);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs)
|
|
@@ -404,7 +404,7 @@ void CGameHandler::changeSecSkill(const CGHeroInstance * hero, SecondarySkill wh
|
|
|
sss.which = which;
|
|
|
sss.val = val;
|
|
|
sss.abs = abs;
|
|
|
- sendAndApply(&sss);
|
|
|
+ sendAndApply(sss);
|
|
|
|
|
|
if (hero->visitedTown)
|
|
|
giveSpells(hero->visitedTown, hero);
|
|
@@ -596,7 +596,7 @@ void CGameHandler::setPortalDwelling(const CGTownInstance * town, bool forced=fa
|
|
|
ssi.creatures[town->town->creatures.size()].first = creatureId.toEntity(VLC)->getGrowth();
|
|
|
}
|
|
|
ssi.creatures[town->town->creatures.size()].second.push_back(creatureId);
|
|
|
- sendAndApply(&ssi);
|
|
|
+ sendAndApply(ssi);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -683,7 +683,7 @@ void CGameHandler::onNewTurn()
|
|
|
SetAvailableArtifacts saa;
|
|
|
saa.id = ObjectInstanceID::NONE;
|
|
|
pickAllowedArtsSet(saa.arts, getRandomGenerator());
|
|
|
- sendAndApply(&saa);
|
|
|
+ sendAndApply(saa);
|
|
|
}
|
|
|
|
|
|
newTurnProcessor->onNewTurn();
|
|
@@ -770,7 +770,7 @@ void CGameHandler::giveSpells(const CGTownInstance *t, const CGHeroInstance *h)
|
|
|
}
|
|
|
}
|
|
|
if (!cs.spells.empty())
|
|
|
- sendAndApply(&cs);
|
|
|
+ sendAndApply(cs);
|
|
|
}
|
|
|
|
|
|
bool CGameHandler::removeObject(const CGObjectInstance * obj, const PlayerColor & initiator)
|
|
@@ -784,7 +784,7 @@ bool CGameHandler::removeObject(const CGObjectInstance * obj, const PlayerColor
|
|
|
RemoveObject ro;
|
|
|
ro.objectID = obj->id;
|
|
|
ro.initiator = initiator;
|
|
|
- sendAndApply(&ro);
|
|
|
+ sendAndApply(ro);
|
|
|
|
|
|
checkVictoryLossConditionsForAll(); //eg if monster escaped (removing objs after battle is done dircetly by endBattle, not this function)
|
|
|
return true;
|
|
@@ -857,7 +857,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
|
|
{
|
|
|
//send info about movement failure
|
|
|
complain(message);
|
|
|
- sendAndApply(&tmh);
|
|
|
+ sendAndApply(tmh);
|
|
|
return false;
|
|
|
};
|
|
|
|
|
@@ -924,7 +924,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
|
|
tmh.attackedFrom = std::make_optional(guardPos);
|
|
|
|
|
|
tmh.result = result;
|
|
|
- sendAndApply(&tmh);
|
|
|
+ sendAndApply(tmh);
|
|
|
|
|
|
if (visitDest == VISIT_DEST && objectToVisit && objectToVisit->id == h->id)
|
|
|
{ // Hero should be always able to visit any object he is staying on even if there are guards around
|
|
@@ -1101,7 +1101,7 @@ void CGameHandler::showBlockingDialog(const IObjectInterface * caller, BlockingD
|
|
|
auto dialogQuery = std::make_shared<CBlockingDialogQuery>(this, caller, *iw);
|
|
|
queries->addQuery(dialogQuery);
|
|
|
iw->queryID = dialogQuery->queryID;
|
|
|
- sendToAllClients(iw);
|
|
|
+ sendToAllClients(*iw);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::showTeleportDialog(TeleportDialog *iw)
|
|
@@ -1109,7 +1109,7 @@ void CGameHandler::showTeleportDialog(TeleportDialog *iw)
|
|
|
auto dialogQuery = std::make_shared<CTeleportDialogQuery>(this, *iw);
|
|
|
queries->addQuery(dialogQuery);
|
|
|
iw->queryID = dialogQuery->queryID;
|
|
|
- sendToAllClients(iw);
|
|
|
+ sendToAllClients(*iw);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::giveResource(PlayerColor player, GameResID which, int val) //TODO: cap according to Bersy's suggestion
|
|
@@ -1127,7 +1127,7 @@ void CGameHandler::giveResources(PlayerColor player, TResources resources)
|
|
|
sr.abs = false;
|
|
|
sr.player = player;
|
|
|
sr.res = resources;
|
|
|
- sendAndApply(&sr);
|
|
|
+ sendAndApply(sr);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::giveCreatures(const CArmedInstance *obj, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove)
|
|
@@ -1187,7 +1187,7 @@ void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInsta
|
|
|
vc.hid = hero->id;
|
|
|
vc.tid = obj->id;
|
|
|
vc.flags |= 1;
|
|
|
- sendAndApply(&vc);
|
|
|
+ sendAndApply(vc);
|
|
|
}
|
|
|
visitCastleObjects(obj, hero);
|
|
|
|
|
@@ -1227,7 +1227,7 @@ void CGameHandler::stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroI
|
|
|
HeroVisitCastle vc;
|
|
|
vc.hid = hero->id;
|
|
|
vc.tid = obj->id;
|
|
|
- sendAndApply(&vc);
|
|
|
+ sendAndApply(vc);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::removeArtifact(const ArtifactLocation & al)
|
|
@@ -1240,7 +1240,7 @@ void CGameHandler::removeArtifact(const ObjectInstanceID & srcId, const std::vec
|
|
|
BulkEraseArtifacts ea;
|
|
|
ea.artHolder = srcId;
|
|
|
ea.posPack.insert(ea.posPack.end(), slotsPack.begin(), slotsPack.end());
|
|
|
- sendAndApply(&ea);
|
|
|
+ sendAndApply(ea);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells)
|
|
@@ -1249,7 +1249,7 @@ void CGameHandler::changeSpells(const CGHeroInstance * hero, bool give, const st
|
|
|
cs.hid = hero->id;
|
|
|
cs.spells = spells;
|
|
|
cs.learn = give;
|
|
|
- sendAndApply(&cs);
|
|
|
+ sendAndApply(cs);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setResearchedSpells(const CGTownInstance * town, int level, const std::vector<SpellID> spells, bool accepted)
|
|
@@ -1264,12 +1264,12 @@ void CGameHandler::setResearchedSpells(const CGTownInstance * town, int level, c
|
|
|
|
|
|
void CGameHandler::giveHeroBonus(GiveBonus * bonus)
|
|
|
{
|
|
|
- sendAndApply(bonus);
|
|
|
+ sendAndApply(*bonus);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setMovePoints(SetMovePoints * smp)
|
|
|
{
|
|
|
- sendAndApply(smp);
|
|
|
+ sendAndApply(*smp);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setMovePoints(ObjectInstanceID hid, int val, bool absolute)
|
|
@@ -1278,7 +1278,7 @@ void CGameHandler::setMovePoints(ObjectInstanceID hid, int val, bool absolute)
|
|
|
smp.hid = hid;
|
|
|
smp.val = val;
|
|
|
smp.absolute = absolute;
|
|
|
- sendAndApply(&smp);
|
|
|
+ sendAndApply(smp);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setManaPoints(ObjectInstanceID hid, int val)
|
|
@@ -1287,7 +1287,7 @@ void CGameHandler::setManaPoints(ObjectInstanceID hid, int val)
|
|
|
sm.hid = hid;
|
|
|
sm.val = val;
|
|
|
sm.absolute = true;
|
|
|
- sendAndApply(&sm);
|
|
|
+ sendAndApply(sm);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::giveHero(ObjectInstanceID id, PlayerColor player, ObjectInstanceID boatId)
|
|
@@ -1296,7 +1296,7 @@ void CGameHandler::giveHero(ObjectInstanceID id, PlayerColor player, ObjectInsta
|
|
|
gh.id = id;
|
|
|
gh.player = player;
|
|
|
gh.boatId = boatId;
|
|
|
- sendAndApply(&gh);
|
|
|
+ sendAndApply(gh);
|
|
|
|
|
|
//Reveal fow around new hero, especially released from Prison
|
|
|
auto h = getHero(id);
|
|
@@ -1309,7 +1309,7 @@ void CGameHandler::changeObjPos(ObjectInstanceID objid, int3 newPos, const Playe
|
|
|
cop.objid = objid;
|
|
|
cop.nPos = newPos;
|
|
|
cop.initiator = initiator;
|
|
|
- sendAndApply(&cop);
|
|
|
+ sendAndApply(cop);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID toHero)
|
|
@@ -1379,7 +1379,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
|
|
}
|
|
|
iw.text.appendLocalString(EMetaText::GENERAL_TXT, 142);//from %s
|
|
|
iw.text.replaceTextID(h2->getNameTextID());
|
|
|
- sendAndApply(&cs2);
|
|
|
+ sendAndApply(cs2);
|
|
|
}
|
|
|
|
|
|
if (!cs1.spells.empty() && !cs2.spells.empty())
|
|
@@ -1407,9 +1407,9 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
|
|
}
|
|
|
iw.text.appendLocalString(EMetaText::GENERAL_TXT, 148);//from %s
|
|
|
iw.text.replaceTextID(h2->getNameTextID());
|
|
|
- sendAndApply(&cs1);
|
|
|
+ sendAndApply(cs1);
|
|
|
}
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1426,43 +1426,43 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
|
|
|
hex.player = h1->getOwner();
|
|
|
hex.hero1 = hero1;
|
|
|
hex.hero2 = hero2;
|
|
|
- sendAndApply(&hex);
|
|
|
+ sendAndApply(hex);
|
|
|
|
|
|
useScholarSkill(hero1,hero2);
|
|
|
queries->addQuery(exchange);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::sendToAllClients(CPackForClient * pack)
|
|
|
+void CGameHandler::sendToAllClients(CPackForClient & pack)
|
|
|
{
|
|
|
- logNetwork->trace("\tSending to all clients: %s", typeid(*pack).name());
|
|
|
+ logNetwork->trace("\tSending to all clients: %s", typeid(pack).name());
|
|
|
for (auto c : lobby->activeConnections)
|
|
|
- c->sendPack(*pack);
|
|
|
+ c->sendPack(pack);
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::sendAndApply(CPackForClient * pack)
|
|
|
+void CGameHandler::sendAndApply(CPackForClient & pack)
|
|
|
{
|
|
|
sendToAllClients(pack);
|
|
|
- gs->apply(*pack);
|
|
|
+ gs->apply(pack);
|
|
|
logNetwork->trace("\tApplied on gs: %s", typeid(pack).name());
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::sendAndApply(CGarrisonOperationPack * pack)
|
|
|
+void CGameHandler::sendAndApply(CGarrisonOperationPack & pack)
|
|
|
{
|
|
|
- sendAndApply(static_cast<CPackForClient *>(pack));
|
|
|
+ sendAndApply(static_cast<CPackForClient &>(pack));
|
|
|
checkVictoryLossConditionsForAll();
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::sendAndApply(SetResources * pack)
|
|
|
+void CGameHandler::sendAndApply(SetResources & pack)
|
|
|
{
|
|
|
- sendAndApply(static_cast<CPackForClient *>(pack));
|
|
|
- checkVictoryLossConditionsForPlayer(pack->player);
|
|
|
+ sendAndApply(static_cast<CPackForClient &>(pack));
|
|
|
+ checkVictoryLossConditionsForPlayer(pack.player);
|
|
|
}
|
|
|
|
|
|
-void CGameHandler::sendAndApply(NewStructures * pack)
|
|
|
+void CGameHandler::sendAndApply(NewStructures & pack)
|
|
|
{
|
|
|
- sendAndApply(static_cast<CPackForClient *>(pack));
|
|
|
- checkVictoryLossConditionsForPlayer(getTown(pack->tid)->tempOwner);
|
|
|
+ sendAndApply(static_cast<CPackForClient &>(pack));
|
|
|
+ checkVictoryLossConditionsForPlayer(getTown(pack.tid)->tempOwner);
|
|
|
}
|
|
|
|
|
|
bool CGameHandler::isPlayerOwns(CPackForServer * pack, ObjectInstanceID id)
|
|
@@ -1644,7 +1644,7 @@ bool CGameHandler::bulkSplitStack(SlotID slotSrc, ObjectInstanceID srcOwner, si3
|
|
|
if(actualAmount <= howMany)
|
|
|
break;
|
|
|
}
|
|
|
- sendAndApply(&bulkRS);
|
|
|
+ sendAndApply(bulkRS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -1686,7 +1686,7 @@ bool CGameHandler::bulkMergeStacks(SlotID slotSrc, ObjectInstanceID srcOwner)
|
|
|
rs.count = creatureSet.getStackCount(slot);
|
|
|
bulkRS.moves.push_back(rs);
|
|
|
}
|
|
|
- sendAndApply(&bulkRS);
|
|
|
+ sendAndApply(bulkRS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -1773,7 +1773,7 @@ bool CGameHandler::bulkMoveArmy(ObjectInstanceID srcArmy, ObjectInstanceID destA
|
|
|
rs.count = move.second.second;
|
|
|
bulkRS.moves.push_back(rs);
|
|
|
}
|
|
|
- sendAndApply(&bulkRS);
|
|
|
+ sendAndApply(bulkRS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -1855,7 +1855,7 @@ bool CGameHandler::bulkSmartSplitStack(SlotID slotSrc, ObjectInstanceID srcOwner
|
|
|
complain((boost::format("Failure: totalCreatures=%d but check=%d") % totalCreatures % check).str());
|
|
|
return false;
|
|
|
}
|
|
|
- sendAndApply(&bulkSRS);
|
|
|
+ sendAndApply(bulkSRS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2096,7 +2096,7 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
|
|
if (ssi.creatures[level].second.empty()) // first creature in a dwelling
|
|
|
ssi.creatures[level].first = crea->getGrowth();
|
|
|
ssi.creatures[level].second.push_back(crea->getId());
|
|
|
- sendAndApply(&ssi);
|
|
|
+ sendAndApply(ssi);
|
|
|
}
|
|
|
if(t->town->buildings.at(buildingID)->subId == BuildingSubID::PORTAL_OF_SUMMONING)
|
|
|
{
|
|
@@ -2178,7 +2178,7 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
|
|
}
|
|
|
|
|
|
//We know what has been built, apply changes. Do this as final step to properly update town window
|
|
|
- sendAndApply(&ns);
|
|
|
+ sendAndApply(ns);
|
|
|
|
|
|
//Other post-built events. To some logic like giving spells to work gamestate changes for new building must be already in place!
|
|
|
for(auto builtID : ns.bid)
|
|
@@ -2247,7 +2247,7 @@ bool CGameHandler::razeStructure (ObjectInstanceID tid, BuildingID bid)
|
|
|
rs.tid = tid;
|
|
|
rs.bid.insert(bid);
|
|
|
rs.destroyed = t->destroyed + 1;
|
|
|
- sendAndApply(&rs);
|
|
|
+ sendAndApply(rs);
|
|
|
//TODO: Remove dwellers
|
|
|
// if (t->subID == 4 && bid == 17) //Veil of Darkness
|
|
|
// {
|
|
@@ -2255,7 +2255,7 @@ bool CGameHandler::razeStructure (ObjectInstanceID tid, BuildingID bid)
|
|
|
// rb.whoID = t->id;
|
|
|
// rb.source = BonusSource::TOWN_STRUCTURE;
|
|
|
// rb.id = 17;
|
|
|
-// sendAndApply(&rb);
|
|
|
+// sendAndApply(rb);
|
|
|
// }
|
|
|
return true;
|
|
|
}
|
|
@@ -2380,7 +2380,7 @@ bool CGameHandler::recruitCreatures(ObjectInstanceID objid, ObjectInstanceID dst
|
|
|
sac.tid = objid;
|
|
|
sac.creatures = dwelling->creatures;
|
|
|
sac.creatures[level].first -= cram;
|
|
|
- sendAndApply(&sac);
|
|
|
+ sendAndApply(sac);
|
|
|
|
|
|
if (warMachine)
|
|
|
{
|
|
@@ -2443,7 +2443,7 @@ bool CGameHandler::changeStackType(const StackLocation &sl, const CCreature *c)
|
|
|
sst.army = sl.army->id;
|
|
|
sst.slot = sl.slot;
|
|
|
sst.type = c->getId();
|
|
|
- sendAndApply(&sst);
|
|
|
+ sendAndApply(sst);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2502,7 +2502,7 @@ bool CGameHandler::swapGarrisonOnSiege(ObjectInstanceID tid)
|
|
|
intown.visiting = ObjectInstanceID();
|
|
|
intown.garrison = town->visitingHero->id;
|
|
|
}
|
|
|
- sendAndApply(&intown);
|
|
|
+ sendAndApply(intown);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2524,7 +2524,7 @@ bool CGameHandler::garrisonSwap(ObjectInstanceID tid)
|
|
|
intown.tid = tid;
|
|
|
intown.visiting = ObjectInstanceID();
|
|
|
intown.garrison = town->visitingHero->id;
|
|
|
- sendAndApply(&intown);
|
|
|
+ sendAndApply(intown);
|
|
|
return true;
|
|
|
}
|
|
|
else if (town->garrisonHero && !town->visitingHero) //move hero out of the garrison
|
|
@@ -2541,7 +2541,7 @@ bool CGameHandler::garrisonSwap(ObjectInstanceID tid)
|
|
|
intown.tid = tid;
|
|
|
intown.garrison = ObjectInstanceID();
|
|
|
intown.visiting = town->garrisonHero->id;
|
|
|
- sendAndApply(&intown);
|
|
|
+ sendAndApply(intown);
|
|
|
return true;
|
|
|
}
|
|
|
else if (!!town->garrisonHero && town->visitingHero) //swap visiting and garrison hero
|
|
@@ -2550,7 +2550,7 @@ bool CGameHandler::garrisonSwap(ObjectInstanceID tid)
|
|
|
intown.tid = tid;
|
|
|
intown.garrison = town->visitingHero->id;
|
|
|
intown.visiting = town->garrisonHero->id;
|
|
|
- sendAndApply(&intown);
|
|
|
+ sendAndApply(intown);
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
@@ -2631,7 +2631,7 @@ bool CGameHandler::moveArtifact(const PlayerColor & player, const ArtifactLocati
|
|
|
ma.artsPack0.push_back(BulkMoveArtifacts::LinkedSlots(src.slot, dstSlot));
|
|
|
if(src.artHolder != dst.artHolder)
|
|
|
ma.artsPack0.back().askAssemble = true;
|
|
|
- sendAndApply(&ma);
|
|
|
+ sendAndApply(ma);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2732,7 +2732,7 @@ bool CGameHandler::bulkMoveArtifacts(const PlayerColor & player, ObjectInstanceI
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- sendAndApply(&ma);
|
|
|
+ sendAndApply(ma);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2799,7 +2799,7 @@ bool CGameHandler::manageBackpackArtifacts(const PlayerColor & player, const Obj
|
|
|
bma.artsPack0.emplace_back(ArtifactPosition::BACKPACK_START, backpackEnd);
|
|
|
}
|
|
|
}
|
|
|
- sendAndApply(&bma);
|
|
|
+ sendAndApply(bma);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2815,7 +2815,7 @@ bool CGameHandler::saveArtifactsCostume(const PlayerColor & player, const Object
|
|
|
costume.costumeSet.emplace(slot, slotInfo->getArt()->getTypeId());
|
|
|
}
|
|
|
|
|
|
- sendAndApply(&costume);
|
|
|
+ sendAndApply(costume);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -2870,7 +2870,7 @@ bool CGameHandler::switchArtifactsCostume(const PlayerColor & player, const Obje
|
|
|
|
|
|
const auto backpackCap = getSettings().getInteger(EGameSettings::HEROES_BACKPACK_CAP);
|
|
|
if((backpackCap < 0 || estimateBackpackSize <= backpackCap) && !bma.artsPack0.empty())
|
|
|
- sendAndApply(&bma);
|
|
|
+ sendAndApply(bma);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -2913,7 +2913,7 @@ bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition a
|
|
|
AssembledArtifact aa;
|
|
|
aa.al = dstLoc;
|
|
|
aa.builtArt = combinedArt;
|
|
|
- sendAndApply(&aa);
|
|
|
+ sendAndApply(aa);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2926,7 +2926,7 @@ bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition a
|
|
|
|
|
|
DisassembledArtifact da;
|
|
|
da.al = dstLoc;
|
|
|
- sendAndApply(&da);
|
|
|
+ sendAndApply(da);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
@@ -3045,7 +3045,7 @@ bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, GameRe
|
|
|
if (!found)
|
|
|
COMPLAIN_RET("Cannot find selected artifact on the list");
|
|
|
|
|
|
- sendAndApply(&saa);
|
|
|
+ sendAndApply(saa);
|
|
|
giveHeroNewArtifact(h, aid, ArtifactPosition::FIRST_AVAILABLE);
|
|
|
return true;
|
|
|
}
|
|
@@ -3209,7 +3209,7 @@ bool CGameHandler::setFormation(ObjectInstanceID hid, EArmyFormation formation)
|
|
|
ChangeFormation cf;
|
|
|
cf.hid = hid;
|
|
|
cf.formation = formation;
|
|
|
- sendAndApply(&cf);
|
|
|
+ sendAndApply(cf);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -3266,7 +3266,7 @@ void CGameHandler::showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID h
|
|
|
gd.objid = upobj;
|
|
|
gd.removableUnits = removableUnits;
|
|
|
gd.queryID = garrisonQuery->queryID;
|
|
|
- sendAndApply(&gd);
|
|
|
+ sendAndApply(gd);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::showObjectWindow(const CGObjectInstance * object, EOpenWindowMode window, const CGHeroInstance * visitor, bool addQuery)
|
|
@@ -3282,7 +3282,7 @@ void CGameHandler::showObjectWindow(const CGObjectInstance * object, EOpenWindow
|
|
|
pack.queryID = windowQuery->queryID;
|
|
|
queries->addQuery(windowQuery);
|
|
|
}
|
|
|
- sendAndApply(&pack);
|
|
|
+ sendAndApply(pack);
|
|
|
}
|
|
|
|
|
|
bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
|
|
@@ -3384,7 +3384,7 @@ void CGameHandler::objectVisited(const CGObjectInstance * obj, const CGHeroInsta
|
|
|
hv.heroId = h->id;
|
|
|
hv.player = h->tempOwner;
|
|
|
hv.starting = true;
|
|
|
- sendAndApply(&hv);
|
|
|
+ sendAndApply(hv);
|
|
|
|
|
|
obj->onHeroVisit(h);
|
|
|
};
|
|
@@ -3407,7 +3407,7 @@ void CGameHandler::objectVisitEnded(const CGHeroInstance *h, PlayerColor player)
|
|
|
hv.player = event.getPlayer();
|
|
|
hv.heroId = event.getHero();
|
|
|
hv.starting = false;
|
|
|
- sendAndApply(&hv);
|
|
|
+ sendAndApply(hv);
|
|
|
};
|
|
|
|
|
|
//TODO: ObjectVisitEnded should also have id of visited object,
|
|
@@ -3478,14 +3478,14 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
|
|
{
|
|
|
InfoWindow iw;
|
|
|
getVictoryLossMessage(player, victoryLossCheckResult, iw);
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
|
|
|
PlayerEndsGame peg;
|
|
|
peg.player = player;
|
|
|
peg.victoryLossCheckResult = victoryLossCheckResult;
|
|
|
peg.statistic = StatisticDataSet(gameState()->statistic);
|
|
|
addStatistics(peg.statistic); // add last turn befor win / loss
|
|
|
- sendAndApply(&peg);
|
|
|
+ sendAndApply(peg);
|
|
|
|
|
|
turnOrder->onPlayerEndsGame(player);
|
|
|
|
|
@@ -3504,8 +3504,8 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
|
|
getVictoryLossMessage(player, peg.victoryLossCheckResult, iw);
|
|
|
iw.player = i->first;
|
|
|
|
|
|
- sendAndApply(&iw);
|
|
|
- sendAndApply(&peg);
|
|
|
+ sendAndApply(iw);
|
|
|
+ sendAndApply(peg);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3549,7 +3549,7 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
|
|
InfoWindow iw;
|
|
|
getVictoryLossMessage(player, victoryLossCheckResult.invert(), iw);
|
|
|
iw.player = pc;
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
}
|
|
|
}
|
|
|
checkVictoryLossConditions(playerColors);
|
|
@@ -3576,7 +3576,7 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
|
|
SetMovePoints smp;
|
|
|
smp.hid = h->id;
|
|
|
smp.val = 0;
|
|
|
- sendAndApply(&smp);
|
|
|
+ sendAndApply(smp);
|
|
|
|
|
|
InfoWindow iw;
|
|
|
iw.type = EInfoWindowMode::AUTO;
|
|
@@ -3589,19 +3589,19 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
|
|
iw.text.appendName(grail); // ... " The Grail"
|
|
|
iw.soundID = soundBase::ULTIMATEARTIFACT;
|
|
|
giveHeroNewArtifact(h, grail, ArtifactPosition::FIRST_AVAILABLE); //give grail
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
|
|
|
iw.soundID = soundBase::invalid;
|
|
|
iw.components.emplace_back(ComponentType::ARTIFACT, grail);
|
|
|
iw.text.clear();
|
|
|
iw.text.appendTextID(grail.toArtifact()->getDescriptionTextID());
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iw.text.appendLocalString(EMetaText::GENERAL_TXT, 59); //"Nothing here. \n Where could it be?"
|
|
|
iw.soundID = soundBase::Dig;
|
|
|
- sendAndApply(&iw);
|
|
|
+ sendAndApply(iw);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
@@ -3721,7 +3721,7 @@ bool CGameHandler::insertNewStack(const StackLocation &sl, const CCreature *c, T
|
|
|
ins.slot = sl.slot;
|
|
|
ins.type = c->getId();
|
|
|
ins.count = count;
|
|
|
- sendAndApply(&ins);
|
|
|
+ sendAndApply(ins);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -3740,7 +3740,7 @@ bool CGameHandler::eraseStack(const StackLocation &sl, bool forceRemoval)
|
|
|
EraseStack es;
|
|
|
es.army = sl.army->id;
|
|
|
es.slot = sl.slot;
|
|
|
- sendAndApply(&es);
|
|
|
+ sendAndApply(es);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -3765,7 +3765,7 @@ bool CGameHandler::changeStackCount(const StackLocation &sl, TQuantity count, bo
|
|
|
csc.slot = sl.slot;
|
|
|
csc.count = count;
|
|
|
csc.absoluteValue = absoluteValue;
|
|
|
- sendAndApply(&csc);
|
|
|
+ sendAndApply(csc);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -3847,7 +3847,7 @@ bool CGameHandler::moveStack(const StackLocation &src, const StackLocation &dst,
|
|
|
rs.srcSlot = src.slot;
|
|
|
rs.dstSlot = dst.slot;
|
|
|
rs.count = count;
|
|
|
- sendAndApply(&rs);
|
|
|
+ sendAndApply(rs);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -3881,7 +3881,7 @@ bool CGameHandler::swapStacks(const StackLocation & sl1, const StackLocation & s
|
|
|
ss.dstArmy = sl2.army->id;
|
|
|
ss.srcSlot = sl1.slot;
|
|
|
ss.dstSlot = sl2.slot;
|
|
|
- sendAndApply(&ss);
|
|
|
+ sendAndApply(ss);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -3919,7 +3919,7 @@ bool CGameHandler::putArtifact(const ArtifactLocation & al, const ArtifactInstan
|
|
|
if(artInst->canBePutAt(putTo, dst.slot))
|
|
|
{
|
|
|
PutArtifact pa(id, dst, askAssemble.value());
|
|
|
- sendAndApply(&pa);
|
|
|
+ sendAndApply(pa);
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
@@ -3954,7 +3954,7 @@ bool CGameHandler::giveHeroNewArtifact(
|
|
|
{
|
|
|
COMPLAIN_RET_FALSE_IF(!artType->canBePutAt(h, pos, false), "Cannot put artifact in that slot!");
|
|
|
}
|
|
|
- sendAndApply(&na);
|
|
|
+ sendAndApply(na);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -3999,7 +3999,7 @@ void CGameHandler::synchronizeArtifactHandlerLists()
|
|
|
{
|
|
|
UpdateArtHandlerLists uahl;
|
|
|
uahl.allocatedArtifacts = gs->allocatedArtifacts;
|
|
|
- sendAndApply(&uahl);
|
|
|
+ sendAndApply(uahl);
|
|
|
}
|
|
|
|
|
|
bool CGameHandler::isValidObject(const CGObjectInstance *obj) const
|
|
@@ -4086,7 +4086,7 @@ void CGameHandler::changeFogOfWar(const std::unordered_set<int3> &tiles, PlayerC
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- sendAndApply(&fow);
|
|
|
+ sendAndApply(fow);
|
|
|
}
|
|
|
|
|
|
const CGHeroInstance * CGameHandler::getVisitingHero(const CGObjectInstance *obj)
|
|
@@ -4137,7 +4137,7 @@ void CGameHandler::setObjPropertyValue(ObjectInstanceID objid, ObjProperty prop,
|
|
|
sob.id = objid;
|
|
|
sob.what = prop;
|
|
|
sob.identifier = NumericID(value);
|
|
|
- sendAndApply(&sob);
|
|
|
+ sendAndApply(sob);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, ObjPropertyID identifier)
|
|
@@ -4146,7 +4146,7 @@ void CGameHandler::setObjPropertyID(ObjectInstanceID objid, ObjProperty prop, Ob
|
|
|
sob.id = objid;
|
|
|
sob.what = prop;
|
|
|
sob.identifier = identifier;
|
|
|
- sendAndApply(&sob);
|
|
|
+ sendAndApply(sob);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setBankObjectConfiguration(ObjectInstanceID objid, const BankConfig & configuration)
|
|
@@ -4154,7 +4154,7 @@ void CGameHandler::setBankObjectConfiguration(ObjectInstanceID objid, const Bank
|
|
|
SetBankConfiguration srb;
|
|
|
srb.objectID = objid;
|
|
|
srb.configuration = configuration;
|
|
|
- sendAndApply(&srb);
|
|
|
+ sendAndApply(srb);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setRewardableObjectConfiguration(ObjectInstanceID objid, const Rewardable::Configuration & configuration)
|
|
@@ -4162,7 +4162,7 @@ void CGameHandler::setRewardableObjectConfiguration(ObjectInstanceID objid, cons
|
|
|
SetRewardableConfiguration srb;
|
|
|
srb.objectID = objid;
|
|
|
srb.configuration = configuration;
|
|
|
- sendAndApply(&srb);
|
|
|
+ sendAndApply(srb);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::setRewardableObjectConfiguration(ObjectInstanceID townInstanceID, BuildingID buildingID, const Rewardable::Configuration & configuration)
|
|
@@ -4171,12 +4171,12 @@ void CGameHandler::setRewardableObjectConfiguration(ObjectInstanceID townInstanc
|
|
|
srb.objectID = townInstanceID;
|
|
|
srb.buildingID = buildingID;
|
|
|
srb.configuration = configuration;
|
|
|
- sendAndApply(&srb);
|
|
|
+ sendAndApply(srb);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::showInfoDialog(InfoWindow * iw)
|
|
|
{
|
|
|
- sendAndApply(iw);
|
|
|
+ sendAndApply(*iw);
|
|
|
}
|
|
|
|
|
|
vstd::RNG & CGameHandler::getRandomGenerator()
|
|
@@ -4261,7 +4261,7 @@ void CGameHandler::newObject(CGObjectInstance * object, PlayerColor initiator)
|
|
|
NewObject no;
|
|
|
no.newObject = object;
|
|
|
no.initiator = initiator;
|
|
|
- sendAndApply(&no);
|
|
|
+ sendAndApply(no);
|
|
|
}
|
|
|
|
|
|
void CGameHandler::startBattle(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const BattleLayout & layout, const CGTownInstance *town)
|