SaveGame: Properly handle naming savegames using strrefs. (IWD2)
[gemrb.git] / gemrb / includes / globals.h
blobdc48297fbc912331babe79741a81b154becd49e8
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.
21 /**
22 * @file globals.h
23 * Some global definitions and includes
24 * @author The GemRB Project
28 #ifndef GLOBALS_H
29 #define GLOBALS_H
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
35 #include "ie_types.h"
37 #define VERSION_GEMRB "0.6.0"
39 #define GEMRB_STRING "GemRB v" VERSION_GEMRB
41 #ifndef GLOBALS_ONLY_DEFS
43 #include "stdlib.h"
44 #include "stdio.h"
45 #include "errors.h"
46 #include "win32def.h"
47 #include "SClassID.h"
48 #include "RGBAColor.h"
49 #include "Region.h"
50 #include "Sprite2D.h"
51 #include "VideoMode.h"
52 #include "VideoModes.h"
53 #include "DataStream.h"
54 #include "AnimStructures.h"
56 #endif //GLOBALS_ONLY_DEFS
58 //Global Variables
60 #ifdef WIN32
61 #define PathDelimiter '\\'
62 #define SPathDelimiter "\\"
63 #else
64 #define PathDelimiter '/'
65 #define SPathDelimiter "/"
66 #endif
68 #define IE_NORMAL 0
69 #define IE_SHADED 1
71 #define IE_STR_STRREFON 1
72 #define IE_STR_SOUND 2
73 #define IE_STR_SPEECH 4
74 #define IE_STR_ALLOW_ZERO 8 //0 strref is allowed
75 #define IE_STR_STRREFOFF 256
76 #define IE_STR_REMOVE_NEWLINE 0x1000 // gemrb extension: remove extraneus ending newline
78 // bitflag operations
79 // !!! Keep these synchronized with GUIDefines.py !!!
80 #define BM_SET 0 //gemrb extension
81 #define BM_AND 1
82 #define BM_OR 2
83 #define BM_XOR 3
84 #define BM_NAND 4 //gemrb extension
86 //IDS Importer Defines
87 #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
88 #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"
90 /////feature flags
91 #define GF_HAS_KAPUTZ 0 //pst
92 #define GF_ALL_STRINGS_TAGGED 1 //bg1, pst, iwd1
93 #define GF_HAS_SONGLIST 2 //bg2
94 #define GF_TEAM_MOVEMENT 3 //pst
95 #define GF_UPPER_BUTTON_TEXT 4 //bg2
96 #define GF_LOWER_LABEL_TEXT 5 //bg2
97 #define GF_HAS_PARTY_INI 6 //iwd2
98 #define GF_SOUNDFOLDERS 7 //iwd2
99 #define GF_IGNORE_BUTTON_FRAMES 8 // all?
100 #define GF_ONE_BYTE_ANIMID 9 // pst
101 #define GF_HAS_DPLAYER 10 // not pst
102 #define GF_HAS_EXPTABLE 11 // iwd, iwd2
103 #define GF_HAS_BEASTS_INI 12 //pst; also for quests.ini
104 #define GF_HAS_DESC_ICON 13 //bg
105 #define GF_HAS_PICK_SOUND 14 //pst
106 #define GF_IWD_MAP_DIMENSIONS 15 //iwd, iwd2
107 #define GF_AUTOMAP_INI 16 //pst
108 #define GF_SMALL_FOG 17 //bg1, pst
109 #define GF_REVERSE_DOOR 18 //pst
110 #define GF_PROTAGONIST_TALKS 19 //pst
111 #define GF_HAS_SPELLLIST 20 //iwd2
112 #define GF_IWD2_SCRIPTNAME 21 //iwd2, iwd, how
113 #define GF_DIALOGUE_SCROLLS 22 //pst
114 #define GF_KNOW_WORLD 23 //iwd2
115 #define GF_REVERSE_TOHIT 24 //all except iwd2
116 #define GF_SAVE_FOR_HALF 25 //pst
117 #define GF_CHARNAMEISGABBER 26 //iwd2
118 #define GF_MAGICBIT 27 //iwd, iwd2
119 #define GF_CHECK_ABILITIES 28 //bg2 (others?)
120 #define GF_CHALLENGERATING 29 //iwd2
121 #define GF_SPELLBOOKICONHACK 30 //bg2
122 #define GF_ENHANCED_EFFECTS 31 //iwd2 (maybe iwd/how too)
123 #define GF_DEATH_ON_ZERO_STAT 32 //not in iwd2
124 #define GF_SPAWN_INI 33 //pst, iwd, iwd2
125 #define GF_IWD2_DEATHVARFORMAT 34 //iwd branch (maybe pst)
126 #define GF_RESDATA_INI 35 //pst
127 #define GF_OVERRIDE_CURSORPOS 36 //pst, iwd2
128 #define GF_BREAKABLE_WEAPONS 37 //bg1, not bg2 and iwd2, maybe others
129 #define GF_3ED_RULES 38 //iwd2
130 #define GF_LEVELSLOT_PER_CLASS 39 //iwd2
131 #define GF_SELECTIVE_MAGIC_RES 40 //bg2, iwd2, (how)
132 #define GF_HAS_HIDE_IN_SHADOWS 41 // not in bg1 and pst
133 #define GF_AREA_VISITED_VAR 42 //iwd, iwd2
134 #define GF_PROPER_BACKSTAB 43 //bg2, iwd2, how?
135 #define GF_ONSCREEN_TEXT 44 //pst
136 #define GF_SPECIFIC_DMG_BONUS 45 //how, iwd2
137 #define GF_STRREF_SAVEGAME 46 //iwd2
138 //update this
139 #define GF_COUNT 47
141 //the number of item usage fields (used in CREItem and STOItem)
142 #define CHARGE_COUNTERS 3
144 /////AI global defines
145 #define AI_UPDATE_TIME 15
147 /////maximum animation orientation count (used in many places)
148 #define MAX_ORIENT 16
150 /////globally used functions
152 class Scriptable;
153 class Actor;
155 /* this function will work with pl/cz special characters */
157 extern unsigned char pl_uppercase[256];
158 extern unsigned char pl_lowercase[256];
160 GEM_EXPORT void strnlwrcpy(char* d, const char *s, int l);
161 GEM_EXPORT void strnuprcpy(char* d, const char *s, int l);
162 GEM_EXPORT void strnspccpy(char* d, const char *s, int l);
163 #ifndef HAVE_STRNLEN
164 GEM_EXPORT int strnlen(const char* string, int maxlen);
165 #endif
166 GEM_EXPORT unsigned char GetOrient(Point &s, Point &d);
167 GEM_EXPORT unsigned int Distance(Point pos, Point pos2);
168 GEM_EXPORT unsigned int Distance(Point pos, Scriptable *b);
169 GEM_EXPORT unsigned int PersonalDistance(Point pos, Scriptable *b);
170 GEM_EXPORT unsigned int Distance(Scriptable *a, Scriptable *b);
171 GEM_EXPORT unsigned int PersonalDistance(Scriptable *a, Scriptable *b);
172 GEM_EXPORT int EARelation(Scriptable *a, Actor *b);
173 GEM_EXPORT bool dir_exists(const char* path);
174 GEM_EXPORT int strlench(const char* string, char ch);
175 #ifndef HAVE_STRNDUP
176 GEM_EXPORT char* strndup(const char* s, size_t l);
177 #endif
179 #ifndef WIN32
180 GEM_EXPORT char* strupr(char* string);
181 GEM_EXPORT char* strlwr(char* string);
182 #endif
184 #ifdef WIN32
185 #define GetTime(store) store = GetTickCount()
186 #else
187 #include <sys/time.h>
188 #define GetTime(store) \
190 struct timeval tv; \
191 gettimeofday(&tv, NULL); \
192 store = (tv.tv_usec/1000) + (tv.tv_sec*1000); \
194 #endif
196 //struct ActorBlock;
198 inline int MIN(int a, int b)
200 return (a > b ? b : a);
203 inline int MAX(int a, int b)
205 return (a < b ? b : a);
208 inline bool valid_number(const char* string, long& val)
210 char* endpr;
212 val = (long) strtoul( string, &endpr, 0 );
213 return ( const char * ) endpr != string;
216 #endif //! GLOBALS_H