diff --git a/ai/trolly/build.c b/ai/trolly/build.c index f61521ba78..9959d0d04f 100644 --- a/ai/trolly/build.c +++ b/ai/trolly/build.c @@ -116,7 +116,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla PathFinderInfo->position++; // TODO: problems! if (CmdFailed(cost)) { - DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be built!"); + DEBUG(ai, 0, "[BuildPath] tunnel could not be built (0x%X)", route[part]); return 0; } return cost; @@ -127,7 +127,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla PathFinderInfo->position++; // TODO: problems! if (CmdFailed(cost)) { - DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be built!"); + DEBUG(ai, 0, "[BuildPath] bridge could not be built (0x%X, 0x%X)", route[part], route[part - 1]); return 0; } return cost; @@ -166,7 +166,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla PathFinderInfo->position++; // TODO: problems! if (CmdFailed(cost)) { - DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: tunnel could not be built!"); + DEBUG(ai, 0, "[BuildPath] tunnel could not be built (0x%X)", route[part]); return 0; } return cost; @@ -177,7 +177,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla PathFinderInfo->position++; // TODO: problems! if (CmdFailed(cost)) { - DEBUG(ai,0)("[AiNew - BuildPath] We have a serious problem: bridge could not be built!"); + DEBUG(ai, 0, "[BuildPath] bridge could not be built (0x%X, 0x%X)", route[part], route[part + 1]); return 0; } return cost; @@ -201,7 +201,7 @@ int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte fla // Currently, we ignore CMD_ERRORs! if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_STREET) && !EnsureNoVehicle(route[part])) { // Problem.. let's just abort it all! - DEBUG(ai,0)("Darn, the route could not be built.. aborting!"); + DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]); p->ainew.state = AI_STATE_NOTHING; return 0; } diff --git a/ai/trolly/pathfinder.c b/ai/trolly/pathfinder.c index c5ab35122e..6ffdf1fec9 100644 --- a/ai/trolly/pathfinder.c +++ b/ai/trolly/pathfinder.c @@ -200,14 +200,14 @@ static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *curre PathFinderInfo->route[i++] = parent->node.tile; if (i > lengthof(PathFinderInfo->route)) { // We ran out of space for the PathFinder - DEBUG(ai, 0)("[AiPathFinder] Ran out of space in the route[] array!!!"); + DEBUG(ai, 0, "No more space in pathfinder route[] array"); PathFinderInfo->route_length = -1; // -1 indicates out of space return; } parent = parent->parent; } while (parent != NULL); PathFinderInfo->route_length = i; - DEBUG(ai, 1)("[Ai-PathFinding] Found route of %d nodes long in %d nodes of searching", i, Hash_Size(&aystar->ClosedListHash)); + DEBUG(ai, 1, "Found route of %d nodes long in %d nodes of searching", i, Hash_Size(&aystar->ClosedListHash)); } diff --git a/ai/trolly/shared.c b/ai/trolly/shared.c index d41544ef07..e683b60ea4 100644 --- a/ai/trolly/shared.c +++ b/ai/trolly/shared.c @@ -109,7 +109,7 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag) // Out of special_vehicle spots :s if (new_id == -1) { - DEBUG(ai, 1)("special_vehicles list is too small :("); + DEBUG(ai, 1, "special_vehicles list is too small"); return false; } p->ainew.special_vehicles[new_id].veh_id = v->index; diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c index 23a700b06f..d67a064b4b 100644 --- a/ai/trolly/trolly.c +++ b/ai/trolly/trolly.c @@ -445,8 +445,7 @@ static void AiNew_State_LocateRoute(Player *p) p->ainew.to_ic = p->ainew.temp; p->ainew.state = AI_STATE_FIND_STATION; - DEBUG(ai,1)( - "[AiNew - LocateRoute] Found bus-route of %d tiles long (from %d to %d)", + DEBUG(ai, 1, "[LocateRoute] found bus-route of %d tiles long (from %d to %d)", distance, p->ainew.from_ic, p->ainew.temp @@ -508,8 +507,7 @@ static void AiNew_State_LocateRoute(Player *p) } p->ainew.state = AI_STATE_FIND_STATION; - DEBUG(ai,1)( - "[AiNew - LocateRoute] Found truck-route of %d tiles long (from %d to %d)", + DEBUG(ai, 1, "[LocateRoute] found truck-route of %d tiles long (from %d to %d)", distance, p->ainew.from_ic, p->ainew.temp @@ -763,7 +761,7 @@ static void AiNew_State_FindPath(Player *p) r = p->ainew.pathfinder->main(p->ainew.pathfinder); switch (r) { case AYSTAR_NO_PATH: - DEBUG(ai,1)("[AiNew] PathFinder found no route!"); + DEBUG(ai, 1, "No route found by pathfinder"); // Start all over again p->ainew.state = AI_STATE_NOTHING; break; @@ -955,7 +953,7 @@ static void AiNew_State_VerifyRoute(Player *p) // Check if we have enough money for it! if (p->ainew.new_cost > p->player_money - AI_MINIMUM_MONEY) { // Too bad.. - DEBUG(ai,1)("[AiNew] Can't pay for this route (%d)", p->ainew.new_cost); + DEBUG(ai, 1, "Insufficient funds to build route (%d)", p->ainew.new_cost); p->ainew.state = AI_STATE_NOTHING; return; } @@ -975,7 +973,7 @@ static void AiNew_State_VerifyRoute(Player *p) p->ainew.state = AI_STATE_BUILD_STATION; p->ainew.temp = 0; - DEBUG(ai,1)("[AiNew] The route is set and buildable.. going to build it!"); + DEBUG(ai, 1, "The route is set and buildable, building 0x%X to 0x%X...", p->ainew.from_tile, p->ainew.to_tile); } @@ -993,7 +991,7 @@ static void AiNew_State_BuildStation(Player *p) p->ainew.state = AI_STATE_BUILD_PATH; } if (CmdFailed(res)) { - DEBUG(ai,0)("[AiNew - BuildStation] Strange but true... station can not be built!"); + DEBUG(ai, 0, "[BuildStation] station could not be built (0x%X)", p->ainew.to_tile); p->ainew.state = AI_STATE_NOTHING; // If the first station _was_ build, destroy it if (p->ainew.temp != 0) @@ -1010,7 +1008,7 @@ static void AiNew_State_BuildPath(Player *p) assert(p->ainew.state == AI_STATE_BUILD_PATH); // p->ainew.temp is set to -1 when this function is called for the first time if (p->ainew.temp == -1) { - DEBUG(ai,1)("[AiNew] Starting to build the path.."); + DEBUG(ai, 1, "Starting to build new path"); // Init the counter p->ainew.counter = (4 - _opt.diff.competitor_speed) * AI_BUILDPATH_PAUSE + 1; // Set the position to the startingplace (-1 because in a minute we do ++) @@ -1091,8 +1089,7 @@ static void AiNew_State_BuildPath(Player *p) } } - - DEBUG(ai,1)("[AiNew] Done building the path (cost: %d)", p->ainew.new_cost); + DEBUG(ai, 1, "Finished building path, cost: %d", p->ainew.new_cost); p->ainew.state = AI_STATE_BUILD_DEPOT; } } @@ -1122,7 +1119,7 @@ static void AiNew_State_BuildDepot(Player *p) res = AiNew_Build_Depot(p, p->ainew.depot_tile, p->ainew.depot_direction, DC_EXEC); if (CmdFailed(res)) { - DEBUG(ai,0)("[AiNew - BuildDepot] Strange but true... depot can not be built!"); + DEBUG(ai, 0, "[BuildDepot] depot could not be built (0x%X)", p->ainew.depot_tile); p->ainew.state = AI_STATE_NOTHING; return; } diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 016014c8a1..e0613e3e75 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -1546,8 +1546,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *a static void AircraftEventHandler_General(Vehicle *v, const AirportFTAClass *apc) { - DEBUG(misc, 0) ("OK, you shouldn't be here, check your Airport Scheme!"); - assert(0); + assert("OK, you shouldn't be here, check your Airport Scheme!" && 0); } static void AircraftEventHandler_TakeOff(Vehicle *v, const AirportFTAClass *apc) { @@ -1748,7 +1747,7 @@ static bool AirportMove(Vehicle *v, const AirportFTAClass *apc) // error handling if (v->u.air.pos >= apc->nofelements) { - DEBUG(misc, 0) ("position %d is not valid for current airport. Max position is %d", v->u.air.pos, apc->nofelements-1); + DEBUG(misc, 0, "[Ap] position %d is not valid for current airport. Max position is %d", v->u.air.pos, apc->nofelements-1); assert(v->u.air.pos < apc->nofelements); } @@ -1783,8 +1782,8 @@ static bool AirportMove(Vehicle *v, const AirportFTAClass *apc) current = current->next; } while (current != NULL); - DEBUG(misc, 0) ("Cannot move further on Airport...! pos:%d state:%d", v->u.air.pos, v->u.air.state); - DEBUG(misc, 0) ("Airport entry point: %d, Vehicle: %d", apc->entry_point, v->index); + DEBUG(misc, 0, "[Ap] cannot move further on Airport! (pos %d state %d)", v->u.air.pos, v->u.air.state); + DEBUG(misc, 0, "[Ap] airport entry point: %d, Vehicle: %d", apc->entry_point, v->index); assert(0); return false; } diff --git a/airport.c b/airport.c index 3de08bbd87..2135bd11b3 100644 --- a/airport.c +++ b/airport.c @@ -219,14 +219,14 @@ static void AirportFTAClass_Constructor(AirportFTAClass *apc, * need to be changed, so don't allow that for now */ nofterminals = AirportGetTerminalCount(terminals, &nofterminalgroups); if (nofterminals > MAX_TERMINALS) { - DEBUG(misc, 0) ("[Ap] Currently only maximum of %d terminals are supported (you wanted %d)", MAX_TERMINALS, nofterminals); + DEBUG(misc, 0, "[Ap] only a maximum of %d terminals are supported (requested %d)", MAX_TERMINALS, nofterminals); assert(nofterminals <= MAX_TERMINALS); } apc->terminals = terminals; nofhelipads = AirportGetTerminalCount(helipads, &nofhelipadgroups); if (nofhelipads > MAX_HELIPADS) { - DEBUG(misc, 0) ("[Ap] Currently only maximum of %d helipads are supported (you wanted %d)", MAX_HELIPADS, nofhelipads); + DEBUG(misc, 0, "[Ap] only a maximum of %d helipads are supported (requested %d)", MAX_HELIPADS, nofhelipads); assert(nofhelipads <= MAX_HELIPADS); } apc->helipads = helipads; @@ -236,7 +236,7 @@ static void AirportFTAClass_Constructor(AirportFTAClass *apc, * later on to build and validate the state machine */ apc->nofelements = AirportGetNofElements(apFA); if (entry_point >= apc->nofelements) { - DEBUG(misc, 0) ("[Ap] Entry (%d) must be within the airport (maximum %d)", entry_point, apc->nofelements); + DEBUG(misc, 0, "[Ap] entry (%d) must be within the airport (maximum %d)", entry_point, apc->nofelements); assert(entry_point < apc->nofelements); } @@ -247,14 +247,14 @@ static void AirportFTAClass_Constructor(AirportFTAClass *apc, /* Build the state machine itself */ AirportBuildAutomata(apc, apFA); - DEBUG(misc, 1) ("[Ap] #count %3d; #term %2d (%dgrp); #helipad %2d (%dgrp); entry %3d", + DEBUG(misc, 2, "[Ap] #count %3d; #term %2d (%dgrp); #helipad %2d (%dgrp); entry %3d", apc->nofelements, nofterminals, nofterminalgroups, nofhelipads, nofhelipadgroups, apc->entry_point); /* Test if everything went allright. This is only a rude static test checking * the symantic correctness. By no means does passing the test mean that the * airport is working correctly or will not deadlock for example */ { byte ret = AirportTestFTA(apc); - if (ret != MAX_ELEMENTS) DEBUG(misc, 0) ("[Ap] ERROR with element: %d", ret - 1); + if (ret != MAX_ELEMENTS) DEBUG(misc, 0, "[Ap] problem with element: %d", ret - 1); assert(ret == MAX_ELEMENTS); } diff --git a/console.c b/console.c index b08fb74866..9335472165 100644 --- a/console.c +++ b/console.c @@ -427,11 +427,13 @@ void CDECL IConsolePrintF(uint16 color_code, const char *s, ...) * which is achieved by using this function. Can only be used by * @debug() in debug.c. You need at least a level 2 (developer) for debugging * messages to show up + * @param dbg debugging category + * @param string debugging message */ -void IConsoleDebug(const char *string) +void IConsoleDebug(const char *dbg, const char *string) { if (_stdlib_developer > 1) - IConsolePrintF(_icolour_dbg, "dbg: %s", string); + IConsolePrintF(_icolour_dbg, "dbg: [%s] %s", dbg, string); } /** diff --git a/console.h b/console.h index 0c74a14bd3..ef8063bc81 100644 --- a/console.h +++ b/console.h @@ -126,7 +126,7 @@ void IConsoleOpen(void); /* console output */ void IConsolePrint(uint16 color_code, const char *string); void CDECL IConsolePrintF(uint16 color_code, const char *s, ...); -void IConsoleDebug(const char *string); +void IConsoleDebug(const char *dbg, const char *string); void IConsoleWarning(const char *string); void IConsoleError(const char *string); diff --git a/debug.c b/debug.c index 60865473ae..fc3ca2df0d 100644 --- a/debug.c +++ b/debug.c @@ -16,24 +16,27 @@ int _debug_map_level; int _debug_misc_level; int _debug_ms_level; int _debug_net_level; -int _debug_spritecache_level; +int _debug_sprite_level; int _debug_oldloader_level; int _debug_ntp_level; int _debug_npf_level; int _debug_yapf_level; int _debug_freetype_level; +int _debug_sl_level; -void CDECL debug(const char *s, ...) +void CDECL debug(const char *dbg, ...) { va_list va; + const char *s; char buf[1024]; - va_start(va, s); + va_start(va, dbg); + s = va_arg(va, const char*); vsnprintf(buf, lengthof(buf), s, va); va_end(va); - fprintf(stderr, "dbg: %s\n", buf); - IConsoleDebug(buf); + fprintf(stderr, "dbg: [%s] %s\n", dbg, buf); + IConsoleDebug(dbg, buf); } typedef struct DebugLevel { @@ -50,12 +53,13 @@ typedef struct DebugLevel { DEBUG_LEVEL(misc), DEBUG_LEVEL(ms), DEBUG_LEVEL(net), - DEBUG_LEVEL(spritecache), + DEBUG_LEVEL(sprite), DEBUG_LEVEL(oldloader), DEBUG_LEVEL(ntp), DEBUG_LEVEL(npf), DEBUG_LEVEL(yapf), - DEBUG_LEVEL(freetype) + DEBUG_LEVEL(freetype), + DEBUG_LEVEL(sl), }; #undef DEBUG_LEVEL diff --git a/debug.h b/debug.h index c0005f8dbf..f45db4d3fa 100644 --- a/debug.h +++ b/debug.h @@ -3,10 +3,24 @@ #ifndef DEBUG_H #define DEBUG_H +/* Debugging messages policy: + * These should be the severities used for direct DEBUG() calls + * maximum debugging level should be 10 if really deep, deep + * debugging is needed. + * (there is room for exceptions, but you have to have a good cause): + * 0 - errors or severe warnings + * 1 - other non-fatal, non-severe warnings + * 2 - crude progress indicator of functionality + * 3 - important debugging messages (function entry) + * 4 - debugging messages (crude loop status, etc.) + * 5 - detailed debugging information + * 6.. - extremely detailed spamming + */ + #ifdef NO_DEBUG_MESSAGES - #define DEBUG(name, level) + #define DEBUG(name, level, ...) #else - #define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug + #define DEBUG(name, level, ...) if (level == 0 || _debug_ ## name ## _level >= level) debug(#name, __VA_ARGS__) extern int _debug_ai_level; extern int _debug_driver_level; @@ -15,15 +29,16 @@ extern int _debug_misc_level; extern int _debug_ms_level; extern int _debug_net_level; - extern int _debug_spritecache_level; + extern int _debug_sprite_level; extern int _debug_oldloader_level; extern int _debug_ntp_level; extern int _debug_npf_level; extern int _debug_yapf_level; extern int _debug_freetype_level; + extern int _debug_sl_level; #endif -void CDECL debug(const char *s, ...); +void CDECL debug(const char *dbg, ...); void SetDebugString(const char *s); const char *GetDebugString(void); @@ -45,7 +60,7 @@ const char *GetDebugString(void); #define TOC(str, count)\ __sum__ += _rdtsc() - _xxx_;\ if (++__i__ == count) {\ - printf("[%s]: %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ + DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ __i__ = 0;\ __sum__ = 0;\ }\ diff --git a/driver.c b/driver.c index f1afb5ec76..d8f4f1f153 100644 --- a/driver.c +++ b/driver.c @@ -125,16 +125,13 @@ void LoadDriver(int driver, const char *name) for (dd = dc->descs; dd->name != NULL; dd++) { err = dd->drv->start(NULL); if (err == NULL) break; - DEBUG(driver, 1) ("Probing %s driver \"%s\" failed with error: %s", + DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", dc->name, dd->name, err ); } - if (dd->name == NULL) { - error("Couldn't find any suitable %s driver", dc->name); - } + if (dd->name == NULL) error("Couldn't find any suitable %s driver", dc->name); - DEBUG(driver, 1) - ("Successfully probed %s driver \"%s\"", dc->name, dd->name); + DEBUG(driver, 1, "Successfully probed %s driver '%s'", dc->name, dd->name); *dc->drv = dd->drv; } else { diff --git a/engine.c b/engine.c index 9ac2ad7ac5..0a4b21c3dc 100644 --- a/engine.c +++ b/engine.c @@ -54,7 +54,7 @@ void DeleteCustomEngineNames(void) void LoadCustomEngineNames(void) { /* XXX: not done */ - DEBUG(misc, 1) ("LoadCustomEngineNames: not done"); + DEBUG(misc, 1, "LoadCustomEngineNames: not done"); } static void SetupEngineNames(void) diff --git a/fontcache.c b/fontcache.c index b4673b2449..d555eea94a 100644 --- a/fontcache.c +++ b/fontcache.c @@ -69,7 +69,7 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) if (ret != ERROR_SUCCESS) ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T(FONT_DIR_9X), 0, KEY_READ, &hKey); if (ret != ERROR_SUCCESS) { - DEBUG(freetype, 0) ("Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows (NT)\\CurrentVersion\\Fonts"); + DEBUG(freetype, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows (NT)\\CurrentVersion\\Fonts"); return err; } @@ -111,7 +111,7 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) } if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, vbuffer))) { - DEBUG(freetype, 0) ("SHGetFolderPath cannot return fonts directory"); + DEBUG(freetype, 0, "SHGetFolderPath cannot return fonts directory"); goto folder_error; } @@ -241,7 +241,7 @@ static void LoadFreeTypeFont(const char *font_name, FT_Face *face, const char *t if (error != FT_Err_Ok) error = GetFontByFaceName(font_name, face); if (error == FT_Err_Ok) { - DEBUG(freetype, 2) ("[FreeType] Requested '%s', using '%s %s'", font_name, (*face)->family_name, (*face)->style_name); + DEBUG(freetype, 2, "Requested '%s', using '%s %s'", font_name, (*face)->family_name, (*face)->style_name); /* Attempt to select the unicode character map */ error = FT_Select_Charmap(*face, ft_encoding_unicode); @@ -278,7 +278,7 @@ static void LoadFreeTypeFont(const char *font_name, FT_Face *face, const char *t void InitFreeType(void) { if (strlen(_freetype.small_font) == 0 && strlen(_freetype.medium_font) == 0 && strlen(_freetype.large_font) == 0) { - DEBUG(freetype, 1) ("[FreeType] No font faces specified, using sprite fonts instead"); + DEBUG(freetype, 1, "No font faces specified, using sprite fonts instead"); return; } @@ -287,7 +287,7 @@ void InitFreeType(void) return; } - DEBUG(freetype, 2) ("[FreeType] Initialized"); + DEBUG(freetype, 2, "Initialized"); /* Load each font */ LoadFreeTypeFont(_freetype.small_font, &_face_small, "small"); @@ -344,16 +344,16 @@ static GlyphEntry *GetGlyphPtr(FontSize size, WChar key) static void SetGlyphPtr(FontSize size, WChar key, const GlyphEntry *glyph) { if (_glyph_ptr[size] == NULL) { - DEBUG(freetype, 3) ("[FreeType] Allocating root glyph cache for size %u", size); + DEBUG(freetype, 3, "Allocating root glyph cache for size %u", size); _glyph_ptr[size] = calloc(256, sizeof(**_glyph_ptr)); } if (_glyph_ptr[size][GB(key, 8, 8)] == NULL) { - DEBUG(freetype, 3) ("[FreeType] Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), size); + DEBUG(freetype, 3, "Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), size); _glyph_ptr[size][GB(key, 8, 8)] = calloc(256, sizeof(***_glyph_ptr)); } - DEBUG(freetype, 4) ("[FreeType] Set glyph for unicode character 0x%04X, size %u", key, size); + DEBUG(freetype, 4, "Set glyph for unicode character 0x%04X, size %u", key, size); _glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].sprite = glyph->sprite; _glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].width = glyph->width; } @@ -520,3 +520,5 @@ void InitializeUnicodeGlyphMap(void) } } + + diff --git a/genworld.c b/genworld.c index e6c646b0d7..1d802d996e 100644 --- a/genworld.c +++ b/genworld.c @@ -79,7 +79,7 @@ bool IsGenerateWorldThreaded(void) static void *_GenerateWorld(void *arg) { _generating_world = true; - if (_network_dedicated) DEBUG(net, 0)("Generating map, please wait..."); + if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait..."); /* Set the Random() seed to generation_seed so we produce the same map with the same seed */ if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom(); _random_seeds[0][0] = _random_seeds[0][1] = _patches.generation_seed; @@ -151,7 +151,7 @@ static void *_GenerateWorld(void *arg) DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0); MarkWholeScreenDirty(); - if (_network_dedicated) DEBUG(net, 0)("Map generated, starting game"); + if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game"); return NULL; } @@ -271,7 +271,7 @@ void GenerateWorld(int mode, uint size_x, uint size_y) if (_network_dedicated || (_gw.thread = OTTDCreateThread(&_GenerateWorld, NULL)) == NULL) { - DEBUG(misc, 1) ("[Sl] Cannot create savegame thread, reverting to single-threaded mode..."); + DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode"); _gw.threaded = false; _GenerateWorld(NULL); return; diff --git a/genworld_gui.c b/genworld_gui.c index 7b597bd571..260e133a38 100644 --- a/genworld_gui.c +++ b/genworld_gui.c @@ -844,7 +844,7 @@ static void _SetGeneratingWorldProgress(gwp_class class, uint progress, uint tot /* Never show steps smaller then 2%, even if it is a mod 5% */ if (_tp.percent <= last_percent + 2) return; - DEBUG(net, 1)("Percent complete: %d", _tp.percent); + DEBUG(net, 1, "Map generation percentage complete: %d", _tp.percent); last_percent = _tp.percent; /* Don't continue as dedicated never has a thread running */ diff --git a/gfx.c b/gfx.c index 4fffd9407a..0422fa00ad 100644 --- a/gfx.c +++ b/gfx.c @@ -2003,7 +2003,7 @@ void ToggleFullScreen(bool fs) { _video_driver->toggle_fullscreen(fs); if (_fullscreen != fs && _num_resolutions == 0) { - DEBUG(misc, 0) ("Could not find a suitable fullscreen resolution."); + DEBUG(driver, 0, "Could not find a suitable fullscreen resolution"); } } diff --git a/gfxinit.c b/gfxinit.c index 1ac0a30d6b..ae9fb3cb84 100644 --- a/gfxinit.c +++ b/gfxinit.c @@ -54,7 +54,7 @@ static uint LoadGrfFile(const char* filename, uint load_index, int file_index) FioOpenFile(file_index, filename); - DEBUG(spritecache, 2) ("Reading grf-file ``%s''", filename); + DEBUG(sprite, 2, "Reading grf-file '%s'", filename); while (LoadNextSprite(load_index, file_index)) { load_index++; @@ -62,7 +62,7 @@ static uint LoadGrfFile(const char* filename, uint load_index, int file_index) error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); } } - DEBUG(spritecache, 2) ("Currently %i sprites are loaded", load_index); + DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); return load_index - load_index_org; } @@ -74,7 +74,7 @@ static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int FioOpenFile(file_index, filename); - DEBUG(spritecache, 2) ("Reading indexed grf-file ``%s''", filename); + DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); while ((start = *index_tbl++) != END) { uint end = *index_tbl++; @@ -382,7 +382,7 @@ static void LoadSpriteTables(void) void GfxLoadSprites(void) { - DEBUG(spritecache, 1) ("Loading sprite set %d.", _opt.landscape); + DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape); GfxInitSpriteMem(); LoadSpriteTables(); diff --git a/graph_gui.c b/graph_gui.c index 50eb932d9d..c6a9b845b5 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -1152,9 +1152,7 @@ static void GlobalSortSignList(void) /* Create array for sorting */ _sign_sort = realloc((void *)_sign_sort, (GetMaxSignIndex() + 1)* sizeof(_sign_sort[0])); - if (_sign_sort == NULL) { - error("Could not allocate memory for the sign-sorting-list"); - } + if (_sign_sort == NULL) error("Could not allocate memory for the sign-sorting-list"); FOR_ALL_SIGNS(si) _sign_sort[n++] = si; _num_sign_sort = n; @@ -1163,7 +1161,7 @@ static void GlobalSortSignList(void) _sign_sort_dirty = false; - DEBUG(misc, 1) ("Resorting global sign list..."); + DEBUG(misc, 3, "Resorting global signs list"); } static void SignListWndProc(Window *w, WindowEvent *e) diff --git a/industry_gui.c b/industry_gui.c index 13fbac9cc9..fa6d13198a 100644 --- a/industry_gui.c +++ b/industry_gui.c @@ -563,8 +563,7 @@ static void MakeSortedIndustryList(void) /* Create array for sorting */ _industry_sort = realloc((void *)_industry_sort, (GetMaxIndustryIndex() + 1) * sizeof(_industry_sort[0])); - if (_industry_sort == NULL) - error("Could not allocate memory for the industry-sorting-list"); + if (_industry_sort == NULL) error("Could not allocate memory for the industry-sorting-list"); FOR_ALL_INDUSTRIES(i) _industry_sort[n++] = i; @@ -573,7 +572,7 @@ static void MakeSortedIndustryList(void) qsort((void*)_industry_sort, n, sizeof(_industry_sort[0]), GeneralIndustrySorter); - DEBUG(misc, 1) ("Resorting Industries list..."); + DEBUG(misc, 3, "Resorting industries list"); } diff --git a/map.c b/map.c index 9901c7eb8a..df16343c7d 100644 --- a/map.c +++ b/map.c @@ -32,7 +32,7 @@ void AllocateMap(uint size_x, uint size_y) (size_y&(size_y-1)) != 0) error("Invalid map size"); - DEBUG(map, 1)("Allocating map of size %dx%d", size_x, size_y); + DEBUG(map, 1, "Allocating map of size %dx%d", size_x, size_y); _map_log_x = FindFirstBit(size_x); _map_size_x = size_x; diff --git a/misc_gui.c b/misc_gui.c index e5ffef5c3c..1b8165b9ab 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -173,14 +173,14 @@ static void Place_LandInfo(TileIndex tile) #else # define LANDINFOD_LEVEL 1 #endif - DEBUG(misc, LANDINFOD_LEVEL) ("TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile)); - DEBUG(misc, LANDINFOD_LEVEL) ("type_height = %#x", _m[tile].type_height); - DEBUG(misc, LANDINFOD_LEVEL) ("m1 = %#x", _m[tile].m1); - DEBUG(misc, LANDINFOD_LEVEL) ("m2 = %#x", _m[tile].m2); - DEBUG(misc, LANDINFOD_LEVEL) ("m3 = %#x", _m[tile].m3); - DEBUG(misc, LANDINFOD_LEVEL) ("m4 = %#x", _m[tile].m4); - DEBUG(misc, LANDINFOD_LEVEL) ("m5 = %#x", _m[tile].m5); - DEBUG(misc, LANDINFOD_LEVEL) ("extra = %#x", _m[tile].extra); + DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile)); + DEBUG(misc, LANDINFOD_LEVEL, "type_height = %#x", _m[tile].type_height); + DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1); + DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2); + DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3); + DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4); + DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5); + DEBUG(misc, LANDINFOD_LEVEL, "extra = %#x", _m[tile].extra); #undef LANDINFOD_LEVEL } diff --git a/music/dmusic.cpp b/music/dmusic.cpp index 3af6dfc810..e20842d2e9 100644 --- a/music/dmusic.cpp +++ b/music/dmusic.cpp @@ -162,7 +162,7 @@ static void DMusicMidiPlaySong(const char* filename) if (FAILED(loader->GetObject( &obj_desc, IID_IDirectMusicSegment, (LPVOID*)&segment ))) { - DEBUG(misc, 0) ("DirectMusic: Get object failed"); + DEBUG(driver, 0, "DirectMusic: GetObject failed"); return; } @@ -170,19 +170,19 @@ static void DMusicMidiPlaySong(const char* filename) if (FAILED(segment->SetParam( GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, performance ))) { - DEBUG(misc, 0) ("DirectMusic: SetParam (MIDI file) failed"); + DEBUG(driver, 0, "DirectMusic: SetParam (MIDI file) failed"); return; } // tell the segment to 'download' the instruments if (FAILED(segment->SetParam(GUID_Download, 0xFFFFFFFF, 0, 0, performance))) { - DEBUG(misc, 0) ("DirectMusic: Failed to download instruments"); + DEBUG(driver, 0, "DirectMusic: failed to download instruments"); return; } // start playing the MIDI file if (FAILED(performance->PlaySegment(segment, 0, 0, NULL))) { - DEBUG(misc, 0) ("DirectMusic: PlaySegment failed"); + DEBUG(driver, 0, "DirectMusic: PlaySegment failed"); return; } @@ -193,7 +193,7 @@ static void DMusicMidiPlaySong(const char* filename) static void DMusicMidiStopSong(void) { if (FAILED(performance->Stop(segment, NULL, 0, 0))) { - DEBUG(misc, 0) ("DirecMusic: StopSegment failed"); + DEBUG(driver, 0, "DirectMusic: StopSegment failed"); } seeking = false; } diff --git a/music/extmidi.c b/music/extmidi.c index 76a9ab5041..901fa4fd78 100644 --- a/music/extmidi.c +++ b/music/extmidi.c @@ -59,7 +59,7 @@ static bool ExtMidiIsPlaying(void) static void ExtMidiSetVolume(byte vol) { - DEBUG(driver, 1) ("extmidi: set volume not implemented"); + DEBUG(driver, 1, "extmidi: set volume not implemented"); } static void DoPlay(void) @@ -82,7 +82,7 @@ static void DoPlay(void) } case -1: - DEBUG(driver, 0) ("extmidi: couldn't fork: %s", strerror(errno)); + DEBUG(driver, 0, "extmidi: couldn't fork: %s", strerror(errno)); /* FALLTHROUGH */ default: diff --git a/namegen.c b/namegen.c index 8403bec681..c70cc2d35f 100644 --- a/namegen.c +++ b/namegen.c @@ -773,7 +773,7 @@ uint32 GetOldTownName(uint32 townnameparts, byte old_town_name_type) return FIXNUM(townnameparts - 86, lengthof(name_french_real), 0); case 2: /* German */ - DEBUG(misc, 0) ("German Townnames are buggy... (%d)", townnameparts); + DEBUG(misc, 0, "German Townnames are buggy (%d)", townnameparts); return townnameparts; case 4: /* Latin-American */ diff --git a/network.c b/network.c index 73d7e7a0ad..13f24ef0af 100644 --- a/network.c +++ b/network.c @@ -208,13 +208,13 @@ static void NetworkError(StringID error_string) static void ClientStartError(const char *error) { - DEBUG(net, 0)("[NET] Client could not start network: %s",error); + DEBUG(net, 0, "[client] could not start network: %s",error); NetworkError(STR_NETWORK_ERR_CLIENT_START); } static void ServerStartError(const char *error) { - DEBUG(net, 0)("[NET] Server could not start network: %s",error); + DEBUG(net, 0, "[server] could not start network: %s",error); NetworkError(STR_NETWORK_ERR_SERVER_START); } @@ -347,13 +347,13 @@ static void NetworkFindIPs(void) _broadcast_list[0] = 0; if (sock < 0) { - DEBUG(net, 0)("Error creating socket!"); + DEBUG(net, 0, "[core] error creating socket"); return; } output_length = _netstat(sock, &output_pointer, 1); if (output_length < 0) { - DEBUG(net, 0)("Error running _netstat!"); + DEBUG(net, 0, "[core] error running _netstat"); return; } @@ -484,10 +484,10 @@ static void NetworkFindIPs(void) _broadcast_list[i] = 0; - DEBUG(net, 3)("Detected broadcast addresses:"); + DEBUG(net, 3, "Detected broadcast addresses:"); // Now display to the debug all the detected ips for (i = 0; _broadcast_list[i] != 0; i++) { - DEBUG(net, 3)(" %d) %s", i, inet_ntoa(*(struct in_addr *)&_broadcast_list[i]));//inet_ntoa(inaddr)); + DEBUG(net, 3, "%d) %s", i, inet_ntoa(*(struct in_addr *)&_broadcast_list[i]));//inet_ntoa(inaddr)); } } @@ -503,10 +503,10 @@ unsigned long NetworkResolveHost(const char *hostname) if (ip == INADDR_NONE) { struct hostent *he = gethostbyname(hostname); if (he == NULL) { - DEBUG(net, 0) ("[NET] Cannot resolve %s", hostname); + DEBUG(net, 0, "Cannot resolve '%s'", hostname); } else { struct in_addr addr = *(struct in_addr *)he->h_addr_list[0]; - DEBUG(net, 1) ("[NET] Resolved %s to %s", hostname, inet_ntoa(addr)); + DEBUG(net, 1, "Resolved '%s' to %s", hostname, inet_ntoa(addr)); ip = addr.s_addr; } } @@ -585,7 +585,7 @@ void NetworkCloseClient(NetworkClientState *cs) return; } - DEBUG(net, 1) ("[NET] Closed client connection"); + DEBUG(net, 1, "Closed client connection %d", cs->index); if (!cs->has_quit && _network_server && cs->status > STATUS_INACTIVE) { // We did not receive a leave message from this client... @@ -666,7 +666,7 @@ static bool NetworkConnect(const char *hostname, int port) SOCKET s; struct sockaddr_in sin; - DEBUG(net, 1) ("[NET] Connecting to %s %d", hostname, port); + DEBUG(net, 1, "Connecting to %s %d", hostname, port); s = socket(AF_INET, SOCK_STREAM, 0); if (s == INVALID_SOCKET) { @@ -674,7 +674,7 @@ static bool NetworkConnect(const char *hostname, int port) return false; } - if (!SetNoDelay(s)) DEBUG(net, 1)("[NET] Setting TCP_NODELAY failed"); + if (!SetNoDelay(s)) DEBUG(net, 1, "Setting TCP_NODELAY failed"); sin.sin_family = AF_INET; sin.sin_addr.s_addr = NetworkResolveHost(hostname); @@ -684,7 +684,7 @@ static bool NetworkConnect(const char *hostname, int port) /* We failed to connect for which reason what so ever */ if (connect(s, (struct sockaddr*) &sin, sizeof(sin)) != 0) return false; - if (!SetNonBlocking(s)) DEBUG(net, 0)("[NET] Setting non-blocking failed"); // XXX should this be an error? + if (!SetNonBlocking(s)) DEBUG(net, 0, "Setting non-blocking mode failed"); // XXX should this be an error? // in client mode, only the first client field is used. it's pointing to the server. NetworkAllocClient(s); @@ -712,7 +712,7 @@ static void NetworkAcceptClients(void) SetNonBlocking(s); // XXX error handling? - DEBUG(net, 1) ("[NET] Client connected from %s on frame %d", inet_ntoa(sin.sin_addr), _frame_counter); + DEBUG(net, 1, "Client connected from %s on frame %d", inet_ntoa(sin.sin_addr), _frame_counter); SetNoDelay(s); // XXX error handling? @@ -724,7 +724,7 @@ static void NetworkAcceptClients(void) if (sin.sin_addr.s_addr == inet_addr(_network_ban_list[i])) { Packet *p = NetworkSend_Init(PACKET_SERVER_BANNED); - DEBUG(net, 1)("[NET] Banned ip tried to join (%s), refused", _network_ban_list[i]); + DEBUG(net, 1, "Banned ip tried to join (%s), refused", _network_ban_list[i]); p->buffer[0] = p->size & 0xFF; p->buffer[1] = p->size >> 8; @@ -773,7 +773,7 @@ static bool NetworkListen(void) SOCKET ls; struct sockaddr_in sin; - DEBUG(net, 1) ("[NET] Listening on %s:%d", _network_server_bind_ip_host, _network_server_port); + DEBUG(net, 1, "Listening on %s:%d", _network_server_bind_ip_host, _network_server_port); ls = socket(AF_INET, SOCK_STREAM, 0); if (ls == INVALID_SOCKET) { @@ -790,7 +790,7 @@ static bool NetworkListen(void) } } - if (!SetNonBlocking(ls)) DEBUG(net, 0)("[NET] Setting non-blocking failed"); // XXX should this be an error? + if (!SetNonBlocking(ls)) DEBUG(net, 0, "Setting non-blocking mode failed"); // XXX should this be an error? sin.sin_family = AF_INET; sin.sin_addr.s_addr = _network_server_bind_ip; @@ -828,7 +828,7 @@ static void NetworkClose(void) // We are a server, also close the listensocket closesocket(_listensocket); _listensocket = INVALID_SOCKET; - DEBUG(net, 1) ("[NET] Closed listener"); + DEBUG(net, 1, "Closed listener"); NetworkUDPClose(); } } @@ -1193,7 +1193,7 @@ static void NetworkHandleLocalQueue(void) if (_frame_counter > cp->frame) { // If we reach here, it means for whatever reason, we've already executed // past the command we need to execute. - DEBUG(net, 0)("[NET] Trying to execute a packet in the past!"); + DEBUG(net, 0, "Trying to execute a packet in the past!"); assert(0); } @@ -1230,7 +1230,7 @@ static bool NetworkDoClientLoop(void) if (_sync_seed_1 != _random_seeds[0][0]) { #endif NetworkError(STR_NETWORK_ERR_DESYNC); - DEBUG(net, 0)("[NET] Sync error detected!"); + DEBUG(net, 0, "Sync error detected!"); NetworkClientError(NETWORK_RECV_STATUS_DESYNC, DEREF_CLIENT(0)); return false; } @@ -1245,7 +1245,7 @@ static bool NetworkDoClientLoop(void) _sync_frame = 0; } else if (_sync_frame < _frame_counter) { - DEBUG(net, 1)("[NET] Missed frame for sync-test (%d / %d)", _sync_frame, _frame_counter); + DEBUG(net, 1, "Missed frame for sync-test (%d / %d)", _sync_frame, _frame_counter); _sync_frame = 0; } } @@ -1339,17 +1339,17 @@ static void NetworkGenerateUniqueId(void) // This tries to launch the network for a given OS void NetworkStartUp(void) { - DEBUG(net, 3) ("[NET][Core] Starting network..."); + DEBUG(net, 3, "[core] starting network..."); #if defined(__MORPHOS__) || defined(__AMIGA__) /* * IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_ * network related function, else: crash. */ - DEBUG(misc,3) ("[NET][Core] Loading bsd socket library"); + DEBUG(net, 3, "[core] loading bsd socket library"); SocketBase = OpenLibrary("bsdsocket.library", 4); if (SocketBase == NULL) { - DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available."); + DEBUG(net, 0, "[core] can't open bsdsocket.library version 4, network unavailable"); _network_available = false; return; } @@ -1364,7 +1364,7 @@ void NetworkStartUp(void) TimerBase = TimerRequest->tr_node.io_Device; if (TimerBase == NULL) { // free ressources... - DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available."); + DEBUG(net, 0, "[core] can't initialize timer, network unavailable"); _network_available = false; return; } @@ -1404,9 +1404,9 @@ void NetworkStartUp(void) #if defined(WIN32) { WSADATA wsa; - DEBUG(net, 3) ("[NET][Core] Loading windows socket library"); + DEBUG(net, 3, "[core] loading windows socket library"); if (WSAStartup(MAKEWORD(2,0), &wsa) != 0) { - DEBUG(net, 0) ("[NET][Core] Error: WSAStartup failed. Network not available."); + DEBUG(net, 0, "[core] WSAStartup failed, network unavailable"); _network_available = false; return; } @@ -1414,7 +1414,7 @@ void NetworkStartUp(void) #endif // WIN32 NetworkInitialize(); - DEBUG(net, 3) ("[NET][Core] Network online. Multiplayer available."); + DEBUG(net, 3, "[core] network online, multiplayer available"); NetworkFindIPs(); } @@ -1424,7 +1424,7 @@ void NetworkShutDown(void) NetworkDisconnect(); NetworkUDPClose(); - DEBUG(net, 3) ("[NET][Core] Shutting down the network."); + DEBUG(net, 3, "[core] shutting down network"); _network_available = false; diff --git a/network_client.c b/network_client.c index 22d23720e7..1dee26e2d9 100644 --- a/network_client.c +++ b/network_client.c @@ -437,8 +437,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WAIT) InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0); // We are put on hold for receiving the map.. we need GUI for this ;) - DEBUG(net, 1)("[NET] The server is currently busy sending the map to someone else.. please hold..." ); - DEBUG(net, 1)("[NET] There are %d clients in front of you", _network_join_waiting); + DEBUG(net, 1, "The server is currently busy sending the map to someone else, please wait..." ); + DEBUG(net, 1, "There are %d clients in front of you", _network_join_waiting); return NETWORK_RECV_STATUS_OKAY; } @@ -544,13 +544,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FRAME) #endif } #endif - DEBUG(net, 7)("[NET] Received FRAME %d",_frame_counter_server); + DEBUG(net, 5, "Received FRAME %d", _frame_counter_server); // Let the server know that we received this frame correctly // We do this only once per day, to save some bandwidth ;) if (!_network_first_time && last_ack_frame < _frame_counter) { last_ack_frame = _frame_counter + DAY_TICKS; - DEBUG(net,6)("[NET] Sent ACK at %d", _frame_counter); + DEBUG(net, 4, "Sent ACK at %d", _frame_counter); SEND_COMMAND(PACKET_CLIENT_ACK)(); } @@ -680,7 +680,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_QUIT) // The client is gone, give the NetworkClientInfo free ci->client_index = NETWORK_EMPTY_INDEX; } else { - DEBUG(net, 0)("[NET] Error - unknown client (%d) is leaving the game", index); + DEBUG(net, 0, "Unknown client (%d) is leaving the game", index); } InvalidateWindow(WC_CLIENT_LIST, 0); @@ -807,7 +807,7 @@ NetworkRecvStatus NetworkClient_ReadPackets(NetworkClientState *cs) res = _network_client_packet[type](p); } else { res = NETWORK_RECV_STATUS_MALFORMED_PACKET; - DEBUG(net, 0)("[NET][client] Received invalid packet type %d", type); + DEBUG(net, 0, "[client] received invalid packet type %d", type); } free(p); diff --git a/network_data.c b/network_data.c index 2af0f29760..62e95e2cd3 100644 --- a/network_data.c +++ b/network_data.c @@ -154,9 +154,8 @@ bool NetworkSend_Packets(NetworkClientState *cs) res = send(cs->socket, p->buffer + p->pos, p->size - p->pos, 0); if (res == -1) { int err = GET_LAST_ERROR(); - if (err != EWOULDBLOCK) { - // Something went wrong.. close client! - DEBUG(net, 0) ("[NET] send() failed with error %d", err); + if (err != EWOULDBLOCK) { // Something went wrong.. close client! + DEBUG(net, 0, "send failed with error %d", err); CloseConnection(cs); return false; } @@ -320,9 +319,8 @@ Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) if (res == -1) { int err = GET_LAST_ERROR(); if (err != EWOULDBLOCK) { - // Something went wrong.. - if (err != 104) // 104 is Connection Reset by Peer - DEBUG(net, 0) ("[NET] recv() failed with error %d", err); + /* Something went wrong... (104 is connection reset by peer) */ + if (err != 104) DEBUG(net, 0, "recv failed with error %d", err); *status = CloseConnection(cs); return NULL; } @@ -330,7 +328,7 @@ Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) return NULL; } if (res == 0) { - // Client/server has left us :( + // Client/server has left *status = CloseConnection(cs); return NULL; } @@ -352,9 +350,8 @@ Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) if (res == -1) { int err = GET_LAST_ERROR(); if (err != EWOULDBLOCK) { - // Something went wrong.. - if (err != 104) // 104 is Connection Reset by Peer - DEBUG(net, 0) ("[NET] recv() failed with error %d", err); + /* Something went wrong... (104 is connection reset by peer) */ + if (err != 104) DEBUG(net, 0, "recv failed with error %d", err); *status = CloseConnection(cs); return NULL; } @@ -362,7 +359,7 @@ Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) return NULL; } if (res == 0) { - // Client/server has left us :( + // Client/server has left *status = CloseConnection(cs); return NULL; } @@ -415,7 +412,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma while (temp_callback < _callback_table_count && _callback_table[temp_callback] != callback) temp_callback++; if (temp_callback == _callback_table_count) { - DEBUG(net, 0) ("[NET] Unknown callback. (Pointer: %p) No callback sent.", callback); + DEBUG(net, 0, "Unknown callback. (Pointer: %p) No callback sent", callback); temp_callback = 0; /* _callback_table[0] == NULL */ } @@ -467,7 +464,7 @@ void NetworkExecuteCommand(CommandPacket *cp) _cmd_text = cp->text; /* cp->callback is unsigned. so we don't need to do lower bounds checking. */ if (cp->callback > _callback_table_count) { - DEBUG(net,0) ("[NET] Received out-of-bounds callback! (%d)", cp->callback); + DEBUG(net, 0, "Received out-of-bounds callback (%d)", cp->callback); cp->callback = 0; } DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND); diff --git a/network_gamelist.c b/network_gamelist.c index bcc75ad7e4..15fd7aa573 100644 --- a/network_gamelist.c +++ b/network_gamelist.c @@ -36,7 +36,7 @@ NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port) } else { prev_item->next = item; } - DEBUG(net, 4) ("[NET][GameList] Added server to list"); + DEBUG(net, 4, "[gamelist] added server to list"); UpdateNetworkGameWindow(false); @@ -63,7 +63,7 @@ void NetworkGameListRemoveItem(NetworkGameList *remove) free(remove); remove = NULL; - DEBUG(net, 4) ("[NET][GameList] Removed server from list"); + DEBUG(net, 4, "[gamelist] removed server from list"); UpdateNetworkGameWindow(false); return; } diff --git a/network_server.c b/network_server.c index 3b2861f91f..2be0e26544 100644 --- a/network_server.c +++ b/network_server.c @@ -153,7 +153,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientState *cs, Netwo NetworkGetClientName(client_name, sizeof(client_name), cs); - DEBUG(net, 2) ("[NET] '%s' made an error and has been disconnected. Reason: %s", client_name, str); + DEBUG(net, 1, "'%s' made an error and has been disconnected. Reason: '%s'", client_name, str); NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str); @@ -168,7 +168,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientState *cs, Netwo } } } else { - DEBUG(net, 2) ("[NET] Client %d made an error and has been disconnected. Reason: %s", cs->index, str); + DEBUG(net, 1, "Client %d made an error and has been disconnected. Reason: '%s'", cs->index, str); } cs->has_quit = true; @@ -901,7 +901,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ERROR) GetNetworkErrorMsg(str, errorno, lastof(str)); - DEBUG(net, 2)("[NET] %s reported an error and is closing his connection (%s)", client_name, str); + DEBUG(net, 2, "'%s' reported an error and is closing its connection (%s)", client_name, str); NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str); @@ -1057,7 +1057,7 @@ void NetworkServer_HandleChat(NetworkAction action, DestType desttype, int dest, } break; default: - DEBUG(net, 0)("[NET][Server] Received unknown destination type %d. Doing broadcast instead."); + DEBUG(net, 0, "[server] received unknown chat destination type %d. Doing broadcast instead", desttype); /* fall-through to next case */ case DESTTYPE_BROADCAST: FOR_ALL_CLIENTS(cs) { @@ -1126,11 +1126,11 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_RCON) NetworkRecv_string(cs, p, command, sizeof(command)); if (strcmp(pass, _network_game_info.rcon_password) != 0) { - DEBUG(net, 0)("[RCon] Wrong password from client-id %d", cs->index); + DEBUG(net, 0, "[rcon] wrong password from client-id %d", cs->index); return; } - DEBUG(net, 0)("[RCon] Client-id %d executed: %s", cs->index, command); + DEBUG(net, 0, "[rcon] client-id %d executed: '%s'", cs->index, command); _redirect_console_to_client = cs->index; IConsoleCmdExec(command); @@ -1314,7 +1314,7 @@ void NetworkUpdateClientInfo(uint16 client_index) static void NetworkCheckRestartMap(void) { if (_network_restart_game_year != 0 && _cur_year >= _network_restart_game_year) { - DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year); + DEBUG(net, 0, "Auto-restarting map. Year %d reached", _cur_year); StartNewGameWithoutGUI(GENERATE_NEW_SEED); } @@ -1428,7 +1428,7 @@ bool NetworkServer_ReadPackets(NetworkClientState *cs) if (type < PACKET_END && _network_server_packet[type] != NULL && !cs->has_quit) { _network_server_packet[type](cs, p); } else { - DEBUG(net, 0)("[NET][Server] Received invalid packet type %d", type); + DEBUG(net, 0, "[server] received invalid packet type %d", type); } free(p); } diff --git a/network_udp.c b/network_udp.c index 5ff0483c03..a2d6ed3955 100644 --- a/network_udp.c +++ b/network_udp.c @@ -139,7 +139,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER) free(packet); - DEBUG(net, 2)("[NET][UDP] Queried from %s", inet_ntoa(client_addr->sin_addr)); + DEBUG(net, 2, "[udp] queried from '%s'", inet_ntoa(client_addr->sin_addr)); } DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE) @@ -156,7 +156,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE) if (_udp_cs.has_quit) return; - DEBUG(net, 6)("[NET][UDP] Server response from %s:%d", inet_ntoa(client_addr->sin_addr),ntohs(client_addr->sin_port)); + DEBUG(net, 4, "[udp] server response from %s:%d", inet_ntoa(client_addr->sin_addr),ntohs(client_addr->sin_port)); // Find next item item = NetworkGameListAddItem(inet_addr(inet_ntoa(client_addr->sin_addr)), ntohs(client_addr->sin_port)); @@ -414,12 +414,10 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST) DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_ACK_REGISTER) { _network_advertise_retries = 0; - DEBUG(net, 2)("[NET][UDP] We are advertised on the master-server!"); + DEBUG(net, 2, "[udp] advertising on master server successfull"); - if (!_network_advertise) { - /* We are advertised, but we don't want to! */ - NetworkUDPRemoveAdvertise(); - } + /* We are advertised, but we don't want to! */ + if (!_network_advertise) NetworkUDPRemoveAdvertise(); } /** @@ -448,7 +446,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_GET_NEWGRFS) /* Just a fail-safe.. should never happen */ if (_udp_cs.has_quit) return; - DEBUG(net, 6)("[NET][UDP] NewGRF data request from %s:%d", inet_ntoa(client_addr->sin_addr), ntohs(client_addr->sin_port)); + DEBUG(net, 6, "[udp] newgrf data request from %s:%d", inet_ntoa(client_addr->sin_addr), ntohs(client_addr->sin_port)); num_grfs = NetworkRecv_uint8 (&_udp_cs, p); if (num_grfs > NETWORK_MAX_GRF_COUNT) return; @@ -502,7 +500,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_NEWGRFS) /* Just a fail-safe.. should never happen */ if (_udp_cs.has_quit) return; - DEBUG(net, 6)("[NET][UDP] NewGRF data reply from %s:%d", inet_ntoa(client_addr->sin_addr),ntohs(client_addr->sin_port)); + DEBUG(net, 6, "[udp] newgrf data reply from %s:%d", inet_ntoa(client_addr->sin_addr),ntohs(client_addr->sin_port)); num_grfs = NetworkRecv_uint8 (&_udp_cs, p); if (num_grfs > NETWORK_MAX_GRF_COUNT) return; @@ -566,9 +564,9 @@ static void NetworkHandleUDPPacket(Packet* p, struct sockaddr_in* client_addr) _network_udp_packet[type](p, client_addr); } else { if (!_udp_cs.has_quit) { - DEBUG(net, 0)("[NET][UDP] Received invalid packet type %d", type); + DEBUG(net, 0, "[udp] received invalid packet type %d", type); } else { - DEBUG(net, 0)("[NET][UDP] Received illegal packet"); + DEBUG(net, 0, "[udp] received illegal packet"); } } } @@ -586,10 +584,8 @@ static void NetworkSendUDP_Packet(SOCKET udp, Packet* p, struct sockaddr_in* rec // Send the buffer res = sendto(udp, p->buffer, p->size, 0, (struct sockaddr *)recv, sizeof(*recv)); - // Check for any errors, but ignore it for the rest - if (res == -1) { - DEBUG(net, 1)("[NET][UDP] Send error: %i", GET_LAST_ERROR()); - } + // Check for any errors, but ignore it otherwise + if (res == -1) DEBUG(net, 1, "[udp] sendto failed with: %i", GET_LAST_ERROR()); } // Start UDP listener @@ -602,7 +598,7 @@ bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast) *udp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (*udp == INVALID_SOCKET) { - DEBUG(net, 1)("[NET][UDP] Failed to start UDP support"); + DEBUG(net, 0, "[udp] failed to start UDP listener"); return false; } @@ -622,7 +618,7 @@ bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast) sin.sin_port = htons(port); if (bind(*udp, (struct sockaddr*)&sin, sizeof(sin)) != 0) { - DEBUG(net, 1) ("[NET][UDP] error: bind failed on %s:%i", inet_ntoa(*(struct in_addr *)&host), port); + DEBUG(net, 0, "[udp] bind failed on %s:%i", inet_ntoa(*(struct in_addr *)&host), port); return false; } @@ -634,7 +630,7 @@ bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast) #endif } - DEBUG(net, 1)("[NET][UDP] Listening on port %s:%d", inet_ntoa(*(struct in_addr *)&host), port); + DEBUG(net, 1, "[udp] listening on port %s:%d", inet_ntoa(*(struct in_addr *)&host), port); return true; } @@ -642,7 +638,7 @@ bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast) // Close UDP connection void NetworkUDPClose(void) { - DEBUG(net, 1) ("[NET][UDP] Closed listeners"); + DEBUG(net, 1, "[udp] closed listeners"); if (_network_udp_server) { if (_udp_server_socket != INVALID_SOCKET) { @@ -715,7 +711,7 @@ static void NetworkUDPBroadCast(SOCKET udp) out_addr.sin_port = htons(_network_server_port); out_addr.sin_addr.s_addr = _broadcast_list[i]; - DEBUG(net, 6)("[NET][UDP] Broadcasting to %s", inet_ntoa(out_addr.sin_addr)); + DEBUG(net, 4, "[udp] broadcasting to %s", inet_ntoa(out_addr.sin_addr)); NetworkSendUDP_Packet(udp, p, &out_addr); } @@ -745,7 +741,7 @@ void NetworkUDPQueryMasterServer(void) NetworkSendUDP_Packet(_udp_client_socket, p, &out_addr); - DEBUG(net, 2)("[NET][UDP] Queried Master Server at %s:%d", inet_ntoa(out_addr.sin_addr),ntohs(out_addr.sin_port)); + DEBUG(net, 2, "[udp] master server queried at %s:%d", inet_ntoa(out_addr.sin_addr),ntohs(out_addr.sin_port)); free(p); } @@ -754,15 +750,14 @@ void NetworkUDPQueryMasterServer(void) void NetworkUDPSearchGame(void) { // We are still searching.. - if (_network_udp_broadcast > 0) - return; + if (_network_udp_broadcast > 0) return; // No UDP-socket yet.. if (_udp_client_socket == INVALID_SOCKET) if (!NetworkUDPListen(&_udp_client_socket, 0, 0, true)) return; - DEBUG(net, 0)("[NET][UDP] Searching server"); + DEBUG(net, 0, "[udp] searching server"); NetworkUDPBroadCast(_udp_client_socket); _network_udp_broadcast = 300; // Stay searching for 300 ticks @@ -808,15 +803,14 @@ void NetworkUDPRemoveAdvertise(void) Packet *p; /* Check if we are advertising */ - if (!_networking || !_network_server || !_network_udp_server) - return; + if (!_networking || !_network_server || !_network_udp_server) return; /* check for socket */ if (_udp_master_socket == INVALID_SOCKET) if (!NetworkUDPListen(&_udp_master_socket, _network_server_bind_ip, 0, false)) return; - DEBUG(net, 2)("[NET][UDP] Removing advertise.."); + DEBUG(net, 1, "[udp] removing advertise from master server"); /* Find somewhere to send */ out_addr.sin_family = AF_INET; @@ -872,7 +866,7 @@ void NetworkUDPAdvertise(void) out_addr.sin_port = htons(NETWORK_MASTER_SERVER_PORT); out_addr.sin_addr.s_addr = NetworkResolveHost(NETWORK_MASTER_SERVER_HOST); - DEBUG(net, 1)("[NET][UDP] Advertising to master server"); + DEBUG(net, 1, "[udp] advertising to master server"); /* Send the packet */ p = NetworkSend_Init(PACKET_UDP_SERVER_REGISTER); diff --git a/newgrf.c b/newgrf.c index 53aa855947..be68ff5949 100644 --- a/newgrf.c +++ b/newgrf.c @@ -118,38 +118,16 @@ static uint16 cargo_disallowed[TOTAL_NUM_ENGINES]; /* Contains the GRF ID of the owner of a vehicle if it has been reserved */ static uint32 _grm_engines[TOTAL_NUM_ENGINES]; -/* Debugging messages policy: - * - * These should be the severities used for direct DEBUG() calls - * (there is room for exceptions, but you have to have a good cause): - * - * 0..2 - dedicated to grfmsg() - * 3 - * 4 - * 5 - * 6 - action handler entry reporting - one per action - * 7 - basic action progress reporting - in loops, only single one allowed - * 8 - more detailed progress reporting - less important stuff, in deep loops etc - * 9 - extremely detailed progress reporting - detailed reports inside of deep loops and so - */ - - -typedef enum grfmsg_severity { - GMS_NOTICE, - GMS_WARN, - GMS_ERROR, - GMS_FATAL, -} grfmsg_severity; - -static void CDECL grfmsg(grfmsg_severity severity, const char *str, ...) +/** DEBUG() function dedicated to newGRF debugging messages + * Function is essentialy the same as DEBUG(grf, severity, ...) with the + * addition of file:line information when parsing grf files. + * NOTE: for the above reason(s) grfmsg() should ONLY be used for + * loading/parsing grf files, not for runtime debug messages as there + * is no file information available during that time. + * @param severity debugging severity level, see debug.h + * @param debugging message in printf() format */ +void CDECL grfmsg(int severity, const char *str, ...) { - static const char* const severitystr[] = { - "Notice", - "Warning", - "Error", - "Fatal" - }; - int export_severity = 0; char buf[1024]; va_list va; @@ -157,8 +135,7 @@ static void CDECL grfmsg(grfmsg_severity severity, const char *str, ...) vsnprintf(buf, sizeof(buf), str, va); va_end(va); - export_severity = 2 - (severity == GMS_FATAL ? 2 : severity); - DEBUG(grf, export_severity) ("[%s:%d][%s] %s", _cur_grffile->filename, _nfo_line, severitystr[severity], buf); + DEBUG(grf, severity, "[%s:%d] %s", _cur_grfconfig->filename, _nfo_line, buf); } static inline void check_length(int real, int wanted, const char *str) @@ -261,7 +238,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf case 1: ei[i].railtype = RAILTYPE_MONO; break; case 2: ei[i].railtype = RAILTYPE_MAGLEV; break; default: - grfmsg(GMS_WARN, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring.", tracktype); + grfmsg(1, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring", tracktype); break; } } @@ -313,7 +290,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf case 0x4C3C: rvi[i].running_cost_class = 2; break; case 0: break; /* Used by wagons */ default: - grfmsg(GMS_WARN, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring.", base); + grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); break; } } @@ -364,7 +341,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf if (ctype < NUM_CARGO) { rvi[i].cargo_type = ctype; } else { - grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring.", ctype); + grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring", ctype); } } break; @@ -418,7 +395,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf if (pos < NUM_TRAIN_ENGINES) { AlterRailVehListOrder(engine + i, pos); } else { - grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring.", pos); + grfmsg(2, "RailVehicleChangeInfo: Invalid train engine ID %d, ignoring", pos); } } break; @@ -457,7 +434,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf byte weight = grf_load_byte(&buf); if (weight > 4) { - grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring.", weight << 8); + grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); } else { SB(rvi[i].weight, 8, 8, weight); } @@ -552,7 +529,7 @@ static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf if (cargo < NUM_CARGO) { rvi[i].cargo_type = cargo; } else { - grfmsg(GMS_NOTICE, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring.", cargo); + grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring", cargo); } } break; @@ -672,7 +649,7 @@ static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf if (cargo < NUM_CARGO) { svi[i].cargo_type = cargo; } else { - grfmsg(GMS_NOTICE, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring.", cargo); + grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring", cargo); } } break; @@ -856,7 +833,7 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int bool ret = false; if (stid + numinfo > MAX_STATIONS) { - grfmsg(GMS_WARN, "StationChangeInfo: Station %u is invalid, max %u, ignoring.", stid + numinfo, MAX_STATIONS); + grfmsg(1, "StationChangeInfo: Station %u is invalid, max %u, ignoring", stid + numinfo, MAX_STATIONS); return false; } @@ -869,7 +846,7 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int /* Check that all stations we are modifying are defined. */ FOR_EACH_OBJECT { if (statspec[i] == NULL) { - grfmsg(GMS_NOTICE, "StationChangeInfo: Attempt to modify undefined station %u, ignoring.", stid + i); + grfmsg(2, "StationChangeInfo: Attempt to modify undefined station %u, ignoring", stid + i); return false; } } @@ -1102,7 +1079,7 @@ static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int byte sprite; if (tableid >= 7) { // skip invalid data - grfmsg(GMS_WARN, "BridgeChangeInfo: Table %d >= 7, skipping.", tableid); + grfmsg(1, "BridgeChangeInfo: Table %d >= 7, skipping", tableid); for (sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); continue; } @@ -1148,7 +1125,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i if (price < NUM_PRICES) { SetPriceBaseMultiplier(price, factor); } else { - grfmsg(GMS_WARN, "GlobalVarChangeInfo: Price %d out of range, ignoring.", price); + grfmsg(1, "GlobalVarChangeInfo: Price %d out of range, ignoring", price); } } break; @@ -1175,7 +1152,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i * to be compatible */ _currency_specs[curidx].rate = rate / 1000; } else { - grfmsg(GMS_WARN, "GlobalVarChangeInfo: Currency multipliers %d out of range, ignoring.", curidx); + grfmsg(1, "GlobalVarChangeInfo: Currency multipliers %d out of range, ignoring", curidx); } } break; @@ -1191,7 +1168,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i * since newgrf specs said that only 0 and 1 can be set for symbol_pos */ _currency_specs[curidx].symbol_pos = GB(options, 8, 1); } else { - grfmsg(GMS_WARN, "GlobalVarChangeInfo: Currency option %d out of range, ignoring.", curidx); + grfmsg(1, "GlobalVarChangeInfo: Currency option %d out of range, ignoring", curidx); } } break; @@ -1205,7 +1182,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i memcpy(_currency_specs[curidx].prefix,&tempfix,4); _currency_specs[curidx].prefix[4] = 0; } else { - grfmsg(GMS_WARN, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring.", curidx); + grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); } } break; @@ -1219,7 +1196,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i memcpy(&_currency_specs[curidx].suffix,&tempfix,4); _currency_specs[curidx].suffix[4] = 0; } else { - grfmsg(GMS_WARN, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring.", curidx); + grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); } } break; @@ -1232,7 +1209,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i if (curidx < NUM_CURRENCY) { _currency_specs[curidx].to_euro = year_euro; } else { - grfmsg(GMS_WARN, "GlobalVarChangeInfo: Euro intro date %d out of range, ignoring.", curidx); + grfmsg(1, "GlobalVarChangeInfo: Euro intro date %d out of range, ignoring", curidx); } } break; @@ -1254,7 +1231,7 @@ static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, bool ret = false; if (_cur_grffile->sound_offset == 0) { - grfmsg(GMS_WARN, "SoundEffectChangeInfo: No effects defined, skipping."); + grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); return false; } @@ -1264,7 +1241,7 @@ static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); if (sound >= GetNumSounds()) { - grfmsg(GMS_WARN, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); + grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); } else { GetSound(sound)->volume = grf_load_byte(&buf); } @@ -1276,7 +1253,7 @@ static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); if (sound >= GetNumSounds()) { - grfmsg(GMS_WARN, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); + grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); } else { GetSound(sound)->priority = grf_load_byte(&buf); } @@ -1289,7 +1266,7 @@ static bool SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, uint orig_sound = grf_load_byte(&buf); if (sound >= GetNumSounds() || orig_sound >= GetNumSounds()) { - grfmsg(GMS_WARN, "SoundEffectChangeInfo: Sound %d or %d not defined (max %d)", sound, orig_sound, GetNumSounds()); + grfmsg(1, "SoundEffectChangeInfo: Sound %d or %d not defined (max %d)", sound, orig_sound, GetNumSounds()); } else { FileEntry *newfe = GetSound(sound); FileEntry *oldfe = GetSound(orig_sound); @@ -1350,7 +1327,7 @@ static void FeatureChangeInfo(byte *buf, int len) EngineInfo *ei = NULL; if (len == 1) { - DEBUG(grf, 8) ("Silently ignoring one-byte special sprite 0x00."); + grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); return; } @@ -1361,17 +1338,17 @@ static void FeatureChangeInfo(byte *buf, int len) numinfo = grf_load_byte(&buf); engine = grf_load_byte(&buf); - DEBUG(grf, 6) ("FeatureChangeInfo: Feature %d, %d properties, to apply to %d+%d", + grfmsg(6, "FeatureChangeInfo: feature %d, %d properties, to apply to %d+%d", feature, numprops, engine, numinfo); if (feature >= lengthof(handler) || handler[feature] == NULL) { - grfmsg(GMS_WARN, "FeatureChangeInfo: Unsupported feature %d, skipping.", feature); + grfmsg(1, "FeatureChangeInfo: Unsupported feature %d, skipping", feature); return; } if (feature <= GSF_AIRCRAFT) { if (engine + numinfo > _vehcounts[feature]) { - grfmsg(GMS_ERROR, "FeatureChangeInfo: Last engine ID %d out of bounds (max %d), skipping.", engine + numinfo, _vehcounts[feature]); + grfmsg(0, "FeatureChangeInfo: Last engine ID %d out of bounds (max %d), skipping", engine + numinfo, _vehcounts[feature]); return; } ei = &_engine_info[engine + _vehshifts[feature]]; @@ -1428,8 +1405,7 @@ static void FeatureChangeInfo(byte *buf, int len) break; } - if (ignoring) - grfmsg(GMS_NOTICE, "FeatureChangeInfo: Ignoring property 0x%02X (not implemented).", prop); + if (ignoring) grfmsg(2, "FeatureChangeInfo: Ignoring property 0x%02X (not implemented)", prop); } } @@ -1506,9 +1482,7 @@ static void NewSpriteSet(byte *buf, int len) _cur_grffile->spriteset_numsets = num_sets; _cur_grffile->spriteset_numents = num_ents; - DEBUG(grf, 7) ( - "New sprite set at %d of type %d, " - "consisting of %d sets with %d views each (total %d)", + grfmsg(7, "New sprite set at %d of type %d, consisting of %d sets with %d views each (total %d)", _cur_spriteid, feature, num_sets, num_ents, num_sets * num_ents ); @@ -1525,7 +1499,7 @@ static const SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 grou if (HASBIT(groupid, 15)) return NewCallBackResultSpriteGroup(groupid); if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty.", setid, type, groupid); + grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid); return NULL; } @@ -1538,7 +1512,7 @@ static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); if (spriteid >= _cur_grffile->spriteset_numsets) { - grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); + grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); return NULL; } @@ -1546,7 +1520,7 @@ static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte * is skipped, as TTDPatch mandates that Action 0x02s must be processed. * We don't have that rule, but must live by the Patch... */ if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { - grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty.", + grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty", setid, type, _cur_grffile->spriteset_start + spriteid * num_sprites, _cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1); @@ -1554,7 +1528,7 @@ static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte } if (feature != _cur_grffile->spriteset_feature) { - grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping.", + grfmsg(1, "NewSpriteGroup(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping", _cur_grffile->spriteset_feature, feature); return NULL; } @@ -1722,7 +1696,7 @@ static void NewSpriteGroup(byte *buf, int len) uint i; if (_cur_grffile->spriteset_start == 0) { - grfmsg(GMS_ERROR, "NewSpriteGroup: No sprite set to work on! Skipping."); + grfmsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); return; } @@ -1736,27 +1710,26 @@ static void NewSpriteGroup(byte *buf, int len) if (num_loaded > 0) group->g.real.loaded = calloc(num_loaded, sizeof(*group->g.real.loaded)); if (num_loading > 0) group->g.real.loading = calloc(num_loading, sizeof(*group->g.real.loading)); - DEBUG(grf, 6) ("NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", + grfmsg(6, "NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", setid, sprites, num_loaded, num_loading); for (i = 0; i < num_loaded; i++) { uint16 spriteid = grf_load_word(&buf); group->g.real.loaded[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); - DEBUG(grf, 8) ("NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); + grfmsg(8, "NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); } for (i = 0; i < num_loading; i++) { uint16 spriteid = grf_load_word(&buf); group->g.real.loading[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); - DEBUG(grf, 8) ("NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); + grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); } break; } /* Loading of Tile Layout and Production Callback groups would happen here */ - default: - grfmsg(GMS_WARN, "NewSpriteGroup: Unsupported feature %d, skipping.", feature); + default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); } } } @@ -1801,18 +1774,18 @@ static void FeatureMapSpriteGroup(byte *buf, int len) /* If ``n-id'' (or ``idcount'') is zero, this is a ``feature * callback''. */ if (idcount == 0) { - grfmsg(GMS_NOTICE, "FeatureMapSpriteGroup: Feature callbacks not implemented yet."); + grfmsg(2, "FeatureMapSpriteGroup: Feature callbacks not implemented yet"); return; } cidcount = buf[3 + idcount]; check_length(len, 4 + idcount + cidcount * 3, "FeatureMapSpriteGroup"); - DEBUG(grf, 6) ("FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d.", + grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d", feature, idcount, cidcount, wagover); if (feature > GSF_STATION) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Unsupported feature %d, skipping.", feature); + grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); return; } @@ -1830,7 +1803,7 @@ static void FeatureMapSpriteGroup(byte *buf, int len) uint16 groupid = grf_load_word(&bp); if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", + grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); return; } @@ -1839,7 +1812,7 @@ static void FeatureMapSpriteGroup(byte *buf, int len) if (ctype == 0xFF) ctype = GC_PURCHASE; if (ctype >= NUM_GLOBAL_CID) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); + grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); continue; } @@ -1852,7 +1825,7 @@ static void FeatureMapSpriteGroup(byte *buf, int len) uint16 groupid = grf_load_word(&bp); if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", + grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); return; } @@ -1875,7 +1848,7 @@ static void FeatureMapSpriteGroup(byte *buf, int len) // what should we exactly do with that? --pasky if (_cur_grffile->spriteset_start == 0 || _cur_grffile->spritegroups == 0) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: No sprite set to work on! Skipping."); + grfmsg(1, "FeatureMapSpriteGroup: No sprite set to work on! Skipping"); return; } @@ -1886,10 +1859,10 @@ static void FeatureMapSpriteGroup(byte *buf, int len) if (wagover) { if (last_engines_count == 0) { - grfmsg(GMS_ERROR, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with."); + grfmsg(0, "FeatureMapSpriteGroup: WagonOverride: No engine to do override with"); return; } - DEBUG(grf, 6) ("FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons.", + grfmsg(6, "FeatureMapSpriteGroup: WagonOverride: %u engines, %u wagons", last_engines_count, idcount); } @@ -1900,27 +1873,27 @@ static void FeatureMapSpriteGroup(byte *buf, int len) byte *bp = &buf[4 + idcount]; if (engine_id > _vehcounts[feature]) { - grfmsg(GMS_ERROR, "Id %u for feature 0x%02X is out of bounds.", engine_id, feature); + grfmsg(0, "Id %u for feature 0x%02X is out of bounds", engine_id, feature); return; } - DEBUG(grf, 7) ("FeatureMapSpriteGroup: [%d] Engine %d...", i, engine); + grfmsg(7, "FeatureMapSpriteGroup: [%d] Engine %d...", i, engine); for (c = 0; c < cidcount; c++) { uint8 ctype = grf_load_byte(&bp); uint16 groupid = grf_load_word(&bp); - DEBUG(grf, 8) ("FeatureMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); + grfmsg(8, "FeatureMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); + grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); return; } if (ctype == GC_INVALID) ctype = GC_PURCHASE; if (ctype >= NUM_GLOBAL_CID) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); + grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); continue; } @@ -1937,14 +1910,14 @@ static void FeatureMapSpriteGroup(byte *buf, int len) byte *bp = buf + 4 + idcount + cidcount * 3; uint16 groupid = grf_load_word(&bp); - DEBUG(grf, 8) ("-- Default group id 0x%04X", groupid); + grfmsg(8, "-- Default group id 0x%04X", groupid); for (i = 0; i < idcount; i++) { uint8 engine = buf[3 + i] + _vehshifts[feature]; // Don't tell me you don't love duplicated code! if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); + grfmsg(1, "FeatureMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping", groupid, _cur_grffile->spritegroups_count); return; } @@ -2015,7 +1988,7 @@ static void FeatureNewName(byte *buf, int len) } endid = id + num; - DEBUG(grf, 6) ("FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X.", + grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", id, endid, feature, lang); name = (const char*)buf; /*transfer read value*/ @@ -2025,7 +1998,7 @@ static void FeatureNewName(byte *buf, int len) size_t ofs = strlen(name) + 1; if (ofs < 128) { - DEBUG(grf, 8) ("FeatureNewName: %d <- %s", id, name); + grfmsg(8, "FeatureNewName: %d <- %s", id, name); switch (feature) { case GSF_TRAIN: @@ -2045,7 +2018,7 @@ static void FeatureNewName(byte *buf, int len) switch (GB(id, 8, 8)) { case 0xC4: /* Station class name */ if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { - grfmsg(GMS_WARN, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); + grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); } else { StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); @@ -2054,7 +2027,7 @@ static void FeatureNewName(byte *buf, int len) case 0xC5: /* Station name */ if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { - grfmsg(GMS_WARN, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); + grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); } else { _cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); } @@ -2067,7 +2040,7 @@ static void FeatureNewName(byte *buf, int len) break; default: - DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); + grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); break; } break; @@ -2080,7 +2053,7 @@ static void FeatureNewName(byte *buf, int len) switch (GB(id, 8,8)) { case 0xC9: /* House name */ default: - DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); + grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); } break; @@ -2089,7 +2062,7 @@ static void FeatureNewName(byte *buf, int len) AddGRFString(_cur_spriteid, id, lang, name); break; default : - DEBUG(grf,7) ("FeatureNewName: Unsupported feature (0x%02X)", feature); + grfmsg(7, "FeatureNewName: Unsupported feature (0x%02X)", feature); break; #endif } @@ -2097,9 +2070,9 @@ static void FeatureNewName(byte *buf, int len) /* ofs is the string length + 1, so if the string is empty, ofs * is 1 */ if (ofs == 1) { - DEBUG(grf, 7) ("FeatureNewName: Can't add empty name"); + grfmsg(7, "FeatureNewName: Can't add empty name"); } else { - DEBUG(grf, 7) ("FeatureNewName: Too long a name (%d)", ofs); + grfmsg(7, "FeatureNewName: Too long a name (%d)", ofs); } } name += ofs; @@ -2129,7 +2102,7 @@ static void GraphicsNew(byte *buf, int len) switch (type) { case 0x04: /* Signal graphics */ if (num != 112 && num != 240) { - grfmsg(GMS_WARN, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping."); + grfmsg(1, "GraphicsNews: Signal graphics sprite count must be 112 or 240, skipping"); return; } _signal_base = _cur_spriteid; @@ -2137,7 +2110,7 @@ static void GraphicsNew(byte *buf, int len) case 0x05: /* Catenary graphics */ if (num != 48) { - grfmsg(GMS_WARN, "GraphicsNews: Catenary graphics sprite count must be 48, skipping."); + grfmsg(1, "GraphicsNews: Catenary graphics sprite count must be 48, skipping"); return; } replace = SPR_ELRAIL_BASE + 3; @@ -2145,7 +2118,7 @@ static void GraphicsNew(byte *buf, int len) case 0x06: /* Foundations */ if (num != 74) { - grfmsg(GMS_WARN, "GraphicsNews: Foundation graphics sprite count must be 74, skipping."); + grfmsg(1, "GraphicsNews: Foundation graphics sprite count must be 74, skipping"); return; } replace = SPR_SLOPES_BASE; @@ -2153,7 +2126,7 @@ static void GraphicsNew(byte *buf, int len) case 0x08: /* Canal graphics */ if (num != 65) { - grfmsg(GMS_WARN, "GraphicsNews: Canal graphics sprite count must be 65, skipping."); + grfmsg(1, "GraphicsNews: Canal graphics sprite count must be 65, skipping"); return; } replace = SPR_CANALS_BASE + 5; @@ -2161,22 +2134,22 @@ static void GraphicsNew(byte *buf, int len) case 0x0D: /* Coast graphics */ if (num != 16) { - grfmsg(GMS_WARN, "GraphicsNews: Coast graphics sprite count must be 16, skipping."); + grfmsg(1, "GraphicsNews: Coast graphics sprite count must be 16, skipping"); return; } _coast_base = _cur_spriteid; break; default: - grfmsg(GMS_NOTICE, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring).\n", + grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)", type, num); return; } if (replace == 0) { - grfmsg(GMS_NOTICE, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid); + grfmsg(2, "GraphicsNew: Loading %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, _cur_spriteid); } else { - grfmsg(GMS_NOTICE, "GraphicsNew: Replacing %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, replace); + grfmsg(2, "GraphicsNew: Replacing %u sprites of type 0x%02X at SpriteID 0x%04X", num, type, replace); } for (; num > 0; num--) { @@ -2244,7 +2217,7 @@ static uint32 GetParamVal(byte param, uint32 *cond_val) if (param < 0x80) return _cur_grffile->param[param]; /* In-game variable. */ - grfmsg(GMS_WARN, "Unsupported in-game variable 0x%02X.", param); + grfmsg(1, "Unsupported in-game variable 0x%02X", param); return -1; } } @@ -2278,7 +2251,7 @@ static void CfgApply(byte *buf, int len) FioSeekTo(pos, SEEK_SET); if (type != 0xFF) { - grfmsg(GMS_NOTICE, "CfgApply: Ignoring (next sprite is real, unsupported)"); + grfmsg(2, "CfgApply: Ignoring (next sprite is real, unsupported)"); return; } @@ -2311,11 +2284,11 @@ static void CfgApply(byte *buf, int len) /* If the parameter is a GRF parameter (not an internal variable) check * if it (and all further sequential parameters) has been defined. */ if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= _cur_grffile->param_end) { - grfmsg(GMS_NOTICE, "CfgApply: Ignoring (param %d not set)", (param_num + (param_size - 1) / 4)); + grfmsg(2, "CfgApply: Ignoring (param %d not set)", (param_num + (param_size - 1) / 4)); break; } - DEBUG(grf, 8) ("CfgApply: Applying %u bytes from parameter 0x%02X at offset 0x%04X", param_size, param_num, offset); + grfmsg(8, "CfgApply: Applying %u bytes from parameter 0x%02X at offset 0x%04X", param_size, param_num, offset); for (i = 0; i < param_size; i++) { uint32 value = GetParamVal(param_num + i / 4, NULL); @@ -2371,18 +2344,18 @@ static void SkipIf(byte *buf, int len) } if (param < 0x80 && _cur_grffile->param_end <= param) { - DEBUG(grf, 7) ("Param %d undefined, skipping test", param); + grfmsg(7, "Param %d undefined, skipping test", param); return; } if (param == 0x88 && GetFileByGRFID(cond_val) == NULL) { - DEBUG(grf, 7) ("GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); + grfmsg(7, "GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); return; } param_val = GetParamVal(param, &cond_val); - DEBUG(grf, 7) ("Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); + grfmsg(7, "Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); switch (condtype) { case 0: result = !!(param_val & (1 << cond_val)); break; @@ -2433,13 +2406,11 @@ static void SkipIf(byte *buf, int len) break; } - default: - grfmsg(GMS_WARN, "Unsupported test %d. Ignoring.", condtype); - return; + default: grfmsg(1, "Unsupported test %d. Ignoring", condtype); return; } if (!result) { - grfmsg(GMS_NOTICE, "Not skipping sprites, test was false."); + grfmsg(2, "Not skipping sprites, test was false"); return; } @@ -2462,13 +2433,13 @@ static void SkipIf(byte *buf, int len) } if (choice != NULL) { - grfmsg(GMS_NOTICE, "Jumping to label 0x%0X at line %d, test was true.", choice->label, choice->nfo_line); + grfmsg(2, "Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line); FioSeekTo(choice->pos, SEEK_SET); _nfo_line = choice->nfo_line; return; } - grfmsg(GMS_NOTICE, "Skipping %d sprites, test was true.", numsprites); + grfmsg(2, "Skipping %d sprites, test was true", numsprites); _skip_sprites = numsprites; if (_skip_sprites == 0) { /* Zero means there are no sprites to skip, so @@ -2548,7 +2519,7 @@ static void GRFInfo(byte *buf, int len) SETBIT(_cur_grfconfig->flags, GCF_ACTIVATED); /* Do swap the GRFID for displaying purposes since people expect that */ - DEBUG(grf, 1) ("Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name); + DEBUG(grf, 1, "Loaded GRFv%d set %08lX - %s", version, BSWAP32(grfid), name); } /* Action 0x0A */ @@ -2572,8 +2543,7 @@ static void SpriteReplace(byte *buf, int len) uint16 first_sprite = grf_load_word(&buf); uint j; - grfmsg(GMS_NOTICE, - "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", + grfmsg(2, "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", i, num_sprites, first_sprite ); @@ -2647,7 +2617,7 @@ static void GRFComment(byte *buf, int len) if (len == 1) return; ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len)); - grfmsg(GMS_NOTICE, "GRFComment: %s", comment); + grfmsg(2, "GRFComment: %s", comment); } /* Action 0x0D */ @@ -2699,7 +2669,7 @@ static void ParamSet(byte *buf, int len) * an earlier action D */ if (oper & 0x80) { if (target < 0x80 && target < _cur_grffile->param_end) { - DEBUG(grf, 7) ("Param %u already defined, skipping.", target); + grfmsg(7, "Param %u already defined, skipping", target); return; } @@ -2710,7 +2680,7 @@ static void ParamSet(byte *buf, int len) if (GB(data, 0, 8) == 0xFF) { if (data == 0x0000FFFF) { /* Patch variables */ - grfmsg(GMS_NOTICE, "ParamSet: Reading Patch variables unsupported."); + grfmsg(2, "ParamSet: Reading Patch variables unsupported"); return; } else { /* GRF Resource Management */ @@ -2757,7 +2727,7 @@ static void ParamSet(byte *buf, int len) if (size == count) { /* Got the slot... */ if (op == 0 || op == 3) { - grfmsg(GMS_NOTICE, "GRM: Reserving %d vehicles at %d", count, start); + grfmsg(2, "GRM: Reserving %d vehicles at %d", count, start); for (i = 0; i < count; i++) _grm_engines[shift + start + i] = _cur_grffile->grfid; } src1 = start; @@ -2765,7 +2735,7 @@ static void ParamSet(byte *buf, int len) /* Unable to allocate */ if (op != 4 && op != 5) { /* Deactivate GRF */ - grfmsg(GMS_FATAL, "GRM: Unable to allocate %d vehicles, deactivating", count); + grfmsg(0, "GRM: Unable to allocate %d vehicles, deactivating", count); SETBIT(_cur_grfconfig->flags, GCF_DISABLED); CLRBIT(_cur_grfconfig->flags, GCF_ACTIVATED); @@ -2773,7 +2743,7 @@ static void ParamSet(byte *buf, int len) return; } - grfmsg(GMS_WARN, "GRM: Unable to allocate %d vehicles", count); + grfmsg(1, "GRM: Unable to allocate %d vehicles", count); src1 = -1; } break; @@ -2792,14 +2762,12 @@ static void ParamSet(byte *buf, int len) break; default: - grfmsg(GMS_WARN, "GRM: Unsupported operation %d for general sprites", op); + grfmsg(1, "GRM: Unsupported operation %d for general sprites", op); return; } break; - default: - grfmsg(GMS_WARN, "GRM: Unsupported feature 0x%X", feature); - return; + default: grfmsg(1, "GRM: Unsupported feature 0x%X", feature); return; } } } @@ -2905,9 +2873,7 @@ static void ParamSet(byte *buf, int len) } break; - default: - grfmsg(GMS_ERROR, "ParamSet: Unknown operation %d, skipping.", oper); - return; + default: grfmsg(0, "ParamSet: Unknown operation %d, skipping", oper); return; } switch (target) { @@ -2923,7 +2889,7 @@ static void ParamSet(byte *buf, int len) case 0x96: // Tile refresh offset downwards case 0x97: // Snow line height case 0x99: // Global ID offset - DEBUG(grf, 7) ("ParamSet: Skipping unimplemented target 0x%02X", target); + grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); break; case 0x9E: /* Miscellaneous GRF features */ @@ -2937,7 +2903,7 @@ static void ParamSet(byte *buf, int len) _cur_grffile->param[target] = res; if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; } else { - DEBUG(grf, 7) ("ParamSet: Skipping unknown target 0x%02X", target); + grfmsg(7, "ParamSet: Skipping unknown target 0x%02X", target); } break; } @@ -2965,7 +2931,7 @@ static void GRFInhibit(byte *buf, int len) /* Unset activation flag */ if (file != NULL && file != _cur_grfconfig) { - grfmsg(GMS_NOTICE, "GRFInhibit: Deactivating file ``%s''", file->filename); + grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename); SETBIT(file->flags, GCF_DISABLED); CLRBIT(file->flags, GCF_ACTIVATED); } @@ -3001,7 +2967,7 @@ static void DefineGotoLabel(byte *buf, int len) l->next = label; } - grfmsg(GMS_NOTICE, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); + grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); } /* Action 0x11 */ @@ -3032,16 +2998,16 @@ static void ImportGRFSound(byte *buf, int len) file = GetFileByGRFID(grfid); if (file == NULL || file->sound_offset == 0) { - grfmsg(GMS_WARN, "ImportGRFSound: Source file not available."); + grfmsg(1, "ImportGRFSound: Source file not available"); return; } if (file->sound_offset + sound >= GetNumSounds()) { - grfmsg(GMS_WARN, "ImportGRFSound: Sound effect %d is invalid.", sound); + grfmsg(1, "ImportGRFSound: Sound effect %d is invalid", sound); return; } - grfmsg(GMS_NOTICE, "ImportGRFSound: Copying sound %d (%d) from file %X", sound, file->sound_offset + sound, grfid); + grfmsg(2, "ImportGRFSound: Copying sound %d (%d) from file %X", sound, file->sound_offset + sound, grfid); *se = *GetSound(file->sound_offset + sound); @@ -3054,7 +3020,7 @@ static void ImportGRFSound(byte *buf, int len) static void GRFImportBlock(byte *buf, int len) { if (_grf_data_blocks == 0) { - grfmsg(GMS_NOTICE, "GRFImportBlock: Unexpected import block, skipping."); + grfmsg(2, "GRFImportBlock: Unexpected import block, skipping"); return; } @@ -3065,7 +3031,7 @@ static void GRFImportBlock(byte *buf, int len) /* XXX 'Action 0xFE' isn't really specified. It is only mentioned for * importing sounds, so this is probably all wrong... */ if (grf_load_byte(&buf) != _grf_data_type) { - grfmsg(GMS_WARN, "GRFImportBlock: Import type mismatch."); + grfmsg(1, "GRFImportBlock: Import type mismatch"); } switch (_grf_data_type) { @@ -3084,7 +3050,7 @@ static void LoadGRFSound(byte *buf, int len) se = AllocateFileEntry(); if (grf_load_dword(&buf) != BSWAP32('RIFF')) { - grfmsg(GMS_WARN, "LoadGRFSound: Missing RIFF header"); + grfmsg(1, "LoadGRFSound: Missing RIFF header"); return; } @@ -3092,7 +3058,7 @@ static void LoadGRFSound(byte *buf, int len) grf_load_dword(&buf); if (grf_load_dword(&buf) != BSWAP32('WAVE')) { - grfmsg(GMS_WARN, "LoadGRFSound: Invalid RIFF type"); + grfmsg(1, "LoadGRFSound: Invalid RIFF type"); return; } @@ -3104,7 +3070,7 @@ static void LoadGRFSound(byte *buf, int len) case ' tmf': /* 'fmt ' */ /* Audio format, must be 1 (PCM) */ if (grf_load_word(&buf) != 1) { - grfmsg(GMS_WARN, "LoadGRFSound: Invalid audio format"); + grfmsg(1, "LoadGRFSound: Invalid audio format"); return; } se->channels = grf_load_word(&buf); @@ -3126,7 +3092,7 @@ static void LoadGRFSound(byte *buf, int len) se->volume = 0x80; se->priority = 0; - grfmsg(GMS_NOTICE, "LoadGRFSound: channels %u, sample rate %u, bits per sample %u, length %u", se->channels, se->rate, se->bits_per_sample, size); + grfmsg(2, "LoadGRFSound: channels %u, sample rate %u, bits per sample %u, length %u", se->channels, se->rate, se->bits_per_sample, size); return; default: @@ -3162,7 +3128,7 @@ static void LoadFontGlyph(byte *buf, int len) uint16 base_char = grf_load_word(&buf); uint c; - DEBUG(grf, 7) ("LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); + grfmsg(7, "LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); for (c = 0; c < num_char; c++) { SetUnicodeGlyph(size, base_char + c, _cur_spriteid); @@ -3179,7 +3145,7 @@ static void GRFDataBlock(byte *buf, int len) const char *name; if (_grf_data_blocks == 0) { - grfmsg(GMS_NOTICE, "GRFDataBlock: unexpected data block, skipping."); + grfmsg(2, "GRFDataBlock: unexpected data block, skipping"); return; } @@ -3188,7 +3154,7 @@ static void GRFDataBlock(byte *buf, int len) name = (const char *)buf; buf += name_len + 1; - grfmsg(GMS_NOTICE, "GRFDataBlock: block name '%s'...", name); + grfmsg(2, "GRFDataBlock: block name '%s'...", name); _grf_data_blocks--; @@ -3583,7 +3549,7 @@ static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) /* Use the preloaded sprite data. */ buf = _preload_sprite; _preload_sprite = NULL; - DEBUG(grf, 7) ("DecodeSpecialSprite: Using preloaded pseudo sprite data"); + grfmsg(7, "DecodeSpecialSprite: Using preloaded pseudo sprite data"); /* Skip the real (original) content of this action. */ FioSeekTo(num, SEEK_CUR); @@ -3592,17 +3558,17 @@ static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) action = buf[0]; if (action == 0xFF) { - DEBUG(grf, 7) ("Handling data block in stage %d", stage); + grfmsg(7, "Handling data block in stage %d", stage); GRFDataBlock(buf, num); } else if (action == 0xFE) { - DEBUG(grf, 7) ("Handling import block in stage %d", stage); + grfmsg(7, "Handling import block in stage %d", stage); GRFImportBlock(buf, num); } else if (action >= lengthof(handlers)) { - DEBUG(grf, 7) ("Skipping unknown action 0x%02X", action); + grfmsg(7, "Skipping unknown action 0x%02X", action); } else if (handlers[action][stage] == NULL) { - DEBUG(grf, 7) ("Skipping action 0x%02X in stage %d", action, stage); + grfmsg(7, "Skipping action 0x%02X in stage %d", action, stage); } else { - DEBUG(grf, 7) ("Handling action 0x%02X in stage %d", action, stage); + grfmsg(7, "Handling action 0x%02X in stage %d", action, stage); handlers[action][stage](buf, num); } free(buf); @@ -3625,7 +3591,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) * processed once at initialization. */ if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { _cur_grffile = GetFileByFilename(filename); - if (_cur_grffile == NULL) error("File ``%s'' lost in cache.\n", filename); + if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename); if (stage == GLS_ACTIVATION && !HASBIT(config->flags, GCF_ACTIVATED)) return; } @@ -3634,7 +3600,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) _cur_grfconfig = config; - DEBUG(grf, 7) ("Reading NewGRF-file '%s'", filename); + DEBUG(grf, 2, "Reading NewGRF-file '%s'", filename); /* Skip the first sprite; we don't care about how many sprites this * does contain; newest TTDPatches and George's longvehicles don't @@ -3642,7 +3608,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) if (FioReadWord() == 4 && FioReadByte() == 0xFF) { FioReadDword(); } else { - DEBUG(grf, 7) ("Custom .grf has invalid format."); + DEBUG(grf, 7, "Custom .grf has invalid format"); return; } @@ -3665,7 +3631,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) FioSkipBytes(num); } } else { - if (_skip_sprites == 0) DEBUG(grf, 7) ("Skipping unexpected sprite"); + if (_skip_sprites == 0) grfmsg(7, "Skipping unexpected sprite"); FioSkipBytes(7); num -= 8; @@ -3712,15 +3678,13 @@ void LoadNewGRF(uint load_index, uint file_index) for (c = _grfconfig; c != NULL; c = c->next) { if (HASBIT(c->flags, GCF_DISABLED) || HASBIT(c->flags, GCF_NOT_FOUND)) continue; - if (!FioCheckFileExists(c->filename)) { - // TODO: usrerror() - error("NewGRF file missing: %s", c->filename); - } + // TODO usererror() + if (!FioCheckFileExists(c->filename)) error("NewGRF file is missing '%s'", c->filename); if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); LoadNewGRFFile(c, slot++, stage); if (stage == GLS_ACTIVATION) ClearTemporaryNewGRFData(); - DEBUG(spritecache, 2) ("Currently %i sprites are loaded", load_index); + DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); } } diff --git a/newgrf.h b/newgrf.h index 2cefa9c84e..1d8c5a3659 100644 --- a/newgrf.h +++ b/newgrf.h @@ -68,4 +68,6 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage); void LoadNewGRF(uint load_index, uint file_index); void ReloadNewGRFData(void); // in openttd.c +void CDECL grfmsg(int severity, const char *str, ...); + #endif /* NEWGRF_H */ diff --git a/newgrf_config.c b/newgrf_config.c index 6b74c99b29..f07e869e97 100644 --- a/newgrf_config.c +++ b/newgrf_config.c @@ -162,7 +162,7 @@ bool IsGoodGRFConfigList(void) res = false; } else { - DEBUG(grf, 1) ("[GRF] Loading GRF %08X from %s", BSWAP32(c->grfid), f->filename); + DEBUG(grf, 1, "Loading GRF %08X from '%s'", BSWAP32(c->grfid), f->filename); /* The filename could be the filename as in the savegame. As we need * to load the GRF here, we need the correct filename, so overwrite that * in any case and set the name and info when it is not set already. @@ -257,9 +257,9 @@ void ScanNewGRFFiles(void) ClearGRFConfigList(&_all_grfs); - DEBUG(grf, 1) ("[GRF] Scanning for NewGRFs"); + DEBUG(grf, 1, "Scanning for NewGRFs"); num = ScanPath(_paths.data_dir); - DEBUG(grf, 1) ("[GRF] Scan complete, found %d files", num); + DEBUG(grf, 1, "Scan complete, found %d files", num); } @@ -406,3 +406,4 @@ const ChunkHandler _newgrf_chunk_handlers[] = { { 'NGRF', Save_NGRF, Load_NGRF, CH_ARRAY | CH_LAST } }; + diff --git a/newgrf_engine.c b/newgrf_engine.c index 328ed3290e..0662f3fc89 100644 --- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -153,7 +153,7 @@ void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *grou assert(cargo < NUM_GLOBAL_CID); if (engine_custom_sprites[engine][cargo] != NULL) { - DEBUG(grf, 6)("SetCustomEngineSprites: engine `%d' cargo `%d' already has group -- replacing.", engine, cargo); + grfmsg(6, "SetCustomEngineSprites: engine %d cargo %d already has group -- replacing", engine, cargo); } engine_custom_sprites[engine][cargo] = group; } @@ -183,7 +183,7 @@ void SetRotorOverrideSprites(EngineID engine, const SpriteGroup *group) assert(engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES); if (heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] != NULL) { - DEBUG(grf, 6)("SetRotorOverrideSprites: engine `%d' already has group -- replacing.", engine); + grfmsg(6, "SetRotorOverrideSprites: engine %d already has group -- replacing.", engine); } heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] = group; } @@ -803,7 +803,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by break; } - DEBUG(grf, 1)("Unhandled vehicle property 0x%X, type 0x%X", variable, v->type); + DEBUG(grf, 1, "Unhandled vehicle property 0x%X, type 0x%X", variable, v->type); *available = false; return -1; diff --git a/newgrf_station.c b/newgrf_station.c index 043fe113d5..96e4f34be2 100644 --- a/newgrf_station.c +++ b/newgrf_station.c @@ -12,6 +12,7 @@ #include "table/strings.h" #include "station.h" #include "station_map.h" +#include "newgrf.h" #include "newgrf_callbacks.h" #include "newgrf_station.h" #include "newgrf_spritegroup.h" @@ -74,7 +75,7 @@ StationClassID AllocateStationClass(uint32 class) } } - DEBUG(grf, 2)("StationClassAllocate: Already allocated %d classes, using default.", STAT_CLASS_MAX); + grfmsg(2, "StationClassAllocate: already allocated %d classes, using default", STAT_CLASS_MAX); return STAT_CLASS_DFLT; } @@ -390,7 +391,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by } } - DEBUG(grf, 1)("Unhandled station property 0x%X", variable); + DEBUG(grf, 1, "Unhandled station property 0x%X", variable); *available = false; return -1; diff --git a/newgrf_text.c b/newgrf_text.c index e21a66bd72..e859f6e6c5 100644 --- a/newgrf_text.c +++ b/newgrf_text.c @@ -17,6 +17,7 @@ #include "variables.h" #include "macros.h" #include "table/strings.h" +#include "newgrf.h" #include "newgrf_text.h" #include "table/control_codes.h" @@ -327,7 +328,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne if (!replaced) *ptext = newtext; } - DEBUG(grf, 2)("Added 0x%X: grfid 0x%X string 0x%X lang 0x%X string %s", id, grfid, stringid, newtext->langid, newtext->text); + grfmsg(3, "Added 0x%X: grfid %08X string 0x%X lang 0x%X string '%s'", id, grfid, stringid, newtext->langid, newtext->text); return (GRFTAB << TABSIZE) + id; } diff --git a/npf.c b/npf.c index 7e680e30a0..5fa37d2abe 100644 --- a/npf.c +++ b/npf.c @@ -133,7 +133,7 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar* as, AyStarNode* current, Open dist = NPFDistanceTrack(from, to); } - DEBUG(npf, 4)("Calculating H for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), dist); + DEBUG(npf, 4, "Calculating H for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), dist); if (dist < ftd->best_bird_dist) { ftd->best_bird_dist = dist; @@ -153,7 +153,7 @@ static void NPFFillTrackdirChoice(AyStarNode* current, OpenListNode* parent) /* This is a first order decision, so we'd better save the * direction we chose */ current->user_data[NPF_TRACKDIR_CHOICE] = trackdir; - DEBUG(npf, 6)("Saving trackdir: 0x%X", trackdir); + DEBUG(npf, 6, "Saving trackdir: 0x%X", trackdir); } else { /* We've already made the decision, so just save our parent's decision */ current->user_data[NPF_TRACKDIR_CHOICE] = parent->path.node.user_data[NPF_TRACKDIR_CHOICE]; @@ -293,7 +293,7 @@ static int32 NPFRoadPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare cost += _patches.npf_road_curve_penalty; NPFMarkTile(tile); - DEBUG(npf, 4)("Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost); + DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost); return cost; } @@ -397,7 +397,7 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare //TODO NPFMarkTile(tile); - DEBUG(npf, 4)("Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost); + DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost); return cost; } @@ -528,7 +528,7 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current) TransportType type = aystar->user_data[NPF_TYPE]; /* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */ aystar->num_neighbours = 0; - DEBUG(npf, 4)("Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); + DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile); /* Find dest tile */ if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) { @@ -618,13 +618,13 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current) } trackdirbits = ts & TRACKDIR_BIT_MASK; /* Filter out signal status and the unused bits */ - DEBUG(npf, 4)("Next node: (%d, %d) [%d], possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits); + DEBUG(npf, 4, "Next node: (%d, %d) [%d], possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits); /* Select only trackdirs we can reach from our current trackdir */ trackdirbits &= TrackdirReachesTrackdirs(src_trackdir); if (_patches.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) /* Filter out trackdirs that would make 90 deg turns for trains */ trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir); - DEBUG(npf,6)("After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits); + DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits); i = 0; /* Enumerate possible track */ @@ -632,7 +632,7 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current) Trackdir dst_trackdir; dst_trackdir = FindFirstBit2x64(trackdirbits); trackdirbits = KillFirstBit2x64(trackdirbits); - DEBUG(npf, 5)("Expanded into trackdir: %d, remaining trackdirs: 0x%X", dst_trackdir, trackdirbits); + DEBUG(npf, 5, "Expanded into trackdir: %d, remaining trackdirs: 0x%X", dst_trackdir, trackdirbits); /* Check for oneway signal against us */ if (IsTileType(dst_tile, MP_RAILWAY) && GetRailTileType(dst_tile) == RAIL_TILE_SIGNALS) { @@ -712,10 +712,10 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, AyStarNode* start if (result.best_bird_dist != 0) { if (target != NULL) { - DEBUG(npf, 1) ("Could not find route to tile 0x%X from 0x%X.", target->dest_coords, start1->tile); + DEBUG(npf, 1, "Could not find route to tile 0x%X from 0x%X.", target->dest_coords, start1->tile); } else { /* Assumption: target == NULL, so we are looking for a depot */ - DEBUG(npf, 1) ("Could not find route to a depot from tile 0x%X.", start1->tile); + DEBUG(npf, 1, "Could not find route to a depot from tile 0x%X.", start1->tile); } } @@ -861,7 +861,7 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, best_result = result; } if (result.best_bird_dist != 0) { - DEBUG(npf, 1) ("Could not find route to any depot from tile 0x%X.", tile); + DEBUG(npf, 1, "Could not find route to any depot from tile 0x%X.", tile); } return best_result; } diff --git a/oldloader.c b/oldloader.c index ea447290d3..e0579eb60a 100644 --- a/oldloader.c +++ b/oldloader.c @@ -124,7 +124,7 @@ static byte ReadByteFromFile(LoadgameState *ls) /* We tried to read, but there is nothing in the file anymore.. */ if (count == 0) { - DEBUG(oldloader, 1)("[OldLoader] Read past end of file, loading failed"); + DEBUG(oldloader, 0, "Read past end of file, loading failed"); ls->failed = true; } @@ -211,7 +211,7 @@ static bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks) break; case OC_ASSERT: - DEBUG(oldloader, 4)("[OldLoader] Assert point: 0x%X / 0x%X", ls->total_read, chunk->offset + _bump_assert_value); + DEBUG(oldloader, 4, "Assert point: 0x%X / 0x%X", ls->total_read, chunk->offset + _bump_assert_value); if (ls->total_read != chunk->offset + _bump_assert_value) ls->failed = true; default: break; } @@ -422,10 +422,9 @@ static void ReadTTDPatchFlags(void) for (i = 0; i < 17; i++) _old_map3[i] = 0; for (i = 0x1FE00; i < 0x20000; i++) _old_map3[i] = 0; - if (_new_ttdpatch_format) - DEBUG(oldloader, 1)("[OldLoader] Found TTDPatch game"); + if (_new_ttdpatch_format) DEBUG(oldloader, 1, "Found TTDPatch game"); - DEBUG(oldloader, 1)("[OldLoader] Vehicle-multiplier is set to %d (%d vehicles)", _old_vehicle_multiplier, _old_vehicle_multiplier * 850); + DEBUG(oldloader, 1, "Vehicle-multiplier is set to %d (%d vehicles)", _old_vehicle_multiplier, _old_vehicle_multiplier * 850); } static const OldChunks town_chunk[] = { @@ -1095,7 +1094,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int num) /* This chunk size should always be 10 bytes */ if (ls->total_read - temp != 10) { - DEBUG(oldloader, 4)("[OldLoader] Assert failed in Vehicle"); + DEBUG(oldloader, 4, "Assert failed in Vehicle"); return false; } @@ -1204,7 +1203,7 @@ static bool LoadOldVehicle(LoadgameState *ls, int num) /* This should be consistent, else we have a big problem... */ if (v->index != _current_vehicle_id) { - DEBUG(oldloader, 0)("[OldLoader] -- Loading failed - vehicle-array is invalid"); + DEBUG(oldloader, 0, "Loading failed - vehicle-array is invalid"); return false; } @@ -1490,13 +1489,13 @@ static bool LoadOldMain(LoadgameState *ls) /* The first 49 is the name of the game + checksum, skip it */ fseek(ls->file, HEADER_SIZE, SEEK_SET); - DEBUG(oldloader, 4)("[OldLoader] Going to read main chunk.."); + DEBUG(oldloader, 4, "Reading main chunk..."); /* Load the biggest chunk */ if (!LoadChunk(ls, NULL, main_chunk)) { - DEBUG(oldloader, 0)("[OldLoader] Loading failed!"); + DEBUG(oldloader, 0, "Loading failed"); return false; } - DEBUG(oldloader, 4)("[OldLoader] Done. Converting stuff.."); + DEBUG(oldloader, 4, "Done, converting game data..."); /* Fix some general stuff */ _opt.landscape = _opt.landscape & 0xF; @@ -1534,8 +1533,8 @@ static bool LoadOldMain(LoadgameState *ls) /* We have a new difficulty setting */ _opt.diff.town_council_tolerance = clamp(_opt.diff_level, 0, 2); - DEBUG(oldloader, 4)("[OldLoader] Done!"); - DEBUG(oldloader, 1)("[OldLoader] TTD(Patch) savegame successfully converted"); + DEBUG(oldloader, 4, "Finished converting game data"); + DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted"); return true; } @@ -1544,7 +1543,7 @@ bool LoadOldSaveGame(const char *file) { LoadgameState ls; - DEBUG(oldloader, 4)("[OldLoader] Trying to load an TTD(Patch) savegame"); + DEBUG(oldloader, 4, "Trying to load a TTD(Patch) savegame"); InitLoading(&ls); @@ -1552,7 +1551,7 @@ bool LoadOldSaveGame(const char *file) ls.file = fopen(file, "rb"); if (ls.file == NULL) { - DEBUG(oldloader, 0)("[OldLoader] Could not open file %s", file); + DEBUG(oldloader, 0, "Cannot open file '%s'", file); return false; } diff --git a/oldpool.c b/oldpool.c index e857907f17..2b2d188e88 100644 --- a/oldpool.c +++ b/oldpool.c @@ -13,7 +13,7 @@ void CleanPool(OldMemoryPool *pool) { uint i; - DEBUG(misc, 4)("[Pool] (%s) Cleaning pool..", pool->name); + DEBUG(misc, 4, "[Pool] (%s) cleaning pool..", pool->name); /* Free all blocks */ for (i = 0; i < pool->current_blocks; i++) { @@ -46,12 +46,11 @@ bool AddBlockToPool(OldMemoryPool *pool) pool->total_items = (pool->current_blocks + 1) * (1 << pool->block_size_bits); - DEBUG(misc, 4)("[Pool] (%s) Increasing size of pool to %d items (%d bytes)", pool->name, pool->total_items, pool->total_items * pool->item_size); + DEBUG(misc, 4, "[Pool] (%s) increasing size of pool to %d items (%d bytes)", pool->name, pool->total_items, pool->total_items * pool->item_size); /* Increase the poolsize */ pool->blocks = realloc(pool->blocks, sizeof(pool->blocks[0]) * (pool->current_blocks + 1)); - if (pool->blocks == NULL) - error("Pool: (%s) could not allocate memory for blocks", pool->name); + if (pool->blocks == NULL) error("Pool: (%s) could not allocate memory for blocks", pool->name); /* Allocate memory to the new block item */ pool->blocks[pool->current_blocks] = malloc(pool->item_size * (1 << pool->block_size_bits)); diff --git a/openttd.c b/openttd.c index 4fcc78e70c..8b825966a8 100644 --- a/openttd.c +++ b/openttd.c @@ -429,7 +429,7 @@ int ttd_main(int argc, char *argv[]) AI_Initialize(); // Sample catalogue - DEBUG(misc, 1) ("Loading sound effects..."); + DEBUG(misc, 1, "Loading sound effects..."); MxInitialize(11025); SoundInitialize("sample.cat"); @@ -442,7 +442,7 @@ int ttd_main(int argc, char *argv[]) /* Initialize game palette */ GfxInitPalettes(); - DEBUG(driver, 1) ("Loading drivers..."); + DEBUG(driver, 1, "Loading drivers..."); LoadDriver(SOUND_DRIVER, _ini_sounddriver); LoadDriver(MUSIC_DRIVER, _ini_musicdriver); LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads @@ -653,7 +653,7 @@ static void StartScenario(void) // invalid type if (_file_to_saveload.mode == SL_INVALID) { - DEBUG(misc, 0) ("[Sl] Savegame is obsolete or invalid format: %s", _file_to_saveload.name); + DEBUG(sl, 0, "Savegame is obsolete or invalid format: '%s'", _file_to_saveload.name); ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0); _game_mode = GM_MENU; return; @@ -912,7 +912,7 @@ static void DoAutosave(void) } } - DEBUG(misc, 2) ("Autosaving to %s", buf); + DEBUG(sl, 2, "Autosaving to '%s'", buf); if (SaveOrLoad(buf, SL_SAVE) != SL_OK) ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); } @@ -1124,7 +1124,6 @@ static inline RailType UpdateRailType(RailType rt, RailType min) return rt >= min ? (RailType)(rt + 1): rt; } - bool AfterLoadGame(void) { Window *w; diff --git a/order_cmd.c b/order_cmd.c index 4c318cb32c..b510e84eaf 100644 --- a/order_cmd.c +++ b/order_cmd.c @@ -1006,7 +1006,7 @@ void CheckOrders(const Vehicle* v) if (problem_type < 0) return; message = STR_TRAIN_HAS_TOO_FEW_ORDERS + ((v->type - VEH_Train) << 2) + problem_type; - //DEBUG(misc, 3) ("Triggered News Item for %d", v->index); + //DEBUG(misc, 3, "Triggered News Item for vehicle %d", v->index); SetDParam(0, v->unitnumber); AddNewsItem( diff --git a/pathfind.c b/pathfind.c index 1e724c632c..961042f203 100644 --- a/pathfind.c +++ b/pathfind.c @@ -533,7 +533,7 @@ static bool NtpVisit(NewTrackPathFinder* tpf, TileIndex tile, DiagDirection dir, // allocate a link. if out of links, handle this by returning // that a tile was already visisted. if (tpf->num_links_left == 0) { - DEBUG(ntp, 1) ("[NTP] no links left"); + DEBUG(ntp, 1, "No links left"); return false; } @@ -567,7 +567,7 @@ static bool NtpVisit(NewTrackPathFinder* tpf, TileIndex tile, DiagDirection dir, /* get here if we need to add a new link to link, * first, allocate a new link, in the same way as before */ if (tpf->num_links_left == 0) { - DEBUG(ntp, 1) ("[NTP] no links left"); + DEBUG(ntp, 1, "No links left"); return false; } tpf->num_links_left--; @@ -735,7 +735,7 @@ start_at: // too long search length? bail out. if (si.cur_length >= tpf->maxlength) { - DEBUG(ntp,1) ("[NTP] cur_length too big"); + DEBUG(ntp, 1, "Cur_length too big"); bits = 0; break; } @@ -884,7 +884,7 @@ start_at: // out of stack items, bail out? if (tpf->nstack >= lengthof(tpf->stack)) { - DEBUG(ntp, 1) ("[NTP] out of stack"); + DEBUG(ntp, 1, "Out of stack"); break; } diff --git a/rail_cmd.c b/rail_cmd.c index 19af91a9b3..d1f7ead8a7 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1665,7 +1665,7 @@ make_red: ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]]; ssd->cur_stack++; } else { - DEBUG(misc, 0) ("NUM_SSD_STACK too small"); /// @todo WTF is this??? + DEBUG(misc, 0, "NUM_SSD_STACK too small"); /// @todo WTF is this??? } } diff --git a/roadveh_cmd.c b/roadveh_cmd.c index b5ed7807d6..57143853bc 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -252,7 +252,7 @@ void ClearSlot(Vehicle *v) assert(rs->num_vehicles != 0); rs->num_vehicles--; - DEBUG(ms, 3) ("Multistop: Clearing slot at 0x%X", rs->xy); + DEBUG(ms, 3, "Clearing slot at 0x%X", rs->xy); } /** Sell a road vehicle. @@ -1041,7 +1041,7 @@ static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Tra void* perf = NpfBeginInterval(); NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes); int t = NpfEndInterval(perf); - DEBUG(yapf, 4)("[YAPF][NPFR] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size); + DEBUG(yapf, 4, "[NPFR] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size); return ret; } @@ -1542,22 +1542,22 @@ again: //we have arrived at the wrong station //XXX The question is .. what to do? Actually we shouldn't be here //but I guess we need to clear the slot - DEBUG(ms, 0) ("Multistop: Vehicle %d (index %d) arrived at wrong stop.", v->unitnumber, v->index); + DEBUG(ms, 0, "Vehicle %d (index %d) arrived at wrong stop", v->unitnumber, v->index); if (v->tile != v->dest_tile) { - DEBUG(ms, 0) ("Multistop: -- Current tile 0x%X is not destination tile 0x%X. Route problem", v->tile, v->dest_tile); + DEBUG(ms, 2, " current tile 0x%X is not destination tile 0x%X. Route problem", v->tile, v->dest_tile); } if (v->dest_tile != v->u.road.slot->xy) { - DEBUG(ms, 0) ("Multistop: -- Stop tile 0x%X is not destination tile 0x%X. Multistop desync", v->u.road.slot->xy, v->dest_tile); + DEBUG(ms, 2, " stop tile 0x%X is not destination tile 0x%X. Multistop desync", v->u.road.slot->xy, v->dest_tile); } if (v->current_order.type != OT_GOTO_STATION) { - DEBUG(ms, 0) ("Multistop: -- Current order type (%d) is not OT_GOTO_STATION.", v->current_order.type); + DEBUG(ms, 2, " current order type (%d) is not OT_GOTO_STATION", v->current_order.type); } else { if (v->current_order.dest != st->index) - DEBUG(ms, 0) ("Multistop: -- Current station %d is not target station in current_order.station (%d).", + DEBUG(ms, 2, " current station %d is not target station in current_order.station (%d)", st->index, v->current_order.dest); } - DEBUG(ms, 0) (" -- Force a slot clearing."); + DEBUG(ms, 2, " force a slot clearing"); ClearSlot(v); } @@ -1652,7 +1652,7 @@ void OnNewDay_RoadVeh(Vehicle *v) //Current slot has expired if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot != NULL && v->u.road.slot_age-- == 0) { - DEBUG(ms, 2) ("Multistop: Slot expired for vehicle %d (index %d) at stop 0x%X", + DEBUG(ms, 3, "Slot expired for vehicle %d (index %d) at stop 0x%X", v->unitnumber, v->index, v->u.road.slot->xy); ClearSlot(v); } @@ -1670,22 +1670,21 @@ void OnNewDay_RoadVeh(Vehicle *v) uint dist, badness; uint minbadness = UINT_MAX; - DEBUG(ms, 2) ( - "Multistop: Attempting to obtain a slot for vehicle %d (index %d) at station %d (0x%X)", + DEBUG(ms, 2, "Attempting to obtain a slot for vehicle %d (index %d) at station %d (0x%X)", v->unitnumber, v->index, st->index, st->xy ); /* Now we find the nearest road stop that has a free slot */ for (; rs != NULL; rs = rs->next) { dist = RoadFindPathToStop(v, rs->xy); if (dist == UINT_MAX) { - DEBUG(ms, 4) (" ---- stop 0x%X is not reachable, not treating further", rs->xy); + DEBUG(ms, 4, " stop 0x%X is unreachable, not treating further", rs->xy); continue; } badness = (rs->num_vehicles + 1) * (rs->num_vehicles + 1) + dist; - DEBUG(ms, 4) (" ---- stop 0x%X has %d vehicle%s waiting", rs->xy, rs->num_vehicles, rs->num_vehicles == 1 ? "":"s"); - DEBUG(ms, 4) (" ---- Distance is %u", dist); - DEBUG(ms, 4) (" -- Badness %u", badness); + DEBUG(ms, 4, " stop 0x%X has %d vehicle%s waiting", rs->xy, rs->num_vehicles, rs->num_vehicles == 1 ? "":"s"); + DEBUG(ms, 4, " distance is %u", dist); + DEBUG(ms, 4, " badness %u", badness); if (badness < minbadness) { best = rs; @@ -1695,20 +1694,20 @@ void OnNewDay_RoadVeh(Vehicle *v) if (best != NULL) { best->num_vehicles++; - DEBUG(ms, 3) (" -- Assigned to stop 0x%X", best->xy); + DEBUG(ms, 3, "Assigned to stop 0x%X", best->xy); v->u.road.slot = best; v->dest_tile = best->xy; v->u.road.slot_age = 14; } else { - DEBUG(ms, 3) (" -- Could not find a suitable stop"); + DEBUG(ms, 3, "Could not find a suitable stop"); } } else { - DEBUG(ms, 5) ("Multistop: --- Distance from station too far. Postponing slotting for vehicle %d (index %d) at station %d, (0x%X)", + DEBUG(ms, 5, "Distance from station too far. Postponing slotting for vehicle %d (index %d) at station %d, (0x%X)", v->unitnumber, v->index, st->index, st->xy); } } else { - DEBUG(ms, 4) ("Multistop: No road stop for vehicle %d (index %d) at station %d (0x%X)", + DEBUG(ms, 4, "No road stop for vehicle %d (index %d) at station %d (0x%X)", v->unitnumber, v->index, st->index, st->xy); } } diff --git a/saveload.c b/saveload.c index 7dc41ab5a5..b96522d64f 100644 --- a/saveload.c +++ b/saveload.c @@ -311,7 +311,7 @@ int SlIterateArray(void) case CH_SPARSE_ARRAY: index = (int)SlReadSparseIndex(); break; case CH_ARRAY: index = _sl.array_index++; break; default: - DEBUG(misc, 0) ("[Sl] SlIterateArray: error"); + DEBUG(sl, 0, "SlIterateArray error"); return -1; // error } @@ -557,7 +557,7 @@ static void SlString(void *ptr, size_t length, VarType conv) case SLE_VAR_STRB: case SLE_VAR_STRBQ: if (len >= length) { - DEBUG(misc, 0) ("[Sl] String length in savegame is bigger than buffer, truncating"); + DEBUG(sl, 1, "String length in savegame is bigger than buffer, truncating"); SlCopyBytes(ptr, length); SlSkipBytes(len - length); len = length - 1; @@ -863,7 +863,7 @@ static void SlSaveChunk(const ChunkHandler *ch) ChunkSaveLoadProc *proc = ch->save_proc; SlWriteUint32(ch->id); - DEBUG(misc, 1) ("[Sl] Saving chunk %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id); + DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id); if (ch->flags & CH_AUTO_LENGTH) { // Need to calculate the length. Solve that by calling SlAutoLength in the save_proc. @@ -941,7 +941,7 @@ static void SlLoadChunks(void) const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { - DEBUG(misc, 1) ("[Sl] Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id); + DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id); ch = SlFindChunkHandler(id); if (ch == NULL) SlError("found unknown tag in savegame (sync error)"); @@ -1520,7 +1520,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) _sl.fh = (mode == SL_SAVE) ? fopen(filename, "wb") : fopen(filename, "rb"); if (_sl.fh == NULL) { - DEBUG(misc, 0) ("[Sl] Cannot open savegame for saving/loading."); + DEBUG(sl, 0, "Cannot open savegame '%s' for saving/loading.", filename); return SL_ERROR; } @@ -1556,7 +1556,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) _sl.write_bytes = fmt->writer; _sl.excpt_uninit = fmt->uninit_write; if (!fmt->init_write()) { - DEBUG(misc, 0) ("[Sl] Initializing writer %s failed.", fmt->name); + DEBUG(sl, 0, "Initializing writer '%s' failed.", fmt->name); return AbortSaveLoad(); } @@ -1569,7 +1569,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) SaveFileStart(); if (_network_server || (save_thread = OTTDCreateThread(&SaveFileToDisk, (void*)"")) == NULL) { - DEBUG(misc, 1) ("[Sl] Cannot create savegame thread, reverting to single-threaded mode..."); + DEBUG(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode..."); SaveFileToDisk(NULL); SaveFileDone(); } @@ -1578,7 +1578,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) assert(mode == SL_LOAD); if (fread(hdr, sizeof(hdr), 1, _sl.fh) != 1) { - DEBUG(misc, 0) ("[Sl] Cannot read savegame header, aborting."); + DEBUG(sl, 0, "Cannot read savegame header, aborting"); return AbortSaveLoad(); } @@ -1586,7 +1586,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) for (fmt = _saveload_formats; ; fmt++) { /* No loader found, treat as version 0 and use LZO format */ if (fmt == endof(_saveload_formats)) { - DEBUG(misc, 0) ("[Sl] Unknown savegame type, trying to load it as the buggy format."); + DEBUG(sl, 0, "Unknown savegame type, trying to load it as the buggy format"); rewind(_sl.fh); _sl_version = 0; _sl_minor_version = 0; @@ -1603,11 +1603,11 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) * So never EVER use this minor version again. -- TrueLight -- 22-11-2005 */ _sl_minor_version = (TO_BE32(hdr[1]) >> 8) & 0xFF; - DEBUG(misc, 1)("[Sl] Loading savegame version %d", _sl_version); + DEBUG(sl, 1, "Loading savegame version %d", _sl_version); /* Is the version higher than the current? */ if (_sl_version > SAVEGAME_VERSION) { - DEBUG(misc, 0) ("[Sl] Savegame version invalid."); + DEBUG(sl, 0, "Savegame version invalid"); return AbortSaveLoad(); } break; @@ -1624,7 +1624,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) } if (!fmt->init_read()) { - DEBUG(misc, 0) ("[Sl] Initializing loader %s failed.", fmt->name); + DEBUG(sl, 0, "Initializing loader '%s' failed", fmt->name); return AbortSaveLoad(); } @@ -1669,7 +1669,7 @@ int GetSavegameType(char *file) f = fopen(file, "rb"); if (fread(&hdr, sizeof(hdr), 1, f) != 1) { - DEBUG(misc, 0) ("[Sl] Savegame is obsolete or invalid format"); + DEBUG(sl, 0, "Savegame is obsolete or invalid format"); mode = SL_LOAD; // don't try to get filename, just show name as it is written } else { // see if we have any loader for this type. diff --git a/screenshot.c b/screenshot.c index 503c78a5c0..5a73fa52a7 100644 --- a/screenshot.c +++ b/screenshot.c @@ -157,13 +157,13 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message) { - DEBUG(misc, 0) ("ERROR(libpng): %s - %s", message, (char *)png_get_error_ptr(png_ptr)); + DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr)); longjmp(png_ptr->jmpbuf, 1); } static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message) { - DEBUG(misc, 0) ("WARNING(libpng): %s - %s", message, (char *)png_get_error_ptr(png_ptr)); + DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (char *)png_get_error_ptr(png_ptr)); } static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) @@ -571,3 +571,5 @@ bool MakeScreenshot(void) } } + + diff --git a/ship_cmd.c b/ship_cmd.c index 0f361b54d3..f72323915c 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -505,7 +505,7 @@ static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Tra void* perf = NpfBeginInterval(); NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes); int t = NpfEndInterval(perf); - DEBUG(yapf, 4)("[YAPF][NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size); + DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size); return ret; } diff --git a/spritecache.c b/spritecache.c index a27444ce12..e8c031fad6 100644 --- a/spritecache.c +++ b/spritecache.c @@ -87,7 +87,7 @@ static void* ReadSprite(SpriteID id) uint num; byte type; - DEBUG(spritecache, 9) ("load sprite %d", id); + DEBUG(sprite, 9, "Load sprite %d", id); if (!SpriteExists(id)) { error( @@ -211,7 +211,7 @@ void IncreaseSpriteLRU(void) // Increase all LRU values #if defined(WANT_NEW_LRU) if (_sprite_lru_counter > 16384) { - DEBUG(spritecache, 2) ("fixing lru %d, inuse=%d", _sprite_lru_counter, GetSpriteCacheUsage()); + DEBUG(sprite, 3, "Fixing lru %d, inuse=%d", _sprite_lru_counter, GetSpriteCacheUsage()); for (i = 0; i != MAX_SPRITES; i++) if (_sprite_ptr[i] != NULL) { @@ -244,9 +244,7 @@ static void CompactSpriteCache(void) { MemBlock *s; - DEBUG(spritecache, 2) ( - "compacting sprite cache, inuse=%d", GetSpriteCacheUsage() - ); + DEBUG(sprite, 3, "Compacting sprite cache, inuse=%d", GetSpriteCacheUsage()); for (s = _spritecache_ptr; s->size != 0;) { if (s->size & S_FREE_MASK) { @@ -290,7 +288,7 @@ static void DeleteEntryFromSpriteCache(void) MemBlock* s; int cur_lru; - DEBUG(spritecache, 2) ("DeleteEntryFromSpriteCache, inuse=%d", GetSpriteCacheUsage()); + DEBUG(sprite, 3, "DeleteEntryFromSpriteCache, inuse=%d", GetSpriteCacheUsage()); #if defined(WANT_NEW_LRU) cur_lru = 0xffff; diff --git a/station_cmd.c b/station_cmd.c index 7bfe6f18ed..99801d2563 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -2769,11 +2769,11 @@ void BuildOilRig(TileIndex tile) Station *st = AllocateStation(); if (st == NULL) { - DEBUG(misc, 0) ("Couldn't allocate station for oilrig at 0x%X, reverting to oilrig only...", tile); + DEBUG(misc, 0, "Can't allocate station for oilrig at 0x%X, reverting to oilrig only", tile); return; } if (!GenerateStationName(st, tile, 2)) { - DEBUG(misc, 0) ("Couldn't allocate station-name for oilrig at 0x%X, reverting to oilrig only...", tile); + DEBUG(misc, 0, "Can't allocate station-name for oilrig at 0x%X, reverting to oilrig only", tile); return; } diff --git a/station_gui.c b/station_gui.c index 72fae3c477..84845ab861 100644 --- a/station_gui.c +++ b/station_gui.c @@ -202,10 +202,9 @@ static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities, /* Create array for sorting */ station_sort = malloc((GetMaxStationIndex() + 1) * sizeof(station_sort[0])); - if (station_sort == NULL) - error("Could not allocate memory for the station-sorting-list"); + if (station_sort == NULL) error("Could not allocate memory for the station-sorting-list"); - DEBUG(misc, 1) ("Building station list for player %d...", owner); + DEBUG(misc, 3, "Building station list for player %d", owner); FOR_ALL_STATIONS(st) { if (st->owner == owner) { @@ -476,7 +475,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e) case WE_TICK: if (--sl->resort_timer == 0) { - DEBUG(misc, 1) ("Periodic rebuild station list player %d", owner); + DEBUG(misc, 3, "Periodic rebuild station list player %d", owner); sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; sl->flags |= VL_REBUILD; SetWindowDirty(w); diff --git a/string.c b/string.c index bac6ac8db0..dba2c71314 100644 --- a/string.c +++ b/string.c @@ -208,7 +208,7 @@ size_t Utf8Decode(WChar *c, const char *s) } } - //DEBUG(misc, 1) ("Invalid UTF-8 sequence"); + //DEBUG(misc, 1, "[utf8] invalid UTF-8 sequence"); *c = '?'; return 1; } @@ -241,7 +241,7 @@ size_t Utf8Encode(char *buf, WChar c) return 4; } - //DEBUG(misc, 1) ("Can't UTF-8 encode value 0x%X", c); + //DEBUG(misc, 1, "[utf8] can't UTF-8 encode value 0x%X", c); *buf = '?'; return 1; } diff --git a/town_gui.c b/town_gui.c index 1434edcdd2..896e7cffda 100644 --- a/town_gui.c +++ b/town_gui.c @@ -410,8 +410,7 @@ static void MakeSortedTownList(void) /* Create array for sorting */ _town_sort = realloc((void*)_town_sort, (GetMaxTownIndex() + 1) * sizeof(_town_sort[0])); - if (_town_sort == NULL) - error("Could not allocate memory for the town-sorting-list"); + if (_town_sort == NULL) error("Could not allocate memory for the town-sorting-list"); FOR_ALL_TOWNS(t) _town_sort[n++] = t; @@ -420,7 +419,7 @@ static void MakeSortedTownList(void) _last_town = NULL; // used for "cache" qsort((void*)_town_sort, n, sizeof(_town_sort[0]), _town_sort_order & 2 ? TownPopSorter : TownNameSorter); - DEBUG(misc, 1) ("Resorting Towns list..."); + DEBUG(misc, 3, "Resorting towns list"); } diff --git a/train_cmd.c b/train_cmd.c index 11bf9ae104..772cd5431d 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -2351,7 +2351,7 @@ static byte ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir, } time = NpfEndInterval(perf); - DEBUG(yapf, 4)("[YAPF][NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size); + DEBUG(yapf, 4, "[NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size); } else { void* perf = NpfBeginInterval(); int time = 0; @@ -2377,7 +2377,7 @@ static byte ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir, } time = NpfEndInterval(perf); - DEBUG(yapf, 4)("[YAPF][NTPT] %d us - %d rounds - %d open - %d closed -- ", time, 0, 0, 0); + DEBUG(yapf, 4, "[NTPT] %d us - %d rounds - %d open - %d closed -- ", time, 0, 0, 0); } // handle "path not found" state if (path_not_found) { diff --git a/unix.c b/unix.c index c40cbafe2f..267351b00e 100644 --- a/unix.c +++ b/unix.c @@ -334,7 +334,7 @@ static const char *convert_tofrom_fs(iconv_t convd, const char *name) iconv(convd, NULL, NULL, NULL, NULL); if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) { - DEBUG(misc, 0) ("[Iconv] Error converting '%s'. Errno %d", name, errno); + DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno); } *outbuf = '\0'; @@ -353,7 +353,7 @@ const char *OTTD2FS(const char *name) const char *env = GetLocalCode(); convd = iconv_open(env, INTERNALCODE); if (convd == (iconv_t)(-1)) { - DEBUG(misc, 0) ("[iconv] Conversion from codeset '%s' to '%s' unsupported", INTERNALCODE, env); + DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", INTERNALCODE, env); return name; } } @@ -372,7 +372,7 @@ const char *FS2OTTD(const char *name) const char *env = GetLocalCode(); convd = iconv_open(INTERNALCODE, env); if (convd == (iconv_t)(-1)) { - DEBUG(misc, 0) ("[iconv] Conversion from codeset '%s' to '%s' unsupported", env, INTERNALCODE); + DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", env, INTERNALCODE); return name; } } diff --git a/vehicle.c b/vehicle.c index 28551f28d6..b6239b4aa9 100644 --- a/vehicle.c +++ b/vehicle.c @@ -368,7 +368,7 @@ bool AllocateVehicles(Vehicle **vl, int num) } -static VehicleID _vehicle_position_hash[0x1000]; +VehicleID _vehicle_position_hash[0x1000]; void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc) { @@ -517,7 +517,7 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v) if (v->first != NULL) { if (IsFrontEngine(v->first) || IsFreeWagon(v->first)) return v->first; - DEBUG(misc, 0) ("v->first cache faulty. We shouldn't be here, rebuilding cache!"); + DEBUG(misc, 0, "v->first cache faulty. We shouldn't be here, rebuilding cache!"); } /* It is the fact (currently) that newly built vehicles do not have diff --git a/vehicle_gui.c b/vehicle_gui.c index 758791dc37..1c3d45b820 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -141,7 +141,7 @@ static void BuildVehicleList(vehiclelist_d* vl, PlayerID owner, StationID statio { if (!(vl->l.flags & VL_REBUILD)) return; - DEBUG(misc, 1) ("Building vehicle list for player %d station %d...", owner, station); + DEBUG(misc, 3, "Building vehicle list for player %d at station %d", owner, station); vl->l.list_length = GenerateVehicleSortList(&vl->sort_list, &vl->length_of_sort_list, vl->vehicle_type, owner, station, order, depot_airport_index, window_type); @@ -1827,7 +1827,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e) StationID station = ((w->window_number & VLW_MASK) == VLW_STATION_LIST) ? GB(w->window_number, 16, 16) : INVALID_STATION; PlayerID owner = (PlayerID)w->caption_color; - DEBUG(misc, 1) ("Periodic resort %d list player %d station %d", vl->vehicle_type, owner, station); + DEBUG(misc, 3, "Periodic resort %d list player %d at station %d", vl->vehicle_type, owner, station); vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; vl->l.flags |= VL_RESORT; SetWindowDirty(w); diff --git a/video/dedicated_v.c b/video/dedicated_v.c index e0124e02c0..c4a74e902e 100644 --- a/video/dedicated_v.c +++ b/video/dedicated_v.c @@ -92,7 +92,7 @@ static void CreateWindowsConsoleThread(void) _hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, NULL, 0, &dwThreadId); if (_hThread == NULL) error("Cannot create console thread!"); - DEBUG(driver, 1) ("Windows console thread started..."); + DEBUG(driver, 2, "Windows console thread started"); } static void CloseWindowsConsoleThread(void) @@ -100,7 +100,7 @@ static void CloseWindowsConsoleThread(void) CloseHandle(_hThread); CloseHandle(_hInputReady); CloseHandle(_hWaitForInputHandling); - DEBUG(driver, 1) ("Windows console thread shut down..."); + DEBUG(driver, 2, "Windows console thread shut down"); } #endif @@ -133,7 +133,7 @@ static const char *DedicatedVideoStart(const char * const *parm) OS2_SwitchToConsoleMode(); #endif - DEBUG(driver, 1)("Loading dedicated server..."); + DEBUG(driver, 1, "Loading dedicated server"); return NULL; } @@ -253,7 +253,7 @@ static void DedicatedVideoMainLoop(void) * intro game... */ if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) { /* Loading failed, pop out.. */ - DEBUG(net, 0)("Loading requested map failed. Aborting."); + DEBUG(net, 0, "Loading requested map failed, aborting"); _networking = false; } else { /* We can load this game, so go ahead */ @@ -264,7 +264,7 @@ static void DedicatedVideoMainLoop(void) // Done loading, start game! if (!_networking) { - DEBUG(net, 1)("Dedicated server could not be launched. Aborting."); + DEBUG(net, 0, "Dedicated server could not be started, aborting"); return; } diff --git a/video/sdl_v.c b/video/sdl_v.c index b0a25a9d7c..77d7a1e53c 100644 --- a/video/sdl_v.c +++ b/video/sdl_v.c @@ -175,7 +175,7 @@ static bool CreateMainSurface(int w, int h) GetAvailableVideoMode(&w, &h); - DEBUG(driver, 1) ("sdl: using mode %dx%d", w, h); + DEBUG(driver, 1, "SDL: using mode %dx%d", w, h); /* Give the application an icon */ icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp"); @@ -295,8 +295,8 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym) if (sym->mod & KMOD_ALT) key |= WKC_ALT; // these two lines really help porting hotkey combos. Uncomment to use -- Bjarni #if 0 - DEBUG(driver, 0) ("scancode character pressed %u", sym->scancode); - DEBUG(driver, 0) ("unicode character pressed %u", sym->unicode); + DEBUG(driver, 0, "Scancode character pressed %u", sym->scancode); + DEBUG(driver, 0, "Unicode character pressed %u", sym->unicode); #endif return (key << 16) + sym->unicode; } @@ -404,7 +404,7 @@ static const char *SdlVideoStart(const char * const *parm) if (s != NULL) return s; SDL_CALL SDL_VideoDriverName(buf, 30); - DEBUG(driver, 1) ("sdl: using driver '%s'", buf); + DEBUG(driver, 1, "SDL: using driver '%s'", buf); GetVideoModes(); CreateMainSurface(_cur_resolution[0], _cur_resolution[1]); diff --git a/viewport.c b/viewport.c index 8f50bdec8b..fa19e7b602 100644 --- a/viewport.c +++ b/viewport.c @@ -419,7 +419,7 @@ void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z) assert((image & SPRITE_MASK) < MAX_SPRITES); if (vd->spritelist_mem >= vd->eof_spritelist_mem) { - DEBUG(misc, 0) ("Out of sprite mem"); + DEBUG(sprite, 0, "Out of sprite memory"); return; } ts = (TileSpriteToDraw*)vd->spritelist_mem; @@ -487,7 +487,7 @@ void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, vd->last_child = NULL; if (vd->spritelist_mem >= vd->eof_spritelist_mem) { - DEBUG(misc, 0) ("Out of sprite mem"); + DEBUG(sprite, 0, "Out of sprite memory"); return; } ps = (ParentSpriteToDraw*)vd->spritelist_mem; @@ -499,7 +499,7 @@ void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, // parent_list somewhere below to a higher number. // This can not really hurt you, it just gives some black // spots on the screen ;) - DEBUG(misc, 0) ("Out of sprite mem (parent_list)"); + DEBUG(sprite, 0, "Out of sprite memory (parent_list)"); return; } @@ -551,7 +551,7 @@ void AddChildSpriteScreen(uint32 image, int x, int y) assert((image & SPRITE_MASK) < MAX_SPRITES); if (vd->spritelist_mem >= vd->eof_spritelist_mem) { - DEBUG(misc, 0) ("Out of sprite mem"); + DEBUG(sprite, 0, "Out of sprite memory"); return; } cs = (ChildScreenSpriteToDraw*)vd->spritelist_mem; @@ -576,7 +576,7 @@ void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 par StringSpriteToDraw *ss; if (vd->spritelist_mem >= vd->eof_spritelist_mem) { - DEBUG(misc, 0) ("Out of sprite mem"); + DEBUG(sprite, 0, "Out of sprite memory"); return NULL; } ss = (StringSpriteToDraw*)vd->spritelist_mem; @@ -1759,7 +1759,7 @@ void HandleViewportClicked(const ViewPort *vp, int x, int y) v = CheckClickOnVehicle(vp, x, y); if (v != NULL) { - DEBUG(misc, 2) ("Vehicle %d at %p", v->index, v); + DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v); _on_vehicle_click_proc[v->type - 0x10](v); } } diff --git a/win32.c b/win32.c index 9aa99dab90..a0a3d05b41 100644 --- a/win32.c +++ b/win32.c @@ -1041,7 +1041,7 @@ wchar_t *convert_to_fs(const char *name, wchar_t *utf16_buf, size_t buflen) { int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, utf16_buf, buflen); if (len == 0) { - DEBUG(misc, 0) ("[utf8] Error converting '%s'. Errno %d", name, GetLastError()); + DEBUG(misc, 0, "[utf8] error converting '%s'. Errno %d", name, GetLastError()); utf16_buf[0] = '\0'; } @@ -1071,7 +1071,7 @@ char *convert_from_fs(const wchar_t *name, char *utf8_buf, size_t buflen) { int len = WideCharToMultiByte(CP_UTF8, 0, name, -1, utf8_buf, buflen, NULL, NULL); if (len == 0) { - DEBUG(misc, 0) ("[utf8] Error converting wide-string. Errno %d", GetLastError()); + DEBUG(misc, 0, "[utf8] error converting wide-string. Errno %d", GetLastError()); utf8_buf[0] = '\0'; } @@ -1107,7 +1107,7 @@ HRESULT OTTDSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, # define W(x) x "A" #endif if (!LoadLibraryList((Function*)&SHGetFolderPath, "SHFolder.dll\0" W("SHGetFolderPath") "\0\0")) { - DEBUG(misc, 0) ("Unable to load " W("SHGetFolderPath") "from SHFolder.dll"); + DEBUG(misc, 0, "Unable to load " W("SHGetFolderPath") "from SHFolder.dll"); } #undef W first_time = false; diff --git a/window.c b/window.c index 3a89dda763..d29963069f 100644 --- a/window.c +++ b/window.c @@ -1614,7 +1614,7 @@ void MouseLoop(int click, int mousewheel) if (vp != NULL) { switch (click) { case 1: - DEBUG(misc, 2) ("cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); + DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); if (_thd.place_mode != 0 && // query button and place sign button work in pause mode _cursor.sprite != SPR_CURSOR_QUERY && @@ -1869,7 +1869,7 @@ void HideVitalWindows(void) int PositionMainToolbar(Window *w) { - DEBUG(misc, 1) ("Repositioning Main Toolbar..."); + DEBUG(misc, 5, "Repositioning Main Toolbar..."); if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) { w = FindWindowById(WC_MAIN_TOOLBAR, 0); diff --git a/yapf/yapf_base.hpp b/yapf/yapf_base.hpp index 0c7e7effe3..1d04179874 100644 --- a/yapf/yapf_base.hpp +++ b/yapf/yapf_base.hpp @@ -146,7 +146,7 @@ public: float cache_hit_ratio = (float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f; int cost = bDestFound ? m_pBestDestNode->m_cost : -1; int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1; - DEBUG(yapf, 3)("[YAPF][YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ", ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000), m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000)); + DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ", ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000), m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000)); return bDestFound; } diff --git a/yapf/yapf_costcache.hpp b/yapf/yapf_costcache.hpp index 4d1f5ea0ff..c90d373027 100644 --- a/yapf/yapf_costcache.hpp +++ b/yapf/yapf_costcache.hpp @@ -155,7 +155,7 @@ protected: // some statistics if (last_date != _date) { last_date = _date; - DEBUG(yapf, 1) ("pf time today:%5d ms", _total_pf_time_us / 1000); + DEBUG(yapf, 2, "Pf time today: %5d ms", _total_pf_time_us / 1000); _total_pf_time_us = 0; }