Skip to content

Commit

Permalink
Flatten some PRI* macros
Browse files Browse the repository at this point in the history
  • Loading branch information
rollerozxa committed May 9, 2024
1 parent fcbbfc2 commit 7e4d00a
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/src/activator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <map>
#include "Box2D/Box2D.h"
#include <tms/math/vector.h>
#include <inttypes.h>


class entity;
class creature;
Expand Down
2 changes: 1 addition & 1 deletion src/src/chunk_preloader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ chunk_preloader::preload_connection()
this->connection_rels.insert(std::make_pair(e_id, conn_id));
this->connection_rels.insert(std::make_pair(o_id, conn_id));

tms_debugf("preloaded connection %" PRIu32 " <-> %" PRIu32 " @ %" PRIu32, e_id, o_id, (uint32_t)ptr);
tms_debugf("preloaded connection %u <-> %u @ %u", e_id, o_id, (uint32_t)ptr);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/src/crc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ crc32_level(const lvlinfo &lvl, const lvlbuf &lb, uint32_t timestamp, uint32_t l
#ifndef _NO_TMS
tms_assertf(method < 5, "only 5 methods of crc32_level are implemented.");

tms_infof("Using lastscore %" PRIu32 "in crc32_level.", last_score);
tms_infof("Using lastscore %u in crc32_level.", last_score);
#endif

unsigned char crc_buf[CRC_BUFFER_SIZE];
Expand Down
1 change: 0 additions & 1 deletion src/src/crc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "pkgman.hh"

#include "zlib.h"
#include <inttypes.h>

uint32_t crc32_uint64(uint32_t crc, uint64_t data);

Expand Down
2 changes: 1 addition & 1 deletion src/src/creature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ creature::init()
void
creature::setup()
{
tms_debugf("creature setup %" PRIu32, this->id);
tms_debugf("creature setup %u", this->id);
entity::setup();

this->max_armour = ROBOT_MAX_ARMOUR;
Expand Down
2 changes: 1 addition & 1 deletion src/src/decorations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void
decoration::write_quickinfo(char *out)
{
if (G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (id:%" PRIu32 ", g_id:%" PRIu8 ")", decorations[this->get_decoration_type()].name, this->id, this->g_id);
sprintf(out, "%s (id:%u, g_id:%u)", decorations[this->get_decoration_type()].name, this->id, this->g_id);
} else
sprintf(out, "%s", decorations[this->get_decoration_type()].name);
}
4 changes: 2 additions & 2 deletions src/src/entity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ void entity::create_circle(b2BodyType type,
void entity::create_rect(b2BodyType type,
float width, float height, m *m, b2Fixture **fixture_out /* = NULL */)
{
tms_assertf(!this->is_composable(), "error: create_rect() called on composable object (g_id: %" PRIu8 ")", this->g_id);
tms_assertf(!this->is_composable(), "error: create_rect() called on composable object (g_id: %u)", this->g_id);

if (!this->body) {
if (type == b2_staticBody && fixture_out == 0) {
Expand Down Expand Up @@ -1581,7 +1581,7 @@ entity::write_quickinfo(char *out)
{
if (G->state.sandbox && settings["display_object_id"]->v.b) {
/* XXX GID XXX */
sprintf(out, "%s\nid:%" PRIu32 ", g_id:%" PRIu8, this->get_name(), this->id, this->g_id);
sprintf(out, "%s\nid:%u, g_id:%u", this->get_name(), this->id, this->g_id);
} else {
sprintf(out, "%s", this->get_name());
}
Expand Down
8 changes: 4 additions & 4 deletions src/src/escript.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ subscribe_to_entity(lua_State *L, const int index, void *userdata)
entity *e = *(static_cast<entity**>(p));
std::set<entity*>::iterator it = es->subscriptions.find(e);
if (it == es->subscriptions.end()) {
tms_debugf("Luascript with id %" PRIu32 " subscribing to entity with id %" PRIu32 " %s",
tms_debugf("Luascript with id %u subscribing to entity with id %u %s",
es->id,
e->id,
e->get_name());
Expand Down Expand Up @@ -1033,7 +1033,7 @@ extern "C" {
{
uint32_t id = lua_tounsigned(L, lua_upvalueindex(1));

tms_debugf("Attempting to entity userdata with id %" PRIu32, id);
tms_debugf("Attempting to entity userdata with id %u", id);
entity *e = W->get_entity_by_id(id);

entity **ee = static_cast<entity**>(lua_newuserdata(L, sizeof(entity*)));
Expand Down Expand Up @@ -3474,7 +3474,7 @@ timelimit_cb(lua_State *L, lua_Debug *d)
{
const uint32_t cur_time = SDL_GetTicks() - start_tick;

tms_debugf("Cur time: %" PRIu32, cur_time);
tms_debugf("Cur time: %u", cur_time);

if (is_first_run) {
if (cur_time > FIRST_RUN_TIMELIMIT) {
Expand Down Expand Up @@ -4468,7 +4468,7 @@ escript::read_state(lvlinfo *lvl, lvlbuf *lb)
lb->r_buf((char*)this->static_draw->texture->data, buf_sz);

uint32_t num_static_sprites = lb->r_uint32();
tms_debugf("num static sprites: %" PRIu32, num_static_sprites);
tms_debugf("num static sprites: %u", num_static_sprites);
for (uint32_t i=0; i<num_static_sprites; ++i) {
struct escript_sprite s;
s.x = lb->r_float();
Expand Down
2 changes: 0 additions & 2 deletions src/src/factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "faction.hh"
#include "text.hh"

#include <inttypes.h>

static std::vector<struct factory_object> generic_objects;
static std::vector<struct factory_object> armory_objects;
static std::vector<struct factory_object> robot_objects;
Expand Down
10 changes: 5 additions & 5 deletions src/src/game-gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ game::widget_clicked(principia_wdg *w, uint8_t button_id, int pid)
return true;
}

tms_errorf("Unhandled GW: %" PRIu8, button_id);
tms_errorf("Unhandled GW: %u", button_id);
}
break;
}
Expand Down Expand Up @@ -2575,7 +2575,7 @@ game::create_sandbox_menu()
entity *e = menu_objects[n].e;

char override_path[512];
snprintf(override_path, 512, "../data-src/override/%" PRIu32 ".png", e->g_id);
snprintf(override_path, 512, "../data-src/override/%u.png", e->g_id);

if (!file_exists(override_path)) {
cam->width = 2.0f * 1.f/e->menu_scale;
Expand Down Expand Up @@ -2604,7 +2604,7 @@ game::create_sandbox_menu()
menu_objects[n].image.width = SIZE_PER_MENU_ITEM;
menu_objects[n].image.height = SIZE_PER_MENU_ITEM;

tms_infof("%" PRIu32 " (%s) at %.2f/%.2f.", menu_objects[n].e->g_id, menu_objects[n].e->get_name(), VEC2_INLINE(menu_objects[n].image.bl));
tms_infof("%u (%s) at %.2f/%.2f.", menu_objects[n].e->g_id, menu_objects[n].e->get_name(), VEC2_INLINE(menu_objects[n].image.bl));

/* object */
tms_graph_add_entity_with_children(menu_graph, menu_objects[n].e);
Expand All @@ -2614,7 +2614,7 @@ game::create_sandbox_menu()
menu_graph->render(cam, this);
tms_graph_remove_entity_with_children(menu_graph, menu_objects[n].e);
} else {
tms_infof("%" PRIu32 " (%s) is being overridden", menu_objects[n].e->g_id, menu_objects[n].e->get_name());
tms_infof("%u (%s) is being overridden", menu_objects[n].e->g_id, menu_objects[n].e->get_name());
}

n++;
Expand All @@ -2640,7 +2640,7 @@ game::create_sandbox_menu()
entity *e = menu_objects[n].e;

char override_path[512];
snprintf(override_path, 512, "../data-src/override/%" PRIu32 ".png", e->g_id);
snprintf(override_path, 512, "../data-src/override/%u.png", e->g_id);

if (file_exists(override_path)) {
struct tms_texture tex;
Expand Down
16 changes: 8 additions & 8 deletions src/src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7168,7 +7168,7 @@ game::open_state(int id_type, uint32_t id, uint32_t save_id)
id_type += LEVEL_LOCAL_STATE;
}

tms_infof("opening state %" PRIu32 " of %d level %" PRIu32, save_id, id_type, id);
tms_infof("opening state %u of %d level %u", save_id, id_type, id);

bool test = this->state.test_playing;

Expand Down Expand Up @@ -7534,7 +7534,7 @@ game::numkey_pressed(uint8_t key)
}
} else {
if (key > MAX_COPY_ENTITIES) {
tms_errorf("handle_slot called with slot %" PRIu8 ", even though the max number of copy entities is %d", key, MAX_COPY_ENTITIES);
tms_errorf("handle_slot called with slot %u, even though the max number of copy entities is %d", key, MAX_COPY_ENTITIES);
return;
}

Expand Down Expand Up @@ -9194,8 +9194,8 @@ game::check_select_object(int x, int y, int pid)
entity *e = this->sel_p_ent;
snprintf(msg, 2047,
BOLD_BEGIN "Name:" BOLD_END " %s\n"
BOLD_BEGIN "ID:" BOLD_END " %" PRIu32 "\n"
BOLD_BEGIN "Type ID (g_id):" BOLD_END " %" PRIu8 "\n"
BOLD_BEGIN "ID:" BOLD_END " %u\n"
BOLD_BEGIN "Type ID (g_id):" BOLD_END " %u\n"
BOLD_BEGIN "Position:" BOLD_END " %.2f/%.2f\n"
BOLD_BEGIN "Angle:" BOLD_END " %.2f\n",
e->get_name(),
Expand Down Expand Up @@ -9500,7 +9500,7 @@ game::check_select_object(int x, int y, int pid)
down[pid] = false;
if (this->sel_p_ent && this->sel_p_ent != rm && this->sel_p_ent->id != 0) {
if (this->sel_p_ent->flag_active(ENTITY_IS_ROBOT)) {
ui::messagef("Managing robot with id %" PRIu32 ".", this->sel_p_ent->id);
ui::messagef("Managing robot with id %u.", this->sel_p_ent->id);
rm->properties[0].v.i = this->sel_p_ent->id;
}
this->add_highlight(this->sel_p_ent, false);
Expand Down Expand Up @@ -11543,9 +11543,9 @@ game::clamp_entities()

W->groups = new_groups;

tms_debugf("Done in %" PRIu32 " ticks", SDL_GetTicks()-ss);
tms_debugf("Old biggest id: %" PRIu32 ". New: %" PRIu32, prev_biggest, id-1);
tms_debugf("Entities: %" PRIu32 ", Cables: %" PRIu32 ", Groups: %" PRIu32,
tms_debugf("Done in %u ticks", SDL_GetTicks()-ss);
tms_debugf("Old biggest id: %u. New: %u", prev_biggest, id-1);
tms_debugf("Entities: %u, Cables: %u, Groups: %u",
num_entities, num_cables, num_groups);

of::_id = id;
Expand Down
3 changes: 1 addition & 2 deletions src/src/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "game.hh"
#include "model.hh"
#include "settings.hh"
#include <inttypes.h>

generator::generator()
: voltage(3.f)
Expand Down Expand Up @@ -109,7 +108,7 @@ void
generator::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (%.0fv, id:%" PRIu32 ", g_id:%" PRIu8 ")", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
sprintf(out, "%s (%.0fv, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else {
sprintf(out, "%s (%.0fv)", this->get_name(), this->properties[0].v.f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/i0o1gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void
var_getter::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
snprintf(out, 255, "%s (%s, id:%" PRIu32 ", g_id:%" PRIu8 ")", this->get_name(), this->properties[0].v.s.buf, this->id, this->g_id);
snprintf(out, 255, "%s (%s, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.s.buf, this->id, this->g_id);
} else {
snprintf(out, 255, "%s (%s)", this->get_name(), this->properties[0].v.s.buf);
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/i1o1gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void
esub::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (-%.5f, id:%" PRIu32 ", g_id:%" PRIu8 ")", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
sprintf(out, "%s (-%.5f, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else {
sprintf(out, "%s (-%.5f)", this->get_name(), this->properties[0].v.f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/i2o0gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void
var_setter::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
snprintf(out, 255, "%s (%s, id:%" PRIu32 ", g_id:%" PRIu8 ")", this->get_name(), this->properties[0].v.s.buf, this->id, this->g_id);
snprintf(out, 255, "%s (%s, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.s.buf, this->id, this->g_id);
} else {
snprintf(out, 255, "%s (%s)", this->get_name(), this->properties[0].v.s.buf);
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ void
item::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s\nid:%" PRIu32 ", g_id:%" PRIu8, item_options[this->get_item_type()].name, this->id, this->g_id);
sprintf(out, "%s\nid:%u, g_id:%u", item_options[this->get_item_type()].name, this->id, this->g_id);
} else {
sprintf(out, "%s", item_options[this->get_item_type()].name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/src/jumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void
jumper::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (%.5f, id:%" PRIu32 ", g_id:%" PRIu8 ")", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
sprintf(out, "%s (%.5f, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else {
sprintf(out, "%s (%.5f)", this->get_name(), this->properties[0].v.f);
}
Expand Down
12 changes: 6 additions & 6 deletions src/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2369,9 +2369,9 @@ _get_featured_levels(void *_num)

char url[256];
if (fl_fetch_time && file_exists(featured_data_path)) {
snprintf(url, 255, "https://%s/internal/get_featured?num=%" PRIu32 "&time=%d", P.community_host, num_featured_levels, fl_fetch_time);
snprintf(url, 255, "https://%s/internal/get_featured?num=%u&time=%d", P.community_host, num_featured_levels, fl_fetch_time);
} else {
snprintf(url, 255, "https://%s/internal/get_featured?num=%" PRIu32, P.community_host, num_featured_levels);
snprintf(url, 255, "https://%s/internal/get_featured?num=%u", P.community_host, num_featured_levels);
}

curl_easy_setopt(P.curl, CURLOPT_URL, url);
Expand Down Expand Up @@ -2566,7 +2566,7 @@ _get_featured_levels(void *_num)

uint32_t num_getting_started_links = lb.r_uint32();

tms_infof("Num getting started links: %" PRIu32, num_getting_started_links);
tms_infof("Num getting started links: %u", num_getting_started_links);

menu_shared::gs_entries.clear();

Expand Down Expand Up @@ -2938,7 +2938,7 @@ _submit_score(void *p)

lp->last_score = more_data[(x+highscore_level_offset)%5];

tms_infof("Last score: %" PRIu32, lp->last_score);
tms_infof("Last score: %u", lp->last_score);
}

for (int x=0; x<5; ++x) {
Expand Down Expand Up @@ -2966,7 +2966,7 @@ _submit_score(void *p)
curl_mime_filedata(part, data_path);

char tmp[32];
sprintf(tmp, "%" PRIu32, W->level.community_id);
sprintf(tmp, "%u", W->level.community_id);

part = curl_mime_addpart(mime);
curl_mime_name(part, "lvl_id");
Expand Down Expand Up @@ -3627,7 +3627,7 @@ initial_loader(int step)
total += loader_times[x];
}

tms_infof("%27s: %" PRIu32, "Total", total);
tms_infof("%27s: %u", "Total", total);

ui::emit_signal(SIGNAL_QUICKADD_REFRESH);
}
Expand Down
4 changes: 2 additions & 2 deletions src/src/menu-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ menu_base::widget_clicked(principia_wdg *w, uint8_t button_id, int pid)
{
uint32_t id = VOID_TO_UINT32(w->data3);
char tmp[1024];
snprintf(tmp, 1023, "https://%s/level/%" PRIu32, P.community_host, id);
snprintf(tmp, 1023, "https://%s/level/%u", P.community_host, id);
ui::open_url(tmp);
}
break;
Expand All @@ -66,7 +66,7 @@ menu_base::widget_clicked(principia_wdg *w, uint8_t button_id, int pid)
{
uint32_t id = VOID_TO_UINT32(w->data3);
char tmp[1024];
snprintf(tmp, 1023, "https://%s/contest/%" PRIu32, P.community_host, id);
snprintf(tmp, 1023, "https://%s/contest/%u", P.community_host, id);
ui::open_url(tmp);
}
break;
Expand Down
Loading

0 comments on commit 7e4d00a

Please sign in to comment.