mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Merge pull request #160 from vmarkovtsev/issue/2388
Fix 2388 obelisks puzzle revealing
This commit is contained in:
@@ -275,7 +275,7 @@ TSubgoal Win::whatToDoToAchieve()
|
|||||||
// 0.85 -> radius now 2 tiles
|
// 0.85 -> radius now 2 tiles
|
||||||
// 0.95 -> 1 tile radius, position is fully known
|
// 0.95 -> 1 tile radius, position is fully known
|
||||||
// AFAIK H3 AI does something like this
|
// AFAIK H3 AI does something like this
|
||||||
int3 grailPos = cb->getGrailPos(ratio);
|
int3 grailPos = cb->getGrailPos(&ratio);
|
||||||
if(ratio > 0.99)
|
if(ratio > 0.99)
|
||||||
{
|
{
|
||||||
return sptr (Goals::DigAtTile(grailPos));
|
return sptr (Goals::DigAtTile(grailPos));
|
||||||
|
@@ -2170,7 +2170,7 @@ void CPlayerInterface::showPuzzleMap()
|
|||||||
|
|
||||||
//TODO: interface should not know the real position of Grail...
|
//TODO: interface should not know the real position of Grail...
|
||||||
double ratio = 0;
|
double ratio = 0;
|
||||||
int3 grailPos = cb->getGrailPos(ratio);
|
int3 grailPos = cb->getGrailPos(&ratio);
|
||||||
|
|
||||||
GH.pushInt(new CPuzzleWindow(grailPos, ratio));
|
GH.pushInt(new CPuzzleWindow(grailPos, ratio));
|
||||||
}
|
}
|
||||||
|
@@ -219,18 +219,20 @@ void CClient::endGame( bool closeConnection /*= true*/ )
|
|||||||
GH.curInt = nullptr;
|
GH.curInt = nullptr;
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
|
boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
|
||||||
logNetwork->infoStream() << "Ending current game!";
|
logNetwork->infoStream() << "Ending current game!";
|
||||||
if(GH.topInt())
|
if(GH.topInt())
|
||||||
|
{
|
||||||
GH.topInt()->deactivate();
|
GH.topInt()->deactivate();
|
||||||
|
}
|
||||||
GH.listInt.clear();
|
GH.listInt.clear();
|
||||||
GH.objsToBlit.clear();
|
GH.objsToBlit.clear();
|
||||||
GH.statusbar = nullptr;
|
GH.statusbar = nullptr;
|
||||||
logNetwork->infoStream() << "Removed GUI.";
|
logNetwork->infoStream() << "Removed GUI.";
|
||||||
|
|
||||||
vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh);
|
vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh);
|
||||||
vstd::clear_pointer(gs);
|
vstd::clear_pointer(gs);
|
||||||
|
|
||||||
logNetwork->infoStream() << "Deleted mapHandler and gameState.";
|
logNetwork->infoStream() << "Deleted mapHandler and gameState.";
|
||||||
LOCPLINT = nullptr;
|
LOCPLINT = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,9 +240,9 @@ void CClient::endGame( bool closeConnection /*= true*/ )
|
|||||||
battleints.clear();
|
battleints.clear();
|
||||||
callbacks.clear();
|
callbacks.clear();
|
||||||
battleCallbacks.clear();
|
battleCallbacks.clear();
|
||||||
logNetwork->infoStream() << "Deleted playerInts.";
|
CGObelisk::reset();
|
||||||
|
logNetwork->infoStream() << "Deleted playerInts.";
|
||||||
logNetwork->infoStream() << "Client stopped.";
|
logNetwork->infoStream() << "Client stopped.";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
@@ -727,15 +727,16 @@ int CPlayerSpecificInfoCallback::getHeroSerial(const CGHeroInstance * hero, bool
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int3 CPlayerSpecificInfoCallback::getGrailPos( double &outKnownRatio )
|
int3 CPlayerSpecificInfoCallback::getGrailPos( double *outKnownRatio )
|
||||||
{
|
{
|
||||||
if (!player || CGObelisk::obeliskCount == 0)
|
if (!player || CGObelisk::obeliskCount == 0)
|
||||||
{
|
{
|
||||||
outKnownRatio = 0.0;
|
*outKnownRatio = 0.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outKnownRatio = static_cast<double>(CGObelisk::visited[gs->getPlayerTeam(*player)->id]) / CGObelisk::obeliskCount;
|
*outKnownRatio = static_cast<double>(CGObelisk::visited[gs->getPlayerTeam(*player)->id])
|
||||||
|
/ CGObelisk::obeliskCount;
|
||||||
}
|
}
|
||||||
return gs->map->grailPos;
|
return gs->map->grailPos;
|
||||||
}
|
}
|
||||||
|
@@ -125,7 +125,7 @@ class DLL_LINKAGE CPlayerSpecificInfoCallback : public CGameInfoCallback
|
|||||||
public:
|
public:
|
||||||
int howManyTowns() const;
|
int howManyTowns() const;
|
||||||
int howManyHeroes(bool includeGarrisoned = true) const;
|
int howManyHeroes(bool includeGarrisoned = true) const;
|
||||||
int3 getGrailPos(double &outKnownRatio);
|
int3 getGrailPos(double *outKnownRatio);
|
||||||
boost::optional<PlayerColor> getMyColor() const;
|
boost::optional<PlayerColor> getMyColor() const;
|
||||||
|
|
||||||
std::vector <const CGTownInstance *> getTownsInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible
|
std::vector <const CGTownInstance *> getTownsInfo(bool onlyOur = true) const; //true -> only owned; false -> all visible
|
||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
|
|
||||||
int getResourceAmount(Res::ERes type) const;
|
int getResourceAmount(Res::ERes type) const;
|
||||||
TResources getResourceAmount() const;
|
TResources getResourceAmount() const;
|
||||||
const std::vector< std::vector< std::vector<ui8> > > & getVisibilityMap()const; //returns visibility map
|
const std::vector< std::vector< std::vector<ui8> > > & getVisibilityMap()const; //returns visibility map
|
||||||
const PlayerSettings * getPlayerSettings(PlayerColor color) const;
|
const PlayerSettings * getPlayerSettings(PlayerColor color) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,4 +154,3 @@ public:
|
|||||||
|
|
||||||
virtual void showInfoDialog(const std::string &msg, PlayerColor player);
|
virtual void showInfoDialog(const std::string &msg, PlayerColor player);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -534,7 +534,7 @@ void CGSeerHut::newTurn() const
|
|||||||
{
|
{
|
||||||
if (quest->lastDay >= 0 && quest->lastDay < cb->getDate()-1) //time is up
|
if (quest->lastDay >= 0 && quest->lastDay < cb->getDate()-1) //time is up
|
||||||
{
|
{
|
||||||
cb->setObjProperty (id, 10, CQuest::COMPLETE);
|
cb->setObjProperty (id, CGSeerHut::OBJPROP_VISITED, CQuest::COMPLETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +551,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
if (firstVisit)
|
if (firstVisit)
|
||||||
{
|
{
|
||||||
isCustom = quest->isCustomFirst;
|
isCustom = quest->isCustomFirst;
|
||||||
cb->setObjProperty (id, 10, CQuest::IN_PROGRESS);
|
cb->setObjProperty (id, CGSeerHut::OBJPROP_VISITED, CQuest::IN_PROGRESS);
|
||||||
|
|
||||||
AddQuest aq;
|
AddQuest aq;
|
||||||
aq.quest = QuestInfo (quest, this, visitablePos());
|
aq.quest = QuestInfo (quest, this, visitablePos());
|
||||||
@@ -658,7 +658,7 @@ void CGSeerHut::finishQuest(const CGHeroInstance * h, ui32 accept) const
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cb->setObjProperty (id, 10, CQuest::COMPLETE); //mission complete
|
cb->setObjProperty (id, CGSeerHut::OBJPROP_VISITED, CQuest::COMPLETE); //mission complete
|
||||||
completeQuest(h); //make sure to remove QuestGuard at the very end
|
completeQuest(h); //make sure to remove QuestGuard at the very end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -130,6 +130,8 @@ public:
|
|||||||
h & rewardType & rID & rVal & seerName;
|
h & rewardType & rID & rVal & seerName;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
static constexpr int OBJPROP_VISITED = 10;
|
||||||
|
|
||||||
void setPropertyDer(ui8 what, ui32 val) override;
|
void setPropertyDer(ui8 what, ui32 val) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#include "../CPlayerState.h"
|
#include "../CPlayerState.h"
|
||||||
|
|
||||||
std::map <si32, std::vector<ObjectInstanceID> > CGMagi::eyelist;
|
std::map <si32, std::vector<ObjectInstanceID> > CGMagi::eyelist;
|
||||||
ui8 CGObelisk::obeliskCount; //how many obelisks are on map
|
ui8 CGObelisk::obeliskCount = 0; //how many obelisks are on map
|
||||||
std::map<TeamID, ui8> CGObelisk::visited; //map: team_id => how many obelisks has been visited
|
std::map<TeamID, ui8> CGObelisk::visited; //map: team_id => how many obelisks has been visited
|
||||||
|
|
||||||
///helpers
|
///helpers
|
||||||
@@ -60,7 +60,7 @@ static std::string & visitedTxt(const bool visited)
|
|||||||
|
|
||||||
void CPlayersVisited::setPropertyDer( ui8 what, ui32 val )
|
void CPlayersVisited::setPropertyDer( ui8 what, ui32 val )
|
||||||
{
|
{
|
||||||
if(what == 10)
|
if(what == CPlayersVisited::OBJPROP_VISITED)
|
||||||
players.insert(PlayerColor(val));
|
players.insert(PlayerColor(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1314,7 +1314,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
iw.soundID = soundBase::gazebo;
|
iw.soundID = soundBase::gazebo;
|
||||||
iw.player = h->getOwner();
|
iw.player = h->getOwner();
|
||||||
if(!wasVisited(h->tempOwner))
|
if(!wasVisited(h->tempOwner))
|
||||||
cb->setObjProperty(id, 10, h->tempOwner.getNum());
|
cb->setObjProperty(id, CGWitchHut::OBJPROP_VISITED, h->tempOwner.getNum());
|
||||||
ui32 txt_id;
|
ui32 txt_id;
|
||||||
if(h->getSecSkillLevel(SecondarySkill(ability))) //you already know this skill
|
if(h->getSecSkillLevel(SecondarySkill(ability))) //you already know this skill
|
||||||
{
|
{
|
||||||
@@ -1424,7 +1424,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!wasVisited(h->tempOwner))
|
if(!wasVisited(h->tempOwner))
|
||||||
cb->setObjProperty(id, 10, h->tempOwner.getNum());
|
cb->setObjProperty(id, CGShrine::OBJPROP_VISITED, h->tempOwner.getNum());
|
||||||
|
|
||||||
InfoWindow iw;
|
InfoWindow iw;
|
||||||
iw.soundID = soundBase::temple;
|
iw.soundID = soundBase::temple;
|
||||||
@@ -1826,7 +1826,7 @@ void CCartographer::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answ
|
|||||||
//water = 0; land = 1; underground = 2;
|
//water = 0; land = 1; underground = 2;
|
||||||
cb->getAllTiles (fw.tiles, hero->tempOwner, subID - 1, !subID + 1); //reveal appropriate tiles
|
cb->getAllTiles (fw.tiles, hero->tempOwner, subID - 1, !subID + 1); //reveal appropriate tiles
|
||||||
cb->sendAndApply (&fw);
|
cb->sendAndApply (&fw);
|
||||||
cb->setObjProperty (id, 10, hero->tempOwner.getNum());
|
cb->setObjProperty (id, CCartographer::OBJPROP_VISITED, hero->tempOwner.getNum());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1848,11 +1848,16 @@ void CGObelisk::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
iw.text.addTxt(MetaString::ADVOB_TXT, 96);
|
iw.text.addTxt(MetaString::ADVOB_TXT, 96);
|
||||||
cb->sendAndApply(&iw);
|
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());
|
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 for all players in the team
|
||||||
|
for (auto & color : ts->players)
|
||||||
|
{
|
||||||
|
cb->setObjProperty(id, CGObelisk::OBJPROP_VISITED, color.getNum());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1867,6 +1872,12 @@ void CGObelisk::initObj()
|
|||||||
obeliskCount++;
|
obeliskCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGObelisk::reset()
|
||||||
|
{
|
||||||
|
obeliskCount = 0;
|
||||||
|
visited.clear();
|
||||||
|
}
|
||||||
|
|
||||||
std::string CGObelisk::getHoverText(PlayerColor player) const
|
std::string CGObelisk::getHoverText(PlayerColor player) const
|
||||||
{
|
{
|
||||||
return getObjectName() + " " + visitedTxt(wasVisited(player));
|
return getObjectName() + " " + visitedTxt(wasVisited(player));
|
||||||
@@ -1874,20 +1885,26 @@ std::string CGObelisk::getHoverText(PlayerColor player) const
|
|||||||
|
|
||||||
void CGObelisk::setPropertyDer( ui8 what, ui32 val )
|
void CGObelisk::setPropertyDer( ui8 what, ui32 val )
|
||||||
{
|
{
|
||||||
CPlayersVisited::setPropertyDer(what, val);
|
|
||||||
switch(what)
|
switch(what)
|
||||||
{
|
{
|
||||||
case 20:
|
case CGObelisk::OBJPROP_INC:
|
||||||
assert(val < PlayerColor::PLAYER_LIMIT_I);
|
{
|
||||||
visited[TeamID(val)]++;
|
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)
|
if(progress > obeliskCount)
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Error: Visited " << visited[TeamID(val)] << "\t\t" << obeliskCount;
|
logGlobal->errorStream() << "Error: Visited " << progress << "\t\t" << obeliskCount;
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
CPlayersVisited::setPropertyDer(what, val);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,8 @@ public:
|
|||||||
h & static_cast<CGObjectInstance&>(*this);
|
h & static_cast<CGObjectInstance&>(*this);
|
||||||
h & players;
|
h & players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr int OBJPROP_VISITED = 10;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE CGCreature : public CArmedInstance //creatures on map
|
class DLL_LINKAGE CGCreature : public CArmedInstance //creatures on map
|
||||||
@@ -451,12 +453,14 @@ class DLL_LINKAGE CGDenOfthieves : public CGObjectInstance
|
|||||||
class DLL_LINKAGE CGObelisk : public CPlayersVisited
|
class DLL_LINKAGE CGObelisk : public CPlayersVisited
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static constexpr int OBJPROP_INC = 20;
|
||||||
static ui8 obeliskCount; //how many obelisks are on map
|
static ui8 obeliskCount; //how many obelisks are on map
|
||||||
static std::map<TeamID, ui8> visited; //map: team_id => how many obelisks has been visited
|
static std::map<TeamID, ui8> visited; //map: team_id => how many obelisks has been visited
|
||||||
|
|
||||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||||
void initObj() override;
|
void initObj() override;
|
||||||
std::string getHoverText(PlayerColor player) const override;
|
std::string getHoverText(PlayerColor player) const override;
|
||||||
|
static void reset();
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user