Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DorpsGek opened this issue Jun 13, 2012 · 7 comments
Closed

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

DorpsGek opened this issue Jun 13, 2012 · 7 comments
Labels
component: interface This is an interface issue enhancement Issue would be a good enhancement; we accept Pull Requests! flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay stale Stale issues

Comments

@DorpsGek
Copy link
Member

Zuu opened the ticket and wrote:

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.

Reported version: 1.2.1
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5208
@DorpsGek
Copy link
Member Author

ChubbyPitbull wrote:

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".

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5208#comment12536

@DorpsGek
Copy link
Member Author

ChubbyPitbull wrote:

Patch modified to address comments from Alberth in http://paste.openttdcoop.org/show/2524/

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5208#comment12540

@DorpsGek
Copy link
Member Author

planetmaker wrote:

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


This comment was imported from FlySpray: https://bugs.openttd.org/task/5208#comment13777

@DorpsGek
Copy link
Member Author

ChubbyPitbull wrote:

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.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5208#comment13778

@DorpsGek
Copy link
Member Author

ChubbyPitbull wrote:

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 "\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.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5208#comment13781

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) enhancement labels Apr 7, 2018
@TrueBrain TrueBrain added patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay enhancement Issue would be a good enhancement; we accept Pull Requests! and removed enhancement from FlySpray labels Apr 13, 2018
@andythenorth
Copy link
Contributor

Thanks for this. There's been no activity on this for some time, and as it stands, it doesn't look likely that it will go any further. Since OpenTTD moved to GitHub, we use pull requests rather than patches, as they are a much more productive workflow.

I'm planning to close this soon (in 7 days), as we try to keep the issue count low for OpenTTD, it helps us focus on things that are important and fun.

If you would like to continue with this patch, the best way would be to move the patch to your own GitHub fork, update it for the current OpenTTD master, and then create a pull request. For more information, please see our CONTRIBUTING.md.

We are also happy to discuss directly on the issue, or in #openttd irc, including help to get this into a pull request. Thanks for your contribution!

@stale
Copy link

stale bot commented Mar 6, 2019

This issue has been automatically marked as stale because it has not had any activity in the last two months.
If you believe the issue is still relevant, please test on the latest nightly and report back.
It will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale Stale issues label Mar 6, 2019
@stale stale bot closed this as completed Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue enhancement Issue would be a good enhancement; we accept Pull Requests! flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay stale Stale issues
Projects
None yet
Development

No branches or pull requests

3 participants