--- /home/yonatyt/simu-git/simutrans-master/dataobj/scenario.cc 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/scenario.cc 2021-08-21 19:16:43.306367000 -0400 @@ -541,6 +541,21 @@ } +const char* scenario_t::is_link_go_to_pos(koord3d pos) +{ + if (env_t::server) { + // networkgame: allowed + return NULL; + } + // call script + if (what_scenario == SCRIPTED) { + static plainstring msg; + const char *err = script->call_function(script_vm_t::FORCE, "is_link_go_to_pos", msg, pos); + + return err == NULL ? msg.c_str() : NULL; + } + return NULL; +} const char* scenario_t::get_error_text() { --- /home/yonatyt/simu-git/simutrans-master/dataobj/scenario.h 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/scenario.h 2021-08-21 19:16:34.822128000 -0400 @@ -438,6 +438,15 @@ */ const char* is_convoy_allowed(const player_t* player, convoihandle_t cnv, depot_t* depot); + /** + * Called when player click link in scenario windows. + * + * @param pos coordinate go to in link + * + * @return null if allowed, an error message otherwise + */ + const char* is_link_go_to_pos(koord3d pos); + /// @return debug dump of forbidden tools const char* get_forbidden_text(); /// @} --- /home/yonatyt/simu-git/simutrans-master/gui/scenario_info.cc 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/scenario_info.cc 2021-08-21 19:16:50.497643000 -0400 @@ -95,6 +95,9 @@ gui_frame_t::draw(pos, size); } +// implementation in simtool.cc +void open_error_msg_win(const char* error); + bool scenario_info_t::action_triggered( gui_action_creator_t *comp, value_t v) { if ( comp == &tabs ) { @@ -122,6 +125,11 @@ p = welt->lookup_kartenboden(k)->get_pos(); } welt->get_viewport()->change_world_position( p ); + + const char* err = welt->get_scenario()->is_link_go_to_pos( p ); + if (err) { + open_error_msg_win(err); + } } } } --- /home/yonatyt/simu-git/simutrans-master/script/api/api_skeleton.cc 2021-08-21 10:37:45.000000000 -0400 +++ /home/yonatyt/simu-git/files/api_skeleton.cc 2021-08-21 19:16:55.791957000 -0400 @@ -277,6 +277,18 @@ register_function("is_convoy_allowed"); /** + * Called when player click link in scenario windows. + * + * @param pos coordinate go to in link + * + * @return null if allowed, an error message otherwise + * @typemask string(coord3d) + * @ingroup scen_skel + * @ingroup quick_return_func + */ +register_function("is_link_go_to_pos"); + +/** * Initializes the tool. * @returns true upon success. *