diff --git a/cfg/language.ini b/cfg/language.ini index 74625e20..568e216c 100644 --- a/cfg/language.ini +++ b/cfg/language.ini @@ -1012,8 +1012,6 @@ LANG_1010 = Matrix inversion failed (determinant is zero)\n LANG_1011 = Only 1 unique vert!\n LANG_1012 = All verts are colinear!\n LANG_1013 = Can't write to output file!\n -LANG_1014 = \x1B[0m -LANG_1015 = \x1B[{};{}m LANG_1016 = \n***** ERROR *****\nAssume '{}' failed\n at {}:{}\n {}\n\n LANG_1017 = Deleting unused data:\n LANG_1018 = ERROR: model number must be 0 - {}\n diff --git a/src/bsp/Bsp.cpp b/src/bsp/Bsp.cpp index b88696bd..5966b121 100644 --- a/src/bsp/Bsp.cpp +++ b/src/bsp/Bsp.cpp @@ -50,7 +50,7 @@ void Bsp::init_empty_bsp() bsp_valid = true; renderer = NULL; - logf(get_localized_string(LANG_0035)); + print_log(get_localized_string(LANG_0035)); renderer = NULL; bsp_valid = true; @@ -198,17 +198,17 @@ Bsp::Bsp(std::string fpath) if (!fileExists(fpath)) { - logf(get_localized_string(LANG_0036),fpath); + print_log(get_localized_string(LANG_0036),fpath); return; } if (!load_lumps(fpath)) { - logf(get_localized_string(LANG_0037),fpath); + print_log(get_localized_string(LANG_0037),fpath); return; } - logf(get_localized_string(LANG_0038),reverse_bits(originCrc32)); + print_log(get_localized_string(LANG_0038),reverse_bits(originCrc32)); std::string entFilePath; if (g_settings.sameDirForEnt) { @@ -219,7 +219,7 @@ Bsp::Bsp(std::string fpath) } if (g_settings.autoImportEnt && fileExists(entFilePath)) { - logf(get_localized_string(LANG_0039),entFilePath); + print_log(get_localized_string(LANG_0039),entFilePath); int len; char* newlump = loadFile(entFilePath, len); @@ -243,7 +243,7 @@ Bsp::Bsp(std::string fpath) abs(lastModel.vOrigin.z - 9999.0) < 0.01 && lastModel.nFaces == 0) { - logf(get_localized_string(LANG_0040),modelCount - 1); + print_log(get_localized_string(LANG_0040),modelCount - 1); bsp_header.lump[LUMP_MODELS].nLength -= sizeof(BSPMODEL); update_lump_pointers(); } @@ -271,7 +271,7 @@ Bsp::Bsp(std::string fpath) { if (!used_models.count(i)) { - logf(get_localized_string(LANG_0041),bsp_name,i); + print_log(get_localized_string(LANG_0041),bsp_name,i); } } @@ -282,7 +282,7 @@ Bsp::Bsp(std::string fpath) if (!ents.empty() && !ents[0]->hasKey("CRC") && !force_skip_crc) { - logf(get_localized_string(LANG_0042)); + print_log(get_localized_string(LANG_0042)); ents[0]->addKeyvalue("CRC", std::to_string(reverse_bits(originCrc32))); update_ent_lump(); } @@ -617,7 +617,7 @@ void Bsp::get_clipnode_leaf_cuts(int iNode, int iStartNode, std::vector& c if (node.iChildren[i] == iStartNode) { - logf(get_localized_string(LANG_0044),node.iChildren[i]); + print_log(get_localized_string(LANG_0044),node.iChildren[i]); return; } @@ -800,7 +800,7 @@ bool Bsp::vertex_manipulation_sync(int modelIdx, std::vector& hul if (tverts.size() < 3) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0045)); + print_log(get_localized_string(LANG_0045)); return false; // invalid solid } @@ -808,7 +808,7 @@ bool Bsp::vertex_manipulation_sync(int modelIdx, std::vector& hul if (!getPlaneFromVerts(tverts, newPlane.vNormal, newPlane.fDist)) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0046)); + print_log(get_localized_string(LANG_0046)); return false; // verts not planar } @@ -870,7 +870,7 @@ bool Bsp::vertex_manipulation_sync(int modelIdx, std::vector& hul } } - //logf(get_localized_string(LANG_0047),planeUpdates); + //print_log(get_localized_string(LANG_0047),planeUpdates); BSPMODEL& model = models[modelIdx]; getBoundingBox(allVertPos, model.nMins, model.nMaxs); @@ -881,7 +881,7 @@ bool Bsp::move(vec3 offset, int modelIdx, bool onlyModel, bool forceMove, bool l { if (modelIdx < 0 || modelIdx >= modelCount) { - logf(get_localized_string(LANG_0048)); + print_log(get_localized_string(LANG_0048)); return false; } @@ -955,7 +955,7 @@ bool Bsp::move(vec3 offset, int modelIdx, bool onlyModel, bool forceMove, bool l abs(target.nMaxs.y) > FLT_MAX_COORD || abs(target.nMaxs.z) > FLT_MAX_COORD) { - logf(get_localized_string(LANG_0049)); + print_log(get_localized_string(LANG_0049)); } STRUCTUSAGE shouldBeMoved(this); @@ -977,7 +977,7 @@ bool Bsp::move(vec3 offset, int modelIdx, bool onlyModel, bool forceMove, bool l abs((float)node.nMins[2] + offset.z) > FLT_MAX_COORD || abs((float)node.nMaxs[2] + offset.z) > FLT_MAX_COORD) { - logf(get_localized_string(LANG_0050)); + print_log(get_localized_string(LANG_0050)); } node.nMins[0] += offset.x; node.nMaxs[0] += offset.x; @@ -1003,7 +1003,7 @@ bool Bsp::move(vec3 offset, int modelIdx, bool onlyModel, bool forceMove, bool l abs((float)leaf.nMins[2] + offset.z) > FLT_MAX_COORD || abs((float)leaf.nMaxs[2] + offset.z) > FLT_MAX_COORD) { - logf(get_localized_string(LANG_0051)); + print_log(get_localized_string(LANG_0051)); } leaf.nMins[0] += offset.x; leaf.nMaxs[0] += offset.x; @@ -1028,7 +1028,7 @@ bool Bsp::move(vec3 offset, int modelIdx, bool onlyModel, bool forceMove, bool l abs(vert.y) > FLT_MAX_COORD || abs(vert.z) > FLT_MAX_COORD) { - logf(get_localized_string(LANG_0052)); + print_log(get_localized_string(LANG_0052)); } } @@ -1045,7 +1045,7 @@ bool Bsp::move(vec3 offset, int modelIdx, bool onlyModel, bool forceMove, bool l if (abs(newPlaneOri.x) > FLT_MAX_COORD || abs(newPlaneOri.y) > FLT_MAX_COORD || abs(newPlaneOri.z) > FLT_MAX_COORD) { - logf(get_localized_string(LANG_0053)); + print_log(get_localized_string(LANG_0053)); } // get distance between new plane origin and the origin-aligned plane @@ -1208,7 +1208,7 @@ void Bsp::resize_lightmaps(LIGHTMAP* oldLightmaps, LIGHTMAP* newLightmaps, COLOR } if (lightmapsResizeCount > 0) { - //logf(get_localized_string(LANG_0054),lightmapsResizeCount); + //print_log(get_localized_string(LANG_0054),lightmapsResizeCount); g_progress.update("Resize lightmaps", faceCount); @@ -1315,7 +1315,7 @@ void Bsp::split_shared_model_structures(int modelIdx) { // skip solid leaf - it doesn't matter if (shouldMove.leaves[i] && shouldNotMove.leaves[i]) { - logf(get_localized_string(LANG_0055)); + print_log(get_localized_string(LANG_0055)); break; } } @@ -1323,7 +1323,7 @@ void Bsp::split_shared_model_structures(int modelIdx) { if (shouldMove.nodes[i] && shouldNotMove.nodes[i]) { - logf(get_localized_string(LANG_0056)); + print_log(get_localized_string(LANG_0056)); break; } } @@ -1332,7 +1332,7 @@ void Bsp::split_shared_model_structures(int modelIdx) if (shouldMove.verts[i] && shouldNotMove.verts[i]) { // this happens on activist series but doesn't break anything - logf(get_localized_string(LANG_0057)); + print_log(get_localized_string(LANG_0057)); break; } } @@ -1413,13 +1413,13 @@ void Bsp::split_shared_model_structures(int modelIdx) if (duplicatePlanes || duplicateClipnodes || duplicateTexinfos) { - logf(get_localized_string(LANG_0058)); + print_log(get_localized_string(LANG_0058)); if (duplicatePlanes) - logf(get_localized_string(LANG_0059),duplicatePlanes); + print_log(get_localized_string(LANG_0059),duplicatePlanes); if (duplicateClipnodes) - logf(get_localized_string(LANG_0060),duplicateClipnodes); + print_log(get_localized_string(LANG_0060),duplicateClipnodes); if (duplicateTexinfos) - logf(get_localized_string(LANG_0061),duplicateTexinfos); + print_log(get_localized_string(LANG_0061),duplicateTexinfos); } } @@ -1549,7 +1549,7 @@ unsigned int Bsp::remove_unused_structs(int lumpIdx, bool* usedStructs, int* rem case LUMP_EDGES: structSize = sizeof(BSPEDGE32); break; case LUMP_SURFEDGES: structSize = sizeof(int); break; default: - logf(get_localized_string(LANG_0062),lumpIdx); + print_log(get_localized_string(LANG_0062),lumpIdx); return 0; } @@ -1787,7 +1787,7 @@ unsigned int Bsp::remove_unused_visdata(bool* usedLeaves, BSPLEAF32* oldLeaves, { if ((int)(i * newVisRowSize + minRowSize) >= newDecompressedVisSize) { - logf(get_localized_string(LANG_0063)); + print_log(get_localized_string(LANG_0063)); break; } memcpy(newDecompressedVis + i * newVisRowSize, decompressedVis + i * oldVisRowSize, minRowSize); @@ -1818,7 +1818,7 @@ unsigned int Bsp::remove_unused_visdata(bool* usedLeaves, BSPLEAF32* oldLeaves, int newWorldLeaves = ((BSPMODEL*)lumps[LUMP_MODELS])->nVisLeafs; - logf(get_localized_string(LANG_0064),oldVisLeafCount,newVisLeafCount); + print_log(get_localized_string(LANG_0064),oldVisLeafCount,newVisLeafCount); int tmpLumpVisMemSize = bsp_header.lump[LUMP_VISIBILITY].nLength; @@ -1827,7 +1827,7 @@ unsigned int Bsp::remove_unused_visdata(bool* usedLeaves, BSPLEAF32* oldLeaves, int oldVisRowSize2 = ((oldVisLeafCount + 63 - 1) & ~63) >> 3; int newVisRowSize2 = ((newVisLeafCount + 63 - 1) & ~63) >> 3; - logf(get_localized_string(LANG_0065),oldVisRowSize,newVisRowSize,oldVisRowSize2,newVisRowSize2,oldVisLeafCount,newVisLeafCount); + print_log(get_localized_string(LANG_0065),oldVisRowSize,newVisRowSize,oldVisRowSize2,newVisRowSize2,oldVisLeafCount,newVisLeafCount); int oldDecompressedLen = oldVisRowSize * newVisLeafCount; @@ -1849,7 +1849,7 @@ unsigned int Bsp::remove_unused_visdata(bool* usedLeaves, BSPLEAF32* oldLeaves, { if (i * newVisRowSize + minRowSize >= newDecompressedVisSize) { - logf(get_localized_string(LANG_1019)); + print_log(get_localized_string(LANG_1019)); break; } memcpy(newDecompressedVis + i * newVisRowSize, decompressedVis + i * oldVisRowSize, minRowSize); @@ -1960,7 +1960,7 @@ STRUCTCOUNT Bsp::remove_unused_model_structures(unsigned int target) int merged_verts = 0; if (g_settings.merge_verts && target & CLEAN_VERTICES) { - logf(get_localized_string(LANG_0066)); + print_log(get_localized_string(LANG_0066)); merged_verts = merge_all_verts() + merge_all_verts(); } @@ -2240,7 +2240,7 @@ void remove_unused_wad_files(Bsp* baseMap, Bsp* targetMap, int tex_type) targetMap->update_ent_lump(); targetMap->update_lump_pointers(); - logf(get_localized_string(LANG_0067),wads); + print_log(get_localized_string(LANG_0067),wads); } bool Bsp::has_hull2_ents() @@ -2330,7 +2330,7 @@ STRUCTCOUNT Bsp::delete_unused_hulls(bool noProgress) if (usageEnts.empty()) { - logf(get_localized_string(LANG_0068),i); + print_log(get_localized_string(LANG_0068),i); for (int k = 0; k < MAX_MAP_HULLS; k++) deletedHulls += models[i].iHeadnodes[k] >= 0; @@ -2450,7 +2450,7 @@ STRUCTCOUNT Bsp::delete_unused_hulls(bool noProgress) if (!needsVisibleHull && !needsMonsterHulls) { if (models[i].iHeadnodes[0] >= 0) - logf(get_localized_string(LANG_0069),i,uses); + print_log(get_localized_string(LANG_0069),i,uses); deletedHulls += models[i].iHeadnodes[0] >= 0; @@ -2473,7 +2473,7 @@ STRUCTCOUNT Bsp::delete_unused_hulls(bool noProgress) } if (deletedAnyHulls) - logf(get_localized_string(LANG_0070),i,uses); + print_log(get_localized_string(LANG_0070),i,uses); model.iHeadnodes[1] = -1; model.iHeadnodes[2] = -1; @@ -2482,7 +2482,7 @@ STRUCTCOUNT Bsp::delete_unused_hulls(bool noProgress) else if (!needsMonsterHulls) { if (models[i].iHeadnodes[2] >= 0) - logf(get_localized_string(LANG_0071),i,uses); + print_log(get_localized_string(LANG_0071),i,uses); deletedHulls += models[i].iHeadnodes[2] >= 0; @@ -2722,7 +2722,7 @@ vec3 Bsp::get_model_center(int modelIdx) { if (modelIdx < 0 || modelIdx > bsp_header.lump[LUMP_MODELS].nLength / sizeof(BSPMODEL)) { - logf(get_localized_string(LANG_0072),modelIdx); + print_log(get_localized_string(LANG_0072),modelIdx); return vec3(); } @@ -2757,10 +2757,10 @@ void Bsp::write(const std::string& path) std::ofstream file(path + ".bak", std::ios::trunc | std::ios::binary); if (!file.is_open()) { - logf(get_localized_string(LANG_0073),path); + print_log(get_localized_string(LANG_0073),path); return; } - logf(get_localized_string(LANG_0074),path + ".bak"); + print_log(get_localized_string(LANG_0074),path + ".bak"); file.write(oldfile, len); delete[] oldfile; @@ -2769,7 +2769,7 @@ void Bsp::write(const std::string& path) std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { - logf(get_localized_string(LANG_0075),path); + print_log(get_localized_string(LANG_0075),path); return; } @@ -3002,11 +3002,11 @@ void Bsp::write(const std::string& path) if (ents.size() && ents[0]->hasKey("CRC")) { originCrc32 = reverse_bits(std::stoul(ents[0]->keyvalues["CRC"])); - logf("SPOOFING CRC value.\nLoading original CRC key from WORLDSPAWN: {}. ", + print_log("SPOOFING CRC value.\nLoading original CRC key from WORLDSPAWN: {}. ", reverse_bits(originCrc32)); } else - logf(get_localized_string(LANG_0076),reverse_bits(originCrc32)); + print_log(get_localized_string(LANG_0076),reverse_bits(originCrc32)); unsigned int crc32 = UINT32_C(0xFFFFFFFF); @@ -3016,11 +3016,11 @@ void Bsp::write(const std::string& path) crc32 = GetCrc32InMemory(lumps[i], bsp_header.lump[i].nLength, crc32); } - logf(get_localized_string(LANG_0077),reverse_bits(crc32)); + print_log(get_localized_string(LANG_0077),reverse_bits(crc32)); if (originCrc32 == crc32) { - logf(get_localized_string(LANG_0078)); + print_log(get_localized_string(LANG_0078)); } else { @@ -3059,11 +3059,11 @@ void Bsp::write(const std::string& path) crc32 = GetCrc32InMemory(lumps[i], bsp_header.lump[i].nLength, crc32); } - logf(get_localized_string(LANG_0079),reverse_bits(crc32)); + print_log(get_localized_string(LANG_0079),reverse_bits(crc32)); } } - logf(get_localized_string(LANG_0080),bsp_path); + print_log(get_localized_string(LANG_0080),bsp_path); // calculate lump offsets int offset = sizeof(BSPHEADER); @@ -3088,7 +3088,7 @@ void Bsp::write(const std::string& path) delete[] zeropad; } if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0081),i,bsp_header_ex.lump[i].nLength,bsp_header_ex.lump[i].nOffset,padding); + print_log(get_localized_string(LANG_0081),i,bsp_header_ex.lump[i].nLength,bsp_header_ex.lump[i].nOffset,padding); } } @@ -3111,7 +3111,7 @@ void Bsp::write(const std::string& path) } if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0082),i,bsp_header.lump[i].nLength,bsp_header.lump[i].nOffset,padding); + print_log(get_localized_string(LANG_0082),i,bsp_header.lump[i].nLength,bsp_header.lump[i].nOffset,padding); } file.seekp(0); @@ -3213,47 +3213,47 @@ bool Bsp::load_lumps(std::string fpath) fin.read((char*)&bsp_header.nVersion, sizeof(int)); - logf("Bsp version: {}\n", bsp_header.nVersion >= 0 && bsp_header.nVersion <= 100 ? std::to_string(bsp_header.nVersion) + print_log("Bsp version: {}\n", bsp_header.nVersion >= 0 && bsp_header.nVersion <= 100 ? std::to_string(bsp_header.nVersion) : std::string({ ((char*)&bsp_header.nVersion)[0],((char*)&bsp_header.nVersion)[1],((char*)&bsp_header.nVersion)[2],((char*)&bsp_header.nVersion)[3] })); if (bsp_header.nVersion == '2PSB') { is_bsp2 = true; - logf(get_localized_string(LANG_0083)); + print_log(get_localized_string(LANG_0083)); } if (bsp_header.nVersion == 'BSP2') { is_bsp2 = true; is_bsp2_old = true; - logf(get_localized_string(LANG_0084)); + print_log(get_localized_string(LANG_0084)); } if (bsp_header.nVersion == 29) { is_bsp29 = true; - logf(get_localized_string(LANG_0085)); + print_log(get_localized_string(LANG_0085)); } for (int i = 0; i < HEADER_LUMPS; i++) { fin.read((char*)&bsp_header.lump[i], sizeof(BSPLUMP)); if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0086),i,bsp_header.lump[i].nLength,bsp_header.lump[i].nOffset); + print_log(get_localized_string(LANG_0086),i,bsp_header.lump[i].nLength,bsp_header.lump[i].nOffset); } fin.read((char*)&bsp_header_ex.id, sizeof(int)); if (bsp_header_ex.id == 'HSAX' /* XASH */) { - logf(get_localized_string(LANG_0087)); + print_log(get_localized_string(LANG_0087)); is_bsp30ext = true; fin.read((char*)&bsp_header_ex.nVersion, sizeof(int)); int extralumpscount = bsp_header_ex.nVersion <= 3 ? EXTRA_LUMPS_OLD : EXTRA_LUMPS; - logf(get_localized_string(LANG_0088),bsp_header_ex.nVersion,extralumpscount); + print_log(get_localized_string(LANG_0088),bsp_header_ex.nVersion,extralumpscount); extralumps = new unsigned char* [EXTRA_LUMPS]; memset(extralumps, 0, sizeof(unsigned char*) * EXTRA_LUMPS); @@ -3262,7 +3262,7 @@ bool Bsp::load_lumps(std::string fpath) { fin.read((char*)&bsp_header_ex.lump[i], sizeof(BSPLUMP)); if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0089),i,bsp_header_ex.lump[i].nLength,bsp_header_ex.lump[i].nOffset); + print_log(get_localized_string(LANG_0089),i,bsp_header_ex.lump[i].nLength,bsp_header_ex.lump[i].nOffset); } for (int i = 0; i < extralumpscount; i++) @@ -3275,7 +3275,7 @@ bool Bsp::load_lumps(std::string fpath) if (bsp_header_ex.lump[i].nOffset >= size || bsp_header_ex.lump[i].nOffset < 0 || bsp_header_ex.lump[i].nLength < 0) { - logf(get_localized_string(LANG_0090),i); + print_log(get_localized_string(LANG_0090),i); is_bsp30ext = false; break; } @@ -3283,7 +3283,7 @@ bool Bsp::load_lumps(std::string fpath) fin.seekg(bsp_header_ex.lump[i].nOffset); if (fin.eof() || bsp_header_ex.lump[i].nOffset + bsp_header_ex.lump[i].nLength >= size) { - logf(get_localized_string(LANG_1020),i); + print_log(get_localized_string(LANG_1020),i); is_bsp30ext = false; break; } @@ -3311,7 +3311,7 @@ bool Bsp::load_lumps(std::string fpath) fin.seekg(bsp_header.lump[i].nOffset); if (fin.eof()) { - logf(get_localized_string(LANG_0091),i); + print_log(get_localized_string(LANG_0091),i); valid = false; } else @@ -3326,7 +3326,7 @@ bool Bsp::load_lumps(std::string fpath) if (bsp_header.lump[LUMP_PLANES].nLength < sizeof(BSPPLANE) || &lumps[LUMP_PLANES][bsp_header.lump[LUMP_PLANES].nLength - 1] != std::search(&lumps[LUMP_PLANES][0], &lumps[LUMP_PLANES][bsp_header.lump[LUMP_PLANES].nLength - 1], &classnametmp[0], &classnametmp[strlen(classnametmp)])) { - logf(get_localized_string(LANG_0092)); + print_log(get_localized_string(LANG_0092)); is_blue_shift = true; std::swap(bsp_header.lump[LUMP_PLANES], bsp_header.lump[LUMP_ENTITIES]); std::swap(lumps[LUMP_PLANES], lumps[LUMP_ENTITIES]); @@ -3365,7 +3365,7 @@ bool Bsp::load_lumps(std::string fpath) tmpnodes[n].iPlane = nodes16[n].iPlane; tmpnodes[n].nFaces = nodes16[n].nFaces; - /*logf("Face {} child0 {} child0 {} plane {} face {} ", tmpnodes[n].firstFace, tmpnodes[n].iChildren[0], tmpnodes[n].iChildren[1], tmpnodes[n].iPlane + /*print_log("Face {} child0 {} child0 {} plane {} face {} ", tmpnodes[n].firstFace, tmpnodes[n].iChildren[0], tmpnodes[n].iChildren[1], tmpnodes[n].iPlane , tmpnodes[n].nFaces);*/ for (int m = 0; m < 3; m++) @@ -3373,10 +3373,10 @@ bool Bsp::load_lumps(std::string fpath) tmpnodes[n].nMaxs[m] = (float)nodes16[n].nMaxs[m]; tmpnodes[n].nMins[m] = (float)nodes16[n].nMins[m]; - // logf("{} {} ", nodes16[n].nMaxs[m], nodes16[n].nMins[m]); + // print_log("{} {} ", nodes16[n].nMaxs[m], nodes16[n].nMins[m]); } - //logf("\n"); + //print_log("\n"); } delete[] lumps[i]; @@ -3387,7 +3387,7 @@ bool Bsp::load_lumps(std::string fpath) else { nodeCount = bsp_header.lump[i].nLength / sizeof(BSPNODE32); - logf(get_localized_string(LANG_0093)); + print_log(get_localized_string(LANG_0093)); } } else @@ -3406,7 +3406,7 @@ bool Bsp::load_lumps(std::string fpath) tmpnodes[n].iPlane = nodes16[n].iPlane; tmpnodes[n].nFaces = nodes16[n].nFaces; - /*logf("Face {} child0 {} child0 {} plane {} face {} ", tmpnodes[n].firstFace, tmpnodes[n].iChildren[0], tmpnodes[n].iChildren[1], tmpnodes[n].iPlane + /*print_log("Face {} child0 {} child0 {} plane {} face {} ", tmpnodes[n].firstFace, tmpnodes[n].iChildren[0], tmpnodes[n].iChildren[1], tmpnodes[n].iPlane , tmpnodes[n].nFaces);*/ for (int m = 0; m < 3; m++) @@ -3414,10 +3414,10 @@ bool Bsp::load_lumps(std::string fpath) tmpnodes[n].nMaxs[m] = (float)nodes16[n].nMaxs[m]; tmpnodes[n].nMins[m] = (float)nodes16[n].nMins[m]; - // logf("{} {} ", nodes16[n].nMaxs[m], nodes16[n].nMins[m]); + // print_log("{} {} ", nodes16[n].nMaxs[m], nodes16[n].nMins[m]); } - //logf("\n"); + //print_log("\n"); } delete[] lumps[i]; @@ -3435,7 +3435,7 @@ bool Bsp::load_lumps(std::string fpath) { faceCount = bsp_header.lump[i].nLength / sizeof(BSPFACE32); tmpMapFaces = (BSPFACE32*)lumps[i]; - logf(get_localized_string(LANG_0094)); + print_log(get_localized_string(LANG_0094)); } else { @@ -3474,7 +3474,7 @@ bool Bsp::load_lumps(std::string fpath) is_32bit_clipnodes = true; clipnodeCount = bsp_header.lump[i].nLength / sizeof(BSPCLIPNODE32); - logf(get_localized_string(LANG_0095)); + print_log(get_localized_string(LANG_0095)); } else { @@ -3502,11 +3502,11 @@ bool Bsp::load_lumps(std::string fpath) if (is_broken_clipnodes) { - logf(get_localized_string(LANG_0096)); + print_log(get_localized_string(LANG_0096)); } else { - logf(get_localized_string(LANG_0097)); + print_log(get_localized_string(LANG_0097)); } if (is_broken_clipnodes) @@ -3546,7 +3546,7 @@ bool Bsp::load_lumps(std::string fpath) if (!is_bsp2_old) { leafCount = bsp_header.lump[i].nLength / sizeof(BSPLEAF32); - logf(get_localized_string(LANG_0098)); + print_log(get_localized_string(LANG_0098)); } else { @@ -3571,7 +3571,7 @@ bool Bsp::load_lumps(std::string fpath) tmpleaves[n].nMins[m] = (float)leaves16[n].nMins[m]; } - //logf("Leaf iFirstMarkSurface {} nMarkSurfaces {} nContents {} nVisOffset {} \n", + //print_log("Leaf iFirstMarkSurface {} nMarkSurfaces {} nContents {} nVisOffset {} \n", // tmpleaves[n].iFirstMarkSurface, tmpleaves[n].nMarkSurfaces, tmpleaves[n].nContents, tmpleaves[n].nVisOffset); } @@ -3616,7 +3616,7 @@ bool Bsp::load_lumps(std::string fpath) if (is_bsp2) { marksurfCount = bsp_header.lump[i].nLength / sizeof(int); - logf(get_localized_string(LANG_0099)); + print_log(get_localized_string(LANG_0099)); } else { @@ -3642,7 +3642,7 @@ bool Bsp::load_lumps(std::string fpath) if (is_bsp2) { edgeCount = bsp_header.lump[i].nLength / sizeof(BSPEDGE32); - logf(get_localized_string(LANG_0100)); + print_log(get_localized_string(LANG_0100)); } else { @@ -3698,7 +3698,7 @@ bool Bsp::load_lumps(std::string fpath) } float fLightSamples = is_bsp2 || is_bsp2_old || is_bsp29 ? 1.0f : 3.0f; - //logf("{} {} {} -> {}\n", is_bsp2, is_bsp2_old, is_bsp29, fLightSamples); + //print_log("{} {} {} -> {}\n", is_bsp2, is_bsp2_old, is_bsp29, fLightSamples); if (fLightSamples < 3.0 && iNextFace >= 0 && iFirstFace >= 0 && iFirstFace != iNextFace) { float face1light = GetFaceLightmapSizeBytes(this, iFirstFace) / (float)sizeof(COLOR3); @@ -3715,7 +3715,7 @@ bool Bsp::load_lumps(std::string fpath) fLightSamples = memsize / face2light; } - //logf(get_localized_string(LANG_0101),fLightSamples,memsize,face1light,face2light); + //print_log(get_localized_string(LANG_0101),fLightSamples,memsize,face1light,face2light); if (abs(fLightSamples - (int)fLightSamples) > 0.01f) { @@ -3728,7 +3728,7 @@ bool Bsp::load_lumps(std::string fpath) { fLightSamples = memsize / face2light; } - //logf(get_localized_string(LANG_1021),fLightSamples,memsize,face1light,face2light); + //print_log(get_localized_string(LANG_1021),fLightSamples,memsize,face1light,face2light); } } @@ -3739,7 +3739,7 @@ bool Bsp::load_lumps(std::string fpath) is_colored_lightmap = tmp_is_colored_lightmap > 1; if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0102),!is_colored_lightmap ? "monochrome" : "colored"); + print_log(get_localized_string(LANG_0102),!is_colored_lightmap ? "monochrome" : "colored"); if (!is_colored_lightmap) { @@ -3802,7 +3802,7 @@ void Bsp::load_ents() { if (lastBracket == 0) { - logf(get_localized_string(LANG_0103),bsp_path,lineNum); + print_log(get_localized_string(LANG_0103),bsp_path,lineNum); continue; } lastBracket = 0; @@ -3819,7 +3819,7 @@ void Bsp::load_ents() if (line[0] == '}') { if (lastBracket == 1) - logf(get_localized_string(LANG_0104),bsp_path,lineNum); + print_log(get_localized_string(LANG_0104),bsp_path,lineNum); lastBracket = 1; if (!ent) continue; @@ -3827,7 +3827,7 @@ void Bsp::load_ents() if (ent->keyvalues.count("classname")) ents.push_back(ent); else - logf(get_localized_string(LANG_0105)); + print_log(get_localized_string(LANG_0105)); ent = NULL; @@ -3859,7 +3859,7 @@ void Bsp::load_ents() if (ent->keyvalues.count("classname")) ents.push_back(ent); else - logf(get_localized_string(LANG_1022)); + print_log(get_localized_string(LANG_1022)); ent = NULL; } if (line.find('{') != std::string::npos) @@ -3874,7 +3874,7 @@ void Bsp::load_ents() { if (ents[0]->keyvalues["classname"] != "worldspawn") { - logf(get_localized_string(LANG_0106)); + print_log(get_localized_string(LANG_0106)); for (int i = 1; i < ents.size(); i++) { if (ents[i]->keyvalues["classname"] == "worldspawn") @@ -3895,42 +3895,50 @@ void Bsp::print_stat(const std::string& name, unsigned int val, unsigned int max const float meg = 1024 * 1024; float percent = (val / (float)max) * 100; - if (val > max) + set_console_colors(); + + + print_log(get_localized_string(LANG_0107),name); + + + if (isMem) { - print_color(PRINT_RED | PRINT_BRIGHT); + print_log("{:8.2f} /{:>7.2f}MB", val / meg, max / meg); } - else if (percent >= 90) + else { - print_color(PRINT_RED | PRINT_GREEN | PRINT_BRIGHT); + print_log("{:8} / {:>8}", val, max); } - else if (percent >= 75) + + + + if (val > max) { - print_color(PRINT_RED | PRINT_GREEN | PRINT_BLUE | PRINT_BRIGHT); + set_console_colors(PRINT_RED | PRINT_INTENSITY); } - else + else if (percent >= 90) { - print_color(PRINT_RED | PRINT_GREEN | PRINT_BLUE); + set_console_colors(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY); } - - logf(get_localized_string(LANG_0107),name); - if (isMem) + else if (percent >= 75) { - logf("{:8.2f} /{:5.2f} MB", val / meg, max / meg); + set_console_colors(PRINT_RED | PRINT_GREEN | PRINT_BLUE | PRINT_INTENSITY); } else { - logf("{:8} / {:>8}", val, max); + set_console_colors(PRINT_GREEN); } - logf(" {:6.1f}%", percent); + print_log(" {:6.1f}%", percent); + + set_console_colors(); if (val > max) { - logf(get_localized_string(LANG_0108)); + print_log(get_localized_string(LANG_0108)); } - logf("\n"); + print_log("\n"); - print_color(PRINT_RED | PRINT_GREEN | PRINT_BLUE); } void Bsp::print_model_stat(STRUCTUSAGE* modelInfo, unsigned int val, int max, bool isMem) @@ -3951,16 +3959,16 @@ void Bsp::print_model_stat(STRUCTUSAGE* modelInfo, unsigned int val, int max, bo if (isMem) { - logf("{:8.1f} / {:-5.1f} MB", val / meg, max / meg); + print_log("{:8.1f} / {:>5.1f}", val / meg, max / meg); } else { - logf(get_localized_string(LANG_0109),classname,targetname,modelInfo->modelIdx,val); + print_log(get_localized_string(LANG_0109),classname,targetname,modelInfo->modelIdx,val); } if (percent >= 0.1f) - logf(" {:6.1f}%", percent); + print_log(" {:6.1f}%", percent); - logf("\n"); + print_log("\n"); } bool sortModelInfos(const STRUCTUSAGE* a, const STRUCTUSAGE* b) @@ -4006,7 +4014,7 @@ bool Bsp::validate() { if (marksurfs[i] >= faceCount) { - logf(get_localized_string(LANG_0110),i,marksurfs[i],faceCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0110),i,marksurfs[i],faceCount); isValid = false; } } @@ -4014,7 +4022,7 @@ bool Bsp::validate() { if (abs(surfedges[i]) >= edgeCount) { - logf(get_localized_string(LANG_0111),i,surfedges[i],edgeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0111),i,surfedges[i],edgeCount); isValid = false; } } @@ -4022,7 +4030,7 @@ bool Bsp::validate() { if (texinfos[i].iMiptex >= textureCount) { - logf(get_localized_string(LANG_0112),i,texinfos[i].iMiptex,textureCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0112),i,texinfos[i].iMiptex,textureCount); isValid = false; } } @@ -4030,23 +4038,23 @@ bool Bsp::validate() { if (faces[i].iPlane >= planeCount) { - logf(get_localized_string(LANG_0113),i,faces[i].iPlane,planeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0113),i,faces[i].iPlane,planeCount); isValid = false; } if (faces[i].nEdges > 0 && faces[i].iFirstEdge >= surfedgeCount) { - logf(get_localized_string(LANG_0114),i,faces[i].iFirstEdge,surfedgeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0114),i,faces[i].iFirstEdge,surfedgeCount); isValid = false; } if (faces[i].iTextureInfo >= texinfoCount) { - logf(get_localized_string(LANG_0115),i,faces[i].iTextureInfo,texinfoCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0115),i,faces[i].iTextureInfo,texinfoCount); isValid = false; } if (lightDataLength > 0 && faces[i].nLightmapOffset >= 0 && faces[i].nLightmapOffset > lightDataLength) { - logf(get_localized_string(LANG_0116),i,faces[i].nLightmapOffset,lightDataLength); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0116),i,faces[i].nLightmapOffset,lightDataLength); isValid = false; } int bmins[2]; @@ -4058,13 +4066,13 @@ bool Bsp::validate() { if (leaves[i].nMarkSurfaces > 0 && leaves[i].iFirstMarkSurface >= marksurfCount) { - logf(get_localized_string(LANG_0117),i,leaves[i].iFirstMarkSurface,marksurfCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0117),i,leaves[i].iFirstMarkSurface,marksurfCount); isValid = false; } if (visDataLength > 0 && leaves[i].nVisOffset != -1 && (leaves[i].nVisOffset < 0 || leaves[i].nVisOffset >= visDataLength)) { - logf(get_localized_string(LANG_0118),i,leaves[i].nVisOffset,visDataLength); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0118),i,leaves[i].nVisOffset,visDataLength); isValid = false; } @@ -4072,7 +4080,7 @@ bool Bsp::validate() { if (leaves[i].nMins[n] > leaves[i].nMaxs[n]) { - logf("backwards mins / maxs in leaf {} Mins: ({}, {}, {}) Maxs: ({} {} {})", i, leaves[i].nMins[0], leaves[i].nMins[1], leaves[i].nMins[2], + print_log(PRINT_RED | PRINT_INTENSITY, "backwards mins / maxs in leaf {} Mins: ({}, {}, {}) Maxs: ({} {} {})", i, leaves[i].nMins[0], leaves[i].nMins[1], leaves[i].nMins[2], leaves[i].nMaxs[0], leaves[i].nMaxs[1], leaves[i].nMaxs[2]); isValid = false; } @@ -4084,7 +4092,7 @@ bool Bsp::validate() { if (edges[i].iVertex[k] >= vertCount) { - logf(get_localized_string(LANG_0119),i,edges[i].iVertex[k],vertCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0119),i,edges[i].iVertex[k],vertCount); isValid = false; } } @@ -4093,24 +4101,24 @@ bool Bsp::validate() { if (nodes[i].nFaces > 0 && nodes[i].firstFace >= faceCount) { - logf(get_localized_string(LANG_0120),i,nodes[i].firstFace,faceCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0120),i,nodes[i].firstFace,faceCount); isValid = false; } if (nodes[i].iPlane >= planeCount) { - logf(get_localized_string(LANG_0121),i,nodes[i].iPlane,planeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0121),i,nodes[i].iPlane,planeCount); isValid = false; } for (int k = 0; k < 2; k++) { if (nodes[i].iChildren[k] != -1 && nodes[i].iChildren[k] > 0 && nodes[i].iChildren[k] >= nodeCount) { - logf(get_localized_string(LANG_0122),i,k,nodes[i].iChildren[k],nodeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0122),i,k,nodes[i].iChildren[k],nodeCount); isValid = false; } else if (~nodes[i].iChildren[k] != -1 && nodes[i].iChildren[k] < 0 && ~nodes[i].iChildren[k] >= leafCount) { - logf(get_localized_string(LANG_0123),i,k,~nodes[i].iChildren[k],leafCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0123),i,k,~nodes[i].iChildren[k],leafCount); isValid = false; } } @@ -4119,14 +4127,14 @@ bool Bsp::validate() { if (clipnodes[i].iPlane < 0 || clipnodes[i].iPlane >= planeCount) { - logf(get_localized_string(LANG_0124),i,clipnodes[i].iPlane,planeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0124),i,clipnodes[i].iPlane,planeCount); isValid = false; } for (int k = 0; k < 2; k++) { if (clipnodes[i].iChildren[k] > 0 && clipnodes[i].iChildren[k] >= clipnodeCount) { - logf(get_localized_string(LANG_0125),i,k,clipnodes[i].iChildren[k],clipnodeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0125),i,k,clipnodes[i].iChildren[k],clipnodeCount); isValid = false; } } @@ -4135,7 +4143,7 @@ bool Bsp::validate() { if (ents[i]->getBspModelIdxForce() > 0 && ents[i]->getBspModelIdxForce() >= modelCount) { - logf(get_localized_string(LANG_0126),i,ents[i]->getBspModelIdxForce(),modelCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0126),i,ents[i]->getBspModelIdxForce(),modelCount); isValid = false; } } @@ -4149,19 +4157,19 @@ bool Bsp::validate() totalFaces += models[i].nFaces; if (models[i].nFaces > 0 && (models[i].iFirstFace < 0 || models[i].iFirstFace >= faceCount)) { - logf(get_localized_string(LANG_0127),i,models[i].iFirstFace,faceCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0127),i,models[i].iFirstFace,faceCount); isValid = false; } if (models[i].iHeadnodes[0] >= nodeCount) { - logf(get_localized_string(LANG_0128),i,models[i].iHeadnodes[0],nodeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0128),i,models[i].iHeadnodes[0],nodeCount); isValid = false; } for (int k = 1; k < MAX_MAP_HULLS; k++) { if (models[i].iHeadnodes[k] >= clipnodeCount) { - logf(get_localized_string(LANG_0129),i,k,models[i].iHeadnodes[k],clipnodeCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0129),i,k,models[i].iHeadnodes[k],clipnodeCount); isValid = false; } } @@ -4169,7 +4177,7 @@ bool Bsp::validate() models[i].nMins.y > models[i].nMaxs.y || models[i].nMins.z > models[i].nMaxs.z) { - logf("Backwards mins/maxs in model {}. Mins: ({}, {}, {}) Maxs: ({} {} {})\n", i, + print_log("Backwards mins/maxs in model {}. Mins: ({}, {}, {}) Maxs: ({} {} {})\n", i, models[i].nMins.x, models[i].nMins.y, models[i].nMins.z, models[i].nMaxs.x, models[i].nMaxs.y, models[i].nMaxs.z); isValid = false; @@ -4177,13 +4185,13 @@ bool Bsp::validate() } if (totalVisLeaves != leafCount) { - logf(get_localized_string(LANG_0130),totalVisLeaves,leafCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0130),totalVisLeaves,leafCount); isValid = false; } if (totalFaces > faceCount) { - logf(get_localized_string(LANG_0131),totalFaces,faceCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0131),totalFaces,faceCount); isValid = false; } @@ -4197,7 +4205,7 @@ bool Bsp::validate() } if (worldspawn_count != 1) { - logf(get_localized_string(LANG_0132),worldspawn_count,ents.size()); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0132),worldspawn_count,ents.size()); isValid = false; } @@ -4220,7 +4228,7 @@ bool Bsp::validate() { if (!used_models.count(i)) { - logf(get_localized_string(LANG_1023),bsp_name,i); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1023),bsp_name,i); } } @@ -4234,16 +4242,16 @@ bool Bsp::validate() BSPMIPTEX* tex = (BSPMIPTEX*)(textures + texOffset); if (tex->szName[0] == '\0') { - logf(get_localized_string(LANG_0133),i); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0133),i); } else if (strlen(tex->szName) >= MAXTEXTURENAME) { - logf(get_localized_string(LANG_0134),i); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0134),i); } if (tex->nOffsets[0] > 0 && dataOffset + texOffset + texlen > bsp_header.lump[LUMP_TEXTURES].nLength) { - logf(get_localized_string(LANG_0135),i,dataOffset + texOffset + texlen,bsp_header.lump[LUMP_TEXTURES].nLength); - logf(get_localized_string(LANG_0136),i,tex->szName[0] != '\0' ? tex->szName : "UNKNOWN_NAME",texOffset,dataOffset); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0135),i,dataOffset + texOffset + texlen,bsp_header.lump[LUMP_TEXTURES].nLength); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0136),i,tex->szName[0] != '\0' ? tex->szName : "UNKNOWN_NAME",texOffset,dataOffset); } } } @@ -4284,7 +4292,7 @@ void Bsp::print_info(bool perModelStats, int perModelLimit, int sortMode) surfedgeCount >= (is_bsp2 ? INT_MAX : (int)MAX_MAP_SURFEDGES) || (is_bsp2 ? INT_MAX : edgeCount >= (int)MAX_MAP_EDGES) || textureCount >= (int)MAX_MAP_TEXTURES || lightDataLength >= (int)MAX_MAP_LIGHTDATA || visDataLength >= (int)MAX_MAP_VISDATA) { - logf(get_localized_string(LANG_0137)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0137)); return; } @@ -4301,8 +4309,8 @@ void Bsp::print_info(bool perModelStats, int perModelLimit, int sortMode) case SORT_FACES: maxCount = faceCount; countName = " Faces"; break; } - logf(get_localized_string(LANG_0138),countName); - logf("------------------------- ------------------------- ----- ---------- --------\n"); + print_log(get_localized_string(LANG_0138),countName); + print_log("------------------------- ------------------------- ----- ---------- --------\n"); for (int i = 0; i < modelCount && i < perModelLimit; i++) { @@ -4324,8 +4332,8 @@ void Bsp::print_info(bool perModelStats, int perModelLimit, int sortMode) } else { - logf(get_localized_string(LANG_0139)); - logf("------------ ------------------- --------\n"); + print_log(get_localized_string(LANG_0139)); + print_log("------------ ------------------- --------\n"); print_stat("models", modelCount, MAX_MAP_MODELS, false); print_stat("planes", planeCount, (is_bsp2 ? INT_MAX : MAX_MAP_PLANES), false); print_stat("vertexes", vertCount, MAX_MAP_VERTS, false); @@ -4354,19 +4362,19 @@ void Bsp::print_clipnode_tree(int iNode, int depth) { for (int i = 0; i < depth; i++) { - logf(" "); + print_log(" "); } if (iNode < 0) { - logf(getLeafContentsName(iNode)); - logf("\n"); + print_log(getLeafContentsName(iNode)); + print_log("\n"); return; } else { BSPPLANE& plane = planes[clipnodes[iNode].iPlane]; - logf(get_localized_string(LANG_0140),plane.vNormal.x,plane.vNormal.y,plane.vNormal.z,plane.fDist); + print_log(get_localized_string(LANG_0140),plane.vNormal.x,plane.vNormal.y,plane.vNormal.z,plane.fDist); } @@ -4380,20 +4388,20 @@ void Bsp::print_model_hull(int modelIdx, int hull_number) { if (modelIdx < 0 || modelIdx > bsp_header.lump[LUMP_MODELS].nLength / sizeof(BSPMODEL)) { - logf(get_localized_string(LANG_1024),modelIdx); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1024),modelIdx); return; } // the first hull is used for point-sized clipping, but uses nodes and not clipnodes. if (hull_number < 0 || hull_number >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_0141),MAX_MAP_HULLS); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0141),MAX_MAP_HULLS); return; } BSPMODEL& model = models[modelIdx]; - logf(get_localized_string(LANG_0142),modelIdx,hull_number,get_model_usage(modelIdx)); + print_log(get_localized_string(LANG_0142),modelIdx,hull_number,get_model_usage(modelIdx)); if (hull_number == 0) print_model_bsp(modelIdx); @@ -4443,20 +4451,19 @@ void Bsp::recurse_node(int nodeIdx, int depth) { for (int i = 0; i < depth; i++) { - logf(" "); + print_log(" "); } if (nodeIdx < 0) { BSPLEAF32& leaf = leaves[~nodeIdx]; print_leaf(leaf); - logf(get_localized_string(LANG_0143),~nodeIdx); + print_log(get_localized_string(LANG_0143),~nodeIdx); return; } else { print_node(nodes[nodeIdx]); - logf("\n"); } recurse_node(nodes[nodeIdx].iChildren[0], depth + 1); @@ -4467,7 +4474,7 @@ void Bsp::print_node(const BSPNODE32& node) { BSPPLANE& plane = planes[node.iPlane]; - logf("Plane ({} {} {}) d: {}, Faces: {}, Min({}, {}, {}), Max({}, {}, {})", + print_log("Plane ({} {} {}) d: {}, Faces: {}, Min({}, {}, {}), Max({}, {}, {})\n", plane.vNormal.x, plane.vNormal.y, plane.vNormal.z, plane.fDist, node.nFaces, node.nMins[0], node.nMins[1], node.nMins[2], @@ -4581,7 +4588,7 @@ void Bsp::mark_face_structures(int iFace, STRUCTUSAGE* usage) { if (iFace > faceCount) { - logf(get_localized_string(LANG_0144)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0144)); return; } BSPFACE32& face = faces[iFace]; @@ -4607,7 +4614,7 @@ void Bsp::mark_node_structures(int iNode, STRUCTUSAGE* usage, bool skipLeaves) { if (iNode > nodeCount) { - logf(get_localized_string(LANG_0145)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0145)); return; } BSPNODE32& node = nodes[iNode]; @@ -4644,7 +4651,7 @@ void Bsp::mark_clipnode_structures(int iNode, STRUCTUSAGE* usage) { if (iNode > clipnodeCount) { - logf(get_localized_string(LANG_0146)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0146)); return; } BSPCLIPNODE32& node = clipnodes[iNode]; @@ -4665,7 +4672,7 @@ void Bsp::mark_model_structures(int modelIdx, STRUCTUSAGE* usage, bool skipLeave { if (modelIdx > modelCount) { - logf(get_localized_string(LANG_0147)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0147)); return; } BSPMODEL& model = models[modelIdx]; @@ -4690,7 +4697,7 @@ void Bsp::remap_face_structures(int faceIdx, STRUCTREMAP* remap) { if (faceIdx > faceCount) { - logf(get_localized_string(LANG_0148)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0148)); return; } if (remap->visitedFaces[faceIdx]) @@ -4703,8 +4710,8 @@ void Bsp::remap_face_structures(int faceIdx, STRUCTREMAP* remap) face.iPlane = remap->planes[face.iPlane]; face.iTextureInfo = remap->texInfo[face.iTextureInfo]; - //logf(get_localized_string(LANG_0149),faceIdx,face.iFirstEdge,remap->surfEdges[face.iFirstEdge]); - //logf(get_localized_string(LANG_1025),faceIdx,face.iTextureInfo,remap->texInfo[face.iTextureInfo]); + //print_log(get_localized_string(LANG_0149),faceIdx,face.iFirstEdge,remap->surfEdges[face.iFirstEdge]); + //print_log(get_localized_string(LANG_1025),faceIdx,face.iTextureInfo,remap->texInfo[face.iTextureInfo]); //face.iFirstEdge = remap->surfEdges[face.iFirstEdge]; } @@ -4712,7 +4719,7 @@ void Bsp::remap_node_structures(int iNode, STRUCTREMAP* remap) { if (iNode > nodeCount) { - logf(get_localized_string(LANG_1026)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1026)); return; } BSPNODE32& node = nodes[iNode]; @@ -4743,7 +4750,7 @@ void Bsp::remap_clipnode_structures(int iNode, STRUCTREMAP* remap) { if (iNode > clipnodeCount) { - logf(get_localized_string(LANG_1027)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1027)); return; } BSPCLIPNODE32& node = clipnodes[iNode]; @@ -4770,7 +4777,7 @@ void Bsp::remap_model_structures(int modelIdx, STRUCTREMAP* remap) { if (modelIdx > modelCount) { - logf(get_localized_string(LANG_1028)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1028)); return; } BSPMODEL& model = ((BSPMODEL*)lumps[LUMP_MODELS])[modelIdx]; @@ -4804,7 +4811,7 @@ void Bsp::delete_hull(int hull_number, int redirect) { if (hull_number < 0 || hull_number >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_0150),MAX_MAP_HULLS); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0150),MAX_MAP_HULLS); return; } @@ -4818,26 +4825,26 @@ void Bsp::delete_hull(int hull_number, int modelIdx, int redirect) { if (modelIdx < 0 || modelIdx >= modelCount) { - logf(get_localized_string(LANG_0151),modelIdx); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0151),modelIdx); return; } // the first hull is used for point-sized clipping, but uses nodes and not clipnodes. if (hull_number < 0 || hull_number >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_1029),MAX_MAP_HULLS); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1029),MAX_MAP_HULLS); return; } if (redirect >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_0152),MAX_MAP_HULLS); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0152),MAX_MAP_HULLS); return; } if (hull_number == 0 && redirect > 0) { - logf(get_localized_string(LANG_0153),MAX_MAP_HULLS); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0153),MAX_MAP_HULLS); return; } @@ -4854,11 +4861,11 @@ void Bsp::delete_hull(int hull_number, int modelIdx, int redirect) { if (model.iHeadnodes[hull_number] > 0 && model.iHeadnodes[redirect] < 0) { - //logf(get_localized_string(LANG_0154),redirect); + //print_log(get_localized_string(LANG_0154),redirect); } else if (model.iHeadnodes[hull_number] == model.iHeadnodes[redirect]) { - //logf(get_localized_string(LANG_0155),hull_number,redirect); + //print_log(get_localized_string(LANG_0155),hull_number,redirect); } model.iHeadnodes[hull_number] = model.iHeadnodes[redirect]; } @@ -4932,7 +4939,7 @@ void Bsp::add_model(Bsp* sourceMap, int modelIdx) usage.compute_sum(); - logf(""); + print_log(""); } BSPMIPTEX* Bsp::find_embedded_texture(const char* name, int& texid) @@ -4979,24 +4986,24 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he { if (!oldname || oldname[0] == '\0' || strlen(oldname) >= MAXTEXTURENAME) { - logf(get_localized_string(LANG_0156)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0156)); return -1; } char name[MAXTEXTURENAME]; memset(name, 0, MAXTEXTURENAME); memcpy(name, oldname, std::min(MAXTEXTURENAME, (int)strlen(oldname))); - logf(get_localized_string(LANG_0157),!data ? "embedded" : "wad",name,width,height); + print_log(get_localized_string(LANG_0157),!data ? "embedded" : "wad",name,width,height); if (width % 16 != 0 || height % 16 != 0) { - logf(get_localized_string(LANG_0158)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0158)); return -1; } if (width > (int)MAX_TEXTURE_DIMENSION || height > (int)MAX_TEXTURE_DIMENSION) { - logf(get_localized_string(LANG_0159)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0159)); return -1; } @@ -5008,12 +5015,12 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he // internal, with data if (oldtex) { - logf(get_localized_string(LANG_0160),name); + print_log(get_localized_string(LANG_0160),name); if (oldtex->nWidth != width || oldtex->nHeight != height) { if (!data) { - logf(get_localized_string(LANG_0161)); + print_log(get_localized_string(LANG_0161)); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; oldtex->nWidth = width; @@ -5025,7 +5032,7 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he else { oldtex->szName[0] = '\0'; - logf("Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", + print_log(PRINT_RED | PRINT_GREEN, "Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", oldtex->nWidth, oldtex->nHeight, width, height); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; @@ -5034,11 +5041,11 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he else if (data) { only_copy_data = true; - logf(get_localized_string(LANG_0162)); + print_log(get_localized_string(LANG_0162)); } else { - logf(get_localized_string(LANG_0163)); + print_log(get_localized_string(LANG_0163)); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; @@ -5054,12 +5061,12 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he // external without data if (oldtex) { - logf(get_localized_string(LANG_0164),name); + print_log(get_localized_string(LANG_0164),name); if (oldtex->nWidth != width || oldtex->nHeight != height) { if (!data) { - logf("Same wad texture with size different {}x{} > {}x{} found in map.\nJust update size and return index.\n", + print_log("Same wad texture with size different {}x{} > {}x{} found in map.\nJust update size and return index.\n", oldtex->nWidth, oldtex->nHeight, width, height); oldtex->nWidth = width; @@ -5069,7 +5076,7 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he else { oldtex->szName[0] = '\0'; - logf("Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", + print_log(PRINT_RED | PRINT_GREEN, "Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", oldtex->nWidth, oldtex->nHeight, width, height); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; @@ -5077,7 +5084,7 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he } else if (!data) { - logf(get_localized_string(LANG_0165)); + print_log(get_localized_string(LANG_0165)); return oldtexid; } else @@ -5085,7 +5092,7 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; oldtex->szName[0] = '\0'; - logf(get_localized_string(LANG_0166)); + print_log(get_localized_string(LANG_0166)); } } } @@ -5153,7 +5160,7 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he { if (colorCount >= 256) { - logf(get_localized_string(LANG_0167)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0167)); delete[] mip[0]; return -1; } @@ -5320,18 +5327,18 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he int Bsp::add_texture(WADTEX* tex) { - //logf(get_localized_string(LANG_0168),tex->szName,tex->nWidth,tex->nHeight,tex->nOffsets[0],tex->nOffsets[1],tex->nOffsets[2],tex->nOffsets[3]); - logf(get_localized_string(LANG_0169),tex->szName,tex->nWidth,tex->nHeight); + //print_log(get_localized_string(LANG_0168),tex->szName,tex->nWidth,tex->nHeight,tex->nOffsets[0],tex->nOffsets[1],tex->nOffsets[2],tex->nOffsets[3]); + print_log(get_localized_string(LANG_0169),tex->szName,tex->nWidth,tex->nHeight); if (tex->nWidth % 16 != 0 || tex->nHeight % 16 != 0) { - logf(get_localized_string(LANG_1030)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1030)); return -1; } if (tex->nWidth > (int)MAX_TEXTURE_DIMENSION || tex->nHeight > (int)MAX_TEXTURE_DIMENSION) { - logf(get_localized_string(LANG_1031)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1031)); return -1; } @@ -5342,11 +5349,11 @@ int Bsp::add_texture(WADTEX* tex) if (oldtex) { - logf(get_localized_string(LANG_1032),tex->szName); + print_log(get_localized_string(LANG_1032),tex->szName); if (oldtex->nWidth != tex->nWidth || oldtex->nHeight != tex->nHeight) { oldtex->szName[0] = '\0'; - logf("Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", + print_log(PRINT_RED | PRINT_GREEN, "Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", oldtex->nWidth, oldtex->nHeight, tex->nWidth, tex->nHeight); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; @@ -5354,7 +5361,7 @@ int Bsp::add_texture(WADTEX* tex) else { only_copy_data = true; - logf(get_localized_string(LANG_1033)); + print_log(get_localized_string(LANG_1033)); } } else @@ -5365,10 +5372,10 @@ int Bsp::add_texture(WADTEX* tex) // external without data if (oldtex) { - logf(get_localized_string(LANG_1034),tex->szName); + print_log(get_localized_string(LANG_1034),tex->szName); if (oldtex->nWidth != tex->nWidth || oldtex->nHeight != tex->nHeight) { - logf("Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", + print_log(PRINT_RED | PRINT_GREEN, "Warning! Texture size different {}x{} > {}x{}.\nRenaming old texture and create new one.\n", oldtex->nWidth, oldtex->nHeight, tex->nWidth, tex->nHeight); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; @@ -5376,7 +5383,7 @@ int Bsp::add_texture(WADTEX* tex) } else { - logf(get_localized_string(LANG_1035)); + print_log(get_localized_string(LANG_1035)); oldtex->nOffsets[0] = oldtex->nOffsets[1] = oldtex->nOffsets[2] = oldtex->nOffsets[3] = 0; oldtex->szName[0] = '\0'; @@ -5413,7 +5420,7 @@ int Bsp::add_texture(WADTEX* tex) } if (tex_usage > 0) { - logf(get_localized_string(LANG_0170),tex_usage); + print_log(get_localized_string(LANG_0170),tex_usage); } } @@ -5978,12 +5985,12 @@ void Bsp::simplify_model_collision(int modelIdx, int hullIdx) { if (modelIdx < 0 || modelIdx >= modelCount) { - logf(get_localized_string(LANG_1036),modelIdx); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1036),modelIdx); return; } if (hullIdx >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_1146),MAX_MAP_HULLS); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1146),MAX_MAP_HULLS); return; } @@ -5991,19 +5998,19 @@ void Bsp::simplify_model_collision(int modelIdx, int hullIdx) if (model.iHeadnodes[1] < 0 && model.iHeadnodes[2] < 0 && model.iHeadnodes[3] < 0) { - logf(get_localized_string(LANG_0171)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0171)); return; } if (hullIdx > 0 && model.iHeadnodes[hullIdx] < 0) { - logf(get_localized_string(LANG_0172),hullIdx); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0172),hullIdx); return; } if (model.iHeadnodes[0] < 0) { - logf(get_localized_string(LANG_0173)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0173)); // TODO: create verts from plane intersections return; } @@ -6277,7 +6284,7 @@ BSPTEXTUREINFO* Bsp::get_unique_texinfo(int faceIdx) texinfos[newInfo] = texinfos[targetInfo]; targetInfo = newInfo; targetFace.iTextureInfo = newInfo; - logf(get_localized_string(LANG_0174),newInfo); + print_log(get_localized_string(LANG_0174),newInfo); break; } } @@ -6373,7 +6380,7 @@ int Bsp::regenerate_clipnodes_from_nodes(int iNode, int hullIdx) { if (solidContents != CONTENTS_SOLID) { - logf(get_localized_string(LANG_0175),solidContents); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0175),solidContents); } // solidContents or CONTENTS_SOLID? return CONTENTS_SOLID; @@ -6496,7 +6503,7 @@ void Bsp::write_csg_outputs(const std::string& path) }; pln_file.write((char*)&csgplane, sizeof(CSGPLANE)); } - logf(get_localized_string(LANG_0176),numPlanes); + print_log(get_localized_string(LANG_0176),numPlanes); BSPMODEL* tmodels = (BSPMODEL*)lumps[LUMP_MODELS]; BSPMODEL world = tmodels[0]; @@ -6541,7 +6548,7 @@ void Bsp::write_csg_outputs(const std::string& path) if (i == LUMP_PLANES) { int count = bsp_header.lump[i].nLength / sizeof(BSPPLANE); - logf(get_localized_string(LANG_0177),count); + print_log(get_localized_string(LANG_0177),count); } } else @@ -6589,12 +6596,12 @@ void Bsp::write_csg_polys(int nodeIdx, FILE* polyfile, int flipPlaneSkip, bool d if (debug) { BSPPLANE plane = planes[iPlane]; - logf("Writing face ({:2.0f} {:2.0f} {:2.0f}) {:4.0f} {}\n", + print_log("Writing face ({:2.0f} {:2.0f} {:2.0f}) {:4.0f} {}\n", plane.vNormal.x, plane.vNormal.y, plane.vNormal.z, plane.fDist, (faceContents == CONTENTS_SOLID ? "SOLID" : "EMPTY")); if (flipped && false) { - logf(get_localized_string(LANG_0178)); + print_log(get_localized_string(LANG_0178)); } } @@ -6624,14 +6631,14 @@ void Bsp::write_csg_polys(int nodeIdx, FILE* polyfile, int flipPlaneSkip, bool d fprintf(polyfile, "\n"); } if (debug) - logf("\n"); + print_log("\n"); } } void Bsp::print_leaf(const BSPLEAF32& leaf) { - logf(getLeafContentsName(leaf.nContents)); - logf(" {} surfs, Min({}, {}, {}), Max({} {} {})", leaf.nMarkSurfaces, + print_log(getLeafContentsName(leaf.nContents)); + print_log(" {} surfs, Min({}, {}, {}), Max({} {} {})", leaf.nMarkSurfaces, leaf.nMins[0], leaf.nMins[1], leaf.nMins[2], leaf.nMaxs[0], leaf.nMaxs[1], leaf.nMaxs[2]); } @@ -6670,35 +6677,35 @@ void Bsp::update_lump_pointers() visDataLength = bsp_header.lump[LUMP_VISIBILITY].nLength; if (planeCount > (is_bsp2 ? INT_MAX : MAX_MAP_PLANES)) - logf(get_localized_string(LANG_0179)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0179)); if (texinfoCount > (is_bsp2 ? INT_MAX : MAX_MAP_TEXINFOS)) - logf(get_localized_string(LANG_0180)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0180)); if (leafCount > (is_bsp2 ? INT_MAX : (int)MAX_MAP_LEAVES)) - logf(get_localized_string(LANG_0181)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0181)); if (modelCount > (int)MAX_MAP_MODELS) - logf(get_localized_string(LANG_0182)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0182)); if (texinfoCount > (is_bsp2 ? INT_MAX : MAX_MAP_TEXINFOS)) - logf(get_localized_string(LANG_1037)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1037)); if (nodeCount > (is_bsp2 ? INT_MAX : (int)MAX_MAP_NODES)) - logf(get_localized_string(LANG_0183)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0183)); if (vertCount > (is_bsp2 ? INT_MAX : MAX_MAP_VERTS)) - logf(get_localized_string(LANG_0184)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0184)); if (faceCount > (is_bsp2 ? INT_MAX : MAX_MAP_FACES)) - logf(get_localized_string(LANG_0185)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0185)); if (clipnodeCount > (int)(is_32bit_clipnodes ? INT_MAX : is_broken_clipnodes ? (MAX_MAP_CLIPNODES_DEFAULT * 2 - 15) : MAX_MAP_CLIPNODES)) - logf(get_localized_string(LANG_0186)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0186)); if (marksurfCount > (is_bsp2 ? INT_MAX : MAX_MAP_MARKSURFS)) - logf(get_localized_string(LANG_0187)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0187)); if (surfedgeCount > (is_bsp2 ? INT_MAX : (int)MAX_MAP_SURFEDGES)) - logf(get_localized_string(LANG_0188)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0188)); if (edgeCount > (is_bsp2 ? INT_MAX : (int)MAX_MAP_EDGES)) - logf(get_localized_string(LANG_0189)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0189)); if (textureCount > (int)MAX_MAP_TEXTURES) - logf(get_localized_string(LANG_0190)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0190)); if (lightDataLength > (int)MAX_MAP_LIGHTDATA) - logf(get_localized_string(LANG_0191)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0191)); if (visDataLength > (int)MAX_MAP_VISDATA) - logf(get_localized_string(LANG_0192)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0192)); } void Bsp::replace_lump(int lumpIdx, void* newData, size_t newLength) @@ -6737,7 +6744,7 @@ void Bsp::ExportToObjWIP(const std::string& path, ExportObjOrder order, int isca { if (!createDir(path)) { - logf(get_localized_string(LANG_0193),path); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0193),path); return; } @@ -6749,8 +6756,8 @@ void Bsp::ExportToObjWIP(const std::string& path, ExportObjOrder order, int isca scale = abs(scale); FILE* f = NULL; - logf(get_localized_string(LANG_0194),bsp_name + ".obj",path); - logf(get_localized_string(LANG_0195),iscale == 1 ? "scale" : iscale < 0 ? "downscale" : "upscale",abs(iscale)); + print_log(get_localized_string(LANG_0194),bsp_name + ".obj",path); + print_log(get_localized_string(LANG_0195),iscale == 1 ? "scale" : iscale < 0 ? "downscale" : "upscale",abs(iscale)); fopen_s(&f, (path + bsp_name + ".obj").c_str(), "wb"); if (f) { @@ -6791,7 +6798,7 @@ void Bsp::ExportToObjWIP(const std::string& path, ExportObjOrder order, int isca if (!bsprend->getRenderPointers(i, &rface, &rgroup)) { - logf(get_localized_string(LANG_0196)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0196)); break; } @@ -6982,7 +6989,7 @@ void Bsp::ExportToObjWIP(const std::string& path, ExportObjOrder order, int isca } else { - logf(get_localized_string(LANG_0197)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0197)); } } @@ -6992,7 +6999,7 @@ void recurse_node(Bsp* map, int nodeIdx) if (nodeIdx < 0) { //BSPLEAF32& leaf = map->leaves[~nodeIdx]; - logf(get_localized_string(LANG_1038),~nodeIdx); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1038),~nodeIdx); return; } @@ -7004,7 +7011,7 @@ void Bsp::ExportPortalFile() { if (bsp_path.size() < 4) { - logf(get_localized_string(LANG_0198)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0198)); return; } std::string targetFileName = bsp_path.substr(0, bsp_path.size() - 4) + "X.prt"; @@ -7012,17 +7019,17 @@ void Bsp::ExportPortalFile() std::ofstream targetFile(targetFileName, std::ios::trunc | std::ios::binary); if (!targetFile.is_open()) { - logf(get_localized_string(LANG_0199),targetFileName); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0199),targetFileName); return; } /*std::ofstream targetViewFile(targetFileName, std::ios::trunc | std::ios::binary); if (!targetFile.is_open()) { - logf(get_localized_string(LANG_0200),targetViewFileName); + print_log(get_localized_string(LANG_0200),targetViewFileName); return; } - logf(get_localized_string(LANG_0201),targetViewFileName);*/ - logf(get_localized_string(LANG_0202),targetFileName); + print_log(get_localized_string(LANG_0201),targetViewFileName);*/ + print_log(get_localized_string(LANG_0202),targetFileName); targetFile << fmt::format("{}\n", leafCount - 1); @@ -7047,7 +7054,7 @@ void Bsp::ExportLightFile() { if (bsp_path.size() < 4) { - logf(get_localized_string(LANG_0203)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0203)); return; } @@ -7056,7 +7063,7 @@ void Bsp::ExportLightFile() std::ofstream targetFile(targetFileName, std::ios::trunc | std::ios::binary); if (!targetFile.is_open()) { - logf(get_localized_string(LANG_0204),targetFileName); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0204),targetFileName); return; } int version = 1; @@ -7069,7 +7076,7 @@ void Bsp::ImportLightFile() { if (bsp_path.size() < 4) { - logf(get_localized_string(LANG_0205)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0205)); return; } @@ -7078,7 +7085,7 @@ void Bsp::ImportLightFile() std::ifstream targetFile(targetFileName, std::ios::binary); if (!targetFile.is_open()) { - logf(get_localized_string(LANG_0206),targetFileName); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0206),targetFileName); return; } char header[16]{}; @@ -7092,7 +7099,7 @@ void Bsp::ImportLightFile() } else { - logf(get_localized_string(LANG_0207)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0207)); } } @@ -7100,7 +7107,7 @@ void Bsp::ExportExtFile() { if (bsp_path.size() < 4) { - logf(get_localized_string(LANG_0208)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0208)); return; } @@ -7109,21 +7116,21 @@ void Bsp::ExportExtFile() std::ofstream targetFile(targetFileName, std::ios::trunc | std::ios::binary); if (!targetFile.is_open()) { - logf(get_localized_string(LANG_0209),targetFileName); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0209),targetFileName); return; } - logf(get_localized_string(LANG_0210),targetFileName); + print_log(get_localized_string(LANG_0210),targetFileName); write(targetMapFileName + "_nolight.bsp"); Bsp* tmpBsp = new Bsp(targetMapFileName + "_nolight.bsp"); - logf(get_localized_string(LANG_0211)); + print_log(get_localized_string(LANG_0211)); removeFile(targetMapFileName + "_nolight.bsp"); - logf(get_localized_string(LANG_0212),targetMapFileName + "_nolight.bsp"); + print_log(get_localized_string(LANG_0212),targetMapFileName + "_nolight.bsp"); tmpBsp->lumps[LUMP_LIGHTING] = NULL; tmpBsp->bsp_header.lump[LUMP_LIGHTING].nOffset = 0; @@ -7136,11 +7143,11 @@ void Bsp::ExportExtFile() tmpBsp->update_lump_pointers(); - logf(get_localized_string(LANG_0213),targetMapFileName); + print_log(get_localized_string(LANG_0213),targetMapFileName); tmpBsp->write(targetMapFileName + "_nolight.bsp"); - logf(get_localized_string(LANG_0214),targetFileName); + print_log(get_localized_string(LANG_0214),targetFileName); targetFile << fmt::format("{}\n", faceCount); for (int i = 0; i < faceCount; i++) @@ -7150,7 +7157,7 @@ void Bsp::ExportExtFile() targetFile << fmt::format("{} {} {} {}\n", mins[0], mins[1], maxs[0], maxs[1]); } - logf(get_localized_string(LANG_0215),targetMapFileName + "_nolight.wa_"); + print_log(get_localized_string(LANG_0215),targetMapFileName + "_nolight.wa_"); Wad* tmpWad = new Wad(); std::vector addedTextures; @@ -7201,7 +7208,7 @@ void Bsp::ExportExtFile() } } - logf(get_localized_string(LANG_0216),addedTextures.size() - missingTex,missingTex); + print_log(get_localized_string(LANG_0216),addedTextures.size() - missingTex,missingTex); tmpWad->write(targetMapFileName + "_nolight.wa_", outTextures); @@ -7224,11 +7231,11 @@ void Bsp::ExportToMapWIP(const std::string& path) { if (!createDir(path)) { - logf(get_localized_string(LANG_1039),path); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1039),path); return; } FILE* f = NULL; - logf(get_localized_string(LANG_1040),(bsp_name + ".map"),path); + print_log(get_localized_string(LANG_1040),(bsp_name + ".map"),path); fopen_s(&f, (path + bsp_name + ".map").c_str(), "wb"); if (f) { @@ -7246,7 +7253,7 @@ void Bsp::ExportToMapWIP(const std::string& path) for (int i = 0; i < bsprend->renderModels[modelIdx].groupCount; i++) { - logf(get_localized_string(LANG_0217),entIdx,modelIdx,i); + print_log(get_localized_string(LANG_0217),entIdx,modelIdx,i); //RenderGroup& rgroup = bsprend->renderModels[modelIdx].renderGroups[i]; } @@ -7255,7 +7262,7 @@ void Bsp::ExportToMapWIP(const std::string& path) } else { - logf(get_localized_string(LANG_1041)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1041)); } } @@ -7313,7 +7320,7 @@ void Bsp::decalShoot(vec3 pos, const char* texname) if (bestMath > 0) { int modelidx = get_model_from_face(bestMath); - logf(get_localized_string(LANG_0218),modelidx,bestMath,bestDir); + print_log(get_localized_string(LANG_0218),modelidx,bestMath,bestDir); std::vector worldVerts; } @@ -7483,7 +7490,7 @@ bool Bsp::is_texture_with_pal(int textureid) int lastMipSize = (tex->nWidth / 8) * (tex->nHeight / 8); unsigned char* palOffset = pStartOffset + tex->nOffsets[3] + lastMipSize; - //logf("{}-{}={}\n", (void*)(pStartOffset + palOffset), (void*)(pEndOffset), (int)((pStartOffset + palOffset) - pEndOffset)); + //print_log("{}-{}={}\n", (void*)(pStartOffset + palOffset), (void*)(pEndOffset), (int)((pStartOffset + palOffset) - pEndOffset)); if (abs(palOffset - pEndOffset) >= sizeof(COLOR3) * 256) // No align check { return true; diff --git a/src/bsp/BspMerger.cpp b/src/bsp/BspMerger.cpp index 4be3494b..29f71dab 100644 --- a/src/bsp/BspMerger.cpp +++ b/src/bsp/BspMerger.cpp @@ -10,13 +10,13 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string { if (maps.size() < 1) { - logf(get_localized_string(LANG_0219)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0219)); return NULL; } std::vector>> blocks = separate(maps, gap); - logf(get_localized_string(LANG_0220)); + print_log(get_localized_string(LANG_0220)); for (int z = 0; z < blocks.size(); z++) { @@ -28,7 +28,7 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string if (abs(block.offset.x) >= EPSILON || abs(block.offset.y) >= EPSILON || abs(block.offset.z) >= EPSILON) { - logf(" Apply offset ({:6.0f}, {:6.0f}, {:6.0f}) to {}\n", + print_log(" Apply offset ({:6.0f}, {:6.0f}, {:6.0f}) to {}\n", block.offset.x, block.offset.y, block.offset.z, block.map->bsp_name.c_str()); block.map->move(block.offset); } @@ -51,7 +51,7 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string // TODO: Don't merge linearly. Merge gradually bigger chunks to minimize BSP tree depth. // Not worth it until more than 27 maps are merged together (merge cube bigger than 3x3x3) - logf(get_localized_string(LANG_0221),maps.size()); + print_log(get_localized_string(LANG_0221),maps.size()); // merge maps along X axis to form rows of maps @@ -68,7 +68,7 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string if (x != 0) { - //logf(get_localized_string(LANG_0222),x,y,z,0,y,z); + //print_log(get_localized_string(LANG_0222),x,y,z,0,y,z); std::string merge_name = ++mergeCount < maps.size() ? "row_" + std::to_string(rowId) : "result"; merge(rowStart, block, merge_name); } @@ -88,7 +88,7 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string if (y != 0) { - //logf(get_localized_string(LANG_1042),0,y,z,0,0,z); + //print_log(get_localized_string(LANG_1042),0,y,z,0,0,z); std::string merge_name = ++mergeCount < maps.size() ? "layer_" + std::to_string(colId) : "result"; merge(colStart, block, merge_name); } @@ -104,7 +104,7 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string if (z != 0) { - //logf(get_localized_string(LANG_1147),0,0,z,0,0,0); + //print_log(get_localized_string(LANG_1147),0,0,z,0,0,0); merge(layerStart, block, "result"); } } @@ -119,7 +119,7 @@ Bsp* BspMerger::merge(std::vector maps, const vec3& gap, const std::string for (int x = 0; x < blocks[z][y].size(); x++) flattenedBlocks.push_back(blocks[z][y][x]); - logf(get_localized_string(LANG_0223)); + print_log(get_localized_string(LANG_0223)); update_map_series_entity_logic(output, flattenedBlocks, maps, output_name, maps[0]->bsp_name, noscript); } @@ -131,7 +131,7 @@ void BspMerger::merge(MAPBLOCK& dst, MAPBLOCK& src, std::string resultType) std::string thisName = dst.merge_name.size() ? dst.merge_name : dst.map->bsp_name; std::string otherName = src.merge_name.size() ? src.merge_name : src.map->bsp_name; dst.merge_name = std::move(resultType); - logf(" {:>8} = {} + {}\n", dst.merge_name, thisName, otherName); + print_log(" {:>8} = {} + {}\n", dst.merge_name, thisName, otherName); merge(*dst.map, *src.map); } @@ -184,7 +184,7 @@ std::vector>> BspMerger::separate(std::vector< if (noOverlap) { - logf(get_localized_string(LANG_0224)); + print_log(get_localized_string(LANG_0224)); return orderedBlocks; } @@ -203,7 +203,7 @@ std::vector>> BspMerger::separate(std::vector< if (maxMapsPerRow * maxMapsPerCol * maxMapsPerLayer < (float)maps.size()) { - logf(get_localized_string(LANG_0225)); + print_log(get_localized_string(LANG_0225)); return orderedBlocks; } @@ -211,15 +211,15 @@ std::vector>> BspMerger::separate(std::vector< vec3 mergedMapMin = mergedMapSize * -0.5f; vec3 mergedMapMax = mergedMapMin + mergedMapSize; - logf(get_localized_string(LANG_0226),maxDims.x,maxDims.y,maxDims.z); - logf(get_localized_string(LANG_0227),maxMapsPerRow,maxMapsPerCol,maxMapsPerLayer,maxMapsPerRow * maxMapsPerCol * maxMapsPerLayer); + print_log(get_localized_string(LANG_0226),maxDims.x,maxDims.y,maxDims.z); + print_log(get_localized_string(LANG_0227),maxMapsPerRow,maxMapsPerCol,maxMapsPerLayer,maxMapsPerRow * maxMapsPerCol * maxMapsPerLayer); float actualWidth = std::min(idealMapsPerAxis, (float)maps.size()); float actualLength = std::min(idealMapsPerAxis, (float)ceil((float)maps.size() / idealMapsPerAxis)); float actualHeight = std::min(idealMapsPerAxis, (float)ceil((float)maps.size() / (idealMapsPerAxis * idealMapsPerAxis))); - logf(get_localized_string(LANG_0228),actualWidth,actualLength,actualHeight); + print_log(get_localized_string(LANG_0228),actualWidth,actualLength,actualHeight); - logf("Merged map bounds: min=({:.0f},{:.0f}, {:.0f})\n" + print_log("Merged map bounds: min=({:.0f},{:.0f}, {:.0f})\n" " max=({:.0f}, {:.0f},{:.0f})\n", mergedMapMin.x, mergedMapMin.y, mergedMapMin.z, mergedMapMax.x, mergedMapMax.y, mergedMapMax.z); @@ -239,8 +239,8 @@ std::vector>> BspMerger::separate(std::vector< MAPBLOCK& block = blocks[blockIdx]; block.offset = targetMins - block.mins; - //logf(get_localized_string(LANG_0229),blockIdx,targetMins.x,targetMins.y,targetMins.z); - //logf(get_localized_string(LANG_0230),block.map->name,block.offset.x,block.offset.y,block.offset.z); + //print_log(get_localized_string(LANG_0229),blockIdx,targetMins.x,targetMins.y,targetMins.z); + //print_log(get_localized_string(LANG_0230),block.map->name,block.offset.x,block.offset.y,block.offset.z); row.push_back(block); @@ -477,7 +477,7 @@ void BspMerger::update_map_series_entity_logic(Bsp* mergedMap, std::vectorupdate_ent_lump(); @@ -888,7 +888,7 @@ int BspMerger::force_unique_ent_names_per_map(Bsp* mergedMap) std::string oldName = *it2; std::string newName = oldName + "_" + std::to_string(renameSuffix++); - //logf << "\nRenaming " << *it2 << " to " << newName << endl; + //print_log << "\nRenaming " << *it2 << " to " << newName << endl; for (int i = 0; i < mergedMap->ents.size(); i++) { @@ -912,7 +912,7 @@ bool BspMerger::merge(Bsp& mapA, Bsp& mapB, bool modelMerge) BSPPLANE separationPlane = separate(mapA, mapB); if (separationPlane.nType == -1 && !modelMerge) { - logf(get_localized_string(LANG_0236)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0236)); return false; } thisWorldLeafCount = mapA.models[0].nVisLeafs; // excludes solid leaf 0 @@ -941,7 +941,7 @@ bool BspMerger::merge(Bsp& mapA, Bsp& mapB, bool modelMerge) { if (!modelMerge) { - logf(get_localized_string(LANG_0237),g_lump_names[i]); + print_log(get_localized_string(LANG_0237),g_lump_names[i]); mapA.bsp_header.lump[i].nLength = mapB.bsp_header.lump[i].nLength; mapA.lumps[i] = new unsigned char[mapB.bsp_header.lump[i].nLength]; memcpy(mapA.lumps[i], mapB.lumps[i], mapB.bsp_header.lump[i].nLength); @@ -956,7 +956,7 @@ bool BspMerger::merge(Bsp& mapA, Bsp& mapB, bool modelMerge) } else if (!mapB.lumps[i]) { - logf(get_localized_string(LANG_0238),g_lump_names[i]); + print_log(get_localized_string(LANG_0238),g_lump_names[i]); } else { @@ -1066,12 +1066,12 @@ BSPPLANE BspMerger::separate(Bsp& mapA, Bsp& mapB) { separationPlane.nType = -1; // no simple separating axis - logf(get_localized_string(LANG_0239)); - logf("({:6.0f}, {:6.0f}, {:6.0f})", amin.x, amin.y, amin.z); - logf(" - ({:6.0f}, {:6.0f}, {:6.0f}) {}\n", amax.x, amax.y, amax.z, mapA.bsp_name); + print_log(get_localized_string(LANG_0239)); + print_log("({:6.0f}, {:6.0f}, {:6.0f})", amin.x, amin.y, amin.z); + print_log(" - ({:6.0f}, {:6.0f}, {:6.0f}) {}\n", amax.x, amax.y, amax.z, mapA.bsp_name); - logf("({:6.0f}, {:6.0f}, {:6.0f})", bmin.x, bmin.y, bmin.z); - logf(" - ({:6.0f}, {:6.0f}, {:6.0f}) {}\n", bmax.x, bmax.y, bmax.z, mapB.bsp_name); + print_log("({:6.0f}, {:6.0f}, {:6.0f})", bmin.x, bmin.y, bmin.z); + print_log(" - ({:6.0f}, {:6.0f}, {:6.0f}) {}\n", bmax.x, bmax.y, bmax.z, mapB.bsp_name); } return separationPlane; @@ -1216,7 +1216,7 @@ void BspMerger::merge_planes(Bsp& mapA, Bsp& mapB) size_t newLen = mergedPlanes.size() * sizeof(BSPPLANE); size_t duplicates = (mapA.planeCount + mapB.planeCount) - mergedPlanes.size(); - logf(get_localized_string(LANG_0240),duplicates); + print_log(get_localized_string(LANG_0240),duplicates); unsigned char* newPlanes = new unsigned char[newLen]; memcpy(newPlanes, &mergedPlanes[0], newLen); @@ -1327,7 +1327,7 @@ void BspMerger::merge_textures(Bsp& mapA, Bsp& mapB) delete[] mipTexOffsets; - logf(get_localized_string(LANG_0241),duplicates); + print_log(get_localized_string(LANG_0241),duplicates); mapA.replace_lump(LUMP_TEXTURES, newTextureData, newLen); } @@ -1397,7 +1397,7 @@ void BspMerger::merge_texinfo(Bsp& mapA, Bsp& mapB) unsigned char* newTexinfoData = new unsigned char[newLen]; memcpy(newTexinfoData, &mergedInfo[0], newLen); - logf(get_localized_string(LANG_0242),duplicates); + print_log(get_localized_string(LANG_0242),duplicates); mapA.replace_lump(LUMP_TEXINFO, newTexinfoData, newLen); } @@ -1781,7 +1781,7 @@ void BspMerger::merge_vis(Bsp& mapA, Bsp& mapB) { if (thisLeafCount == 0) { - logf(get_localized_string(LANG_0243)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0243)); return; } if (thisWorldLeafCount == 0) @@ -1836,7 +1836,7 @@ void BspMerger::merge_vis(Bsp& mapA, Bsp& mapB) mapA.replace_lump(LUMP_VISIBILITY, compressedVisResize, newVisLen); - logf(get_localized_string(LANG_0244),oldLen,newVisLen); + print_log(get_localized_string(LANG_0244),oldLen,newVisLen); delete[] decompressedVis; delete[] compressedVis; @@ -1933,7 +1933,7 @@ void BspMerger::create_merge_headnodes(Bsp& mapA, Bsp& mapB, BSPPLANE separation if (swapNodeChildren) separationPlane.vNormal = separationPlane.vNormal.invert(); - //logf(get_localized_string(LANG_0245),separationPlane.vNormal.x,separationPlane.vNormal.y,separationPlane.vNormal.z,separationPlane.fDist); + //print_log(get_localized_string(LANG_0245),separationPlane.vNormal.x,separationPlane.vNormal.y,separationPlane.vNormal.z,separationPlane.fDist); // write separating plane @@ -1978,7 +1978,7 @@ void BspMerger::create_merge_headnodes(Bsp& mapA, Bsp& mapB, BSPPLANE separation BSPCLIPNODE32 newHeadNodes[NEW_NODE_COUNT]; for (int i = 0; i < NEW_NODE_COUNT; i++) { - //logf(get_localized_string(LANG_0246),i+1,thisWorld.iHeadnodes[i+1]); + //print_log(get_localized_string(LANG_0246),i+1,thisWorld.iHeadnodes[i+1]); newHeadNodes[i] = { separationPlaneIdx, // plane idx { // child nodes diff --git a/src/bsp/Wad.cpp b/src/bsp/Wad.cpp index b855f694..d6abc6ba 100644 --- a/src/bsp/Wad.cpp +++ b/src/bsp/Wad.cpp @@ -58,7 +58,7 @@ bool Wad::readInfo() if (!fileExists(file)) { - logf(get_localized_string(LANG_0247),filename); + print_log(get_localized_string(LANG_0247),filename); return false; } @@ -66,7 +66,7 @@ bool Wad::readInfo() if (!filedata) { - logf(get_localized_string(LANG_1043),filename); + print_log(get_localized_string(LANG_1043),filename); return false; } @@ -74,7 +74,7 @@ bool Wad::readInfo() { delete[] filedata; filedata = NULL; - logf(get_localized_string(LANG_0248),filename); + print_log(get_localized_string(LANG_0248),filename); return false; } @@ -86,7 +86,7 @@ bool Wad::readInfo() { delete[] filedata; filedata = NULL; - logf(get_localized_string(LANG_0249),filename); + print_log(get_localized_string(LANG_0249),filename); return false; } @@ -94,7 +94,7 @@ bool Wad::readInfo() { delete[] filedata; filedata = NULL; - logf(get_localized_string(LANG_0250),filename); + print_log(get_localized_string(LANG_0250),filename); return false; } @@ -107,7 +107,7 @@ bool Wad::readInfo() usableTextures = false; - //logf("D {} {}\n", header.nDirOffset, header.nDir); + //print_log("D {} {}\n", header.nDirOffset, header.nDir); for (int i = 0; i < header.nDir; i++) { @@ -115,7 +115,7 @@ bool Wad::readInfo() if (offset + sizeof(WADDIRENTRY) > fileLen) { - logf(get_localized_string(LANG_0251)); + print_log(get_localized_string(LANG_0251)); return false; } @@ -132,7 +132,7 @@ bool Wad::readInfo() if (!usableTextures) { - logf(get_localized_string(LANG_0252),basename(filename)); + print_log(get_localized_string(LANG_0252),basename(filename)); if (!dirEntries.size()) return false; } @@ -161,7 +161,7 @@ WADTEX* Wad::readTexture(int dirIndex, int* texturetype) { if (dirIndex < 0 || dirIndex >= dirEntries.size()) { - logf(get_localized_string(LANG_0253)); + print_log(get_localized_string(LANG_0253)); return NULL; } //if (cache != NULL) @@ -189,7 +189,7 @@ WADTEX* Wad::readTexture(const std::string& texname, int* texturetype) if (dirEntries[idx].bCompression) { - logf(get_localized_string(LANG_0254)); + print_log(get_localized_string(LANG_0254)); return NULL; } @@ -204,7 +204,7 @@ WADTEX* Wad::readTexture(const std::string& texname, int* texturetype) memcpy((char*)&mtex, &filedata[offset], sizeof(BSPMIPTEX)); offset += sizeof(BSPMIPTEX); if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0255),mtex.szName,mtex.nWidth,mtex.nHeight); + print_log(get_localized_string(LANG_0255),mtex.szName,mtex.nWidth,mtex.nHeight); int w = mtex.nWidth; int h = mtex.nHeight; int sz = w * h; // miptex 0 @@ -228,7 +228,7 @@ WADTEX* Wad::readTexture(const std::string& texname, int* texturetype) tex->data = data; tex->needclean = true; if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0256),tex->szName,tex->nWidth,tex->nHeight); + print_log(get_localized_string(LANG_0256),tex->szName,tex->nWidth,tex->nHeight); return tex; } @@ -405,7 +405,7 @@ WADTEX* create_wadtex(const char* name, COLOR3* rgbdata, int width, int height) { if (colorCount >= 256) { - logf(get_localized_string(LANG_1044)); + print_log(get_localized_string(LANG_1044)); delete[] mip[0]; return NULL; } @@ -511,7 +511,7 @@ WADTEX* create_wadtex(const char* name, COLOR3* rgbdata, int width, int height) COLOR3* ConvertWadTexToRGB(WADTEX* wadTex, COLOR3* palette) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0257),wadTex->szName,wadTex->nWidth,wadTex->nHeight); + print_log(get_localized_string(LANG_0257),wadTex->szName,wadTex->nWidth,wadTex->nHeight); int lastMipSize = (wadTex->nWidth / 8) * (wadTex->nHeight / 8); if (palette == NULL) palette = (COLOR3*)(wadTex->data + wadTex->nOffsets[3] + lastMipSize + sizeof(short) - sizeof(BSPMIPTEX)); @@ -527,14 +527,14 @@ COLOR3* ConvertWadTexToRGB(WADTEX* wadTex, COLOR3* palette) } if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0258),wadTex->szName,wadTex->nWidth,wadTex->nHeight); + print_log(get_localized_string(LANG_0258),wadTex->szName,wadTex->nWidth,wadTex->nHeight); return imageData; } COLOR3* ConvertMipTexToRGB(BSPMIPTEX* tex, COLOR3* palette) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0259),tex->szName,tex->nWidth,tex->nHeight); + print_log(get_localized_string(LANG_0259),tex->szName,tex->nWidth,tex->nHeight); int lastMipSize = (tex->nWidth / 8) * (tex->nHeight / 8); if (palette == NULL) @@ -550,7 +550,7 @@ COLOR3* ConvertMipTexToRGB(BSPMIPTEX* tex, COLOR3* palette) } if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0260),tex->szName,tex->nWidth,tex->nHeight); + print_log(get_localized_string(LANG_0260),tex->szName,tex->nWidth,tex->nHeight); return imageData; } @@ -558,7 +558,7 @@ COLOR3* ConvertMipTexToRGB(BSPMIPTEX* tex, COLOR3* palette) COLOR4* ConvertWadTexToRGBA(WADTEX* wadTex, COLOR3* palette) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0261),wadTex->szName,wadTex->nWidth,wadTex->nHeight); + print_log(get_localized_string(LANG_0261),wadTex->szName,wadTex->nWidth,wadTex->nHeight); int lastMipSize = (wadTex->nWidth / 8) * (wadTex->nHeight / 8); if (palette == NULL) @@ -581,14 +581,14 @@ COLOR4* ConvertWadTexToRGBA(WADTEX* wadTex, COLOR3* palette) } if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0262),wadTex->szName,wadTex->nWidth,wadTex->nHeight); + print_log(get_localized_string(LANG_0262),wadTex->szName,wadTex->nWidth,wadTex->nHeight); return imageData; } COLOR4* ConvertMipTexToRGBA(BSPMIPTEX* tex, COLOR3* palette) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0263),tex->szName,tex->nWidth,tex->nHeight); + print_log(get_localized_string(LANG_0263),tex->szName,tex->nWidth,tex->nHeight); int lastMipSize = (tex->nWidth / 8) * (tex->nHeight / 8); if (palette == NULL) @@ -611,6 +611,6 @@ COLOR4* ConvertMipTexToRGBA(BSPMIPTEX* tex, COLOR3* palette) } if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0264),tex->szName,tex->nWidth,tex->nHeight); + print_log(get_localized_string(LANG_0264),tex->szName,tex->nWidth,tex->nHeight); return imageData; } \ No newline at end of file diff --git a/src/bsp/remap.cpp b/src/bsp/remap.cpp index 1c743056..aea180dc 100644 --- a/src/bsp/remap.cpp +++ b/src/bsp/remap.cpp @@ -92,14 +92,14 @@ void print_stat(int indent, int stat, const char* data) int statabs = abs(stat); for (int i = 0; i < indent; i++) - logf(" "); + print_log(" "); const char* plural = "s"; if (std::string(data) == "vertex") { plural = "es"; } - logf("{} {} {}{}\n", stat > 0 ? "Deleted" : "Added", statabs, data, statabs > 1 ? plural : ""); + print_log("{} {} {}{}\n", stat > 0 ? "Deleted" : "Added", statabs, data, statabs > 1 ? plural : ""); } void print_stat_mem(int indent, int bytes, const char* data) @@ -109,8 +109,8 @@ void print_stat_mem(int indent, int bytes, const char* data) return; } for (int i = 0; i < indent; i++) - logf(" "); - logf("{} {:.2f} KB of {}\n", bytes > 0 ? "Deleted" : "Added", (abs(bytes) / 1024.0f), data); + print_log(" "); + print_log("{} {:.2f} KB of {}\n", bytes > 0 ? "Deleted" : "Added", (abs(bytes) / 1024.0f), data); } void STRUCTCOUNT::print_delete_stats(int indent) diff --git a/src/cli/CommandLine.cpp b/src/cli/CommandLine.cpp index 8d1f8f19..51c31df9 100644 --- a/src/cli/CommandLine.cpp +++ b/src/cli/CommandLine.cpp @@ -82,7 +82,7 @@ bool CommandLine::hasOptionVector(const std::string& optionName) if (parts.size() != 3) { - logf(get_localized_string(LANG_0265),optionName); + print_log(get_localized_string(LANG_0265),optionName); return false; } @@ -106,7 +106,7 @@ vec3 CommandLine::getOptionVector(const std::string& optionName) if (parts.size() != 3) { - logf(get_localized_string(LANG_1045),optionName); + print_log(get_localized_string(LANG_1045),optionName); return ret; } diff --git a/src/cli/ProgressMeter.cpp b/src/cli/ProgressMeter.cpp index d791ce14..548ceee0 100644 --- a/src/cli/ProgressMeter.cpp +++ b/src/cli/ProgressMeter.cpp @@ -17,7 +17,7 @@ void ProgressMeter::update(const char* newTitle, int totalProgressTicks) progress_total = totalProgressTicks; if (simpleMode && !hide) { - logf(std::string(newTitle) + "\n"); + print_log(std::string(newTitle) + "\n"); } } @@ -40,8 +40,8 @@ void ProgressMeter::tick() float percent = (progress / (float)progress_total) * 100; - for (int i = 0; i < 12; i++) logf("\b\b\b\b"); - logf(get_localized_string(LANG_0266),progress_title,percent); + for (int i = 0; i < 12; i++) print_log("\b\b\b\b"); + print_log(get_localized_string(LANG_0266),progress_title,percent); } void ProgressMeter::clear() @@ -51,7 +51,7 @@ void ProgressMeter::clear() return; } // 50 chars - for (int i = 0; i < 6; i++) logf("\b\b\b\b\b\b\b\b\b\b"); - for (int i = 0; i < 6; i++) logf(" "); - for (int i = 0; i < 6; i++) logf("\b\b\b\b\b\b\b\b\b\b"); + for (int i = 0; i < 6; i++) print_log("\b\b\b\b\b\b\b\b\b\b"); + for (int i = 0; i < 6; i++) print_log(" "); + for (int i = 0; i < 6; i++) print_log("\b\b\b\b\b\b\b\b\b\b"); } \ No newline at end of file diff --git a/src/editor/BspRenderer.cpp b/src/editor/BspRenderer.cpp index 4788e07a..fbeb0658 100644 --- a/src/editor/BspRenderer.cpp +++ b/src/editor/BspRenderer.cpp @@ -39,7 +39,7 @@ BspRenderer::BspRenderer(Bsp* _map, PointEntRenderer* _pointEntRenderer) if (g_settings.start_at_entity) { - logf(get_localized_string(LANG_0267)); + print_log(get_localized_string(LANG_0267)); Entity* foundEnt = NULL; for (auto ent : map->ents) { @@ -319,17 +319,17 @@ void BspRenderer::loadTextures() if (path.empty()) { - logf(get_localized_string(LANG_0268), wadNames[i]); + print_log(get_localized_string(LANG_0268), wadNames[i]); continue; } - logf(get_localized_string(LANG_0269), path); + print_log(get_localized_string(LANG_0269), path); Wad* wad = new Wad(path); if (wad->readInfo()) wads.push_back(wad); else { - logf(get_localized_string(LANG_0270), path); + print_log(get_localized_string(LANG_0270), path); delete wad; } } @@ -394,11 +394,11 @@ void BspRenderer::loadTextures() } if (wadTexCount) - logf(get_localized_string(LANG_0271), wadTexCount); + print_log(get_localized_string(LANG_0271), wadTexCount); if (embedCount) - logf(get_localized_string(LANG_0272), embedCount); + print_log(get_localized_string(LANG_0272), embedCount); if (missingCount) - logf(get_localized_string(LANG_0273), missingCount); + print_log(get_localized_string(LANG_0273), missingCount); } void BspRenderer::reload() @@ -497,7 +497,7 @@ void BspRenderer::loadLightmaps() numRenderLightmapInfos = map->faceCount; lightmaps = new LightmapInfo[map->faceCount]{}; - logf(get_localized_string(LANG_0274)); + print_log(get_localized_string(LANG_0274)); int lightmapCount = 0; @@ -517,7 +517,7 @@ void BspRenderer::loadLightmaps() { BSPFACE32& face = map->faces[i]; BSPTEXTUREINFO& texinfo = map->texinfos[face.iTextureInfo]; - if (face.nLightmapOffset < 0 || (texinfo.nFlags & TEX_SPECIAL) || face.nLightmapOffset >= map->bsp_header.lump[LUMP_LIGHTING].nLength) + if (!atlases.size() || face.nLightmapOffset < 0 || (texinfo.nFlags & TEX_SPECIAL) || face.nLightmapOffset >= map->bsp_header.lump[LUMP_LIGHTING].nLength) { } @@ -543,7 +543,7 @@ void BspRenderer::loadLightmaps() { if (face.nStyles[s] == 255) continue; - int atlasId = atlases.size() - 1; + size_t atlasId = atlases.size() - 1; // TODO: Try fitting in earlier atlases before using the latest one if (!atlases[atlasId]->insert(info.w, info.h, info.x[s], info.y[s])) @@ -556,13 +556,13 @@ void BspRenderer::loadLightmaps() if (!atlases[atlasId]->insert(info.w, info.h, info.x[s], info.y[s])) { - logf(get_localized_string(LANG_0275), info.w, info.h, LIGHTMAP_ATLAS_SIZE, LIGHTMAP_ATLAS_SIZE); + print_log(get_localized_string(LANG_0275), info.w, info.h, LIGHTMAP_ATLAS_SIZE, LIGHTMAP_ATLAS_SIZE); continue; } } lightmapCount++; - info.atlasId[s] = atlasId; + info.atlasId[s] = (int)atlasId; // copy lightmap data into atlas int lightmapSz = info.w * info.h * sizeof(COLOR3); @@ -588,6 +588,7 @@ void BspRenderer::loadLightmaps() } } } + } } @@ -602,7 +603,7 @@ void BspRenderer::loadLightmaps() numLightmapAtlases = atlasTextures.size(); //lodepng_encode24_file("atlas.png", atlasTextures[0]->data, LIGHTMAP_ATLAS_SIZE, LIGHTMAP_ATLAS_SIZE); - logf(get_localized_string(LANG_0276), lightmapCount, atlases.size()); + print_log(get_localized_string(LANG_0276), lightmapCount, atlases.size()); lightmapsGenerated = true; } @@ -617,7 +618,7 @@ void BspRenderer::updateLightmapInfos() if (map->faceCount < numRenderLightmapInfos) { // Already done in remove_unused_structs!!! - logf(get_localized_string(LANG_0277)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0277)); return; } @@ -635,7 +636,7 @@ void BspRenderer::updateLightmapInfos() lightmaps = newLightmaps; numRenderLightmapInfos = map->faceCount; - logf(get_localized_string(LANG_0278), addedFaces); + print_log(get_localized_string(LANG_0278), addedFaces); } void BspRenderer::preRenderFaces() @@ -675,7 +676,7 @@ void BspRenderer::genRenderFaces(int& renderModelCount) modelRenderGroups += groupCount; } - logf("Created {} solid render groups ({} world, {} entity)\n", + print_log("Created {} solid render groups ({} world, {} entity)\n", worldRenderGroups + modelRenderGroups, worldRenderGroups, modelRenderGroups); @@ -689,7 +690,7 @@ void BspRenderer::addNewRenderFace() delete[] renderModels; renderModels = tmpRenderModel; numRenderModels = map->modelCount + 1; - logf(get_localized_string(LANG_0279)); + print_log(get_localized_string(LANG_0279)); } void BspRenderer::deleteRenderModel(RenderModel* renderModel) @@ -1126,7 +1127,7 @@ bool BspRenderer::refreshModelClipnodes(int modelIdx) } if (modelIdx < 0 || modelIdx >= numRenderClipnodes) { - logf(get_localized_string(LANG_0280)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0280)); return false; } for (int hullIdx = 0; hullIdx < MAX_MAP_HULLS; hullIdx++) @@ -1255,7 +1256,7 @@ void BspRenderer::generateClipnodeBufferForHull(int modelIdx, int hullIdx) std::vector solidNodes = map->get_model_leaf_volume_cuts(modelIdx, hullIdx); - //logf(get_localized_string(LANG_0281),solidNodes.size(),modelIdx,hullIdx); + //print_log(get_localized_string(LANG_0281),solidNodes.size(),modelIdx,hullIdx); std::vector meshes; for (int k = 0; k < solidNodes.size(); k++) { @@ -1309,7 +1310,7 @@ void BspRenderer::generateClipnodeBufferForHull(int modelIdx, int hullIdx) if (faceVerts.size() < 1) { - // logf(get_localized_string(LANG_0282)); + // print_log(get_localized_string(LANG_0282)); continue; } @@ -1317,7 +1318,7 @@ void BspRenderer::generateClipnodeBufferForHull(int modelIdx, int hullIdx) if (faceVerts.size() < 3) { - // logf(get_localized_string(LANG_1046)); + // print_log(get_localized_string(LANG_1046)); continue; } @@ -1349,7 +1350,7 @@ void BspRenderer::generateClipnodeBufferForHull(int modelIdx, int hullIdx) } if (!found) { - logf(get_localized_string(LANG_0283)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0283)); } vec3 plane_z = mesh.faces[n].normal; @@ -1522,7 +1523,7 @@ void BspRenderer::refreshPointEnt(int entIdx) if (skipIdx >= numPointEnts) { - logf(get_localized_string(LANG_0284)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0284)); return; } } @@ -1865,7 +1866,7 @@ BspRenderer::~BspRenderer() texturesFuture.valid() && texturesFuture.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready || clipnodesFuture.valid() && clipnodesFuture.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready) { - logf(get_localized_string(LANG_0285)); + print_log(get_localized_string(LANG_0285)); } for (int i = 0; i < wads.size(); i++) @@ -1970,7 +1971,7 @@ void BspRenderer::delayLoadData() } clipnodesLoaded = true; - logf(get_localized_string(LANG_0286), clipnodeLeafCount); + print_log(get_localized_string(LANG_0286), clipnodeLeafCount); updateClipnodeOpacity((g_render_flags & RENDER_TRANSPARENT) ? 128 : 255); } } @@ -1986,7 +1987,7 @@ void BspRenderer::highlightFace(int faceIdx, bool highlight, COLOR4 color, bool RenderGroup* rgroup; if (!getRenderPointers(faceIdx, &rface, &rgroup)) { - logf(get_localized_string(LANG_1047)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1047)); return; } @@ -2023,7 +2024,7 @@ void BspRenderer::updateFaceUVs(int faceIdx) RenderGroup* rgroup; if (!getRenderPointers(faceIdx, &rface, &rgroup)) { - logf(get_localized_string(LANG_1148)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1148)); return; } @@ -2772,7 +2773,7 @@ void BspRenderer::updateEntityState(int entIdx) void BspRenderer::saveLumpState() { if (g_verbose) - logf("SAVE LUMP STATES TO BACKUP\n"); + print_log("SAVE LUMP STATES TO BACKUP\n"); map->update_ent_lump(); for (int i = 0; i < HEADER_LUMPS; i++) { @@ -2783,10 +2784,10 @@ void BspRenderer::saveLumpState() void BspRenderer::pushEntityUndoState(const std::string& actionDesc, int entIdx) { if (g_verbose) - logf("SAVE ENT STATES TO BACKUP\n"); + print_log("SAVE ENT STATES TO BACKUP\n"); if (entIdx < 0) { - logf(get_localized_string(LANG_0287)); + print_log(get_localized_string(LANG_0287)); return; } @@ -2794,7 +2795,7 @@ void BspRenderer::pushEntityUndoState(const std::string& actionDesc, int entIdx) if (!ent) { - logf(get_localized_string(LANG_0288)); + print_log(get_localized_string(LANG_0288)); return; } @@ -2826,7 +2827,7 @@ void BspRenderer::pushEntityUndoState(const std::string& actionDesc, int entIdx) if (!anythingToUndo) { - logf(get_localized_string(LANG_0289)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0289)); return; // nothing to undo } @@ -2837,10 +2838,10 @@ void BspRenderer::pushEntityUndoState(const std::string& actionDesc, int entIdx) void BspRenderer::pushModelUndoState(const std::string& actionDesc, unsigned int targets) { if (g_verbose) - logf("SAVE MODEL STATES TO BACKUP\n"); + print_log("SAVE MODEL STATES TO BACKUP\n"); if (!map) { - logf(get_localized_string(LANG_0290)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0290)); return; } @@ -2872,7 +2873,7 @@ void BspRenderer::pushModelUndoState(const std::string& actionDesc, unsigned int differences[i] = true; if (g_verbose) { - logf(get_localized_string(LANG_0291), g_lump_names[i], newLumps.lumps[i].size(), undoLumpState.lumps[i].size()); + print_log(get_localized_string(LANG_0291), g_lump_names[i], newLumps.lumps[i].size(), undoLumpState.lumps[i].size()); } targetLumps = targetLumps | (1 << i); } @@ -2881,7 +2882,7 @@ void BspRenderer::pushModelUndoState(const std::string& actionDesc, unsigned int if (!anyDifference) { - logf(get_localized_string(LANG_0292)); + print_log(get_localized_string(LANG_0292)); return; } @@ -2929,7 +2930,7 @@ void BspRenderer::undo() Command* undoCommand = undoHistory[undoHistory.size() - 1]; if (!undoCommand->allowedDuringLoad && g_app->isLoading) { - logf(get_localized_string(LANG_0293), undoCommand->desc); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0293), undoCommand->desc); return; } @@ -2949,7 +2950,7 @@ void BspRenderer::redo() Command* redoCommand = redoHistory[redoHistory.size() - 1]; if (!redoCommand->allowedDuringLoad && g_app->isLoading) { - logf(get_localized_string(LANG_0294), redoCommand->desc); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0294), redoCommand->desc); return; } diff --git a/src/editor/Command.cpp b/src/editor/Command.cpp index 4480ed72..9ce534fc 100644 --- a/src/editor/Command.cpp +++ b/src/editor/Command.cpp @@ -477,7 +477,7 @@ int CreateBspModelCommand::getDefaultTextureIdx() BSPMIPTEX& tex = *((BSPMIPTEX*)(map->textures + texOffset)); if (tex.szName[0] != '\0' && strcasecmp(tex.szName, "aaatrigger") == 0) { - logf(get_localized_string(LANG_0295)); + print_log(get_localized_string(LANG_0295)); return i; } } @@ -644,7 +644,7 @@ void CleanMapCommand::execute() BspRenderer* renderer = getBspRenderer(); if (!renderer) return; - logf(get_localized_string(LANG_0296),map->bsp_name); + print_log(get_localized_string(LANG_0296),map->bsp_name); map->remove_unused_model_structures().print_delete_stats(1); refresh(); @@ -712,10 +712,10 @@ void OptimizeMapCommand::execute() return; map->update_ent_lump(); - logf(get_localized_string(LANG_0297),map->bsp_name); + print_log(get_localized_string(LANG_0297),map->bsp_name); if (!map->has_hull2_ents()) { - logf(get_localized_string(LANG_0298)); + print_log(get_localized_string(LANG_0298)); map->delete_hull(2, 1); } diff --git a/src/editor/Fgd.cpp b/src/editor/Fgd.cpp index 3c004726..c31fa6c7 100644 --- a/src/editor/Fgd.cpp +++ b/src/editor/Fgd.cpp @@ -55,7 +55,7 @@ void Fgd::merge(Fgd* other) if (classMap.find(className) != classMap.end()) { - logf(get_localized_string(LANG_0299), className, other->name); + print_log(get_localized_string(LANG_0299), className, other->name); continue; } @@ -77,7 +77,7 @@ bool Fgd::parse() std::regex brackEnd(R"(\s*\[\s*\]$)"); - logf(get_localized_string(LANG_0300), path); + print_log(get_localized_string(LANG_0300), path); std::ifstream in(path); @@ -163,7 +163,7 @@ bool Fgd::parse() { if (bracketNestLevel) { - logf(get_localized_string(LANG_0301), lineNum, name); + print_log(get_localized_string(LANG_0301), lineNum, name); } parseClassHeader(*fgdClass); @@ -205,7 +205,7 @@ bool Fgd::parse() { if (fgdClass->keyvalues.empty()) { - logf(get_localized_string(LANG_0302), lineNum, name); + print_log(get_localized_string(LANG_0302), lineNum, name); continue; } KeyvalueDef& lastKey = fgdClass->keyvalues[fgdClass->keyvalues.size() - 1]; @@ -225,7 +225,7 @@ void Fgd::parseClassHeader(FgdClass& fgdClass) if (headerParts.empty()) { - logf(get_localized_string(LANG_0303), lineNum, name); + print_log(get_localized_string(LANG_0303), lineNum, name); return; } @@ -249,7 +249,7 @@ void Fgd::parseClassHeader(FgdClass& fgdClass) } else { - logf(get_localized_string(LANG_0304), typeParts[0], name); + print_log(get_localized_string(LANG_0304), typeParts[0], name); } // parse constructors/properties @@ -283,7 +283,7 @@ void Fgd::parseClassHeader(FgdClass& fgdClass) } else { - logf(get_localized_string(LANG_0305), lineNum, name); + print_log(get_localized_string(LANG_0305), lineNum, name); } fgdClass.sizeSet = true; @@ -298,7 +298,7 @@ void Fgd::parseClassHeader(FgdClass& fgdClass) } else { - logf(get_localized_string(LANG_0306), lineNum, name); + print_log(get_localized_string(LANG_0306), lineNum, name); } fgdClass.colorSet = true; } @@ -312,7 +312,7 @@ void Fgd::parseClassHeader(FgdClass& fgdClass) } else { - logf(get_localized_string("LANG_FGD_BAD_OFFSET"), lineNum, name); + print_log(get_localized_string("LANG_FGD_BAD_OFFSET"), lineNum, name); } } else if (lpart.starts_with("studio(")) @@ -358,19 +358,19 @@ void Fgd::parseClassHeader(FgdClass& fgdClass) else if (flag == "Path" || flag == "Light") ; else - logf(get_localized_string(LANG_0307), flag, lineNum, name); + print_log(get_localized_string(LANG_0307), flag, lineNum, name); } } else if (typeParts[i].find('(') != std::string::npos) { std::string typeName = typeParts[i].substr(0, typeParts[i].find('(')); - logf(get_localized_string(LANG_0308), typeName, lineNum, name); + print_log(get_localized_string(LANG_0308), typeName, lineNum, name); } } if (headerParts.size() == 1) { - logf(get_localized_string(LANG_1048), lineNum, name); + print_log(get_localized_string(LANG_1048), lineNum, name); return; } std::vector nameParts = splitStringIgnoringQuotes(headerParts[1], ":"); @@ -448,7 +448,7 @@ void Fgd::parseKeyvalue(FgdClass& outClass) outClass.keyvalues.push_back(def); - //logf << "ADD KEY " << def.name << "(" << def.valueType << ") : " << def.description << " : " << def.defaultValue << endl; + //print_log << "ADD KEY " << def.name << "(" << def.valueType << ") : " << def.description << " : " << def.defaultValue << endl; } void Fgd::parseChoicesOrFlags(KeyvalueDef& outKey) @@ -561,7 +561,7 @@ void Fgd::processClassInheritance() for (int i = 0; i < classes.size(); i++) { classMap[classes[i]->name] = classes[i]; - //logf(get_localized_string(LANG_0309),classes[i]->name); + //print_log(get_localized_string(LANG_0309),classes[i]->name); } for (int i = 0; i < classes.size(); i++) @@ -578,7 +578,7 @@ void Fgd::processClassInheritance() std::vector newSpawnflags; std::set addedKeys; std::set addedSpawnflags; - //logf << classes[i]->name << " INHERITS FROM: "; + //print_log << classes[i]->name << " INHERITS FROM: "; for (int k = (int)allBaseClasses.size() - 1; k >= 0; k--) { if (!classes[i]->colorSet && allBaseClasses[k]->colorSet) @@ -613,7 +613,7 @@ void Fgd::processClassInheritance() } } } - //logf << allBaseClasses[k]->name << " "; + //print_log << allBaseClasses[k]->name << " "; } for (int c = 0; c < classes[i]->keyvalues.size(); c++) @@ -738,7 +738,7 @@ void FgdClass::getBaseClasses(Fgd* fgd, std::vector& inheritanceList) { if (fgd->classMap.find(baseClasses[i]) == fgd->classMap.end()) { - logf(get_localized_string(LANG_0310), baseClasses[i], name); + print_log(get_localized_string(LANG_0310), baseClasses[i], name); continue; } inheritanceList.push_back(fgd->classMap[baseClasses[i]]); @@ -827,7 +827,7 @@ void Fgd::setSpawnflagNames() if (!choice.isInteger) { - logf(get_localized_string(LANG_0311), choice.svalue, name); + print_log(get_localized_string(LANG_0311), choice.svalue, name); continue; } @@ -840,7 +840,7 @@ void Fgd::setSpawnflagNames() if (bit > 31) { - logf(get_localized_string(LANG_0312), choice.svalue, name); + print_log(get_localized_string(LANG_0312), choice.svalue, name); } else { diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 14881f51..d0d263f4 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -78,7 +78,6 @@ void Gui::init() imgui_io->ConfigWindowsMoveFromTitleBarOnly = true; - clearLog(); // load icons unsigned char* icon_data = NULL; unsigned int w, h; @@ -91,6 +90,15 @@ void Gui::init() faceIconTexture->upload(GL_RGBA); } +ImVec4 imguiColorFromConsole(unsigned short colors) +{ + bool intensity = (colors & PRINT_INTENSITY) != 0; + float red = (colors & PRINT_RED) ? (intensity ? 1.0f : 0.5f) : 0.0f; + float green = (colors & PRINT_GREEN) ? (intensity ? 1.0f : 0.5f) : 0.0f; + float blue = (colors & PRINT_BLUE) ? (intensity ? 1.0f : 0.5f) : 0.0f; + return ImVec4(red, green, blue, 1.0f); +} + void Gui::draw() { Bsp* map = app->getSelectedMap(); @@ -231,12 +239,12 @@ void Gui::copyTexture() Bsp* map = app->getSelectedMap(); if (!map) { - logf(get_localized_string(LANG_0313)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0313)); return; } else if (app->pickInfo.selectedFaces.size() == 0 || app->pickInfo.selectedFaces.size() > 1) { - logf(get_localized_string(LANG_0314)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0314)); return; } BSPTEXTUREINFO& texinfo = map->texinfos[map->faces[app->pickInfo.selectedFaces[0]].iTextureInfo]; @@ -254,12 +262,12 @@ void Gui::copyLightmap() if (!map) { - logf(get_localized_string(LANG_1049)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1049)); return; } else if (app->pickInfo.selectedFaces.size() == 0 || app->pickInfo.selectedFaces.size() > 1) { - logf(get_localized_string(LANG_1050)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1050)); return; } @@ -279,12 +287,12 @@ void Gui::pasteLightmap() Bsp* map = app->getSelectedMap(); if (!map) { - logf(get_localized_string(LANG_1149)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1149)); return; } else if (app->pickInfo.selectedFaces.size() == 0 || app->pickInfo.selectedFaces.size() > 1) { - logf(get_localized_string(LANG_1150)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1150)); return; } int faceIdx = app->pickInfo.selectedFaces[0]; @@ -299,7 +307,7 @@ void Gui::pasteLightmap() if (dstLightmap.width != copiedLightmap.width || dstLightmap.height != copiedLightmap.height) { - logf("WARNING: lightmap sizes don't match ({}x{} != {}{})", + print_log(PRINT_RED | PRINT_INTENSITY, "WARNING: lightmap sizes don't match ({}x{} != {}{})", copiedLightmap.width, copiedLightmap.height, dstLightmap.width, @@ -317,12 +325,12 @@ void Gui::pasteLightmap() void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) { - logf(get_localized_string(LANG_0315)); + print_log(get_localized_string(LANG_0315)); src_map->update_ent_lump(); src_map->update_lump_pointers(); src_map->write(src_map->bsp_path + ".tmp.bsp"); - logf(get_localized_string(LANG_0316)); + print_log(get_localized_string(LANG_0316)); Bsp* tmpMap = new Bsp(src_map->bsp_path + ".tmp.bsp"); @@ -339,7 +347,7 @@ void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) tmpMap->bsp_header.nVersion = 30; } - logf(get_localized_string(LANG_0317)); + print_log(get_localized_string(LANG_0317)); removeFile(src_map->bsp_path + ".tmp.bsp"); vec3 modelOrigin = tmpMap->get_model_center(id); @@ -348,12 +356,12 @@ void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) while (tmpMap->modelCount < 2) { - logf(get_localized_string(LANG_0318)); + print_log(get_localized_string(LANG_0318)); tmpMap->create_model(); } tmpMap->models[1] = tmpModel; - logf(get_localized_string(LANG_0319)); + print_log(get_localized_string(LANG_0319)); tmpMap->models[0] = tmpModel; tmpMap->models[0].nVisLeafs = 0; tmpMap->models[0].iHeadnodes[0] = tmpMap->models[0].iHeadnodes[1] = @@ -363,7 +371,7 @@ void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) { delete tmpMap->ents[i]; } - logf(get_localized_string(LANG_0320)); + print_log(get_localized_string(LANG_0320)); Entity* tmpEnt = new Entity("worldspawn"); Entity* tmpEnt2 = new Entity("func_wall"); @@ -373,7 +381,7 @@ void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) tmpEnt2->setOrAddKeyvalue("model", "*1"); - logf(get_localized_string(LANG_0321)); + print_log(get_localized_string(LANG_0321)); tmpMap->modelCount = 2; tmpMap->lumps[LUMP_MODELS] = (unsigned char*)tmpMap->models; tmpMap->bsp_header.lump[LUMP_MODELS].nLength = sizeof(BSPMODEL) * 2; @@ -385,25 +393,25 @@ void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) tmpMap->update_ent_lump(); tmpMap->update_lump_pointers(); - logf(get_localized_string(LANG_0322)); + print_log(get_localized_string(LANG_0322)); STRUCTCOUNT removed = tmpMap->remove_unused_model_structures(CLEAN_LIGHTMAP | CLEAN_PLANES | CLEAN_NODES | CLEAN_CLIPNODES | CLEAN_CLIPNODES_SOMETHING | CLEAN_LEAVES | CLEAN_FACES | CLEAN_SURFEDGES | CLEAN_TEXINFOS | CLEAN_EDGES | CLEAN_VERTICES | CLEAN_TEXTURES | CLEAN_VISDATA); if (!removed.allZero()) removed.print_delete_stats(1); - logf(get_localized_string(LANG_0323)); + print_log(get_localized_string(LANG_0323)); tmpMap->modelCount = 1; tmpMap->models[0] = tmpMap->models[1]; tmpMap->lumps[LUMP_MODELS] = (unsigned char*)tmpMap->models; tmpMap->bsp_header.lump[LUMP_MODELS].nLength = sizeof(BSPMODEL); - logf(get_localized_string(LANG_0324)); + print_log(get_localized_string(LANG_0324)); tmpMap->ents.clear(); tmpMap->ents.push_back(tmpEnt); tmpMap->update_ent_lump(); tmpMap->update_lump_pointers(); - logf(get_localized_string(LANG_0325)); + print_log(get_localized_string(LANG_0325)); /*int markid = 0; for (int i = 0; i < tmpMap->leafCount; i++) @@ -424,10 +432,10 @@ void ExportModel(Bsp* src_map, int id, int ExportType, bool movemodel) tmpMap->update_lump_pointers(); - logf(get_localized_string(LANG_0326)); + print_log(get_localized_string(LANG_0326)); remove_unused_wad_files(src_map, tmpMap, ExportType); - logf(get_localized_string(LANG_0327)); + print_log(get_localized_string(LANG_0327)); removed = tmpMap->remove_unused_model_structures(CLEAN_LIGHTMAP | CLEAN_PLANES | CLEAN_NODES | CLEAN_CLIPNODES | CLEAN_CLIPNODES_SOMETHING | CLEAN_LEAVES | CLEAN_FACES | CLEAN_SURFEDGES | CLEAN_TEXINFOS | CLEAN_EDGES | CLEAN_VERTICES | CLEAN_TEXTURES | CLEAN_VISDATA | CLEAN_MARKSURFACES); @@ -641,7 +649,7 @@ void Gui::draw3dContextMenus() { map->regenerate_clipnodes(modelIdx, -1); checkValidHulls(); - logf(get_localized_string(LANG_0328), modelIdx); + print_log(get_localized_string(LANG_0328), modelIdx); } ImGui::Separator(); @@ -652,7 +660,7 @@ void Gui::draw3dContextMenus() { map->regenerate_clipnodes(modelIdx, i); checkValidHulls(); - logf(get_localized_string(LANG_0329), i, modelIdx); + print_log(get_localized_string(LANG_0329), i, modelIdx); } } ImGui::EndMenu(); @@ -668,7 +676,7 @@ void Gui::draw3dContextMenus() map->delete_hull(3, modelIdx, -1); map->getBspRender()->refreshModel(modelIdx); checkValidHulls(); - logf(get_localized_string(LANG_0330), modelIdx); + print_log(get_localized_string(LANG_0330), modelIdx); } if (ImGui::MenuItem(get_localized_string(LANG_1069).c_str())) { @@ -677,7 +685,7 @@ void Gui::draw3dContextMenus() map->delete_hull(3, modelIdx, -1); map->getBspRender()->refreshModelClipnodes(modelIdx); checkValidHulls(); - logf(get_localized_string(LANG_0331), modelIdx); + print_log(get_localized_string(LANG_0331), modelIdx); } ImGui::Separator(); @@ -694,7 +702,7 @@ void Gui::draw3dContextMenus() map->getBspRender()->refreshModel(modelIdx); else map->getBspRender()->refreshModelClipnodes(modelIdx); - logf(get_localized_string(LANG_0332), i, modelIdx); + print_log(get_localized_string(LANG_0332), i, modelIdx); } } @@ -709,7 +717,7 @@ void Gui::draw3dContextMenus() map->simplify_model_collision(modelIdx, 2); map->simplify_model_collision(modelIdx, 3); map->getBspRender()->refreshModelClipnodes(modelIdx); - logf(get_localized_string(LANG_0333), modelIdx); + print_log(get_localized_string(LANG_0333), modelIdx); } ImGui::Separator(); @@ -722,7 +730,7 @@ void Gui::draw3dContextMenus() { map->simplify_model_collision(modelIdx, 1); map->getBspRender()->refreshModelClipnodes(modelIdx); - logf(get_localized_string(LANG_0334), i, modelIdx); + print_log(get_localized_string(LANG_0334), i, modelIdx); } } @@ -750,7 +758,7 @@ void Gui::draw3dContextMenus() map->models[modelIdx].iHeadnodes[i] = map->models[modelIdx].iHeadnodes[k]; map->getBspRender()->refreshModelClipnodes(modelIdx); checkValidHulls(); - logf(get_localized_string(LANG_0335), i, k, modelIdx); + print_log(get_localized_string(LANG_0335), i, k, modelIdx); } } @@ -804,7 +812,7 @@ void Gui::draw3dContextMenus() { if (ImGui::MenuItem(get_localized_string(LANG_0464).c_str(), 0, false, !app->isLoading && allowDuplicate)) { - logf(get_localized_string(LANG_0336), app->pickInfo.selectedEnts.size()); + print_log(get_localized_string(LANG_0336), app->pickInfo.selectedEnts.size()); for (auto& tmpEntIdx : app->pickInfo.selectedEnts) { DuplicateBspModelCommand* command = new DuplicateBspModelCommand("Duplicate BSP Model", tmpEntIdx); @@ -937,7 +945,7 @@ bool ExportWad(Bsp* map) else { retval = false; - logf(get_localized_string(LANG_0337)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0337)); } tmpWadTex.clear(); delete tmpWad; @@ -945,7 +953,7 @@ bool ExportWad(Bsp* map) else { retval = false; - logf(get_localized_string(LANG_0338)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0338)); } return retval; } @@ -956,7 +964,7 @@ void ImportWad(Bsp* map, Renderer* app, std::string path) if (!tmpWad->readInfo()) { - logf(get_localized_string(LANG_0339)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0339)); delete tmpWad; return; } @@ -1050,7 +1058,7 @@ void Gui::drawMenuBar() if (tmppath.find(basename(pathlowercase)) != std::string::npos) { foundInMap = true; - logf(get_localized_string(LANG_0340)); + print_log(get_localized_string(LANG_0340)); break; } } @@ -1140,7 +1148,7 @@ void Gui::drawMenuBar() } else { - logf(get_localized_string(LANG_0341)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0341)); } } } @@ -1188,7 +1196,7 @@ void Gui::drawMenuBar() } else { - logf(get_localized_string(LANG_1051)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1051)); } } } @@ -1778,7 +1786,7 @@ void Gui::drawMenuBar() createDir(g_working_dir); } - logf(get_localized_string(LANG_0342), entFilePath); + print_log(get_localized_string(LANG_0342), entFilePath); std::ofstream entFile(entFilePath, std::ios::trunc); map->update_ent_lump(); if (map->bsp_header.lump[LUMP_ENTITIES].nLength > 0) @@ -1789,10 +1797,10 @@ void Gui::drawMenuBar() } if (ImGui::MenuItem(get_localized_string(LANG_0534).c_str(), NULL, false, map && !map->is_mdl_model)) { - logf(get_localized_string(LANG_0343), g_working_dir, map->bsp_name + ".wad"); + print_log(get_localized_string(LANG_0343), g_working_dir, map->bsp_name + ".wad"); if (ExportWad(map)) { - logf(get_localized_string(LANG_0344)); + print_log(get_localized_string(LANG_0344)); map->delete_embedded_textures(); if (map->ents.size()) { @@ -1954,7 +1962,7 @@ void Gui::drawMenuBar() hash += "1"; if (ImGui::MenuItem((basename(wad->filename) + hash).c_str())) { - logf(get_localized_string(LANG_0345), basename(wad->filename)); + print_log(get_localized_string(LANG_0345), basename(wad->filename)); createDir(g_working_dir + "wads/" + basename(wad->filename)); @@ -1971,7 +1979,7 @@ void Gui::drawMenuBar() if (texture->szName[0] != '\0') { - logf(get_localized_string(LANG_0346), texture->szName, basename(wad->filename)); + print_log(get_localized_string(LANG_0346), texture->szName, basename(wad->filename)); COLOR4* texturedata = ConvertWadTexToRGBA(texture); lodepng_encode32_file((g_working_dir + "wads/" + basename(wad->filename) + "/" + std::string(texture->szName) + ".png").c_str() @@ -2046,7 +2054,7 @@ void Gui::drawMenuBar() } else { - logf(get_localized_string(LANG_0347)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0347)); } } @@ -2076,7 +2084,7 @@ void Gui::drawMenuBar() entFilePath = g_working_dir + (map->bsp_name + ".ent"); } - logf(get_localized_string(LANG_1052), entFilePath); + print_log(get_localized_string(LANG_1052), entFilePath); if (fileExists(entFilePath)) { int len; @@ -2091,7 +2099,7 @@ void Gui::drawMenuBar() } else { - logf(get_localized_string(LANG_0348)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0348)); } } } @@ -2126,10 +2134,10 @@ void Gui::drawMenuBar() hash += "1"; if (ImGui::MenuItem((basename(wad->filename) + hash).c_str())) { - logf(get_localized_string(LANG_0350), basename(wad->filename)); + print_log(get_localized_string(LANG_0350), basename(wad->filename)); if (!dirExists(g_working_dir + "wads/" + basename(wad->filename))) { - logf(get_localized_string(LANG_0351), g_working_dir + "wads/" + basename(wad->filename)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0351), g_working_dir + "wads/" + basename(wad->filename)); } else { @@ -2156,8 +2164,7 @@ void Gui::drawMenuBar() std::for_each(std::execution::par_unseq, files.begin(), files.end(), [&](const auto file) { - - logf(get_localized_string(LANG_0352), basename(file), basename(wad->filename)); + print_log(get_localized_string(LANG_0352), basename(file), basename(wad->filename)); COLOR4* image_bytes = NULL; unsigned int w2, h2; auto error = lodepng_decode_file((unsigned char**)&image_bytes, &w2, &h2, file.c_str(), @@ -2182,7 +2189,7 @@ void Gui::drawMenuBar() int oldcolors = 0; if ((oldcolors = GetImageColors((COLOR3*)image_bytes, w2 * h2)) > 256) { - logf(get_localized_string(LANG_0353), basename(file)); + print_log(get_localized_string(LANG_0353), basename(file)); Quantizer* tmpCQuantizer = new Quantizer(256, 8); if (ditheringEnabled) @@ -2190,7 +2197,7 @@ void Gui::drawMenuBar() else tmpCQuantizer->ApplyColorTable((COLOR3*)image_bytes, w2 * h2); - logf(get_localized_string(LANG_0354), oldcolors, GetImageColors((COLOR3*)image_bytes, w2 * h2)); + print_log(get_localized_string(LANG_0354), oldcolors, GetImageColors((COLOR3*)image_bytes, w2 * h2)); delete tmpCQuantizer; } @@ -2203,7 +2210,7 @@ void Gui::drawMenuBar() free(image_bytes); } }); - logf(get_localized_string(LANG_0355)); + print_log(get_localized_string(LANG_0355)); tmpWad->write(textureList); delete tmpWad; @@ -2231,13 +2238,13 @@ void Gui::drawMenuBar() std::ofstream entFile(entPath, std::ios::trunc); if (entFile.is_open()) { - logf(get_localized_string(LANG_1053), entPath); + print_log(get_localized_string(LANG_1053), entPath); entFile.write((const char*)map->lumps[LUMP_ENTITIES], map->bsp_header.lump[LUMP_ENTITIES].nLength - 1); } else { - logf(get_localized_string(LANG_0356), entPath); - logf(get_localized_string(LANG_0357)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0356), entPath); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0357)); } } if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay) @@ -2256,7 +2263,7 @@ void Gui::drawMenuBar() { if (map) { - logf(get_localized_string(LANG_0358), map->bsp_name); + print_log(get_localized_string(LANG_0358), map->bsp_name); map->validate(); } } @@ -2281,7 +2288,7 @@ void Gui::drawMenuBar() g_settings.save(); if (fileSize(g_settings_path) == 0) { - logf(get_localized_string(LANG_0359)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0359)); } else { @@ -2386,7 +2393,7 @@ void Gui::drawMenuBar() if (ImGui::MenuItem(get_localized_string(LANG_1087).c_str(), 0, false, !app->isLoading && allowDuplicate)) { - logf(get_localized_string(LANG_1054), app->pickInfo.selectedEnts.size()); + print_log(get_localized_string(LANG_1054), app->pickInfo.selectedEnts.size()); for (auto& ent : app->pickInfo.selectedEnts) { DuplicateBspModelCommand* command = new DuplicateBspModelCommand("Duplicate BSP Model", ent); @@ -2484,7 +2491,7 @@ void Gui::drawMenuBar() map->delete_hull(i, -1); map->getBspRender()->reloadClipnodes(); // app->mapRenderers[k]->reloadClipnodes(); - logf(get_localized_string(LANG_0360), i, map->bsp_name); + print_log(get_localized_string(LANG_0360), i, map->bsp_name); //} checkValidHulls(); } @@ -2509,7 +2516,7 @@ void Gui::drawMenuBar() map->delete_hull(i, k); map->getBspRender()->reloadClipnodes(); // app->mapRenderers[j]->reloadClipnodes(); - logf(get_localized_string(LANG_0361), i, k, map->bsp_name); + print_log(get_localized_string(LANG_0361), i, k, map->bsp_name); //} checkValidHulls(); } @@ -2554,7 +2561,7 @@ void Gui::drawMenuBar() { if (map->leaves[i].nMins[n] > map->leaves[i].nMaxs[n]) { - logf(get_localized_string(LANG_0362), i); + print_log(get_localized_string(LANG_0362), i); std::swap(map->leaves[i].nMins[n], map->leaves[i].nMaxs[n]); } } @@ -2574,7 +2581,7 @@ void Gui::drawMenuBar() { if (map->models[i].nMins[n] > map->models[i].nMaxs[n]) { - logf(get_localized_string(LANG_0363), i); + print_log(get_localized_string(LANG_0363), i); std::swap(map->models[i].nMins[n], map->models[i].nMaxs[n]); } } @@ -2660,11 +2667,11 @@ void Gui::drawMenuBar() BSPMIPTEX* tex = (BSPMIPTEX*)(map->textures + texOffset); if (tex->szName[0] == '\0' || strlen(tex->szName) >= MAXTEXTURENAME) { - logf(get_localized_string(LANG_1055), i); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1055), i); } if (tex->nOffsets[0] > 0 && dataOffset + texOffset + texlen > map->bsp_header.lump[LUMP_TEXTURES].nLength) { - logf(get_localized_string(LANG_0364), i, map->bsp_header.lump[LUMP_TEXTURES].nLength, dataOffset + texOffset + texlen); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0364), i, map->bsp_header.lump[LUMP_TEXTURES].nLength, dataOffset + texOffset + texlen); char* newlump = new char[dataOffset + texOffset + texlen]; memset(newlump, 0, dataOffset + texOffset + texlen); @@ -2718,7 +2725,7 @@ void Gui::drawMenuBar() } else if (tex.nOffsets[0] <= 0) { - logf(get_localized_string(LANG_0365), i); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0365), i); memset(tex.szName, 0, MAXTEXTURENAME); memcpy(tex.szName, "aaatrigger", 10); } @@ -3615,7 +3622,7 @@ void Gui::drawDebugWidget() } if (mapTexsUsage.size()) - logf(get_localized_string(LANG_0396), (int)mapTexsUsage.size()); + print_log(get_localized_string(LANG_0396), (int)mapTexsUsage.size()); } ImGui::End(); @@ -3696,7 +3703,7 @@ void Gui::drawTextureBrowser() { ImGui::Dummy(ImVec2(0, 10)); ImGuiListClipper clipper; - clipper.Begin(LineOffsets.Size, 30.0f); + clipper.Begin(1, 30.0f); while (clipper.Step()) { @@ -3708,7 +3715,7 @@ void Gui::drawTextureBrowser() { ImGui::Dummy(ImVec2(0, 10)); ImGuiListClipper clipper; - clipper.Begin(LineOffsets.Size, 30.0f); + clipper.Begin(1, 30.0f); while (clipper.Step()) { @@ -3725,7 +3732,7 @@ void Gui::drawTextureBrowser() { ImGui::Dummy(ImVec2(0, 10)); ImGuiListClipper clipper; - clipper.Begin(LineOffsets.Size, 30.0f); + clipper.Begin(1, 30.0f); while (clipper.Step()) { @@ -5126,7 +5133,7 @@ void Gui::drawTransformWidget() } else if (app->transformTarget == TRANSFORM_ORIGIN) { - logf(get_localized_string(LANG_0397)); + print_log(get_localized_string(LANG_0397)); } } } @@ -5137,22 +5144,6 @@ void Gui::drawTransformWidget() ImGui::End(); } -void Gui::clearLog() -{ - Buf.clear(); - LineOffsets.clear(); - LineOffsets.push_back(0); -} - -void Gui::addLog(const char* s) -{ - int old_size = Buf.size(); - Buf.append(s); - for (int new_size = Buf.size(); old_size < new_size; old_size++) - if (Buf[old_size] == '\n') - LineOffsets.push_back(old_size + 1); -} - void Gui::loadFonts() { // data copied to new array so that ImGui doesn't delete static data @@ -5188,6 +5179,8 @@ void Gui::loadFonts() void Gui::drawLog() { + static bool AutoScroll = true; // Keep scrolling if already at the bottom + ImGui::SetNextWindowSize(ImVec2(750.f, 300.f), ImGuiCond_FirstUseEver); ImGui::SetNextWindowSizeConstraints(ImVec2(200.f, 100.f), ImVec2(FLT_MAX, app->windowHeight - 40.f)); if (!ImGui::Begin(get_localized_string(LANG_1164).c_str(), &showLogWidget)) @@ -5196,15 +5189,26 @@ void Gui::drawLog() return; } - g_mutex_list[4].lock(); - for (int i = 0; i < g_log_buffer.size(); i++) + static std::vector log_buffer_copy; + static std::vector color_buffer_copy; + static int real_string_count = 0; + + g_mutex_list[0].lock(); + if (log_buffer_copy.size() != g_log_buffer.size()) { - addLog(g_log_buffer[i].c_str()); + log_buffer_copy = g_log_buffer; + color_buffer_copy = g_color_buffer; + real_string_count = 0; + for (size_t line_no = 0; line_no < log_buffer_copy.size(); line_no++) + { + real_string_count++; + if (line_no + 1 < log_buffer_copy.size() && log_buffer_copy[line_no].size() && log_buffer_copy[line_no][log_buffer_copy[line_no].size() - 1] != '\n') + { + real_string_count--; + } + } } - g_log_buffer.clear(); - g_mutex_list[4].unlock(); - - static int i = 0; + g_mutex_list[0].unlock(); ImGui::BeginChild(get_localized_string(LANG_0706).c_str(), ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); @@ -5218,7 +5222,10 @@ void Gui::drawLog() } if (ImGui::MenuItem(get_localized_string(LANG_0707).c_str())) { - clearLog(); + g_mutex_list[0].lock(); + g_log_buffer.clear(); + g_color_buffer.clear(); + g_mutex_list[0].unlock(); } if (ImGui::MenuItem(get_localized_string(LANG_0708).c_str(), NULL, &AutoScroll)) { @@ -5229,26 +5236,37 @@ void Gui::drawLog() ImGui::PushFont(consoleFont); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - const char* buf = Buf.begin(); - const char* buf_end = Buf.end(); - if (copy) ImGui::LogBegin(ImGuiLogType_Clipboard, 0); + + if (copy) + { + std::string logStr; + for (const auto& str : log_buffer_copy) { + logStr += str; + } + + ImGui::SetClipboardText(logStr.c_str()); + } ImGuiListClipper clipper; - clipper.Begin(LineOffsets.Size); + clipper.Begin(real_string_count, ImGui::GetTextLineHeight()); while (clipper.Step()) { - for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++) + for (int line_no = clipper.DisplayStart; line_no < log_buffer_copy.size(); line_no++) { - const char* line_start = buf + LineOffsets[line_no]; - const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end; - ImGui::TextUnformatted(line_start, line_end); + ImGui::PushStyleColor(ImGuiCol_Text, imguiColorFromConsole(color_buffer_copy[line_no])); + clipper.ItemsHeight = ImGui::GetTextLineHeight(); + ImGui::TextUnformatted(log_buffer_copy[line_no].c_str()); + if (line_no + 1 < log_buffer_copy.size() && log_buffer_copy[line_no].size() && log_buffer_copy[line_no][log_buffer_copy[line_no].size() - 1] != '\n') + { + clipper.ItemsHeight = 0.0f; + ImGui::SameLine(); + } + ImGui::PopStyleColor(); } } clipper.End(); - if (copy) ImGui::LogFinish(); - ImGui::PopFont(); ImGui::PopStyleVar(); @@ -5257,7 +5275,6 @@ void Gui::drawLog() ImGui::EndChild(); ImGui::End(); - } void Gui::drawSettings() @@ -6139,16 +6156,16 @@ void Gui::drawMergeWindow() for (auto& map : maps) delete map; maps.clear(); - logf(get_localized_string(LANG_1056)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1056)); } else { for (int i = 0; i < maps.size(); i++) { - logf(get_localized_string(LANG_1057), maps[i]->bsp_name); + print_log(get_localized_string(LANG_1057), maps[i]->bsp_name); if (DeleteUnusedInfo) { - logf(get_localized_string(LANG_1058)); + print_log(get_localized_string(LANG_1058)); STRUCTCOUNT removed = maps[i]->remove_unused_model_structures(); g_progress.clear(); removed.print_delete_stats(2); @@ -6156,25 +6173,25 @@ void Gui::drawMergeWindow() if (DeleteHull2 || (Optimize && !maps[i]->has_hull2_ents())) { - logf(get_localized_string(LANG_1059)); + print_log(get_localized_string(LANG_1059)); maps[i]->delete_hull(2, 1); maps[i]->remove_unused_model_structures().print_delete_stats(2); } if (Optimize) { - logf(get_localized_string(LANG_1060)); + print_log(get_localized_string(LANG_1060)); maps[i]->delete_unused_hulls().print_delete_stats(2); } - logf("\n"); + print_log("\n"); } BspMerger merger; Bsp* result = merger.merge(maps, vec3(), outPath, NoRipent, NoScript); - logf("\n"); + print_log("\n"); if (result->isValid()) result->write(outPath); - logf("\n"); + print_log("\n"); result->print_info(false, 0, 0); app->clearMaps(); @@ -6188,7 +6205,7 @@ void Gui::drawMergeWindow() } else { - logf(get_localized_string(LANG_0398)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0398)); app->addMap(new Bsp()); } @@ -6254,7 +6271,7 @@ void Gui::drawImportMapWidget() fixupPath(mapPath, FIXUPPATH_SLASH::FIXUPPATH_SLASH_SKIP, FIXUPPATH_SLASH::FIXUPPATH_SLASH_SKIP); if (fileExists(mapPath)) { - logf(get_localized_string(LANG_0399), mapPath); + print_log(get_localized_string(LANG_0399), mapPath); showImportMapWidget = false; if (showImportMapWidget_Type == SHOW_IMPORT_ADD_NEW) { @@ -6405,11 +6422,11 @@ void Gui::drawImportMapWidget() Bsp* model = new Bsp(mapPath); if (!model->ents.size()) { - logf(get_localized_string(LANG_0400)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0400)); } else { - logf(get_localized_string(LANG_0401)); + print_log(get_localized_string(LANG_0401)); Entity* tmpEnt = new Entity("func_breakable"); tmpEnt->setOrAddKeyvalue("gibmodel", std::string("models/") + basename(mapPath)); tmpEnt->setOrAddKeyvalue("model", std::string("models/") + basename(mapPath)); @@ -6417,7 +6434,7 @@ void Gui::drawImportMapWidget() tmpEnt->setOrAddKeyvalue("origin", cameraOrigin.toKeyvalueString()); map->ents.push_back(tmpEnt); map->update_ent_lump(); - logf(get_localized_string(LANG_0402), std::string("models/") + basename(mapPath)); + print_log(get_localized_string(LANG_0402), std::string("models/") + basename(mapPath)); app->updateEnts(); app->reloadBspModels(); } @@ -6427,7 +6444,7 @@ void Gui::drawImportMapWidget() } else { - logf(get_localized_string(LANG_0403)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0403)); } } } @@ -7405,7 +7422,7 @@ void ImportOneBigLightmapFile(Bsp* map) { if (!faces_to_export.size()) { - logf(get_localized_string(LANG_0405), map->faceCount); + print_log(get_localized_string(LANG_0405), map->faceCount); for (int faceIdx = 0; faceIdx < map->faceCount; faceIdx++) { faces_to_export.push_back(faceIdx); @@ -7418,7 +7435,7 @@ void ImportOneBigLightmapFile(Bsp* map) int current_x = 0; int current_y = 0; int max_y_found = 0; - //logf(get_localized_string(LANG_0406),lightId); + //print_log(get_localized_string(LANG_0406),lightId); std::string filename = fmt::format(fmt::runtime(get_localized_string(LANG_0407)), g_working_dir.c_str(), get_localized_string(LANG_0408), lightId); unsigned char* image_bytes; unsigned int w2, h2; @@ -7428,7 +7445,7 @@ void ImportOneBigLightmapFile(Bsp* map) { /*for (int i = 0; i < 100; i++) { - logf("{}/", image_bytes[i]); + print_log("{}/", image_bytes[i]); }*/ colordata.clear(); colordata.resize(w2 * h2); @@ -7491,12 +7508,12 @@ void Gui::ExportOneBigLightmap(Bsp* map) if (app->pickInfo.selectedFaces.size() > 1) { - logf(get_localized_string(LANG_0409), (unsigned int)app->pickInfo.selectedFaces.size()); + print_log(get_localized_string(LANG_0409), (unsigned int)app->pickInfo.selectedFaces.size()); faces_to_export = app->pickInfo.selectedFaces; } else { - logf(get_localized_string(LANG_0410), map->faceCount); + print_log(get_localized_string(LANG_0410), map->faceCount); for (int faceIdx = 0; faceIdx < map->faceCount; faceIdx++) { faces_to_export.push_back(faceIdx); @@ -7547,7 +7564,7 @@ void Gui::ExportOneBigLightmap(Bsp* map) bool found_any_lightmap = false; - //logf(get_localized_string(LANG_0411),lightId); + //print_log(get_localized_string(LANG_0411),lightId); for (int faceIdx : faces_to_export) { int size[2]; @@ -7582,7 +7599,7 @@ void Gui::ExportOneBigLightmap(Bsp* map) if (found_any_lightmap) { filename = fmt::format(fmt::runtime(get_localized_string(LANG_1061)), g_working_dir.c_str(), get_localized_string(LANG_1062), lightId); - logf(get_localized_string(LANG_0412), filename); + print_log(get_localized_string(LANG_0412), filename); lodepng_encode24_file(filename.c_str(), (const unsigned char*)colordata.data(), LMapMaxWidth, current_y + max_y_found); } } @@ -7602,7 +7619,7 @@ void ExportLightmap(BSPFACE32 face, int faceIdx, Bsp* map) int lightmapSz = size[0] * size[1] * sizeof(COLOR3); int offset = face.nLightmapOffset + i * lightmapSz; filename = fmt::format(fmt::runtime(get_localized_string(LANG_0413)), g_working_dir.c_str(), get_localized_string(LANG_0408), faceIdx, i); - logf(get_localized_string(LANG_0414), filename); + print_log(get_localized_string(LANG_0414), filename); lodepng_encode24_file(filename.c_str(), (unsigned char*)(map->lightdata + offset), size[0], size[1]); } } @@ -7621,7 +7638,7 @@ void ImportLightmap(BSPFACE32 face, int faceIdx, Bsp* map) filename = fmt::format(fmt::runtime(get_localized_string(LANG_1063)), g_working_dir.c_str(), get_localized_string(LANG_1062), faceIdx, i); unsigned int w = size[0], h = size[1]; unsigned int w2 = 0, h2 = 0; - logf(get_localized_string(LANG_0415), filename); + print_log(get_localized_string(LANG_0415), filename); unsigned char* image_bytes = NULL; auto error = lodepng_decode24_file(&image_bytes, &w2, &h2, filename.c_str()); if (error == 0 && image_bytes) @@ -7632,13 +7649,13 @@ void ImportLightmap(BSPFACE32 face, int faceIdx, Bsp* map) } else { - logf(get_localized_string(LANG_0416), w, h); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0416), w, h); } free(image_bytes); } else { - logf(get_localized_string(LANG_0417)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0417)); } } } @@ -7700,7 +7717,7 @@ void Gui::drawLightMapTool() memcpy(currentlightMap[i]->data, map->lightdata + offset, lightmapSz); currentlightMap[i]->upload(GL_RGB, true); lightmaps++; - //logf(get_localized_string(LANG_0418),i,offset); + //print_log(get_localized_string(LANG_0418),i,offset); } } @@ -7836,14 +7853,14 @@ void Gui::drawLightMapTool() ImGui::Separator(); if (ImGui::Button(get_localized_string(LANG_1128).c_str(), ImVec2(120, 0))) { - logf(get_localized_string(LANG_0420)); + print_log(get_localized_string(LANG_0420)); createDir(g_working_dir); ExportLightmap(face, faceIdx, map); } ImGui::SameLine(); if (ImGui::Button(get_localized_string(LANG_1129).c_str(), ImVec2(120, 0))) { - logf(get_localized_string(LANG_0421)); + print_log(get_localized_string(LANG_0421)); ImportLightmap(face, faceIdx, map); showLightmapEditorUpdate = true; map->getBspRender()->reloadLightmaps(); @@ -7854,7 +7871,7 @@ void Gui::drawLightMapTool() ImGui::Separator(); if (ImGui::Button(get_localized_string(LANG_0867).c_str(), ImVec2(125, 0))) { - logf(get_localized_string(LANG_1064)); + print_log(get_localized_string(LANG_1064)); createDir(g_working_dir); //for (int z = 0; z < map->faceCount; z++) @@ -7868,7 +7885,7 @@ void Gui::drawLightMapTool() ImGui::SameLine(); if (ImGui::Button(get_localized_string(LANG_0868).c_str(), ImVec2(125, 0))) { - logf(get_localized_string(LANG_1065)); + print_log(get_localized_string(LANG_1065)); //for (int z = 0; z < map->faceCount; z++) //{ @@ -8481,7 +8498,7 @@ StatInfo Gui::calcStat(std::string name, unsigned int val, unsigned int max, boo tmp = fmt::format("{:8.2f}", val / meg); stat.val = std::string(tmp); - tmp = fmt::format("{:5.2f} MB", max / meg); + tmp = fmt::format("{:>5.2f}", max / meg); stat.max = std::string(tmp); } else @@ -8489,7 +8506,7 @@ StatInfo Gui::calcStat(std::string name, unsigned int val, unsigned int max, boo tmp = fmt::format("{:8}", val); stat.val = std::string(tmp); - tmp = fmt::format("{:8}", max); + tmp = fmt::format("{:>8}", max); stat.max = std::string(tmp); } tmp = fmt::format("{:3.1f}%", percent); @@ -8530,7 +8547,7 @@ ModelInfo Gui::calcModelStat(Bsp* map, STRUCTUSAGE* modelInfo, unsigned int val, tmp = fmt::format("{:8.1f}", val / meg); stat.val = std::to_string(val); - tmp = fmt::format("{:>5.1f} MB", max / meg); + tmp = fmt::format("{:>5.1f}", max / meg); stat.usage = tmp; } else @@ -8592,7 +8609,7 @@ void Gui::checkFaceErrors() GetFaceLightmapSize(map, app->pickInfo.selectedFaces[i], size); if ((size[0] > MAX_SURFACE_EXTENT) || (size[1] > MAX_SURFACE_EXTENT) || size[0] < 0 || size[1] < 0) { - //logf(get_localized_string(LANG_0426),size[0],size[1]); + //print_log(get_localized_string(LANG_0426),size[0],size[1]); size[0] = std::min(size[0], MAX_SURFACE_EXTENT); size[1] = std::min(size[1], MAX_SURFACE_EXTENT); badSurfaceExtents = true; diff --git a/src/editor/Gui.h b/src/editor/Gui.h index 020ed685..04eeb5bc 100644 --- a/src/editor/Gui.h +++ b/src/editor/Gui.h @@ -117,10 +117,6 @@ class Gui LIGHTMAP copiedLightmap = LIGHTMAP(); bool refreshSelectedFaces = false; - ImGuiTextBuffer Buf = ImGuiTextBuffer(); - ImVector LineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines - bool AutoScroll = true; // Keep scrolling if already at the bottom - void draw3dContextMenus(); void drawMenuBar(); void drawToolbar(); @@ -152,9 +148,6 @@ class Gui void checkValidHulls(); void reloadLimits(); void ExportOneBigLightmap(Bsp* map); - - void clearLog(); - void addLog(const char* s); void loadFonts(); void checkFaceErrors(); }; \ No newline at end of file diff --git a/src/editor/PointEntRenderer.cpp b/src/editor/PointEntRenderer.cpp index 8c33a8d8..ff8014fc 100644 --- a/src/editor/PointEntRenderer.cpp +++ b/src/editor/PointEntRenderer.cpp @@ -74,7 +74,7 @@ void PointEntRenderer::genPointEntCubes() } } - logf(get_localized_string(LANG_0894),entCubes.size()); + print_log(get_localized_string(LANG_0894),entCubes.size()); } EntCube* PointEntRenderer::getCubeMatchingProps(EntCube* entCube) diff --git a/src/editor/Renderer.cpp b/src/editor/Renderer.cpp index 176e6987..f29de6c5 100644 --- a/src/editor/Renderer.cpp +++ b/src/editor/Renderer.cpp @@ -29,7 +29,7 @@ std::future Renderer::fgdFuture; void error_callback(int error, const char* description) { - logf(get_localized_string(LANG_0895), error, description); + print_log(get_localized_string(LANG_0895), error, description); } void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) @@ -57,27 +57,27 @@ void drop_callback(GLFWwindow* window, int count, const char** paths) { if (lowerPath.ends_with(".bsp")) { - logf(get_localized_string(LANG_0896), tmpPath.string()); + print_log(get_localized_string(LANG_0896), tmpPath.string()); g_app->addMap(new Bsp(tmpPath.string())); } else if (lowerPath.ends_with(".mdl")) { - logf(get_localized_string(LANG_0897), tmpPath.string()); + print_log(get_localized_string(LANG_0897), tmpPath.string()); g_app->addMap(new Bsp(tmpPath.string())); } else { - logf(get_localized_string(LANG_0898), tmpPath.string()); + print_log(get_localized_string(LANG_0898), tmpPath.string()); } } else { - logf(get_localized_string(LANG_0899), tmpPath.string()); + print_log(get_localized_string(LANG_0899), tmpPath.string()); } } else if (g_app->isLoading) { - logf(get_localized_string(LANG_0900)); + print_log(get_localized_string(LANG_0900)); } } @@ -115,7 +115,7 @@ void window_focus_callback(GLFWwindow* window, int focused) void window_close_callback(GLFWwindow* window) { g_settings.save(); - logf(get_localized_string(LANG_0901)); + print_log(get_localized_string(LANG_0901)); std::quick_exit(0); } @@ -134,7 +134,7 @@ Renderer::Renderer() if (!glfwInit()) { - logf(get_localized_string(LANG_0902)); + print_log(get_localized_string(LANG_0902)); return; } @@ -158,7 +158,7 @@ Renderer::Renderer() if (!window) { - logf(get_localized_string(LANG_0903)); + print_log(get_localized_string(LANG_0903)); return; } @@ -248,7 +248,7 @@ void Renderer::renderLoop() if (LIGHTMAP_ATLAS_SIZE > value) { - logf(get_localized_string(LANG_0904), value); + print_log(get_localized_string(LANG_0904), value); } { @@ -655,7 +655,7 @@ void Renderer::renderLoop() int glerror = glGetError(); while (glerror != GL_NO_ERROR) { - logf(get_localized_string(LANG_0905), glerror); + print_log(get_localized_string(LANG_0905), glerror); glerror = glGetError(); } @@ -696,7 +696,7 @@ void Renderer::postLoadFgdsAndTextures() { if (reloading) { - logf(get_localized_string(LANG_0906)); + print_log(get_localized_string(LANG_0906)); return; } reloading = reloadingGameDir = true; @@ -711,7 +711,7 @@ void Renderer::clearMaps() } mapRenderers.clear(); clearSelection(); - logf(get_localized_string(LANG_0907)); + print_log(get_localized_string(LANG_0907)); } void Renderer::reloadMaps() @@ -730,7 +730,7 @@ void Renderer::reloadMaps() } reloadBspModels(); - logf(get_localized_string(LANG_0908)); + print_log(get_localized_string(LANG_0908)); } void Renderer::saveSettings() @@ -792,7 +792,7 @@ void Renderer::loadFgds() Fgd* tmp = new Fgd(newFgdPath); if (!tmp->parse()) { - logf(get_localized_string(LANG_0909), g_settings.fgdPaths[i].path); + print_log(get_localized_string(LANG_0909), g_settings.fgdPaths[i].path); continue; } if (mergedFgd == NULL) @@ -808,7 +808,7 @@ void Renderer::loadFgds() else { FindPathInAssets(NULL, g_settings.fgdPaths[i].path, newFgdPath, true); - logf(get_localized_string(LANG_0910), g_settings.fgdPaths[i].path); + print_log(get_localized_string(LANG_0910), g_settings.fgdPaths[i].path); g_settings.fgdPaths[i].enabled = false; continue; } @@ -2148,7 +2148,7 @@ void Renderer::reloadBspModels() } else { - logf(get_localized_string(LANG_0911), modelPath); + print_log(get_localized_string(LANG_0911), modelPath); FindPathInAssets(bsprend->map, modelPath, newBspPath, true); } } @@ -2164,7 +2164,7 @@ void Renderer::addMap(Bsp* map) { if (!map->bsp_valid) { - logf(get_localized_string(LANG_0912)); + print_log(get_localized_string(LANG_0912)); return; } @@ -2596,7 +2596,7 @@ void Renderer::updateModelVerts() size_t numCubes = modelVerts.size() + modelEdges.size(); modelVertCubes = new cCube[numCubes]; modelVertBuff = new VertexBuffer(colorShader, COLOR_4B | POS_3F, modelVertCubes, (int)(6 * 6 * numCubes), GL_TRIANGLES); - //logf(get_localized_string(LANG_0913),modelVerts.size()); + //print_log(get_localized_string(LANG_0913),modelVerts.size()); } void Renderer::updateSelectionSize() @@ -2807,7 +2807,7 @@ bool Renderer::getModelSolid(std::vector& hullVerts, Bsp* map, So if (verts.size() < 2) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0914)); // hl_c00 pipe in green water place + print_log(get_localized_string(LANG_0914)); // hl_c00 pipe in green water place return false; } @@ -2878,7 +2878,7 @@ bool Renderer::getModelSolid(std::vector& hullVerts, Bsp* map, So if (planeCount != 2) { if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0915), planeCount); + print_log(get_localized_string(LANG_0915), planeCount); return false; } @@ -3111,7 +3111,7 @@ bool Renderer::splitModelFace() int entIdx = pickInfo.GetSelectedEnt(); if (!map) { - logf(get_localized_string(LANG_0916)); + print_log(get_localized_string(LANG_0916)); return false; } BspRenderer* mapRenderer = map->getBspRender(); @@ -3127,12 +3127,12 @@ bool Renderer::splitModelFace() if (selectedEdges.size() != 2) { - logf(get_localized_string(LANG_0917)); + print_log(get_localized_string(LANG_0917)); return false; } if (entIdx < 0) { - logf(get_localized_string(LANG_0918)); + print_log(get_localized_string(LANG_0918)); return false; } Entity* ent = map->ents[entIdx]; @@ -3156,7 +3156,7 @@ bool Renderer::splitModelFace() if (commonPlane == -1) { - logf(get_localized_string(LANG_0919)); + print_log(get_localized_string(LANG_0919)); return false; } @@ -3183,7 +3183,7 @@ bool Renderer::splitModelFace() } if (commonPlaneIdx == -1) { - logf(get_localized_string(LANG_0920)); + print_log(get_localized_string(LANG_0920)); return false; } @@ -3247,14 +3247,14 @@ bool Renderer::splitModelFace() std::vector newHullVerts; if (!map->getModelPlaneIntersectVerts(ent->getBspModelIdx(), modelPlanes, newHullVerts)) { - logf(get_localized_string(LANG_0921)); + print_log(get_localized_string(LANG_0921)); return false; } Solid newSolid; if (!getModelSolid(newHullVerts, map, newSolid)) { - logf(get_localized_string(LANG_0922)); + print_log(get_localized_string(LANG_0922)); return false; } @@ -3275,7 +3275,7 @@ bool Renderer::splitModelFace() if (verts.size() < 3) { - logf(get_localized_string(LANG_0923)); + print_log(get_localized_string(LANG_0923)); return false; } } @@ -3388,7 +3388,7 @@ void Renderer::scaleSelectedVerts(float x, float y, float z) } else { - logf(get_localized_string(LANG_0924)); + print_log(get_localized_string(LANG_0924)); } } @@ -3507,7 +3507,7 @@ void Renderer::pasteEnt(bool noModifyOrigin) Bsp* map = SelectedMap; if (!map) { - logf(get_localized_string(LANG_0925)); + print_log(get_localized_string(LANG_0925)); return; } diff --git a/src/editor/Settings.cpp b/src/editor/Settings.cpp index e4e9dca6..909f6d6e 100644 --- a/src/editor/Settings.cpp +++ b/src/editor/Settings.cpp @@ -165,7 +165,7 @@ void AppSettings::load() std::ifstream file(g_settings_path); if (!file.is_open()) { - logf(get_localized_string(LANG_0926),g_settings_path); + print_log(get_localized_string(LANG_0926),g_settings_path); reset(); return; } @@ -284,7 +284,7 @@ void AppSettings::load() g_settings.moveSpeed = (float)atof(val.c_str()); if (g_settings.moveSpeed < 100) { - logf(get_localized_string(LANG_0927)); + print_log(get_localized_string(LANG_0927)); g_settings.moveSpeed = 500; } } @@ -492,7 +492,7 @@ void AppSettings::load() if (lines_readed > 0) g_settings.settingLoaded = true; else - logf(get_localized_string(LANG_0928),g_settings_path); + print_log(get_localized_string(LANG_0928),g_settings_path); if (defaultIsEmpty && fgdPaths.empty()) { diff --git a/src/gl/Shader.cpp b/src/gl/Shader.cpp index 5d75125e..199532b9 100644 --- a/src/gl/Shader.cpp +++ b/src/gl/Shader.cpp @@ -18,10 +18,10 @@ Shader::Shader(const char* sourceCode, int shaderType) char* log = new char[512]; int len; glGetShaderInfoLog(ID, 512, &len, log); - logf(get_localized_string(LANG_0959),shaderType); - logf(log); + print_log(get_localized_string(LANG_0959),shaderType); + print_log(log); if (len > 512) - logf(get_localized_string(LANG_0960)); + print_log(get_localized_string(LANG_0960)); delete[] log; } } diff --git a/src/gl/ShaderProgram.cpp b/src/gl/ShaderProgram.cpp index 48a85890..8e1ad707 100644 --- a/src/gl/ShaderProgram.cpp +++ b/src/gl/ShaderProgram.cpp @@ -34,10 +34,10 @@ void ShaderProgram::link() char* log = new char[1024]; int len; glGetProgramInfoLog(ID, 1024, &len, log); - logf(get_localized_string(LANG_0961)); - logf(log); + print_log(get_localized_string(LANG_0961)); + print_log(log); if (len > 1024) - logf(get_localized_string(LANG_0962)); + print_log(get_localized_string(LANG_0962)); delete[] log; } } @@ -93,13 +93,13 @@ void ShaderProgram::setMatrixNames(const char* _modelViewMat, const char* _model { modelViewID = glGetUniformLocation(ID, _modelViewMat); if (modelViewID == -1) - logf(get_localized_string(LANG_0963),_modelViewMat); + print_log(get_localized_string(LANG_0963),_modelViewMat); } if (_modelViewProjMat) { modelViewProjID = glGetUniformLocation(ID, _modelViewProjMat); if (modelViewProjID == -1) - logf(get_localized_string(LANG_0964),_modelViewProjMat); + print_log(get_localized_string(LANG_0964),_modelViewProjMat); } } @@ -108,17 +108,17 @@ void ShaderProgram::setVertexAttributeNames(const char* posAtt, const char* colo if (posAtt) { vposID = glGetAttribLocation(ID, posAtt); - if (vposID == -1) logf(get_localized_string(LANG_0965),posAtt); + if (vposID == -1) print_log(get_localized_string(LANG_0965),posAtt); } if (colorAtt) { vcolorID = glGetAttribLocation(ID, colorAtt); - if (vcolorID == -1) logf(get_localized_string(LANG_0966),colorAtt); + if (vcolorID == -1) print_log(get_localized_string(LANG_0966),colorAtt); } if (texAtt) { vtexID = glGetAttribLocation(ID, texAtt); - if (vtexID == -1) logf(get_localized_string(LANG_0967),texAtt); + if (vtexID == -1) print_log(get_localized_string(LANG_0967),texAtt); } } @@ -143,7 +143,7 @@ void ShaderProgram::popMatrix(int matType) stack.pop_back(); } else - logf(get_localized_string(LANG_0968)); + print_log(get_localized_string(LANG_0968)); } } diff --git a/src/gl/Texture.cpp b/src/gl/Texture.cpp index d550d8d5..d132a129 100644 --- a/src/gl/Texture.cpp +++ b/src/gl/Texture.cpp @@ -20,7 +20,7 @@ Texture::Texture(GLsizei _width, GLsizei _height, const char* name) this->id = this->format = 0; snprintf(texName, 64, "%s", name); if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0969),name,width,height); + print_log(get_localized_string(LANG_0969),name,width,height); this->transparentMode = IsTextureTransparent(name) ? 1 : 0; if (name && name[0] == '{') { @@ -40,7 +40,7 @@ Texture::Texture(GLsizei _width, GLsizei _height, unsigned char* data, const cha this->id = this->format = 0; snprintf(texName, 64, "%s", name); if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0970),name,width,height); + print_log(get_localized_string(LANG_0970),name,width,height); this->transparentMode = IsTextureTransparent(name) ? 1 : 0; if (name && name[0] == '{') { @@ -116,7 +116,7 @@ void Texture::upload(int _format, bool lightmap) glTexImage2D(GL_TEXTURE_2D, 0, _format, width, height, 0, _format, GL_UNSIGNED_BYTE, data); if (g_settings.verboseLogs) - logf(get_localized_string(LANG_0971),texName,width,height); + print_log(get_localized_string(LANG_0971),texName,width,height); format = _format; uploaded = true; diff --git a/src/gl/VertexBuffer.cpp b/src/gl/VertexBuffer.cpp index 529bcc10..1e7965bb 100644 --- a/src/gl/VertexBuffer.cpp +++ b/src/gl/VertexBuffer.cpp @@ -41,7 +41,7 @@ VertexAttr::VertexAttr(int numValues, int valueType, int handle, int normalized, size = numValues * 4; break; default: - logf(get_localized_string(LANG_0972),valueType); + print_log(get_localized_string(LANG_0972),valueType); handle = -1; size = 0; } @@ -95,7 +95,7 @@ void VertexBuffer::addAttributes(int attFlags) else if (i >= VBUF_TEX_START) commonAttr[i].handle = shaderProgram->vtexID; else - logf(get_localized_string(LANG_0973),i); + print_log(get_localized_string(LANG_0973),i); attribs.push_back(commonAttr[i]); elementSize += commonAttr[i].size; @@ -119,7 +119,7 @@ void VertexBuffer::addAttribute(int type, const char* varName) { } if (idx >= VBUF_FLAGBITS) { - logf(get_localized_string(LANG_0974)); + print_log(get_localized_string(LANG_0974)); return; } @@ -161,7 +161,7 @@ void VertexBuffer::bindAttributes(bool hideErrors) { attribs[i].handle = glGetAttribLocation(shaderProgram->ID, attribs[i].varName); if ((!hideErrors || g_verbose) && attribs[i].handle == -1) - logf(get_localized_string(LANG_0975),attribs[i].varName); + print_log(get_localized_string(LANG_0975),attribs[i].varName); } attributesBound = true; @@ -235,11 +235,11 @@ void VertexBuffer::drawRange(int _primitive, int start, int end, bool hideErrors } if (start < 0 || start > numVerts || numVerts == 0) - logf(get_localized_string(LANG_0976),start,numVerts); + print_log(get_localized_string(LANG_0976),start,numVerts); else if (end > numVerts || end < 0) - logf(get_localized_string(LANG_0977),end); + print_log(get_localized_string(LANG_0977),end); else if (end - start <= 0) - logf(get_localized_string(LANG_0978),start,end); + print_log(get_localized_string(LANG_0978),start,end); else glDrawArrays(_primitive, start, end - start); diff --git a/src/main.cpp b/src/main.cpp index 93da0b36..8876e3e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -166,22 +166,22 @@ int test() } if (!maps[i]->validate()) { - logf(""); + print_log(""); } - logf(get_localized_string(LANG_0002), maps[i]->bsp_name); + print_log(get_localized_string(LANG_0002), maps[i]->bsp_name); maps[i]->delete_hull(2, 1); //removed.add(maps[i]->delete_unused_hulls()); removed.add(maps[i]->remove_unused_model_structures()); if (!maps[i]->validate()) - logf(""); + print_log(""); } removed.print_delete_stats(1); BspMerger merger; Bsp* result = merger.merge(maps, vec3(1, 1, 1), "yabma_move", false, false); - logf("\n"); + print_log("\n"); if (result) { result->write("yabma_move.bsp"); @@ -200,7 +200,7 @@ int merge_maps(CommandLine& cli) if (input_maps.size() < 2) { - logf(get_localized_string(LANG_0003)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0003)); return 1; } @@ -219,27 +219,27 @@ int merge_maps(CommandLine& cli) for (int i = 0; i < maps.size(); i++) { - logf(get_localized_string(LANG_0004), maps[i]->bsp_name); + print_log(get_localized_string(LANG_0004), maps[i]->bsp_name); - logf(get_localized_string(LANG_0005)); + print_log(get_localized_string(LANG_0005)); STRUCTCOUNT removed = maps[i]->remove_unused_model_structures(); g_progress.clear(); removed.print_delete_stats(2); if (cli.hasOption("-nohull2") || (cli.hasOption("-optimize") && !maps[i]->has_hull2_ents())) { - logf(get_localized_string(LANG_0006)); + print_log(get_localized_string(LANG_0006)); maps[i]->delete_hull(2, 1); maps[i]->remove_unused_model_structures().print_delete_stats(2); } if (cli.hasOption("-optimize")) { - logf(get_localized_string(LANG_0007)); + print_log(get_localized_string(LANG_0007)); maps[i]->delete_unused_hulls().print_delete_stats(2); } - logf("\n"); + print_log("\n"); } vec3 gap = cli.hasOption("-gap") ? cli.getOptionVector("-gap") : vec3(); @@ -249,9 +249,9 @@ int merge_maps(CommandLine& cli) BspMerger merger; Bsp* result = merger.merge(maps, gap, output_name, cli.hasOption("-noripent"), cli.hasOption("-noscript")); - logf("\n"); + print_log("\n"); if (result->isValid()) result->write(output_name); - logf("\n"); + print_log("\n"); result->print_info(false, 0, 0); for (int i = 0; i < maps.size(); i++) @@ -294,7 +294,7 @@ int print_info(CommandLine& cli) } else { - logf(get_localized_string(LANG_0008), limitName); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0008), limitName); delete map; return 0; } @@ -327,7 +327,7 @@ int noclip(CommandLine& cli) if (hull < 0 || hull >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_0009)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0009)); delete map; return 1; } @@ -337,7 +337,7 @@ int noclip(CommandLine& cli) { if (!cli.hasOption("-hull")) { - logf(get_localized_string(LANG_0010)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0010)); delete map; return 1; } @@ -345,12 +345,12 @@ int noclip(CommandLine& cli) if (redirect < 1 || redirect >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_0011)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0011)); return 1; } if (redirect == hull) { - logf(get_localized_string(LANG_0012)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0012)); return 1; } } @@ -359,10 +359,10 @@ int noclip(CommandLine& cli) if (!removed.allZero()) { - logf(get_localized_string(LANG_0013)); + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, get_localized_string(LANG_0013)); removed.print_delete_stats(1); g_progress.clear(); - logf("\n"); + print_log("\n"); } if (cli.hasOption("-model")) @@ -371,22 +371,22 @@ int noclip(CommandLine& cli) if (model < 0 || model >= map->modelCount) { - logf(get_localized_string(LANG_0014), map->modelCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0014), map->modelCount); return 1; } if (hull != -1) { if (redirect) - logf(get_localized_string(LANG_0015), hull, redirect, model); + print_log(get_localized_string(LANG_0015), hull, redirect, model); else - logf(get_localized_string(LANG_0016), hull, model); + print_log(get_localized_string(LANG_0016), hull, model); map->delete_hull(hull, model, redirect); } else { - logf(get_localized_string(LANG_0017), model); + print_log(get_localized_string(LANG_0017), model); for (int i = 1; i < MAX_MAP_HULLS; i++) { map->delete_hull(i, model, redirect); @@ -397,22 +397,22 @@ int noclip(CommandLine& cli) { if (hull == 0) { - logf(get_localized_string(LANG_0018)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0018)); delete map; - return 0; + return 1; } if (hull != -1) { if (redirect) - logf(get_localized_string(LANG_0019), hull, redirect); + print_log(get_localized_string(LANG_0019), hull, redirect); else - logf(get_localized_string(LANG_0020), hull); + print_log(get_localized_string(LANG_0020), hull); map->delete_hull(hull, redirect); } else { - logf(get_localized_string(LANG_0021), hull); + print_log(get_localized_string(LANG_0021), hull); for (int i = 1; i < MAX_MAP_HULLS; i++) { map->delete_hull(i, redirect); @@ -425,11 +425,11 @@ int noclip(CommandLine& cli) if (!removed.allZero()) removed.print_delete_stats(1); else if (redirect == 0) - logf(get_localized_string(LANG_0022)); - logf("\n"); + print_log(get_localized_string(LANG_0022)); + print_log("\n"); if (map->isValid()) map->write(cli.hasOption("-o") ? cli.getOption("-o") : map->bsp_path); - logf("\n"); + print_log("\n"); map->print_info(false, 0, 0); delete map; @@ -447,7 +447,7 @@ int simplify(CommandLine& cli) if (!cli.hasOption("-model")) { - logf(get_localized_string(LANG_0023)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0023)); delete map; return 1; } @@ -458,7 +458,7 @@ int simplify(CommandLine& cli) if (hull < 1 || hull >= MAX_MAP_HULLS) { - logf(get_localized_string(LANG_0024)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0024)); delete map; return 1; } @@ -470,27 +470,27 @@ int simplify(CommandLine& cli) if (!removed.allZero()) { - logf(get_localized_string(LANG_1017)); + print_log(get_localized_string(LANG_1017)); removed.print_delete_stats(1); g_progress.clear(); - logf("\n"); + print_log("\n"); } STRUCTCOUNT oldCounts(map); if (modelIdx < 0 || modelIdx >= map->modelCount) { - logf(get_localized_string(LANG_1018), map->modelCount); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1018), map->modelCount); return 1; } if (hull != 0) { - logf(get_localized_string(LANG_0025), hull, modelIdx); + print_log(get_localized_string(LANG_0025), hull, modelIdx); } else { - logf(get_localized_string(LANG_0026), modelIdx); + print_log(get_localized_string(LANG_0026), modelIdx); } map->simplify_model_collision(modelIdx, hull); @@ -505,10 +505,10 @@ int simplify(CommandLine& cli) if (!change.allZero()) change.print_delete_stats(1); - logf("\n"); + print_log("\n"); if (map->isValid()) map->write(cli.hasOption("-o") ? cli.getOption("-o") : map->bsp_path); - logf("\n"); + print_log("\n"); map->print_info(false, 0, 0); delete map; @@ -526,28 +526,28 @@ int deleteCmd(CommandLine& cli) if (!removed.allZero()) { - logf(get_localized_string(LANG_1145)); + print_log(get_localized_string(LANG_1145)); removed.print_delete_stats(1); g_progress.clear(); - logf("\n"); + print_log("\n"); } if (cli.hasOption("-model")) { int modelIdx = cli.getOptionInt("-model"); - logf(get_localized_string(LANG_0027), modelIdx); + print_log(get_localized_string(LANG_0027), modelIdx); map->delete_model(modelIdx); map->update_ent_lump(); removed = map->remove_unused_model_structures(); if (!removed.allZero()) removed.print_delete_stats(1); - logf("\n"); + print_log("\n"); } if (map->isValid()) map->write(cli.hasOption("-o") ? cli.getOption("-o") : map->bsp_path); - logf("\n"); + print_log("\n"); map->print_info(false, 0, 0); delete map; @@ -568,20 +568,20 @@ int transform(CommandLine& cli) { move = cli.getOptionVector("-move"); - logf("Applying offset ({:.2f}, {:.2f}, {:.2f})\n", + print_log("Applying offset ({:.2f}, {:.2f}, {:.2f})\n", move.x, move.y, move.z); map->move(move); } else { - logf(get_localized_string(LANG_0028)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0028)); delete map; return 1; } if (map->isValid()) map->write(cli.hasOption("-o") ? cli.getOption("-o") : map->bsp_path); - logf("\n"); + print_log("\n"); map->print_info(false, 0, 0); delete map; @@ -597,10 +597,11 @@ int unembed(CommandLine& cli) if (map->bsp_valid) { int deleted = map->delete_embedded_textures(); - logf(get_localized_string(LANG_0029), deleted); + print_log(get_localized_string(LANG_0029), deleted); - if (map->isValid()) map->write(cli.hasOption("-o") ? cli.getOption("-o") : map->bsp_path); - logf("\n"); + if (map->isValid()) + map->write(cli.hasOption("-o") ? cli.getOption("-o") : map->bsp_path); + print_log("\n"); delete map; return 0; } @@ -612,7 +613,7 @@ void print_help(const std::string& command) { if (command == "merge") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "merge - Merges two or more maps together\n\n" "Usage: bspguy merge -maps \"map1, map2, ... mapN\" [options]\n" @@ -642,7 +643,7 @@ void print_help(const std::string& command) } else if (command == "info") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "info - Show BSP data summary\n\n" "Usage: bspguy info [options]\n" @@ -656,7 +657,7 @@ void print_help(const std::string& command) } else if (command == "noclip") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "noclip - Delete some clipnodes from the BSP\n\n" "Usage: bspguy noclip [options]\n" @@ -678,7 +679,7 @@ void print_help(const std::string& command) } else if (command == "simplify") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "simplify - Replaces model hulls with a simple bounding box\n\n" "Usage: bspguy simplify [options]\n" @@ -695,7 +696,7 @@ void print_help(const std::string& command) } else if (command == "delete") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "delete - Delete BSP models.\n\n" "Usage: bspguy delete [options]\n" @@ -709,7 +710,7 @@ void print_help(const std::string& command) } else if (command == "transform") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "transform - Apply 3D transformations\n\n" "Usage: bspguy transform [options]\n" @@ -722,7 +723,7 @@ void print_help(const std::string& command) } else if (command == "unembed") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "unembed - Deletes embedded texture data, so that they reference WADs instead.\n\n" "Usage: bspguy unembed \n" @@ -731,7 +732,7 @@ void print_help(const std::string& command) } else if (command == "exportobj") { - logf("{}", + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "exportobj - Export bsp geometry to obj [WIP].\n\n" "Usage: bspguy exportobj \n" @@ -740,8 +741,8 @@ void print_help(const std::string& command) } else { - logf("{}\n\n", g_version_string); - logf("{}", + print_log(PRINT_RED | PRINT_INTENSITY, "{}\n\n", g_version_string); + print_log(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY, "{}", "This tool modifies Sven Co-op BSPs without having to decompile them.\n\n" "Usage: bspguy [options]\n" @@ -800,7 +801,7 @@ void make_minidump(EXCEPTION_POINTERS* e) "_%4d%02d%02d_%02d%02d%02d(%d).dmp", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, crashdumps); - logf(get_localized_string(LANG_0030), name); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0030), name); auto hFile = CreateFileA(name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) @@ -854,7 +855,7 @@ LONG CALLBACK unhandled_handler(EXCEPTION_POINTERS* e) return ExceptionContinueExecution; } - logf(get_localized_string(LANG_0031), GetLastError(), e->ExceptionRecord->ExceptionCode, e->ExceptionRecord->ExceptionAddress, (void*)GetModuleHandleA(0)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0031), GetLastError(), e->ExceptionRecord->ExceptionCode, e->ExceptionRecord->ExceptionAddress, (void*)GetModuleHandleA(0)); if (crashdumps > 0) { @@ -873,13 +874,19 @@ int main(int argc, char* argv[]) setlocale(LC_ALL, ".utf8"); setlocale(LC_NUMERIC, "C"); - std::cout << "BSPGUY:" << g_version_string << std::endl; + //set_console_colors; + set_console_colors(PRINT_RED | PRINT_GREEN | PRINT_INTENSITY); + std::cout << "BSPGUY:" << g_version_string << std::endl; + set_console_colors(); //std::fesetround(FE_TONEAREST); try { #ifdef WIN32 - ::ShowWindow(::GetConsoleWindow(), SW_SHOW); + if (::GetConsoleWindow()) + { + ::ShowWindow(::GetConsoleWindow(), SW_SHOW); + } #ifndef NDEBUG SetUnhandledExceptionFilter(unhandled_handler); AddVectoredExceptionHandler(1, unhandled_handler); @@ -938,7 +945,7 @@ int main(int argc, char* argv[]) { if (!fileExists(cli.bspfile)) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0034), cli.bspfile); retval = 1; } else @@ -948,7 +955,7 @@ int main(int argc, char* argv[]) { if (!fileExists(cli.bspfile)) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0034), cli.bspfile); retval = 1; } else @@ -958,7 +965,7 @@ int main(int argc, char* argv[]) { if (!fileExists(cli.bspfile)) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0034), cli.bspfile); retval = 1; } else @@ -968,7 +975,7 @@ int main(int argc, char* argv[]) { if (!fileExists(cli.bspfile)) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0034), cli.bspfile); retval = 1; } else @@ -978,7 +985,7 @@ int main(int argc, char* argv[]) { if (!fileExists(cli.bspfile)) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0034), cli.bspfile); retval = 1; } else @@ -992,7 +999,7 @@ int main(int argc, char* argv[]) { if (!fileExists(cli.bspfile)) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0034), cli.bspfile); retval = 1; } else @@ -1006,14 +1013,14 @@ int main(int argc, char* argv[]) return 0; } else if (cli.bspfile.size() == 0) - logf("{}\n", get_localized_string(LANG_0032)); + print_log("{}\n", get_localized_string(LANG_0032)); else - logf("{}\n", ("Start bspguy editor with: " + cli.bspfile)); + print_log("{}\n", ("Start bspguy editor with: " + cli.bspfile)); - logf(get_localized_string(LANG_0033), g_settings_path); + print_log(get_localized_string(LANG_0033), g_settings_path); if (!start_viewer(cli.bspfile.c_str())) { - logf(get_localized_string(LANG_0034), cli.bspfile); + print_log(get_localized_string(LANG_0034), cli.bspfile); } } diff --git a/src/mdl/mdl_studio.cpp b/src/mdl/mdl_studio.cpp index b1307721..76e60120 100644 --- a/src/mdl/mdl_studio.cpp +++ b/src/mdl/mdl_studio.cpp @@ -84,14 +84,14 @@ void StudioModel::CalcBoneAdj() if (value > 1.0f) value = 1.0f; value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; } - // logf("{} {} {} : {}\n", m_controller[j], m_prevcontroller[j], value, dadt ); + // print_log("{} {} {} : {}\n", m_controller[j], m_prevcontroller[j], value, dadt ); } else { value = m_mouth / 64.0f; if (value > 1.0f) value = 1.0f; value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; - // logf("{} {}\n", mouthopen, value ); + // print_log("{} {}\n", mouthopen, value ); } switch (pbonecontroller[j].type & STUDIO_TYPES) { @@ -520,13 +520,13 @@ void StudioModel::SetupModel(int bodypart) if (bodypart >= m_pstudiohdr->numbodyparts || bodypart < 0) { - logf(get_localized_string(LANG_0979), bodypart); + print_log(get_localized_string(LANG_0979), bodypart); bodypart = 0; } if (m_pstudiohdr->bodypartindex < 0) { - logf(get_localized_string(LANG_0980), m_pstudiohdr->bodypartindex); + print_log(get_localized_string(LANG_0980), m_pstudiohdr->bodypartindex); } mstudiobodyparts_t* pbodypart = (mstudiobodyparts_t*)((unsigned char*)m_pstudiohdr + m_pstudiohdr->bodypartindex) + bodypart; @@ -544,27 +544,27 @@ void StudioModel::SetupModel(int bodypart) if (m_ptexturehdr && m_ptexturehdr->skinindex < 0) { - logf(get_localized_string(LANG_0981), m_ptexturehdr->skinindex); + print_log(get_localized_string(LANG_0981), m_ptexturehdr->skinindex); } if (m_pmodel->normindex < 0) { - logf(get_localized_string(LANG_0982), m_pmodel->normindex); + print_log(get_localized_string(LANG_0982), m_pmodel->normindex); } if (m_pmodel->vertindex < 0) { - logf(get_localized_string(LANG_0983), m_pmodel->vertindex); + print_log(get_localized_string(LANG_0983), m_pmodel->vertindex); } if (m_pmodel->vertinfoindex < 0) { - logf(get_localized_string(LANG_0984), m_pmodel->vertinfoindex); + print_log(get_localized_string(LANG_0984), m_pmodel->vertinfoindex); } if (m_ptexturehdr && m_ptexturehdr->textureindex < 0) { - logf(get_localized_string(LANG_0985), m_ptexturehdr->textureindex); + print_log(get_localized_string(LANG_0985), m_ptexturehdr->textureindex); } } @@ -619,27 +619,27 @@ void StudioModel::RefreshMeshList(int body) if (m_ptexturehdr && m_ptexturehdr->skinindex < 0) { - logf(get_localized_string(LANG_1137), m_ptexturehdr->skinindex); + print_log(get_localized_string(LANG_1137), m_ptexturehdr->skinindex); } if (m_pmodel->normindex < 0) { - logf(get_localized_string(LANG_1138), m_pmodel->normindex); + print_log(get_localized_string(LANG_1138), m_pmodel->normindex); } if (m_pmodel->vertindex < 0) { - logf(get_localized_string(LANG_1139), m_pmodel->vertindex); + print_log(get_localized_string(LANG_1139), m_pmodel->vertindex); } if (m_pmodel->vertinfoindex < 0) { - logf(get_localized_string(LANG_1140), m_pmodel->vertinfoindex); + print_log(get_localized_string(LANG_1140), m_pmodel->vertinfoindex); } if (m_ptexturehdr && m_ptexturehdr->textureindex < 0) { - logf(get_localized_string(LANG_1141), m_ptexturehdr->textureindex); + print_log(get_localized_string(LANG_1141), m_ptexturehdr->textureindex); } if (pskinref && m_ptexturehdr && m_skinnum >= 0 && m_skinnum < m_ptexturehdr->numskinfamilies) @@ -884,7 +884,7 @@ void StudioModel::UploadTexture(mstudiotexture_t* ptexture, unsigned char* data, out[i] = pal[data[i]]; } } - //logf("Texture name {} texture flags {}\n", ptexture->name, ptexture->flags); + //print_log("Texture name {} texture flags {}\n", ptexture->name, ptexture->flags); // ptexture->width = outwidth; // ptexture->height = outheight; auto texture = new Texture(ptexture->width, ptexture->height, (unsigned char*)out, ptexture->name); @@ -902,7 +902,7 @@ studiohdr_t* StudioModel::LoadModel(std::string modelname, bool IsTexture) void* buffer = loadFile(modelname, size); if (!buffer) { - logf(get_localized_string(LANG_0986), modelname); + print_log(get_localized_string(LANG_0986), modelname); return NULL; } @@ -938,7 +938,7 @@ studioseqhdr_t* StudioModel::LoadDemandSequences(std::string modelname, int seqi void* buffer = loadFile(str.str(), size); if (!buffer) { - logf(get_localized_string(LANG_0987), str.str()); + print_log(get_localized_string(LANG_0987), str.str()); return NULL; } return (studioseqhdr_t*)buffer; @@ -1037,12 +1037,12 @@ void StudioModel::Init(std::string modelname) m_pstudiohdr = LoadModel(modelname); if (!m_pstudiohdr) { - logf(get_localized_string(LANG_0988), modelname); + print_log(get_localized_string(LANG_0988), modelname); return; } if (g_settings.verboseLogs) { - logf(get_localized_string(LANG_0989), modelname, m_pstudiohdr->version); + print_log(get_localized_string(LANG_0989), modelname, m_pstudiohdr->version); } // preload textures if (m_pstudiohdr->numtextures == 0) diff --git a/src/qtools/rad.cpp b/src/qtools/rad.cpp index 597b1cf9..0a56f67b 100644 --- a/src/qtools/rad.cpp +++ b/src/qtools/rad.cpp @@ -96,7 +96,7 @@ const BSPPLANE getPlaneFromFace(Bsp* bsp, const BSPFACE32* const face) { if (!face) { - logf(get_localized_string(LANG_0990)); + print_log(get_localized_string(LANG_0990)); return BSPPLANE(); } @@ -329,7 +329,7 @@ bool GetFaceExtents(Bsp* bsp, int facenum, int mins_out[2], int maxs_out[2]) if (!(tex.nFlags & TEX_SPECIAL) && (maxs_out[i] - mins_out[i]) * TEXTURE_STEP > 4096) { - logf(get_localized_string(LANG_0991),facenum,(int)((maxs_out[i] - mins_out[i]) * TEXTURE_STEP)); + print_log(get_localized_string(LANG_0991),facenum,(int)((maxs_out[i] - mins_out[i]) * TEXTURE_STEP)); return false; } } diff --git a/src/qtools/rad.h b/src/qtools/rad.h index 4e5028a2..f47cd268 100644 --- a/src/qtools/rad.h +++ b/src/qtools/rad.h @@ -12,8 +12,8 @@ // sky or slime or null, no lightmap or 256 subdivision #define TEX_SPECIAL 1 -#define assume(exp, message) {if (!(exp)) {logf(get_localized_string(LANG_0001),#exp,__FILE__,__LINE__,message); }} -#define hlassume(exp, message) {if (!(exp)) {logf(get_localized_string(LANG_1016),#exp,__FILE__,__LINE__,#message); }} +#define assume(exp, message) {if (!(exp)) {print_log(get_localized_string(LANG_0001),#exp,__FILE__,__LINE__,message); }} +#define hlassume(exp, message) {if (!(exp)) {print_log(get_localized_string(LANG_1016),#exp,__FILE__,__LINE__,#message); }} #define qmax(a,b) (((a) > (b)) ? (a) : (b)) // changed 'max' to 'qmax'. --vluzacn #define qmin(a,b) (((a) < (b)) ? (a) : (b)) // changed 'min' to 'qmin'. --vluzacn diff --git a/src/qtools/vis.cpp b/src/qtools/vis.cpp index 92f17c96..d0717fe0 100644 --- a/src/qtools/vis.cpp +++ b/src/qtools/vis.cpp @@ -15,22 +15,22 @@ void printVisRow(unsigned char* vis, int len, int offsetLeaf, int mask) int leafIdx = i * 8 + b; if (leafIdx == offsetLeaf) { - print_color(PRINT_GREEN | PRINT_BRIGHT); + set_console_colors(PRINT_GREEN | PRINT_INTENSITY); } else { if (i * 8 < offsetLeaf && i * 8 + 8 > offsetLeaf && (1 << b) & mask) { - print_color(PRINT_RED | PRINT_GREEN); + set_console_colors(PRINT_RED | PRINT_GREEN); } else - print_color(PRINT_RED | PRINT_GREEN | PRINT_BLUE); + set_console_colors(PRINT_RED | PRINT_GREEN | PRINT_BLUE); } - logf("{}", (unsigned int)((bits >> b) & 1)); + print_log("{}", (unsigned int)((bits >> b) & 1)); } - logf(" "); + print_log(" "); } - logf("\n"); + print_log("\n"); } bool shiftVis(unsigned char* vis, int len, int offsetLeaf, int shift) @@ -38,6 +38,8 @@ bool shiftVis(unsigned char* vis, int len, int offsetLeaf, int shift) if (shift == 0) return false; + g_debug_shift = g_verbose; + unsigned char bitsPerStep = 8; unsigned char offsetBit = offsetLeaf % bitsPerStep; unsigned char mask = 0; // part of the unsigned char that shouldn't be shifted @@ -66,7 +68,7 @@ bool shiftVis(unsigned char* vis, int len, int offsetLeaf, int shift) if (g_debug_shift) { - logf(get_localized_string(LANG_0992)); + print_log(get_localized_string(LANG_0992)); } int overflow = 0; @@ -74,7 +76,7 @@ bool shiftVis(unsigned char* vis, int len, int offsetLeaf, int shift) { if (g_debug_shift) { - logf("{:2d} = ", k); + print_log("{:2d} = ", k); printVisRow(vis, len, offsetLeaf, mask); } @@ -135,12 +137,12 @@ bool shiftVis(unsigned char* vis, int len, int offsetLeaf, int shift) if (g_debug_shift && k == bitShifts - 1) { - logf("{:2d} = ", k + 1); + print_log("{:2d} = ", k + 1); printVisRow(vis, len, offsetLeaf, mask); } } if (overflow) - logf(get_localized_string(LANG_0993),overflow); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0993),overflow); if (byteShifts > 0) @@ -196,7 +198,7 @@ void decompress_vis_lump(BSPLEAF32* leafLump, unsigned char* visLump, unsigned c { if ((i + 1) * sizeof(BSPLEAF32) >= leafMemSize) { - logf(get_localized_string(LANG_0994),i + 1,leafMemSize / sizeof(BSPLEAF32)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0994),i + 1,leafMemSize / sizeof(BSPLEAF32)); return; } @@ -209,11 +211,11 @@ void decompress_vis_lump(BSPLEAF32* leafLump, unsigned char* visLump, unsigned c if (leafLump[i + 1].nVisOffset >= visLumpMemSize) { - logf(get_localized_string(LANG_0995),leafLump[i + 1].nVisOffset,visLumpMemSize); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0995),leafLump[i + 1].nVisOffset,visLumpMemSize); return; } // Tracing ... - // logf(get_localized_string(LANG_0996),leafLump[i].nVisOffset,visLumpMemSize); + // print_log(get_localized_string(LANG_0996),leafLump[i].nVisOffset,visLumpMemSize); DecompressVis((unsigned char*)(visLump + leafLump[i + 1].nVisOffset), dest, oldVisRowSize, visDataLeafCount, visLumpMemSize - leafLump[i + 1].nVisOffset); // Leaf visibility row lengths are multiples of 64 leaves, so there are usually some unused bits at the end. @@ -229,7 +231,7 @@ void decompress_vis_lump(BSPLEAF32* leafLump, unsigned char* visLump, unsigned c } else { - logf(get_localized_string(LANG_0997)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0997)); return; } } @@ -259,12 +261,12 @@ void DecompressVis(unsigned char* src, unsigned char* dest, unsigned int dest_le { if (out > startdst + dest_length) { - logf(get_localized_string(LANG_0998),(int)(out - startdst),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0998),(int)(out - startdst),dest_length); return; } if (src > startsrc + src_length) { - logf(get_localized_string(LANG_0999),(int)(src - startsrc),src_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0999),(int)(src - startsrc),src_length); return; } *out = *src; @@ -279,7 +281,7 @@ void DecompressVis(unsigned char* src, unsigned char* dest, unsigned int dest_le { if (out > startdst + dest_length) { - logf(get_localized_string(LANG_1142),(int)(out - startdst),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1142),(int)(out - startdst),dest_length); return; } *out = 0; @@ -306,7 +308,7 @@ int CompressVis(unsigned char* src, unsigned int src_length, unsigned char* dest if (current_length > dest_length) { - logf(get_localized_string(LANG_1000),current_length,dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1000),current_length,dest_length); return (int)(dest_p - dest); } @@ -335,7 +337,7 @@ int CompressVis(unsigned char* src, unsigned int src_length, unsigned char* dest current_length++; if (current_length > dest_length) { - logf(get_localized_string(LANG_1143),current_length,dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1143),current_length,dest_length); return (int)(dest_p - dest); } *dest_p = rep; @@ -384,7 +386,7 @@ int CompressAll(BSPLEAF32* leafs, unsigned char* uncompressed, unsigned char* ou { if (i + 1 >= maxLeafs) { - logf(get_localized_string(LANG_1001),i + 1,maxLeafs); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1001),i + 1,maxLeafs); delete[] sharedRows; delete[] compressed; return (int)(vismap_p - output); @@ -394,7 +396,7 @@ int CompressAll(BSPLEAF32* leafs, unsigned char* uncompressed, unsigned char* ou { if (sharedRows[i] + 1 >= maxLeafs) { - logf(get_localized_string(LANG_1002),(int)(sharedRows[i] + 1),maxLeafs); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1002),(int)(sharedRows[i] + 1),maxLeafs); delete[] sharedRows; delete[] compressed; return (int)(vismap_p - output); @@ -415,7 +417,7 @@ int CompressAll(BSPLEAF32* leafs, unsigned char* uncompressed, unsigned char* ou if (vismap_p >= output + bufferSize) { - logf(get_localized_string(LANG_1003),(void*)vismap_p,(void*)(output + bufferSize)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1003),(void*)vismap_p,(void*)(output + bufferSize)); delete[] sharedRows; return (int)(vismap_p - output); @@ -459,7 +461,7 @@ void DecompressLeafVis(unsigned char* src, unsigned int src_len, unsigned char* { if (out > dest + dest_length) { - logf(get_localized_string(LANG_1004),(int)(out - dest),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1004),(int)(out - dest),dest_length); return; } @@ -476,13 +478,13 @@ void DecompressLeafVis(unsigned char* src, unsigned int src_len, unsigned char* { if (out > dest + dest_length) { - logf(get_localized_string(LANG_1005),(int)(out - dest),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1005),(int)(out - dest),dest_length); return; } if (src > src_start + src_len) { - logf(get_localized_string(LANG_1006),(int)(out - dest),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1006),(int)(out - dest),dest_length); return; } @@ -496,7 +498,7 @@ void DecompressLeafVis(unsigned char* src, unsigned int src_len, unsigned char* if (src > src_start + src_len) { - logf(get_localized_string(LANG_1144),(int)(out - dest),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1144),(int)(out - dest),dest_length); return; } @@ -504,7 +506,7 @@ void DecompressLeafVis(unsigned char* src, unsigned int src_len, unsigned char* { if (out > dest + dest_length) { - logf(get_localized_string(LANG_1007),(int)(out - dest),dest_length); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1007),(int)(out - dest),dest_length); return; } diff --git a/src/qtools/winding.cpp b/src/qtools/winding.cpp index 48b73bd9..7ed5ecd6 100644 --- a/src/qtools/winding.cpp +++ b/src/qtools/winding.cpp @@ -72,7 +72,7 @@ Winding::Winding(const BSPPLANE& plane, float epsilon) } if (x == -1) { - logf(get_localized_string(LANG_1008)); + print_log(get_localized_string(LANG_1008)); } @@ -305,7 +305,7 @@ bool Winding::Clip(BSPPLANE& split, bool keepon, float epsilon) if (newNumPoints > maxpts) { - logf(get_localized_string(LANG_1009)); + print_log(get_localized_string(LANG_1009)); } delete[] m_Points; diff --git a/src/util/lang.cpp b/src/util/lang.cpp index d22daf28..20a31bf2 100644 --- a/src/util/lang.cpp +++ b/src/util/lang.cpp @@ -82,7 +82,7 @@ void set_localize_lang(std::string lang) } catch (std::runtime_error runtime) { - logf("Language parse from {} fatal error: {}\n", g_config_dir + "language.ini", runtime.what()); + print_log("Language parse from {} fatal error: {}\n", g_config_dir + "language.ini", runtime.what()); } last_lang = lang; } diff --git a/src/util/mat4x4.cpp b/src/util/mat4x4.cpp index 89001a91..e553164a 100644 --- a/src/util/mat4x4.cpp +++ b/src/util/mat4x4.cpp @@ -392,7 +392,7 @@ mat4x4 mat4x4::invert() if (abs(det) < EPSILON) { - logf(get_localized_string(LANG_1010)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1010)); return out; } @@ -509,8 +509,8 @@ vec4 operator*(const mat4x4& mat, const vec4& vec) void mat4x4print(const mat4x4& mat) { - logf("{} {} {} {}\n", mat.m[0], mat.m[1], mat.m[2], mat.m[3]); - logf("{} {} {} {}\n", mat.m[4], mat.m[5], mat.m[6], mat.m[7]); - logf("{} {} {} {}\n", mat.m[8], mat.m[9], mat.m[10], mat.m[11]); - logf("{} {} {} {}\n\n", mat.m[12], mat.m[13], mat.m[14], mat.m[15]); + print_log("{} {} {} {}\n", mat.m[0], mat.m[1], mat.m[2], mat.m[3]); + print_log("{} {} {} {}\n", mat.m[4], mat.m[5], mat.m[6], mat.m[7]); + print_log("{} {} {} {}\n", mat.m[8], mat.m[9], mat.m[10], mat.m[11]); + print_log("{} {} {} {}\n\n", mat.m[12], mat.m[13], mat.m[14], mat.m[15]); } \ No newline at end of file diff --git a/src/util/util.cpp b/src/util/util.cpp index ddd74ef7..9e5374e2 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -28,6 +28,8 @@ bool DebugKeyPressed = false; ProgressMeter g_progress; int g_render_flags; std::vector g_log_buffer; +std::vector g_color_buffer; + std::mutex g_mutex_list[10] = {}; bool fileExists(const std::string& fileName) @@ -105,17 +107,17 @@ std::streampos fileSize(const std::string& filePath) std::vector splitString(std::string s, const std::string& delimiter, int maxParts) { - std::vector split; - size_t pos; - while ((pos = s.find(delimiter)) != std::string::npos && (maxParts == 0 || split.size() < maxParts - 1)) { - if (pos != 0) { - split.push_back(s.substr(0, pos)); - } - s.erase(0, pos + delimiter.length()); - } - if (!s.empty()) - split.push_back(s); - return split; + std::vector split; + size_t pos; + while ((pos = s.find(delimiter)) != std::string::npos && (maxParts == 0 || split.size() < maxParts - 1)) { + if (pos != 0) { + split.push_back(s.substr(0, pos)); + } + s.erase(0, pos + delimiter.length()); + } + if (!s.empty()) + split.push_back(s); + return split; } std::vector splitStringIgnoringQuotes(std::string s, const std::string& delimitter) @@ -228,7 +230,7 @@ std::string toLowerCase(const std::string& s) return ret; } -std::string trimSpaces(const std::string & str) +std::string trimSpaces(const std::string& str) { if (str.empty()) { @@ -254,7 +256,7 @@ int getTextureSizeInBytes(BSPMIPTEX* bspTexture, bool palette) if (palette) sz += sizeof(COLOR3) * 256; // pallette + padding - + for (int i = 0; i < MIPLEVELS; i++) { sz += (bspTexture->nWidth >> i) * (bspTexture->nHeight >> i); @@ -753,7 +755,7 @@ std::vector getTriangularVerts(std::vector& verts) if (i1 == -1) { - //logf(get_localized_string(LANG_1011)); + //print_log(get_localized_string(LANG_1011)); return std::vector(); } @@ -778,7 +780,7 @@ std::vector getTriangularVerts(std::vector& verts) if (i2 == -1) { - //logf(get_localized_string(LANG_1012)); + //print_log(get_localized_string(LANG_1012)); return std::vector(); } @@ -939,7 +941,7 @@ void WriteBMP(const std::string& fileName, unsigned char* pixels, int width, int fopen_s(&outputFile, fileName.c_str(), "wb"); if (!outputFile) { - logf(get_localized_string(LANG_1013)); + print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_1013)); return; } //*****HEADER************// @@ -1155,20 +1157,29 @@ std::string GetCurrentDir() { return g_current_dir + "/"; } +unsigned short g_console_colors = 0; #ifdef WIN32 -void print_color(int colors) +void set_console_colors(unsigned short colors) { HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); - colors = colors ? colors : (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - SetConsoleTextAttribute(console, (WORD)colors); + if (!console) + console = ::GetConsoleWindow(); + if (console) + { + colors = colors ? colors : (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); + g_console_colors = colors; + SetConsoleTextAttribute(console, colors); + } } #else -void print_color(int colors) +void set_console_colors(unsigned short colors) { - if (!colors) + colors = colors ? colors : (PRINT_GREEN | PRINT_BLUE | PRINT_RED | PRINT_INTENSITY); + g_console_colors = colors; + if (colors == 0) { - logf(get_localized_string(LANG_1014)); + std::cout << "\x1B[0m"; return; } const char* mode = colors & PRINT_BRIGHT ? "1" : "0"; @@ -1183,7 +1194,7 @@ void print_color(int colors) case PRINT_GREEN | PRINT_BLUE: color = "36"; break; case PRINT_GREEN | PRINT_BLUE | PRINT_RED: color = "36"; break; } - logf(get_localized_string(LANG_1015),mode,color); + std::cout << "\x1B[" << mode << ";" << color << "m"; } #endif @@ -1464,7 +1475,7 @@ bool FindPathInAssets(Bsp* map, const std::string& path, std::string& outpath, b if (tracesearch) { outTrace << "-------------END PATH TRACING-------------\n"; - logf("{}", outTrace.str()); + print_log("{}", outTrace.str()); } return false; } @@ -1478,8 +1489,8 @@ void FixupAllSystemPaths() { if (!dirExists(GetCurrentDir() + g_settings.gamedir)) { - logf("Error{}: Gamedir {} not exits!", "[1]", g_settings.gamedir); - logf("Error{}: Gamedir {} not exits!", "[2]", GetCurrentDir() + g_settings.gamedir); + print_log(PRINT_RED | PRINT_INTENSITY, "Error{}: Gamedir {} not exits!", "[1]", g_settings.gamedir); + print_log(PRINT_RED | PRINT_INTENSITY, "Error{}: Gamedir {} not exits!", "[2]", GetCurrentDir() + g_settings.gamedir); } else { @@ -1495,8 +1506,8 @@ void FixupAllSystemPaths() fixupPath(g_settings.workingdir, FIXUPPATH_SLASH::FIXUPPATH_SLASH_SKIP, FIXUPPATH_SLASH::FIXUPPATH_SLASH_CREATE); if (!dirExists(g_settings.workingdir)) - { - /* + { + /* fixup workingdir to relative */ fixupPath(g_settings.workingdir, FIXUPPATH_SLASH::FIXUPPATH_SLASH_REMOVE, FIXUPPATH_SLASH::FIXUPPATH_SLASH_CREATE); @@ -1505,8 +1516,8 @@ void FixupAllSystemPaths() { if (!dirExists(g_game_dir + g_settings.workingdir)) { - logf("Error{}: Workdir {} not exits!", "[1]", g_settings.workingdir); - logf("Error{}: Workdir {} not exits!", "[2]", g_game_dir + g_settings.workingdir); + print_log(PRINT_RED | PRINT_INTENSITY, "Error{}: Workdir {} not exits!", "[1]", g_settings.workingdir); + print_log(PRINT_RED | PRINT_INTENSITY, "Error{}: Workdir {} not exits!", "[2]", g_game_dir + g_settings.workingdir); } else { diff --git a/src/util/util.h b/src/util/util.h index 1b86c1b6..611b6e57 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -27,10 +27,13 @@ extern std::string g_version_string; #define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename), (mode)))==NULL #endif -#define PRINT_BLUE 1 -#define PRINT_GREEN 2 -#define PRINT_RED 4 -#define PRINT_BRIGHT 8 +enum PRINT_CONTS : unsigned short +{ + PRINT_BLUE = 1, + PRINT_GREEN = 2, + PRINT_RED = 4, + PRINT_INTENSITY = 8 +}; static const vec3 s_baseaxis[18] = { {0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor @@ -45,10 +48,17 @@ extern bool DebugKeyPressed; extern bool g_verbose; extern ProgressMeter g_progress; extern std::vector g_log_buffer; +extern std::vector g_color_buffer; extern std::mutex g_mutex_list[10]; + +extern unsigned short g_console_colors; +//ImVec4 imguiColorFromConsole(unsigned short colors); +void set_console_colors(unsigned short colors = 0); + + template -inline void logf(const std::string & format, Args ...args) noexcept +inline void print_log(const std::string& format, Args ...args) noexcept { g_mutex_list[0].lock(); @@ -64,11 +74,39 @@ inline void logf(const std::string & format, Args ...args) noexcept { std::cout << log_line; g_log_buffer.push_back(log_line); + g_color_buffer.push_back(g_console_colors); } g_mutex_list[0].unlock(); } +template +inline void print_log(unsigned short colors, const std::string& format, Args ...args) noexcept +{ + g_mutex_list[0].lock(); + + set_console_colors(colors); + + std::string log_line = fmt::vformat(format, fmt::make_format_args(args...)); + +#ifndef NDEBUG + static std::ofstream outfile("log.txt", std::ios_base::app); + outfile << log_line; + outfile.flush(); +#endif + + if (g_log_buffer.size() == 0 || g_log_buffer[g_log_buffer.size() - 1] != log_line) + { + std::cout << log_line; + g_log_buffer.push_back(log_line); + g_color_buffer.push_back(colors); + } + g_mutex_list[0].unlock(); + + set_console_colors(); +} + + bool fileExists(const std::string& fileName); bool copyFile(const std::string& fileName, const std::string& fileName2); @@ -94,8 +132,6 @@ std::wstring stripFileName(const std::wstring& path); bool isNumeric(const std::string& s); -void print_color(int colors); - bool dirExists(const std::string& dirName); bool createDir(const std::string& dirName);