The International Simutrans Forum

 

Author Topic: [patch] Allows 8 layouts for city buildings (hopefully)  (Read 9928 times)

0 Members and 1 Guest are viewing this topic.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
[patch] Allows 8 layouts for city buildings (hopefully)
« on: June 07, 2009, 07:05:04 PM »
This patch will allow you to build city buildings with 8 rotations.

Code: [Select]
--- a/besch/haus_besch.cc
+++ b/besch/haus_besch.cc
@@ -107,6 +107,10 @@
 const haus_tile_besch_t *haus_besch_t::get_tile(int layout, int x, int y) const
  */
 int haus_besch_t::layout_anpassen(int layout) const
 {
+ if(layout >= 4 && layouts <= 4) {
+ //
+ layout -= 4;
+ }
  if(layout >= 2 && layouts <= 2) {
  // Sind Layout C und D nicht definiert, nehemen wir ersatzweise A und B
  layout -= 2;
diff --git a/dings/gebaeude.cc b/dings/gebaeude.cc
index 61cb3d9..d226ff2 100644
--- a/dings/gebaeude.cc
+++ b/dings/gebaeude.cc
@@ -142,8 +142,8 @@
 gebaeude_t::rotate90()
  uint8 layout = tile->get_layout();
  koord new_offset = tile->get_offset();
 
- if(haus_besch->get_all_layouts()<=4) {
- layout = (layout+3) % haus_besch->get_all_layouts();
+ if(haus_besch->get_utyp() == haus_besch_t::unbekannt  ||  haus_besch->get_all_layouts()<=4) {
+ layout = (layout & 4) + ((layout+3) % haus_besch->get_all_layouts() & 3);
  }
  else {
 
diff --git a/simcity.cc b/simcity.cc
index 75ac660..f1b259d 100644
--- a/simcity.cc
+++ b/simcity.cc
@@ -1927,6 +1927,10 @@ static koord neighbours[] = {
 };
 
 
+// return layout
+static int gebaeude_layout[] = {0,0,1,4,2,0,5,1,3,7,1,0,6,3,2,0};
+
+
 void stadt_t::baue_gebaeude(const koord k)
 {
  grund_t* gr = welt->lookup_kartenboden(k);
@@ -1981,15 +1985,15 @@ void stadt_t::baue_gebaeude(const koord k)
  // we have something to built here ...
  if (h != NULL) {
  // check for pavement
- int streetdir = -1;
+ int streetdir = 0;
  for (int i = 0; i < 8; i++) {
  gr = welt->lookup_kartenboden(k + neighbours[i]);
  if (gr && gr->get_weg_hang() == gr->get_grund_hang()) {
  strasse_t* weg = (strasse_t*)gr->get_weg(road_wt);
  if (weg != NULL) {
- if (i < 4 && streetdir == -1) {
+ if (i < 4) {
  // update directions (SENW)
- streetdir = i;
+ streetdir += (1 << i);
  }
  weg->set_gehweg(true);
  // if not current city road standard, then replace it
@@ -2009,7 +2013,7 @@ void stadt_t::baue_gebaeude(const koord k)
  }
  }
 
- const gebaeude_t* gb = hausbauer_t::baue(welt, NULL, pos, streetdir == -1 ? 0 : streetdir, h);
+ const gebaeude_t* gb = hausbauer_t::baue(welt, NULL, pos, gebaeude_layout[streetdir], h);
  add_gebaeude_to_stadt(gb);
  }
  }
@@ -2140,9 +2144,9 @@ void stadt_t::renoviere_gebaeude(gebaeude_t* gb)
  if (gr != NULL && gr->get_weg_hang() == gr->get_grund_hang()) {
  strasse_t* weg = static_cast<strasse_t*>(gr->get_weg(road_wt));
  if (weg != NULL) {
- if (i < 4 && streetdir == 0) {
- // update directions (NESW)
- streetdir = i;
+ if (i < 4) {
+ // update directions (SENW)
+ streetdir += (1 << i);
  }
  weg->set_gehweg(true);
  // if not current city road standard, then replace it
@@ -2176,7 +2180,7 @@ void stadt_t::renoviere_gebaeude(gebaeude_t* gb)
  }
 
  // exchange building; try to face it to street in front
- gb->set_tile( h->get_tile(streetdir, 0, 0) );
+ gb->set_tile( h->get_tile(gebaeude_layout[streetdir], 0, 0) );
  welt->lookup(k)->get_kartenboden()->calc_bild();
  update_gebaeude_from_stadt(gb);
 
« Last Edit: June 07, 2009, 09:58:42 PM by z9999 »

Offline Michael 'Cruzer'

  • Devotee
  • *
  • Posts: 206
  • Founder of pak192.comic
    • Marktplatz für Parkplätze
  • Languages: DE, EN
Re: [patch] Allows 8 rotations for city buildings (hopefully)
« Reply #1 on: June 07, 2009, 07:45:38 PM »
Does this means, that the buildings always rotaade to the road? If yes, it is the greatest patch ever! This patch could slove the big probelm of pak192.comic!

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: [patch] Allows 8 rotations for city buildings (hopefully)
« Reply #2 on: June 07, 2009, 08:02:29 PM »
Wow, great!

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 rotations for city buildings (hopefully)
« Reply #3 on: June 07, 2009, 08:25:38 PM »
Does this means, that the buildings always rotaade to the road? If yes, it is the greatest patch ever! This patch could slove the big probelm of pak192.comic!

Maybe no, sorry.
What is the big probelm ?

Offline gauthier

  • Devotees (Inactive)
  • *
  • Posts: 3628
    • SNFOS'website (in both FR and EN)
  • Languages: FR, EN, JP
Re: [patch] Allows 8 rotations for city buildings (hopefully)
« Reply #4 on: June 07, 2009, 08:35:20 PM »
it would be great for typical buildings of Paris :)

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 rotations for city buildings (hopefully)
« Reply #5 on: June 07, 2009, 08:43:25 PM »
Let me get this straight - does this mean you can now draw corner-specific buildings?

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: [patch] Allows 8 rotations for city buildings (hopefully)
« Reply #6 on: June 07, 2009, 09:25:03 PM »
Looks like yes - if you get the other 4 rotations before, that is!? I guess you just have to declare it as having 8 rotations to get the corner ones.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #7 on: June 07, 2009, 10:00:13 PM »
Main purpose of this patch is that corner buildings won't to be built without corner.

In current simutrans, same buildings are not built next to each other.
So, if you want to use corner, you need to make 2 same buildings with 8 layouts.

Image of year 1890 for test.

http://simutrans-germany.com/files/upload/sample-1890.png

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #8 on: June 08, 2009, 08:06:45 AM »
Ooo, nice to see pakBritain used to test the concept - this code is exactly what I'd hoped for those corner shops!

Offline Michael 'Cruzer'

  • Devotee
  • *
  • Posts: 206
  • Founder of pak192.comic
    • Marktplatz für Parkplätze
  • Languages: DE, EN
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #9 on: June 08, 2009, 04:00:55 PM »
Maybe no, sorry.
What is the big probelm ?

Corner buildings actually build randomly, and in 192*192 looks this very strange!

Offline Isaac Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3924
  • Providing hosting for Simutrans projects
    • pc2.io
  • Languages: EN
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #10 on: June 08, 2009, 11:02:37 PM »
Ooooohhhh.. hope this makes it to trunk :D

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #11 on: June 09, 2009, 08:15:59 PM »
I like the look of this!

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #12 on: June 11, 2009, 08:22:46 AM »
There is probably some additional code needed for the building oritentation of stations in hausbauer_t, as every building with layout>4 in the builder routine is supposed to be a station, if memory serves me right.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #13 on: June 11, 2009, 09:07:03 AM »
This code doesn't conflict with station code.
Additional code aren't required.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #14 on: June 17, 2009, 09:27:37 PM »
Did the roration actually worked as intended?

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #15 on: June 18, 2009, 05:36:12 AM »
Yes.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #16 on: June 18, 2009, 10:01:18 AM »
Does this work automatically, or does it require extra information in the .dat files?

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #17 on: June 18, 2009, 10:26:24 AM »
And also given which board this is now in, is this patch in trunk already?

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #18 on: June 18, 2009, 12:25:08 PM »
Now in trunk, but not yet on nightly site.

Code I used for test is below.
In pak128.Britain, east and west of all building is wrong. So, you need to change all. As prissi wrote, it is SENW.

Code: [Select]
Obj=building
Name=KG_COM_1880_0
copyright=Kieron
type=com
chance=20
Level=10
intro_year=1880
retire_year=1910
needs_ground=1
dims=1,1,8

BackImage[0][0][0][0][0]=images/com/1880-terrace-row-shop.2
BackImage[1][0][0][0][0]=images/com/1880-terrace-row-shop.1
BackImage[2][0][0][0][0]=images/com/1880-terrace-row-shop.0
BackImage[3][0][0][0][0]=images/com/1880-terrace-row-shop.3
BackImage[4][0][0][0][0]=images/com/1880-terrace-corner-shop.1
BackImage[5][0][0][0][0]=images/com/1880-terrace-corner-shop.0
BackImage[6][0][0][0][0]=images/com/1880-terrace-corner-shop.3
BackImage[7][0][0][0][0]=images/com/1880-terrace-corner-shop.2
----
Obj=building
Name=KG_COM_1880_1
copyright=Kieron
type=com
chance=20
Level=8
intro_year=1880
retire_year=1910
needs_ground=1
dims=1,1,8

BackImage[0][0][0][0][0]=images/com/1880-terrace-row-shop.2
BackImage[1][0][0][0][0]=images/com/1880-terrace-row-shop.1
BackImage[2][0][0][0][0]=images/com/1880-terrace-row-shop.0
BackImage[3][0][0][0][0]=images/com/1880-terrace-row-shop.3
BackImage[4][0][0][0][0]=images/com/1880-terrace-corner-shop.1
BackImage[5][0][0][0][0]=images/com/1880-terrace-corner-shop.0
BackImage[6][0][0][0][0]=images/com/1880-terrace-corner-shop.3
BackImage[7][0][0][0][0]=images/com/1880-terrace-corner-shop.2
----
Obj=building
Name=KG_COM_1880_2
copyright=Kieron
type=com
chance=20
Level=6
intro_year=1880
retire_year=1910
needs_ground=1
dims=1,1,4

BackImage[0][0][0][0][0]=images/com/1880-terrace-row-shop-2f.2
BackImage[1][0][0][0][0]=images/com/1880-terrace-row-shop-2f.1
BackImage[2][0][0][0][0]=images/com/1880-terrace-row-shop-2f.0
BackImage[3][0][0][0][0]=images/com/1880-terrace-row-shop-2f.3

Code: [Select]
dims=1,1,1
+---+
|000|
|0 0|
|000|
+---+
dims=1,1,2
+---+
|001|
|1 1|
|100|
+---+
dims=1,1,4
+---+
|221|
|3 1|
|300|
+---+
dims=1,1,8
+---+
|625|
|3 1|
|704|
+---+

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #19 on: June 18, 2009, 12:43:45 PM »
OK thanks - I'll test the buildings orientations and make sure pak128.Britain takes advantage of this new feature :)

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #20 on: June 18, 2009, 12:46:06 PM »
Sorry, I was wrong.

In pak128.Britain, east and west of all building is wrong.
In pak128.Britain, north and south of all building is wrong.

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #21 on: June 18, 2009, 12:53:35 PM »
Sorry - are you saying that in SVN I need to flip the images for [ 0] and [2] or [1] and [3]?

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #22 on: June 18, 2009, 07:47:15 PM »
[ 0] and [2], isn't it ?
Sorry if it was wrong, I don't know british buildings well.

[ 0]... face to southern road
[1]... face to eastern road
[2]... face to northern road
[3]... face to western road

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #23 on: June 18, 2009, 09:40:16 PM »
The sources I have in my dev-version work facing the road in all orientations (with r2447), but the sources on SVN aren't right.  I'll update the SVN, but first I'll wait for the 8 rotations and new makeobj and include the corner shops (tomorrow presumably if it's committed now?)

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #24 on: June 18, 2009, 09:48:37 PM »
It was in the SVN yesterday...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #25 on: June 18, 2009, 10:04:32 PM »
A new makeobj is not really needed, this should work with the current one just fine.

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #26 on: June 19, 2009, 09:49:10 PM »
It works :-)



This is in r161 of Pak128.Britain on SVN (screenshot with r2535 of exe), and will be in the upcoming pak128.Britain release.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #27 on: June 19, 2009, 10:15:07 PM »
I like! Can you set those gasometers to corner only, too? They occur rather too frequently as it currently stands.

Offline The Hood

  • Devotees (Inactive)
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [patch] Allows 8 layouts for city buildings (hopefully)
« Reply #28 on: June 20, 2009, 07:14:48 AM »
The gasometers occur frequently because there are very few industrial citybuildings, especially with timeline on.  Besides I don't like those graphics, so they will get the chop when I next do some citybuildings.