fix for https://github.com/Attnam/ivan/issues/119
[k8-i-v-a-n.git] / src / game / fluid.h
blob2b0c989ea0640513680843ed8f68b8383cdb8bf0
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
12 #ifndef __FLUID_H__
13 #define __FLUID_H__
15 #include "lsquare.h"
16 #include "trap.h"
19 class bitmap;
22 typedef truth (rawbitmap::*pixelpredicate) (v2) const;
24 class fluid : public entity {
25 public:
26 /* Come To The Dark Side */
27 fluid *Next;
29 public:
30 fluid ();
31 fluid (liquid *, lsquare *);
32 fluid (liquid *, item *, cfestring &, truth);
33 virtual ~fluid ();
35 virtual void Be ();
36 void Save (outputfile &) const;
37 void Load (inputfile &);
38 void SimpleDraw (blitdata &) const;
39 void Draw (blitdata &) const;
40 inline liquid *GetLiquid () const { return Liquid; }
41 virtual square *GetSquareUnderEntity (int = 0) const { return LSquareUnder; }
42 inline square *GetSquareUnder () const { return LSquareUnder; }
43 inline void SetLSquareUnder (lsquare *What) { LSquareUnder = What; }
44 inline lsquare *GetLSquareUnder () const { return LSquareUnder; }
45 virtual truth IsOnGround () const { return true; }
46 void AddLiquid (sLong);
47 void AddLiquidAndVolume (sLong);
48 virtual void SignalVolumeAndWeightChange ();
49 void SetMotherItem (item *);
50 static void AddFluidInfo (const fluid *, festring &);
51 void CheckGearPicture (v2, int, truth);
52 void DrawGearPicture (blitdata &, int) const;
53 truth FadePictures ();
54 void DrawBodyArmorPicture (blitdata &, int) const;
55 void Redistribute ();
56 virtual material *RemoveMaterial (material *);
57 void Destroy ();
58 inline cfestring &GetLocationName () const { return LocationName; }
59 inline truth IsInside () const { return Flags & FLUID_INSIDE; }
60 truth UseImage() const;
61 virtual int GetTrapType () const { return Liquid->GetType() | FLUID_TRAP; }
62 virtual feuLong GetTrapID () const { return TrapData.TrapID; }
63 virtual feuLong GetVictimID () const { return TrapData.VictimID; }
64 virtual void AddTrapName (festring &, int) const;
65 virtual void UnStick () { TrapData.VictimID = 0; }
66 virtual void UnStick (int I) { TrapData.BodyParts &= ~(1 << I); }
67 void StepOnEffect (character *);
68 virtual truth TryToUnStick (character *, v2);
69 virtual void PreProcessForBone ();
70 virtual void PostProcessForBone ();
71 virtual truth IsStuckTo (ccharacter *) const;
72 truth IsDangerous (ccharacter *) const;
74 protected:
75 trapdata TrapData;
76 struct imagedata {
77 imagedata (truth = true);
78 ~imagedata ();
79 void Animate (blitdata &, int) const;
80 void AddLiquidToPicture (const rawbitmap *, sLong, sLong, col16, pixelpredicate);
81 void Save (outputfile &) const;
82 void Load (inputfile &);
83 truth Fade ();
84 void Clear (truth);
85 /* Only pictures of fluids not on ground have their RandMaps initialized,
86 since they are animated. Note that the picture is always unrotated. */
87 bitmap *Picture;
88 /* Used by Animate() */
89 mutable int DripTimer;
90 mutable v2 DripPos;
91 mutable col16 DripColor;
92 mutable alpha DripAlpha;
93 /* Sum of all alphas of Picture. The volume of the liquid is currently
94 proportional to AlphaSum of the fluid's Image, limiting it
95 considerably. */
96 sLong AlphaSum;
97 /* AlphaSum / (non-transparent pixels in Picture), used to synchronise
98 gear pictures with the main image */
99 packalpha AlphaAverage;
100 /* The position of a gear picture in humanoid.pcx which binds the fluid;
101 remembered so that it can be easily determined whether the fluid needs
102 to be redistributed due to a major graphics change */
103 v2 ShadowPos;
104 /* Animation of gear items needs to know whether the raw picture is
105 rotated somehow. Currently this is the case only for an item
106 in the left hand of a character. */
107 int SpecialFlags;
109 liquid *Liquid;
110 lsquare *LSquareUnder;
111 /* MotherItem == 0 means that the fluid is on ground */
112 item *MotherItem;
113 imagedata Image;
114 /* Data of pictures shown over the player if he equips the item which
115 the fluid covers. Note that these are not destroyed when the armor
116 or weapon is unequipped. There is no real need, since the existence
117 of the fluid is very temporary anyway. */
118 imagedata *GearImage;
119 feuLong Flags;
120 festring LocationName;
121 static const sLong BodyArmorPartPixels[];
125 outputfile &operator << (outputfile &, const fluid *);
126 inputfile &operator >> (inputfile &, fluid *&);
129 #endif