1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Squashed commit of PR #314:

commit 437c6c6fd4931abe69d3b7fe501b231a74182159
Author: Piotr Wójcik <chocimier@tlen.pl>
Date:   Sat Jun 24 18:36:16 2017 +0200

    Rename CPlayersVisited to CTeamVisited

commit baf1423cd9b090eaaa0a6962f2bd0f440e2e0747
Author: Piotr Wójcik <chocimier@tlen.pl>
Date:   Wed Jun 21 16:41:37 2017 +0200

    Share visited status of CPlayersVisited objects across team
This commit is contained in:
Piotr Wójcik
2017-06-30 23:39:37 +03:00
committed by Arseniy Shestakov
parent 29e50cc21c
commit 7bc9853175
3 changed files with 21 additions and 20 deletions

View File

@@ -60,18 +60,18 @@ static std::string & visitedTxt(const bool visited)
return VLC->generaltexth->allTexts[id]; return VLC->generaltexth->allTexts[id];
} }
void CPlayersVisited::setPropertyDer( ui8 what, ui32 val ) void CTeamVisited::setPropertyDer(ui8 what, ui32 val)
{ {
if(what == CPlayersVisited::OBJPROP_VISITED) if(what == CTeamVisited::OBJPROP_VISITED)
players.insert(PlayerColor(val)); players.insert(PlayerColor(val));
} }
bool CPlayersVisited::wasVisited( PlayerColor player ) const bool CTeamVisited::wasVisited(PlayerColor player) const
{ {
return vstd::contains(players,player); return wasVisited(cb->getPlayer(player)->team);
} }
bool CPlayersVisited::wasVisited( TeamID team ) const bool CTeamVisited::wasVisited(TeamID team) const
{ {
for(auto i : players) for(auto i : players)
{ {
@@ -2127,7 +2127,7 @@ void CGObelisk::setPropertyDer( ui8 what, ui32 val )
break; break;
} }
default: default:
CPlayersVisited::setPropertyDer(what, val); CTeamVisited::setPropertyDer(what, val);
break; break;
} }
} }

View File

@@ -16,7 +16,8 @@
class CMap; class CMap;
class DLL_LINKAGE CPlayersVisited: public CGObjectInstance /// Legacy class, use CRewardableObject instead
class DLL_LINKAGE CTeamVisited: public CGObjectInstance
{ {
public: public:
std::set<PlayerColor> players; //players that visited this object std::set<PlayerColor> players; //players that visited this object
@@ -116,7 +117,7 @@ protected:
void serializeJsonOptions(JsonSerializeFormat & handler) override; void serializeJsonOptions(JsonSerializeFormat & handler) override;
}; };
class DLL_LINKAGE CGWitchHut : public CPlayersVisited class DLL_LINKAGE CGWitchHut : public CTeamVisited
{ {
public: public:
std::vector<si32> allowedAbilities; std::vector<si32> allowedAbilities;
@@ -128,7 +129,7 @@ public:
void initObj(CRandomGenerator & rand) override; void initObj(CRandomGenerator & rand) override;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CPlayersVisited&>(*this); h & static_cast<CTeamVisited&>(*this);
h & allowedAbilities & ability; h & allowedAbilities & ability;
} }
protected: protected:
@@ -224,7 +225,7 @@ protected:
void serializeJsonOptions(JsonSerializeFormat & handler) override; void serializeJsonOptions(JsonSerializeFormat & handler) override;
}; };
class DLL_LINKAGE CGShrine : public CPlayersVisited class DLL_LINKAGE CGShrine : public CTeamVisited
{ {
public: public:
SpellID spell; //id of spell or NONE if random SpellID spell; //id of spell or NONE if random
@@ -235,7 +236,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CPlayersVisited&>(*this);; h & static_cast<CTeamVisited&>(*this);;
h & spell; h & spell;
} }
protected: protected:
@@ -454,7 +455,7 @@ public:
} }
}; };
class DLL_LINKAGE CCartographer : public CPlayersVisited class DLL_LINKAGE CCartographer : public CTeamVisited
{ {
///behaviour varies depending on surface and floor ///behaviour varies depending on surface and floor
public: public:
@@ -463,7 +464,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CPlayersVisited&>(*this); h & static_cast<CTeamVisited&>(*this);
} }
}; };
@@ -472,7 +473,7 @@ class DLL_LINKAGE CGDenOfthieves : public CGObjectInstance
void onHeroVisit(const CGHeroInstance * h) const override; void onHeroVisit(const CGHeroInstance * h) const override;
}; };
class DLL_LINKAGE CGObelisk : public CPlayersVisited class DLL_LINKAGE CGObelisk : public CTeamVisited
{ {
public: public:
static const int OBJPROP_INC = 20; static const int OBJPROP_INC = 20;
@@ -486,7 +487,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & static_cast<CPlayersVisited&>(*this); h & static_cast<CTeamVisited&>(*this);
} }
protected: protected:
void setPropertyDer(ui8 what, ui32 val) override; void setPropertyDer(ui8 what, ui32 val) override;

View File

@@ -153,11 +153,11 @@ void registerTypesMapObjects2(Serializer &s)
s.template registerType<CRewardableObject, CGOnceVisitable>(); s.template registerType<CRewardableObject, CGOnceVisitable>();
s.template registerType<CGVisitableOPW, CGMagicSpring>(); s.template registerType<CGVisitableOPW, CGMagicSpring>();
s.template registerType<CGObjectInstance, CPlayersVisited>(); s.template registerType<CGObjectInstance, CTeamVisited>();
s.template registerType<CPlayersVisited, CGWitchHut>(); s.template registerType<CTeamVisited, CGWitchHut>();
s.template registerType<CPlayersVisited, CGShrine>(); s.template registerType<CTeamVisited, CGShrine>();
s.template registerType<CPlayersVisited, CCartographer>(); s.template registerType<CTeamVisited, CCartographer>();
s.template registerType<CPlayersVisited, CGObelisk>(); s.template registerType<CTeamVisited, CGObelisk>();
//s.template registerType<CQuest>(); //s.template registerType<CQuest>();
//s.template registerType<IQuestObject>(); //s.template registerType<IQuestObject>();