_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

game.cpp File Reference
#include "SDL_image.h"
#include "stratagus.h"
#include "game.h"
#include "actions.h"
#include "ai.h"
#include "animation.h"
#include "commands.h"
#include "construct.h"
#include "depend.h"
#include "editor.h"
#include "font.h"
#include "interface.h"
#include "iocompat.h"
#include "iolib.h"
#include "map.h"
#include "minimap.h"
#include "missile.h"
#include "netconnect.h"
#include "network.h"
#include "online_service.h"
#include "parameters.h"
#include "pathfinder.h"
#include "player.h"
#include "replay.h"
#include "results.h"
#include "settings.h"
#include "sound.h"
#include "sound_server.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "trigger.h"
#include "ui.h"
#include "unit.h"
#include "unit_manager.h"
#include "unittype.h"
#include "upgrade.h"
#include "version.h"
#include "video.h"

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

Settings GameSettings
 
static int LcmPreventRecurse
 Game Settings. More...
 
GameResults GameResult
 prevent recursion through LoadGameMap More...
 
std::string GameName
 Outcome of the game. More...
 
std::string FullGameName
 Name of the game. More...
 
unsigned long GameCycle
 
unsigned long FastForwardCycle
 Game simulation cycle counter. More...
 
bool UseHPForXp = false
 Cycle to fastforward to in a replay. More...
 
gcn::GuiGui
 true if gain XP by dealing damage, false if by killing. More...
 
static std::vector< gcn::Container * > Containers
 
std::string PlayerTypeNames [static_cast< int >(PlayerTypes::PlayerRescueActive)+1]
 
void CleanGame ()
 
void SaveGameSettings (CFile &file)
 
void CreateGame (const std::string &filename, CMap *map)
 forward declaration More...
 
void StartMap (const std::string &filename, bool clean)
 
void FreeAllContainers ()
 Cleanup all modules. More...
 
static void LoadStratagusMap (const std::string &smpname, const std::string &mapname)
 
static void WriteMapPreview (const char *mapname, CMap &map)
 
static int WriteMapPresentation (const std::string &mapname, CMap &map, Vec2i newSize)
 
int WriteMapSetup (const char *mapSetup, CMap &map, int writeTerrain, Vec2i newSize, Vec2i offset)
 
int SaveStratagusMap (const std::string &mapName, CMap &map, int writeTerrain, Vec2i newSize, Vec2i offset)
 Save a stratagus map (smp format) More...
 
static void LoadMap (const std::string &filename, CMap &map)
 
void SetGamePaused (bool paused)
 Set the game paused or unpaused. More...
 
bool GetGamePaused ()
 Get the game paused or unpaused. More...
 
void SetGameSpeed (int speed)
 Set the game speed. More...
 
int GetGameSpeed ()
 Get the game speed. More...
 
static void GameTypeFreeForAll ()
 
static void GameTypeTopVsBottom ()
 
static void GameTypeLeftVsRight ()
 
static void GameTypeManVsMachine ()
 
static void GameTypeManTeamVsMachine ()
 
static void GameTypeMachineVsMachine ()
 
static void GameTypeMachineVsMachineTraining ()
 
void InitSettings ()
 Game settings. More...
 
static void CleanGame_Lua ()
 
static int CclSetGameName (lua_State *l)
 
static int CclSetFullGameName (lua_State *l)
 
static int CclSetGodMode (lua_State *l)
 
static int CclGetGodMode (lua_State *l)
 
static int CclSetSpeedResourcesHarvest (lua_State *l)
 
static int CclSetSpeedResourcesReturn (lua_State *l)
 
static int CclSetSpeedBuild (lua_State *l)
 
static int CclGetSpeedBuild (lua_State *l)
 
static int CclSetSpeedTrain (lua_State *l)
 
static int CclGetSpeedTrain (lua_State *l)
 
static int CclSetSpeedUpgrade (lua_State *l)
 
static int CclSetSpeedResearch (lua_State *l)
 
static int CclSetSpeeds (lua_State *l)
 
static int CclDefineDefaultIncomes (lua_State *l)
 
static int CclDefineDefaultActions (lua_State *l)
 
static int CclDefineDefaultResourceNames (lua_State *l)
 
static int CclDefineDefaultResourceAmounts (lua_State *l)
 
static int CclDefineDefaultResourceMaxAmounts (lua_State *l)
 
static int ScriptSetUseHPForXp (lua_State *l)
 
static int CclSetLocalPlayerName (lua_State *l)
 
static int CclGetLocalPlayerName (lua_State *l)
 
static int CclGetStratagusVersion (lua_State *l)
 
static int CclGetStratagusHomepage (lua_State *l)
 
static int CclSetMenuRace (lua_State *l)
 
