diff --git a/simmenu.cc b/simmenu.cc index b4887dfaf..3fe616db2 100644 --- a/simmenu.cc +++ b/simmenu.cc @@ -119,6 +119,7 @@ tool_t *create_general_tool(int toolnr) case TOOL_ERROR_MESSAGE: tool = new tool_error_message_t(); break; case TOOL_CHANGE_WATER_HEIGHT: tool = new tool_change_water_height_t(); break; case TOOL_SET_CLIMATE: tool = new tool_set_climate_t(); break; + case TOOL_ROTATE_STATION: tool = new tool_rotate_station_t(); break; default: dbg->error("create_general_tool()","cannot satisfy request for general_tool[%i]!",toolnr); return NULL; } @@ -268,7 +269,7 @@ void general_tool_get_desc_builder(uint16 id, const char *param_str, const obj_d // The following 3's descriptions are registered by hausbauer_t. case TOOL_BUILD_DEPOT: case TOOL_BUILD_STATION: - case TOOL_HEADQUARTER: { + case TOOL_HEADQUARTER: { const building_desc_t* desc2 = hausbauer_t::get_desc(param_str); desc = desc2; tool = desc2->get_builder(); diff --git a/simmenu.h b/simmenu.h index 91e991919..c477b08e6 100644 --- a/simmenu.h +++ b/simmenu.h @@ -72,6 +72,7 @@ enum { TOOL_ERROR_MESSAGE, TOOL_CHANGE_WATER_HEIGHT, TOOL_SET_CLIMATE, + TOOL_ROTATE_STATION, GENERAL_TOOL_COUNT, GENERAL_TOOL = 0x1000 }; diff --git a/simmenu.h.gch b/simmenu.h.gch new file mode 100644 index 000000000..98d6fdf28 Binary files /dev/null and b/simmenu.h.gch differ diff --git a/simtool.cc b/simtool.cc index 6a3ac0953..4affe260c 100644 --- a/simtool.cc +++ b/simtool.cc @@ -4270,6 +4270,15 @@ DBG_MESSAGE("tool_station_aux()", "building %s on square %d,%d for waytype %x", layout |= 8-(neighbour_layout[senkrecht & next_own & ribi_t::southeast]&8); } } + // invert layout if shift pressed + if ( is_shift_pressed() ) { + layout ^= 8; + } + } + } + else { + if ( is_shift_pressed() ) { + layout ^= 8; } } // avoid orientation on 8 tiled buildings @@ -4608,6 +4617,77 @@ const char *tool_build_station_t::work( player_t *player, koord3d pos ) } +const char *tool_rotate_station_t::tool_rotate_platform(player_t *player, koord3d pos) +{ + koord k = pos.get_2d(); + + grund_t *bd = welt->lookup(pos); + halthandle_t halt = bd->get_halt(); + + if( !bd || bd->get_weg_hang()!=slope_t::flat ) { + // only flat tiles, only one stop per map square + return "No suitable way on the ground!"; + } + + if( bd->ist_tunnel() && bd->ist_karten_boden() ) { + // do not build on tunnel entries + return "No suitable way on the ground!"; + } + + if( bd->get_depot() ) { + // not on depots + return NOTICE_UNSUITABLE_GROUND; + } + + if( bd->hat_weg(air_wt) && bd->get_weg(air_wt)->get_desc()->get_styp()!=type_flat ) { + return "Flugzeughalt muss auf\nRunway liegen!\n"; + } + + if( bd && !bd->get_halt().is_bound() ) { + // if there's no platform + return "There's no platforms!\n"; + } + + uint32 layout = 0; + + if( bd && bd->get_halt().is_bound() ) { + // check, if there is an oriented stop + const gebaeude_t* gb = bd->find(); + if(gb && gb->get_tile()->get_desc()->get_all_layouts()>4 && (gb->get_tile()->get_desc()->get_type()>building_desc_t::dock || gb->get_tile()->get_desc()->get_type()>building_desc_t::flat_dock) ) { + layout = gb->get_tile()->get_layout(); + } + + if( gb->get_tile()->get_desc()->get_all_layouts() == 16 ) { + layout ^= 8; + hausbauer_t::build_station_extension_depot(halt->get_owner(), bd->get_pos(), layout, gb->get_tile()->get_desc(), &halt); + } + delete gb; + } + + return NULL; +} + +const char *tool_rotate_station_t::work( player_t *player, koord3d pos ) +{ + const grund_t *gr = welt->lookup(pos); + if(!gr) { + return ""; + } + + // ownership allowed? + halthandle_t halt = gr->get_halt(); + if(halt.is_bound() && !player_t::check_owner( player, halt->get_owner())) { + return "Das Feld gehoert\neinem anderen Spieler\n"; + } + + // check underground / above ground + if (const char* msg = check_pos(player, pos)) { + return msg; + } + + return tool_rotate_station_t::tool_rotate_platform(player, pos); +} + char const* tool_build_roadsign_t::get_tooltip(player_t const*) const { const roadsign_desc_t * desc = roadsign_t::find_desc(default_param); diff --git a/simtool.h b/simtool.h index cf43f3023..dfeba7fa2 100644 --- a/simtool.h +++ b/simtool.h @@ -399,6 +399,17 @@ public: waytype_t get_waytype() const OVERRIDE; }; +class tool_rotate_station_t : public tool_t { +private: + const char *tool_rotate_platform(player_t *, koord3d); + +public: + tool_rotate_station_t() : tool_t(TOOL_ROTATE_STATION | GENERAL_TOOL) {} + char const* get_tooltip(player_t const*) const OVERRIDE { return translator::translate("Rotate Platform"); } + char const* work(player_t*, koord3d) OVERRIDE; + bool is_init_network_save() const OVERRIDE { return true; } +}; + // builds roadsigns and signals class tool_build_roadsign_t : public two_click_tool_t { private: diff --git a/simtool.h.gch b/simtool.h.gch new file mode 100644 index 000000000..cf9200df4 Binary files /dev/null and b/simtool.h.gch differ