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

       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"

game.cpp File Reference

The game set-up and creation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include "map.h"
#include "minimap.h"
#include "player.h"
#include "unit.h"
#include "unittype.h"
#include "upgrade.h"
#include "pathfinder.h"
#include "ui.h"
#include "font.h"
#include "sound.h"
#include "sound_server.h"
#include "interface.h"
#include "cursor.h"
#include "spells.h"
#include "construct.h"
#include "actions.h"
#include "network.h"
#include "netconnect.h"
#include "missile.h"
#include "settings.h"
#include "results.h"
#include "trigger.h"
#include "replay.h"
#include "iolib.h"
#include "iocompat.h"
#include "script.h"

Go to the source code of this file.

Functions

static void LoadStratagusMap (const std::string &smpname, const std::string &mapname, CMap *map)
static int WriteMapPresentation (const std::string &mapname, CMap *map)
int WriteMapSetup (const char *mapSetup, CMap *map)
int SaveStratagusMap (const std::string &mapName, CMap *map)
 < Save a stratagus map (smp format)
static void LoadMap (const std::string &filename, CMap *map)
void SetGamePaused (bool paused)
 < Set the game paused or unpaused
bool GetGamePaused ()
 Set the game speed.
void SetGameSpeed (int speed)
 Get the game speed.
int GetGameSpeed ()
static void GameTypeFreeForAll (void)
static void GameTypeTopVsBottom (void)
static void GameTypeLeftVsRight (void)
static void GameTypeManVsMachine (void)
static void GameTypeManTeamVsMachine (void)
void CreateGame (const std::string &filename, CMap *map)
 Init Setting to default values.
void InitSettings (void)

Variables

Settings GameSettings
 Game Settings.
static int LcmPreventRecurse
 prevent recursion through LoadGameMap
GameResults GameResult
 Outcome of the game.


Detailed Description

The game set-up and creation.

Definition in file game.cpp.


Function Documentation

void CreateGame ( const std::string &  filename,
CMap map 
)

Init Setting to default values.

CreateGame.

Load map, graphics, sounds, etc

Parameters:
filename map filename
map map loaded
Todo:
FIXME: use in this function InitModules / LoadModules!!!

Definition at line 518 of file game.cpp.

References CallbackMusicOn, CViewport::Center(), CVideo::ClearScreen(), CUnit::Colors, CommandLog(), CMinimap::Create(), CreatePlayer(), CurrentMapPath, DebugPlayers(), DebugPrint, FastForwardCycle, CMapInfo::Filename, FlagRevealMap, FlushCommands, GameCycle, GameNoResult, GamePaused, GameResult, Settings::GameType, GameTypeFreeForAll(), GameTypeLeftVsRight(), GameTypeManTeamVsMachine(), GameTypeManVsMachine(), GameTypeTopVsBottom(), CMap::Info, CMap::Init(), InitButtons(), InitConstructions(), InitGroups(), InitIcons(), InitMissileTypes(), InitNetwork2(), InitPathfinder(), InitPlayers(), InitSelections(), InitSoundClient(), InitSpells(), InitSyncRand(), InitTriggers(), InitUnitTypes(), InitUserInterface(), InitVisionTable(), IsNetworkGame, LibraryFileName(), CUserInterface::Load(), LoadConstructions(), LoadCursors(), LoadDecorations(), LoadIcons(), LoadMap(), LoadMissileSprites(), LoadUnitSounds(), LoadUnitTypes(), LocalPlayerName, LuaLoadFile(), Map, MapUnitSounds(), CUserInterface::Minimap, CUserInterface::NormalFontColor, NoUnitP, NumUnits, CUnit::Player, PlayerMax, PlayersInitAi(), CMapInfo::PlayerType, Settings::Presets, CUnit::RescuedFrom, CMap::Reveal(), CUserInterface::ReverseFontColor, SaveGameLoading, CUserInterface::SelectedViewport, SetDefaultTextColors(), CPlayer::SetName(), SetPlayersPalette(), SettingsGameTypeFreeForAll, SettingsGameTypeLeftVsRight, SettingsGameTypeManTeamVsMachine, SettingsGameTypeManVsMachine, SettingsGameTypeMapDefault, SettingsGameTypeMelee, SettingsGameTypeTopVsBottom, SettingsPresetMapDefault, SoundEnabled(), CPlayer::StartX, CPlayer::StartY, strcasestr(), strcpy_s(), SyncHash, ThisPlayer, TileSizeX, TileSizeY, SettingsPresets::Type, UI, CPlayer::UnitColors, Units, UnitUnderCursor, Video, and CUserInterface::Viewports.

Referenced by CEditor::Init(), and StartMap().

