News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Persistent history for manually entered servers

Started by victor_18993, Yesterday at 07:58:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

victor_18993

Hi Prissi,

This is a follow-up to an older request concerning a persistent history of manually entered multiplayer servers. Since the original topic is now closed, I have opened this new topic to present a working and tested patch.

01-recent-servers-dialog.png

At present, a manually entered server address is retained only for the current session. This patch adds a local MRU history containing the last ten manually entered servers that were successfully connected to.

The existing public server list remains unchanged. Servers selected from the public list are not added to this history.

The interface provides:

- a recent-server selector;
- an optional local alias, displayed as "Alias (address)";
- removal of individual entries;
- import and export of shareable server lists.

Only the server address and its optional alias are stored. No passwords, player nicknames, pakset information or game data are saved.

The data is stored as a small, versioned UTF-8 CSV file named `recent_servers.csv` in the Simutrans user directory. It is deliberately not encrypted because it contains no credentials or private connection data. It is never included in a savegame or synchronized over the network.

A manually entered address is recorded as pending when the connection starts and is added to the history only after `network_connect()` completes successfully. Failed connection attempts are discarded. Entries are deduplicated by address, ordered with the most recently used first, and limited to ten.

Persistence and import/export include the following safeguards:

- saving through a temporary file followed by checked replacement;
- transactional imports;
- rejection of unknown file-format versions;
- a 64 KiB import-size limit;
- preservation of the current history if importing or saving fails;
- explicit confirmation before overwriting an exported file.

Scope of the patch:

- no savegame-format change;
- no network-protocol change;
- no server-side change;
- no new dependency;
- no native platform-specific file dialog;
- no change to the existing public server list.

Validation on r12103:

- Simutrans builds successfully;
- all 61 dedicated automated checks pass;
- a failed connection creates no history entry;
- a real connection to `simutrans-forum.de:13355` completed `NWC_JOIN`, `NWC_SYNC` and `NWC_GAME`, and created the expected local entry;
- the recent-server dialog and overwrite confirmation were tested visually in game;
- the complete patch applies cleanly to r12103.

I have attached the complete patch and two screenshots.

Before reducing or extending the patch, I would appreciate your opinion on three design points:

1. Is a separate `recent_servers.csv` file in the user directory acceptable, or would you prefer this state to be stored in an existing configuration file?
2. Should import/export be included in the first version, or would you prefer an initial patch containing only the history, aliases and removal?
3. Is a fixed limit of ten entries reasonable?

Regards.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

prissi

Honestly, with less than three active servers ... (Of course I wished there were more servers.) Also, simutrans reconnects on the last used server already.

I honestly never use the server windo at all, rahter use "net:..." in the open window (which also bypasses the version check) or use "-load net:..." on the command line. Then one can have several versions as shortlinks.

Finally, I am not a fan of a big dialog, and import and export is really not needed. Just read the csv file when opening and read and save it when joining a server.

Also the servers have a name already. A second name is slightly confusing. What one could do is looking in the list for a server with the same name and remove this entry when adding a new conenction to a server with the same name. (Especially private hosted servers could be prone to changing IP number every 24h.)

victor_18993

Thanks, Prissi. That makes sense.

I agree that the current version is too large for this feature. I will reduce it to a minimal recent-address history integrated into the existing server window: no aliases, no import/export and no separate management dialog.

The file would simply be loaded when opening the server window and updated after a successful connection, as you suggest. I will also look at using the server-reported name to replace an older entry when a private server changes address, while keeping address-based deduplication as the fallback.

I will check how small the resulting patch becomes before taking it any further.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)