0.4.0
[gemrb.git] / gemrb / includes / globals.h
blob8663fe84b7b06ad584f0e85ec2ffa8e779a22bd1
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * $Id$
22 /**
23 * @file globals.h
24 * Some global definitions and includes
25 * @author The GemRB Project
29 #ifndef GLOBALS_H
30 #define GLOBALS_H
32 #ifdef HAVE_CONFIG_H
33 #include <config.h>
34 #endif
36 #include "ie_types.h"
38 #define VERSION_GEMRB "0.4.0"
40 #define GEMRB_STRING "GemRB v" VERSION_GEMRB
42 #ifndef GLOBALS_ONLY_DEFS
44 #include "stdlib.h"
45 #include "stdio.h"
46 #include "errors.h"
47 #include "win32def.h"
48 #include "SClassID.h"
49 #include "../plugins/Core/Class_ID.h"
50 #include "../plugins/Core/ClassDesc.h"
51 #include "RGBAColor.h"
52 #include "../plugins/Core/Region.h"
53 #include "../plugins/Core/Sprite2D.h"
54 #include "../plugins/Core/VideoMode.h"
55 #include "../plugins/Core/VideoModes.h"
56 #include "../plugins/Core/DataStream.h"
57 #include "../plugins/Core/AnimStructures.h"
59 #endif //GLOBALS_ONLY_DEFS
61 #define GEM_EXPORT_DLL extern "C"
63 //Global Variables
65 #ifdef WIN32
66 #define PathDelimiter '\\'
67 #define SPathDelimiter "\\"
68 #else
69 #define PathDelimiter '/'
70 #define SPathDelimiter "/"
71 #endif
73 #define ExtractFileFromPath(file, full_path) strcpy (file, ((strrchr (full_path, PathDelimiter)==NULL) ? ((strchr (full_path, ':')==NULL) ? full_path : (strchr(full_path, ':') +1) ) : (strrchr(full_path, PathDelimiter) +1)))
75 #define IE_NORMAL 0
76 #define IE_SHADED 1
78 #define IE_STR_STRREFON 1
79 #define IE_STR_SOUND 2
80 #define IE_STR_SPEECH 4
81 #define IE_STR_ALLOW_ZERO 8 //0 strref is allowed
82 #define IE_STR_STRREFOFF 256
84 // bitflag operations
85 // !!! Keep these synchronized with GUIDefines.py !!!
86 #define BM_SET 0 //gemrb extension
87 #define BM_AND 1
88 #define BM_OR 2
89 #define BM_XOR 3
90 #define BM_NAND 4 //gemrb extension
92 //IDS Importer Defines
93 #define IDS_VALUE_NOT_LOCATED -65535 // GetValue returns this if text is not found in arrays ... this needs to be a unique number that does not exist in the value[] array
94 #define GEM_ENCRYPTION_KEY "\x88\xa8\x8f\xba\x8a\xd3\xb9\xf5\xed\xb1\xcf\xea\xaa\xe4\xb5\xfb\xeb\x82\xf9\x90\xca\xc9\xb5\xe7\xdc\x8e\xb7\xac\xee\xf7\xe0\xca\x8e\xea\xca\x80\xce\xc5\xad\xb7\xc4\xd0\x84\x93\xd5\xf0\xeb\xc8\xb4\x9d\xcc\xaf\xa5\x95\xba\x99\x87\xd2\x9d\xe3\x91\xba\x90\xca"
96 /////feature flags
97 #define GF_HAS_KAPUTZ 0 //pst
98 #define GF_ALL_STRINGS_TAGGED 1 //bg1, pst, iwd1
99 #define GF_HAS_SONGLIST 2 //bg2
100 #define GF_TEAM_MOVEMENT 3 //pst
101 #define GF_UPPER_BUTTON_TEXT 4 //bg2
102 #define GF_LOWER_LABEL_TEXT 5 //bg2
103 #define GF_HAS_PARTY_INI 6 //iwd2
104 #define GF_SOUNDFOLDERS 7 //iwd2
105 #define GF_IGNORE_BUTTON_FRAMES 8 // all?
106 #define GF_ONE_BYTE_ANIMID 9 // pst
107 #define GF_HAS_DPLAYER 10 // not pst
108 #define GF_HAS_EXPTABLE 11 // iwd, iwd2
109 #define GF_HAS_BEASTS_INI 12 //pst; also for quests.ini
110 #define GF_HAS_DESC_ICON 13 //bg
111 #define GF_HAS_PICK_SOUND 14 //pst
112 #define GF_IWD_MAP_DIMENSIONS 15 //iwd, iwd2
113 #define GF_AUTOMAP_INI 16 //pst
114 #define GF_SMALL_FOG 17 //bg1, pst
115 #define GF_REVERSE_DOOR 18 //pst
116 #define GF_PROTAGONIST_TALKS 19 //pst
117 #define GF_HAS_SPELLLIST 20 //iwd2
118 #define GF_IWD2_SCRIPTNAME 21 //iwd2
119 #define GF_DIALOGUE_SCROLLS 22 //pst
120 #define GF_KNOW_WORLD 23 //iwd2
121 #define GF_REVERSE_TOHIT 24 //all except iwd2
122 #define GF_SAVE_FOR_HALF 25 //pst
123 #define GF_CHARNAMEISGABBER 26 //iwd2
124 #define GF_MAGICBIT 27 //iwd, iwd2
125 #define GF_CHECK_ABILITIES 28 //bg2 (others?)
126 #define GF_CHALLENGERATING 29 //iwd2
127 #define GF_SPELLBOOKICONHACK 30 //bg2
128 #define GF_ENHANCED_EFFECTS 31 //iwd2 (maybe iwd/how too)
129 #define GF_DEATH_ON_ZERO_STAT 32 //not in iwd2
130 #define GF_SPAWN_INI 33 //pst, iwd, iwd2
131 #define GF_IWD_DEATHVARFORMAT 34 //iwd branch (maybe pst)
132 #define GF_RESDATA_INI 35 //pst
133 #define GF_OVERRIDE_CURSORPOS 36 //pst, iwd2
134 //update this
135 #define GF_COUNT 37
137 //the number of item usage fields (used in CREItem and STOItem)
138 #define CHARGE_COUNTERS 3
140 /////AI global defines
141 #define AI_UPDATE_TIME 15
143 /////maximum animation orientation count (used in many places)
144 #define MAX_ORIENT 16
146 /////globally used functions
147 #ifdef WIN32
149 #ifdef GEM_BUILD_DLL
150 #define GEM_EXPORT __declspec(dllexport)
151 #else
152 #define GEM_EXPORT __declspec(dllimport)
153 #endif
155 #else
156 #define GEM_EXPORT
157 #endif
159 class Scriptable;
160 class Actor;
162 /* this function will work with pl/cz special characters */
164 extern unsigned char pl_uppercase[256];
165 extern unsigned char pl_lowercase[256];
167 GEM_EXPORT void strnlwrcpy(char* d, const char *s, int l);
168 GEM_EXPORT void strnuprcpy(char* d, const char *s, int l);
169 GEM_EXPORT void strnspccpy(char* d, const char *s, int l);
170 GEM_EXPORT unsigned char GetOrient(Point &s, Point &d);
171 GEM_EXPORT unsigned int Distance(Point pos, Point pos2);
172 GEM_EXPORT unsigned int Distance(Point pos, Scriptable *b);
173 GEM_EXPORT unsigned int PersonalDistance(Point pos, Scriptable *b);
174 GEM_EXPORT unsigned int Distance(Scriptable *a, Scriptable *b);
175 GEM_EXPORT unsigned int PersonalDistance(Scriptable *a, Scriptable *b);
176 GEM_EXPORT int EARelation(Actor *a, Actor *b);
177 GEM_EXPORT bool dir_exists(const char* path);
178 GEM_EXPORT int strlench(const char* string, char ch);
179 #ifndef HAVE_STRNDUP
180 GEM_EXPORT char* strndup(const char* s, unsigned int l);
181 #endif
183 #ifndef WIN32
184 char* strupr(char* string);
185 char* strlwr(char* string);
186 #endif
188 #ifdef WIN32
189 #define GetTime(store) store = GetTickCount()
190 #else
191 #include <sys/time.h>
192 #define GetTime(store) \
194 struct timeval tv; \
195 gettimeofday(&tv, NULL); \
196 store = (tv.tv_usec/1000) + (tv.tv_sec*1000); \
198 #endif
200 //struct ActorBlock;
202 inline int MIN(int a, int b)
204 return (a > b ? b : a);
207 inline int MAX(int a, int b)
209 return (a < b ? b : a);
212 inline bool valid_number(const char* string, long& val)
214 char* endpr;
216 val = (long) strtoul( string, &endpr, 0 );
217 return ( const char * ) endpr != string;
220 #endif //! GLOBALS_H