1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-12-05 22:28:04 +00:00

Qualify calls to format

C++20 introduces `std::format` and we `using namespace std`,
so some of these would be ambiguous in C++20.
This commit is contained in:
Arthur O'Dwyer
2023-08-21 10:02:25 -07:00
parent a250a4d430
commit ced3bbcad4
41 changed files with 101 additions and 101 deletions

View File

@@ -105,7 +105,7 @@ void draw_game_cell(const cell_to_draw& cd) {
}
if(view_proper_times) {
string str = format(tformat, cd.center.shift / ads_time_unit);
string str = hr::format(tformat, cd.center.shift / ads_time_unit);
queuestr(shiftless(rgpushxto0(cd.center.h)), .1, str, 0xFF4040, 8);
}
@@ -167,7 +167,7 @@ void draw_game_cell(const cell_to_draw& cd) {
}
if(view_proper_times && rock.type != oParticle) {
string str = format(tformat, rock.pt_main.shift / ads_time_unit);
string str = hr::format(tformat, rock.pt_main.shift / ads_time_unit);
queuestr(shiftless(rgpushxto0(rock.pt_main.h)), .1, str, 0xFFFFFF, 8);
}
}
@@ -213,7 +213,7 @@ void draw_game_cell(const cell_to_draw& cd) {
queuecurve(shiftless(Id), 0xFF, shipcolor, PPR::MONSTER_FOOT);
if(view_proper_times) {
string str = format(tformat, (cr.shift + rock.start) / ads_time_unit);
string str = hr::format(tformat, (cr.shift + rock.start) / ads_time_unit);
queuestr(shiftless(rgpushxto0(cr.h)), .1, str, 0xC0C0C0, 8);
}
}
@@ -350,13 +350,13 @@ void view_ads_game() {
poly_outline = 0xFF;
if(view_proper_times) {
string str = format(tformat, ship_pt / ads_time_unit);
string str = hr::format(tformat, ship_pt / ads_time_unit);
queuestr(shiftless(Id), .1, str, 0xFFFFFF, 8);
}
}
if(paused && view_proper_times) {
string str = format(tformat, view_pt / ads_time_unit);
string str = hr::format(tformat, view_pt / ads_time_unit);
queuestr(shiftless(Id), .1, str, 0xFFFF00, 8);
}
}

View File

@@ -29,7 +29,7 @@ struct rock_generator {
};
void report(string s) {
println(hlog, lalign(10, format(tformat, cshift/ds_time_unit)), ": ", s);
println(hlog, lalign(10, hr::format(tformat, cshift/ds_time_unit)), ": ", s);
};
ld rand_range(ld a, ld b) { return lerp(a, b, randd()); };
@@ -585,7 +585,7 @@ void view_ds_game() {
if(view_proper_times && rock.type != oParticle) {
ld t = rock.pt_main.shift;
if(rock.type == oMainRock) t += current.shift;
string str = format(tformat, t / ds_time_unit);
string str = hr::format(tformat, t / ds_time_unit);
queuestr(shiftless(sphereflip * rgpushxto0(rock.pt_main.h)), .1, str, 0xFFFF00, 8);
}
@@ -638,7 +638,7 @@ void view_ds_game() {
}
if(view_proper_times) {
string str = format(tformat, (cr.shift + ss.start) / ds_time_unit);
string str = hr::format(tformat, (cr.shift + ss.start) / ds_time_unit);
queuestr(shiftless(sphereflip * rgpushxto0(cr.h)), .1, str, 0xC0C0C0, 8);
}
}
@@ -664,13 +664,13 @@ void view_ds_game() {
poly_outline = 0xFF;
if(view_proper_times) {
string str = format(tformat, ship_pt / ds_time_unit);
string str = hr::format(tformat, ship_pt / ds_time_unit);
queuestr(shiftless(sphereflip), .1, str, 0xFFFFFF, 8);
}
}
if(paused && view_proper_times) {
string str = format(tformat, view_pt / ds_time_unit);
string str = hr::format(tformat, view_pt / ds_time_unit);
queuestr(shiftless(sphereflip), .1, str, 0xFFFF00, 8);
}

View File

