$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1998-2007 by Lutz Sammer and Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __STRATAGUS_H__ 00031 #define __STRATAGUS_H__ 00032 00034 00035 /*============================================================================ 00036 == Config definitions 00037 ============================================================================*/ 00038 00039 // Dynamic loading. 00040 //#define DYNAMIC_LOAD 00041 00042 /*============================================================================ 00043 == Compiler repairs 00044 ============================================================================*/ 00045 00046 #ifdef _MSC_VER 00047 00048 #define WIN32_LEAN_AND_MEAN 00049 #define NOUSER 00050 00051 #define NOMINMAX // do not use min, max as macro 00052 00053 #define inline __inline 00054 #define alloca _alloca 00055 00056 #pragma warning(disable:4244) 00057 #pragma warning(disable:4761) 00058 #pragma warning(disable:4786) 00059 #include <stdlib.h> 00060 #define abort() _ASSERT(0) 00061 #include <stdio.h> 00062 #define snprintf _snprintf 00063 #define vsnprintf _vsnprintf 00064 #define unlink _unlink 00065 #include <string.h> 00066 #define strdup _strdup 00067 #define strcasecmp _stricmp 00068 #define strncasecmp _strnicmp 00069 #include <io.h> 00070 #define access _access 00071 #define write _write 00072 #include <direct.h> 00073 #define makedir(dir, permissions) _mkdir(dir) 00074 00075 #ifndef __func__ 00076 #define __func__ __FUNCTION__ 00077 #endif 00078 00079 #endif // } _MSC_VER 00080 00081 #ifdef __GNUC__ 00082 #ifdef USE_WIN32 00083 #define makedir(dir, permissions) mkdir(dir) 00084 #else 00085 #define makedir(dir, permissions) mkdir(dir, permissions) 00086 #endif 00087 #endif 00088 00089 /*============================================================================ 00090 == Debug definitions 00091 ============================================================================*/ 00092 00098 #define _C_ , 00099 00101 #define PrintFunction() \ 00102 do { fprintf(stdout, "%s:%d: %s: ", __FILE__, __LINE__, __func__); } while (0) 00103 00104 00105 #ifdef DEBUG // { 00106 00110 #define Assert(cond) do { if (!(cond)) { \ 00111 fprintf(stderr, "Assertion failed at %s:%d: %s: %s\n", __FILE__, __LINE__, __func__, #cond); \ 00112 abort(); }} while (0) 00113 00117 #define DebugPrint(args) \ 00118 do { PrintFunction(); fprintf(stdout, args); } while (0) 00119 00120 #else // }{ DEBUG 00121 00122 #define Assert(cond) /* disabled */ 00123 #define DebugPrint(args) /* disabled */ 00124 00125 #endif 00126 00127 #ifdef REFS_DEBUG // { 00128 00132 #define RefsAssert(cond) do { if (!(cond)) { \ 00133 fprintf(stderr, "Assertion failed at %s:%d: %s\n", __FILE__, __LINE__, __func__); \ 00134 abort(); } } while (0) 00135 00136 #else // }{ REFS_DEBUG 00137 00138 #define RefsAssert(cond) /* disabled */ 00139 00140 #endif // } !REFS_DEBUG 00141 00142 /*============================================================================ 00143 == Definitions 00144 ============================================================================*/ 00145 00146 #include <string.h> 00147 00148 #ifndef __UTIL_H__ 00149 #include "util.h" 00150 #endif 00151 00152 inline char *new_strdup(const char *str) 00153 { 00154 int len = strlen(str) + 1; 00155 char *newstr = new char[len]; 00156 strcpy_s(newstr, len, str); 00157 return newstr; 00158 } 00159 00160 /*---------------------------------------------------------------------------- 00161 -- Translate 00162 ----------------------------------------------------------------------------*/ 00163 00164 #include "translate.h" 00165 00166 #define _(str) Translate(str) 00167 #define N_(str) str 00168 00169 /*---------------------------------------------------------------------------- 00170 -- General 00171 ----------------------------------------------------------------------------*/ 00172 00173 #include "version.h" 00174 00176 extern const char NameLine[]; 00177 00178 /*---------------------------------------------------------------------------- 00179 -- Some limits 00180 ----------------------------------------------------------------------------*/ 00181 00182 #define PlayerMax 16 00183 #define UnitTypeMax 2048 00184 #define UpgradeMax 2048 00185 #define UnitMax 65536 00186 00187 /*---------------------------------------------------------------------------- 00188 -- Screen 00189 ----------------------------------------------------------------------------*/ 00190 00192 #define SCROLL_UP 15 00194 #define SCROLL_DOWN (Video.Height - 16) 00196 #define SCROLL_LEFT 15 00198 #define SCROLL_RIGHT (Video.Width - 16) 00199 00201 #define FRAMES_PER_SECOND 30 // 1/30s 00203 #define CYCLES_PER_SECOND 30 // 1/30s 0.33ms 00204 00205 /*---------------------------------------------------------------------------- 00206 -- stratagus.c 00207 ----------------------------------------------------------------------------*/ 00208 00209 class Parameters 00210 { 00211 public: 00212 void SetDefaultValues(); 00213 00214 const std::string& GetUserDirectory() { return UserDirectory; } 00215 00216 private: 00217 void SetUserDirectory(); 00218 00219 public: 00220 std::string applicationName; 00221 std::string luaStartFilename; 00222 std::string luaEditorStartFilename; 00223 std::string LocalPlayerName; 00224 private: 00225 std::string UserDirectory; 00226 public: 00227 static Parameters Instance; 00228 }; 00229 00230 00231 00232 extern std::string StratagusLibPath; 00233 extern std::string GameName; 00234 extern std::string FullGameName; 00235 extern std::string ClickMissile; 00236 extern std::string DamageMissile; 00237 extern std::string MenuRace; 00238 00239 extern int SpeedBuild; 00240 extern int SpeedTrain; 00241 extern int SpeedUpgrade; 00242 extern int SpeedResearch; 00243 00244 extern bool UseHPForXp; 00245 00246 extern unsigned long GameCycle; 00247 extern unsigned long ResultGameCycle; 00248 extern unsigned long FastForwardCycle; 00249 00250 extern void LoadGame(const std::string &filename); 00251 extern int SaveGame(const std::string &filename); 00252 extern void DeleteSaveGame(const std::string &filename); 00253 extern bool SaveGameLoading; 00254 struct lua_State; 00255 extern std::string SaveGlobal(lua_State *l, bool is_root); 00256 00257 extern void Exit(int err); 00258 extern void ExitFatal(int err); 00259 00260 extern void UpdateDisplay(); 00261 extern void InitModules(); 00262 extern void LoadModules(); 00263 extern void CleanModules(); 00264 extern void DrawMapArea(); 00265 extern void GameMainLoop(); 00266 00268 extern void ShowLoadProgress(const char *fmt, ...); 00269 00270 struct DisplayAutoLocker { 00271 DisplayAutoLocker(); 00272 ~DisplayAutoLocker(); 00273 }; 00274 00275 extern const int CPU_NUM; 00276 extern bool CanAccessFile(const char *filename); 00277 00278 /*============================================================================ 00279 == Misc 00280 ============================================================================*/ 00281 00282 // @todo configurable. maybe we could move it into one big global 00283 // @todo settings struct? 00285 #define CancelBuildingCostsFactor 75 00287 #define CancelTrainingCostsFactor 100 00289 #define CancelResearchCostsFactor 100 00291 #define CancelUpgradeCostsFactor 100 00292 00294 00295 #endif // !__STRATAGUS_H__