Skip to content

Launch request

Formats

Added in 0.3.0

Describes the game, saved game or map capture a launcher asks for with -LAUNCH=, and the result file the game writes back.

Format
Kind
Configuration file
Filename
*

A launcher writes a launch request file and starts the game with -LAUNCH=<file>. The game reads the file, plays the game, resumes the saved game or makes the map capture it asks for in place of the startup movies and the menu, and exits when that ends. A relative file name is taken from the game’s folder. When the request gives a result file, the game writes it before it exits.

The file is a Request message of the launch.proto schema in the OpenTS repository’s docs/launch folder, in the Protocol Buffers binary encoding. The game refuses a file that:

  • is larger than 1,048,576 bytes, or is not a valid encoding of the message;
  • has a version other than 1;
  • sets no verb;
  • has a text field that is not valid UTF-8.

A request sets exactly one verb:

VerbWhat this version does
playStarts a campaign mission, a skirmish, or a game against other machines.
loadResumes a saved game.
captureDraws a map to a PNG picture, as the map capture switches do.
replayRefuses the request.
verifyRefuses the request.

request_id is any text; the result file repeats it. channel is not read.

game is what every machine in the game shares, and must be the same on each of them. map_path, session and network belong to this machine.

FieldMeaning
game.kind1 for a campaign mission, 2 for a skirmish, 3 for a game against other machines. Use 3 exactly when more than one player is human, observers included.
game.seedThe random seed. A game against other machines needs one. A seed that is set is used as given, 0 included; a campaign mission or skirmish without one draws a seed.
game.playersAt most eight players, human players first. In a skirmish or against other machines a player’s position in the list is the house it becomes.
game.optionsThe game options, each key at most once, from the table below.
game.anonymousShows players as “Player N” in place of their names.
game.global_flagsThe numbers of the scenario’s global flags that are set when a campaign mission starts, from 0 to 49, ascending, each once. Refused in any other game.
map_pathThe scenario to play, opened as the game opens any file. Required.
session.local_playerThe position in game.players of the human playing on this machine; 0 in a campaign mission. Required.
session.hostMakes this machine the host of a game against other machines, as Host=yes does.
session.autosave_intervalFrames between automatic saves; 0 for none.
session.next_campaign_autosave, session.next_skirmish_autosaveThe automatic-save slot to write next, counted from 0.
session.skip_score_screenPasses over the score screen at the end of a game.
session.write_statistics, session.game_id, session.map_hashWrite stats.dmp with this game number and map hash.
session.map_nameThe map’s name, which only stats.dmp reports.
session.load_screenThe picture shown while the scenario loads, and where the loading bars go in it.
session.difficulty_nameText shown in place of the campaign difficulty’s name.
network.portThis machine’s UDP port, or its number on the tunnel when network.tunnel is set.
network.peersOne entry for each other human player: its position in game.players, its IPv4 address, and its port or tunnel number.
network.tunnelThe address and port of a tunnel to play through.
network.connect_timeout, network.reconnect_timeoutThe longest wait, in milliseconds, for another machine while the game loads and once it runs. The game rounds down to 16 ms and keeps each wait between 960 and 576,000 ms; 0 keeps the defaults of 57,600 and 38,400 ms.

Set network exactly when game.kind is 3. The game does not read session.game_mode, recording, or network.protocol, frame_send_rate and max_ahead. A request that sets fixture is refused.

A player in game.players takes these fields:

FieldMeaning
nameAt most 63 bytes. A human player needs one, and in a game against other machines no two human players have the same name, ignoring case. A computer player without one is shown under a name the game picks.
humanSet for a human player, unset for a computer player.
observerSet for a human player who watches and does not play.
countryA position in the rules’ list of countries, from 0, or -1 for one the game picks.
colorA position in the rules’ [Colors] list, from 0, or -1 for one the game picks. Human players who give a color need different ones.
startA start position from 0 to 7, or -1 for one the game picks.
ai_levelA computer player’s difficulty: 0 for the hardest, 1, or 2 for the easiest. Without it the AIDifficulty option applies.
alliesThe positions of the players this one is allied with, ascending, never an observer or the player itself.

