global 'new' and 'delete' overrides, to make valgrind happy and segfaults better
[k8-i-v-a-n.git] / src / game / slot.h
blob21e22b4d0cbdb54926828b6427aea73bd6645ea0
1 /*
3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
6 * Public License
8 * See LICENSING which should be included
9 * along with this file for more details
13 #ifndef __SLOT_H__
14 #define __SLOT_H__
16 #include "ivancommon.h"
18 #include "typedef.h"
21 class item;
22 class character;
23 class outputfile;
24 class inputfile;
25 class bodypart;
26 class square;
29 class slot
31 public:
32 slot() : Item(0) { }
33 virtual ~slot() {}
35 virtual void Empty() = 0;
36 virtual void Save(outputfile&) const;
37 virtual void Load(inputfile&);
38 item* GetItem() const { return Item; }
39 item* operator->() const { return Item; }
40 item* operator*() const { return Item; }
41 virtual void AddFriendItem(item*) const = 0;
42 virtual truth IsOnGround() const { return false; }
43 virtual void PutInItem(item*) = 0;
44 virtual square* GetSquareUnder(int = 0) const = 0;
45 virtual void SignalVolumeAndWeightChange() = 0;
46 virtual void SignalEmitationIncrease(col24) = 0;
47 virtual void SignalEmitationDecrease(col24) = 0;
48 virtual void DonateTo(item*);
49 virtual truth CanBeSeenBy(ccharacter*) const = 0;
50 virtual void SignalEnchantmentChange() { }
51 virtual truth IsVisible() const = 0;
52 virtual truth IsGearSlot() const { return false; }
53 virtual ccharacter* FindCarrier() const = 0;
54 protected:
55 item* Item;
58 class stackslot : public slot
60 public:
61 friend class stack;
62 friend class stackiterator;
64 stackslot(stack* MotherStack, stackslot* Last) : MotherStack(MotherStack), Last(Last), Next(0) { }
65 virtual ~stackslot () {}
67 virtual void Empty();
68 virtual void AddFriendItem(item*) const;
69 virtual truth IsOnGround() const;
70 virtual square* GetSquareUnder(int = 0) const;
71 virtual void SignalVolumeAndWeightChange();
72 virtual void SignalEmitationIncrease(col24);
73 virtual void SignalEmitationDecrease(col24);
74 virtual void DonateTo(item*);
75 virtual truth CanBeSeenBy(ccharacter*) const;
76 stack* GetMotherStack() const { return MotherStack; }
77 void SetMotherStack(stack* What) { MotherStack = What; }
78 virtual truth IsVisible() const;
79 virtual void PutInItem(item*);
80 virtual void Load(inputfile&);
81 virtual ccharacter* FindCarrier() const;
82 protected:
83 stack* MotherStack;
84 stackslot* Last;
85 stackslot* Next;
88 class bodypartslot : public slot
90 public:
91 virtual ~bodypartslot () {}
93 virtual void Empty();
94 character* GetMaster() const { return Master; }
95 void SetMaster(character* What) { Master = What; }
96 virtual void AddFriendItem(item*) const;
97 virtual square* GetSquareUnder(int = 0) const;
98 virtual void SignalVolumeAndWeightChange();
99 virtual void SignalEmitationIncrease(col24);
100 virtual void SignalEmitationDecrease(col24);
101 virtual void PutInItem(item*);
102 virtual void Load(inputfile&);
103 virtual truth CanBeSeenBy(ccharacter*) const;
104 virtual truth IsVisible() const { return false; }
105 virtual ccharacter* FindCarrier() const { return Master; }
106 protected:
107 character* Master;
110 class gearslot : public slot
112 public:
113 virtual ~gearslot () {}
115 virtual void Empty();
116 bodypart* GetBodyPart() const { return BodyPart; }
117 void SetBodyPart(bodypart* What) { BodyPart = What; }
118 virtual void AddFriendItem(item*) const;
119 void Init(bodypart*, int);
120 int GetEquipmentIndex() const { return EquipmentIndex; }
121 void SetEquipmentIndex(int What) { EquipmentIndex = What; }
122 virtual void PutInItem(item*);
123 virtual square* GetSquareUnder(int = 0) const;
124 virtual void SignalVolumeAndWeightChange();
125 virtual void SignalEmitationIncrease(col24);
126 virtual void SignalEmitationDecrease(col24);
127 virtual truth CanBeSeenBy(ccharacter*) const;
128 virtual void SignalEnchantmentChange();
129 virtual truth IsVisible() const { return false; }
130 virtual truth IsGearSlot() const { return true; }
131 virtual ccharacter* FindCarrier() const;
132 protected:
133 bodypart* BodyPart;
134 int EquipmentIndex;
137 inline outputfile& operator<<(outputfile& SaveFile, const slot& Slot)
139 Slot.Save(SaveFile);
140 return SaveFile;
143 inline inputfile& operator>>(inputfile& SaveFile, slot& Slot)
145 Slot.Load(SaveFile);
146 return SaveFile;
149 #endif