News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Incorrect snow images

Started by kierongreen, July 02, 2013, 12:04:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kierongreen

While working on new bridge images I've encountered a number of errors in selecting whether snow images should be used for bridges, pillars and ways. Patch attached to fix these:

Index: boden/wege/weg.cc
===================================================================
--- boden/wege/weg.cc    (revision 6573)
+++ boden/wege/weg.cc    (working copy)
@@ -449,7 +449,7 @@
     }
     else {
         // use snow image if above snowline and above ground
-        bool snow = (from->ist_karten_boden()  ||  !from->ist_tunnel())  &&  (get_pos().z >= welt->get_snowline());
+        bool snow = (from->ist_karten_boden()  ||  !from->ist_tunnel())  &&  (get_pos().z >= welt->get_snowline() || welt->get_climate( get_pos().get_2d() ) == arctic_climate  );
         flags &= ~IS_SNOW;
         if(  snow  ) {
             flags |= IS_SNOW;
Index: dings/bruecke.cc
===================================================================
--- dings/bruecke.cc    (revision 6573)
+++ dings/bruecke.cc    (working copy)
@@ -44,14 +44,14 @@
#if MULTI_THREAD>1
             weg0->lock_mutex();
#endif
-            if(img>=bruecke_besch_t::N_Start  &&  img<=bruecke_besch_t::W_Start) {
-                // must take the upper value for the start of the bridge
-                const hang_t::typ slope = gr->get_grund_hang();
-                weg0->set_bild( besch->get_hintergrund( img, welt->get_climate( get_pos().get_2d() ) == arctic_climate  ||  get_pos().z + hang_t::height(slope) >= welt->get_snowline() ) );
-            }
-            else {
-                weg0->set_bild( besch->get_hintergrund( img, welt->get_climate( get_pos().get_2d() ) == arctic_climate  ||  get_pos().z >= welt->get_snowline() ) );
-            }
+            // if on a slope then start of bridge - take the upper value
+            const hang_t::typ slope = gr->get_grund_hang();
+            bool is_snow = welt->get_climate( get_pos().get_2d() ) == arctic_climate  ||  get_pos().z + hang_t::height(slope) >= welt->get_snowline();
+
+            // handle cases where old bridges don't have correct images
+            image_id display_image=besch->get_hintergrund( img, is_snow );
+            weg0->set_bild( display_image );
+
             weg0->set_yoff(-gr->get_weg_yoff() );

             weg0->set_after_bild(IMG_LEER);
@@ -77,7 +77,11 @@

image_id bruecke_t::get_after_bild() const
{
-    return besch->get_vordergrund( img, welt->get_climate( get_pos().get_2d() ) == arctic_climate  ||  get_pos().z + (img >= bruecke_besch_t::N_Start  &&  img <= bruecke_besch_t::W_Start) >= welt->get_snowline() );
+    grund_t *gr=welt->lookup(get_pos());
+    // if on a slope then start of bridge - take the upper value
+    const hang_t::typ slope = gr->get_grund_hang();
+    bool is_snow = welt->get_climate( get_pos().get_2d() ) == arctic_climate  ||  get_pos().z + hang_t::height(slope) >= welt->get_snowline();
+    return besch->get_vordergrund( img, is_snow );
}


Index: dings/pillar.cc
===================================================================
--- dings/pillar.cc    (revision 6573)
+++ dings/pillar.cc    (working copy)
@@ -46,9 +46,9 @@
void pillar_t::calc_bild()
{
     bool hide = false;
+    int height = get_yoff();
     if(  besch->has_pillar_asymmetric()  ) {
         if(  grund_t *gr = welt->lookup(get_pos())  ) {
-            int height = get_yoff();
             hang_t::typ slope = gr->get_grund_hang();
             if(  dir == bruecke_besch_t::NS_Pillar  ) {
                 height += min( corner1(slope), corner2(slope) ) * TILE_HEIGHT_STEP;
@@ -62,7 +62,7 @@
         }

     }
-    bild = hide ? IMG_LEER : besch->get_hintergrund( (bruecke_besch_t::img_t)dir, get_pos().z >= welt->get_snowline()  ||  welt->get_climate( get_pos().get_2d() ) == arctic_climate );
+    bild = hide ? IMG_LEER : besch->get_hintergrund( (bruecke_besch_t::img_t)dir, get_pos().z-height/TILE_HEIGHT_STEP >= welt->get_snowline()  ||  welt->get_climate( get_pos().get_2d() ) == arctic_climate );
}




prissi

Kieron, you should have commit rights; just include your bugfixes.

kierongreen

r6579 | kierongreen | 2013-07-07 17:55:35 +0100 (Sun, 07 Jul 2013) | 1 line

FIX: snow images for ways, pillars and bridges now used correctly


Hopefully I've been more successful in committing files to the svn this time than I was 7 years ago :p