The International Simutrans Forum

 

Author Topic: [Idea] Getting pakfile name from in-game object.  (Read 527 times)

0 Members and 1 Guest are viewing this topic.

Offline Emil Sawicki

  • *
  • Posts: 191
  • pak128 player
  • Languages: CZ, EN, NO, PL
[Idea] Getting pakfile name from in-game object.
« on: June 29, 2018, 06:34:05 PM »
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.

Offline ACarlotti

  • *
  • Posts: 165
Re: [Idea] Getting pakfile name from in-game object.
« Reply #1 on: June 29, 2018, 08:58:13 PM »
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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2791
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [Idea] Getting pakfile name from in-game object.
« Reply #2 on: June 29, 2018, 09:55:48 PM »
You can use grep with MSYS on Windows :P SublimeText can also search binary files.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5173
  • Languages: EN, NO
Re: [Idea] Getting pakfile name from in-game object.
« Reply #3 on: June 29, 2018, 10:19:42 PM »
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.

Offline Emil Sawicki

  • *
  • Posts: 191
  • pak128 player
  • Languages: CZ, EN, NO, PL
Re: [Idea] Getting pakfile name from in-game object.
« Reply #4 on: June 30, 2018, 09:49:03 AM »
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
Code: [Select]
\msys\1.0\msys.bat -norxvt

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2791
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [Idea] Getting pakfile name from in-game object.
« Reply #5 on: June 30, 2018, 12:27:45 PM »
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.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2344
  • Languages: EN
Re: [Idea] Getting pakfile name from in-game object.
« Reply #6 on: June 30, 2018, 03:31:06 PM »
If a type list was added in game (commonly requested feature) one could show the file name there...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9103
  • Languages: De,EN,JP
Re: [Idea] Getting pakfile name from in-game object.
« Reply #7 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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2791
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [Idea] Getting pakfile name from in-game object.
« Reply #8 on: June 30, 2018, 08:29:39 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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5173
  • Languages: EN, NO
Re: [Idea] Getting pakfile name from in-game object.
« Reply #9 on: July 01, 2018, 08:17:31 AM »
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.

Offline Leartin

  • Devotee
  • *
  • Posts: 1002
  • PAK-DEV P192C
  • Languages: DE, EN
Re: [Idea] Getting pakfile name from in-game object.
« Reply #10 on: July 02, 2018, 06:00:42 AM »
Simply 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.)

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5173
  • Languages: EN, NO
Re: [Idea] Getting pakfile name from in-game object.
« Reply #11 on: July 02, 2018, 03:35:16 PM »
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).

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2791
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [Idea] Getting pakfile name from in-game object.
« Reply #12 on: July 03, 2018, 01:00:54 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.

Offline Leartin

  • Devotee
  • *
  • Posts: 1002
  • PAK-DEV P192C
  • Languages: DE, EN
Re: [Idea] Getting pakfile name from in-game object.
« Reply #13 on: July 04, 2018, 07:11:25 AM »
That 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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5173
  • Languages: EN, NO
Re: [Idea] Getting pakfile name from in-game object.
« Reply #14 on: July 04, 2018, 06:00:00 PM »
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.