The International Simutrans Forum

 

Author Topic: [r9576] loading a script fails due to relative path on Windows 10  (Read 194 times)

0 Members and 1 Guest are viewing this topic.

Offline THLeaderH

  • Coder/patcher
  • Devotee
  • *
  • Posts: 419
  • Languages: JP,EN
One player reported me that he cannot launch a scripted tool with clicking the icon in the toolbar. However, the scripted tool can be launched with the script tool loading window. I investigated why this happens and found that the file path is passed in the relative form when the tool is called with the icon, but in the absolute form when it is called with the loading window. It seems that load_script() function fails when the file path is passed in the relative form.

Replacing simmain.cc:1170 with
Code: [Select]
script_tool_manager_t::load_scripts((env_t::program_dir + env_t::objfilename + "tool/").c_str());solved the problem for his environment.

However, the most mysterious thing is that this phenomenon only happens for him with Windows 10, and nobody else reported this problem to me.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10528
  • Languages: De,EN,JP
Re: [r9576] loading a script fails due to relative path on Windows 10
« Reply #1 on: January 24, 2021, 01:42:26 PM »
Simutrans has no member "env_t::program_dir". I suppose you men data_dir? I put this into r9586

However, I wonder if this is not also needed for the user tools.

Offline THLeaderH

  • Coder/patcher
  • Devotee
  • *
  • Posts: 419
  • Languages: JP,EN
Re: [r9576] loading a script fails due to relative path on Windows 10
« Reply #2 on: January 25, 2021, 04:27:01 AM »
Yes, env_t::program_dir was renamed to data_dir some times ago.

I think absolute path is also needed for the user tools, that are under the "addons" directory. After you commit it, I will ask the person who reported me this issue to test it.