@@ -94,7 +94,7 @@ void display(int id, int y, ld val, ld maxv, ld tank, ld unit) {
if(maxv == 0) {
string s;
if(main_rock) s = format(tformat, current.shift);
if(main_rock) s = hr::format(tformat, current.shift);
else s = its(val + .5);
queuestr(sta, ctr, 0, 20, s, col >> 8, 1, 0);

View File

@@ -499,7 +499,7 @@ void bantar_record() {
vid.xres = vid.yres = TSIZE;
banachtarski::bantar_frame();
IMAGESAVE(rbuf.render(), ("bantar/" + format("%05d", fr) + IMAGEEXT).c_str());
IMAGESAVE(rbuf.render(), ("bantar/" + hr::format("%05d", fr) + IMAGEEXT).c_str());
printf("GL %5d/%5d\n", i, 10000);
fr++;
}

View File

@@ -1755,7 +1755,7 @@ void run() {
perfect_linewidth = 0;
shot::shot_aa = 2;
vid.linewidth *= 2;
shot::take(format("bringris-%04d.png", id++), [] { draw_screen(vid.xres, false); });
shot::take(hr::format("bringris-%04d.png", id++), [] { draw_screen(vid.xres, false); });
vid.linewidth /= 2;
}
#endif

View File

@@ -97,7 +97,7 @@ int readArgs() {
for(auto& loc: p.second.locs) {
dynamicval<transmatrix> dv(View, loc.lView);
dynamicval<cell*> dc(centerover, loc.lco);
shot::take(format(s.c_str(), p.first, i++));
shot::take(hr::format(s.c_str(), p.first, i++));
}
}
}

View File

@@ -32,7 +32,7 @@ int tallybox_total(qtybox& box) {
}
string segdesc(segment *s) {
return format("(%s-%s: len=%d, qty=%d/%d)", get_path(s->left).c_str(), get_path(s->right).c_str(), segmentlen(s), get0(s->qty), tallybox_total(s->qty));
return hr::format("(%s-%s: len=%d, qty=%d/%d)", get_path(s->left).c_str(), get_path(s->right).c_str(), segmentlen(s), get0(s->qty), tallybox_total(s->qty));
}
@@ -342,7 +342,7 @@ void compute_betweenness(bool verify) {
auto b = betweenness3(c1);
// add_to_set(c1, 1, 0);
auto b4 = betweenness4(c1);
print(hlog, format("B;%10Ld;%10Ld;%20.10Lf;%3d;%-40s", b.first, b.second, b4, vertices[i]->lev, rogueviz::vdata[i].name.c_str()));
print(hlog, hr::format("B;%10Ld;%10Ld;%20.10Lf;%3d;%-40s", b.first, b.second, b4, vertices[i]->lev, rogueviz::vdata[i].name.c_str()));
if(verify) {
/*
betweenness_type a = b.first;
@@ -364,7 +364,7 @@ void compute_betweenness(bool verify) {
else printf("\n");
pb++;
}
if(verify) println(hlog, format("errorcount = %d/%d\n", errorcount, errorcount2));
if(verify) println(hlog, hr::format("errorcount = %d/%d\n", errorcount, errorcount2));
}
void build(mycell *c, int lev, string s) {

View File

@@ -45,7 +45,7 @@ void memoryInfo() {
}
void debugtally() {
print(hlog, "T"); for(int i=0; i<MAXDIST; i++) if(tally[i]) print(hlog, format(" %4d/%4lld", edgetally[i], tally[i]));
print(hlog, "T"); for(int i=0; i<MAXDIST; i++) if(tally[i]) print(hlog, hr::format(" %4d/%4lld", edgetally[i], tally[i]));
println(hlog, " .. %", loglikopt());
}

View File

@@ -142,7 +142,7 @@ int move_restart() {
print(hlog, " stats:");
for(int a=0; a<2; a++) for(int b=0; b<128; b++) {
int d = distances_map[a][b];
if(d) print(hlog, format(" %d/%d:%d", a,b, d));
if(d) print(hlog, hr::format(" %d/%d:%d", a,b, d));
}
println(hlog, "\n");
return lastmoves = moves;
@@ -157,7 +157,7 @@ void verifycs() {
edgecs += edgetally[u] * u*u,
totalcs += tally[u] * u*u;
print(hlog, "edgecs=", format("%lld", edgecs), " totalcs=", format("%lld", totalcs));
print(hlog, "edgecs=", hr::format("%lld", edgecs), " totalcs=", hr::format("%lld", totalcs));
}
void preparegraph() {

View File

@@ -61,15 +61,15 @@ void do_analyze_grid(int maxv) {
ld wE2 = wstats[d][2];
ld wVr = wE2 - wE * wE;
print(hlog, format("d=%2d: q = %8d E = %12.8" PLDF " dif = %12.8" PLDF " Vr = %12.8" PLDF " Vr/(d-1)=%12.8" PLDF,
print(hlog, hr::format("d=%2d: q = %8d E = %12.8" PLDF " dif = %12.8" PLDF " Vr = %12.8" PLDF " Vr/(d-1)=%12.8" PLDF,
d, q, E, dif, Vr, Vd));
if(0) print(hlog, format(" | <%" PLDF "> ex = %12.8" PLDF " d.ex = %12.8" PLDF " Vr = %12.8" PLDF, wstats[d][0], wE, wE - lwE, wVr));
if(0) print(hlog, hr::format(" | <%" PLDF "> ex = %12.8" PLDF " d.ex = %12.8" PLDF " Vr = %12.8" PLDF, wstats[d][0], wE, wE - lwE, wVr));
ld Sigma = sqrt(Vr);
sort(distances[d].begin(), distances[d].end());
if(Sigma) for(int u=1; u<8; u++)
print(hlog, format(" %8.5" PLDF, (distances[d][u * isize(distances[d]) / 8] - E) / Sigma));
print(hlog, hr::format(" %8.5" PLDF, (distances[d][u * isize(distances[d]) / 8] - E) / Sigma));
println(hlog);
lwE = wE;

View File

@@ -78,7 +78,7 @@ ld bestll2(ld a, ld ab) { return bestll(a, ab-a); }
template<class T> void fix_logistic_parameters(logistic& l, const T& f, const char *name, ld eps) {
indenter_finish im("fix_logistic_parameters");
ld cur = f(l);
println(hlog, format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%" PLDF ")", name, cur, l.R, l.T));
println(hlog, hr::format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%" PLDF ")", name, cur, l.R, l.T));
for(ld step=1; step>eps; step /= 2) {
@@ -94,7 +94,7 @@ template<class T> void fix_logistic_parameters(logistic& l, const T& f, const ch
while(true) { l.T -= step; ld t = f(l); if(t <= cur) break; cur = t; }
l.T += step;
println(hlog, format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%10.5" PLDF ")", name, cur, l.R, l.T));
println(hlog, hr::format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%10.5" PLDF ")", name, cur, l.R, l.T));
fflush(stdout);
}
}
@@ -269,7 +269,7 @@ void writestats() {
ld placement_loglik = loglik_placement();
for(int u=0; u<MAXDIST; u++) if(tally[u]) {
println(hlog, format("* %4d: %8d / %12Ld = %lf %.10" PLDF " %.10" PLDF,
println(hlog, hr::format("* %4d: %8d / %12Ld = %lf %.10" PLDF " %.10" PLDF,
u, edgetally[u], tally[u], double(edgetally[u]) / tally[u],
saved_logistic.yes(u), current_logistic.yes(u)));
}
@@ -393,7 +393,7 @@ void fast_loglik_cont(logistic& l, const logisticfun& f, const char *name, ld st
if(name) println(hlog, "fix_logistic_parameters");
indenter_finish im(name);
ld cur = f(l);
if(name) println(hlog, format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%" PLDF ")", name, cur, l.R, l.T));
if(name) println(hlog, hr::format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%" PLDF ")", name, cur, l.R, l.T));
map<pair<double, double>, double> memo;
auto ff = [&] () {
@@ -424,7 +424,7 @@ void fast_loglik_cont(logistic& l, const logisticfun& f, const char *name, ld st
if(changed) goto loop;
if(name) println(hlog, format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%10.5" PLDF ")", name, cur, l.R, l.T));
if(name) println(hlog, hr::format("%s = %20.10" PLDF " (R=%10.5" PLDF " T=%10.5" PLDF ")", name, cur, l.R, l.T));
fflush(stdout);
}
}

View File

@@ -397,7 +397,7 @@ void wfc() {
if(isize(freq)) println(hlog, "last freq = ", freq[0].prob);
println(hlog, "freq size = ", isize(freq));
println(hlog, "tfreq = ", format("%lld", tfreq));
println(hlog, "tfreq = ", hr::format("%lld", tfreq));
println(hlog, "trans size = ", isize(trans));
println(hlog, "next code = ", nextcode);
clearMessages();

View File

@@ -100,7 +100,7 @@ void experiment() {
println(hlog, "found: ", tie(ia, ib));
for(auto& row: jms[ia]) {
for(auto& i: row) print(hlog, format("%2d, ", i));
for(auto& i: row) print(hlog, hr::format("%2d, ", i));
println(hlog);
}
}

View File

@@ -31,7 +31,7 @@ void build(crystal::coord co, int at) {
if(WDIM == 3) c->wall = waWaxWall;
}
println(hlog, co, " twos = ", twos, " index = ", index, " set = ", format("%06X", c->landparam));
println(hlog, co, " twos = ", twos, " index = ", index, " set = ", hr::format("%06X", c->landparam));
}

View File

@@ -921,7 +921,7 @@ void ncee() {
displayButton(vid.xres - 8, 8 + vid.fsize, XLAT("(v) menu"), 'v', 16);
if(algo_ticks)
displaystr(8, 8 + vid.fsize, 0, vid.fsize * 2, format("%d.%03d", algo_ticks/1000, algo_ticks%1000), 0xFFFFFF, 0);
displaystr(8, 8 + vid.fsize, 0, vid.fsize * 2, hr::format("%d.%03d", algo_ticks/1000, algo_ticks%1000), 0xFFFFFF, 0);
keyhandler = [=] (int sym, int uni) {
// dialog::handleNavigation(sym, uni);
@@ -977,7 +977,7 @@ void ncee() {
fmap = genellipse(D, i * degree / slow);
println(hlog, "i = ", i);
for(int a=0; a<10; a++) iterate();
if(i >= 0) shot::take(format(rfname.c_str(), i), draw_ncee);
if(i >= 0) shot::take(hr::format(rfname.c_str(), i), draw_ncee);
}
}
};

View File

@@ -388,7 +388,7 @@ void level::init() {
start.timer = 0;
current = start;
println(hlog, "start.where = ", start.where);
println(hlog, "current.where = ", current.where, " : ", format("%p", &current));
println(hlog, "current.where = ", current.where, " : ", hr::format("%p", &current));
int qgoals = isize(goals);
records[0].resize(qgoals, 0);

View File

@@ -22,7 +22,7 @@ void save() {
if(l->records[i][g]) {
println(f, "*RECORD");
println(f, l->name);
println(f, format("%d %d %f", i, g, l->records[i][g]));
println(f, hr::format("%d %d %f", i, g, l->records[i][g]));
}
}
}
@@ -40,7 +40,7 @@ void save() {
println(f, l->name);
println(f, p.name);
println(f, isize(p.plan));
for(auto t: p.plan) println(f, format("%.6f %.6f %.6f %.6f", t.at[0], t.at[1], t.vel[0], t.vel[1]));
for(auto t: p.plan) println(f, hr::format("%.6f %.6f %.6f %.6f", t.at[0], t.at[1], t.vel[0], t.vel[1]));
println(f);
}
}

View File

@@ -217,7 +217,7 @@ void timestamp::centerview(level *lev) {
}
string format_timer(ld t) {
return format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100));
return hr::format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100));
}
void timestamp::draw_instruments(level* l) {
@@ -373,7 +373,7 @@ void timestamp::draw_instruments(level* l) {
string s;
if(loaded_or_planned) s = "R";
else if(reversals) s = format("+%d", reversals);
else if(reversals) s = hr::format("+%d", reversals);
else return;
displaystr(vid.xres - vid.fsize, vid.fsize*4, 0, vid.fsize, s, 0, 16);
}

View File

@@ -196,7 +196,7 @@ string latex_packages =
string latex_cachename(string s, flagtype flags) {
unsigned hash = 0;
for(char c: latex_packages + s) hash = (hash << 3) ^ hash ^ c ^ flags;
return format("latex-cache/%08X.png", hash);
return hr::format("latex-cache/%08X.png", hash);
}
/* note: you pdftopng from the xpdf package for this to work! */
@@ -330,7 +330,7 @@ void show_animation(presmode mode, string s, int sx, int sy, int frames, int fps
/* actually load */
array<int, 2> tab;
if(pipe(&tab[0])) {
addMessage(format("Error: %s", strerror(errno)));
addMessage(hr::format("Error: %s", strerror(errno)));
return;
}

View File

@@ -431,7 +431,7 @@ namespace sag {
if(t2 - tl > 980) {
tl = t2;
println(hlog, format("it %12Ld temp %6.4f [1/e at %13.6f] cost = %f ",
println(hlog, hr::format("it %12Ld temp %6.4f [1/e at %13.6f] cost = %f ",
numiter, double(sag::temperature), (double) exp(sag::temperature),
double(sag::cost)));
}
@@ -458,7 +458,7 @@ namespace sag {
auto t2 = SDL_GetTicks();
if(t2 - t1 > 1000) {
t1 = t2;
println(hlog, format("it %12Ld temp %6.4f [1/e at %13.6f] cost = %f ",
println(hlog, hr::format("it %12Ld temp %6.4f [1/e at %13.6f] cost = %f ",
numiter, double(sag::temperature), (double) exp(sag::temperature),
double(sag::cost)));
}
@@ -491,7 +491,7 @@ namespace sag {
if(t < (sag_ittime+1) / 2) ipturn *= 2;
else if(t > sag_ittime * 2) ipturn /= 2;
else ipturn = ipturn * sag_ittime / t;
print(hlog, format("it %12Ld temp %6.4f [2:%8.6f,10:%8.6f,50:%8.6f] cost = %f\n",
print(hlog, hr::format("it %12Ld temp %6.4f [2:%8.6f,10:%8.6f,50:%8.6f] cost = %f\n",
numiter, double(sag::temperature),
(double) exp(-2 * exp(-sag::temperature)),
(double) exp(-10 * exp(-sag::temperature)),
@@ -701,7 +701,7 @@ namespace sag {
dhrg::fast_loglik_cont(lgemb, lc, nullptr, 1, 1e-5);
println(hlog, "loglik = ", format("%.6f", lc(lgemb)), " R = ", lgemb.R, " T = ", lgemb.T, " iterations = ", embiter);
println(hlog, "loglik = ", hr::format("%.6f", lc(lgemb)), " R = ", lgemb.R, " T = ", lgemb.T, " iterations = ", embiter);
}
void reassign_embedding() {
@@ -769,7 +769,7 @@ namespace sag {
for(int i=0; i<isize(sagid); i++) {
println(f, vdata[i].name);
for(int d=0; d<MDIM; d++)
println(f, format("%.20f", placement[i][d]));
println(f, hr::format("%.20f", placement[i][d]));
}
}
@@ -1153,8 +1153,8 @@ void geo_stats() {
out("geometry", S3 >= OINF ? "tree" : hyperbolic ? "hyperbolic" : sphere ? "sphere" : euclid ? "euclid" : nil ? "nil" : sol ? "solv" : mproduct ? "product" : "other");
out("closed", max_sag_dist == isize(sagcells) ? 0 : closed_manifold ? 1 : 0);
out("angular", angular);
for(int p: {1, 10, 50}) { out(format("sagdist%02d", p), sorted_sagdist[(p * sorted_sagdist.size()) / 100]); }
for(int p: {1, 2, 3, 4}) { out(format("d%d", p), d[p]); }
for(int p: {1, 10, 50}) { out(hr::format("sagdist%02d", p), sorted_sagdist[(p * sorted_sagdist.size()) / 100]); }
for(int p: {1, 2, 3, 4}) { out(hr::format("d%d", p), d[p]); }
println(hlog);
#undef out
}
@@ -1173,7 +1173,7 @@ void output_stats() {
dhrg::prepare_pairs(DN, [] (int i) { return edges_yes[i]; });
dhrg::greedy_routing(routing_result, [] (int i, int j) { return sagdist[sagid[i]][sagid[j]]; });
print(hlog, "CSV;", logid++, ";", isize(sagnode), ";", DN, ";", isize(sagedges), ";", lgsag.R, ";", lgsag.T, ";", cost, ";", mAP, ";", routing_result.suc / routing_result.tot, ";", routing_result.routedist / routing_result.bestdist);
if(report_tempi) print(hlog, ";", hightemp,";",lowtemp,";",format("%lld", numiter));
if(report_tempi) print(hlog, ";", hightemp,";",lowtemp,";",hr::format("%lld", numiter));
println(hlog);
}