diff --git bauer/vehikelbauer.cc bauer/vehikelbauer.cc index e968ace75..6b11052e8 100644 --- bauer/vehikelbauer.cc +++ bauer/vehikelbauer.cc @@ -251,6 +251,7 @@ static bool compare_vehicles(const vehicle_desc_t* a, const vehicle_desc_t* b) case depot_frame_t::sb_price: cmp = compare_price(a, b); if (cmp != 0) return cmp < 0; + // fallthrough case depot_frame_t::sb_cost: cmp = compare_cost(a, b); if (cmp != 0) return cmp < 0; @@ -276,6 +277,7 @@ static bool compare_vehicles(const vehicle_desc_t* a, const vehicle_desc_t* b) case depot_frame_t::sb_intro_date: cmp = compare_intro_year_month(a, b); if (cmp != 0) return cmp < 0; + // fallthrough case depot_frame_t::sb_retire_date: cmp = compare_retire_year_month(a, b); if (cmp != 0) return cmp < 0; diff --git dataobj/crossing_logic.cc dataobj/crossing_logic.cc index a6a1be795..055778e6f 100644 --- dataobj/crossing_logic.cc +++ dataobj/crossing_logic.cc @@ -42,7 +42,6 @@ crossing_logic_t::crossing_logic_t( const crossing_desc_t *desc ) void crossing_logic_t::info(cbuffer_t & buf) const { static char const* const state_str[4] = { "invalid", "open", "request closing", "closed" }; - assert(state<4); buf.printf("%s%u%s%u%s%s\n", translator::translate("\nway1 reserved by"), on_way1.get_count(), translator::translate("\nway2 reserved by"), on_way2.get_count(), diff --git descriptor/building_desc.cc descriptor/building_desc.cc index beceb1768..0c8d3bc6b 100644 --- descriptor/building_desc.cc +++ descriptor/building_desc.cc @@ -215,7 +215,8 @@ sint32 building_desc_t::get_price(karte_t *world) const case tram_wt: return -s.cst_multiply_station * get_level(); case water_wt: return -s.cst_multiply_dock * get_level(); case air_wt: return -s.cst_multiply_airterminal * get_level(); - case 0: return -s.cst_multiply_post * get_level(); + case ignore_wt: return -s.cst_multiply_post * get_level(); + default: return 0; } case depot: switch(get_extra()) { diff --git network/network.cc network/network.cc index 38d5d5956..d8b342756 100644 --- network/network.cc +++ network/network.cc @@ -1004,7 +1004,7 @@ void remove_port_forwarding( int port ) #else // or we just get only our IP and hope we are not behind a router ... -bool prepare_for_server(char *externalIPAddress, char *alter_IP, int port) +bool prepare_for_server(char *externalIPAddress, char *, int) { cbuffer_t myIPaddr; // lets get IP by query "simutrans-forum.de/get_IP.php" for IP and assume that the redirection is working diff --git obj/crossing.cc obj/crossing.cc index 625f8a301..f64d16db6 100644 --- obj/crossing.cc +++ obj/crossing.cc @@ -118,7 +118,12 @@ void crossing_t::rdwr(loadsave_t *file) // variables ... attention, logic now in crossing_logic_t state = logic==NULL ? crossing_logic_t::CROSSING_INVALID : logic->get_state(); - file->rdwr_byte(state); + + uint8 s = state; + file->rdwr_byte(s); + assert(s <= crossing_logic_t::CROSSING_CLOSED); + state = static_cast(s); + file->rdwr_byte(ns); if(file->get_version()<99016) { uint32 ldummy=0; @@ -156,7 +161,7 @@ void crossing_t::rdwr(loadsave_t *file) if(desc==NULL) { dbg->fatal("crossing_t::rdwr()","requested for waytypes %i and %i but nothing defined!", w1, w2 ); } - crossing_logic_t::add( this, static_cast(state) ); + crossing_logic_t::add( this, state ); } } @@ -188,7 +193,7 @@ void crossing_t::finish_rd() #ifdef MULTI_THREAD pthread_mutex_lock( &crossing_logic_mutex ); #endif - crossing_logic_t::add( this, static_cast(state) ); + crossing_logic_t::add( this, state ); logic->recalc_state(); #ifdef MULTI_THREAD pthread_mutex_unlock( &crossing_logic_mutex ); diff --git obj/crossing.h obj/crossing.h index 57b6581f9..b9dca6237 100644 --- obj/crossing.h +++ obj/crossing.h @@ -24,7 +24,7 @@ class crossing_t : public obj_no_info_t protected: image_id foreground_image, image; uint8 ns; // direction - uint8 state; // only needed for loading ... + crossing_logic_t::crossing_state_t state; // only needed for loading ... crossing_logic_t *logic; const crossing_desc_t *desc; diff --git simhalt.cc simhalt.cc index edc450ab5..e918a26d7 100644 --- simhalt.cc +++ simhalt.cc @@ -2356,7 +2356,6 @@ void haltestelle_t::change_owner( player_t *player ) } // make way object public if any suitable - wayobj_t *wo = NULL; for( uint8 i = 1; i < gr->get_top(); i++ ) { if( wayobj_t *const wo = obj_cast(gr->obj_bei(i)) ) { player_t *woplayer = wo->get_owner(); @@ -2365,11 +2364,9 @@ void haltestelle_t::change_owner( player_t *player ) // change ownership wo->set_owner( player ); wo->set_flag(obj_t::dirty); - player_t *const woowner = wo->get_owner(); waytype_t const financetype = wo->get_desc()->get_waytype(); player_t::add_maintenance( woplayer, -cost, financetype); player_t::add_maintenance( player, cost, financetype); - sint64 const workcost = -welt->scale_with_month_length(cost * welt->get_settings().cst_make_public_months); player_t::book_construction_costs( woplayer, cost, koord::invalid, financetype); } } @@ -2423,7 +2420,7 @@ void haltestelle_t::merge_halt( halthandle_t halt_merged ) } assert(!halt_merged->existiert_in_welt()); - + // transfer goods halt_merged->transfer_goods(self); destroy(halt_merged); diff --git simmain.cc simmain.cc index 1c166a25c..ad996f15e 100644 --- simmain.cc +++ simmain.cc @@ -81,6 +81,7 @@ using std::string; +#ifdef DEBUG /* diagnostic routine: * show the size of several internal structures */ @@ -111,9 +112,10 @@ static void show_sizes() DBG_MESSAGE("sizes", "karte_t: %d", sizeof(karte_t)); DBG_MESSAGE("sizes", "player_t: %d\n", sizeof(player_t)); } +#endif // DEBUG - +#if defined DEBUG || defined PROFILE // render tests ... static void show_times(karte_t *welt, main_view_t *view) { @@ -194,7 +196,7 @@ static void show_times(karte_t *welt, main_view_t *view) } dbg->message( "welt->sync_step/step(200,1,1)", "%i iterations took %li ms", i, dr_time() - ms ); } - +#endif // defined DEBUG || defined PROFILE void modal_dialogue( gui_frame_t *gui, ptrdiff_t magic, karte_t *welt, bool (*quit)() ) diff --git simtool.cc simtool.cc index 966ecf45e..3fe6957ec 100644 --- simtool.cc +++ simtool.cc @@ -6320,7 +6320,7 @@ image_id tool_merge_stop_t::get_marker_image() return cursor; } -uint8 tool_merge_stop_t::is_valid_pos( player_t *player, const koord3d &pos, const char *&error, const koord3d &start ) +uint8 tool_merge_stop_t::is_valid_pos( player_t *player, const koord3d &pos, const char *&error, const koord3d &/*start*/ ) { grund_t *bd = welt->lookup(pos); if (bd==NULL) { diff --git simworld.cc simworld.cc index a024cf03c..230704182 100644 --- simworld.cc +++ simworld.cc @@ -2034,7 +2034,7 @@ karte_t::karte_t() : for(int i=0; ierror("karte_t::save(loadsave_t *file)", "Could not load motd from motd file!"); + len = 1; + } + motd[len-1] = 0; file->rdwr_str( motd, len ); free( motd ); diff --git tpl/binary_heap_tpl.h tpl/binary_heap_tpl.h index ed40ed3f6..4890c5a16 100644 --- tpl/binary_heap_tpl.h +++ tpl/binary_heap_tpl.h @@ -31,15 +31,15 @@ class binary_heap_tpl private: T *nodes; -public: uint32 node_count; uint32 node_size; +public: binary_heap_tpl() { DBG_MESSAGE("binary_heap_tpl()","initialized"); - nodes = MALLOCN(T, 4096); node_size = 4096; + nodes = MALLOCN(T, node_size); node_count = 0; } @@ -61,11 +61,8 @@ public: // need to enlarge? (must be 2^x) if(node_count==node_size) { - T *tmp=nodes; node_size *= 2; - nodes = MALLOCN(T, node_size); - memcpy( nodes, tmp, sizeof(T)*(node_size/2) ); - free( tmp ); + nodes = REALLOC(nodes, T, node_size); } // now we have to move it to the right position diff --git unicode.cc unicode.cc index 301bed4a0..56ba88d26 100644 --- unicode.cc +++ unicode.cc @@ -3,9 +3,9 @@ utf32 const UNICODE_NUL = 0; -static inline int is_1byte_seq(utf8 c) { return c<0x80; } // normal ASCII (equivalent to (c & 0x80) == 0x00) -static inline int is_2byte_seq(utf8 c) { return (c & 0xE0) == 0xC0; } // 2 Byte sequence, total letter value is 110xxxxx 10yyyyyy => 00000xxx xxyyyyyy -static inline int is_3byte_seq(utf8 c) { return (c & 0xF0) == 0xE0; } // 3 Byte sequence, total letter value is 1110xxxx 10yyyyyy 10zzzzzz => xxxxyyyy yyzzzzzz +//static inline int is_1byte_seq(utf8 c) { return c<0x80; } // normal ASCII (equivalent to (c & 0x80) == 0x00) +//static inline int is_2byte_seq(utf8 c) { return (c & 0xE0) == 0xC0; } // 2 Byte sequence, total letter value is 110xxxxx 10yyyyyy => 00000xxx xxyyyyyy +//static inline int is_3byte_seq(utf8 c) { return (c & 0xF0) == 0xE0; } // 3 Byte sequence, total letter value is 1110xxxx 10yyyyyy 10zzzzzz => xxxxyyyy yyzzzzzz static inline int is_cont_char(utf8 c) { return (c & 0xC0) == 0x80; } // the bytes in a sequence have always the format 10xxxxxx utf8_decoder_t::utf8_decoder_t(utf8 const *const str)