A campaign request lists one human player; the mission gives that player a house, so country, color and start are not read.

An option is a key with a number or a flag. A key that does not apply to the kind of game is refused, and so is a value outside the range.

KeyValueGamesAcceptedWithout it
AIDifficultynumberskirmish, other machines0 (easiest) to 2 (hardest)1
AlliesAllowedflagskirmish, other machinesno
AttackNeutralUnitsflagskirmish, other machinesno
AutoDeployMCVflagskirmish, other machinesno
Basesflagskirmish, other machinesyes
BridgeDestructionflagskirmish, other machinesyes
BuildOffAllyflagskirmish, other machinesno
Campaignnumbercampaign-1 to the last campaign-1
CampaignComputerDifficultynumbercampaign0 to 21
CampaignPlayerDifficultynumbercampaign0 to 21
CoachModeflagskirmish, other machinesno
Cratesflagskirmish, other machinesno
Creditsnumberskirmish, other machinesany10000
Firestormflagevery gameyes
FogOfWarflagskirmish, other machinesno
GameSpeednumberevery game0 to 60
HarvesterTruceflagskirmish, other machinesno
MCVRedeployflagskirmish, other machinesyes
MultiEngineerflagskirmish, other machinesno
PlayMoviesflagskirmish, other machinesno
ScrapMetalflagskirmish, other machinesno
SharedControlflagskirmish, other machinesno
ShortGameflagskirmish, other machinesno
SurrenderOnDisconnectflagskirmish, other machinesyes
TechLevelnumberskirmish, other machinesany10
UnitCountnumberskirmish, other machinesany0

Each key has the meaning of the SPAWN.INI key of the same name, except these six, which SPAWN.INI names differently:

KeySPAWN.INI key
BridgeDestructionBridgeDestroy
CampaignCampaignID
CampaignComputerDifficultyDifficultyModeComputer
CampaignPlayerDifficultyDifficultyModeHuman
PlayMoviesPlayMoviesInMultiplayer
SurrenderOnDisconnectAutoSurrender

AIDifficulty numbers difficulties the other way from ai_level.

For a country or color of -1, the game draws a value before the map loads. It draws a country from those with Multiplay=yes, or takes the first country when none has it. It draws a color from the eight colors the menu offers, the [Colors] entries numbered 1, 10, 13, 16, 19, 23, 27 and 36, leaving out every color a player gives and every color an earlier draw took. When all eight are taken, it draws from the other [Colors] entries not taken, and when every entry is taken, from all of them. A color a computer player gives is used even when another player gives the same one.

The game draws for the human players in list order, then for the computer players in list order, from random numbers that start from game.seed. Every machine in a game therefore draws the same values, and a skirmish without a seed draws differently at each launch.

A load request resumes a saved game, as LoadSaveGame=yes does in SPAWN.INI. The save gives the kind of game, its scenario, its options and its houses.

FieldMeaning
saveThe file name of the save in the saved-games folder, with no folder part. Required.
sessionThe same fields as in a play request. local_player and host are read only for a game against other machines. load_screen and difficulty_name take effect only when the scenario is restarted.
networkRequired for a save from a game against other machines, as in a play request, and not read otherwise.
playersRequired for a save from a game against other machines, and not read otherwise.
game_speedThe speed, 0 to 6, to play at. Without it the game plays at the saved speed.
anonymousShows players as “Player N” in place of their names, as game.anonymous does. A save does not keep it.

In a game against other machines, each machine loads the save it wrote itself, and players lists the human players who rejoin, the same list on every machine. session.local_player is the position of the player on this machine, and each entry of network.peers gives another position in the list. Each player needs a name of 1 to 63 bytes that no other player in the list has, ignoring case, and a country and color that are -1 or ones the rules have.

After loading the save, the game gives each player the saved human house with the same name, ignoring case. The houses keep the countries and colors the save gives them. The resume fails when:

  • a player has no saved house of that name;
  • a player watches in the request but played in the save, or the reverse;
  • this machine’s save was written by a player other than session.local_player.

