From 68c9b7c3ad902784c07b0d76c81c87e073c826b3 Mon Sep 17 00:00:00 2001 From: darkvater Date: Mon, 16 Aug 2004 14:48:35 +0000 Subject: [PATCH] (svn r66) -Fix Station list updated on station deletion/station rename -Changed debug messages to comply with DEBUG(name, level) heuristics --- airport.c | 6 ++---- grfspecial.c | 7 +++---- industry_gui.c | 2 ++ misc_gui.c | 19 +++++++++---------- namegen.c | 5 +---- station_cmd.c | 2 ++ station_gui.c | 5 ++--- town_gui.c | 2 ++ ttd.c | 2 ++ variables.h | 1 + 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/airport.c b/airport.c index d090dbb61c..270f26c144 100644 --- a/airport.c +++ b/airport.c @@ -92,10 +92,8 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport, // build the state machine AirportBuildAutomata(Airport, FA); - //#ifdef _DEBUG - // {printf("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s)\n", Airport->nofelements, - // Airport->nofterminals, Airport->nofterminalgroups, Airport->nofhelipads, Airport->nofhelipadgroups);} - //#endif + // DEBUG(misc, 1) ("#Elements %2d; #Terminals %2d in %d group(s); #Helipads %2d in %d group(s)", Airport->nofelements, + // Airport->nofterminals, Airport->nofterminalgroups, Airport->nofhelipads, Airport->nofhelipadgroups); { diff --git a/grfspecial.c b/grfspecial.c index 69a905be08..47f7bc31cb 100644 --- a/grfspecial.c +++ b/grfspecial.c @@ -39,14 +39,13 @@ enum grfmsg_severity { static void CDECL grfmsg(enum grfmsg_severity severity, const char *str, ...) { static const char * const severitystr[4] = { "Notice", "Warning", "Error", "Fatal" }; + char buf[1024]; va_list va; - if(_debug_misc_level==0) return; va_start(va, str); - fprintf(stderr, "[%s][%s] ", _cur_grffile, severitystr[severity]); - vfprintf(stderr, str, va); + vsprintf(buf, str, va); va_end(va); - fprintf(stderr, "\n"); + DEBUG(grf, 1) ("[%s][%s] %s", _cur_grffile, severitystr[severity], buf); } static byte INLINE grf_load_byte(byte **buf) { diff --git a/industry_gui.c b/industry_gui.c index 015e657d86..09e3c97d2b 100644 --- a/industry_gui.c +++ b/industry_gui.c @@ -465,6 +465,8 @@ static void MakeSortedIndustryList() _last_industry_idx = 255; // used for "cache" qsort(_industry_sort, n, 1, IndustrySorter); + + //DEBUG(misc, 1) ("Resorting Industries list..."); } diff --git a/misc_gui.c b/misc_gui.c index c1b30b0a9c..755ca0c794 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -149,18 +149,17 @@ static void Place_LandInfo(uint tile) GetAcceptedCargo(tile, &lid.ac); GetTileDesc(tile, &lid.td); -#if defined(_DEBUG) + #if defined(_DEBUG) { - printf("TILE: %#x (%i,%i)\n", tile, GET_TILE_X(tile), GET_TILE_Y(tile)); - printf("_map_type_and_height=%#x\n", _map_type_and_height[tile]); - printf("_map2=%#x\n", _map2[tile]); - printf("_map3_lo=%#x\n", _map3_lo[tile]); - printf("_map3_hi=%#x\n", _map3_hi[tile]); - printf("_map5=%#x\n", _map5[tile]); - printf("_map_owner=%#x\n", _map_owner[tile]); - printf("\n"); + DEBUG(misc, 0) ("TILE: %#x (%i,%i)", tile, GET_TILE_X(tile), GET_TILE_Y(tile)); + DEBUG(misc, 0) ("_map_type_and_height=%#x", _map_type_and_height[tile]); + DEBUG(misc, 0) ("_map2=%#x", _map2[tile]); + DEBUG(misc, 0) ("_map3_lo=%#x", _map3_lo[tile]); + DEBUG(misc, 0) ("_map3_hi=%#x", _map3_hi[tile]); + DEBUG(misc, 0) ("_map5=%#x", _map5[tile]); + DEBUG(misc, 0) ("_map_owner=%#x", _map_owner[tile]); } -#endif + #endif } void PlaceLandBlockInfo() diff --git a/namegen.c b/namegen.c index 9b0829ff33..e1cb08bb5e 100644 --- a/namegen.c +++ b/namegen.c @@ -1986,15 +1986,12 @@ uint32 GetOldTownName(uint32 townnameparts, byte old_town_name_type) * 0000 0000 0000 0000 0000 0000 1111 1111 */ return FIXNUM(townnameparts - 86, NUM_FRENCH_1, 0); case 2: /* German */ - #ifdef _DEBUG - printf("German Townnames are buggy... (%d)\n", townnameparts); - #endif + DEBUG(misc, 0) ("German Townnames are buggy... (%d)", townnameparts); return townnameparts; case 4: /* Latin-American */ /* 0000 0000 0000 0000 0000 0000 1111 1111 */ return FIXNUM(townnameparts, NUM_SPANISH_1, 0); case 5: /* Silly */ - //AppendPart(&buf, GETNUM(16, NUM_SILLY_2),silly_2); /* NUM_SILLY_1 - lower 16 bits * NUM_SILLY_2 - upper 16 bits without leading 1 (first 8 bytes) * 1000 0000 2222 2222 0000 0000 1111 1111 */ diff --git a/station_cmd.c b/station_cmd.c index 17471e4191..df9a387f81 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1998,6 +1998,7 @@ static void DeleteStation(Station *st) DeleteName(st->string_id); MarkStationDirty(st); _station_sort_dirty = true; + InvalidateWindowClasses(WC_STATION_LIST); index = st->index; DeleteWindowById(WC_STATION_VIEW, index); @@ -2403,6 +2404,7 @@ static void ChangeTileOwner_Station(uint tile, byte old_player, byte new_player) _map_owner[tile] = new_player; st->owner = new_player; _station_sort_dirty = true; + InvalidateWindowClasses(WC_STATION_LIST); } else { DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); } diff --git a/station_gui.c b/station_gui.c index ade69f6911..a10ad0c478 100644 --- a/station_gui.c +++ b/station_gui.c @@ -107,9 +107,8 @@ static void MakeSortedStationList(Window *w) _last_station_idx = 255; // used for "cache" qsort(_station_sort, n, sizeof(_station_sort[0]), StationSorterByName); - //#ifdef _DEBUG - // {printf("Resorting Stations list...\n");} - //#endif + + //DEBUG(misc, 1) ("Resorting Stations list..."); } static void PlayerStationsWndProc(Window *w, WindowEvent *e) diff --git a/town_gui.c b/town_gui.c index a8e5718e3d..5571bcfc99 100644 --- a/town_gui.c +++ b/town_gui.c @@ -392,6 +392,8 @@ static void MakeSortedTownList() _last_town_idx = 255; // used for "cache" qsort(_town_sort, n, 1, _town_sort_order & 2 ? TownSorterByPop : TownSorterByName); + + //DEBUG(misc, 1) ("Resorting Towns list..."); } diff --git a/ttd.c b/ttd.c index 78ee234b30..eff9d9d29a 100644 --- a/ttd.c +++ b/ttd.c @@ -428,6 +428,7 @@ void SetDebugString(const char *s) _debug_spritecache_level = v; _debug_misc_level = v; + _debug_grf_level = v; } // individual levels @@ -443,6 +444,7 @@ void SetDebugString(const char *s) // check debugging levels if IS_LVL("misc") p = &_debug_misc_level; else if IS_LVL("spritecache") p = &_debug_spritecache_level; + else if IS_LVL("grf") p = &_debug_grf_level; else { ShowInfoF("Unknown debug level '%.*s'", s-t, t); return; diff --git a/variables.h b/variables.h index fcb7f1736e..a992b1e126 100644 --- a/variables.h +++ b/variables.h @@ -426,6 +426,7 @@ VARDEF bool _ignore_wrong_grf; /* Debugging levels */ VARDEF int _debug_spritecache_level; VARDEF int _debug_misc_level; +VARDEF int _debug_grf_level; void CDECL debug(const char *s, ...); #define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug