3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
24 typedef std::vector
<item
*> itemvector
;
25 typedef std::vector
<itemvector
> itemvectorvector
;
28 /* Stack contains an arbitrary number of items in a linked list, which can
29 be browsed using stackiterators like this:
31 for (stackiterator i = Stack->GetBottom(); i.HasItem(); ++i) {
33 i->ItemMemberFunction();
36 or using a temporary vector:
38 itemvector ItemVector;
39 Stack->FillItemVector(ItemVector);
41 for (int c = 0; c < ItemVector.size(); ++c) {
42 item *Item = ItemVector[c];
43 ItemVector[c]->ItemMemberFunction();
46 The former is faster and should be used if items can't be removed nor
47 added during the loop (at worst, this could cause a crash), otherwise
48 the latter is necessary.
50 Items are added to stack with Stack->AddItem(Item) and removed by
51 Item->RemoveFromSlot(). A number of Stack->DrawContents() functions
52 is provided as an easy item-selecting GUI.
56 stackiterator (stackslot
*Slot
) : Slot(Slot
) {}
57 stackiterator
&operator ++ () { Slot
= Slot
->Next
; return *this; }
58 stackiterator
&operator -- () { Slot
= Slot
->Last
; return *this; }
59 truth
HasItem () const { return truth(Slot
); }
60 item
*operator -> () const { return Slot
->Item
; }
61 item
*operator * () const { return Slot
->Item
; }
62 const stackslot
&GetSlot () const { return *Slot
; }
71 stack (square
*, entity
*, feuLong
= 0);
73 void Load (inputfile
&);
74 void Draw (ccharacter
*, blitdata
&, int) const;
75 void AddItem (item
*, truth
= true);
76 void RemoveItem (stackslot
*);
77 item
*GetItem (int) const;
78 void GetVisibleItemsV (ccharacter
*Viewer
, std::vector
<item
*> &vi
);
79 truth
HasSomethingFunny (ccharacter
*Viewer
, truth seeCorpses
=false, truth seeUnstepped
=false);
80 void SetSteppedOn (truth v
);
81 stackiterator
GetBottom () const { return stackiterator(Bottom
); }
82 stackiterator
GetTop () const { return stackiterator(Top
); }
83 int GetItems () const { return Items
; }
84 int GetSideItems (int) const;
85 int GetVisibleItems (ccharacter
*) const;
86 int GetNativeVisibleItems (ccharacter
*) const;
87 int GetVisibleSideItems (ccharacter
*, int) const;
88 void SetMotherSquare (square
*What
) { MotherSquare
= What
; }
89 item
*DrawContents (ccharacter
*, cfestring
&, int = 0, sorter
= 0) const;
90 int DrawContents (itemvector
&, ccharacter
*, cfestring
&, int = 0, sorter
= 0) const;
91 int DrawContents (itemvector
&, stack
*, ccharacter
*, cfestring
&, cfestring
&, cfestring
&,
92 cfestring
&, col16
, int, sorter
= 0) const;
94 void Clean (truth
= false);
95 void Save (outputfile
&) const;
96 int SearchItem (item
*) const;
97 square
*GetSquareUnder () const;
98 lsquare
*GetLSquareUnder () const { return static_cast<lsquare
*>(GetSquareUnder()); }
99 truth
SortedItems (ccharacter
*, sorter
) const;
100 void BeKicked (character
*, int, int);
101 void Polymorph (character
*);
102 void CheckForStepOnEffect (character
*);
103 lsquare
*GetLSquareTrulyUnder (int) const;
104 void ReceiveDamage (character
*, int, int, int = YOURSELF
);
105 void TeleportRandomly (uInt
= 0xFFFF);
106 void FillItemVector (itemvector
&) const;
107 truth
IsOnGround () const;
108 truth
RaiseTheDead (character
*);
109 truth
TryKey (item
*, character
*);
110 truth
Open (character
*);
111 void SignalVolumeAndWeightChange ();
112 void CalculateVolumeAndWeight ();
113 sLong
GetVolume () const { return Volume
; }
114 sLong
GetWeight () const { return Weight
; }
115 sLong
GetWeight (ccharacter
*, int) const;
116 entity
*GetMotherEntity () const { return MotherEntity
; }
117 void SetMotherEntity (entity
*What
) { MotherEntity
= What
; }
118 area
*GetArea () const { return GetSquareUnder()->GetArea(); }
119 lsquare
*GetNearLSquare (v2 Pos
) const { return GetLSquareUnder()->GetLevel()->GetLSquare(Pos
); }
120 col24
GetEmitation () const { return Emitation
; }
121 void SignalEmitationIncrease (int, col24
);
122 void SignalEmitationDecrease (int, col24
);
123 void CalculateEmitation ();
124 col24
GetSideEmitation (int);
125 truth
CanBeSeenBy (ccharacter
*, int) const;
126 truth
IsDangerous (ccharacter
*) const;
127 truth
Duplicate (int, feuLong
= 0);
128 void MoveItemsTo (stack
*);
129 void MoveItemsTo (slot
*);
130 item
*GetBottomItem (ccharacter
*, truth
) const;
131 item
*GetBottomVisibleItem (ccharacter
*) const;
132 item
*GetBottomSideItem (ccharacter
*, int, truth
) const;
133 void Pile (itemvectorvector
&, ccharacter
*, int, sorter
= 0) const;
134 sLong
GetTruePrice () const;
135 static int GetSelected () { return Selected
; }
136 static void SetSelected (int What
) { Selected
= What
; }
137 truth
TakeSomethingFrom (character
*, cfestring
&);
138 truth
PutSomethingIn (character
*, cfestring
&, sLong
, feuLong
);
139 truth
IsVisible () const { return !(Flags
& HIDDEN
); }
140 int GetSpoiledItems () const;
141 void SortAllItems (const sortdata
&) const;
142 void Search (ccharacter
*, int);
143 truth
NeedDangerSymbol (ccharacter
*) const;
144 void PreProcessForBone ();
145 void PostProcessForBone ();
146 void FinalProcessForBone ();
147 void AddElement (item
*, truth
= false);
148 void SpillFluid (character
*, liquid
*, sLong
);
149 void AddItems (const itemvector
&);
150 void MoveItemsTo (itemvector
&, int);
151 void Freeze () { Flags
|= FREEZED
; }
152 void UnFreeze () { Flags
&= ~FREEZED
; }
153 void DropSideItems ();
154 truth
DetectMaterial (cmaterial
*) const;
155 void SetLifeExpectancy (int, int);
156 truth
Necromancy (character
*);
157 void CalculateEnchantments ();
158 ccharacter
*FindCarrier () const;
163 void RemoveElement (stackslot
*);
164 void AddContentsToList (felist
&, ccharacter
*, cfestring
&, int, int, sorter
) const;
165 int SearchChosen (itemvector
&, ccharacter
*, int, int, int, int, sorter
= 0) const;
166 static truth
AllowDamage (int, int);
172 square
*MotherSquare
;
173 entity
*MotherEntity
;
176 col24 Emitation
: 24;