The International Simutrans Forum

Development => Bug Reports => Topic started by: THLeaderH on January 24, 2021, 09:55:22 AM

Title: [r9576] loading a script fails due to relative path on Windows 10
Post by: THLeaderH on January 24, 2021, 09:55:22 AM
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
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.
Title: Re: [r9576] loading a script fails due to relative path on Windows 10
Post by: prissi 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.
Title: Re: [r9576] loading a script fails due to relative path on Windows 10
Post by: THLeaderH 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.