Mercurial > hg > openttd
changeset 3630:63048d7c5193 draft
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
author | Darkvater <Darkvater@openttd.org> |
---|---|
date | Sat, 22 Apr 2006 13:56:16 +0000 |
parents | 0b11a7c0a0e9 |
children | d037f1facfdf |
files | newgrf.c newgrf_engine.c newgrf_text.c npf.c oldloader.c roadveh_cmd.c station_cmd.c |
diffstat | 7 files changed, 41 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf.c +++ b/newgrf.c @@ -1210,7 +1210,7 @@ } if (ignoring) - grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property %x (not implemented).", prop); + grfmsg(GMS_NOTICE, "VehicleChangeInfo: Ignoring property 0x%02X (not implemented).", prop); } } @@ -1388,7 +1388,7 @@ if (HASBIT(groupid, 15)) { dg->ranges[i].group = NewCallBackResultSpriteGroup(groupid); } else if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "NewSpriteGroup(%02x:0x%x): Groupid %04x does not exist, leaving empty.", setid, numloaded, groupid); + grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty.", setid, numloaded, groupid); dg->ranges[i].group = NULL; } else { dg->ranges[i].group = _cur_grffile->spritegroups[groupid]; @@ -1402,7 +1402,7 @@ if (HASBIT(groupid, 15)) { dg->default_group = NewCallBackResultSpriteGroup(groupid); } else if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "NewSpriteGroup(%02x:0x%x): Groupid %04x does not exist, leaving empty.", setid, numloaded, groupid); + grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty.", setid, numloaded, groupid); dg->default_group = NULL; } else { dg->default_group = _cur_grffile->spritegroups[groupid]; @@ -1446,7 +1446,7 @@ if (HASBIT(groupid, 15)) { rg->groups[i] = NewCallBackResultSpriteGroup(groupid); } else if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "NewSpriteGroup(%02x:0x%x): Groupid %04x does not exist, leaving empty.", setid, numloaded, groupid); + grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty.", setid, numloaded, groupid); rg->groups[i] = NULL; } else { rg->groups[i] = _cur_grffile->spritegroups[groupid]; @@ -1463,7 +1463,7 @@ } if (_cur_grffile->spriteset_feature != feature) { - grfmsg(GMS_ERROR, "NewSpriteGroup: Group feature %x doesn't match set feature %x! Playing it risky and trying to use it anyway.", feature, _cur_grffile->spriteset_feature); + grfmsg(GMS_ERROR, "NewSpriteGroup: Group feature 0x%02X doesn't match set feature 0x%X! Playing it risky and trying to use it anyway.", feature, _cur_grffile->spriteset_feature); // return; // XXX: we can't because of MB's newstats.grf --pasky } @@ -1573,7 +1573,7 @@ uint16 groupid = grf_load_word(&bp); if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x or empty, skipping.", + grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); return; } @@ -1592,7 +1592,7 @@ uint16 groupid = grf_load_word(&bp); if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { - grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x or empty, skipping.", + grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); return; } @@ -1649,8 +1649,7 @@ byte *bp = &buf[4 + idcount]; if (engine_id > _vehcounts[feature]) { - grfmsg(GMS_ERROR, "Id %u for feature %x is out of bounds.", - engine_id, feature); + grfmsg(GMS_ERROR, "Id %u for feature 0x%02X is out of bounds.", engine_id, feature); return; } @@ -1660,10 +1659,10 @@ uint8 ctype = grf_load_byte(&bp); uint16 groupid = grf_load_word(&bp); - DEBUG(grf, 8) ("VehicleMapSpriteGroup: * [%d] Cargo type %x, group id %x", c, ctype, groupid); + DEBUG(grf, 8) ("VehicleMapSpriteGroup: * [%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, "VehicleMapSpriteGroup: Spriteset %x out of range %x or empty, skipping.", groupid, _cur_grffile->spritegroups_count); + grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); return; } @@ -1683,14 +1682,14 @@ byte *bp = buf + 4 + idcount + cidcount * 3; uint16 groupid = grf_load_word(&bp); - DEBUG(grf, 8) ("-- Default group id %x", groupid); + DEBUG(grf, 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, "VehicleMapSpriteGroup: Spriteset %x out of range %x or empty, skipping.", groupid, _cur_grffile->spritegroups_count); + grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset 0x%04X out of range 0x%X or empty, skipping.", groupid, _cur_grffile->spritegroups_count); return; } @@ -1750,7 +1749,7 @@ } endid = id + num; - DEBUG(grf, 6) ("VehicleNewName: About to rename engines %d..%d (feature %d) in language 0x%x.", + DEBUG(grf, 6) ("VehicleNewName: About to rename engines %d..%d (feature %d) in language 0x%02X.", id, endid, feature, lang); name = (const char*)buf; /*transfer read value*/ @@ -1785,7 +1784,7 @@ break; default: - DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (%x)", id); + DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (0x%04X)", id); break; } break; @@ -1797,7 +1796,7 @@ switch (GB(id, 8,8)) { case 0xC9: /* House name */ default: - DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (%x)", id); + DEBUG(grf, 7) ("VehicleNewName: Unsupported ID (0x%04X)", id); } break; @@ -1806,7 +1805,7 @@ AddGRFString(_cur_spriteid, id, lang, name); break; default : - DEBUG(grf,7) ("VehicleNewName: Unsupported feature (%x)", feature); + DEBUG(grf,7) ("VehicleNewName: Unsupported feature (0x%02X)", feature); break; #endif } @@ -1836,7 +1835,7 @@ type = grf_load_byte(&buf); num = grf_load_extended(&buf); - grfmsg(GMS_NOTICE, "GraphicsNew: Custom graphics (type %x) sprite block of length %d (unimplemented, ignoring).\n", + grfmsg(GMS_NOTICE, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %d (unimplemented, ignoring).\n", type, num); } @@ -1946,7 +1945,7 @@ } } - DEBUG(grf, 7) ("Test condtype %d, param %x, condval %x", condtype, param_val, cond_val); + DEBUG(grf, 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; @@ -2367,7 +2366,7 @@ l->next = label; } - grfmsg(GMS_NOTICE, "DefineGotoLabel: GOTO target with label 0x%X", label->label); + grfmsg(GMS_NOTICE, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); } static void InitializeGRFSpecial(void)
--- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -169,7 +169,7 @@ break; } - DEBUG(grf, 1)("Unhandled vehicle property 0x%x (var 0x%x), type 0x%x", var, var + 0x80, v->type); + DEBUG(grf, 1)("Unhandled vehicle property 0x%02X (var 0x%02X), type 0x%02X", var, var + 0x80, v->type); return -1; }
--- a/newgrf_text.c +++ b/newgrf_text.c @@ -174,7 +174,7 @@ textptr->next = newtext; } - DEBUG(grf, 2)("Added %x: grfid %x string %x lang %x string %s", id, grfid, stringid, newtext->langid, newtext->text); + DEBUG(grf, 2)("Added 0x%X: grfid 0x%X string 0x%X lang 0x%X string %s", id, grfid, stringid, newtext->langid, newtext->text); return (GRFTAB << TABSIZE) + id; }
--- a/npf.c +++ b/npf.c @@ -152,7 +152,7 @@ /* 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: %#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]; @@ -608,13 +608,13 @@ } trackdirbits = ts & TRACKDIR_BIT_MASK; /* Filter out signal status and the unused bits */ - DEBUG(npf, 4)("Next node: (%d, %d) [%d], possible trackdirs: %#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: %#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 */ @@ -622,7 +622,7 @@ Trackdir dst_trackdir; dst_trackdir = FindFirstBit2x64(trackdirbits); trackdirbits = KillFirstBit2x64(trackdirbits); - DEBUG(npf, 5)("Expanded into trackdir: %d, remaining trackdirs: %#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_TYPE_SIGNALS) { @@ -704,10 +704,10 @@ 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); } } @@ -855,7 +855,7 @@ 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; }
--- a/oldloader.c +++ b/oldloader.c @@ -211,7 +211,7 @@ break; case OC_ASSERT: - DEBUG(oldloader, 4)("[OldLoader] Assert point: %x / %x", ls->total_read, chunk->offset + _bump_assert_value); + DEBUG(oldloader, 4)("[OldLoader] 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; }
--- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -240,7 +240,7 @@ assert(rs->num_vehicles != 0); rs->num_vehicles--; - DEBUG(ms, 3) ("Multistop: Clearing slot at 0x%x", rs->xy); + DEBUG(ms, 3) ("Multistop: Clearing slot at 0x%X", rs->xy); } /** Sell a road vehicle. @@ -1459,10 +1459,10 @@ //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); 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, 0) ("Multistop: -- 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, 0) ("Multistop: -- 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); @@ -1604,7 +1604,7 @@ //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, 2) ("Multistop: Slot expired for vehicle %d (index %d) at stop 0x%X", v->unitnumber, v->index, v->u.road.slot->xy); ClearSlot(v); } @@ -1624,18 +1624,18 @@ 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)", v->unitnumber, + DEBUG(ms, 2) ("Multistop: 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 not reachable, not treating further", rs->xy); continue; } badness = (rs->num_vehicles + 1) * (rs->num_vehicles + 1) + dist / NPF_TILE_LENGTH; - DEBUG(ms, 4) (" ---- stop 0x%x has %d vehicle%s waiting", rs->xy, rs->num_vehicles, rs->num_vehicles == 1 ? "":"s"); + 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); @@ -1647,7 +1647,7 @@ 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; @@ -1656,11 +1656,11 @@ 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) ("Multistop: --- 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) ("Multistop: No road stop for vehicle %d (index %d) at station %d (0x%X)", v->unitnumber, v->index, st->index, st->xy); } }
--- a/station_cmd.c +++ b/station_cmd.c @@ -2643,11 +2643,11 @@ Station *st = AllocateStation(); if (st == NULL) { - DEBUG(misc, 0) ("Couldn't allocate station for oilrig at %#X, reverting to oilrig only...", tile); + DEBUG(misc, 0) ("Couldn'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 %#X, reverting to oilrig only...", tile); + DEBUG(misc, 0) ("Couldn't allocate station-name for oilrig at 0x%X, reverting to oilrig only...", tile); return; }