____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 2001-2008 by Lutz Sammer, Andreas Arens 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 // 00028 00030 00031 /*---------------------------------------------------------------------------- 00032 -- Includes 00033 ----------------------------------------------------------------------------*/ 00034 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 00038 #include "stratagus.h" 00039 #include "icons.h" 00040 #include "cursor.h" 00041 #include "construct.h" 00042 #include "unittype.h" 00043 #include "upgrade.h" 00044 #include "interface.h" 00045 #include "missile.h" 00046 #include "map.h" 00047 #include "script.h" 00048 #include "ui.h" 00049 #include "ai.h" 00050 #include "results.h" 00051 #include "trigger.h" 00052 #include "actions.h" 00053 #include "minimap.h" 00054 #include "replay.h" 00055 #include "sound.h" 00056 #include "sound_server.h" 00057 #include "font.h" 00058 #include "pathfinder.h" 00059 #include "spells.h" 00060 #include "particle.h" 00061 00062 /*---------------------------------------------------------------------------- 00063 -- Variables 00064 ----------------------------------------------------------------------------*/ 00065 00066 /*---------------------------------------------------------------------------- 00067 -- Functions 00068 ----------------------------------------------------------------------------*/ 00069 00070 void InitDefinedVariables(); 00071 00077 void CleanModules(void) 00078 { 00079 EndReplayLog(); 00080 CleanMessages(); 00081 00082 CleanIcons(); 00083 CleanCursors(); 00084 CleanUserInterface(); 00085 CleanFonts(); 00086 CleanTriggers(); 00087 FreeAi(); 00088 CleanPlayers(); 00089 CleanConstructions(); 00090 CleanDecorations(); 00091 CleanUnitTypes(); 00092 CleanUnits(); 00093 CleanSelections(); 00094 CleanGroups(); 00095 CleanButtons(); 00096 CleanMissileTypes(); 00097 CleanMissiles(); 00098 Map.Clean(); 00099 Map.CleanFogOfWar(); 00100 CParticleManager::exit(); 00101 CleanReplayLog(); 00102 CleanSpells(); 00103 FreeVisionTable(); 00104 FreePathfinder(); 00105 } 00106 00112 void InitModules(void) 00113 { 00114 GameCycle = 0; 00115 FastForwardCycle = 0; 00116 SyncHash = 0; 00117 00118 CallbackMusicOn(); 00119 InitSyncRand(); 00120 InitIcons(); 00121 InitVideoCursors(); 00122 InitUserInterface(); 00123 InitPlayers(); 00124 InitMissileTypes(); 00125 InitMissiles(); 00126 InitConstructions(); 00127 00128 // LUDO : 0 = don't reset player stats ( units level , upgrades, ... ) ! 00129 InitUnitTypes(0); 00130 00131 InitUnits(); 00132 InitSelections(); 00133 InitGroups(); 00134 InitSpells(); 00135 00136 InitButtons(); 00137 InitTriggers(); 00138 00139 InitAiModule(); 00140 00141 Map.Init(); 00142 } 00143 00149 void LoadModules(void) 00150 { 00151 LoadFonts(); 00152 LoadIcons(); 00153 LoadCursors(); 00154 UI.Load(); 00155 LoadMissileSprites(); 00156 LoadConstructions(); 00157 LoadDecorations(); 00158 LoadUnitTypes(); 00159 00160 InitPathfinder(); 00161 00162 LoadUnitSounds(); 00163 MapUnitSounds(); 00164 if (SoundEnabled()) { 00165 InitSoundClient(); 00166 } 00167 00168 SetPlayersPalette(); 00169 UI.Minimap.Create(); 00170 00171 SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor); 00172 } 00173 00179 void LoadGame(const std::string &filename) 00180 { 00181 unsigned long game_cycle; 00182 unsigned syncrand; 00183 unsigned synchash; 00184 int i; 00185 00186 // log will be enabled if found in the save game 00187 CommandLogDisabled = true; 00188 SaveGameLoading = true; 00189 00190 SetDefaultTextColors(FontYellow, FontWhite); 00191 LoadFonts(); 00192 00193 CclGarbageCollect(0); 00194 InitVisionTable(); 00195 InitUnitTypes(1); 00196 LuaLoadFile(filename); 00197 CclGarbageCollect(0); 00198 00199 for (i = 0; i < NumPlayers; ++i) { 00200 Players[i].RebuildUnitsConsumingResourcesList(); 00201 } 00202 00203 // Place units 00204 for (i = 0; i < NumUnits; ++i) { 00205 CUnit *unit = Units[i]; 00206 if (!unit->Removed) { 00207 unit->Removed = 1; 00208 unit->Place(unit->X, unit->Y); 00209 } 00210 } 00211 00212 game_cycle = GameCycle; 00213 syncrand = SyncRandSeed; 00214 synchash = SyncHash; 00215 00216 InitModules(); 00217 LoadModules(); 00218 00219 GameCycle = game_cycle; 00220 SyncRandSeed = syncrand; 00221 SyncHash = synchash; 00222 SelectionChanged(); 00223 } 00224
1.5.6