static int CclSavedGameInfo (lua_State *l)
 
void LuaRegisterModules ()
 Initialize all modules. More...
 

Function Documentation

◆ CclDefineDefaultActions()

static int CclDefineDefaultActions ( lua_State *  l)
static

Define default action for the resources.

Parameters
lLua state.

◆ CclDefineDefaultIncomes()

static int CclDefineDefaultIncomes ( lua_State *  l)
static

Define default incomes for a new player.

Parameters
lLua state.

◆ CclDefineDefaultResourceAmounts()

static int CclDefineDefaultResourceAmounts ( lua_State *  l)
static

Define default names for the resources.

Parameters
lLua state.

◆ CclDefineDefaultResourceMaxAmounts()

static int CclDefineDefaultResourceMaxAmounts ( lua_State *  l)
static

Define max amounts for the resources.

Parameters
lLua state.

◆ CclDefineDefaultResourceNames()

static int CclDefineDefaultResourceNames ( lua_State *  l)
static

Define default names for the resources.

Parameters
lLua state.

◆ CclGetGodMode()

static int CclGetGodMode ( lua_State *  l)
static

Description

Get God mode.

Parameters
lLua state.
Returns
God mode.

Example:

g_mode = GetGodMode() print(g_mode)

◆ CclGetLocalPlayerName()

static int CclGetLocalPlayerName ( lua_State *  l)
static

Description

Get the local player name

Parameters
lLua state.

Example:

GetLocalPlayerName()

◆ CclGetSpeedBuild()

static int CclGetSpeedBuild ( lua_State *  l)
static

Get building speed (deprecated).

Parameters
lLua state.
Returns
Building speed.

◆ CclGetSpeedTrain()

static int CclGetSpeedTrain ( lua_State *  l)
static

Get training speed (deprecated).

Parameters
lLua state.
Returns
Training speed.

◆ CclGetStratagusHomepage()

static int CclGetStratagusHomepage ( lua_State *  l)
static

Description

Get Stratagus Homepage

Example:

url = GetStratagusHomepage() print(url)

◆ CclGetStratagusVersion()

static int CclGetStratagusVersion ( lua_State *  l)
static

Description

Get Stratagus Version

Example:

version = GetStratagusVersion() print(version)

◆ CclSavedGameInfo()

static int CclSavedGameInfo ( lua_State *  l)
static

Load the SavedGameInfo Header

Parameters
lLua state.

◆ CclSetFullGameName()

static int CclSetFullGameName ( lua_State *  l)
static

◆ CclSetGameName()

static int CclSetGameName ( lua_State *  l)
static

Description

Return of game name.

Parameters
lLua state.

Example:

SetGameName("Wargus Map - Chapter 1")

◆ CclSetGodMode()

static int CclSetGodMode ( lua_State *  l)
static

Description

Set God mode.

Parameters
lLua state.
Returns
The old mode.

Example:

– God Mode enabled SetGodMode(true) – God Mode disabled SetGodMode(false)

◆ CclSetLocalPlayerName()

static int CclSetLocalPlayerName ( lua_State *  l)
static

Description

Set the local player name

Parameters
lLua state.

Example:

SetLocalPlayerName("Stormreaver Clan")

◆ CclSetMenuRace()

static int CclSetMenuRace ( lua_State *  l)
static

◆ CclSetSpeedBuild()

static int CclSetSpeedBuild ( lua_State *  l)
static

Set building speed (deprecated).

Parameters
lLua state.

◆ CclSetSpeedResearch()

static int CclSetSpeedResearch ( lua_State *  l)
static

For debug increase researching speed (deprecated).

Parameters
lLua state.

◆ CclSetSpeedResourcesHarvest()

static int CclSetSpeedResourcesHarvest ( lua_State *  l)
static

Set resource harvesting speed (deprecated).

Parameters
lLua state.

◆ CclSetSpeedResourcesReturn()

static int CclSetSpeedResourcesReturn ( lua_State *  l)
static

Set resource returning speed (deprecated).

Parameters
lLua state.

◆ CclSetSpeeds()

static int CclSetSpeeds ( lua_State *  l)
static

For debug increase all speeds (deprecated).

Parameters
lLua state.

◆ CclSetSpeedTrain()

static int CclSetSpeedTrain ( lua_State *  l)
static

Set training speed (deprecated).

Parameters
lLua state.

◆ CclSetSpeedUpgrade()

static int CclSetSpeedUpgrade ( lua_State *  l)
static

For debug increase upgrading speed (deprecated).

Parameters
lLua state.

◆ CleanGame()

void CleanGame ( )

Cleanup game.

Call each module to clean up. Contrary to CleanModules, maps can be restarted without reloading all lua files.

