freg
0.3
Free-Roaming Elementary Game
Main Page
Related Pages
Classes
Files
File List
File Members
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
{
43
SECONDS_IN_HOUR
= 60,
44
SECONDS_IN_DAY
= 24*
SECONDS_IN_HOUR
,
45
END_OF_NIGHT
= 6*
SECONDS_IN_HOUR
,
46
END_OF_MORNING
= 12*
SECONDS_IN_HOUR
,
47
END_OF_NOON
= 18*
SECONDS_IN_HOUR
,
48
END_OF_EVENING
= 0*
SECONDS_IN_HOUR
,
49
SECONDS_IN_NIGHT
=
END_OF_NIGHT
,
50
SECONDS_IN_DAYLIGHT
=
SECONDS_IN_DAY
-
END_OF_NIGHT
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
=
'.'
,
61
SHRED_TESTSHRED
=
'T'
,
62
SHRED_PYRAMID
=
'P'
,
63
SHRED_HILL
=
'+'
,
64
SHRED_DESERT
=
':'
,
65
SHRED_WATER
=
'~'
,
66
SHRED_FOREST
=
'%'
,
67
SHRED_MOUNTAIN
=
'^'
,
68
SHRED_EMPTY
=
'_'
,
69
SHRED_CHAOS
=
'!'
,
70
SHRED_CASTLE
=
'C'
,
71
SHRED_WASTE
=
'='
,
72
SHRED_ACID_LAKE
=
'a'
,
73
SHRED_LAVA_LAKE
=
'l'
,
74
SHRED_CRATER
=
'c'
,
75
SHRED_DEAD_FOREST
=
'f'
,
76
SHRED_DEAD_HILL
=
'*'
,
77
SHRED_NULLMOUNTAIN
=
'#'
,
78
SHRED_NORMAL_UNDERGROUND
=
'-'
,
79
};
80
81
const
int
DEFAULT_MAP_SIZE
= 79;
82
const
char
DEFAULT_SHRED
=
SHRED_PLAIN
;
83
const
char
OUT_BORDER_SHRED
=
SHRED_WATER
;
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
95
enum
push_reaction
{
96
MOVABLE
,
97
ENVIRONMENT
,
98
NOT_MOVABLE
,
99
MOVE_UP
,
100
JUMP
,
101
DAMAGE
,
102
};
103
104
enum
times_of_day
{
105
TIME_NIGHT
,
106
TIME_MORNING
,
107
TIME_NOON
,
108
TIME_EVENING
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
196
enum
usage_types
{
197
USAGE_TYPE_NO
,
198
USAGE_TYPE_OPEN
,
199
USAGE_TYPE_READ
,
200
USAGE_TYPE_READ_IN_INVENTORY
,
201
USAGE_TYPE_POUR
,
202
USAGE_TYPE_SET_FIRE
,
203
USAGE_TYPE_INNER
204
};
205
206
enum
transparency
{
207
BLOCK_OPAQUE
= 0,
208
BLOCK_TRANSPARENT
,
209
INVISIBLE
,
210
NONSTANDARD
= 6,
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
SHRED_FOREST
Definition:
header.h:66
USAGE_TYPE_READ
Definition:
header.h:199
SHRED_ACID_LAKE
Definition:
header.h:72
BUCKET
20
Definition:
header.h:135
Abs
unsigned Abs(const int x)
Definition:
header.h:219
SUB_NUT
16
Definition:
header.h:176
WOOD
10
Definition:
header.h:170
SOUTH
3
Definition:
header.h:90
home_path
const QString home_path
Definition:
main.cpp:50
FILTER
32
Definition:
header.h:147
SHRED_MOUNTAIN
Definition:
header.h:67
MOVE_UP
Definition:
header.h:99
SUB_CLOUD
29
Definition:
header.h:189
INFORMER
Definition:
header.h:148
push_reaction
push_reaction
Definition:
header.h:95
EXPLOSIVE
27
Definition:
header.h:187
SHRED_LAVA_LAKE
Definition:
header.h:73
GRASS
6
Definition:
header.h:121
MEDKIT
31
Definition:
header.h:146
ACID
28
Definition:
header.h:188
ILLUMINATOR
24
Definition:
header.h:139
SHRED_CASTLE
Definition:
header.h:70
UNDEF
Definition:
header.h:211
END_OF_NOON
Definition:
header.h:47
JUMP
Definition:
header.h:100
SECONDS_IN_DAY
Definition:
header.h:44
UP
0
Definition:
header.h:87
CLAY
18
Definition:
header.h:178
STAR
4
Definition:
header.h:164
GOLD
21
Definition:
header.h:181
BOOTS
29
Definition:
header.h:144
times_of_day
times_of_day
Definition:
header.h:104
NORTH
2
Definition:
header.h:89
NONSTANDARD
Definition:
header.h:210
BLOCK
0
Definition:
header.h:115
LAST_SUB
Nothing is made from LAST_SUB.
Definition:
header.h:193
EAST
4
Definition:
header.h:91
COAL
26
Definition:
header.h:186
SOIL
6
Definition:
header.h:166
SHOVEL
21
Definition:
header.h:136
TIME_NOON
Definition:
header.h:107
SHRED_PLAIN
Definition:
header.h:60
ARMOUR
27
Definition:
header.h:142
PLATE
11
Definition:
header.h:126
BELL
1
Definition:
header.h:116
H_MEAT
7 (hominid meat)
Definition:
header.h:167
SHRED_TESTSHRED
Definition:
header.h:61
HELMET
28
Definition:
header.h:143
SHRED_NORMAL_UNDERGROUND
Definition:
header.h:78
HEIGHT
const int HEIGHT
Definition:
header.h:40
BUSH
7
Definition:
header.h:122
BLOCK_OPAQUE
Definition:
header.h:207
WORKBENCH
12
Definition:
header.h:127
ANYWHERE
Definition:
header.h:86
SHRED_CHAOS
Definition:
header.h:69
END_OF_NIGHT
Definition:
header.h:45
locale
const QString locale
Definition:
header.h:56
FALLING
9
Definition:
header.h:124
SHRED_CRATER
Definition:
header.h:74
END_OF_MORNING
Definition:
header.h:46
GLASS
9
Definition:
header.h:169
DIFFERENT
11
Definition:
header.h:171
SHRED_DESERT
Definition:
header.h:64
SHRED_EMPTY
Definition:
header.h:68
Round
int Round(const float x)
For positive numbers only.
Definition:
header.h:217
SKY
3
Definition:
header.h:163
PAPER
20
Definition:
header.h:180
ENVIRONMENT
Definition:
header.h:97
SECONDS_IN_HOUR
Definition:
header.h:43
SHRED_PYRAMID
Definition:
header.h:62
MAP
18
Definition:
header.h:133
shred_type
shred_type
Definition:
header.h:59
CONVERTER
26
Definition:
header.h:141
LADDER
14
Definition:
header.h:129
OUT_BORDER_SHRED
const char OUT_BORDER_SHRED
Definition:
header.h:83
IsLikeAir
bool IsLikeAir(int sub)
MOSS_STONE
1
Definition:
header.h:161
NULLSTONE
2
Definition:
header.h:162
kinds
kinds
Kinds of atom.
Definition:
header.h:112
CONTAINER
2
Definition:
header.h:117
TIME_NIGHT
Definition:
header.h:105
PICK
4
Definition:
header.h:119
IRON
12
Definition:
header.h:172
subs
subs
Substance block is made from.
Definition:
header.h:157
WEAPON
13
Definition:
header.h:128
AIR
19
Definition:
header.h:179
RABBIT
8
Definition:
header.h:123
LAST_KIND
Nothing is LAST_KIND.
Definition:
header.h:150
SUB_PLASTIC
Definition:
header.h:191
USAGE_TYPE_OPEN
Definition:
header.h:198
PREDATOR
19
Definition:
header.h:134
DEFAULT_SHRED
const char DEFAULT_SHRED
Definition:
header.h:82
DIAMOND
5
Definition:
header.h:165
USAGE_TYPE_READ_IN_INVENTORY
Definition:
header.h:200
AXE
22
Definition:
header.h:137
DAMAGE
Definition:
header.h:101
SHRED_WASTE
Definition:
header.h:71
STEEL
23
Definition:
header.h:183
WATER
13
Definition:
header.h:173
TIME_MORNING
Definition:
header.h:106
SHRED_HILL
Definition:
header.h:63
FIRE
25
Definition:
header.h:185
usage_types
usage_types
Definition:
header.h:196
ADAMANTINE
24
Definition:
header.h:184
DOWN
1
Definition:
header.h:88
BLOCK_TRANSPARENT
Definition:
header.h:208
dirs
dirs
Definition:
header.h:85
BONE
22
Definition:
header.h:182
SECONDS_IN_DAYLIGHT
Definition:
header.h:50
STONE
0
Definition:
header.h:160
TIME_EVENING
Definition:
header.h:108
SHRED_NULLMOUNTAIN
Definition:
header.h:77
MOVABLE
Definition:
header.h:96
HAMMER
23
Definition:
header.h:138
BOX
16
Definition:
header.h:131
INVISIBLE
Definition:
header.h:209
SHRED_WIDTH_SHIFT
const int SHRED_WIDTH_SHIFT
Definition:
header.h:39
USAGE_TYPE_POUR
Definition:
header.h:201
KIND_TEXT
17
Definition:
header.h:132
CLOCK
10
Definition:
header.h:125
RAIN_MACHINE
25
Definition:
header.h:140
DOOR
15
Definition:
header.h:130
DWARF
3
Definition:
header.h:118
LIQUID
5
Definition:
header.h:120
SAND
15
Definition:
header.h:175
SECONDS_IN_NIGHT
Definition:
header.h:49
SHRED_DEAD_HILL
Definition:
header.h:76
SHRED_WIDTH
const int SHRED_WIDTH
Definition:
header.h:38
SHRED_DEAD_FOREST
Definition:
header.h:75
USAGE_TYPE_SET_FIRE
Definition:
header.h:202
transparency
transparency
Definition:
header.h:206
DEBUG
const bool DEBUG
Definition:
header.h:33
WEST
5
Definition:
header.h:92
NOT_MOVABLE
Definition:
header.h:98
DEFAULT_MAP_SIZE
const int DEFAULT_MAP_SIZE
Definition:
header.h:81
TELEGRAPH
30
Definition:
header.h:145
A_MEAT
8 (animal meat)
Definition:
header.h:168
USAGE_TYPE_INNER
Definition:
header.h:203
ROSE
17
Definition:
header.h:177
SUB_DUST
30
Definition:
header.h:190
GREENERY
14
Definition:
header.h:174
SHRED_WATER
Definition:
header.h:65
END_OF_EVENING
Definition:
header.h:48
USAGE_TYPE_NO
Definition:
header.h:197
times
times
Definition:
header.h:42
Generated on Thu Oct 2 2014 23:24:13 for freg by
1.8.7