mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Creature banks are now functional, however there are some glitches listed on our board.
This commit is contained in:
parent
df6a7d680e
commit
7660e29751
@ -4078,9 +4078,6 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
|
|||||||
loot << "%d %s";
|
loot << "%d %s";
|
||||||
loot.addReplacement (iw.components.back().val);
|
loot.addReplacement (iw.components.back().val);
|
||||||
loot.addReplacement (MetaString::RES_NAMES, iw.components.back().subtype);
|
loot.addReplacement (MetaString::RES_NAMES, iw.components.back().subtype);
|
||||||
//loot << iw.components.back().val << " ";
|
|
||||||
//loot.addTxt (iw.components.back().val);
|
|
||||||
//loot.addTxt (MetaString::RES_NAMES, iw.components.back().subtype);
|
|
||||||
cb->giveResource (h->getOwner(), it, bc->resources[it]);
|
cb->giveResource (h->getOwner(), it, bc->resources[it]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4093,19 +4090,21 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
|
|||||||
cb->giveHeroArtifact (*it, h->id ,-2);
|
cb->giveHeroArtifact (*it, h->id ,-2);
|
||||||
}
|
}
|
||||||
//display loot
|
//display loot
|
||||||
if (textID == 34)
|
if (!loot.message.empty())
|
||||||
{
|
{
|
||||||
iw.text.addTxt(MetaString::ADVOB_TXT,34);//Heaving defeated %s, you discover %s
|
if (textID == 34)
|
||||||
iw.text.addReplacement(MetaString::CRE_PL_NAMES, result->casualties[1].begin()->first);
|
{
|
||||||
//std::string loot_final;
|
iw.text.addTxt(MetaString::ADVOB_TXT, 34);//Heaving defeated %s, you discover %s
|
||||||
//loot.toString (loot_final);
|
iw.text.addReplacement (MetaString::CRE_PL_NAMES, result->casualties[1].begin()->first);
|
||||||
iw.text.addReplacement (loot.buildList());
|
iw.text.addReplacement (loot.buildList());
|
||||||
//iw.text.addReplacement(" %d %s%s%d %s");
|
}
|
||||||
|
else
|
||||||
|
iw.text.addTxt (MetaString::ADVOB_TXT, textID);
|
||||||
|
cb->showInfoDialog(&iw);
|
||||||
}
|
}
|
||||||
else
|
loot.clear();
|
||||||
iw.text.addTxt (MetaString::ADVOB_TXT, textID);
|
iw.components.clear();
|
||||||
|
iw.text.clear();
|
||||||
cb->showInfoDialog(&iw);
|
|
||||||
|
|
||||||
//grant creatures
|
//grant creatures
|
||||||
CCreatureSet ourArmy;
|
CCreatureSet ourArmy;
|
||||||
@ -4115,7 +4114,28 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
|
|||||||
ourArmy.slots[slot].first = it->first;
|
ourArmy.slots[slot].first = it->first;
|
||||||
ourArmy.slots[slot].second += it->second;
|
ourArmy.slots[slot].second += it->second;
|
||||||
}
|
}
|
||||||
cb->giveCreatures (id, h, &ourArmy);
|
for (std::map<si32,std::pair<ui32,si32> >::const_iterator i = ourArmy.slots.begin(); i != ourArmy.slots.end(); i++)
|
||||||
|
{
|
||||||
|
iw.components.push_back (Component(Component::CREATURE, i->second.first, i->second.second, 0));
|
||||||
|
loot << "%s";
|
||||||
|
if (i->second.second == 1)
|
||||||
|
loot.addReplacement (MetaString::CRE_SING_NAMES, i->second.first);
|
||||||
|
else
|
||||||
|
loot.addReplacement (MetaString::CRE_PL_NAMES, i->second.first);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ourArmy.slots.size())
|
||||||
|
{
|
||||||
|
if (ourArmy.slots.size() == 1 && ourArmy.slots.begin()->second.second == 1)
|
||||||
|
iw.text.addTxt (MetaString::ADVOB_TXT, 185);
|
||||||
|
else
|
||||||
|
iw.text.addTxt (MetaString::ADVOB_TXT, 186);
|
||||||
|
|
||||||
|
iw.text.addReplacement (loot.buildList());
|
||||||
|
iw.text.addReplacement (h->name);
|
||||||
|
cb->showInfoDialog(&iw);
|
||||||
|
cb->giveCreatures (id, h, &ourArmy);
|
||||||
|
}
|
||||||
cb->setObjProperty (id, 15, 0); //bc = NULL
|
cb->setObjProperty (id, 15, 0); //bc = NULL
|
||||||
}
|
}
|
||||||
else //in case of defeat
|
else //in case of defeat
|
||||||
|
2
int3.h
2
int3.h
@ -89,7 +89,7 @@ public:
|
|||||||
}
|
}
|
||||||
operator bool() const
|
operator bool() const
|
||||||
{
|
{
|
||||||
return slots.size()>0;
|
return slots.size() > 0;
|
||||||
}
|
}
|
||||||
void sweep()
|
void sweep()
|
||||||
{
|
{
|
||||||
|
@ -265,7 +265,7 @@ DLL_EXPORT std::string MetaString::buildList () const
|
|||||||
{
|
{
|
||||||
if (i > 0 && message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING)
|
if (i > 0 && message[i] == TEXACT_STRING || message[i] == TLOCAL_STRING)
|
||||||
{
|
{
|
||||||
if (i == message.size())
|
if (i == message.size() - 1)
|
||||||
lista += " and ";
|
lista += " and ";
|
||||||
else
|
else
|
||||||
lista += ", ";
|
lista += ", ";
|
||||||
|
@ -1566,19 +1566,17 @@ void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreature
|
|||||||
if (creatures->slots.size() <= 0)
|
if (creatures->slots.size() <= 0)
|
||||||
return;
|
return;
|
||||||
CCreatureSet heroArmy = h->army;
|
CCreatureSet heroArmy = h->army;
|
||||||
while (creatures)
|
while (*creatures)
|
||||||
{
|
{
|
||||||
int slot = heroArmy.getSlotFor(creatures->slots.begin()->second.first);
|
int slot = heroArmy.getSlotFor (creatures->slots.begin()->second.first);
|
||||||
if(slot < 0)
|
if (slot < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
heroArmy.slots[slot].first = creatures->slots.begin()->second.first;
|
heroArmy.slots[slot].first = creatures->slots.begin()->second.first;
|
||||||
heroArmy.slots[slot].second += creatures->slots.begin()->second.second;
|
heroArmy.slots[slot].second += creatures->slots.begin()->second.second;
|
||||||
creatures->slots.erase(creatures->slots.begin());
|
creatures->slots.erase (creatures->slots.begin());
|
||||||
//ourArmy.slots.erase(ourArmy.slots.begin());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!creatures) //all creatures can be moved to hero army - do that
|
if (!*creatures) //all creatures can be moved to hero army - do that
|
||||||
{
|
{
|
||||||
SetGarrisons sg;
|
SetGarrisons sg;
|
||||||
sg.garrs[h->id] = heroArmy;
|
sg.garrs[h->id] = heroArmy;
|
||||||
@ -1588,8 +1586,8 @@ void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreature
|
|||||||
{
|
{
|
||||||
SetGarrisons sg;
|
SetGarrisons sg;
|
||||||
sg.garrs[objid] = *creatures;
|
sg.garrs[objid] = *creatures;
|
||||||
sendAndApply(&sg);
|
sendAndApply (&sg);
|
||||||
showGarrisonDialog(objid, h->id, true, 0);
|
showGarrisonDialog (objid, h->id, true, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user