The International Simutrans Forum

 

Author Topic: Fix compilation for rarely-used defines  (Read 335 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 250
Fix compilation for rarely-used defines
« on: July 07, 2020, 09:16:47 AM »
This patch fixes compile errors when some rarely-used defines like DEBUG_ROUTES are defined.

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: Fix compilation for rarely-used defines
« Reply #1 on: July 09, 2020, 10:34:58 AM »
Many thanks ceeac. Reviewed and committed to trunk in 9162.

Notes:

Code: [Select]
diff --git bauer/wegbauer.cc bauer/wegbauer.cc
index 1550fb6aaf..a46b52880c 100644
--- bauer/wegbauer.cc
+++ bauer/wegbauer.cc
@@ -1477,7 +1477,7 @@ DBG_DEBUG("insert to close","(%i,%i,%i)  f=%i",gr->get_pos().x,gr->get_pos().y,g
             if((step&0x03)==0) {
                 INT_CHECK( "wegbauer 1347" );
 #ifdef DEBUG_ROUTES
-                if((step&1023)==0) {minimap_t::get_karte()->calc_map();}
+                if((step&1023)==0) {minimap_t::get_instance()->calc_map();}
 #endif
             }
 
@@ -1986,7 +1986,7 @@ DBG_DEBUG("insert to close","(%i,%i,%i)  f=%i",gr->get_pos().x,gr->get_pos().y,g
             if((step&0x03)==0) {
                 INT_CHECK( "wegbauer 1347" );
 #ifdef DEBUG_ROUTES
-                if((step&1023)==0) {minimap_t::get_karte()->calc_map();}
+                if((step&1023)==0) {minimap_t::get_instance()->calc_map();}
 #endif
             }
 
@@ -2256,7 +2256,7 @@ void way_builder_t::build_tunnel_and_bridges()
 
             if(start->get_grund_hang()==slope_t::flat  ||  start->get_grund_hang()==slope_type(zv*(-1))  ||  start->get_grund_hang()==2*slope_type(zv*(-1))) {
                 // code derived from simtool
-               
+
                 sint8 bridge_height = 0;
                 const char *error;
This fixes missing refactoring in commit 8835 (along with a minor correction to formatting)

Code: [Select]
diff --git dataobj/route.cc dataobj/route.cc
index 8a4f72d25c..1920d7df43 100644
--- dataobj/route.cc
+++ dataobj/route.cc
@@ -676,9 +676,14 @@ route_t::route_result_t route_t::calc_route(karte_t *welt, const koord3d ziel, c
 
     INT_CHECK("route 336");
 
+#ifdef DEBUG_ROUTES
+    const uint32 ms = dr_time();
+#endif
     bool ok = intern_calc_route(welt, start, ziel, tdriver, max_khm, 0xFFFFFFFFul );
 #ifdef DEBUG_ROUTES
-    if(tdriver->get_waytype()==water_wt) {DBG_DEBUG("route_t::calc_route()","route from %d,%d to %d,%d with %i steps in %u ms found.",start.x, start.y, ziel.x, ziel.y, route.get_count()-1, dr_time()-ms );}
+    if(tdriver->get_waytype()==water_wt) {
+        DBG_DEBUG("route_t::calc_route()", "route from %d,%d to %d,%d with %i steps in %u ms found.", start.x, start.y, ziel.x, ziel.y, route.get_count()-1, dr_time()-ms );
+    }
 #endif
 
     INT_CHECK("route 343");
This fixes bug introduced in commit 7491

Code: [Select]
diff --git gui/minimap.cc gui/minimap.cc
index 2c2f58a2f7..27af904283 100644
--- gui/minimap.cc
+++ gui/minimap.cc
@@ -712,9 +712,10 @@ PIXVAL minimap_t::calc_ground_color(const grund_t *gr)
 
 #ifdef DEBUG_ROUTES
     /* for debug purposes only ...*/
-    if(world->ist_markiert(gr)) {
+    if(gr->get_flag(grund_t::marked)) {
         color = color_idx_to_rgb(COL_PURPLE);
-    }else
+    }
+    else
 #endif
     if(gr->get_halt().is_bound()) {
         color = COL_HALT;
Fixes bug introduced in 6734

Code: [Select]
diff --git player/ai_passenger.cc player/ai_passenger.cc
index 9b894d7175..6ed724c2c6 100644
--- player/ai_passenger.cc
+++ player/ai_passenger.cc
@@ -842,7 +842,7 @@ void ai_passenger_t::walk_city(linehandle_t const line, grund_t* const start, in
                             for( uint8 own=0;  own<pl->get_haltlist_count();  own++  ) {
                                 if(  hl[own]->is_enabled(goods_manager_t::INDEX_PAS)  ) {
                                     // our stop => nothing to do
-#if AUTOJOIN_PUBLIC
+#ifdef AUTOJOIN_PUBLIC
                                     // we leave also public stops alone
                                     if(  hl[own]->get_owner()==this  ||  hl[own]->get_owner()==welt->get_public_player()  ) {
 #else


diff --git simtool.cc simtool.cc
index 4052ede014..ea98feb53c 100644
--- simtool.cc
+++ simtool.cc
@@ -296,7 +296,7 @@ static halthandle_t suche_nahe_haltestelle(player_t *player, karte_t *welt, koor
         }
     }
 
-#if AUTOJOIN_PUBLIC
+#ifdef AUTOJOIN_PUBLIC
     // now search everything for public stops
     for(  int i=0;  i<8;  i++ ) {
         if(  planquadrat_t* plan=welt->access(k+koord::neighbours[i])  ) {
diff --git vehicle/simvehicle.cc vehicle/simvehicle.cc
index 79eb5503fe..c2b240bc27 100644
--- vehicle/simvehicle.cc
+++ vehicle/simvehicle.cc
@@ -3235,7 +3235,7 @@ bool water_vehicle_t::check_next_tile(const grund_t *bd) const
     }
     // channel can have more stuff to check
     const weg_t *w = bd->get_weg(water_wt);
-#if ENABLE_WATERWAY_SIGNS
+#ifdef ENABLE_WATERWAY_SIGNS
     if(  w  &&  w->has_sign()  ) {
         const roadsign_t* rs = bd->find<roadsign_t>();
         if(  rs->get_desc()->get_wtyp()==get_waytype()  ) {
While #if ((UNDEFINED_CONSTANT)) will evaluate to #if 0 and hence be false, and if ((DEFINED_CONSTANT)) should evaluate as true #ifdef has a clearer intent