freg  0.3
Free-Roaming Elementary Game
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
header.h
Go to the documentation of this file.
1  /* freg, Free-Roaming Elementary Game with open and interactive world
2  * Copyright (C) 2012-2014 Alexander 'mmaulwurff' Kromm
3  * mmaulwurff@gmail.com
4  *
5  * This file is part of FREG.
6  *
7  * FREG is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FREG is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with FREG. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #ifndef HEADER_H
21 #define HEADER_H
22 
23 #include <QtGlobal>
24 #include <QLocale>
25 
26 #ifdef Q_OS_WIN32
27 #include <windows.h>
28 #endif
29 
30 #ifdef QT_NO_DEBUG
31 const bool DEBUG = false;
32 #else
33 const bool DEBUG = true;
34 #endif
35 
36 extern const QString home_path;
37 
38 const int SHRED_WIDTH = 16;
39 const int SHRED_WIDTH_SHIFT = 4;
40 const int HEIGHT = 128;
41 
42 enum times {
51 };
52 
53 #ifdef Q_OS_WIN32
54 const QString locale = "en";
55 #else
56 const QString locale = QLocale::system().name();
57 #endif
58 
59 enum shred_type {
60  SHRED_PLAIN = '.',
63  SHRED_HILL = '+',
64  SHRED_DESERT = ':',
65  SHRED_WATER = '~',
66  SHRED_FOREST = '%',
68  SHRED_EMPTY = '_',
69  SHRED_CHAOS = '!',
70  SHRED_CASTLE = 'C',
71  SHRED_WASTE = '=',
74  SHRED_CRATER = 'c',
79 };
80 
81 const int DEFAULT_MAP_SIZE = 79;
84 
85 enum dirs {
86  ANYWHERE = 0,
87  UP = 0, ///< 0
88  DOWN, ///< 1
89  NORTH, ///< 2
90  SOUTH, ///< 3
91  EAST, ///< 4
92  WEST ///< 5
93 };
94 
102 };
103 
109 };
110 
111 /// Kinds of atom
112 enum kinds {
113  // add new kinds to bottom (before LAST_KIND).
114  // changind kind codes will break file compatibility.
115  BLOCK, ///< 0
116  BELL, ///< 1
117  CONTAINER, ///< 2
118  DWARF, ///< 3
119  PICK, ///< 4
120  LIQUID, ///< 5
121  GRASS, ///< 6
122  BUSH, ///< 7
123  RABBIT, ///< 8
124  FALLING, ///< 9
125  CLOCK, ///< 10
126  PLATE, ///< 11
127  WORKBENCH, ///< 12
128  WEAPON, ///< 13
129  LADDER, ///< 14
130  DOOR, ///< 15
131  BOX, ///< 16
132  KIND_TEXT, ///< 17
133  MAP, ///< 18
134  PREDATOR, ///< 19
135  BUCKET, ///< 20
136  SHOVEL, ///< 21
137  AXE, ///< 22
138  HAMMER, ///< 23
139  ILLUMINATOR, ///< 24
140  RAIN_MACHINE, ///< 25
141  CONVERTER, ///< 26
142  ARMOUR, ///< 27
143  HELMET, ///< 28
144  BOOTS, ///< 29
145  TELEGRAPH, ///< 30
146  MEDKIT, ///< 31
147  FILTER, ///< 32
148  INFORMER, ///< 33
149  /// Nothing is LAST_KIND.
150  LAST_KIND // keep it last in this list.
151 }; // enum kinds
152 
153 /// Substance block is made from.
154 /** Don't make blocks from SKY and STAR, they are special for shred loading
155  * and saving.
156  * Don't make non-BLOCK blocks from air, otherwise leaks are possible. */
157 enum subs {
158  // do not change order, this will break file compatibility.
159  // add new substances right before LAST_SUB.
160  STONE, ///< 0
161  MOSS_STONE, ///< 1
162  NULLSTONE, ///< 2
163  SKY, ///< 3
164  STAR, ///< 4
165  DIAMOND, ///< 5
166  SOIL, ///< 6
167  H_MEAT, ///< 7 (hominid meat)
168  A_MEAT, ///< 8 (animal meat)
169  GLASS, ///< 9
170  WOOD, ///< 10
171  DIFFERENT, ///< 11
172  IRON, ///< 12
173  WATER, ///< 13
174  GREENERY, ///< 14
175  SAND, ///< 15
176  SUB_NUT, ///< 16
177  ROSE, ///< 17
178  CLAY, ///< 18
179  AIR, ///< 19
180  PAPER, ///< 20
181  GOLD, ///< 21
182  BONE, ///< 22
183  STEEL, ///< 23
184  ADAMANTINE, ///< 24
185  FIRE, ///< 25
186  COAL, ///< 26
187  EXPLOSIVE, ///< 27
188  ACID, ///< 28
189  SUB_CLOUD, ///< 29
190  SUB_DUST, ///< 30
191  SUB_PLASTIC,///< 31
192  /// Nothing is made from LAST_SUB.
193  LAST_SUB // keep it last in this list
194 }; // enum subs
195 
204 };
205 
211  UNDEF // temporary, doesn't appear in world.
212 };
213 
214 bool IsLikeAir(int sub);
215 
216 /// For positive numbers only.
217 inline int Round(const float x) { return int(x + 0.5f); }
218 
219 inline unsigned Abs(const int x) {
220  const unsigned mask = x >> (sizeof(unsigned)*8 - 1);
221  return (x ^ mask) - mask;
222 }
223 
224 #define sizeof_array(ARRAY) (sizeof(ARRAY)/sizeof(ARRAY[0]))
225 
226 #endif // HEADER_H
20
Definition: header.h:135
unsigned Abs(const int x)
Definition: header.h:219
16
Definition: header.h:176
10
Definition: header.h:170
3
Definition: header.h:90
const QString home_path
Definition: main.cpp:50
32
Definition: header.h:147
Definition: header.h:99
29
Definition: header.h:189
push_reaction
Definition: header.h:95
27
Definition: header.h:187
6
Definition: header.h:121
31
Definition: header.h:146
28
Definition: header.h:188
Definition: header.h:211
Definition: header.h:100
0
Definition: header.h:87
18
Definition: header.h:178
4
Definition: header.h:164
21
Definition: header.h:181
29
Definition: header.h:144
times_of_day
Definition: header.h:104
2
Definition: header.h:89
0
Definition: header.h:115
Nothing is made from LAST_SUB.
Definition: header.h:193
4
Definition: header.h:91
26
Definition: header.h:186
6
Definition: header.h:166
21
Definition: header.h:136
27
Definition: header.h:142
11
Definition: header.h:126
1
Definition: header.h:116
7 (hominid meat)
Definition: header.h:167
28
Definition: header.h:143
const int HEIGHT
Definition: header.h:40
7
Definition: header.h:122
12
Definition: header.h:127
const QString locale
Definition: header.h:56
9
Definition: header.h:124
9
Definition: header.h:169
11
Definition: header.h:171
int Round(const float x)
For positive numbers only.
Definition: header.h:217
3
Definition: header.h:163
20
Definition: header.h:180
18
Definition: header.h:133
shred_type
Definition: header.h:59
26
Definition: header.h:141
14
Definition: header.h:129
const char OUT_BORDER_SHRED
Definition: header.h:83
bool IsLikeAir(int sub)
2
Definition: header.h:162
kinds
Kinds of atom.
Definition: header.h:112
2
Definition: header.h:117
4
Definition: header.h:119
12
Definition: header.h:172
subs
Substance block is made from.
Definition: header.h:157
13
Definition: header.h:128
19
Definition: header.h:179
8
Definition: header.h:123
Nothing is LAST_KIND.
Definition: header.h:150
19
Definition: header.h:134
const char DEFAULT_SHRED
Definition: header.h:82
5
Definition: header.h:165
22
Definition: header.h:137
Definition: header.h:101
23
Definition: header.h:183
13
Definition: header.h:173
25
Definition: header.h:185
usage_types
Definition: header.h:196
24
Definition: header.h:184
1
Definition: header.h:88
dirs
Definition: header.h:85
22
Definition: header.h:182
0
Definition: header.h:160
Definition: header.h:96
23
Definition: header.h:138
16
Definition: header.h:131
const int SHRED_WIDTH_SHIFT
Definition: header.h:39
17
Definition: header.h:132
10
Definition: header.h:125
15
Definition: header.h:130
3
Definition: header.h:118
5
Definition: header.h:120
15
Definition: header.h:175
const int SHRED_WIDTH
Definition: header.h:38
transparency
Definition: header.h:206
const bool DEBUG
Definition: header.h:33
5
Definition: header.h:92
const int DEFAULT_MAP_SIZE
Definition: header.h:81
30
Definition: header.h:145
8 (animal meat)
Definition: header.h:168
17
Definition: header.h:177
30
Definition: header.h:190
14
Definition: header.h:174
times
Definition: header.h:42