OpenTTD

Tasklist

FS#5208 - Console: make console commands 'ls' and 'load' work with scenarios

Attached to Project: OpenTTD
Opened by Leif Linse (Zuu) - Wednesday, 13 June 2012, 19:52 GMT
Last edited by andythenorth (andythenorth) - Saturday, 02 September 2017, 12:14 GMT
Type Feature Request
Category Interface
Status With patch
Assigned To Nick Malishchak (ChubbyPitbull)
Operating System All
Severity Low
Priority Normal
Reported Version 1.2.1
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Currently 'ls' and 'load' doesn't support .scn (scenario) files.

For the work flow of developing a scenario that uses a Game Script, it is necessary to re-load the scenario each time a bug have been fixed in the GS code. However, to do that one have to go back to the main menu and use the GUI there to play the scenario.

Proposed changes:
- make 'ls' also list .scn files
- make 'load' also load .scn files => play scenario
- add 'edit_scn' that loads an .scn file into the scenario editor

Perhaps there are also useful changes for allowing saving of scenarios from the console.
This task depends upon

Comment by Nick Malishchak (ChubbyPitbull) - Sunday, 18 August 2013, 14:46 GMT
Added new SaveLoadDialogMode SLD_LOAD_GAME_SCENARIO
Changed console_commands.cpp::*GetFiosItem to add SaveLoadDialogMode parameter to set _saveload_mode when *GetFiosItem is called, and to handle scenario file types.
Added fios.cpp::FiosGetSaveScenarioListCallback to filter for both save games and scenarios
Added fios.cpp::FiosGetSaveScenarioList to send save file dir and scenario dir (as subdir) to fios.cpp::FiosGetFileList
Changed fios.cpp::FiosGetFileList to scan both _fios_path AND subdir if mode = SLD_LOAD_GAME_SCENARIO
Changed fios_gui.cpp::BuildFileList to handle SLD_LOAD_GAME_SCENARIO case.
Changed console_commands.cpp::DEF_CONSOLE_CMD(ConLoad) to use SLD_LOAD_GAME_SCENARIO mode, and to accept both save game and scenario file types.
Changed console_commands.cpp::DEF_CONSOLE_CMD(ConListFiles) to use SLD_LOAD_GAME_SCENARIO mode.
Changed console_commands.cpp::DEF_CONSOLE_CMD(ConRemove) to use SLD_LOAD_GAME_SCENARIO mode, and to accept only save game and scenario file types.
Added console_commands.cpp::DEF_CONSOLE_CMD(ConEditScn) to load scenarios into the scenario editor. Linked to console command "edit_scn".
Comment by Nick Malishchak (ChubbyPitbull) - Sunday, 18 August 2013, 16:30 GMT
Patch modified to address comments from Alberth in http://paste.openttdcoop.org/show/2524/
Comment by Ingo von Borstel (planetmaker) - Sunday, 15 February 2015, 14:16 GMT
I'm just going through some (older) issues... and this seems useful. However, in trying to compile this:
/Users/ingo/ottd/trunk/src/fios.cpp: In function ‘void FiosGetSaveScenarioList(SaveLoadDialogMode)’:
/Users/ingo/ottd/trunk/src/fios.cpp:572: error: invalid conversion from ‘int’ to ‘const char*’
/Users/ingo/ottd/trunk/src/fios.cpp:572: error: initializing argument 2 of ‘char* FioGetDirectory(char*, const char*, Subdirectory)’

with r27151
Comment by Nick Malishchak (ChubbyPitbull) - Sunday, 15 February 2015, 17:36 GMT
I'll pull the latest and see what the issue is. The patch file is from a year and a half ago, so something the patch was expecting has probably changed since I posted it.
Comment by Nick Malishchak (ChubbyPitbull) - Sunday, 15 February 2015, 21:10 GMT
Updated Patch for trunk r27154:

Changed console_cmds.cpp::DEF_CONSOLE_CMD(ConListFiles) to indicate in the help text that "ls" will also display scenarios.
Fixed compile issue in fios.cpp::FiosGetSaveScenarioList. Function definition of FioGetDirectory had changed since patch was originally created.
Removed ability to delete a scenario using console "rm" command. Changes to console_cmds.cpp::GetFiosItem and fios.cpp::FiosDelete since the original patch broke this functionality in the path. console_cmds.cpp::GetFiosItem only provides a file name, not a full path, and fios.cpp::FiosDelete attempts to auto-detect file type in order to prepend a path and append an extension to the const char * passed to fios.cpp::FiosDelete. However, fios.cpp::FiosMakeSavegameName erroneously guesses at the filetype buy checking the game mode global, so it will only treat a passed file as a scenario if you are actually in the scenario editor in game. Additionally, the pre-pended path is based simply on the _fios_path global, which is not available from console_cmds.cpp::DEF_CONSOLE_CMD(ConRemove). Thus, attempting to delete a scenario from the OpenTTD Title screen resulted in the fiios.cpp::FiosDelete attempting to delete "<My Documents>\OpenTTD\save\andalusia-0.4.1\andalusia 0.4.1.scn.sav." Additionally, scenarios might not neccesarily be in just the SCENARIO_DIR. Being able to "rm" scenarios was not specifically requested in the feature request, so taking this out of the patch for now.

Loading...