global 'new' and 'delete' overrides, to make valgrind happy and segfaults better
[k8-i-v-a-n.git] / src / game / igraph.h
blob9281c06c563caea5f52c5f440ac7df6a44212aa7
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 __IGRAPH_H__
14 #define __IGRAPH_H__
16 #include "ivancommon.h"
18 #include <map>
20 #include "ivandef.h"
21 #include "femath.h"
24 class bitmap;
25 class rawbitmap;
26 class outputfile;
27 class inputfile;
28 class festring;
31 /* memcmp doesn't like alignment of structure members */
33 struct graphicid {
34 graphicid() { }
35 bool operator<(const graphicid&) const;
36 uShort BitmapPosX NO_ALIGNMENT;
37 uShort BitmapPosY NO_ALIGNMENT;
38 packcol16 Color[4] NO_ALIGNMENT;
39 uChar Frame /*k8NO_ALIGNMENT*/;
40 uChar FileIndex /*k8NO_ALIGNMENT*/;
41 uShort SpecialFlags NO_ALIGNMENT;
42 packalpha Alpha[4] /*k8NO_ALIGNMENT*/;
43 packalpha BaseAlpha /*k8NO_ALIGNMENT*/;
44 uChar SparkleFrame /*k8NO_ALIGNMENT*/;
45 uChar SparklePosX /*k8NO_ALIGNMENT*/;
46 uChar SparklePosY /*k8NO_ALIGNMENT*/;
47 packcol16 OutlineColor NO_ALIGNMENT;
48 packalpha OutlineAlpha /*k8NO_ALIGNMENT*/;
49 uChar FlyAmount /*k8NO_ALIGNMENT*/;
50 v2 Position NO_ALIGNMENT;
51 uChar RustData[4] /*k8NO_ALIGNMENT*/;
52 uShort Seed NO_ALIGNMENT;
53 uChar WobbleData /*k8NO_ALIGNMENT*/;
56 inline bool graphicid::operator<(const graphicid& GI) const
58 return memcmp(this, &GI, sizeof(graphicid)) < 0;
61 outputfile& operator<<(outputfile&, const graphicid&);
62 inputfile& operator>>(inputfile&, graphicid&);
64 struct tile
66 tile() { }
67 tile(bitmap* Bitmap) : Bitmap(Bitmap), Users(1) { }
68 bitmap* Bitmap;
69 sLong Users;
72 typedef std::map<graphicid, tile> tilemap;
74 struct graphicdata
76 graphicdata() : AnimationFrames(0) { }
77 ~graphicdata();
78 void Save(outputfile&) const;
79 void Load(inputfile&);
80 void Retire();
81 int AnimationFrames;
82 bitmap** Picture;
83 tilemap::iterator* GraphicIterator;
86 outputfile& operator<<(outputfile&, const graphicdata&);
87 inputfile& operator>>(inputfile&, graphicdata&);
89 class igraph {
90 public:
91 virtual ~igraph () {}
93 static void Init();
94 static void DeInit();
95 static cbitmap* GetWTerrainGraphic() { return Graphic[GR_WTERRAIN]; }
96 static cbitmap* GetFOWGraphic() { return Graphic[GR_FOW]; }
97 static const rawbitmap* GetCursorRawGraphic() { return RawGraphic[GR_CURSOR]; }
98 static cbitmap* GetSymbolGraphic() { return Graphic[GR_SYMBOL]; }
99 static bitmap* GetTileBuffer() { return TileBuffer; }
100 static void DrawCursor(v2, int, int = 0);
101 static tilemap::iterator AddUser(const graphicid&);
102 static void RemoveUser(tilemap::iterator);
103 static const rawbitmap* GetHumanoidRawGraphic() { return RawGraphic[GR_HUMANOID]; }
104 static const rawbitmap* GetCharacterRawGraphic() { return RawGraphic[GR_CHARACTER]; }
105 static const rawbitmap* GetEffectRawGraphic() { return RawGraphic[GR_EFFECT]; }
106 static const rawbitmap* GetRawGraphic(int I) { return RawGraphic[I]; }
107 static cint* GetBodyBitmapValidityMap(int);
108 static bitmap* GetFlagBuffer() { return FlagBuffer; }
109 static cbitmap* GetMenuGraphic() { return Menu; }
110 static void LoadMenu();
111 static void UnLoadMenu();
112 static bitmap* GetSilhouetteCache(int I1, int I2, int I3) { return SilhouetteCache[I1][I2][I3]; }
113 static cbitmap* GetBackGround() { return BackGround; }
114 static void BlitBackGround(v2, v2);
115 static void CreateBackGround(int);
116 static bitmap* GenerateScarBitmap(int, int, int);
117 static cbitmap* GetSmileyGraphic() { return Graphic[GR_SMILEY]; }
118 private:
119 static void EditBodyPartTile(rawbitmap*, rawbitmap*, v2, int);
120 static v2 RotateTile(rawbitmap*, rawbitmap*, v2, v2, int);
121 static void CreateBodyBitmapValidityMaps();
122 static void CreateSilhouetteCaches();
123 static col16 GetBackGroundColor(int);
124 static rawbitmap* RawGraphic[RAW_TYPES];
125 static bitmap* Graphic[GRAPHIC_TYPES];
126 static bitmap* TileBuffer;
127 static cchar* RawGraphicFileName[];
128 static cchar* GraphicFileName[];
129 static tilemap TileMap;
130 static uChar RollBuffer[256];
131 static bitmap* FlagBuffer;
132 static int** BodyBitmapValidityMap;
133 static bitmap* Menu;
134 static bitmap* SilhouetteCache[HUMANOID_BODYPARTS][CONDITION_COLORS][SILHOUETTE_TYPES];
135 static rawbitmap* ColorizeBuffer[2];
136 static bitmap* Cursor[CURSOR_TYPES];
137 static bitmap* BigCursor[CURSOR_TYPES];
138 static col16 CursorColor[CURSOR_TYPES];
139 static bitmap* BackGround;
140 static int CurrentColorType;
143 #endif