____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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 <time.h>
#include "stratagus.h"
#include "replay.h"
#include "version.h"
#include "iolib.h"
#include "iocompat.h"
#include "script.h"
#include "unittype.h"
#include "unit_manager.h"
#include "settings.h"
#include "commands.h"
#include "player.h"
#include "map.h"
#include "netconnect.h"
#include "network.h"
#include "interface.h"
#include "actions.h"
Go to the source code of this file.
Classes | |
| class | LogEntry |
| class | MPPlayer |
| class | FullReplay |
Functions | |
| static void | AppendLog (LogEntry *log, CFile *dest) |
| static FullReplay * | StartReplay (void) |
| static void | ApplyReplaySettings (void) |
| static void | DeleteReplay (FullReplay *replay) |
| static void | PrintLogCommand (LogEntry *log, CFile *dest) |
| static void | SaveFullLog (CFile *dest) |
| void | CommandLog (const char *action, const CUnit *unit, int flush, int x, int y, const CUnit *dest, const char *value, int num) |
| < Log commands into file | |
| static int | CclLog (lua_State *l) |
| static int | CclReplayLog (lua_State *l) |
| bool | IsReplayGame () |
| void | SaveReplayList (CFile *file) |
| Register ccl functions related to network. | |
| int | LoadReplay (const std::string &name) |
| End logging. | |
| void | EndReplayLog (void) |
| Clean replay. | |
| void | CleanReplayLog (void) |
| Save the replay list to file. | |
| static void | DoNextReplay (void) |
| static void | ReplayEachCycle (void) |
| void | SinglePlayerReplayEachCycle () |
| Replay user commands from log each cycle, multiplayer games. | |
| void | MultiPlayerReplayEachCycle () |
| Load replay. | |
| void | ReplayCclRegister (void) |
Variables | |
| bool | CommandLogDisabled |
| True if command log is off. | |
| ReplayType | ReplayGameType |
| Replay game type. | |
| static bool | DisabledLog |
| Disabled log for replay. | |
| static CFile * | LogFile |
| Replay log file. | |
| static unsigned long | NextLogCycle |
| Next log cycle number. | |
| static int | InitReplay |
| Initialize replay. | |
| static FullReplay * | CurrentReplay |
| static LogEntry * | ReplayStep |
Definition in file replay.cpp.
Append the LogEntry structure at the end of currentLog, and to LogFile
| log | Pointer the replay log entry to be added | |
| dest | The file to output to |
Definition at line 364 of file replay.cpp.
References FullReplay::Commands, CFile::flush(), LogEntry::Next, and PrintLogCommand().
Referenced by CommandLog().
| static void ApplyReplaySettings | ( | void | ) | [static] |
Applies settings the game used at the start of the replay
Definition at line 221 of file replay.cpp.
References CurrentMapPath, FullReplay::Difficulty, Settings::Difficulty, Exit(), ExitNetwork1(), FlagRevealMap, GameSettings, FullReplay::GameType, Settings::GameType, FullReplay::LocalPlayer, Map, FullReplay::MapPath, FullReplay::MapRichness, Settings::MapRichness, Settings::NetGameType, NetLocalPlayerNumber, NetPlayers, Settings::NoFogOfWar, CMap::NoFogOfWar, FullReplay::NoFow, FullReplay::NumUnits, Settings::NumUnits, FullReplay::Opponents, Settings::Opponents, PlayerMax, FullReplay::Players, Settings::Presets, ReplayGameType, ReplayMultiPlayer, ReplaySinglePlayer, FullReplay::Resource, Settings::Resources, FullReplay::RevealMap, Settings::RevealMap, SettingsMultiPlayerGame, SettingsSinglePlayerGame, strcpy_s(), MPPlayer::Team, SettingsPresets::Team, MPPlayer::Type, SettingsPresets::Type, and FullReplay::Type.
Referenced by CclReplayLog().
| static int CclLog | ( | lua_State * | l | ) | [static] |
Parse log
Definition at line 484 of file replay.cpp.
References _C_, LogEntry::Action, Assert, FullReplay::Commands, LogEntry::DestUnitNumber, LogEntry::Flush, LogEntry::GameCycle, LuaCheckArgs, LuaError, LuaToNumber(), LuaToString(), LogEntry::Next, LogEntry::Num, LogEntry::PosX, LogEntry::PosY, LogEntry::SyncRandSeed, LogEntry::UnitIdent, LogEntry::UnitNumber, and LogEntry::Value.
Referenced by ReplayCclRegister().
| static int CclReplayLog | ( | lua_State * | l | ) | [static] |
Parse replay-log
Definition at line 549 of file replay.cpp.
References _C_, ApplyReplaySettings(), Assert, CommandLogDisabled, FullReplay::Comment1, FullReplay::Comment2, FullReplay::Comment3, FullReplay::Date, FullReplay::Difficulty, FullReplay::Engine, FullReplay::GameType, FullReplay::LocalPlayer, LuaCheckArgs, LuaError, LuaToBoolean(), LuaToNumber(), LuaToString(), FullReplay::Map, FullReplay::MapId, FullReplay::MapPath, FullReplay::MapRichness, MPPlayer::Name, FullReplay::Network, FullReplay::NoFow, FullReplay::NumUnits, FullReplay::Opponents, PlayerMax, FullReplay::Players, FullReplay::Resource, FullReplay::RevealMap, SaveGameLoading, MPPlayer::Team, MPPlayer::Type, and FullReplay::Type.
Referenced by ReplayCclRegister().
| void CleanReplayLog | ( | void | ) |
Save the replay list to file.
Clean replay log
Definition at line 734 of file replay.cpp.
References CommandLogDisabled, DeleteReplay(), DisabledLog, GameObserve, NetPlayers, ReplayGameType, and ReplayNone.
Referenced by CleanGame(), CleanModules(), and LoadReplay().
| void CommandLog | ( | const char * | action, | |
| const CUnit * | unit, | |||
| int | flush, | |||
| int | x, | |||
| int | y, | |||
| const CUnit * | dest, | |||
| const char * | value, | |||
| int | num | |||
| ) |
< Log commands into file
Log commands into file.
This could later be used to recover, crashed games.
| action | Command name (move,attack,...). | |
| unit | Unit that receive the command. | |
| flush | Append command or flush old commands. | |
| x | optional X map position. | |
| y | optional y map position. | |
| dest | optional destination unit. | |
| value | optional command argument (unit-type,...). | |
| num | optional number argument |
Definition at line 400 of file replay.cpp.
References LogEntry::Action, AppendLog(), CL_OPEN_WRITE, CommandLogDisabled, LogEntry::DestUnitNumber, LogEntry::Flush, GameCycle, LogEntry::GameCycle, CUnitType::Ident, CPlayer::Index, LogEntry::Num, LogEntry::PosX, LogEntry::PosY, SaveFullLog(), sprintf_s(), StartReplay(), SyncRandSeed, LogEntry::SyncRandSeed, ThisPlayer, CUnit::Type, LogEntry::UnitIdent, UnitNumber, LogEntry::UnitNumber, UserDirectory, and LogEntry::Value.
Referenced by CreateGame(), InputKey(), ParseCommand(), ParseExtendedCommand(), ParseNetworkCommand(), SendCommandAttack(), SendCommandAttackGround(), SendCommandAutoRepair(), SendCommandAutoSpellCast(), SendCommandBoard(), SendCommandBuildBuilding(), SendCommandCancelTraining(), SendCommandDiplomacy(), SendCommandDismiss(), SendCommandFollow(), SendCommandMove(), SendCommandPatrol(), SendCommandRepair(), SendCommandResource(), SendCommandSharedVision(), SendCommandSpellCast(), SendCommandStandGround(), SendCommandStopUnit(), SendCommandTrainUnit(), and SendCommandUnload().
| static void DeleteReplay | ( | FullReplay * | replay | ) | [static] |
Free a replay from memory
| replay | Pointer to the replay to be freed |
Definition at line 264 of file replay.cpp.
References FullReplay::Commands, and LogEntry::Next.
Referenced by CleanReplayLog(), and EndReplayLog().
| static void DoNextReplay | ( | void | ) | [static] |
Do next replay
Definition at line 754 of file replay.cpp.
References _, _C_, LogEntry::Action, Assert, CclCommand(), CommandQuit(), DebugPrint, LogEntry::DestUnitNumber, DiplomacyAllied, DiplomacyCrazy, DiplomacyEnemy, DiplomacyNeutral, LogEntry::Flush, GameCycle, LogEntry::GameCycle, HandleCheats(), CUnitType::Ident, LogEntry::Next, NextLogCycle, CPlayer::Notify(), NotifyYellow, NoUnitP, LogEntry::Num, LogEntry::PosX, LogEntry::PosY, SendCommandAttack(), SendCommandAttackGround(), SendCommandAutoRepair(), SendCommandAutoSpellCast(), SendCommandBoard(), SendCommandBuildBuilding(), SendCommandCancelTraining(), SendCommandDiplomacy(), SendCommandDismiss(), SendCommandFollow(), SendCommandMove(), SendCommandPatrol(), SendCommandRepair(), SendCommandResource(), SendCommandSharedVision(), SendCommandSpellCast(), SendCommandStandGround(), SendCommandStopUnit(), SendCommandTrainUnit(), SendCommandUnload(), LogEntry::SyncRandSeed, SyncRandSeed, ThisPlayer, CUnit::Type, LogEntry::UnitIdent, LogEntry::UnitNumber, UnitSlots, UnitTypeByIdent(), and LogEntry::Value.
Referenced by ReplayEachCycle().
| void EndReplayLog | ( | void | ) |
Clean replay.
End logging
Definition at line 717 of file replay.cpp.
References CFile::close(), and DeleteReplay().
Referenced by CleanGame(), CleanModules(), and GameMainLoop().
| bool IsReplayGame | ( | ) |
Check if we're replaying a game
Definition at line 676 of file replay.cpp.
References ReplayGameType, and ReplayNone.
Referenced by tolua_stratagus_IsReplayGame00().
| int LoadReplay | ( | const std::string & | name | ) |
End logging.
Load a log file to replay a game
| name | name of file to load. |
Definition at line 696 of file replay.cpp.
References CleanReplayLog(), CommandLogDisabled, DisabledLog, GameObserve, InitReplay, LuaLoadFile(), NextLogCycle, ReplayGameType, and ReplaySinglePlayer.
Referenced by StartReplay().
| void MultiPlayerReplayEachCycle | ( | ) |
Load replay.
Replay user commands from log each cycle, multiplayer games
Definition at line 929 of file replay.cpp.
References ReplayEachCycle(), ReplayGameType, and ReplayMultiPlayer.
Referenced by GameMainLoop().
Definition at line 279 of file replay.cpp.
References LogEntry::Action, LogEntry::DestUnitNumber, LogEntry::Flush, LogEntry::GameCycle, LogEntry::Num, LogEntry::PosX, LogEntry::PosY, CFile::printf(), LogEntry::SyncRandSeed, LogEntry::UnitIdent, LogEntry::UnitNumber, and LogEntry::Value.
Referenced by AppendLog(), and SaveFullLog().
| void ReplayCclRegister | ( | void | ) |
Register Ccl functions with lua
Definition at line 939 of file replay.cpp.
References CclLog(), CclReplayLog(), and Lua.
Referenced by InitCcl().
| static void ReplayEachCycle | ( | void | ) | [static] |
Replay user commands from log each cycle
Definition at line 880 of file replay.cpp.
References _, FullReplay::Commands, DoNextReplay(), GameCycle, LogEntry::GameCycle, GameObserve, InitReplay, MPPlayer::Name, NextLogCycle, PlayerMax, Players, FullReplay::Players, SetMessage(), and CPlayer::SetName().
Referenced by MultiPlayerReplayEachCycle(), and SinglePlayerReplayEachCycle().
| static void SaveFullLog | ( | CFile * | dest | ) | [static] |
Output the FullReplay list to dest file
| dest | The file to output to |
Definition at line 311 of file replay.cpp.
References FullReplay::Commands, FullReplay::Comment1, FullReplay::Comment2, FullReplay::Comment3, FullReplay::Date, FullReplay::Difficulty, FullReplay::Engine, FullReplay::GameType, FullReplay::LocalPlayer, FullReplay::Map, FullReplay::MapId, FullReplay::MapPath, FullReplay::MapRichness, MPPlayer::Name, FullReplay::Network, LogEntry::Next, FullReplay::NoFow, FullReplay::NumUnits, FullReplay::Opponents, PlayerMax, FullReplay::Players, CFile::printf(), PrintLogCommand(), FullReplay::Resource, FullReplay::RevealMap, MPPlayer::Team, MPPlayer::Type, and FullReplay::Type.
Referenced by CommandLog(), and SaveReplayList().
| void SaveReplayList | ( | CFile * | file | ) |
Register ccl functions related to network.
Save generated replay
| file | file to save to. |
Definition at line 686 of file replay.cpp.
References SaveFullLog().
Referenced by SaveGame().
| void SinglePlayerReplayEachCycle | ( | ) |
Replay user commands from log each cycle, multiplayer games.
Replay user commands from log each cycle, single player games
Definition at line 919 of file replay.cpp.
References ReplayEachCycle(), ReplayGameType, and ReplaySinglePlayer.
Referenced by GameMainLoop().
| static FullReplay* StartReplay | ( | void | ) | [static] |
Allocate & fill a new FullReplay structure, from GameSettings.
Definition at line 162 of file replay.cpp.
References FullReplay::Comment1, FullReplay::Comment2, FullReplay::Comment3, CurrentMapPath, FullReplay::Date, CMapInfo::Description, Settings::Difficulty, FullReplay::Difficulty, FullReplay::Engine, GameSettings, Settings::GameType, FullReplay::GameType, CPlayer::Index, CMap::Info, int(), FullReplay::LocalPlayer, Map, FullReplay::Map, FullReplay::MapId, FullReplay::MapPath, Settings::MapRichness, FullReplay::MapRichness, CMapInfo::MapUID, CPlayer::Name, MPPlayer::Name, Settings::NetGameType, FullReplay::Network, NetworkProtocolMajorVersion, NetworkProtocolMinorVersion, NetworkProtocolPatchLevel, Settings::NoFogOfWar, FullReplay::NoFow, Settings::NumUnits, FullReplay::NumUnits, Settings::Opponents, FullReplay::Opponents, PlayerMax, Players, FullReplay::Players, Settings::Presets, ReplayMultiPlayer, ReplaySinglePlayer, FullReplay::Resource, Settings::Resources, Settings::RevealMap, FullReplay::RevealMap, SettingsSinglePlayerGame, StratagusMajorVersion, StratagusMinorVersion, StratagusPatchLevel, SettingsPresets::Team, MPPlayer::Team, ThisPlayer, SettingsPresets::Type, MPPlayer::Type, FullReplay::Type, and VERSION.
Referenced by CommandLog(), and tolua_stratagus_StartReplay00().
| bool CommandLogDisabled |
True if command log is off.
True, if command log is off.
Definition at line 142 of file replay.cpp.
Referenced by CclReplayLog(), CleanReplayLog(), CommandLog(), EditorMainLoop(), LoadGame(), LoadReplay(), and main().
FullReplay* CurrentReplay [static] |
Definition at line 148 of file replay.cpp.
bool DisabledLog [static] |
Disabled log for replay.
Definition at line 144 of file replay.cpp.
Referenced by CleanReplayLog(), and LoadReplay().
int InitReplay [static] |
Initialize replay.
Definition at line 147 of file replay.cpp.
Referenced by LoadReplay(), and ReplayEachCycle().
unsigned long NextLogCycle [static] |
Next log cycle number.
Definition at line 146 of file replay.cpp.
Referenced by DoNextReplay(), LoadReplay(), and ReplayEachCycle().
Replay game type.
Definition at line 143 of file replay.cpp.
Referenced by ApplyReplaySettings(), CleanReplayLog(), InputKey(), IsReplayGame(), LoadReplay(), MultiPlayerReplayEachCycle(), and SinglePlayerReplayEachCycle().
LogEntry* ReplayStep [static] |
Definition at line 149 of file replay.cpp.
1.5.6