From 62c05db04577d96ba14b1faee3a59f940efe2403 Mon Sep 17 00:00:00 2001
From: Yona-TYT <simus.tyt@gmail.com>
Date: Sun, 26 May 2024 17:08:12 -0400
Subject: [PATCH] ADD systemtype in is_tool_allowed

---
 JagexLauncher.dxvk-cache          | Bin 0 -> 12 bytes
 src/simutrans/builder/wegbauer.cc |   2 +-
 src/simutrans/dataobj/scenario.cc |   4 ++--
 src/simutrans/dataobj/scenario.h  |   2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
 create mode 100644 JagexLauncher.dxvk-cache

diff --git a/JagexLauncher.dxvk-cache b/JagexLauncher.dxvk-cache
new file mode 100644
index 0000000000000000000000000000000000000000..96b98eb0b6851e8fe824caa5386cdafb44d6f3ec
GIT binary patch
literal 12
OcmZ>X2=nG*fB*muQvpZ-

literal 0
HcmV?d00001

diff --git a/src/simutrans/builder/wegbauer.cc b/src/simutrans/builder/wegbauer.cc
index 5aa1b9e16..3fe4b9a70 100644
--- a/src/simutrans/builder/wegbauer.cc
+++ b/src/simutrans/builder/wegbauer.cc
@@ -296,7 +296,7 @@ void way_builder_t::fill_menu(tool_selector_t *tool_selector, const waytype_t wt
 {
 	// check if scenario forbids this
 	const waytype_t rwtyp = wtyp!=track_wt  || styp!=type_tram  ? wtyp : tram_wt;
-	if (!welt->get_scenario()->is_tool_allowed(welt->get_active_player(), TOOL_BUILD_WAY | GENERAL_TOOL, rwtyp)) {
+	if (!welt->get_scenario()->is_tool_allowed(welt->get_active_player(), TOOL_BUILD_WAY | GENERAL_TOOL, rwtyp, styp)) {
 		return;
 	}
 
diff --git a/src/simutrans/dataobj/scenario.cc b/src/simutrans/dataobj/scenario.cc
index bb2582fd3..7ab2b572b 100644
--- a/src/simutrans/dataobj/scenario.cc
+++ b/src/simutrans/dataobj/scenario.cc
@@ -411,7 +411,7 @@ void scenario_t::clear_rules()
 }
 
 
-bool scenario_t::is_tool_allowed(const player_t* player, uint16 tool_id, sint16 wt)
+bool scenario_t::is_tool_allowed(const player_t* player, uint16 tool_id, sint16 wt, sint16 st)
 {
 	if (what_scenario != SCRIPTED  &&  what_scenario != SCRIPTED_NETWORK) {
 		return true;
@@ -441,7 +441,7 @@ bool scenario_t::is_tool_allowed(const player_t* player, uint16 tool_id, sint16
 	// then call script if available
 	if (what_scenario == SCRIPTED) {
 		bool ok = true;
-		const char* err = script->call_function(script_vm_t::FORCE, "is_tool_allowed", ok, (uint8)(player  ?  player->get_player_nr() : PLAYER_UNOWNED), tool_id, wt);
+		const char* err = script->call_function(script_vm_t::FORCE, "is_tool_allowed", ok, (uint8)(player  ?  player->get_player_nr() : PLAYER_UNOWNED), tool_id, wt, st);
 		return err != NULL  ||  ok;
 	}
 
diff --git a/src/simutrans/dataobj/scenario.h b/src/simutrans/dataobj/scenario.h
index 221b26783..298020390 100644
--- a/src/simutrans/dataobj/scenario.h
+++ b/src/simutrans/dataobj/scenario.h
@@ -408,7 +408,7 @@ public:
 	 * Called for instance in karte_t::local_set_tool to change active tool or when filling toolbars.
 	 * @return true if player can use this tool.
 	 */
-	bool is_tool_allowed(const player_t* player, uint16 tool_id, sint16 wt = invalid_wt);
+	bool is_tool_allowed(const player_t* player, uint16 tool_id, sint16 wt = invalid_wt, sint16 st = type_all);
 
 	/**
 	 * Checks if player can use the tool at this position.
-- 
2.45.0