◆ CleanGame_Lua()

static void CleanGame_Lua ( )
static

◆ CreateGame()

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

forward declaration

CreateGame.

Load map, graphics, sounds, etc

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

◆ FreeAllContainers()

void FreeAllContainers ( )

Cleanup all modules.

◆ GameTypeFreeForAll()

static void GameTypeFreeForAll ( )
static

Free for all

◆ GameTypeLeftVsRight()

static void GameTypeLeftVsRight ( )
static

Left vs Right

◆ GameTypeMachineVsMachine()

static void GameTypeMachineVsMachine ( )
static

Machine vs Machine

◆ GameTypeMachineVsMachineTraining()

static void GameTypeMachineVsMachineTraining ( )
static

Machine vs Machine Training

◆ GameTypeManTeamVsMachine()

static void GameTypeManTeamVsMachine ( )
static

Man vs Machine with Humans on a Team

◆ GameTypeManVsMachine()

static void GameTypeManVsMachine ( )
static

Man vs Machine

◆ GameTypeTopVsBottom()

static void GameTypeTopVsBottom ( )
static

Top vs Bottom

◆ GetGamePaused()

bool GetGamePaused ( )

Get the game paused or unpaused.

Get the game paused or unpaused

Returns
True if the game is paused, false otherwise

◆ GetGameSpeed()

int GetGameSpeed ( )

Get the game speed.

Get the game speed

Returns
Game speed

◆ InitSettings()

void InitSettings ( )

Game settings.

Init Game Setting to default values

Todo:
FIXME: this should not be executed for restart levels!

◆ LoadMap()

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

Load any map.

Parameters
filenamemap filename
mapmap loaded

◆ LoadStratagusMap()

static void LoadStratagusMap ( const std::string &  smpname,
const std::string &  mapname 
)
static

Load a Stratagus map.

Parameters
smpnamesmp filename
mapnamemap filename
mapmap loaded

◆ LuaRegisterModules()

void LuaRegisterModules ( )

Initialize all modules.

◆ SaveGameSettings()

void SaveGameSettings ( CFile file)

Save game settings.

Parameters
fileSave file handle

◆ SaveStratagusMap()

int SaveStratagusMap ( const std::string &  mapName,
CMap map,
int  writeTerrain,
Vec2i  newSize,
Vec2i  offset 
)

Save a stratagus map (smp format)

Save a Stratagus map.

Parameters
mapNamemap filename
mapmap to save
writeTerrainwrite the tiles map in the .sms

◆ ScriptSetUseHPForXp()

static int ScriptSetUseHPForXp ( lua_State *  l)
static

Affect UseHPForXp.

Parameters
lLua state.
Returns
0.

◆ SetGamePaused()

void SetGamePaused ( bool  paused)

Set the game paused or unpaused.

Set the game paused or unpaused

Parameters
pausedTrue to pause game, false to unpause.

◆ SetGameSpeed()

void SetGameSpeed ( int  speed)

Set the game speed.

Set the game speed

Parameters
speedNew game speed.

◆ StartMap()

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

◆ WriteMapPresentation()

static int WriteMapPresentation ( const std::string &  mapname,
CMap map,
Vec2i  newSize 
)
static

◆ WriteMapPreview()

static void WriteMapPreview ( const char *  mapname,
CMap map 
)
static

◆ WriteMapSetup()

int WriteMapSetup ( const char *  mapSetup,
CMap map,
int  writeTerrain,
Vec2i  newSize,
Vec2i  offset 
)

Write the map setup file.

Parameters
mapsetupmap filename
mapmap to save
writeTerrainwrite the tiles map in the .sms

Variable Documentation

◆ Containers

std::vector<gcn::Container *> Containers
static

◆ FastForwardCycle

unsigned long FastForwardCycle

Game simulation cycle counter.

◆ FullGameName

std::string FullGameName

Name of the game.

◆ GameCycle

unsigned long GameCycle

◆ GameName

std::string GameName

Outcome of the game.

Save game settings.

◆ GameResult

GameResults GameResult

prevent recursion through LoadGameMap

Game results.

◆ GameSettings

Settings GameSettings

◆ Gui

gcn::Gui* Gui

true if gain XP by dealing damage, false if by killing.

◆ LcmPreventRecurse

int LcmPreventRecurse
static

◆ PlayerTypeNames

std::string PlayerTypeNames[static_cast< int >(PlayerTypes::PlayerRescueActive)+1]
Initial value:
= {
"",
"",
"neutral",
"nobody",
"computer",
"person",
"rescue-passive",
"rescue-active"
}

◆ UseHPForXp

bool UseHPForXp = false

Cycle to fastforward to in a replay.

Full Name of the game.

(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.