diff --git a/bspinfo/main.cc b/bspinfo/main.cc index e6752b23..90cedac9 100644 --- a/bspinfo/main.cc +++ b/bspinfo/main.cc @@ -24,7 +24,7 @@ #include #include -#include + #include #include "common/fs.hh" diff --git a/bsputil/bsputil.cc b/bsputil/bsputil.cc index d07b05ea..b1f08781 100644 --- a/bsputil/bsputil.cc +++ b/bsputil/bsputil.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,6 @@ #include // std::sort #include #include -#include /* FIXME - share header with qbsp, etc. */ struct wadinfo_t @@ -848,7 +848,7 @@ int bsputil_main(int argc, char **argv) for (const auto &ent : ents.entities) { strm << "{\n"; for (const auto &epair : ent.epairs) { - fmt::print(strm, "\"{}\" \"{}\"\n", epair.first, epair.second); + ewt::print(strm, "\"{}\" \"{}\"\n", epair.first, epair.second); } if (!ent.map_brushes.empty()) { strm << ent.map_brushes; diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3bf2fa1a..cd3eab1c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -47,6 +47,7 @@ add_library(common STATIC ../include/common/settings.hh ../include/common/prtfile.hh ../include/common/vectorutils.hh + ../include/common/ostream.hh ) target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb TBB::tbbmalloc fmt::fmt nlohmann_json::nlohmann_json) diff --git a/common/bspinfo.cc b/common/bspinfo.cc index 24827aae..04c50805 100644 --- a/common/bspinfo.cc +++ b/common/bspinfo.cc @@ -21,11 +21,11 @@ #include #include #include +#include -#include #include #include -#include +#include #include #include "common/fs.hh" #include "common/imglib.hh" @@ -37,13 +37,13 @@ static std::string hex_string(const uint8_t *bytes, const size_t count) { - std::stringstream str; + std::string str; for (size_t i = 0; i < count; ++i) { - fmt::print(str, "{:x}", bytes[i]); + fmt::format_to(std::back_inserter(str), "{:x}", bytes[i]); } - return str.str(); + return str; } /** @@ -504,14 +504,14 @@ static void export_obj_and_lightmaps(const mbsp_t &bsp, const bspxentries_t &bsp const int vertnum = Face_VertexAtIndex(bsp, face, i); const qvec3f normal = bsp->dplanes[face->planenum].normal; const qvec3f &pos = bsp->dvertexes[vertnum]; - fmt::print(f, "v {:.9} {:.9} {:.9}\n", pos[0], pos[1], pos[2]); - fmt::print(f, "vn {:.9} {:.9} {:.9}\n", normal[0], normal[1], normal[2]); + ewt::print(f, "v {:.9} {:.9} {:.9}\n", pos[0], pos[1], pos[2]); + ewt::print(f, "vn {:.9} {:.9} {:.9}\n", normal[0], normal[1], normal[2]); qvec2f tc = tcs[i]; tc[1] = 1.0 - tc[1]; - fmt::print(f, "vt {:.9} {:.9}\n", tc[0], tc[1]); + ewt::print(f, "vt {:.9} {:.9}\n", tc[0], tc[1]); } f << "f"; @@ -519,7 +519,7 @@ static void export_obj_and_lightmaps(const mbsp_t &bsp, const bspxentries_t &bsp // .obj vertexes start from 1 // .obj faces are CCW, quake is CW, so reverse the order const int vertindex = vertcount + (face->numedges - 1 - i) + 1; - fmt::print(f, " {0}/{0}/{0}", vertindex); + ewt::print(f, " {0}/{0}/{0}", vertindex); } f << '\n'; diff --git a/common/decompile.cc b/common/decompile.cc index 6446a590..61eb5dcb 100644 --- a/common/decompile.cc +++ b/common/decompile.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,6 @@ #include #include -#include #include "tbb/parallel_for.h" @@ -152,10 +152,10 @@ struct compiled_brush_t } if (source) { - fmt::print(stream, "// generated from brush #{}\n", static_cast(source - bsp->dbrushes.data())); + ewt::print(stream, "// generated from brush #{}\n", static_cast(source - bsp->dbrushes.data())); } - fmt::print(stream, "{{\n"); + ewt::print(stream, "{{\n"); for (auto &side : sides) { planepoints p; @@ -177,11 +177,11 @@ struct compiled_brush_t } #if 0 - fmt::print(stream, "// side #{}: {} {}\n", static_cast(side.source - + ewt::print(stream, "// side #{}: {} {}\n", static_cast(side.source - bsp->dbrushsides.data()), side.plane.normal, side.plane.dist); #endif - fmt::print(stream, "( {} ) ( {} ) ( {} ) {} [ {} {} {} {} ] [ {} {} {} {} ] {} {} {}", p[0], p[1], p[2], + ewt::print(stream, "( {} ) ( {} ) ( {} ) {} [ {} {} {} {} ] [ {} {} {} {} ] {} {} {}", p[0], p[1], p[2], side.texture_name, side.valve.axis.at(0, 0), side.valve.axis.at(0, 1), side.valve.axis.at(0, 2), side.valve.shift[0], side.valve.axis.at(1, 0), side.valve.axis.at(1, 1), side.valve.axis.at(1, 2), side.valve.shift[1], 0.0, side.valve.scale[0], side.valve.scale[1]); @@ -209,14 +209,14 @@ struct compiled_brush_t if (!meta || !((meta->contents & ~(Q2_CONTENTS_SOLID | Q2_CONTENTS_WINDOW)) == (contents.native & ~(Q2_CONTENTS_SOLID | Q2_CONTENTS_WINDOW)) && meta->flags == side.flags.native && meta->value == side.value)) { - fmt::print(stream, " {} {} {}", contents.native, side.flags.native, side.value); + ewt::print(stream, " {} {} {}", contents.native, side.flags.native, side.value); } } - fmt::print(stream, "\n"); + ewt::print(stream, "\n"); } - fmt::print(stream, "}}\n"); + ewt::print(stream, "}}\n"); } }; @@ -1099,7 +1099,7 @@ static void DecompileEntity( } // First, print the key/values for this entity - fmt::print(file, "{{\n"); + ewt::print(file, "{{\n"); for (const auto &keyValue : dict) { if (keyValue.first == "model" && !keyValue.second.empty() && keyValue.second[0] == '*') { // strip "model" "*NNN" key/values @@ -1127,7 +1127,7 @@ static void DecompileEntity( continue; } - fmt::print(file, "\"{}\" \"{}\"\n", keyValue.first, keyValue.second); + ewt::print(file, "\"{}\" \"{}\"\n", keyValue.first, keyValue.second); } std::vector> compiledBrushes; @@ -1312,7 +1312,7 @@ static void DecompileEntity( } } - fmt::print(file, "}}\n"); + ewt::print(file, "}}\n"); } void DecompileBSP(const mbsp_t *bsp, const decomp_options &options, std::ofstream &file) diff --git a/common/entdata.cc b/common/entdata.cc index 755af48d..ded88030 100644 --- a/common/entdata.cc +++ b/common/entdata.cc @@ -19,13 +19,12 @@ #include -#include #include // atoi() #include #include -#include +#include entdict_t::entdict_t(std::initializer_list l) : keyvalues(l) diff --git a/common/prtfile.cc b/common/prtfile.cc index 7aa20147..07202310 100644 --- a/common/prtfile.cc +++ b/common/prtfile.cc @@ -22,9 +22,9 @@ #include #include #include +#include #include -#include constexpr const char *PORTALFILE = "PRT1"; constexpr const char *PORTALFILE2 = "PRT2"; @@ -175,11 +175,11 @@ prtfile_t LoadPrtFile(const fs::path &name, const bspversion_t *loadversion) static void WriteDebugPortal(const polylib::winding_t &w, std::ofstream &portalFile) { - fmt::print(portalFile, "{} {} {} ", w.size(), 0, 0); + ewt::print(portalFile, "{} {} {} ", w.size(), 0, 0); for (int i = 0; i < w.size(); i++) { - fmt::print(portalFile, "({} {} {}) ", w.at(i)[0], w.at(i)[1], w.at(i)[2]); + ewt::print(portalFile, "({} {} {}) ", w.at(i)[0], w.at(i)[1], w.at(i)[2]); } - fmt::print(portalFile, "\n"); + ewt::print(portalFile, "\n"); } void WriteDebugPortals(const std::vector &portals, fs::path name) @@ -190,9 +190,9 @@ void WriteDebugPortals(const std::vector &portals, fs::path if (!portal_file) FError("Failed to open {}: {}", name, strerror(errno)); - fmt::print(portal_file, "PRT1\n"); - fmt::print(portal_file, "{}\n", 0); - fmt::print(portal_file, "{}\n", portal_count); + ewt::print(portal_file, "PRT1\n"); + ewt::print(portal_file, "{}\n", 0); + ewt::print(portal_file, "{}\n", portal_count); for (auto &p : portals) { WriteDebugPortal(p, portal_file); } diff --git a/include/common/ostream.hh b/include/common/ostream.hh new file mode 100644 index 00000000..e8d79cf8 --- /dev/null +++ b/include/common/ostream.hh @@ -0,0 +1,36 @@ +/* Copyright (C) 2023 Eric Wasylishen + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +See file, 'COPYING', for details. +*/ + +#pragma once + +#include +#include +#include + +namespace ewt +{ +/** + * replacement for fmt::print from fmt/ostream.h with less compilation time impact. + */ +template +inline void print(std::ostream &stream, fmt::format_string format, T &&...args) +{ + fmt::vformat_to(std::ostream_iterator(stream), format, fmt::make_format_args(args...)); +} +} // namespace ewt diff --git a/light/light.cc b/light/light.cc index f53f510f..500c1c14 100644 --- a/light/light.cc +++ b/light/light.cc @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -39,6 +38,7 @@ #include #include #include +#include #if defined(HAVE_EMBREE) && defined(__SSE2__) #include @@ -1206,8 +1206,8 @@ static void ExportObjFace(std::ofstream &f, const mbsp_t *bsp, const mface_t *fa const int vertnum = Face_VertexAtIndex(bsp, face, i); const qvec3f normal = GetSurfaceVertexNormal(bsp, face, i).normal; const qvec3f &pos = bsp->dvertexes[vertnum]; - fmt::print(f, "v {:.9} {:.9} {:.9}\n", pos[0], pos[1], pos[2]); - fmt::print(f, "vn {:.9} {:.9} {:.9}\n", normal[0], normal[1], normal[2]); + ewt::print(f, "v {:.9} {:.9} {:.9}\n", pos[0], pos[1], pos[2]); + ewt::print(f, "vn {:.9} {:.9} {:.9}\n", normal[0], normal[1], normal[2]); } f << "f"; @@ -1215,7 +1215,7 @@ static void ExportObjFace(std::ofstream &f, const mbsp_t *bsp, const mface_t *fa // .obj vertexes start from 1 // .obj faces are CCW, quake is CW, so reverse the order const int vertindex = *vertcount + (face->numedges - 1 - i) + 1; - fmt::print(f, " {}//{}", vertindex, vertindex); + ewt::print(f, " {}//{}", vertindex, vertindex); } f << '\n'; diff --git a/light/lightgrid.cc b/light/lightgrid.cc index d81d1adb..fa2ca123 100644 --- a/light/lightgrid.cc +++ b/light/lightgrid.cc @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include #include diff --git a/light/ltface.cc b/light/ltface.cc index 1556b1de..7fa8c424 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -32,13 +32,13 @@ #include #include #include +#include #include #include #include #include #include -#include using namespace std; @@ -275,12 +275,12 @@ static void CalcPoints_Debug(const lightsurf_t *surf, const mbsp_t *bsp) f << "{\n"; f << "\"classname\" \"light\"\n"; - fmt::print(f, "\"origin\" \"{}\"\n", point); - fmt::print(f, "\"mangle\" \"{}\"\n", mangle); - fmt::print(f, "\"face\" \"{}\"\n", sample.realfacenum); - fmt::print(f, "\"occluded\" \"{}\"\n", sample.occluded); - fmt::print(f, "\"s\" \"{}\"\n", s); - fmt::print(f, "\"t\" \"{}\"\n", t); + ewt::print(f, "\"origin\" \"{}\"\n", point); + ewt::print(f, "\"mangle\" \"{}\"\n", mangle); + ewt::print(f, "\"face\" \"{}\"\n", sample.realfacenum); + ewt::print(f, "\"occluded\" \"{}\"\n", sample.occluded); + ewt::print(f, "\"s\" \"{}\"\n", s); + ewt::print(f, "\"t\" \"{}\"\n", t); f << "}\n"; } } @@ -2533,7 +2533,7 @@ static void WritePPM(const fs::path &fname, int width, int height, const uint8_t qfile_t file = SafeOpenWrite(fname); // see: http://netpbm.sourceforge.net/doc/ppm.html - fmt::print(file.get(), "P6 {} {} 255 ", width, height); + ewt::print(file.get(), "P6 {} {} 255 ", width, height); int bytes = width * height * 3; Q_assert(bytes == SafeWrite(file, rgbdata, bytes)); } diff --git a/qbsp/exportobj.cc b/qbsp/exportobj.cc index b4605ca4..eeeea3d5 100644 --- a/qbsp/exportobj.cc +++ b/qbsp/exportobj.cc @@ -22,12 +22,12 @@ #include #include +#include #include #include #include #include -#include #include static std::ofstream InitObjFile(const std::string &filesuffix) @@ -66,23 +66,23 @@ static void ExportObjFace( // export the vertices and uvs for (int i = 0; i < w.size(); i++) { const qvec3d &pos = w[i]; - fmt::print(f, "v {:.9} {:.9} {:.9}\n", pos[0], pos[1], pos[2]); + ewt::print(f, "v {:.9} {:.9} {:.9}\n", pos[0], pos[1], pos[2]); qvec3d uv = texinfo.vecs.uvs(pos, width, height); // not sure why -v is needed, .obj uses (0, 0) in the top left apparently? - fmt::print(f, "vt {:.9} {:.9}\n", uv[0], -uv[1]); + ewt::print(f, "vt {:.9} {:.9}\n", uv[0], -uv[1]); } if (!mtlname.empty()) { - fmt::print(f, "usemtl {}\n", mtlname); + ewt::print(f, "usemtl {}\n", mtlname); } f << 'f'; for (int i = 0; i < w.size(); i++) { // .obj vertexes start from 1 // .obj faces are CCW, quake is CW, so reverse the order const int vertindex = *vertcount + (w.size() - 1 - i) + 1; - fmt::print(f, " {}/{}", vertindex, vertindex); + ewt::print(f, " {}/{}", vertindex, vertindex); } f << '\n'; @@ -92,9 +92,9 @@ static void ExportObjFace( static void WriteContentsMaterial(std::ofstream &mtlf, contentflags_t contents, float r, float g, float b) { // fixme-brushbsp - fmt::print(mtlf, "newmtl contents{}\n", contents.native); + ewt::print(mtlf, "newmtl contents{}\n", contents.native); mtlf << "Ka 0 0 0\n"; - fmt::print(mtlf, "Kd {} {} {}\n", r, g, b); + ewt::print(mtlf, "Kd {} {} {}\n", r, g, b); mtlf << "Ks 0 0 0\n"; mtlf << "illum 0\n"; } diff --git a/qbsp/map.cc b/qbsp/map.cc index 59824697..01934d74 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include @@ -3051,10 +3051,10 @@ inline void WriteMapBrushMap(const fs::path &name, const std::vector if (!f) FError("Can't write {}", name); - fmt::print(f, "{{\n\"classname\" \"worldspawn\"\n"); + ewt::print(f, "{{\n\"classname\" \"worldspawn\"\n"); for (auto &brush : list) { - fmt::print(f, "{{\n"); + ewt::print(f, "{{\n"); for (auto &face : brush.faces) { qvec3d corner = {}; @@ -3070,25 +3070,25 @@ inline void WriteMapBrushMap(const fs::path &name, const std::vector winding_t w = BaseWindingForPlane(plane); - fmt::print(f, "( {} ) ", w[0]); - fmt::print(f, "( {} ) ", w[1]); - fmt::print(f, "( {} ) ", w[2]); + ewt::print(f, "( {} ) ", w[0]); + ewt::print(f, "( {} ) ", w[1]); + ewt::print(f, "( {} ) ", w[2]); #if 0 if (face.visible) { - fmt::print(f, "skip 0 0 0 1 1\n"); + ewt::print(f, "skip 0 0 0 1 1\n"); } else { - fmt::print(f, "nonvisible 0 0 0 1 1\n"); + ewt::print(f, "nonvisible 0 0 0 1 1\n"); } #endif - fmt::print(f, "{} 0 0 0 1 1\n", face.texname); + ewt::print(f, "{} 0 0 0 1 1\n", face.texname); } - fmt::print(f, "}}\n"); + ewt::print(f, "}}\n"); } - fmt::print(f, "}}\n"); + ewt::print(f, "}}\n"); f.close(); } @@ -3455,9 +3455,9 @@ static void fprintDoubleAndSpc(std::ofstream &f, double v) { int rounded = rint(v); if (static_cast(rounded) == v) { - fmt::print(f, "{} ", rounded); + ewt::print(f, "{} ", rounded); } else if (std::isfinite(v)) { - fmt::print(f, "{:0.17} ", v); + ewt::print(f, "{:0.17} ", v); } else { printf("WARNING: suppressing nan or infinity\n"); f << "0 "; @@ -3485,7 +3485,7 @@ static void ConvertMapFace(std::ofstream &f, const mapface_t &mapface, const con const texdef_quake_ed_t quakeed = TexDef_BSPToQuakeEd(mapface.get_plane(), texture, texinfo.vecs, mapface.planepts); - fmt::print(f, "{} ", mapface.texname); + ewt::print(f, "{} ", mapface.texname); fprintDoubleAndSpc(f, quakeed.shift[0]); fprintDoubleAndSpc(f, quakeed.shift[1]); fprintDoubleAndSpc(f, quakeed.rotate); @@ -3502,7 +3502,7 @@ static void ConvertMapFace(std::ofstream &f, const mapface_t &mapface, const con case conversion_t::valve: { const texdef_valve_t valve = TexDef_BSPToValve(texinfo.vecs); - fmt::print(f, "{} [ ", mapface.texname); + ewt::print(f, "{} [ ", mapface.texname); fprintDoubleAndSpc(f, valve.axis.at(0, 0)); fprintDoubleAndSpc(f, valve.axis.at(0, 1)); fprintDoubleAndSpc(f, valve.axis.at(0, 2)); @@ -3540,7 +3540,7 @@ static void ConvertMapFace(std::ofstream &f, const mapface_t &mapface, const con fprintDoubleAndSpc(f, bp.at(1, 2)); // N.B.: always print the Q2/Q3 flags - fmt::print(f, ") ) {} ", mapface.texname); + ewt::print(f, ") ) {} ", mapface.texname); if (mapface.raw_info.has_value()) { f << mapface.raw_info->contents.native << " " << mapface.raw_info->flags.native << " " @@ -3578,7 +3578,7 @@ static void ConvertEntity(std::ofstream &f, const mapentity_t &entity, const con f << "{\n"; for (const auto &[key, value] : entity.epairs) { - fmt::print(f, "\"{}\" \"{}\"\n", key, value); + ewt::print(f, "\"{}\" \"{}\"\n", key, value); } for (auto &mapbrush : entity.mapbrushes) { @@ -3771,35 +3771,35 @@ void WriteBspBrushMap(std::string_view filename_suffix, const bspbrush_t::contai if (!f) FError("Can't write {}", name); - fmt::print(f, "{{\n\"classname\" \"worldspawn\"\n"); + ewt::print(f, "{{\n\"classname\" \"worldspawn\"\n"); for (auto &brush : list) { if (!brush) { continue; } - fmt::print(f, "{{\n"); + ewt::print(f, "{{\n"); for (auto &face : brush->sides) { winding_t w = BaseWindingForPlane(face.get_plane()); - fmt::print(f, "( {} ) ", w[0]); - fmt::print(f, "( {} ) ", w[1]); - fmt::print(f, "( {} ) ", w[2]); + ewt::print(f, "( {} ) ", w[0]); + ewt::print(f, "( {} ) ", w[1]); + ewt::print(f, "( {} ) ", w[2]); #if 0 if (face.visible) { - fmt::print(f, "skip 0 0 0 1 1\n"); + ewt::print(f, "skip 0 0 0 1 1\n"); } else { - fmt::print(f, "nonvisible 0 0 0 1 1\n"); + ewt::print(f, "nonvisible 0 0 0 1 1\n"); } #endif - fmt::print(f, "{} 0 0 0 1 1\n", map.miptex[face.get_texinfo().miptex].name); + ewt::print(f, "{} 0 0 0 1 1\n", map.miptex[face.get_texinfo().miptex].name); } - fmt::print(f, "}}\n"); + ewt::print(f, "}}\n"); } - fmt::print(f, "}}\n"); + ewt::print(f, "}}\n"); f.close(); } diff --git a/qbsp/outside.cc b/qbsp/outside.cc index cbea6acc..9a6187ad 100644 --- a/qbsp/outside.cc +++ b/qbsp/outside.cc @@ -28,13 +28,13 @@ #include #include +#include #include #include #include #include #include #include -#include static bool LeafSealsMap(const node_t *node) { @@ -251,7 +251,7 @@ void WriteLeakTrail(std::ofstream &leakfile, qvec3d point1, const qvec3d &point2 vec_t dist = qv::normalizeInPlace(vector); while (dist > qbsp_options.leakdist.value()) { - fmt::print(leakfile, "{}\n", point1); + ewt::print(leakfile, "{}\n", point1); point1 += vector * qbsp_options.leakdist.value(); dist -= qbsp_options.leakdist.value(); } diff --git a/qbsp/prtfile.cc b/qbsp/prtfile.cc index f1626615..f0e112fc 100644 --- a/qbsp/prtfile.cc +++ b/qbsp/prtfile.cc @@ -22,13 +22,13 @@ #include #include +#include #include #include #include #include #include -#include /* ============================================================================== @@ -41,9 +41,9 @@ PORTAL FILE GENERATION static void WriteFloat(std::ofstream &portalFile, vec_t v) { if (fabs(v - Q_rint(v)) < ZERO_EPSILON) - fmt::print(portalFile, "{} ", (int)Q_rint(v)); + ewt::print(portalFile, "{} ", (int)Q_rint(v)); else - fmt::print(portalFile, "{} ", v); + ewt::print(portalFile, "{} ", v); } static void WritePortals_r(node_t *node, std::ofstream &portalFile, bool clusters) @@ -89,19 +89,19 @@ static void WritePortals_r(node_t *node, std::ofstream &portalFile, bool cluster */ plane2 = w->plane(); if (qv::dot(p->plane.get_normal(), plane2.normal) < 1.0 - ANGLEEPSILON) { - fmt::print(portalFile, "{} {} {} ", w->size(), back, front); + ewt::print(portalFile, "{} {} {} ", w->size(), back, front); } else { - fmt::print(portalFile, "{} {} {} ", w->size(), front, back); + ewt::print(portalFile, "{} {} {} ", w->size(), front, back); } for (i = 0; i < w->size(); i++) { - fmt::print(portalFile, "("); + ewt::print(portalFile, "("); WriteFloat(portalFile, w->at(i)[0]); WriteFloat(portalFile, w->at(i)[1]); WriteFloat(portalFile, w->at(i)[2]); - fmt::print(portalFile, ") "); + ewt::print(portalFile, ") "); } - fmt::print(portalFile, "\n"); + ewt::print(portalFile, "\n"); } } @@ -117,7 +117,7 @@ static int WritePTR2ClusterMapping_r(node_t *node, std::ofstream &portalFile, in /* If we're in the next cluster, start a new line */ if (node->viscluster != viscluster) { - fmt::print(portalFile, "-1\n"); + ewt::print(portalFile, "-1\n"); viscluster++; } @@ -125,7 +125,7 @@ static int WritePTR2ClusterMapping_r(node_t *node, std::ofstream &portalFile, in if (node->viscluster != viscluster) FError("Internal error: Detail cluster mismatch"); - fmt::print(portalFile, "{} ", node->visleafnum); + ewt::print(portalFile, "{} ", node->visleafnum); return viscluster; } @@ -218,37 +218,37 @@ static void WritePortalfile(node_t *headnode, portal_state_t &state) // q2 uses a PRT1 file, but with clusters. // (Since q2bsp natively supports clusters, we don't need PRT2.) if (qbsp_options.target_game->id == GAME_QUAKE_II) { - fmt::print(portalFile, "PRT1\n"); - fmt::print(portalFile, "{}\n", state.num_visclusters.count.load()); - fmt::print(portalFile, "{}\n", state.num_visportals.count.load()); + ewt::print(portalFile, "PRT1\n"); + ewt::print(portalFile, "{}\n", state.num_visclusters.count.load()); + ewt::print(portalFile, "{}\n", state.num_visportals.count.load()); WritePortals_r(headnode, portalFile, true); return; } /* If no detail clusters, just use a normal PRT1 format */ if (!state.uses_detail) { - fmt::print(portalFile, "PRT1\n"); - fmt::print(portalFile, "{}\n", state.num_visleafs.count.load()); - fmt::print(portalFile, "{}\n", state.num_visportals.count.load()); + ewt::print(portalFile, "PRT1\n"); + ewt::print(portalFile, "{}\n", state.num_visleafs.count.load()); + ewt::print(portalFile, "{}\n", state.num_visportals.count.load()); WritePortals_r(headnode, portalFile, false); } else if (qbsp_options.forceprt1.value()) { /* Write a PRT1 file for loading in the map editor. Vis will reject it. */ - fmt::print(portalFile, "PRT1\n"); - fmt::print(portalFile, "{}\n", state.num_visclusters.count.load()); - fmt::print(portalFile, "{}\n", state.num_visportals.count.load()); + ewt::print(portalFile, "PRT1\n"); + ewt::print(portalFile, "{}\n", state.num_visclusters.count.load()); + ewt::print(portalFile, "{}\n", state.num_visportals.count.load()); WritePortals_r(headnode, portalFile, true); } else { /* Write a PRT2 */ - fmt::print(portalFile, "PRT2\n"); - fmt::print(portalFile, "{}\n", state.num_visleafs.count.load()); - fmt::print(portalFile, "{}\n", state.num_visclusters.count.load()); - fmt::print(portalFile, "{}\n", state.num_visportals.count.load()); + ewt::print(portalFile, "PRT2\n"); + ewt::print(portalFile, "{}\n", state.num_visleafs.count.load()); + ewt::print(portalFile, "{}\n", state.num_visclusters.count.load()); + ewt::print(portalFile, "{}\n", state.num_visportals.count.load()); WritePortals_r(headnode, portalFile, true); check = WritePTR2ClusterMapping_r(headnode, portalFile, 0); if (check != state.num_visclusters.count.load() - 1) { FError("Internal error: Detail cluster mismatch"); } - fmt::print(portalFile, "-1\n"); + ewt::print(portalFile, "-1\n"); } } @@ -293,12 +293,12 @@ static void WriteDebugPortal(const portal_t *p, std::ofstream &portalFile) { const winding_t *w = &p->winding; - fmt::print(portalFile, "{} {} {} ", w->size(), 0, 0); + ewt::print(portalFile, "{} {} {} ", w->size(), 0, 0); for (int i = 0; i < w->size(); i++) { - fmt::print(portalFile, "({} {} {}) ", w->at(i)[0], w->at(i)[1], w->at(i)[2]); + ewt::print(portalFile, "({} {} {}) ", w->at(i)[0], w->at(i)[1], w->at(i)[2]); } - fmt::print(portalFile, "\n"); + ewt::print(portalFile, "\n"); } static void WriteTreePortals_r(node_t *node, std::ofstream &portalFile) @@ -357,9 +357,9 @@ void WriteDebugTreePortalFile(tree_t &tree, std::string_view filename_suffix) if (!portalFile) FError("Failed to open {}: {}", name, strerror(errno)); - fmt::print(portalFile, "PRT1\n"); - fmt::print(portalFile, "{}\n", 0); - fmt::print(portalFile, "{}\n", portal_count); + ewt::print(portalFile, "PRT1\n"); + ewt::print(portalFile, "{}\n", 0); + ewt::print(portalFile, "{}\n", portal_count); WriteTreePortals_r(tree.headnode, portalFile); logging::print(logging::flag::STAT, " {:8} tree portals written to {}\n", portal_count, name); @@ -385,9 +385,9 @@ void WriteDebugPortals(std::vector portals, std::string_view filenam if (!portal_file) FError("Failed to open {}: {}", name, strerror(errno)); - fmt::print(portal_file, "PRT1\n"); - fmt::print(portal_file, "{}\n", 0); - fmt::print(portal_file, "{}\n", portal_count); + ewt::print(portal_file, "PRT1\n"); + ewt::print(portal_file, "{}\n", 0); + ewt::print(portal_file, "{}\n", portal_count); for (auto &p : portals) { if (p->winding) { WriteDebugPortal(p, portal_file);