The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: z9999 on June 07, 2009, 07:05:04 PM

Title: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 on June 07, 2009, 07:05:04 PM
This patch will allow you to build city buildings with 8 rotations.
(http://simutrans-germany.com/files/upload/rotate.png)

--- 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);


Title: Re: [patch] Allows 8 rotations for city buildings (hopefully)
Post by: Michael 'Cruzer' 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!
Title: Re: [patch] Allows 8 rotations for city buildings (hopefully)
Post by: VS on June 07, 2009, 08:02:29 PM
Wow, great!
Title: Re: [patch] Allows 8 rotations for city buildings (hopefully)
Post by: z9999 on June 07, 2009, 08:25:38 PM
Quote from: Michael 'Cruzer' 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!

Maybe no, sorry.
What is the big probelm ?
Title: Re: [patch] Allows 8 rotations for city buildings (hopefully)
Post by: gauthier on June 07, 2009, 08:35:20 PM
it would be great for typical buildings of Paris :)
Title: Re: [patch] Allows 8 rotations for city buildings (hopefully)
Post by: The Hood on June 07, 2009, 08:43:25 PM
Let me get this straight - does this mean you can now draw corner-specific buildings?
Title: Re: [patch] Allows 8 rotations for city buildings (hopefully)
Post by: VS 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.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 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)
http://simutrans-germany.com/files/upload/sample-1890.png
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood 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!
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: Michael 'Cruzer' on June 08, 2009, 04:00:55 PM
Quote from: z9999 on June 07, 2009, 08:25:38 PM
Maybe no, sorry.
What is the big probelm ?

Corner buildings actually build randomly, and in 192*192 looks this very strange!
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: Isaac Eiland-Hall on June 08, 2009, 11:02:37 PM
Ooooohhhh.. hope this makes it to trunk :D
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: jamespetts on June 09, 2009, 08:15:59 PM
I like the look of this!
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: prissi 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.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 on June 11, 2009, 09:07:03 AM
This code doesn't conflict with station code.
Additional code aren't required.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: prissi on June 17, 2009, 09:27:37 PM
Did the roration actually worked as intended?
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 on June 18, 2009, 05:36:12 AM
Yes.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: jamespetts on June 18, 2009, 10:01:18 AM
Does this work automatically, or does it require extra information in the .dat files?
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood on June 18, 2009, 10:26:24 AM
And also given which board this is now in, is this patch in trunk already?
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 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.


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



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|
+---+

Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood 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 :)
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 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.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood 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]?
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: z9999 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
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood 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?)
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: jamespetts on June 18, 2009, 09:48:37 PM
It was in the SVN yesterday...
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: prissi on June 18, 2009, 10:04:32 PM
A new makeobj is not really needed, this should work with the current one just fine.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood on June 19, 2009, 09:49:10 PM
It works :-)

(http://simutrans-germany.com/files/upload/corner-shop.jpg)

This is in r161 of Pak128.Britain on SVN (screenshot with r2535 of exe), and will be in the upcoming pak128.Britain release.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: jamespetts 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.
Title: Re: [patch] Allows 8 layouts for city buildings (hopefully)
Post by: The Hood 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.