News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

New freight list sort mode: "via (player)"

Started by Nazalassa, April 15, 2025, 02:03:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nazalassa

It recently occured to me there is no easy way to count the amount of freight waiting at a stop to go to some player's network, so I have written a patch which adds a new freight sort mode, "via (player)", which groups and sorts freight by the owner of their next transfer station.

There have been several patches posted to this thread, so if you are not interested in applying three successive patches you can just apply this one (via-player-final.patch) which is the sum of the others.

Note 1: the patch does not attempt to determine the owner of the convoy(s) the freight will take next - it only looks at the owner of the next stop (hence some freight may go to the "public service's network" instead of the "Springfield All Green Initiative"'s network).

Note 2: the patch also updates history.txt, text/en/station.txt and text/en/convoiinfo.txt to mention the new sort mode.

Here is an example of what it looks like:
via-player-example.png
Making paksets since October 2023  |  pak48.bitlit | pak32.box | MLM for pak64 | Empire F7 cars

Life is like a multi-tasking OS: you know you'll eventually get back to everything, but you don't know when.

prissi

There is one spurious question mark in the patch in the English file but otherwise it is fine. However, it would show nothing for most single player games, so maybe on should on enable it if there is more than 2 players in total?

Nazalassa

Quote from: prissi on April 16, 2025, 02:46:30 AMThere is one spurious question mark in the patch in the English file but otherwise it is fine. However, it would show nothing for most single player games, so maybe on should on enable it if there is more than 2 players in total?

Here are two more patches for two ways to implement this. Both need to be applied on top of the original patch.

"via-player-net-only.patch" restricts the "via (player)" freight sorting order to network games only. If a non-network game is loaded with this sorting order active, it is not replaced by another one but once left it cannot be accessed anymore.
I am not sure what I did is the best way to implement this though...

Yet this sort order can as well be useful on some non-network games, too, if there are several players, so "via-player-many-players-only.patch" counts the number of active players to take its decision instead of looking for the "network-game-ness" of the world. It loops over the 13 players that are neither the "human player" nor the "public service", and only enables "via (player)" if one of them is taken. Looping may not be the best way to do it; I may have missed it but it could be a good thing to have a way to get the amount of (non-public-service?) players.

(The patches also fix the question marks in station.txt. Thanks for pointing that out.)
Making paksets since October 2023  |  pak48.bitlit | pak32.box | MLM for pak64 | Empire F7 cars

Life is like a multi-tasking OS: you know you'll eventually get back to everything, but you don't know when.

Nazalassa

I have realized I forgot to check whether the via halt was bound or not before getting its name, which could lead to segfaults. So I updated the patch and attached it to this post.

"via-player-final.patch" contains everything (changes to doc, to code etc.) in one signle patch.
On the other hand, "via-player-no-segfault.patch" can be applied on top of the other patches in this thread to fix the segfault issue.
Making paksets since October 2023  |  pak48.bitlit | pak32.box | MLM for pak64 | Empire F7 cars

Life is like a multi-tasking OS: you know you'll eventually get back to everything, but you don't know when.

prissi

Incorporated in r11682

I have found several inconsistencies, unified the strings and make sure, the display order is the same for all windows.

Matthew

Quote from: prissi on April 16, 2025, 02:46:30 AMThere is one spurious question mark in the patch in the English file but otherwise it is fine. However, it would show nothing for most single player games, so maybe on should on enable it if there is more than 2 players in total?
Quote from: Nazalassa on April 16, 2025, 07:07:06 AMHere are two more patches for two ways to implement this. Both need to be applied on top of the original patch.

"via-player-net-only.patch" restricts the "via (player)" freight sorting order to network games only. If a non-network game is loaded with this sorting order active, it is not replaced by another one but once left it cannot be accessed anymore.
I am not sure what I did is the best way to implement this though...

Yet this sort order can as well be useful on some non-network games, too, if there are several players, so "via-player-many-players-only.patch" counts the number of active players to take its decision instead of looking for the "network-game-ness" of the world. It loops over the 13 players that are neither the "human player" nor the "public service", and only enables "via (player)" if one of them is taken. Looping may not be the best way to do it; I may have missed it but it could be a good thing to have a way to get the amount of (non-public-service?) players.

I am not certain whether the two of you meant human players or in-game logical players in your posts. But I routinely play non-network games (single-player in the sense that only I am connected) with multiple in-game players. Usually this is because I am role-playing several companies, but occasionally it's because I am hot-seating with my nephew. As far as I can tell, the final version does make this feature available in non-network games, so thank you both for making that possible.
(Signature being tested) If you enjoy playing Simutrans, then you might also enjoy watching Japan Railway Journal
Available in English and simplified Chinese
如果您喜欢玩Simutrans的话,那么说不定就想看《日本铁路之旅》(英语也有简体中文字幕)。

Andarix

With so many options, wouldn't it be better to have a selection list instead of a button?

prissi

Requires some more logic to handle the combobox updates for the different windows where this applies too ... but I though the same.