--- /home/yonatyt/simu-git/simutrans-master/dataobj/scenario.cc 2020-03-08 01:52:08.000000000 -0400 +++ /home/yonatyt/simu-git/files/scenario.cc 2020-03-23 17:30:35.993460000 -0400 @@ -263,7 +263,8 @@ diff = (sint32)toolnr - (sint32)other.toolnr; } if (diff == 0) { - diff = (sint32)waytype - (sint32)other.waytype; + //diff = (sint32)waytype - (sint32)other.waytype; + diff = (sint32)other.systemtype - (sint32)systemtype ; } lt = diff < 0; } @@ -273,7 +274,7 @@ bool scenario_t::forbidden_t::operator ==(const forbidden_t &other) const { - bool eq = (type == other.type) && (player_nr == other.player_nr) && (waytype == other.waytype); + bool eq = (type == other.type) && (player_nr == other.player_nr) && (waytype == other.waytype) && (systemtype == other.systemtype); if (eq) { switch(type) { case forbid_tool_rect: @@ -292,7 +293,7 @@ scenario_t::forbidden_t::forbidden_t(const forbidden_t& other) : type(other.type), player_nr(other.player_nr), toolnr(other.player_nr), - waytype(other.waytype), pos_nw(other.pos_nw), pos_se(other.pos_se), + waytype(other.waytype), systemtype(other.systemtype), pos_nw(other.pos_nw), pos_se(other.pos_se), hmin(other.hmin), hmax(other.hmax), error(other.error) { } @@ -388,28 +389,28 @@ void scenario_t::forbid_tool(uint8 player_nr, uint16 tool_id) { - forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, invalid_wt); + forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, invalid_wt, type_invalid); call_forbid_tool(test, true); } void scenario_t::allow_tool(uint8 player_nr, uint16 tool_id) { - forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, invalid_wt); + forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, invalid_wt, type_invalid); call_forbid_tool(test, false); } -void scenario_t::forbid_way_tool(uint8 player_nr, uint16 tool_id, waytype_t wt) +void scenario_t::forbid_way_tool(uint8 player_nr, uint16 tool_id, waytype_t wt, systemtype_t st) { - forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, wt); + forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, wt, st); call_forbid_tool(test, true); } void scenario_t::allow_way_tool(uint8 player_nr, uint16 tool_id, waytype_t wt) { - forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, wt); + forbidden_t *test = new forbidden_t(forbidden_t::forbid_tool, player_nr, tool_id, wt, type_invalid); call_forbid_tool(test, false); } @@ -458,14 +459,14 @@ } -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; } // first test the list if (!forbidden_tools.empty()) { - forbidden_t test(forbidden_t::forbid_tool, PLAYER_UNOWNED, tool_id, invalid_wt); + forbidden_t test(forbidden_t::forbid_tool, PLAYER_UNOWNED, tool_id, invalid_wt, type_invalid); uint8 player_nr = player ? player->get_player_nr() : PLAYER_UNOWNED; // first test waytype invalid_wt, then wt @@ -477,7 +478,8 @@ } // logic to test all possible four cases sim::swap( wt, test.waytype ); - if (test.waytype == invalid_wt) { + sim::swap( st, test.systemtype ); + if (test.waytype == invalid_wt || test.systemtype == type_invalid) { sim::swap( player_nr, test.player_nr ); if (test.player_nr == PLAYER_UNOWNED) { break; --- /home/yonatyt/simu-git/simutrans-master/dataobj/scenario.h 2020-03-08 01:52:08.000000000 -0400 +++ /home/yonatyt/simu-git/files/scenario.h 2020-03-18 19:27:29.430128000 -0400 @@ -93,14 +93,15 @@ uint16 toolnr; /// waytype of tool, @see waytype_t sint16 waytype; + sint16 systemtype; koord pos_nw, pos_se; sint8 hmin, hmax; /// error message to be displayed if user tries to work with the tool plainstring error; /// constructor: forbid tool/etc for a certain player - forbidden_t(forbid_type type_=forbid_tool, uint8 player_nr_=255, uint16 toolnr_=0, sint16 waytype_=invalid_wt) : - type(type_), player_nr(player_nr_), toolnr(toolnr_), waytype(waytype_), + forbidden_t(forbid_type type_=forbid_tool, uint8 player_nr_=255, uint16 toolnr_=0, sint16 waytype_=invalid_wt, sint16 systemtype_=type_invalid) : + type(type_), player_nr(player_nr_), toolnr(toolnr_), waytype(waytype_), systemtype(systemtype_), pos_nw(koord::invalid), pos_se(koord::invalid), hmin(-128), hmax(127), error() {}; /// constructor: forbid tool for a certain player at certain locations (and heights) @@ -141,6 +142,7 @@ file->rdwr_byte(player_nr); file->rdwr_short(toolnr); file->rdwr_short(waytype); + file->rdwr_short(systemtype); file->rdwr_short(pos_nw.x); file->rdwr_short(pos_nw.y); file->rdwr_short(pos_se.x); file->rdwr_short(pos_se.y); file->rdwr_byte(hmin); @@ -343,7 +345,7 @@ * @param tool_id id of tool * @param wt waytype */ - void forbid_way_tool(uint8 player_nr, uint16 tool_id, waytype_t wt); + void forbid_way_tool(uint8 player_nr, uint16 tool_id, waytype_t wt, systemtype_t st); /** * @ingroup squirrel-api @@ -402,7 +404,7 @@ * 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_invalid); /** * Checks if player can use the tool at this position. --- /home/yonatyt/simu-git/simutrans-master/simtypes.h 2020-03-12 09:44:15.000000000 -0400 +++ /home/yonatyt/simu-git/files/simtypes.h 2020-03-15 14:25:24.985163000 -0400 @@ -137,6 +137,8 @@ * System types for ways */ enum systemtype_t { + //--------------yona + type_invalid = -1, type_flat = 0, ///< flat track type_elevated = 1, ///< flag for elevated ways type_runway = 1, ///< flag for runway (only aircrafts) --- /home/yonatyt/Descargas/st-code/bauer/wegbauer.cc 2020-03-08 01:52:08.000000000 -0400 +++ /home/yonatyt/simu-git/files/wegbauer.cc 2020-03-23 17:26:06.078580000 -0400 @@ -293,7 +293,7 @@ { // 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; } --- /home/yonatyt/simu-git/simutrans-master/script/api/api_const.cc 2020-03-12 09:44:15.000000000 -0400 +++ /home/yonatyt/simu-git/files/api_const.cc 2020-03-15 16:16:19.781637000 -0400 @@ -158,6 +158,8 @@ * System type could take also other values than the ones defined here. */ begin_enum("way_system_types"); + //-----------------yona + enum_slot(vm, "st_all", type_invalid); /// flat ways enum_slot(vm, "st_flat", type_flat); /// elevated ways --- /home/yonatyt/simu-git/simutrans-master/script/api/squirrel_types_scenario.awk 2020-03-12 09:44:15.000000000 -0400 +++ /home/yonatyt/simu-git/files/squirrel_types_scenario.awk 2020-03-15 15:08:28.788772000 -0400 @@ -263,7 +263,7 @@ export_types["::load_language_file"] = "string(string)" export_types["::forbid_tool"] = "void(integer, integer)" export_types["::allow_tool"] = "void(integer, integer)" - export_types["::forbid_way_tool"] = "void(integer, integer, way_types)" + export_types["::forbid_way_tool"] = "void(integer, integer, way_types, way_system_types)" export_types["::allow_way_tool"] = "void(integer, integer, way_types)" export_types["::forbid_way_tool_rect"] = "void(integer, integer, way_types, coord, coord, string)" export_types["::allow_way_tool_rect"] = "void(integer, integer, way_types, coord, coord)" --- /home/yonatyt/simu-git/simutrans-master/simutrans/script/scenario_base.nut 2020-03-12 09:44:15.000000000 -0400 +++ /home/yonatyt/simu-git/files/scenario_base.nut 2020-03-23 18:07:22.056457000 -0400 @@ -23,6 +23,8 @@ // table containing all waytypes all_waytypes <- [wt_road, wt_rail, wt_water, wt_monorail, wt_maglev, wt_tram, wt_narrowgauge, wt_air, wt_power] +// table containing all systemtypes +all_systemtypes <- [st_flat, st_elevated, st_runway, st_tram] // placeholder array for all the map editing tools map.editing_tools <- [ tool_add_city, tool_change_city_size, tool_land_chain, tool_city_chain,