1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Minor refactorings, fixes & improvements.

Moved CArtifactSet to ArtHandler. ObjectHandler is already too messed.
This commit is contained in:
DjWarmonger
2011-06-24 17:43:02 +00:00
parent e41d2f6e87
commit bdce46ab60
15 changed files with 221 additions and 226 deletions

View File

@ -12,6 +12,7 @@
#include "../lib/VCMI_Lib.h"
#endif
#include "../lib/CCreatureSet.h"
#include "CArtHandler.h"
#include "../lib/ConstTransitivePtr.h"
#include <boost/unordered_set.hpp>
@ -53,6 +54,7 @@ struct BankConfig;
struct UpdateHeroSpeciality;
struct NewArtifact;
class CGBoat;
class CArtifactSet;
class DLL_EXPORT CQuest
{
@ -248,50 +250,6 @@ public:
}
};
struct DLL_EXPORT ArtSlotInfo
{
ConstTransitivePtr<CArtifactInstance> artifact;
ui8 locked; //if locked, then artifact points to the combined artifact
ArtSlotInfo()
{
locked = false;
}
template <typename Handler> void serialize(Handler &h, const int version)
{
h & artifact & locked;
}
};
class DLL_EXPORT CArtifactSet
{
public:
std::vector<ArtSlotInfo> artifactsInBackpack; //hero's artifacts from bag
bmap<ui16, ArtSlotInfo> artifactsWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
ArtSlotInfo &retreiveNewArtSlot(ui16 slot);
void setNewArtSlot(ui16 slot, CArtifactInstance *art, bool locked);
void eraseArtSlot(ui16 slot);
const ArtSlotInfo *getSlot(ui16 pos) const;
const CArtifactInstance* getArt(ui16 pos, bool excludeLocked = true) const; //NULL - no artifact
CArtifactInstance* getArt(ui16 pos, bool excludeLocked = true); //NULL - no artifact
si32 getArtPos(int aid, bool onlyWorn = true) const; //looks for equipped artifact with given ID and returns its slot ID or -1 if none(if more than one such artifact lower ID is returned)
si32 getArtPos(const CArtifactInstance *art) const;
const CArtifactInstance *getArtByInstanceId(int artInstId) const;
bool hasArt(ui32 aid, bool onlyWorn = false) const; //checks if hero possess artifact of given id (either in backack or worn)
bool isPositionFree(ui16 pos, bool onlyLockCheck = false) const;
si32 getArtTypeId(ui16 pos) const;
virtual ~CArtifactSet();
template <typename Handler> void serialize(Handler &h, const int version)
{
h & artifactsInBackpack & artifactsWorn;
}
};
class DLL_EXPORT CGHeroInstance : public CArmedInstance, public IBoatGenerator, public CArtifactSet
{
public: