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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
34 
35 /*============================================================================
36 == Config definitions
37 ============================================================================*/
38 
39 // Dynamic loading.
40 //#define DYNAMIC_LOAD
41 
42 /*============================================================================
43 == Compiler repairs
44 ============================================================================*/
45 
46 #ifdef _MSC_VER
47 
48 #define WIN32_LEAN_AND_MEAN
49 #define NOUSER
50 
51 #if _MSC_VER >= 1800
52 // From VS2013 onwards, std::min/max are only defined if algorithm is included
53 #include <algorithm>
54 #endif
55 
56 #pragma warning(disable:4244)
57 #pragma warning(disable:4761)
58 #pragma warning(disable:4786)
59 
60 #ifndef __func__
61 #define __func__ __FUNCTION__
62 #endif
63 
64 #define snprintf _snprintf
65 #if !(_MSC_VER >= 1500 && _MSC_VER < 1600)
66 #define vsnprintf _vsnprintf
67 #endif
68 #define unlink _unlink
69 #define strdup _strdup
70 #define strcasecmp _stricmp
71 #define strncasecmp _strnicmp
72 
73 #endif // } _MSC_VER
74 
75 
76 /*============================================================================
77 == Macro
78 ============================================================================*/
79 
80 // To remove warning for unused variable.
81 #ifdef __GNUC__
82 #define UNUSED(var) do {__typeof__ (&var) __attribute__ ((unused)) __tmp = &var; } while(0)
83 #else
84 #define UNUSED(var) (var)
85 #endif
86 
87 #ifdef __GNUC__
88 #define PRINTF_VAARG_ATTRIBUTE(a, b) __attribute__((format (printf, a, b)))
89 #else
90 #define PRINTF_VAARG_ATTRIBUTE(a, b)
91 #endif
92 
93 /*============================================================================
94 == Debug definitions
95 ============================================================================*/
96 
102 #define _C_ ,
103 
104 extern void PrintLocation(const char *file, int line, const char *funcName);
105 
107 #define PrintFunction() PrintLocation(__FILE__, __LINE__, __func__);
108 
109 extern bool EnableDebugPrint;
110 extern bool EnableAssert;
111 extern bool EnableUnitDebug;
112 
113 extern void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr);
114 extern void PrintOnStdOut(const char *format, ...);
115 
119 #define Assert(cond) \
120  do { if (EnableAssert && !(cond)) { AbortAt(__FILE__, __LINE__, __func__, #cond); }} while (0)
121 
125 #define DebugPrint(args) \
126  do { if (EnableDebugPrint) { PrintFunction(); PrintOnStdOut(args); } } while (0)
127 
128 /*============================================================================
129 == Definitions
130 ============================================================================*/
131 
132 #include <string.h>
133 
134 #ifndef __UTIL_H__
135 #include "util.h"
136 #endif
137 
138 inline char *new_strdup(const char *str)
139 {
140  int len = strlen(str) + 1;
141  char *newstr = new char[len];
142  strcpy_s(newstr, len, str);
143  return newstr;
144 }
145 
146 /*----------------------------------------------------------------------------
147 -- General
148 ----------------------------------------------------------------------------*/
149 
151 extern const char NameLine[];
152 
153 /*----------------------------------------------------------------------------
154 -- Some limits
155 ----------------------------------------------------------------------------*/
156 
157 #define PlayerMax 16
158 #define UnitTypeMax 2048
159 #define UpgradeMax 2048
160 #define MAX_RACES 8
161 
163 #define FRAMES_PER_SECOND 30 // 1/30s
164 #define CYCLES_PER_SECOND 30 // 1/30s 0.33ms
166 
167 /*----------------------------------------------------------------------------
168 -- stratagus.cpp
169 ----------------------------------------------------------------------------*/
170 
171 extern std::string StratagusLibPath;
172 extern std::string MenuRace;
173 
174 extern unsigned long GameCycle;
175 extern unsigned long FastForwardCycle;
176 
177 extern void Exit(int err);
178 extern void ExitFatal(int err);
179 
180 extern void UpdateDisplay();
181 extern void DrawMapArea();
182 extern void GameMainLoop();
183 extern int stratagusMain(int argc, char **argv);
184 
186 
187 #endif // !__STRATAGUS_H__
void Exit(int err)
Game Replay Fast Forward Counter.
Definition: stratagus.cpp:396
void PrintLocation(const char *file, int line, const char *funcName)
if enabled, a unit info dump will be created
Definition: util.cpp:520
std::string StratagusLibPath
Definition: stratagus.cpp:236
errno_t strcpy_s(char *dst, size_t dstsize, const char *src)
Definition: util.cpp:185
void PrintOnStdOut(const char *format,...)
Definition: util.cpp:539
const char NameLine[]
Text string: Name, Version, Copyright.
Definition: stratagus.cpp:239
std::string MenuRace
Location of stratagus data.
Definition: stratagus.cpp:242
unsigned long FastForwardCycle
Game simulation cycle counter.
Definition: game.cpp:94
int stratagusMain(int argc, char **argv)
Game main loop.
Definition: stratagus.cpp:698
bool EnableAssert
if enabled, print the debug messages
Definition: stratagus.cpp:245
void GameMainLoop()
Draw the map area.
Definition: mainloop.cpp:400
void DrawMapArea()
Game display update.
Definition: mainloop.cpp:147
bool EnableDebugPrint
Definition: stratagus.cpp:244
bool EnableUnitDebug
if enabled, halt on assertion failures
Definition: stratagus.cpp:246
char * new_strdup(const char *str)
Definition: stratagus.h:138
void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr)
Definition: util.cpp:525
void UpdateDisplay()
Exit with fatal error.
Definition: mainloop.cpp:169
unsigned long GameCycle
Definition: game.cpp:93
void ExitFatal(int err)
Exit.
Definition: stratagus.cpp:433
(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.