Skip to content

Commit a5153d6

Browse files
committed
FIX: multitile city building totally renovated, 3x faster city growth (at the start of the map in debug mode)
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11707 8aca7d54-2c30-db11-9de9-000461428c89
1 parent 87b7420 commit a5153d6

File tree

8 files changed

+445
-394
lines changed

8 files changed

+445
-394
lines changed

simutrans/history.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ Release of 124.3.1 (r11671 on 5-Apr-2025):
2828
ADD: CURRENCY is now translateable to a local currency (no conversions though) and can be also modified by the user
2929
FIX: make sure, the pak path and working path are really different
3030
FIX: single way tile did not force bridge direction
31-
FIX: multitile city building had not all tiles beloging to a city and crshing on deletion
32-
31+
FIX: multitile city building totally renovated, 3x faster city growth (at the start of the map in debug mode)
3332

3433
Release of 124.3 (r11590 on 10-Jan-2025):
3534
FIX: open schedule get applied during rw (reload, quit, change language), line window crashes

src/simutrans/builder/hausbauer.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ bool hausbauer_t::successfully_loaded()
144144

145145
if (desc->is_city_building()) {
146146
// find city build sizes
147-
sint16 max_size = max(desc->get_x(), desc->get_y());
148-
if (max_size > 3) {
149-
dbg->fatal("hausbauer_t::successfully_loaded()", "maximum city building size (3x3) but %s is (%sx%i)", desc->get_name(), desc->get_x(), desc->get_y());
147+
sint16 max_size = desc->get_area();
148+
if (max_size > 9) {
149+
dbg->warning("hausbauer_t::successfully_loaded()", "maximum city building size (3x3) but %s is (%ix%i)", desc->get_name(), desc->get_x(), desc->get_y());
150150
}
151-
if (largest_city_building_area < max_size) {
151+
else if (largest_city_building_area < max_size) {
152+
dbg->message("hausbauer_t::successfully_loaded()", "maximum city building size %s is (%ix%i)", desc->get_name(), desc->get_x(), desc->get_y());
152153
largest_city_building_area = max_size;
153154
}
154155
}
@@ -484,7 +485,8 @@ gebaeude_t* hausbauer_t::build(player_t* player, koord pos, int org_layout, cons
484485
}
485486
}
486487
// now build it
487-
return city->build_city_house(koord3d(pos, base_height), desc, layout);
488+
vector_tpl<const building_desc_t*>ex;
489+
return city->build_city_house(koord3d(pos, base_height), desc, layout, 0, &ex);
488490
}
489491

