News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

[patch] Allows 8 layouts for city buildings (hopefully)

Started by z9999, June 07, 2009, 07:05:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

z9999

This patch will allow you to build city buildings with 8 rotations.


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



Michael 'Cruzer'

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!
Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

VS


My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

z9999

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 ?


The Hood

Let me get this straight - does this mean you can now draw corner-specific buildings?

VS

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.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

z9999

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

The Hood

Ooo, nice to see pakBritain used to test the concept - this code is exactly what I'd hoped for those corner shops!

Michael 'Cruzer'

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!
Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

Isaac Eiland-Hall


jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

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.

z9999

This code doesn't conflict with station code.
Additional code aren't required.

prissi



jamespetts

Does this work automatically, or does it require extra information in the .dat files?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

The Hood

And also given which board this is now in, is this patch in trunk already?

z9999

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


The Hood

OK thanks - I'll test the buildings orientations and make sure pak128.Britain takes advantage of this new feature :)

z9999

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.

The Hood

Sorry - are you saying that in SVN I need to flip the images for [ 0] and [2] or [1] and [3]?

z9999

[ 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

The Hood

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

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

A new makeobj is not really needed, this should work with the current one just fine.

The Hood

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.

jamespetts

I like! Can you set those gasometers to corner only, too? They occur rather too frequently as it currently stands.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

The Hood

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.