diff --git a/script/api/changelog.h.gch b/script/api/changelog.h.gch new file mode 100644 index 000000000..b0968dfd9 Binary files /dev/null and b/script/api/changelog.h.gch differ diff --git a/simmenu.cc b/simmenu.cc index 7471f8983..044e553d7 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_BUILDING: tool = new tool_rotate_building_t(); break; default: dbg->error("create_general_tool()","cannot satisfy request for general_tool[%i]!",toolnr); return NULL; } @@ -269,7 +270,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 80698a77a..6b6be0cdd 100644 --- a/simmenu.h +++ b/simmenu.h @@ -72,6 +72,7 @@ enum { TOOL_ERROR_MESSAGE, TOOL_CHANGE_WATER_HEIGHT, TOOL_SET_CLIMATE, + TOOL_ROTATE_BUILDING, GENERAL_TOOL_COUNT, GENERAL_TOOL = 0x1000 }; diff --git a/simmenu.h.gch b/simmenu.h.gch new file mode 100644 index 000000000..6b995d4c5 Binary files /dev/null and b/simmenu.h.gch differ diff --git a/simtool.cc b/simtool.cc index 20ae588ba..92710b114 100644 --- a/simtool.cc +++ b/simtool.cc @@ -4273,6 +4273,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 @@ -4611,6 +4620,150 @@ const char *tool_build_station_t::work( player_t *player, koord3d pos ) } +const char *tool_rotate_building_t::tool_rotate_platform(koord3d pos) +{ + 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 "No platform here!\n"; + } + + // rotate platforms + if( bd && bd->get_halt().is_bound() ) { + // check, if there is an oriented stop + gebaeude_t* gb = bd->find(); + const building_tile_desc_t *tile = gb->get_tile(); + const building_desc_t *desc = tile->get_desc(); + uint32 layout = tile->get_layout(); + uint32 all_layouts = desc->get_all_layouts(); + if( gb && all_layouts == 16 && bd->hat_wege() ) { + layout ^= 8; + hausbauer_t::build_station_extension_depot(halt->get_owner(), pos, layout, desc, &halt); + delete gb; +DBG_MESSAGE("tool_rotate_platform()", "rotated platform at (%d,%d)", pos.x, pos.y); + } + // rotate station buildings + else if( gb && all_layouts > 1 && !bd->hat_wege() ) { + koord size = desc->get_size( layout ); + player_t *owner = halt->get_owner(); + if( size.x == size.y ) { + const koord3d orgpos = pos - koord3d( tile->get_offset(), 0 ); + koord k; + // delete building + for(k.y = 0; k.y < size.y; k.y ++) { + for(k.x = 0; k.x < size.x; k.x ++) { + grund_t *gr = welt->lookup(koord3d(k,0)+orgpos); + if(gr) { + gebaeude_t *gb_part = gr->find(); + if( gb_part && gb_part->get_tile()==desc->get_tile(layout, k.x, k.y) ) { + delete gb_part; + haltestelle_t::remove(owner, gr->get_pos()); + if(gr->get_typ()==grund_t::fundament) { + const koord newk = k+orgpos.get_2d(); + sint8 new_hgt; + const uint8 new_slope = welt->recalc_natural_slope(newk,new_hgt); + const grund_t *gr2 = welt->lookup(koord3d(newk,new_hgt)); + if( (gr2==NULL || gr2==gr) && new_slope!=slope_t::flat ) { + gr2 = welt->lookup(koord3d(newk, new_hgt+1)); + } + if( gr2 && gr2!=gr ) { + welt->access(newk)->kartenboden_setzen( new boden_t( pos, slope_t::flat ) ); + } + else if( new_hgt <= welt->get_water_hgt(newk) && new_slope == slope_t::flat ) { + welt->access(newk)->kartenboden_setzen( new wasser_t( koord3d( newk, new_hgt ) ) ); + } + else { + welt->access(newk)->kartenboden_setzen( new boden_t( koord3d( newk, new_hgt ), new_slope ) ); + } + } + } + } + } + } + // rebuild it + layout = (layout + 1) % all_layouts; + hausbauer_t::build(owner, orgpos, layout, desc, &halt ); +DBG_MESSAGE("tool_rotate_platform()", "rotated station building at (%d,%d)", orgpos.x, orgpos.y); + } + } + } + + return NULL; +} + +const char *tool_rotate_building_t::tool_rotate_building(koord3d pos) +{ + const grund_t* gr = welt->lookup_kartenboden(pos.get_2d()); + gebaeude_t* gb = gr->find(); + koord3d orgpos = gb->get_first_tile()->get_pos(); + const building_desc_t* desc = gb->get_tile()->get_desc(); + uint32 layout = gb->get_tile()->get_layout(); + uint32 all_layouts = desc->get_all_layouts(); + player_t* owner = gb->get_owner(); + koord dim = desc->get_size(); + if ( all_layouts > 1 && dim.x == dim.y ) { + layout = (layout + 1) % all_layouts; + delete gb; + hausbauer_t::build(owner, orgpos, layout, desc); +DBG_MESSAGE("tool_rotate_building()", "rotate building at (%d,%d)", orgpos.x, orgpos.y); + } + return NULL; +} + +const char *tool_rotate_building_t::work( player_t *player, koord3d pos ) +{ + const grund_t *gr = welt->lookup(pos); + if(!gr) { + return ""; + } + + // Is there a station? + halthandle_t halt = gr->get_halt(); + if (halt.is_bound()) + { + // ownership allowed? + 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_building_t::tool_rotate_platform(pos); + } + + const gebaeude_t* gb = gr->find(); + // Is there a building? + if (gb) { + return tool_rotate_building_t::tool_rotate_building(pos); + } + + return ""; +} + 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..287639c1a 100644 --- a/simtool.h +++ b/simtool.h @@ -399,6 +399,18 @@ public: waytype_t get_waytype() const OVERRIDE; }; +class tool_rotate_building_t : public tool_t { +private: + const char *tool_rotate_platform(koord3d); + const char *tool_rotate_building(koord3d); + +public: + tool_rotate_building_t() : tool_t(TOOL_ROTATE_BUILDING | GENERAL_TOOL) {} + char const* get_tooltip(player_t const*) const OVERRIDE { return translator::translate("Rotate Building"); } + 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..32fc8c0c9 Binary files /dev/null and b/simtool.h.gch differ diff --git a/simutrans/music/43-Driving-on-the-midnight-highway.mid b/simutrans/music/43-Driving-on-the-midnight-highway.mid index e4b3f048c..e69de29bb 100644 Binary files a/simutrans/music/43-Driving-on-the-midnight-highway.mid and b/simutrans/music/43-Driving-on-the-midnight-highway.mid differ diff --git a/simutrans/music/44-Above-the-sky.mid b/simutrans/music/44-Above-the-sky.mid index 152a85e84..e69de29bb 100644 Binary files a/simutrans/music/44-Above-the-sky.mid and b/simutrans/music/44-Above-the-sky.mid differ diff --git a/simutrans/music/45-Misty-Forest.mid b/simutrans/music/45-Misty-Forest.mid index 3db804c97..e69de29bb 100644 Binary files a/simutrans/music/45-Misty-Forest.mid and b/simutrans/music/45-Misty-Forest.mid differ diff --git a/simutrans/music/46-House-in-the-station.mid b/simutrans/music/46-House-in-the-station.mid index b248e5399..e69de29bb 100644 Binary files a/simutrans/music/46-House-in-the-station.mid and b/simutrans/music/46-House-in-the-station.mid differ