News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

[r9576] loading a script fails due to relative path on Windows 10

Started by THLeaderH, January 24, 2021, 09:55:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

THLeaderH

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.

prissi

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.

THLeaderH

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.