490492
sint8 base_h = -128;
@@ -885,7 +887,7 @@ const building_desc_t* hausbauer_t::get_special(uint32 bev, building_desc_t::bty
885887
* @param start_level the minimum level of the house/station
886888
* @param cl allowed climates
887889
*/
888-
static const building_desc_t* get_city_building_from_list(const vector_tpl<const building_desc_t*>& list, int start_level, uint16 time, climate cl, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*>* exclude )
890+
static const building_desc_t* get_city_building_from_list(const vector_tpl<const building_desc_t*>& list, int start_level, uint16 time, climate cl, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*>* exclude )
889891
{
890892
weighted_vector_tpl<const building_desc_t *> selections(16);
891893
int level = start_level;
@@ -908,10 +910,8 @@ static const building_desc_t* get_city_building_from_list(const vector_tpl<const
908910
desc->get_distribution_weight() > 0 &&
909911
desc->is_available(time) &&
910912
// size check
911-
( (desc->get_x() <= maxsize.x && desc->get_y() <= maxsize.y &&
912-
desc->get_x() >= minsize.x && desc->get_y() >= minsize.y ) ||
913-
(desc->get_x() <= maxsize.y && desc->get_y() <= maxsize.x &&
914-
desc->get_x() >= minsize.y && desc->get_y() >= minsize.x ) ) ) {
913+
(desc->get_area()>=minsize && desc->get_area() <= maxsize)
914+
) {
915915
desc_at_least = desc;
916916
if( thislevel == level ) {
917917
if(!exclude || !exclude->is_contained(desc)) {
@@ -948,19 +948,19 @@ static const building_desc_t* get_city_building_from_list(const vector_tpl<const
948948
}
949949

950950

951-
const building_desc_t* hausbauer_t::get_commercial(int level, uint16 time, climate cl, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*>* exclude)
951+
const building_desc_t* hausbauer_t::get_commercial(int level, uint16 time, climate cl, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*>* exclude)
952952
{
953953
return get_city_building_from_list(city_commercial, level, time, cl, clusters, minsize, maxsize, exclude );
954954
}
955955

956956

957-
const building_desc_t* hausbauer_t::get_industrial(int level, uint16 time, climate cl, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*>* exclude)
957+
const building_desc_t* hausbauer_t::get_industrial(int level, uint16 time, climate cl, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*>* exclude)
958958
{
959959
return get_city_building_from_list(city_industry, level, time, cl, clusters, minsize, maxsize, exclude );
960960
}
961961

962962

963-
const building_desc_t* hausbauer_t::get_residential(int level, uint16 time, climate cl, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*> *exclude)
963+
const building_desc_t* hausbauer_t::get_residential(int level, uint16 time, climate cl, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*> *exclude)
964964
{
965965
return get_city_building_from_list(city_residential, level, time, cl, clusters, minsize, maxsize, exclude );
966966
}

src/simutrans/builder/hausbauer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ class hausbauer_t
8585
static void fill_menu(tool_selector_t* tool_selector, building_desc_t::btype, waytype_t wt, sint16 sound_ok);
8686

8787
/// @returns a random commercial building matching the requirements.
88-
static const building_desc_t* get_commercial(int level, uint16 time, climate c, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*>* exclude = NULL);
88+
static const building_desc_t* get_commercial(int level, uint16 time, climate c, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*>* exclude = NULL);
8989

9090
/// @returns a random industrial building matching the requirements.
91-
static const building_desc_t* get_industrial(int level, uint16 time, climate cl, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*>* exclude = NULL);
91+
static const building_desc_t* get_industrial(int level, uint16 time, climate cl, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*>* exclude = NULL);
9292

9393
/// @returns a random residential building matching the requirements.
94-
static const building_desc_t* get_residential(int level, uint16 time, climate cl, uint32 clusters, koord minsize, koord maxsize, vector_tpl<const building_desc_t*>* exclude = NULL);
94+
static const building_desc_t* get_residential(int level, uint16 time, climate cl, uint32 clusters, sint16 minsize, sint16 maxsize, vector_tpl<const building_desc_t*>* exclude = NULL);
9595

9696
/// @returns headquarters with level @p level (takes the first matching one)
9797
static const building_desc_t* get_headquarters(int level, uint16 time);

src/simutrans/ground/boden.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class boden_t : public grund_t
2727
void rdwr(loadsave_t *file) OVERRIDE;
2828

2929
/// @copydoc grund_t::ist_natur
30-
inline bool ist_natur() const OVERRIDE { return !hat_wege() && !is_halt(); }
30+
bool ist_natur() const OVERRIDE {
31+
return (flags & (is_halt_flag | has_way1 | has_way2))==0;
32+
// equivalen to return !hat_wege() && !is_halt();
33+
}
3134

3235
/// @copydoc grund_t::get_name
3336
const char *get_name() const OVERRIDE;

src/simutrans/obj/gebaeude.cc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,6 @@ void gebaeude_t::info(cbuffer_t & buf) const
838838
#ifdef DEBUG
839839
buf.append( "\n\nrotation " );
840840
buf.append( tile->get_layout(), 0 );
841-
buf.append( " best layout " );
842-
buf.append( stadt_t::orient_city_building( get_pos().get_2d() - tile->get_offset(), tile->get_desc(), koord(3,3) ), 0 );
843841
buf.append( "\n" );
844842
#endif
845843
}
@@ -929,9 +927,9 @@ void gebaeude_t::rdwr(loadsave_t *file)
929927
switch(type) {
930928
case building_desc_t::city_res:
931929
{
932-
const building_desc_t *bdsc = hausbauer_t::get_residential( level, welt->get_timeline_year_month(), welt->get_climate( get_pos().get_2d() ), 0, koord(1,1), koord(1,1) );
930+
const building_desc_t *bdsc = hausbauer_t::get_residential( level, welt->get_timeline_year_month(), welt->get_climate( get_pos().get_2d() ), 0, 1, 1 );
933931
if(bdsc==NULL) {
934-
bdsc = hausbauer_t::get_residential(level,0, MAX_CLIMATES, 0, koord(1,1), koord(1,1) );
932+
bdsc = hausbauer_t::get_residential(level,0, MAX_CLIMATES, 0, 1, 1 );
935933
}
936934
if( bdsc) {
937935
dbg->message("gebaeude_t::rwdr", "replace unknown building %s with residence level %i by %s",buf,level,bdsc->get_name());
@@ -943,9 +941,9 @@ void gebaeude_t::rdwr(loadsave_t *file)
943941
case building_desc_t::city_com:
944942
{
945943
// for replacement, ignore cluster and size
946-
const building_desc_t *bdsc = hausbauer_t::get_commercial( level, welt->get_timeline_year_month(), welt->get_climate( get_pos().get_2d() ), 0, koord(1,1), koord(1,1) );
944+
const building_desc_t *bdsc = hausbauer_t::get_commercial( level, welt->get_timeline_year_month(), welt->get_climate( get_pos().get_2d() ), 0, 1, 1 );
947945
if(bdsc==NULL) {
948-
bdsc = hausbauer_t::get_commercial(level, 0, MAX_CLIMATES, 0, koord(1,1), koord(1,1) );
946+
bdsc = hausbauer_t::get_commercial(level, 0, MAX_CLIMATES, 0, 1, 1 );
949947
}
950948
if(bdsc) {
951949
dbg->message("gebaeude_t::rwdr", "replace unknown building %s with commercial level %i by %s",buf,level,bdsc->get_name());
@@ -956,11 +954,11 @@ void gebaeude_t::rdwr(loadsave_t *file)
956954

957955
case building_desc_t::city_ind:
958956
{
959-
const building_desc_t *bdsc = hausbauer_t::get_industrial( level, welt->get_timeline_year_month(), welt->get_climate( get_pos().get_2d() ), 0, koord(1,1), koord(1,1) );
957+
const building_desc_t *bdsc = hausbauer_t::get_industrial( level, welt->get_timeline_year_month(), welt->get_climate( get_pos().get_2d() ), 0, 1, 1 );
960958
if(bdsc==NULL) {
961-
bdsc = hausbauer_t::get_industrial(level, 0, MAX_CLIMATES, 0, koord(1,1), koord(1,1) );
959+
bdsc = hausbauer_t::get_industrial(level, 0, MAX_CLIMATES, 0, 1, 1 );
962960
if(bdsc==NULL) {
963-
bdsc = hausbauer_t::get_residential(level, 0, MAX_CLIMATES, 0, koord(1,1), koord(1,1) );
961+
bdsc = hausbauer_t::get_residential(level, 0, MAX_CLIMATES, 0, 1, 1 );
964962
}
965963
}
966964
if (bdsc) {

src/simutrans/tool/simtool.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5863,7 +5863,8 @@ const char *tool_build_house_t::work( player_t *player, koord3d pos )
58635863
else if( default_param[1]=='A' ) {
58645864
if( desc->get_type()!=building_desc_t::attraction_land && desc->get_type()!=building_desc_t::attraction_city ) {
58655865
// auto rotation only valid for city buildings
5866-
rotation = stadt_t::orient_city_building( k, desc, desc->get_size() );
5866+
koord max_size(max(desc->get_size().x, desc->get_size().y), max(desc->get_size().x, desc->get_size().y));
5867+
rotation = stadt_t::orient_city_building( k, desc, max_size);
58675868
if( rotation < 0 ) {
58685869
return NOTICE_UNSUITABLE_GROUND;
58695870
}

0 commit comments

Comments
 (0)