mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Fix obelisks puzzle revealing
Teams and players were messed up in lib; hardcoded constants were refactored.
This commit is contained in:
@ -60,7 +60,7 @@ static std::string & visitedTxt(const bool visited)
|
||||
|
||||
void CPlayersVisited::setPropertyDer( ui8 what, ui32 val )
|
||||
{
|
||||
if(what == 10)
|
||||
if(what == CPlayersVisited::OBJPROP_VISITED)
|
||||
players.insert(PlayerColor(val));
|
||||
}
|
||||
|
||||
@ -103,16 +103,16 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
|
||||
{
|
||||
std::string hoverName;
|
||||
if(hero->hasVisions(this, 0))
|
||||
{
|
||||
{
|
||||
MetaString ms;
|
||||
ms << stacks.begin()->second->count;
|
||||
ms << " " ;
|
||||
ms.addTxt(MetaString::CRE_PL_NAMES,subID);
|
||||
|
||||
|
||||
ms << "\n";
|
||||
|
||||
|
||||
int decision = takenAction(hero, true);
|
||||
|
||||
|
||||
switch (decision)
|
||||
{
|
||||
case FIGHT:
|
||||
@ -123,19 +123,19 @@ std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
|
||||
break;
|
||||
case JOIN_FOR_FREE:
|
||||
ms.addTxt(MetaString::GENERAL_TXT,243);
|
||||
break;
|
||||
break;
|
||||
default: //decision = cost in gold
|
||||
VLC->generaltexth->allTexts[244];
|
||||
ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision);
|
||||
ms << boost::to_string(boost::format(VLC->generaltexth->allTexts[244]) % decision);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ms.toString(hoverName);
|
||||
ms.toString(hoverName);
|
||||
}
|
||||
else
|
||||
{
|
||||
hoverName = getHoverText(hero->tempOwner);
|
||||
}
|
||||
hoverName = getHoverText(hero->tempOwner);
|
||||
}
|
||||
|
||||
const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"];
|
||||
|
||||
@ -1310,7 +1310,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
||||
iw.soundID = soundBase::gazebo;
|
||||
iw.player = h->getOwner();
|
||||
if(!wasVisited(h->tempOwner))
|
||||
cb->setObjProperty(id, 10, h->tempOwner.getNum());
|
||||
cb->setObjProperty(id, CGWitchHut::OBJPROP_VISITED, h->tempOwner.getNum());
|
||||
ui32 txt_id;
|
||||
if(h->getSecSkillLevel(SecondarySkill(ability))) //you already know this skill
|
||||
{
|
||||
@ -1420,7 +1420,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
|
||||
}
|
||||
|
||||
if(!wasVisited(h->tempOwner))
|
||||
cb->setObjProperty(id, 10, h->tempOwner.getNum());
|
||||
cb->setObjProperty(id, CGShrine::OBJPROP_VISITED, h->tempOwner.getNum());
|
||||
|
||||
InfoWindow iw;
|
||||
iw.soundID = soundBase::temple;
|
||||
@ -1745,7 +1745,7 @@ void CGShipyard::getOutOffsets( std::vector<int3> &offsets ) const
|
||||
int3(-3,0,0), int3(1,0,0), //AB
|
||||
int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG
|
||||
int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const
|
||||
@ -1821,7 +1821,7 @@ void CCartographer::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answ
|
||||
//water = 0; land = 1; underground = 2;
|
||||
cb->getAllTiles (fw.tiles, hero->tempOwner, subID - 1, !subID + 1); //reveal appropriate tiles
|
||||
cb->sendAndApply (&fw);
|
||||
cb->setObjProperty (id, 10, hero->tempOwner.getNum());
|
||||
cb->setObjProperty (id, CCartographer::OBJPROP_VISITED, hero->tempOwner.getNum());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1843,11 +1843,13 @@ void CGObelisk::onHeroVisit( const CGHeroInstance * h ) const
|
||||
iw.text.addTxt(MetaString::ADVOB_TXT, 96);
|
||||
cb->sendAndApply(&iw);
|
||||
|
||||
cb->setObjProperty(id, 20, h->tempOwner.getNum()); //increment general visited obelisks counter
|
||||
// increment general visited obelisks counter
|
||||
cb->setObjProperty(id, CGObelisk::OBJPROP_INC, team.getNum());
|
||||
|
||||
openWindow(OpenWindow::PUZZLE_MAP, h->tempOwner.getNum());
|
||||
|
||||
cb->setObjProperty(id, 10, h->tempOwner.getNum()); //mark that particular obelisk as visited
|
||||
// mark that particular obelisk as visited
|
||||
cb->setObjProperty(id, CGObelisk::OBJPROP_VISITED, h->tempOwner.getNum());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1869,20 +1871,26 @@ std::string CGObelisk::getHoverText(PlayerColor player) const
|
||||
|
||||
void CGObelisk::setPropertyDer( ui8 what, ui32 val )
|
||||
{
|
||||
CPlayersVisited::setPropertyDer(what, val);
|
||||
switch(what)
|
||||
{
|
||||
case 20:
|
||||
assert(val < PlayerColor::PLAYER_LIMIT_I);
|
||||
visited[TeamID(val)]++;
|
||||
case CGObelisk::OBJPROP_INC:
|
||||
{
|
||||
assert(val < PlayerColor::PLAYER_LIMIT_I);
|
||||
auto progress = ++visited[TeamID(val)];
|
||||
logGlobal->debugStream() << boost::format("Player %d: obelisk progress %d / %d")
|
||||
% val % static_cast<int>(progress) % static_cast<int>(obeliskCount);
|
||||
|
||||
if(visited[TeamID(val)] > obeliskCount)
|
||||
{
|
||||
logGlobal->errorStream() << "Error: Visited " << visited[TeamID(val)] << "\t\t" << obeliskCount;
|
||||
assert(0);
|
||||
}
|
||||
if(progress > obeliskCount)
|
||||
{
|
||||
logGlobal->errorStream() << "Error: Visited " << progress << "\t\t" << obeliskCount;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
CPlayersVisited::setPropertyDer(what, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user