_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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 
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 #define NOMINMAX // do not use min, max as macro
51 
52 #if _MSC_VER >= 1800
53 // From VS2013 onwards, std::min/max are only defined if algorithm is included
54 #include <algorithm>
55 #endif
56 
57 #pragma warning(disable:4244)
58 #pragma warning(disable:4761)
59 #pragma warning(disable:4786)
60 
61 #ifndef __func__
62 #define __func__ __FUNCTION__
63 #endif
64 
65 #define snprintf _snprintf
66 #if !(_MSC_VER >= 1500 && _MSC_VER < 1600)
67 #define vsnprintf _vsnprintf
68 #endif
69 #define unlink _unlink
70 #define strdup _strdup
71 #define strcasecmp _stricmp
72 #define strncasecmp _strnicmp
73 
74 #endif // } _MSC_VER
75 
76 
77 /*============================================================================
78 == Macro
79 ============================================================================*/
80 
81 // To remove warning for unused variable.
82 #ifdef __GNUC__
83 #define UNUSED(var) do {__typeof__ (&var) __attribute__ ((unused)) __tmp = &var; } while(0)
84 #else
85 #define UNUSED(var) (var)
86 #endif
87 
88 #ifdef __GNUC__
89 #define PRINTF_VAARG_ATTRIBUTE(a, b) __attribute__((format (printf, a, b)))
90 #else
91 #define PRINTF_VAARG_ATTRIBUTE(a, b)
92 #endif
93 
94 /*============================================================================
95 == Debug definitions
96 ============================================================================*/
97 
103 #define _C_ ,
104 
105 extern void PrintLocation(const char *file, int line, const char *funcName);
106 
108 #define PrintFunction() PrintLocation(__FILE__, __LINE__, __func__);
109 
110 extern bool EnableDebugPrint;
111 extern bool EnableAssert;
112 extern bool EnableUnitDebug;
113 
114 extern void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr);
115 extern void PrintOnStdOut(const char *format, ...);
116 
120 #define Assert(cond) \
121  do { if (EnableAssert && !(cond)) { AbortAt(__FILE__, __LINE__, __func__, #cond); }} while (0)
122 
126 #define DebugPrint(args) \
127  do { if (EnableDebugPrint) { PrintFunction(); PrintOnStdOut(args); } } while (0)
128 
129 /*============================================================================
130 == Definitions
131 ============================================================================*/
132 
133 #include <string.h>
134 
135 #ifndef __UTIL_H__
136 #include "util.h"
137 #endif
138 
139 inline char *new_strdup(const char *str)
140 {
141  int len = strlen(str) + 1;
142  char *newstr = new char[len];
143  strcpy_s(newstr, len, str);
144  return newstr;
145 }
146 
147 /*----------------------------------------------------------------------------
148 -- General
149 ----------------------------------------------------------------------------*/
150 
152 extern const char NameLine[];
153 
154 /*----------------------------------------------------------------------------
155 -- Some limits
156 ----------------------------------------------------------------------------*/
157 
158 #define PlayerMax 16
159 #define UnitTypeMax 2048
160 #define UpgradeMax 2048
161 #define MAX_RACES 8
162 
164 #define FRAMES_PER_SECOND 30 // 1/30s
165 #define CYCLES_PER_SECOND 30 // 1/30s 0.33ms
167 
168 /*----------------------------------------------------------------------------
169 -- stratagus.cpp
170 ----------------------------------------------------------------------------*/
171 
172 extern std::string StratagusLibPath;
173 extern std::string MenuRace;
174 
175 extern unsigned long GameCycle;
176 extern unsigned long FastForwardCycle;
177 
178 extern void Exit(int err);
179 extern void ExitFatal(int err);
180 
181 extern void UpdateDisplay();
182 extern void DrawMapArea();
183 extern void GameMainLoop();
184 extern int stratagusMain(int argc, char **argv);
185 
187 
188 #endif // !__STRATAGUS_H__
void Exit(int err)
Game Replay Fast Forward Counter.
Definition: stratagus.cpp:397
void PrintLocation(const char *file, int line, const char *funcName)
if enabled, a unit info dump will be created
Definition: util.cpp:496
std::string StratagusLibPath
Definition: stratagus.cpp:234
errno_t strcpy_s(char *dst, size_t dstsize, const char *src)
Definition: util.cpp:161
void PrintOnStdOut(const char *format,...)
Definition: util.cpp:515
const char NameLine[]
Text string: Name, Version, Copyright.
Definition: stratagus.cpp:237
std::string MenuRace
Location of stratagus data.
Definition: stratagus.cpp:240
unsigned long FastForwardCycle
Game simulation cycle counter.
Definition: game.cpp:94
int stratagusMain(int argc, char **argv)
Game main loop.
Definition: stratagus.cpp:688
bool EnableAssert
if enabled, print the debug messages
Definition: stratagus.cpp:243
void GameMainLoop()
Draw the map area.
Definition: mainloop.cpp:394
void DrawMapArea()
Game display update.
Definition: mainloop.cpp:146
bool EnableDebugPrint
Definition: stratagus.cpp:242
bool EnableUnitDebug
if enabled, halt on assertion failures
Definition: stratagus.cpp:244
char * new_strdup(const char *str)
Definition: stratagus.h:139
void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr)
Definition: util.cpp:501
void UpdateDisplay()
Exit with fatal error.
Definition: mainloop.cpp:168
unsigned long GameCycle
Definition: game.cpp:93
void ExitFatal(int err)
Exit.
Definition: stratagus.cpp:436
(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.