1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

bugfixing:

- fixed parsing of campaign bonuses (conversion to building ID)
- CONTROL event condition can be also fulfilled by allies
- fix for crash on opening exchange window in Russian version
This commit is contained in:
Ivan Savenko 2014-02-26 17:32:42 +00:00
parent d049abe644
commit 78609871ae
3 changed files with 38 additions and 29 deletions

View File

@ -5147,7 +5147,6 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
CWindowObject(PLAYER_COLORED | BORDERED, "TRADE2") CWindowObject(PLAYER_COLORED | BORDERED, "TRADE2")
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL; OBJ_CONSTRUCTION_CAPTURING_ALL;
char bufor[400];
heroInst[0] = LOCPLINT->cb->getHero(hero1); heroInst[0] = LOCPLINT->cb->getHero(hero1);
heroInst[1] = LOCPLINT->cb->getHero(hero2); heroInst[1] = LOCPLINT->cb->getHero(hero2);
@ -5175,8 +5174,8 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
primSkillAreas[g]->type = g; primSkillAreas[g]->type = g;
primSkillAreas[g]->bonusValue = -1; primSkillAreas[g]->bonusValue = -1;
primSkillAreas[g]->baseType = 0; primSkillAreas[g]->baseType = 0;
sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), CGI->generaltexth->primarySkillNames[g].c_str()); primSkillAreas[g]->hoverText = CGI->generaltexth->heroscrn[1];
primSkillAreas[g]->hoverText = std::string(bufor); boost::replace_first(primSkillAreas[g]->hoverText, "%s", CGI->generaltexth->primarySkillNames[g]);
} }
//heroes related thing //heroes related thing
@ -5195,8 +5194,9 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
secSkillAreas[b][g]->bonusValue = level; secSkillAreas[b][g]->bonusValue = level;
secSkillAreas[b][g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1]; secSkillAreas[b][g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1];
sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[level - 1].c_str(), CGI->generaltexth->skillName[skill].c_str()); secSkillAreas[b][g]->hoverText = CGI->generaltexth->heroscrn[21];
secSkillAreas[b][g]->hoverText = std::string(bufor); boost::algorithm::replace_first(secSkillAreas[b][g]->hoverText, "%s", CGI->generaltexth->levels[level - 1]);
boost::algorithm::replace_first(secSkillAreas[b][g]->hoverText, "%s", CGI->generaltexth->skillName[skill]);
} }
portrait[b] = new CHeroArea(257 + 228*b, 13, heroInst[b]); portrait[b] = new CHeroArea(257 + 228*b, 13, heroInst[b]);
@ -5210,15 +5210,17 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
experience[b]->pos = genRect(32, 32, pos.x + 105 + 490*b, pos.y + 45); experience[b]->pos = genRect(32, 32, pos.x + 105 + 490*b, pos.y + 45);
experience[b]->hoverText = CGI->generaltexth->heroscrn[9]; experience[b]->hoverText = CGI->generaltexth->heroscrn[9];
experience[b]->text = CGI->generaltexth->allTexts[2].c_str(); experience[b]->text = CGI->generaltexth->allTexts[2].c_str();
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->level)); boost::algorithm::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->level));
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(heroInst[b]->level+1))); boost::algorithm::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(heroInst[b]->level+1)));
boost::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->exp)); boost::algorithm::replace_first(experience[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->exp));
spellPoints[b] = new LRClickableAreaWText(); spellPoints[b] = new LRClickableAreaWText();
spellPoints[b]->pos = genRect(32, 32, pos.x + 141 + 490*b, pos.y + 45); spellPoints[b]->pos = genRect(32, 32, pos.x + 141 + 490*b, pos.y + 45);
spellPoints[b]->hoverText = CGI->generaltexth->heroscrn[22]; spellPoints[b]->hoverText = CGI->generaltexth->heroscrn[22];
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), heroInst[b]->name.c_str(), heroInst[b]->mana, heroInst[b]->manaLimit()); spellPoints[b]->text = CGI->generaltexth->allTexts[205];
spellPoints[b]->text = std::string(bufor); boost::algorithm::replace_first(spellPoints[b]->text, "%s", heroInst[b]->name);
boost::algorithm::replace_first(spellPoints[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->mana));
boost::algorithm::replace_first(spellPoints[b]->text, "%d", boost::lexical_cast<std::string>(heroInst[b]->manaLimit()));
//setting morale //setting morale
morale[b] = new MoraleLuckBox(true, genRect(32, 32, 176 + 490*b, 39), true); morale[b] = new MoraleLuckBox(true, genRect(32, 32, 176 + 490*b, 39), true);

