-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathcommon.h
230 lines (186 loc) · 5.23 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#pragma once
#include <assert.h>
#include <vector>
#include <map>
#include <memory>
#include <stdint.h>
// allegro also leaks stdint.h and some weird equivalent of it on windows. let's disable the copy leaked by dfhack.
#define SKIP_DFHACK_STDINT
#define DFHACK_WANT_PLATETYPES
#include <PluginManager.h>
#include <modules/Buildings.h>
#include <modules/Gui.h>
#include <modules/Units.h>
#include <modules/World.h>
#define ALLEGRO_NO_MAGIC_MAIN //This is a DLL file. we got no main function.
#define ALLEGRO_HAVE_STDINT_H
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_opengl.h>
#include <allegro5/utf8.h>
// allegro leaks X headers, undef some of it here:
#undef TileShape
#undef None
#undef Status
#include "commonTypes.h"
#include "Tile.h"
#include <stdio.h>
#include <stdarg.h>
#define RELEASE
constexpr auto INVALID_INDEX = -1;
constexpr auto UNCONFIGURED_INDEX = -2;
#define ISOMETRIC
//#define CAVALIER
// TILEWIDTH: total size of sprite left to right
// TILETOPHEIGHT: floor part of sprite top to bottom
// WALLHEIGHT: height of a one pixel wide stripe of wall top to bottom
// == amount top of wall is raised from where the floor would be
// FLOORHEIGHT: height of a one pixel stripe of the 'wall' of a floor plate
#ifdef CAVALIER
constexpr auto TILEWIDTH = 46;
constexpr auto TILETOPHEIGHT = 46;
constexpr auto WALLHEIGHT = 24;
constexpr auto FLOORHEIGHT = 6;
#endif
#ifdef ISOMETRIC
constexpr auto TILEWIDTH = 32;
constexpr auto TILETOPHEIGHT = 16;
constexpr auto WALLHEIGHT = 16;
constexpr auto FLOORHEIGHT = 4;
#endif
#ifdef DOUBLESIZE
constexpr auto TILEWIDTH = 64;
constexpr auto TILETOPHEIGHT = 32;
constexpr auto WALLHEIGHT = 32;
constexpr auto FLOORHEIGHT = 8;
#endif
// Height of a one pixel stripe of the wall of an entire tile,
// including wall and floor plate
constexpr auto TILEHEIGHT = (WALLHEIGHT + FLOORHEIGHT);
// Width of area copied from an image file
// may be different to plate dimensions to allow overlap later
constexpr auto SPRITEWIDTH = TILEWIDTH;
// Height of area copied from an image file
// may be different to plate dimensions to allow overlap later
constexpr auto SPRITEHEIGHT = (TILETOPHEIGHT + WALLHEIGHT);
constexpr auto WALL_CUTOFF_HEIGHT = 15;
constexpr auto MAPNAVIGATIONSTEP = 1;
constexpr auto MAPNAVIGATIONSTEPBIG = 10;
constexpr auto SHEET_OBJECTSWIDE = 20;
constexpr auto LETTERS_OBJECTSWIDE = 16;
//do not alter, defined by DF
constexpr auto BLOCKEDGESIZE = 16;
constexpr auto COLOR_SEGMENTOUTLINE = 0x112211;
constexpr auto BASE_SHADOW_PLATE = 160;
constexpr auto DEFAULT_SHADOW = 4;
constexpr auto MAX_SHADOW = 7;
// this shouldn't change with mods, so should
// be know ahead of time (especially since we
// use it for fake terrains already)
constexpr auto MAX_BASE_TERRAIN = 525;
constexpr auto FAKE_TERRAIN_COUNT = 0;
// we only need as many as our translation system
// in ContentLoader/lookupMaterialType deals with
constexpr auto MAX_MATGLOSS = 24;
enum dirTypes {
eSimpleInvalid = -1,
eSimpleSingle,
//-----START: Do NOT rearrange these, they're used to autoinsert building borders
eSimpleN,
eSimpleW,
eSimpleS,
eSimpleE,
eSimpleNnW,
eSimpleSnW,
eSimpleSnE,
eSimpleNnE,
//-----END
eSimpleNnS,
eSimpleWnE,
eSimpleNnEnS,
eSimpleNnEnW,
eSimpleNnWnS,
eSimpleWnSnE,
eSimpleNnWnSnE
};
enum dirRelative {
eLeft,
eDown,
eRight,
eUp,
eAbove,
eBelow,
eUpLeft,
eUpRight,
eDownLeft,
eDownRight,
};
class SegmentWrap;
//main.cpp
void LogError(const char* msg, ...) Wformat(printf,1,2);
void PrintMessage(const char* msg, ...) Wformat(printf,1,2);
void LogVerbose(const char* msg, ...) Wformat(printf,1,2);
void SetTitle(const char *format, ...) Wformat(printf,1,2);
constexpr auto MAX_ANIMFRAME = 6;
// binary 00111111
constexpr auto ALL_FRAMES = 0b111111;
//from UserInput.cpp
void doMouse();
void doKeys(int32_t key, uint32_t keymod);
void doRepeatActions();
void initAutoReload();
void abortAutoReload();
//Keybinds.cpp
bool loadKeymapFile();
bool getKeyStrings(int32_t keycode, std::string*& keyname, std::string*& actionname);
//xmlBuildingReader.cpp
class BuildingConfiguration;
// BUG: this is dangerous!
constexpr auto FILENAME_BUFFERSIZE = 1024;
constexpr auto FILENAME_BUFFERSIZE_LOCAL = 2048;
enum MAT_BASICS {
INVALID = -1,
INORGANIC = 0,
AMBER = 1,
CORAL = 2,
GREEN_GLASS = 3,
CLEAR_GLASS = 4,
CRYSTAL_GLASS = 5,
ICE = 6,
COAL = 7,
POTASH = 8,
ASH = 9,
PEARLASH = 10,
LYE = 11,
MUD = 12,
VOMIT = 13,
SALT = 14,
FILTH = 15,
FILTH_FROZEN = 16,
UNKOWN_FROZEN = 17,
GRIME = 18,
ICHOR = 20,
LEATHER = 37,
BLOOD_1 = 39,
BLOOD_2 = 40,
BLOOD_3 = 41,
BLOOD_4 = 42,
BLOOD_5 = 43,
BLOOD_6 = 44,
BLOOD_NAMED = 242,
PLANT = 419,
WOOD = 420,
PLANTCLOTH = 421,
// filthy hacks to get interface stuff
DESIGNATION = 422,
CONSTRUCTION = 423,
};
constexpr auto NUM_FORMS = 5;
constexpr auto FORM_BAR = 1;
constexpr auto FORM_BLOCK = 2;
constexpr auto FORM_BOULDER = 3;
constexpr auto FORM_LOG = 4;
constexpr auto SCALEZOOMFACTOR = 1.1f;