News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

[Idea] Getting pakfile name from in-game object.

Started by Emil Sawicki, June 29, 2018, 06:34:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Emil Sawicki

I'm playing using many addons from other paksets and sometimes there are duplicated buildings, catenaries or something else. Sometimes it's not easy to find'em in my addons folder because of pakfile names not corresponding with in-game objects. It'd be useful to get *.pak name by clicking on such building so I can locate it and remove.
Simutrans 123, Windows 10

ACarlotti

It is already theoretically possible to do this outside of Simutrans. The .pak files contain the names of the vehicles in plaintext (though the .pak files also contain binary data). So you can search the .pak files for the specific text. I don't know how you'd do this on Windows, but on Linux the command "grep -r leyland [pak folder]" will list all .pak files containing objects whose names contain "leyland". It will also find any translation or compatibility files, and sometimes other vehicles that refer to a 'leyland' vehicle in their coupling constraints.

The names of objects actually defined in a pak file will appear a few bytes after the word "TEXT"; if the name is referring to another object then that will usually be a few bytes after "XREF". So you want to look for a file that contains your object's name a few bytes after "TEXT" (possibly after finding the untranslated version of the name in a text file, if names can be translated).


I'm sure it would be possible to display pak-file names in the game itself, but doing so would require adding content to some dialogue (which ones?) for every single object, and I don't think it's particularly useful information to have in-game given that the information can be obtained relatively easily outside of Simutrans in the few cases where it is needed.

An_dz

You can use grep with MSYS on Windows :P SublimeText can also search binary files.

Ters

It is also possible to use makeobj's list command to list the contents of pak files. It requires command line skills (which the average Windows and Mac user doesn't have), and the installation of makeobj (Linux and possibly Mac will have grep available by default), but doesn't require having to interpret the binary result to tell TEXT from XREF. And you have to look through all the pak files to find a match, rather than having a program do it.

Emil Sawicki

Thank you for helpful answers. I'll use MSYS on my Windows 10 64 bit. As for now it doesn't even run, window disappears immediately after running \msys\1.0\msys.bat -norxvt
Simutrans 123, Windows 10

An_dz

Use MSYS2, I don't know if MSYS1 has grep, though it probably does. MSYS2 can also be updated from itself, no need to re-download installers.

DrSuperGood

If a type list was added in game (commonly requested feature) one could show the file name there...

prissi

You can switch to a language with almost no trasnlations turkish or belorussian. Then the object is likelz in its untranslated name in the game.

An_dz

Quote from: prissi on June 30, 2018, 03:48:06 PM
You can switch to a language with almost no trasnlations turkish or belorussian. Then the object is likelz in its untranslated name in the game.
You get the object name, but not the file name.

Ters

Quote from: An_dz on June 30, 2018, 08:29:39 PM
You get the object name, but not the file name.

Getting the object name is still a necessary step given the tools available, which I don't think was properly pointed out earlier.

Simply using the translation file in reverse might however be easier than switching language in Simutrans.

Leartin

Quote from: Ters on July 01, 2018, 08:17:31 AMSimply using the translation file in reverse might however be easier than switching language in Simutrans.
While Object names are unique, translations are not. A simple "Catenary" might be the translated name of many different catenary objects.

Though a similar issue exists with simply switching language. Citybuildings don't display their object name, so they would need to be found in the "build citybuilding" dialog by finding a matching graphic.
For townhalls, you need to build a station next to them while having the correct station naming convention activated and playing in a language that did not translate it.

While it's possible to get most object names from the game, a dedicated tool ingame would be nice. Eg. click on any object to open a dialog containing at least the objects name and translation for the current language. If it's a tool, you require a menu that enables it, so normal players simply  won't have it. But editing the menuconf to enable it is simple enough for anyone in need to see object names.
(Personally, I'd extend such a tool to show as much information about the object as possible, but that might get too close to "unpaking pak files" for some.)

Ters

Showing all the information about an object is one thing (I've made my own tool for such things and more), but the file name, or perhaps even the full path, of the pak file that object was loaded from is something else. That would require dragging along a piece of information, which is useless most of the time, from one end of the game code to the other (my tools does not do this either).

An_dz

Quote from: Leartin on July 02, 2018, 06:00:42 AM
For townhalls, you need to build a station next to them while having the correct station naming convention activated and playing in a language that did not translate it.
Open Advanced(?) Settings and enable townhall_info.

Leartin

Quote from: Ters on July 02, 2018, 03:35:16 PMThat would require dragging along a piece of information, which is useless most of the time
Not even requesting that, but if anything, it shouldn't be stored but searched on demand. Essentially the same method described by An_dz, but instead of using an outside tool, Simutrans would do the search. This would be more useful since you get all files including that object name, both if the same name is used for various objects and if other objects reference them. Since the idea is to find the object in order to delete it, it makes sense to be aware if that affects other objects, eg. in constraints.

Ters

That is possibly even more difficult, requiring two different pak file parsing algorithms. And going through all the pak files once again would take about as long time as loading the pak set did initially. Simutrans isn't too fond of time consuming tasks happening while the game is running.