Debian Codegraph @

engine/include/stratagus.h

raw
1 // ____ _ __
2 // / __ )____ _____ | | / /___ ___________
3 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
4 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
5 // /_____/\____/____/ |__/|__/\__,_/_/ /____/
6 //
7 // A futuristic real-time strategy game.
8 // This file is part of Bos Wars.
9 //
10 /**@name stratagus.h - The main header file. */
11 //
12 // (c) Copyright 1998-2008 by Lutz Sammer and Jimmy Salmon
13 //
14 // This program is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; only version 2 of the License.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 // 02111-1307, USA.
27
28 #ifndef __STRATAGUS_H__
29 #define __STRATAGUS_H__
30
31 //@{
32
33 #ifdef HAVE_CONFIG_H
34 #include <config.h>
35 #endif
36
37 #include <stdlib.h>
38
39 /*============================================================================
40 == Compiler repairs
41 ============================================================================*/
42
43 #ifdef _MSC_VER
44
45 #define WIN32_LEAN_AND_MEAN
46 #define NOUSER
47
48 #define inline __inline
49 #define alloca _alloca
50
51 #pragma warning(disable:4244) /// Conversion from double to uchar
52 #pragma warning(disable:4761) /// Integral size mismatch
53 #pragma warning(disable:4786) /// Truncated to 255 chars
54 #define abort() _ASSERT(0)
55 #include <stdio.h>
56 #define snprintf _snprintf
57 #define vsnprintf _vsnprintf
58 #define unlink _unlink
59 #include <string.h>
60 #define strdup _strdup
61 #define strcasecmp _stricmp
62 #define strncasecmp _strnicmp
63 #include <io.h>
64 #define access _access
65 #define write _write
66 #include <direct.h>
67 #define makedir(dir, permissions) _mkdir(dir)
68
69 #endif // } _MSC_VER
70
71 #ifdef __GNUC__
72 #ifdef USE_WIN32
73 #define makedir(dir, permissions) mkdir(dir)
74 #else
75 #define makedir(dir, permissions) mkdir(dir, permissions)
76 #endif
77 #endif
78
79 /*============================================================================
80 == Debug definitions
81 ============================================================================*/
82
83 /**
84 ** This simulates vararg macros.
85 ** Example:
86 ** DebugPrint("Test %d %d\n" _C_ 1 _C_ 2);
87 */
88 #define _C_ , /// Debug , to simulate vararg macros
89
90 /// Print function in debug macros
91 #define PrintFunction() \
92 do { fprintf(stdout, "%s:%d: ", __FILE__, __LINE__); } while (0)
93
94
95 #ifdef DEBUG // {
96
97 /**
98 ** Assert a condition. If cond is not true abort with file,line.
99 */
100 #define Assert(cond) do { if (!(cond)) { \
101 fprintf(stderr, "Assertion failed at %s:%d: %s\n", __FILE__, __LINE__, #cond); \
102 abort(); }} while (0)
103
104 /**
105 ** Print debug information with function name.
106 */
107 #define DebugPrint(args) \
108 do { PrintFunction(); fprintf(stdout, args); } while (0)
109
110 #else // }{ DEBUG
111
112 #define Assert(cond) /* disabled */
113 #define DebugPrint(args) /* disabled */
114
115 #endif
116
117 /*============================================================================
118 == Definitions
119 ============================================================================*/
120
121 #include <string>
122 #include "util.h"
123 #include "translate.h"
124
125 /*----------------------------------------------------------------------------
126 -- Translate
127 ----------------------------------------------------------------------------*/
128
129 #define _(str) Translate(str)
130 #define N_(str) str
131
132 /*----------------------------------------------------------------------------
133 -- General
134 ----------------------------------------------------------------------------*/
135 #ifndef STRATAGUS_LIB_PATH
136 #define STRATAGUS_LIB_PATH "." /// Where to find the data files
137 #endif
138
139 #ifndef STRATAGUS_HOME_PATH
140 #ifdef __APPLE__
141 #define STRATAGUS_HOME_PATH "Library/boswars/"
142 #elif USE_WIN32
143 #define STRATAGUS_HOME_PATH "boswars/"
144 #else
145 #define STRATAGUS_HOME_PATH ".boswars/"
146 #endif
147 #endif
148
149 /*----------------------------------------------------------------------------
150 -- Some limits
151 ----------------------------------------------------------------------------*/
152
153 #define PlayerMax 9 /// How many players are supported
154 #define UnitTypeMax 257 /// How many unit types supported
155 #define UnitMax 2048 /// How many units supported
156
157 /*----------------------------------------------------------------------------
158 -- Screen
159 ----------------------------------------------------------------------------*/
160
161 /// Frames per second to display
162 #define FRAMES_PER_SECOND 30 // 1/30s
163 /// Game cycles per second to simulate
164 #define CYCLES_PER_SECOND 30 // 1/30s 33ms
165
166 /*----------------------------------------------------------------------------
167 -- stratagus.cpp
168 ----------------------------------------------------------------------------*/
169
170 extern std::string UserDirectory; /// Directory containing user settings and data
171 extern std::string StratagusLibPath; /// Location of stratagus data
172
173 extern std::string ClickMissile; /// Missile to show when you click
174 extern std::string DamageMissile; /// Missile to show damage caused
175
176 extern int SpeedBuild; /// Speed factor for building
177 extern int SpeedTrain; /// Speed factor for training
178
179 extern unsigned long GameCycle; /// Game simulation cycle counter
180 extern unsigned long FastForwardCycle; /// Game Replay Fast Forward Counter
181
182 extern std::string CompileOptions; /// Compile options
183 extern bool SaveGameLoading; /// Save game is in progress of loading
184
185 #ifdef DEBUG
186 extern bool DumpAllSdlEvents; /// Show all events received from SDL
187 #endif
188
189 extern void LoadGame(const std::string &filename); /// Load saved game
190 extern void SaveGame(const std::string &filename); /// Save game
191
192 extern void Exit(int err); /// Exit
193 extern void ExitFatal(int err); /// Exit with fatal error
194
195 extern void UpdateDisplay(void); /// Game display update
196 extern void InitModules(void); /// Initialize all modules
197 extern void LoadModules(void); /// Load all modules
198 extern void CleanModules(void); /// Cleanup all modules
199 extern void DrawMapArea(void); /// Draw the map area
200 extern void GameMainLoop(void); /// Game main loop
201
202 /// Show load progress
203 extern void ShowLoadProgress(const char *fmt, ...) GCC_ATTR((format(printf, 1, 2)));
204
205 //@}
206
207 #endif // !__STRATAGUS_H__