View File

@ -32,7 +32,7 @@ BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<Buildi
list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)}; list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)};
int curPos = campToERMU.size(); int curPos = campToERMU.size();
for (int i=0; i<7; ++i) for (int i=0; i<GameConstants::CREATURES_PER_TOWN; ++i)
{ {
if(camp == curPos) //non-upgraded if(camp == curPos) //non-upgraded
return BuildingID(30 + i); return BuildingID(30 + i);
@ -40,31 +40,34 @@ BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<Buildi
if(camp == curPos) //upgraded if(camp == curPos) //upgraded
return BuildingID(37 + i); return BuildingID(37 + i);
curPos++; curPos++;
//horde building
if (vstd::contains(hordeLvlsPerTType[townType], i)) if (i < 5) // last two levels don't have reserved horde ID. Yet another H3C weirdeness
{ {
if (camp == curPos) if (vstd::contains(hordeLvlsPerTType[townType], i))
{ {
if (hordeLvlsPerTType[townType][0] == i) if (camp == curPos)
{ {
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][0])) //if upgraded dwelling is built if (hordeLvlsPerTType[townType][0] == i)
return BuildingID::HORDE_1_UPGR;
else //upgraded dwelling not presents
return BuildingID::HORDE_1;
}
else
{
if(hordeLvlsPerTType[townType].size() > 1)
{ {
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][1])) //if upgraded dwelling is built if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][0])) //if upgraded dwelling is built
return BuildingID::HORDE_2_UPGR; return BuildingID::HORDE_1_UPGR;
else //upgraded dwelling not presents else //upgraded dwelling not presents
return BuildingID::HORDE_2; return BuildingID::HORDE_1;
}
else
{
if(hordeLvlsPerTType[townType].size() > 1)
{
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][1])) //if upgraded dwelling is built
return BuildingID::HORDE_2_UPGR;
else //upgraded dwelling not presents
return BuildingID::HORDE_2;
}
} }
} }
} }
curPos++;
} }
curPos++;
} }
assert(0); assert(0);
return BuildingID::NONE; //not found return BuildingID::NONE; //not found

View File

@ -2438,16 +2438,20 @@ bool CGameState::checkForVictory( PlayerColor player, const EventCondition & con
} }
case EventCondition::CONTROL: case EventCondition::CONTROL:
{ {
// list of players that need to control object to fulfull condition
// NOTE: cgameinfocallback specified explicitly in order to get const version
auto & team = CGameInfoCallback::getPlayerTeam(player)->players;
if (condition.object) // mode A - flag one specific object, like town if (condition.object) // mode A - flag one specific object, like town
{ {
return condition.object->tempOwner == player; return team.count(condition.object->tempOwner) != 0;
} }
else else
{ {
for(auto & elem : map->objects) // mode B - flag all objects of this type for(auto & elem : map->objects) // mode B - flag all objects of this type
{ {
//check not flagged objs //check not flagged objs
if(elem && elem->tempOwner != player && elem->ID == condition.objectType) if ( elem && elem->ID == condition.objectType && team.count(elem->tempOwner) == 0 )
return false; return false;
} }
return true; return true;