A human player who played in the save but is not listed keeps the house, and the computer plays it.

A resumed game against other machines first runs at the speed the match was playing at when it was saved. The player with the lowest-numbered house, observers left out, then changes the speed for every machine to the game_speed in that player’s request. The game_speed in the other players’ requests is not used.

A capture request sets map_path and out_path together, as -CAPTUREMAP= and -CAPTUREOUT= do, or description_path alone, as -CAPTURE= does. A relative out_path is placed like the result file. A relative description_path is taken from the game’s folder.

Besides a file it cannot read, the game refuses:

  • -LAUNCH= together with -SPAWN, -CAPTUREMAP=, -CAPTUREOUT=, -CAPTURE=, -TIME= or -SEED, in any build;
  • a replay or verify request, and a play request that sets fixture;
  • a capture request that sets description_path with map_path or out_path, or that lacks one of map_path and out_path without description_path;
  • a play request that breaks a rule on this page, such as a country or color the rules do not have;
  • a load request that breaks a rule on this page, or whose save is missing, unreadable, made by another version of the game, or from a game the menu arranged over the local network.

A refused request starts nothing. With a result file, the game reports the refusal there and shows no message. Without one, it shows the reason in a message box, except when a capture switch was also given: that run shows no dialog and writes the reason to the debug log and to the console it was started from.

result_path is the result file’s path. A relative path goes into the -USERDIR= folder, or beside the game without one, as stats.dmp does; an absolute path is used as given. Once the game has read the request it deletes any file at that path. It writes the result when it exits, or when it crashes after accepting the request, to a temporary file that it then renames over the path, so a launcher never reads part of one. No file after the game exits means it could not read the request or write the file, or that it was stopped before its crash handler wrote the report.

The result is a Result message in the same encoding:

FieldMeaning
request_idThe request’s request_id.
code1 when the game or capture ran, 2 when the request was refused, 3 when it was accepted and could not be done, such as a capture that failed, a network that did not open, a save that did not load or whose houses do not match players, or a scenario that never started, 4 when the game crashed, and 7 when a game against other machines ended at its start because the machines had not loaded the same game, as Games that differ at the start describes.
messageWhy, in English, when code is not 1.
scenariosOne entry for each scenario a play or load request started, in order. A resumed save is the first entry. A campaign can start several missions, and a restart starts the same one again.
output_pathThe picture a capture wrote, as an absolute path.
crash_pathAfter a crash, the crash report’s folder.

Each scenario entry gives:

FieldMeaning
map_pathThe scenario’s file name, in upper case.
outcomeHow the scenario ended, from the table below.
completedSet when the game decided the scenario as a win or a loss.
last_frameThe game’s frame counter when the scenario ended. Absent for the scenario a crash ended, and for outcome 7.
not_recordedAlways 1, since this version records no replays; replay_path is always empty.
outcomeWhen
0The local player is an observer, and the scenario ended in a way that gives a player 1, 2 or 4. Also the scenario a crash ended.
1The local player won.
2The local player lost.
3Not reported by this version.
4The scenario was restarted, the player left it, or it ended without being decided, such as when the player pressed Cancel in the reconnect dialog during play or a multiplayer load failed on this machine.
5The game ended because the machines’ games differed: the player quit the out-of-sync dialog, the game stopped with Packet received too late!, or the machines had not loaded the same game at a multiplayer load.
6Every other player voted this machine out during play, or another machine did not answer when play resumed after a multiplayer load.
7The game against other machines ended at its start, before its first frame: another machine did not answer, the player pressed Cancel or was voted out while waiting, or the machines had not loaded the same game.

A machine that stops answering during play is dropped, and the others play on, as Leaving a match describes; the same happens to a player dropped on the loading screen. The players who stay get the outcome of the rest of the game. A machine whose own connection fails cannot tell that apart from the others falling silent, so it drops them in the same way and plays on alone. After the master continues an out-of-sync game, each machine’s outcome likewise comes from the game it plays on.

Source files

Linked at revision cfa7f5bbbc2e.

History

  1. Added0.3.0In development

    Start a game from a launch request