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.
23 * Some global definitions and includes
24 * @author The GemRB Project
37 #define VERSION_GEMRB "0.6.0"
39 #define GEMRB_STRING "GemRB v" VERSION_GEMRB
41 #ifndef GLOBALS_ONLY_DEFS
43 #include "RGBAColor.h"
48 #include "AnimStructures.h"
49 #include "DataStream.h"
52 #include "VideoMode.h"
53 #include "VideoModes.h"
58 #endif //GLOBALS_ONLY_DEFS
65 #define IE_STR_STRREFON 1
66 #define IE_STR_SOUND 2
67 #define IE_STR_SPEECH 4
68 #define IE_STR_ALLOW_ZERO 8 //0 strref is allowed
69 #define IE_STR_STRREFOFF 256
70 #define IE_STR_REMOVE_NEWLINE 0x1000 // gemrb extension: remove extraneus ending newline
73 // !!! Keep these synchronized with GUIDefines.py !!!
74 #define BM_SET 0 //gemrb extension
78 #define BM_NAND 4 //gemrb extension
80 //IDS Importer Defines
81 #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
82 #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"
85 #define GF_HAS_KAPUTZ 0 //pst
86 #define GF_ALL_STRINGS_TAGGED 1 //bg1, pst, iwd1
87 #define GF_HAS_SONGLIST 2 //bg2
88 #define GF_TEAM_MOVEMENT 3 //pst
89 #define GF_UPPER_BUTTON_TEXT 4 //bg2
90 #define GF_LOWER_LABEL_TEXT 5 //bg2
91 #define GF_HAS_PARTY_INI 6 //iwd2
92 #define GF_SOUNDFOLDERS 7 //iwd2
93 #define GF_IGNORE_BUTTON_FRAMES 8 // all?
94 #define GF_ONE_BYTE_ANIMID 9 // pst
95 #define GF_HAS_DPLAYER 10 // not pst
96 #define GF_HAS_EXPTABLE 11 // iwd, iwd2
97 #define GF_HAS_BEASTS_INI 12 //pst; also for quests.ini
98 #define GF_HAS_DESC_ICON 13 //bg
99 #define GF_HAS_PICK_SOUND 14 //pst
100 #define GF_IWD_MAP_DIMENSIONS 15 //iwd, iwd2
101 #define GF_AUTOMAP_INI 16 //pst
102 #define GF_SMALL_FOG 17 //bg1, pst
103 #define GF_REVERSE_DOOR 18 //pst
104 #define GF_PROTAGONIST_TALKS 19 //pst
105 #define GF_HAS_SPELLLIST 20 //iwd2
106 #define GF_IWD2_SCRIPTNAME 21 //iwd2, iwd, how
107 #define GF_DIALOGUE_SCROLLS 22 //pst
108 #define GF_KNOW_WORLD 23 //iwd2
109 #define GF_REVERSE_TOHIT 24 //all except iwd2
110 #define GF_SAVE_FOR_HALF 25 //pst
111 #define GF_CHARNAMEISGABBER 26 //iwd2
112 #define GF_MAGICBIT 27 //iwd, iwd2
113 #define GF_CHECK_ABILITIES 28 //bg2 (others?)
114 #define GF_CHALLENGERATING 29 //iwd2
115 #define GF_SPELLBOOKICONHACK 30 //bg2
116 #define GF_ENHANCED_EFFECTS 31 //iwd2 (maybe iwd/how too)
117 #define GF_DEATH_ON_ZERO_STAT 32 //not in iwd2
118 #define GF_SPAWN_INI 33 //pst, iwd, iwd2
119 #define GF_IWD2_DEATHVARFORMAT 34 //iwd branch (maybe pst)
120 #define GF_RESDATA_INI 35 //pst
121 #define GF_OVERRIDE_CURSORPOS 36 //pst, iwd2
122 #define GF_BREAKABLE_WEAPONS 37 //bg1, not bg2 and iwd2, maybe others
123 #define GF_3ED_RULES 38 //iwd2
124 #define GF_LEVELSLOT_PER_CLASS 39 //iwd2
125 #define GF_SELECTIVE_MAGIC_RES 40 //bg2, iwd2, (how)
126 #define GF_HAS_HIDE_IN_SHADOWS 41 // not in bg1 and pst
127 #define GF_AREA_VISITED_VAR 42 //iwd, iwd2
128 #define GF_PROPER_BACKSTAB 43 //bg2, iwd2, how?
129 #define GF_ONSCREEN_TEXT 44 //pst
130 #define GF_SPECIFIC_DMG_BONUS 45 //how, iwd2
131 #define GF_STRREF_SAVEGAME 46 //iwd2
135 //the number of item usage fields (used in CREItem and STOItem)
136 #define CHARGE_COUNTERS 3
138 /////AI global defines
139 #define AI_UPDATE_TIME 15
141 /////maximum animation orientation count (used in many places)
142 #define MAX_ORIENT 16
144 /////globally used functions
149 /* this function will work with pl/cz special characters */
151 extern unsigned char pl_uppercase
[256];
152 extern unsigned char pl_lowercase
[256];
154 GEM_EXPORT
void strnlwrcpy(char* d
, const char *s
, int l
);
155 GEM_EXPORT
void strnuprcpy(char* d
, const char *s
, int l
);
156 GEM_EXPORT
void strnspccpy(char* d
, const char *s
, int l
);
158 GEM_EXPORT
int strnlen(const char* string
, int maxlen
);
160 GEM_EXPORT
unsigned char GetOrient(const Point
&s
, const Point
&d
);
161 GEM_EXPORT
unsigned int Distance(const Point pos
, const Point pos2
);
162 GEM_EXPORT
unsigned int Distance(const Point pos
, Scriptable
*b
);
163 GEM_EXPORT
unsigned int PersonalDistance(const Point pos
, Scriptable
*b
);
164 GEM_EXPORT
unsigned int Distance(Scriptable
*a
, Scriptable
*b
);
165 GEM_EXPORT
unsigned int PersonalDistance(Scriptable
*a
, Scriptable
*b
);
166 GEM_EXPORT
int EARelation(Scriptable
*a
, Actor
*b
);
167 GEM_EXPORT
bool dir_exists(const char* path
);
168 GEM_EXPORT
int strlench(const char* string
, char ch
);
170 GEM_EXPORT
char* strndup(const char* s
, size_t l
);
174 GEM_EXPORT
char* strupr(char* string
);
175 GEM_EXPORT
char* strlwr(char* string
);
179 #define GetTime(store) store = GetTickCount()
181 #include <sys/time.h>
182 #define GetTime(store) \
185 gettimeofday(&tv, NULL); \
186 store = (tv.tv_usec/1000) + (tv.tv_sec*1000); \
192 inline int MIN(int a
, int b
)
194 return (a
> b
? b
: a
);
197 inline int MAX(int a
, int b
)
199 return (a
< b
? b
: a
);
202 inline bool valid_number(const char* string
, long& val
)
206 val
= (long) strtoul( string
, &endpr
, 0 );
207 return ( const char * ) endpr
!= string
;
210 //we need 32+6 bytes at least, because we store 'context' in the variable
212 #define MAX_VARIABLE_LENGTH 40