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