mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
suggested changes
This commit is contained in:
parent
d16632b54c
commit
a42b60feb9
@ -142,7 +142,7 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsI
|
||||
}
|
||||
else if(auto art = artPlace.getArt())
|
||||
{
|
||||
if(artSetPtr->getHero()->tempOwner == LOCPLINT->playerID)
|
||||
if(artSetPtr->getHero()->getOwner() == LOCPLINT->playerID)
|
||||
{
|
||||
if(checkSpecialArts(*art, hero, std::is_same_v<decltype(artSetWeak), std::weak_ptr<CArtifactsOfHeroAltar>> ? true : false))
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artPlace.slot), ArtifactLocation(artSetPtr->getHero()->id, ArtifactPosition::TRANSITION_POS));
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "mapObjects/CGHeroInstance.h"
|
||||
#include "mapObjects/CGTownInstance.h"
|
||||
#include "mapObjects/MiscObjects.h"
|
||||
#include "mapObjects/CGMarket.h"
|
||||
#include "networkPacks/ArtifactLocation.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "StartInfo.h" // for StartInfo
|
||||
@ -969,30 +968,9 @@ const CGObjectInstance * CGameInfoCallback::getObjInstance( ObjectInstanceID oid
|
||||
return gs->map->objects[oid.num];
|
||||
}
|
||||
|
||||
CArtifactSet * CGameInfoCallback::getArtSet(const ArtifactLocation & loc) const
|
||||
const CArtifactSet * CGameInfoCallback::getArtSet(const ArtifactLocation & loc) const
|
||||
{
|
||||
if(auto hero = const_cast<CGHeroInstance*>(getHero(loc.artHolder)))
|
||||
{
|
||||
if(loc.creature.has_value())
|
||||
{
|
||||
if(loc.creature.value() == SlotID::COMMANDER_SLOT_PLACEHOLDER)
|
||||
return hero->commander;
|
||||
else
|
||||
return hero->getStackPtr(loc.creature.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
return hero;
|
||||
}
|
||||
}
|
||||
else if(auto market = dynamic_cast<const CGArtifactsAltar*>(getObj(loc.artHolder, false)))
|
||||
{
|
||||
return const_cast<CGArtifactsAltar*>(market);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return gs->getArtSet(loc);
|
||||
}
|
||||
|
||||
std::vector<ObjectInstanceID> CGameInfoCallback::getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const
|
||||
|
@ -180,7 +180,7 @@ public:
|
||||
virtual int64_t estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const; //estimates damage of given spell; returns 0 if spell causes no dmg
|
||||
virtual const CArtifactInstance * getArtInstance(ArtifactInstanceID aid) const;
|
||||
virtual const CGObjectInstance * getObjInstance(ObjectInstanceID oid) const;
|
||||
virtual CArtifactSet * getArtSet(const ArtifactLocation & loc) const;
|
||||
virtual const CArtifactSet * getArtSet(const ArtifactLocation & loc) const;
|
||||
//virtual const CGObjectInstance * getArmyInstance(ObjectInstanceID oid) const;
|
||||
|
||||
//objects
|
||||
|
@ -20,11 +20,13 @@
|
||||
#include "bonuses/Propagators.h"
|
||||
#include "bonuses/Updaters.h"
|
||||
|
||||
#include "networkPacks/ArtifactLocation.h"
|
||||
#include "serializer/CLoadFile.h"
|
||||
#include "serializer/CSaveFile.h"
|
||||
#include "rmg/CMapGenOptions.h"
|
||||
#include "mapObjectConstructors/AObjectTypeHandler.h"
|
||||
#include "mapObjectConstructors/CObjectClassesHandler.h"
|
||||
#include "mapObjects/CGMarket.h"
|
||||
#include "mapObjects/CGTownInstance.h"
|
||||
#include "mapObjects/CObjectHandler.h"
|
||||
#include "mapObjects/CQuest.h"
|
||||
@ -268,6 +270,32 @@ CArmedInstance * CNonConstInfoCallback::getArmyInstance(const ObjectInstanceID &
|
||||
return dynamic_cast<CArmedInstance *>(getObjInstance(oid));
|
||||
}
|
||||
|
||||
CArtifactSet * CNonConstInfoCallback::getArtSet(const ArtifactLocation & loc)
|
||||
{
|
||||
if(auto hero = getHero(loc.artHolder))
|
||||
{
|
||||
if(loc.creature.has_value())
|
||||
{
|
||||
if(loc.creature.value() == SlotID::COMMANDER_SLOT_PLACEHOLDER)
|
||||
return hero->commander;
|
||||
else
|
||||
return hero->getStackPtr(loc.creature.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
return hero;
|
||||
}
|
||||
}
|
||||
else if(auto market = dynamic_cast<CGArtifactsAltar*>(getObjInstance(loc.artHolder)))
|
||||
{
|
||||
return market;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool IGameCallback::isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, const CGHeroInstance *hero)
|
||||
{
|
||||
//only server knows
|
||||
|
@ -146,6 +146,7 @@ public:
|
||||
using CGameInfoCallback::getTile;
|
||||
using CGameInfoCallback::getArtInstance;
|
||||
using CGameInfoCallback::getObjInstance;
|
||||
using CGameInfoCallback::getArtSet;
|
||||
|
||||
PlayerState * getPlayerState(const PlayerColor & color, bool verbose = true);
|
||||
TeamState * getTeam(const TeamID & teamID); //get team by team ID
|
||||
@ -156,6 +157,7 @@ public:
|
||||
CArtifactInstance * getArtInstance(const ArtifactInstanceID & aid);
|
||||
CGObjectInstance * getObjInstance(const ObjectInstanceID & oid);
|
||||
CArmedInstance * getArmyInstance(const ObjectInstanceID & oid);
|
||||
CArtifactSet * getArtSet(const ArtifactLocation & loc);
|
||||
|
||||
virtual void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) = 0;
|
||||
};
|
||||
|
@ -341,7 +341,7 @@ public:
|
||||
enum Type
|
||||
{
|
||||
NO_OBJ = -1,
|
||||
ALTAR_OF_SACRIFICE = 2,
|
||||
ALTAR_OF_SACRIFICE [[deprecated]] = 2,
|
||||
ANCHOR_POINT = 3,
|
||||
ARENA = 4,
|
||||
ARTIFACT = 5,
|
||||
|
@ -3434,17 +3434,12 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(o1->ID == Obj::ALTAR_OF_SACRIFICE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(o2->ID == Obj::ALTAR_OF_SACRIFICE)
|
||||
{
|
||||
const auto visitingHero = getVisitingHero(o2);
|
||||
const auto thisHero = static_cast<const CGHeroInstance*>(o1);
|
||||
if(visitingHero == thisHero)
|
||||
return true;
|
||||
}
|
||||
auto market = dynamic_cast<const IMarket*>(o1);
|
||||
if(market == nullptr)
|
||||
market = dynamic_cast<const IMarket*>(o2);
|
||||
if(market)
|
||||
return market->allowsTrade(EMarketMode::ARTIFACT_EXP);
|
||||
|
||||
if (o1->ID == Obj::HERO && o2->ID == Obj::HERO)
|
||||
{
|
||||
const CGHeroInstance *h1 = static_cast<const CGHeroInstance*>(o1);
|
||||
|
@ -141,7 +141,7 @@ void ApplyGhNetPackVisitor::visitExchangeArtifacts(ExchangeArtifacts & pack)
|
||||
|
||||
void ApplyGhNetPackVisitor::visitBulkExchangeArtifacts(BulkExchangeArtifacts & pack)
|
||||
{
|
||||
if(gh.getObj(pack.srcHero)->ID != MapObjectID::ALTAR_OF_SACRIFICE)
|
||||
if(dynamic_cast<const IMarket*>(gh.getObj(pack.srcHero)) == nullptr)
|
||||
gh.throwIfWrongOwner(&pack, pack.srcHero);
|
||||
if(pack.swap)
|
||||
gh.throwIfWrongOwner(&pack, pack.dstHero);
|
||||
|
Loading…
Reference in New Issue
Block a user