____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <sstream>
#include <algorithm>
#include <unistd.h>
#include "SDL.h"
#include "stratagus.h"
#include "unit_manager.h"
#include "video.h"
#include "font.h"
#include "cursor.h"
#include "ui.h"
#include "interface.h"
#include "menus.h"
#include "sound_server.h"
#include "sound.h"
#include "settings.h"
#include "script.h"
#include "network.h"
#include "netconnect.h"
#include "ai.h"
#include "missile.h"
#include "replay.h"
#include "results.h"
#include "editor.h"
#include "movie.h"
#include "pathfinder.h"
#include "widgets.h"
#include "trigger.h"
#include "iolib.h"
#include "iocompat.h"
#include "guichan.h"
#include "version.h"
#include "title.h"
#include "map.h"
Go to the source code of this file.
Functions | |
| void | CreateUserDirectories (void) |
| void | ShowLoadProgress (const char *fmt,...) |
| void | PreMenuSetup (void) |
| static int | MenuLoop () |
| void | CleanGame (void) |
| static void | ExpandPath (std::string &newpath, const std::string &path) |
| void | StartMap (const std::string &filename, bool clean) |
| void | StartSavedGame (const std::string &filename) |
| void | StartReplay (const std::string &filename, bool reveal) |
| int | SaveReplay (const std::string &filename) |
| static void | PrintHeader (void) |
| static int | main1 (int argc, char **argv) |
| void | Exit (int err) |
| Exit. | |
| void | ExitFatal (int err) |
| Exit with fatal error. | |
| static void | Usage (void) |
| int | main (int argc, char **argv) |
Variables | |
| std::string | StratagusLibPath |
| Path for data directory. | |
| std::string | LocalPlayerName |
| Name of local player. | |
| static std::string | NameLine |
| std::string | CliMapName |
| Filename of the map given on the command line. | |
| std::string | CompileOptions |
| Compile options. | |
| static std::vector < gcn::Container * > | Containers |
| int | SpeedBuild = 1 |
| speed factor for building | |
| int | SpeedTrain = 1 |
| speed factor for training | |
| unsigned long | GameCycle |
| Game simulation cycle counter. | |
| unsigned long | FastForwardCycle |
| Cycle to fastforward to in a replay. | |
| gcn::Gui * | Gui |
| A Gui object - binds it all together. | |
Definition in file stratagus.cpp.
| void CleanGame | ( | void | ) |
Cleanup game.
Call each module to clean up. Contrary to CleanModules, maps can be restarted without reloading all lua files.
Definition at line 343 of file stratagus.cpp.
References CMap::Clean(), CleanAi(), CleanGroups(), CleanMessages(), CleanMissiles(), CleanReplayLog(), CleanSelections(), CleanTriggers(), CleanUnits(), CursorBuilding, EndReplayLog(), FreePathfinder(), FreeVisionTable(), Map, and UnitUnderCursor.
Referenced by StartEditor(), and StartMap().
| void CreateUserDirectories | ( | void | ) |
Create directories containing user settings and data.
More specifically: logs, saved games, preferences
Definition at line 1013 of file script.cpp.
References STRATAGUS_HOME_PATH, and UserDirectory.
Referenced by main().
| void Exit | ( | int | err | ) |
Exit.
Exit the game.
| err | Error code to pass to shell. |
Definition at line 566 of file stratagus.cpp.
References _, _C_, CleanModules(), Containers, DebugPrint, ExitNetwork1(), FrameCounter, freeGuichan(), Lua, NetworkQuit(), QuitSound(), SlowFrameCounter, and StopMusic().
Referenced by AiInit(), ApplyReplaySettings(), EditorCallbackKeyDown(), main(), PatchEditorCallbackKeyDown(), SdlDoEvent(), ToggleFullScreen(), and tolua_stratagus_Exit00().
| void ExitFatal | ( | int | err | ) |
Exit with fatal error.
Do a fatal exit. Called on out of memory or crash.
| err | Error code to pass to shell. |
Definition at line 601 of file stratagus.cpp.
Referenced by CPlayerColorGraphic::ForceNew(), CGraphic::ForceNew(), IconConfig::Load(), CGraphic::Load(), LoadCcl(), LoadMap(), LoadStratagusMap(), LuaLoadBuffer(), main(), CPlayerColorGraphic::New(), CGraphic::New(), NewUnitTypeSlot(), FileWriter::printf(), and SaveStratagusMap().
| static void ExpandPath | ( | std::string & | newpath, | |
| const std::string & | path | |||
| ) | [static] |
Definition at line 362 of file stratagus.cpp.
References StratagusLibPath, and UserDirectory.
Referenced by StartReplay(), and StartSavedGame().
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
The main program: initialise, parse options and arguments.
| argc | Number of arguments. | |
| argv | Vector of arguments. |
Definition at line 681 of file stratagus.cpp.
References AiSleepCycles, Assert, CclStartFile, CliMapName, CommandLogDisabled, CompileOptions, CreateUserDirectories(), CVideo::Depth, EditorStartFile, Exit(), ExitFatal(), CVideo::FullScreen, CVideo::Height, InitAiModule(), InitCcl(), InitSyncRand(), LoadCcl(), LocalPlayerName, main1(), NetworkArg, NetworkLag, NetworkPort, NetworkUpdates, STRATAGUS_LIB_PATH, StratagusLibPath, Usage(), Video, VideoForceFullScreen, VideoSyncSpeed, and CVideo::Width.
| static int main1 | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Main1, called from main.
| argc | Number of arguments. | |
| argv | Vector of arguments. |
Definition at line 512 of file stratagus.cpp.
References CVideo::ClearScreen(), FontWhite, FontYellow, CVideo::Height, CUnitManager::Init(), InitMusic(), InitSound(), LoadFonts(), MenuLoop(), NumPlayers, PreMenuSetup(), PrintHeader(), SetClipping(), SetDefaultTextColors(), ShowTitleScreens(), ThisPlayer, UnitManager, Video, and CVideo::Width.
Referenced by main().
| static int MenuLoop | ( | ) | [static] |
Run the guichan main menus loop.
Definition at line 312 of file stratagus.cpp.
References ButtonUnderCursor, CVideo::ClearScreen(), CursorConfig::Cursor, CursorState, CursorStatePoint, GameCursor, IfaceStateMenu, initGuichan(), InterfaceState, Invalidate(), LibraryFileName(), LuaLoadFile(), CUserInterface::Point, UI, and Video.
Referenced by main1().
| void PreMenuSetup | ( | void | ) |
Pre menu setup.
Definition at line 289 of file stratagus.cpp.
References FontWhite, FontYellow, InitSettings(), InitUserInterface(), InitVideoCursors(), CUserInterface::Load(), LoadCursors(), LoadFonts(), SetDefaultTextColors(), and UI.
Referenced by EditorMainLoop(), and main1().
| static void PrintHeader | ( | void | ) | [static] |
Print headerline, copyright, ...
Definition at line 498 of file stratagus.cpp.
References CompileOptions, and NameLine.
| int SaveReplay | ( | const std::string & | filename | ) |
Save the replay
| filename | Name of the file to save to |
Definition at line 444 of file stratagus.cpp.
References CPlayer::Index, ThisPlayer, and UserDirectory.
Referenced by tolua_stratagus_SaveReplay00().
| void ShowLoadProgress | ( | const char * | fmt, | |
| ... | ||||
| ) |
Show load progress.
| fmt | printf format string. |
Definition at line 258 of file stratagus.cpp.
References _C_, ColorBlack, DebugPrint, CVideo::Depth, CVideo::FillRectangle(), GameFont, CVideo::Height, InvalidateArea(), CFont::IsLoaded(), RealizeVideoMemory(), Video, VideoDrawTextCentered(), and CVideo::Width.
Referenced by CEditor::Init(), LoadCcl(), LoadConstructions(), LoadCursors(), LoadDecorations(), LoadFonts(), LoadIcons(), and LoadUnitTypes().
| void StartMap | ( | const std::string & | filename, | |
| bool | clean | |||
| ) |
Definition at line 373 of file stratagus.cpp.
References _C_, CleanGame(), CleanPlayers(), CVideo::ClearScreen(), Containers, CreateGame(), DebugPrint, GameMainLoop(), GetDefaultTextColors(), gcn::Gui::getTop(), CVideo::Height, IfaceStateMenu, IfaceStateNormal, InterfaceState, Invalidate(), Map, NetConnectRunning, SetDefaultTextColors(), gcn::Widget::setDimension(), gcn::Container::setOpaque(), gcn::Gui::setTop(), Video, and CVideo::Width.
Referenced by StartReplay(), StartSavedGame(), and tolua_stratagus_StartMap00().
| void StartReplay | ( | const std::string & | filename, | |
| bool | reveal | |||
| ) |
Definition at line 424 of file stratagus.cpp.
References CleanPlayers(), CurrentMapPath, ExpandPath(), LoadReplay(), ReplayRevealMap, and StartMap().
| void StartSavedGame | ( | const std::string & | filename | ) |
Definition at line 412 of file stratagus.cpp.
References CleanPlayers(), ExpandPath(), LoadGame(), SaveGameLoading, and StartMap().
Referenced by tolua_stratagus_StartSavedGame00().
| static void Usage | ( | void | ) | [static] |
Display the usage.
Definition at line 609 of file stratagus.cpp.
References PrintHeader().
Referenced by main().
| std::string CliMapName |
Filename of the map given on the command line.
Definition at line 230 of file stratagus.cpp.
Referenced by main(), tolua_get_CliMapName(), and tolua_set_CliMapName().
| std::string CompileOptions |
Compile options.
Definition at line 231 of file stratagus.cpp.
Referenced by CclGetCompileFeature(), main(), and PrintHeader().
std::vector<gcn::Container *> Containers [static] |
| unsigned long FastForwardCycle |
Cycle to fastforward to in a replay.
Game Replay Fast Forward Counter.
Definition at line 247 of file stratagus.cpp.
Referenced by CreateGame(), GameMainLoop(), InitModules(), InputKey(), SetGameSpeed(), UiDecreaseGameSpeed(), and UiIncreaseGameSpeed().
| unsigned long GameCycle |
Game simulation cycle counter.
Definition at line 246 of file stratagus.cpp.
Referenced by ActionSetTimer(), AiCheckingWork(), AiCheckRepair(), AiEachSecond(), AiMoveUnitInTheWay(), AiResourceManager(), AiSendExplorers(), CUnitManager::AllocUnit(), Summon::Cast(), CclAiSleep(), CommandLog(), CreateGame(), DoNextReplay(), DoRightButton(), CUnit::Draw(), CViewport::Draw(), DrawInfoPanelNoneSelected(), DrawUnitOn(), GameMainLoop(), HandleActionTrain(), HandleBuffs(), HitUnit(), InitModules(), LoadGame(), NetworkCommands(), NetworkEvent(), NetworkExecCommands(), NetworkQuit(), NetworkRecover(), NetworkResendCommands(), NetworkSendCommand(), NetworkSendCommands(), NetworkSendExtendedCommand(), NetworkSyncCommands(), ParseNetworkCommand(), CUnitManager::ReleaseUnit(), ReplayEachCycle(), SaveGame(), SendCommand(), SetGameSpeed(), tolua_get_unsigned_GameCycle(), tolua_set_unsigned_GameCycle(), UiDecreaseGameSpeed(), UiIncreaseGameSpeed(), UnitActions(), and UpdateTimer().
| std::string LocalPlayerName |
Name of local player.
Name, Version, Copyright
Definition at line 224 of file stratagus.cpp.
Referenced by CclGetLocalPlayerName(), CclSetLocalPlayerName(), ClientParseAsync(), ClientParseConnecting(), ClientParseSynced(), CreateGame(), main(), NetworkConnectSetupGame(), NetworkInitServerConnect(), NetworkProcessClientRequest(), and ServerParseHello().
std::string NameLine [static] |
Initial value:
"Bos Wars V" VERSION ", (c) 1998-2008 by the Bos Wars and Stratagus Project."
Definition at line 227 of file stratagus.cpp.
Referenced by PrintHeader().
| int SpeedBuild = 1 |
speed factor for building
Speed factor for building.
Definition at line 239 of file stratagus.cpp.
Referenced by CclGetSpeedBuild(), CclSetSpeedBuild(), CclSetSpeeds(), DoRepair(), HandleActionBuilt(), and SaveCcl().
| int SpeedTrain = 1 |
speed factor for training
Speed factor for training.
Definition at line 240 of file stratagus.cpp.
Referenced by CclGetSpeedTrain(), CclSetSpeeds(), CclSetSpeedTrain(), HandleActionTrain(), and SaveCcl().
| std::string StratagusLibPath |
Path for data directory.
Location of stratagus data.
Definition at line 223 of file stratagus.cpp.
Referenced by CclFilteredListDirectory(), CclSavedGameInfo(), CclStratagusLibraryPath(), ClientParseConnected(), EditorSaveMap(), ExpandPath(), LibraryFileName(), LoadStratagusMap(), and main().
1.5.6