News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

[Android] pak download in-game

Started by krosk, August 30, 2021, 09:59:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

krosk

Hello,

Patch applicable to r10054, see (https://github.com/krosk/simutrans/tree/r10054) for a fork where patch has been applied successfully.

The get_pak.sh script is not functional on Android as it calls some unavailable binaries.

The code I send makes use of libcurl and libzip to download and extract zips within the game, instead of calling the shell to do this outside the game.
- For now, this is specific to Android only. Extending it to all platforms could be an option, so as to remove dependencies to "system".
- libcurl is version 7.60.0; it is the source integrated into pelya repository. Its license is MIT. It has a dependency to OpenSSL, v1.1.1. Its license is more or less BSD.
- libzip is version 1.2.0; the source code is found at (https://github.com/nih-at/libzip/releases), and the compiled prebuilt versions is from (https://github.com/krosk/libzip-android). Its license is BSD.
- I have not (yet) added license files to simutrans repo; TODO if this patch is integrated

The libsdl-android repository (https://github.com/krosk/commandergenius/tree/sdl_android_prebuilt_2):
- has been updated with the above dependencies (note: build scripts for android are separate from simutrans repo)
- if there is only one pakset installed, it is impossible to open the internal pakset download window. So the android package now includes 2 paksets by default (pak64 and pak64.german), to make available the modal window to download paksets


Some comments:
- in all platforms, the pakset download window is today supposed to be opened only 1 time; opening it a 2nd time and trying to install something will force quit simutrans; this behavior needs to be reviewed again.
- in all platforms, no way to get into the in-game pakset downloader if there is one single pakset installed. This behavior might need to change (like adding a button in settings ? adding a timed button at start?).
- android does not have Ctrl-click multi-selection in list, so we can install paksets only one at a time; I have ideas to make it touch compatible, but this better be a separate discussion. Combined with the above behavior, you need to install, restart, then install another one.
- I am aware all paksets are not necessarily zips, some are cabs or other formats, so my patch does not support these. However, all maintained paksets are zips.
- ssl has been disabled to connect to https, as I was not able to figure out where to get the certificates on Android.

prissi

Thank you very much, most impressive and would be good also for all platforms. Unfortunately on Debian and Windows the programm folder is write protected, so the pak needs to go somewhere else (i.e. the document folder or the games folder on debian). (And no idea about MacOS)

Some random thoughs:
- Simutrans has a multi selection list. The return is then a list, not a single item. This is enabled for the paks; maybe one needs multiple somehow as default.
- The dialog also appears if there is a pak with addons (like pak64 foodchain).
- There is also code for downloading http files but not https. If https is enough, we could reuse the internal functions " network_receive_file()."
- Not all paks are in a simutrans folder. Moreover, we have also cab and tgz paks (the cab unfortunately the relatively popular pak128.Japan). If we use your version (which would make sense for all plaforms), then we would need to repack the paks following this rule and put them somewhere reachable. I think pak128.Japan is GPL so no problem, and pakHO is probably horribly out of date, so no one cares ...

EDIT: submitted in r10055

Mariculous

Quote from: prissi on August 30, 2021, 01:00:40 PM- There is also code for downloading http files but not https. If https is enough, we could reuse the internal functions " network_receive_file()."
On the other hand, CURL is broadly supported on many platforms, including BeOS and amigaOS, it's solid and supports many protocols, including https.
Is there any reason to prefer network_http_post (which calls mentioned network_receive_file) over curl?

prissi

For downloading of pakset: No libcurl (not curl alone) is fine, and for any platform than Android and Windows the script using curl works (well apart from having another libary to chase ... ). But for speaking directly with the server, yes, libcurl is not so useful for that, since it hooks up the socket. So later we have to use our code.

krosk

- Regarding multi selection list, I more or less had the same idea of putting the CTRL modifier as default on Android, so that the list works like a checkbox list. I will post a separate patch later.
- Regarding write protected folders, I need a clarification: can paks (and any file) be installed in env_t::data_dir on windows? on debian? What about env_t::user_dir ?
- Thanks for mentioning not all paks start with simutrans/, I see now the exception in the shell script, and can adapt the code for it.


Quote from: prissi on August 30, 2021, 01:00:40 PM
Thank you very much, most impressive and would be good also for all platforms. Unfortunately on Debian and Windows the programm folder is write protected, so the pak needs to go somewhere else (i.e. the document folder or the games folder on debian). (And no idea about MacOS)

Some random thoughs:
- Simutrans has a multi selection list. The return is then a list, not a single item. This is enabled for the paks; maybe one needs multiple somehow as default.
- The dialog also appears if there is a pak with addons (like pak64 foodchain).
- There is also code for downloading http files but not https. If https is enough, we could reuse the internal functions " network_receive_file()."
- Not all paks are in a simutrans folder. Moreover, we have also cab and tgz paks (the cab unfortunately the relatively popular pak128.Japan). If we use your version (which would make sense for all plaforms), then we would need to repack the paks following this rule and put them somewhere reachable. I think pak128.Japan is GPL so no problem, and pakHO is probably horribly out of date, so no one cares ...

EDIT: submitted in r10055


krosk

The attached patch is applicable to r10059:
- fix the dual case of a pakset having simutrans as top folder or having the pak name as top folder
- fix a proper implementation for HTTPS calling; ssl verification is not disabled anymore and this is not a security risk
- fix an implementation issue for pak192.comic

Some questions:
- Does simutrans has guideline regarding licenses of its dependencies (sdl, fluidsynth, ...) ? Like a folder where you dump all license files
- Regarding write protected folders, I need a clarification: can paks (and any file) be installed in env_t::data_dir on windows? on debian? What about env_t::user_dir ?

Flemmbrav

awesome! i didn't get to report back on pak192.comic running on Android or not as Android 11 kind of prevents me from accessing the pak file location. Thanks a lot for this implementation! Can't wait for the first official version with Android support so i can check the network games from mobile!

prissi

Debian has a patch (and this is why aburch simutrans was started) to have the data dir hardcoded initial to /usr/games/data (or so). In principle all simutrans data can be in a different folder than the simutrans executable, one has just to set env_t::data_dir appropriately. But simutrans just writes to user_dir. Hence, one would need to allow to install paks in the user directory (which is a relatively small effort.) Maybe this weekend I will look at multiple pakset folder locations.

Thanks for your effort. Incorporated in r10061