____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       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"

stratagus.cpp File Reference

The main file. More...

#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::GuiGui
 A Gui object - binds it all together.


Detailed Description

The main file.

Definition in file stratagus.cpp.


Function Documentation

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  ) 

void ExitFatal ( int  err  ) 

Exit with fatal error.

Do a fatal exit. Called on out of memory or crash.

Parameters:
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 
)

static int main1 ( int  argc,
char **  argv 
) [static]

Main1, called from main.

Parameters:
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.

Returns:
0 for success, else exit.

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   ) 

static void PrintHeader ( void   )  [static]

Print headerline, copyright, ...

Definition at line 498 of file stratagus.cpp.

References CompileOptions, and NameLine.

Referenced by main1(), and Usage().

int SaveReplay ( const std::string &  filename  ) 

Save the replay

Parameters:
filename Name of the file to save to
Returns:
0 for success, -1 for failure

Definition at line 444 of file stratagus.cpp.

References CPlayer::Index, ThisPlayer, and UserDirectory.

Referenced by tolua_stratagus_SaveReplay00().

void ShowLoadProgress ( const char *  fmt,
  ... 
)

void StartMap ( const std::string &  filename,
bool  clean 
)

void StartReplay ( const std::string &  filename,
bool  reveal 
)

void StartSavedGame ( const std::string &  filename  ) 

static void Usage ( void   )  [static]

Display the usage.

Definition at line 609 of file stratagus.cpp.

References PrintHeader().

Referenced by main().


Variable Documentation

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]

Definition at line 233 of file stratagus.cpp.

Referenced by Exit(), and StartMap().

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

A Gui object - binds it all together.

Definition at line 51 of file widgets.cpp.

std::string LocalPlayerName

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().


Generated on Sat Feb 21 00:28:19 2009 for Bos Wars by  doxygen 1.5.6