static void GameTypeFreeForAll ( void   )  [static]

Free for all

Definition at line 381 of file game.cpp.

References CommandDiplomacy(), DiplomacyEnemy, and PlayerMax.

Referenced by CreateGame().

static void GameTypeLeftVsRight ( void   )  [static]

static void GameTypeManTeamVsMachine ( void   )  [static]

Man vs Machine whith Humans on a Team

Definition at line 477 of file game.cpp.

References CommandDiplomacy(), DiplomacyAllied, DiplomacyEnemy, PlayerComputer, PlayerMax, PlayerPerson, Players, CPlayer::SharedVision, and CPlayer::Team.

Referenced by CreateGame().

static void GameTypeManVsMachine ( void   )  [static]

Man vs Machine

Definition at line 452 of file game.cpp.

References CommandDiplomacy(), DiplomacyAllied, DiplomacyEnemy, PlayerComputer, PlayerMax, PlayerPerson, Players, and CPlayer::SharedVision.

Referenced by CreateGame().

static void GameTypeTopVsBottom ( void   )  [static]

bool GetGamePaused (  ) 

Set the game speed.

Get the game paused or unpaused

Returns:
True if the game is paused, false otherwise

Definition at line 346 of file game.cpp.

References GamePaused.

Referenced by tolua_get_GamePaused(), and tolua_stratagus_GetGamePaused00().

int GetGameSpeed (  ) 

Get the game speed

Returns:
Game speed

Definition at line 369 of file game.cpp.

References CYCLES_PER_SECOND, and VideoSyncSpeed.

Referenced by tolua_get_GameSpeed(), and tolua_stratagus_GetGameSpeed00().

void InitSettings ( void   ) 

static void LoadMap ( const std::string &  filename,
CMap map 
) [static]

Load any map.

Parameters:
filename map filename
map map loaded

Definition at line 304 of file game.cpp.

References Assert, CMap::Create(), ExitFatal(), CMapInfo::Filename, CMap::Info, LoadStratagusMap(), and LoadStratagusMapInfo().

Referenced by CreateGame().

static void LoadStratagusMap ( const std::string &  smpname,
const std::string &  mapname,
CMap map 
) [static]

Load a Stratagus map.

Parameters:
smpname smp filename
mapname map filename
map map loaded

Definition at line 92 of file game.cpp.

References CL_OPEN_READ, CFile::close(), ExitFatal(), CMapInfo::Filename, CMap::Info, InitPlayers(), LcmPreventRecurse, LuaLoadFile(), Map, CMapInfo::MapHeight, CMapInfo::MapWidth, CFile::open(), StratagusLibPath, strcat_s(), strcpy_s(), and ThisPlayer.

Referenced by LoadMap().

int SaveStratagusMap ( const std::string &  mapName,
CMap map 
)

< Save a stratagus map (smp format)

Save a Stratagus map.

Parameters:
mapName map filename
map map to save

Definition at line 273 of file game.cpp.

References ExitFatal(), CMap::Info, CMapInfo::MapHeight, CMapInfo::MapWidth, WriteMapPresentation(), and WriteMapSetup().

Referenced by EditorSaveMap().

void SetGamePaused ( bool  paused  ) 

< Set the game paused or unpaused

Set the game paused or unpaused

Parameters:
paused True to pause game, false to unpause.

Definition at line 336 of file game.cpp.

References GamePaused.

Referenced by tolua_set_GamePaused(), and tolua_stratagus_SetGamePaused00().

void SetGameSpeed ( int  speed  ) 

Get the game speed.

Set the game speed

Parameters:
speed New game speed.

Definition at line 356 of file game.cpp.

References CYCLES_PER_SECOND, FastForwardCycle, GameCycle, SetVideoSync(), and VideoSyncSpeed.

Referenced by tolua_set_GameSpeed(), and tolua_stratagus_SetGameSpeed00().

static int WriteMapPresentation ( const std::string &  mapname,
CMap map 
) [static]

int WriteMapSetup ( const char *  mapSetup,
CMap map 
)

Write the map setup file.

Parameters:
mapSetup map filename
map map to save

Definition at line 218 of file game.cpp.

References CreateFileWriter(), Map, NumUnits, CMap::PatchManager, PlayerMax, Players, FileWriter::printf(), CPatchManager::savePatches(), and Units.

Referenced by SaveStratagusMap().


Variable Documentation

Outcome of the game.

Definition at line 75 of file game.cpp.

Referenced by CreateGame(), StopGame(), tolua_get_GameResult(), and tolua_set_GameResult().

int LcmPreventRecurse [static]

prevent recursion through LoadGameMap

Definition at line 74 of file game.cpp.

Referenced by LoadStratagusMap().


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