_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

stratagus.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2007 by Lutz Sammer and Jimmy Salmon
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __STRATAGUS_H__
31 #define __STRATAGUS_H__
32 
33 #ifdef HAVE_COZ_PROFILER
34 #include <coz.h>
35 #endif
36 
37 #include <string>
38 #include <vector>
39 
40 #ifdef USE_OPENMP
41 #include <omp.h>
42 #else
43 #define omp_get_thread_num() 0
44 #define omp_get_num_threads() 1
45 #endif
46 
48 
49 /*============================================================================
50 == Config definitions
51 ============================================================================*/
52 
53 // Dynamic loading.
54 //#define DYNAMIC_LOAD
55 
56 /*============================================================================
57 == Compiler repairs
58 ============================================================================*/
59 
60 #ifdef _MSC_VER
61 
62 #ifndef WIN32_LEAN_AND_MEAN
63 #define WIN32_LEAN_AND_MEAN
64 #endif
65 
66 #include <Shlobj.h>
67 
68 #if _MSC_VER >= 1800
69 // From VS2013 onwards, std::min/max are only defined if algorithm is included
70 #include <algorithm>
71 #endif
72 
73 #pragma warning(disable:4244)
74 #pragma warning(disable:4761)
75 #pragma warning(disable:4786)
76 #pragma warning(disable:4996)
77 
78 #ifndef __func__
79 #define __func__ __FUNCTION__
80 #endif
81 
82 #define snprintf _snprintf
83 #if !(_MSC_VER >= 1500 && _MSC_VER < 1600)
84 #define vsnprintf _vsnprintf
85 #endif
86 #define unlink _unlink
87 #define strdup _strdup
88 #define strcasecmp _stricmp
89 #define strncasecmp _strnicmp
90 
91 #endif // } _MSC_VER
92 
93 
94 /*============================================================================
95 == Macro
96 ============================================================================*/
97 
98 // To remove warning for unused variable.
99 #ifdef __GNUC__
100 #define UNUSED(var) do {__typeof__ (&var) __attribute__ ((unused)) __tmp = &var; } while(0)
101 #else
102 #define UNUSED(var) (var)
103 #endif
104 
105 #ifdef __GNUC__
106 #define PRINTF_VAARG_ATTRIBUTE(a, b) __attribute__((format (printf, a, b)))
107 #else
108 #define PRINTF_VAARG_ATTRIBUTE(a, b)
109 #endif
110 
111 /*============================================================================
112 == Debug definitions
113 ============================================================================*/
114 
120 #define _C_ ,
121 
122 extern void PrintLocation(const char *file, int line, const char *funcName);
123 
125 #define PrintFunction() PrintLocation(__FILE__, __LINE__, __func__);
126 
127 extern bool EnableDebugPrint;
128 extern bool EnableAssert;
129 extern bool EnableUnitDebug;
130 extern bool IsRestart;
131 extern bool IsDebugEnabled;
132 extern bool EnableWallsInSinglePlayer;
133 
134 extern std::vector<std::string> OriginalArgv;
135 
136 extern void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr);
137 extern void PrintOnStdOut(const char *format, ...);
138 
142 #define Assert(cond) \
143  do { if (EnableAssert && !(cond)) { AbortAt(__FILE__, __LINE__, __func__, #cond); }} while (0)
144 
148 #define DebugPrint(args) \
149  do { if (EnableDebugPrint) { PrintFunction(); PrintOnStdOut(args); } } while (0)
150 
151 /*============================================================================
152 == Definitions
153 ============================================================================*/
154 
155 #include "util.h"
156 #include "settings.h"
157 
158 inline char *new_strdup(const char *str)
159 {
160  int len = strlen(str) + 1;
161  char *newstr = new char[len];
162  strcpy_s(newstr, len, str);
163  return newstr;
164 }
165 
166 /*----------------------------------------------------------------------------
167 -- General
168 ----------------------------------------------------------------------------*/
169 
171 extern const char NameLine[];
172 
173 /*----------------------------------------------------------------------------
174 -- stratagus.cpp
175 ----------------------------------------------------------------------------*/
176 
177 extern std::string StratagusLibPath;
178 extern std::string MenuRace;
179 
180 extern unsigned long GameCycle;
181 extern unsigned long FastForwardCycle;
182 
183 extern void Exit(int err);
184 extern void ExitFatal(int err);
185 
186 extern void UpdateDisplay();
187 extern void DrawMapArea();
188 extern void GameMainLoop();
189 extern int stratagusMain(int argc, char **argv);
190 
192 
193 #endif // !__STRATAGUS_H__
GameCycle
unsigned long GameCycle
Definition: game.cpp:94
EnableAssert
bool EnableAssert
if enabled, print the debug messages
Definition: stratagus.cpp:247
stratagusMain
int stratagusMain(int argc, char **argv)
Game main loop.
Definition: stratagus.cpp:692
DrawMapArea
void DrawMapArea()
Game display update.
Definition: mainloop.cpp:160
settings.h
EnableDebugPrint
bool EnableDebugPrint
Definition: stratagus.cpp:246
new_strdup
char * new_strdup(const char *str)
Definition: stratagus.h:158
EnableUnitDebug
bool EnableUnitDebug
if enabled, halt on assertion failures
Definition: stratagus.cpp:248
OriginalArgv
std::vector< std::string > OriginalArgv
if true, the game skips some things like title screens
Definition: stratagus.cpp:251
strcpy_s
errno_t strcpy_s(char *dst, size_t dstsize, const char *src)
Definition: util.cpp:217
NameLine
const char NameLine[]
Text string: Name, Version, Copyright.
Definition: stratagus.cpp:241
GameMainLoop
void GameMainLoop()
Draw the map area.
Definition: mainloop.cpp:403
PrintLocation
void PrintLocation(const char *file, int line, const char *funcName)
Definition: util.cpp:477
MenuRace
std::string MenuRace
Location of stratagus data.
Definition: stratagus.cpp:244
AbortAt
void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr)
Definition: util.cpp:482
UpdateDisplay
void UpdateDisplay()
Exit with fatal error.
Definition: mainloop.cpp:182
StratagusLibPath
std::string StratagusLibPath
Definition: stratagus.cpp:238
PrintOnStdOut
void PrintOnStdOut(const char *format,...)
Definition: util.cpp:497
Exit
void Exit(int err)
Game Replay Fast Forward Counter.
Definition: stratagus.cpp:388
IsRestart
bool IsRestart
if enabled, a unit info dump will be created
Definition: stratagus.cpp:249
IsDebugEnabled
bool IsDebugEnabled
Definition: stratagus.cpp:256
FastForwardCycle
unsigned long FastForwardCycle
Game simulation cycle counter.
Definition: game.cpp:95
ExitFatal
void ExitFatal(int err)
Exit.
Definition: stratagus.cpp:433
EnableWallsInSinglePlayer
bool EnableWallsInSinglePlayer
Is debug enabled? Flag to pass into lua code.
Definition: stratagus.cpp:258
util.h
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.