diff --git a/source/bsp.cc b/source/bsp.cc index bb13278d0..f9439045e 100644 --- a/source/bsp.cc +++ b/source/bsp.cc @@ -92,14 +92,11 @@ bool CheckMapInMaplist(int lev_idx) build_result_e BuildFile(buildinfo_t *build_info) { - build_info->total_warnings = 0; - build_info->total_minor_issues = 0; - int num_levels = ajbsp::LevelsInWad(); if (num_levels == 0) { - LogPrintf(" No levels in wad\n"); + LogPrint(" No levels in wad\n"); total_empty_files += 1; return BUILD_OK; } @@ -119,9 +116,6 @@ build_result_e BuildFile(buildinfo_t *build_info) Doom::Send_Prog_Nodes(visited, num_levels); - if (n > 0 && build_info->verbosity >= 2) - LogPrintf("\n"); - res = ajbsp::BuildLevel(n); // handle a failed map (due to lump overflow) @@ -145,40 +139,30 @@ build_result_e BuildFile(buildinfo_t *build_info) if (visited == 0) { - LogPrintf(" No matching levels\n"); + LogPrint(" No matching levels\n"); total_empty_files += 1; return BUILD_OK; } - LogPrintf("\n"); + LogPrint("\n"); total_failed_maps += failures; if (failures > 0) { - LogPrintf(" Failed maps: %d (out of %d)\n", failures, visited); + LogPrint(" Failed maps: %d (out of %d)\n", failures, visited); // allow building other files total_failed_files += 1; } - if (true) - { - LogPrintf(" Serious warnings: %d\n", build_info->total_warnings); - } - - if (build_info->verbosity >= 1) - { - LogPrintf(" Minor issues: %d\n", build_info->total_minor_issues); - } - return BUILD_OK; } void VisitFile(std::string filename, buildinfo_t *build_info) { - LogPrintf("\n"); - LogPrintf("Building %s\n", filename.c_str()); + LogPrint("\n"); + LogPrint("Building %s\n", filename.c_str()); // this will fatal error if it fails ajbsp::OpenWad(filename); @@ -188,7 +172,7 @@ void VisitFile(std::string filename, buildinfo_t *build_info) ajbsp::CloseWad(); if (res == BUILD_Cancelled) - ErrorPrintf("CANCELLED\n"); + FatalError("CANCELLED\n"); } // ----- user information ----------------------------- @@ -241,22 +225,22 @@ void ParseMapRange(char *tok, buildinfo_t *build_info) } if (!ValidateMapName(low)) - ErrorPrintf("illegal map name: '%s'\n", low); + FatalError("illegal map name: '%s'\n", low); if (!ValidateMapName(high)) - ErrorPrintf("illegal map name: '%s'\n", high); + FatalError("illegal map name: '%s'\n", high); if (strlen(low) < strlen(high)) - ErrorPrintf("bad map range (%s shorter than %s)\n", low, high); + FatalError("bad map range (%s shorter than %s)\n", low, high); if (strlen(low) > strlen(high)) - ErrorPrintf("bad map range (%s longer than %s)\n", low, high); + FatalError("bad map range (%s longer than %s)\n", low, high); if (low[0] != high[0]) - ErrorPrintf("bad map range (%s and %s start with different letters)\n", low, high); + FatalError("bad map range (%s and %s start with different letters)\n", low, high); if (StringCompare(low, high) > 0) - ErrorPrintf("bad map range (wrong order, %s > %s)\n", low, high); + FatalError("bad map range (wrong order, %s > %s)\n", low, high); // Ok @@ -279,7 +263,7 @@ void ParseMapList(const char *from_arg, buildinfo_t *build_info) while (*arg) { if (*arg == ',') - ErrorPrintf("bad map list (empty element)\n"); + FatalError("bad map list (empty element)\n"); // find next comma char *tok = arg; @@ -305,7 +289,7 @@ void ParseMapList(const char *from_arg, buildinfo_t *build_info) do \ { \ if (sizeof(type) != size) \ - ErrorPrintf("sizeof " #type " is %d (should be " #size ")\n", (int)sizeof(type)); \ + FatalError("sizeof " #type " is %d (should be " #size ")\n", (int)sizeof(type)); \ } while (0) void CheckTypeSizes(buildinfo_t *build_info) @@ -334,7 +318,7 @@ int AJBSP_BuildNodes(std::string filename, buildinfo_t *build_info) if (filename.empty()) { - ErrorPrintf("no files to process\n"); + FatalError("no files to process\n"); return 0; } @@ -342,38 +326,37 @@ int AJBSP_BuildNodes(std::string filename, buildinfo_t *build_info) // validate file before processing it if (!FileExists(filename)) - ErrorPrintf("no such file: %s\n", filename.c_str()); + FatalError("no such file: %s\n", filename.c_str()); VisitFile(filename, build_info); - LogPrintf("\n"); + LogPrint("\n"); if (total_failed_files > 0) { - LogPrintf("FAILURES occurred on %d map%s in %d file%s.\n", total_failed_maps, + LogPrint("FAILURES occurred on %d map%s in %d file%s.\n", total_failed_maps, total_failed_maps == 1 ? "" : "s", total_failed_files, total_failed_files == 1 ? "" : "s"); - if (build_info->verbosity == 0) - LogPrintf("Rerun with --verbose to see more details.\n"); + LogPrint("Rerun with --verbose to see more details.\n"); return 2; } else if (total_built_maps == 0) { - LogPrintf("NOTHING was built!\n"); + LogPrint("NOTHING was built!\n"); return 1; } else if (total_empty_files == 0) { - LogPrintf("Ok, built all files.\n"); + LogPrint("Ok, built all files.\n"); } else { int built = 1 - total_empty_files; int empty = total_empty_files; - LogPrintf("Ok, built %d file%s, %d file%s empty.\n", built, (built == 1 ? "" : "s"), empty, + LogPrint("Ok, built %d file%s, %d file%s empty.\n", built, (built == 1 ? "" : "s"), empty, (empty == 1 ? " was" : "s were")); } diff --git a/source/bsp.h b/source/bsp.h index 8ba21729e..5715fb40a 100644 --- a/source/bsp.h +++ b/source/bsp.h @@ -47,20 +47,13 @@ class buildinfo_t bool force_v5; bool force_xnod; - bool force_compress; // NOTE: only supported when HAVE_ZLIB is defined + bool force_compress; // the GUI can set this to tell the node builder to stop bool cancelled; int split_cost; - // this affects how some messages are shown - int verbosity; - - // from here on, various bits of internal state - int total_warnings; - int total_minor_issues; - public: buildinfo_t() : fast(false), @@ -73,9 +66,7 @@ class buildinfo_t cancelled(false), - split_cost(SPLIT_COST_DEFAULT), verbosity(0), - - total_warnings(0), total_minor_issues(0) + split_cost(SPLIT_COST_DEFAULT) { } diff --git a/source/bsp_level.cc b/source/bsp_level.cc index 7a564c7a2..1ed92d588 100644 --- a/source/bsp_level.cc +++ b/source/bsp_level.cc @@ -159,11 +159,11 @@ static void BlockAdd(int blk_num, int line_index) uint16_t *cur = block_lines[blk_num]; #if DEBUG_BLOCKMAP - DebugPrintf("Block %d has line %d\n", blk_num, line_index); + DebugPrint("Block %d has line %d\n", blk_num, line_index); #endif if (blk_num < 0 || blk_num >= block_count) - ErrorPrintf("BlockAdd: bad block number %d\n", blk_num); + FatalError("BlockAdd: bad block number %d\n", blk_num); if (!cur) { @@ -205,7 +205,7 @@ static void BlockAddLine(const linedef_t *L) int line_index = L->index; #if DEBUG_BLOCKMAP - DebugPrintf("BlockAddLine: %d (%d,%d) -> (%d,%d)\n", line_index, x1, y1, x2, y2); + DebugPrint("BlockAddLine: %d (%d,%d) -> (%d,%d)\n", line_index, x1, y1, x2, y2); #endif // handle truncated blockmaps @@ -387,7 +387,7 @@ static void CompressBlockmap(void) } #if DEBUG_BLOCKMAP - DebugPrintf("Blockmap: Last ptr = %d duplicates = %d\n", cur_offset, dup_count); + DebugPrint("Blockmap: Last ptr = %d duplicates = %d\n", cur_offset, dup_count); #endif block_compression = (orig_size - new_size) * 100 / orig_size; @@ -455,7 +455,7 @@ static void WriteBlockmap(void) uint16_t ptr = LE_U16(block_ptrs[i]); if (ptr == 0) - ErrorPrintf("WriteBlockmap: offset %d not set.\n", i); + FatalError("WriteBlockmap: offset %d not set.\n", i); lump->Write(&ptr, sizeof(uint16_t)); } @@ -542,7 +542,7 @@ static void FindBlockmapLimits(bbox_t *bbox) } #if DEBUG_BLOCKMAP - DebugPrintf("Blockmap lines centered at (%d,%d)\n", block_mid_x, block_mid_y); + DebugPrint("Blockmap lines centered at (%d,%d)\n", block_mid_x, block_mid_y); #endif } @@ -553,7 +553,7 @@ void InitBlockmap() // find limits of linedefs, and store as map limits FindBlockmapLimits(&map_bbox); - LogPrintf(" Map limits: (%d,%d) to (%d,%d)\n", map_bbox.minx, map_bbox.miny, map_bbox.maxx, + LogPrint(" Map limits: (%d,%d) to (%d,%d)\n", map_bbox.minx, map_bbox.miny, map_bbox.maxx, map_bbox.maxy); block_x = map_bbox.minx - (map_bbox.minx & 0x7); @@ -594,13 +594,13 @@ void PutBlockmap() // leave an empty blockmap lump CreateLevelLump("BLOCKMAP")->Finish(); - Warning("Blockmap overflowed (lump will be empty)\n"); + LogPrint("Blockmap overflowed (lump will be empty)\n"); } else { WriteBlockmap(); - LogPrintf(" Blockmap size: %dx%d (compression: %d%%)\n", block_w, block_h, block_compression); + LogPrint(" Blockmap size: %dx%d (compression: %d%%)\n", block_w, block_h, block_compression); } FreeBlockmap(); @@ -719,7 +719,7 @@ static void Reject_DebugGroups() num++; } - DebugPrintf("Group %d Sectors %d\n", group, num); + DebugPrint("Group %d Sectors %d\n", group, num); } } #endif @@ -780,7 +780,7 @@ void PutReject() Reject_WriteLump(); Reject_Free(); - LogPrintf(" Reject size: %d\n", rej_total_size); + LogPrint(" Reject size: %d\n", rej_total_size); } //------------------------------------------------------------------------ @@ -969,7 +969,7 @@ void FreeWallTips() static vertex_t *SafeLookupVertex(int num) { if (num >= num_vertices) - ErrorPrintf("illegal vertex number #%d\n", num); + FatalError("illegal vertex number #%d\n", num); return lev_vertices[num]; } @@ -980,7 +980,7 @@ static sector_t *SafeLookupSector(uint16_t num) return NULL; if (num >= num_sectors) - ErrorPrintf("illegal sector number #%d\n", (int)num); + FatalError("illegal sector number #%d\n", (int)num); return lev_sectors[num]; } @@ -1007,21 +1007,21 @@ void GetVertices() count = lump->Length() / (int)sizeof(raw_vertex_t); #if DEBUG_LOAD - DebugPrintf("GetVertices: num = %d\n", count); + DebugPrint("GetVertices: num = %d\n", count); #endif if (lump == NULL || count == 0) return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to vertices.\n"); + FatalError("Error seeking to vertices.\n"); for (int i = 0; i < count; i++) { raw_vertex_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading vertices.\n"); + FatalError("Error reading vertices.\n"); vertex_t *vert = NewVertex(); @@ -1045,10 +1045,10 @@ void GetSectors() return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to sectors.\n"); + FatalError("Error seeking to sectors.\n"); #if DEBUG_LOAD - DebugPrintf("GetSectors: num = %d\n", count); + DebugPrint("GetSectors: num = %d\n", count); #endif for (int i = 0; i < count; i++) @@ -1056,7 +1056,7 @@ void GetSectors() raw_sector_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading sectors.\n"); + FatalError("Error reading sectors.\n"); sector_t *sector = NewSector(); @@ -1077,10 +1077,10 @@ void GetThings() return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to things.\n"); + FatalError("Error seeking to things.\n"); #if DEBUG_LOAD - DebugPrintf("GetThings: num = %d\n", count); + DebugPrint("GetThings: num = %d\n", count); #endif for (int i = 0; i < count; i++) @@ -1088,7 +1088,7 @@ void GetThings() raw_thing_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading things.\n"); + FatalError("Error reading things.\n"); thing_t *thing = NewThing(); @@ -1111,10 +1111,10 @@ void GetThingsHexen() return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to things.\n"); + FatalError("Error seeking to things.\n"); #if DEBUG_LOAD - DebugPrintf("GetThingsHexen: num = %d\n", count); + DebugPrint("GetThingsHexen: num = %d\n", count); #endif for (int i = 0; i < count; i++) @@ -1122,7 +1122,7 @@ void GetThingsHexen() raw_hexen_thing_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading things.\n"); + FatalError("Error reading things.\n"); thing_t *thing = NewThing(); @@ -1145,10 +1145,10 @@ void GetSidedefs() return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to sidedefs.\n"); + FatalError("Error seeking to sidedefs.\n"); #if DEBUG_LOAD - DebugPrintf("GetSidedefs: num = %d\n", count); + DebugPrint("GetSidedefs: num = %d\n", count); #endif for (int i = 0; i < count; i++) @@ -1156,7 +1156,7 @@ void GetSidedefs() raw_sidedef_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading sidedefs.\n"); + FatalError("Error reading sidedefs.\n"); sidedef_t *side = NewSidedef(); @@ -1177,10 +1177,10 @@ void GetLinedefs() return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to linedefs.\n"); + FatalError("Error seeking to linedefs.\n"); #if DEBUG_LOAD - DebugPrintf("GetLinedefs: num = %d\n", count); + DebugPrint("GetLinedefs: num = %d\n", count); #endif for (int i = 0; i < count; i++) @@ -1188,7 +1188,7 @@ void GetLinedefs() raw_linedef_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading linedefs.\n"); + FatalError("Error reading linedefs.\n"); linedef_t *line; @@ -1236,10 +1236,10 @@ void GetLinedefsHexen() return; if (!lump->Seek(0)) - ErrorPrintf("Error seeking to linedefs.\n"); + FatalError("Error seeking to linedefs.\n"); #if DEBUG_LOAD - DebugPrintf("GetLinedefsHexen: num = %d\n", count); + DebugPrint("GetLinedefsHexen: num = %d\n", count); #endif for (int i = 0; i < count; i++) @@ -1247,7 +1247,7 @@ void GetLinedefsHexen() raw_hexen_linedef_t raw; if (!lump->Read(&raw, sizeof(raw))) - ErrorPrintf("Error reading linedefs.\n"); + FatalError("Error reading linedefs.\n"); linedef_t *line; @@ -1350,7 +1350,7 @@ void ParseSidedefField(sidedef_t *side, const std::string &key, ajparse::token_k int num = ajparse::LEX_Int(value); if (num < 0 || num >= num_sectors) - ErrorPrintf("illegal sector number #%d\n", (int)num); + FatalError("illegal sector number #%d\n", (int)num); side->sector = lev_sectors[num]; } @@ -1431,21 +1431,21 @@ void ParseUDMF_Block(ajparse::lexer_c &lex, int cur_type) ajparse::token_kind_e tok = lex.Next(key); if (tok == ajparse::TOK_EOF) - ErrorPrintf("Malformed TEXTMAP lump: unclosed block\n"); + FatalError("Malformed TEXTMAP lump: unclosed block\n"); if (tok != ajparse::TOK_Ident) - ErrorPrintf("Malformed TEXTMAP lump: missing key\n"); + FatalError("Malformed TEXTMAP lump: missing key\n"); if (!lex.Match("=")) - ErrorPrintf("Malformed TEXTMAP lump: missing '='\n"); + FatalError("Malformed TEXTMAP lump: missing '='\n"); tok = lex.Next(value); if (tok == ajparse::TOK_EOF || tok == ajparse::TOK_ERROR || value == "}") - ErrorPrintf("Malformed TEXTMAP lump: missing value\n"); + FatalError("Malformed TEXTMAP lump: missing value\n"); if (!lex.Match(";")) - ErrorPrintf("Malformed TEXTMAP lump: missing ';'\n"); + FatalError("Malformed TEXTMAP lump: missing ';'\n"); switch (cur_type) { @@ -1475,7 +1475,7 @@ void ParseUDMF_Block(ajparse::lexer_c &lex, int cur_type) if (line != NULL) { if (line->start == NULL || line->end == NULL) - ErrorPrintf("Linedef #%d is missing a vertex!\n", line->index); + FatalError("Linedef #%d is missing a vertex!\n", line->index); if (line->right || line->left) num_real_lines++; @@ -1502,7 +1502,7 @@ void ParseUDMF_Pass(const std::string &data, int pass) if (tok != ajparse::TOK_Ident) { - ErrorPrintf("Malformed TEXTMAP lump.\n"); + FatalError("Malformed TEXTMAP lump.\n"); return; } @@ -1511,12 +1511,12 @@ void ParseUDMF_Pass(const std::string &data, int pass) { lex.Next(section); if (!lex.Match(";")) - ErrorPrintf("Malformed TEXTMAP lump: missing ';'\n"); + FatalError("Malformed TEXTMAP lump: missing ';'\n"); continue; } if (!lex.Match("{")) - ErrorPrintf("Malformed TEXTMAP lump: missing '{'\n"); + FatalError("Malformed TEXTMAP lump: missing '{'\n"); int cur_type = 0; @@ -1556,7 +1556,7 @@ void ParseUDMF() Lump_c *lump = FindLevelLump("TEXTMAP"); if (lump == NULL || !lump->Seek(0)) - ErrorPrintf("Error finding TEXTMAP lump.\n"); + FatalError("Error finding TEXTMAP lump.\n"); int remain = lump->Length(); @@ -1570,7 +1570,7 @@ void ParseUDMF() int want = OBSIDIAN_MIN(remain, (int)sizeof(buffer)); if (!lump->Read(buffer, want)) - ErrorPrintf("Error reading TEXTMAP lump.\n"); + FatalError("Error reading TEXTMAP lump.\n"); data.append(buffer, want); @@ -1633,11 +1633,11 @@ void PutVertices(const char *name, int do_gl) lump->Finish(); if (count != (do_gl ? num_new_vert : num_old_vert)) - ErrorPrintf("PutVertices miscounted (%d != %d)\n", count, do_gl ? num_new_vert : num_old_vert); + FatalError("PutVertices miscounted (%d != %d)\n", count, do_gl ? num_new_vert : num_old_vert); if (!do_gl && count > 65534) { - Failure("Number of vertices has overflowed.\n"); + LogPrint("Number of vertices has overflowed.\n"); MarkOverflow(LIMIT_VERTEXES); } } @@ -1676,7 +1676,7 @@ void PutGLVertices(int do_v5) lump->Finish(); if (count != num_new_vert) - ErrorPrintf("PutGLVertices miscounted (%d != %d)\n", count, num_new_vert); + FatalError("PutGLVertices miscounted (%d != %d)\n", count, num_new_vert); } static inline uint16_t VertexIndex16Bit(const vertex_t *v) @@ -1726,7 +1726,7 @@ void PutSegs() lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT SEG: %04X Vert %04X->%04X Line %04X %s " + DebugPrint("PUT SEG: %04X Vert %04X->%04X Line %04X %s " "Angle %04X (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->index, LE_U16(raw.start), LE_U16(raw.end), LE_U16(raw.linedef), seg->side ? "L" : "R", LE_U16(raw.angle), seg->start->x, seg->start->y, seg->end->x, seg->end->y); @@ -1737,7 +1737,7 @@ void PutSegs() if (num_segs > 65534) { - Failure("Number of segs has overflowed.\n"); + LogPrint("Number of segs has overflowed.\n"); MarkOverflow(LIMIT_SEGS); } } @@ -1775,7 +1775,7 @@ void PutGLSegs_V2() lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT GL SEG: %04X Line %04X %s Partner %04X " + DebugPrint("PUT GL SEG: %04X Line %04X %s Partner %04X " "(%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->index, LE_U16(raw.linedef), seg->side ? "L" : "R", LE_U16(raw.partner), seg->start->x, seg->start->y, seg->end->x, seg->end->y); @@ -1815,7 +1815,7 @@ void PutGLSegs_V5() lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT V3 SEG: %06X Line %04X %s Partner %06X " + DebugPrint("PUT V3 SEG: %06X Line %04X %s Partner %06X " "(%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->index, LE_U16(raw.linedef), seg->side ? "L" : "R", LE_U32(raw.partner), seg->start->x, seg->start->y, seg->end->x, seg->end->y); @@ -1843,13 +1843,13 @@ void PutSubsecs(const char *name, int do_gl) lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT SUBSEC %04X First %04X Num %04X\n", sub->index, LE_U16(raw.first), LE_U16(raw.num)); + DebugPrint("PUT SUBSEC %04X First %04X Num %04X\n", sub->index, LE_U16(raw.first), LE_U16(raw.num)); #endif } if (num_subsecs > 32767) { - Failure("Number of %s has overflowed.\n", do_gl ? "GL subsectors" : "subsectors"); + LogPrint("Number of %s has overflowed.\n", do_gl ? "GL subsectors" : "subsectors"); MarkOverflow(do_gl ? LIMIT_GL_SSECT : LIMIT_SSECTORS); } @@ -1874,7 +1874,7 @@ void PutGLSubsecs_V5() lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT V3 SUBSEC %06X First %06X Num %06X\n", sub->index, LE_U32(raw.first), LE_U32(raw.num)); + DebugPrint("PUT V3 SUBSEC %06X First %06X Num %06X\n", sub->index, LE_U32(raw.first), LE_U32(raw.num)); #endif } @@ -1916,19 +1916,19 @@ static void PutOneNode(node_t *node, Lump_c *lump) else if (node->r.subsec) raw.right = LE_U16(node->r.subsec->index | 0x8000); else - ErrorPrintf("Bad right child in node %d\n", node->index); + FatalError("Bad right child in node %d\n", node->index); if (node->l.node) raw.left = LE_U16(node->l.node->index); else if (node->l.subsec) raw.left = LE_U16(node->l.subsec->index | 0x8000); else - ErrorPrintf("Bad left child in node %d\n", node->index); + FatalError("Bad left child in node %d\n", node->index); lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT NODE %04X Left %04X Right %04X " + DebugPrint("PUT NODE %04X Left %04X Right %04X " "(%d,%d) -> (%d,%d)\n", node->index, LE_U16(raw.left), LE_U16(raw.right), node->x, node->y, node->x + node->dx, node->y + node->dy); @@ -1967,19 +1967,19 @@ static void PutOneNode_V5(node_t *node, Lump_c *lump) else if (node->r.subsec) raw.right = LE_U32(node->r.subsec->index | 0x80000000U); else - ErrorPrintf("Bad right child in V5 node %d\n", node->index); + FatalError("Bad right child in V5 node %d\n", node->index); if (node->l.node) raw.left = LE_U32(node->l.node->index); else if (node->l.subsec) raw.left = LE_U32(node->l.subsec->index | 0x80000000U); else - ErrorPrintf("Bad left child in V5 node %d\n", node->index); + FatalError("Bad left child in V5 node %d\n", node->index); lump->Write(&raw, sizeof(raw)); #if DEBUG_BSP - DebugPrintf("PUT V5 NODE %08X Left %08X Right %08X " + DebugPrint("PUT V5 NODE %08X Left %08X Right %08X " "(%d,%d) -> (%d,%d)\n", node->index, LE_U32(raw.left), LE_U32(raw.right), node->x, node->y, node->x + node->dx, node->y + node->dy); @@ -2008,11 +2008,11 @@ void PutNodes(const char *name, int do_v5, node_t *root) lump->Finish(); if (node_cur_index != num_nodes) - ErrorPrintf("PutNodes miscounted (%d != %d)\n", node_cur_index, num_nodes); + FatalError("PutNodes miscounted (%d != %d)\n", node_cur_index, num_nodes); if (!do_v5 && node_cur_index > 32767) { - Failure("Number of nodes has overflowed.\n"); + LogPrint("Number of nodes has overflowed.\n"); MarkOverflow(LIMIT_NODES); } } @@ -2025,21 +2025,21 @@ void CheckLimits() // the other checks below, like the vertex counts). if (num_sectors > 65535) { - Failure("Map has too many sectors.\n"); + LogPrint("Map has too many sectors.\n"); MarkOverflow(LIMIT_SECTORS); } // the sidedef 0xFFFF is reserved to mean "no side" in DOOM map format if (num_sidedefs > 65535) { - Failure("Map has too many sidedefs.\n"); + LogPrint("Map has too many sidedefs.\n"); MarkOverflow(LIMIT_SIDEDEFS); } // the linedef 0xFFFF is reserved for minisegs in GL nodes if (num_linedefs > 65535) { - Failure("Map has too many linedefs.\n"); + LogPrint("Map has too many linedefs.\n"); MarkOverflow(LIMIT_LINEDEFS); } @@ -2047,7 +2047,7 @@ void CheckLimits() { if (num_old_vert > 32767 || num_new_vert > 32767 || num_segs > 65535 || num_nodes > 32767) { - Warning("Forcing V5 of GL-Nodes due to overflows.\n"); + LogPrint("Forcing V5 of GL-Nodes due to overflows.\n"); lev_force_v5 = true; } } @@ -2056,7 +2056,7 @@ void CheckLimits() { if (num_old_vert > 32767 || num_new_vert > 32767 || num_segs > 32767 || num_nodes > 32767) { - Warning("Forcing XNOD format nodes due to overflows.\n"); + LogPrint("Forcing XNOD format nodes due to overflows.\n"); lev_force_xnod = true; } } @@ -2075,7 +2075,7 @@ void SortSegs() // do a sanity check for (int i = 0; i < num_segs; i++) if (lev_segs[i]->index < 0) - ErrorPrintf("Seg %p never reached a subsector!\n", i); + FatalError("Seg %p never reached a subsector!\n", i); // sort segs into ascending index std::sort(lev_segs.begin(), lev_segs.end(), Compare_seg_pred()); @@ -2123,7 +2123,7 @@ void PutZVertices() } if (count != num_new_vert) - ErrorPrintf("PutZVertices miscounted (%d != %d)\n", count, num_new_vert); + FatalError("PutZVertices miscounted (%d != %d)\n", count, num_new_vert); } void PutZSubsecs() @@ -2145,17 +2145,17 @@ void PutZSubsecs() for (const seg_t *seg = sub->seg_list; seg; seg = seg->next, cur_seg_index++) { if (cur_seg_index != seg->index) - ErrorPrintf("PutZSubsecs: seg index mismatch in sub %d (%d != %d)\n", i, cur_seg_index, seg->index); + FatalError("PutZSubsecs: seg index mismatch in sub %d (%d != %d)\n", i, cur_seg_index, seg->index); count++; } if (count != sub->seg_count) - ErrorPrintf("PutZSubsecs: miscounted segs in sub %d (%d != %d)\n", i, count, sub->seg_count); + FatalError("PutZSubsecs: miscounted segs in sub %d (%d != %d)\n", i, count, sub->seg_count); } if (cur_seg_index != num_segs) - ErrorPrintf("PutZSubsecs miscounted segs (%d != %d)\n", cur_seg_index, num_segs); + FatalError("PutZSubsecs miscounted segs (%d != %d)\n", cur_seg_index, num_segs); } void PutZSegs() @@ -2168,7 +2168,7 @@ void PutZSegs() const seg_t *seg = lev_segs[i]; if (seg->index != i) - ErrorPrintf("PutZSegs: seg index mismatch (%d != %d)\n", seg->index, i); + FatalError("PutZSegs: seg index mismatch (%d != %d)\n", seg->index, i); uint32_t v1 = LE_U32(VertexIndex_XNOD(seg->start)); uint32_t v2 = LE_U32(VertexIndex_XNOD(seg->end)); @@ -2193,7 +2193,7 @@ void PutXGL3Segs() const seg_t *seg = lev_segs[i]; if (seg->index != i) - ErrorPrintf("PutXGL3Segs: seg index mismatch (%d != %d)\n", seg->index, i); + FatalError("PutXGL3Segs: seg index mismatch (%d != %d)\n", seg->index, i); uint32_t v1 = LE_U32(VertexIndex_XNOD(seg->start)); uint32_t partner = LE_U32(seg->partner ? seg->partner->index : -1); @@ -2266,20 +2266,20 @@ static void PutOneZNode(node_t *node, bool do_xgl3) else if (node->r.subsec) raw.right = LE_U32(node->r.subsec->index | 0x80000000U); else - ErrorPrintf("Bad right child in V5 node %d\n", node->index); + FatalError("Bad right child in V5 node %d\n", node->index); if (node->l.node) raw.left = LE_U32(node->l.node->index); else if (node->l.subsec) raw.left = LE_U32(node->l.subsec->index | 0x80000000U); else - ErrorPrintf("Bad left child in V5 node %d\n", node->index); + FatalError("Bad left child in V5 node %d\n", node->index); ZLibAppendLump(&raw.right, 4); ZLibAppendLump(&raw.left, 4); #if DEBUG_BSP - DebugPrintf("PUT Z NODE %08X Left %08X Right %08X " + DebugPrint("PUT Z NODE %08X Left %08X Right %08X " "(%d,%d) -> (%d,%d)\n", node->index, LE_U32(raw.left), LE_U32(raw.right), node->x, node->y, node->x + node->dx, node->y + node->dy); @@ -2297,7 +2297,7 @@ void PutZNodes(node_t *root, bool do_xgl3) PutOneZNode(root, do_xgl3); if (node_cur_index != num_nodes) - ErrorPrintf("PutZNodes miscounted (%d != %d)\n", node_cur_index, num_nodes); + FatalError("PutZNodes miscounted (%d != %d)\n", node_cur_index, num_nodes); } static int CalcZDoomNodesSize() @@ -2413,7 +2413,7 @@ void LoadLevel() PruneVerticesAtEnd(); } - LogPrintf(" Loaded %d vertices, %d sectors, %d sides, %d lines, %d things\n", num_vertices, num_sectors, + LogPrint(" Loaded %d vertices, %d sectors, %d sides, %d lines, %d things\n", num_vertices, num_sectors, num_sidedefs, num_linedefs, num_things); DetectOverlappingVertices(); @@ -2476,7 +2476,7 @@ static void AddMissingLump(const char *name, const char *after) // if this happens, the level structure is very broken if (exist < 0) { - Warning("Missing %s lump -- level structure is broken\n", after); + LogPrint("Missing %s lump -- level structure is broken\n", after); exist = cur_wad->LevelLastLump(lev_current_idx); } @@ -2655,7 +2655,7 @@ void ZLibBeginLump(Lump_c *lump) zout_stream.opaque = (voidpf)0; if (Z_OK != deflateInit(&zout_stream, Z_DEFAULT_COMPRESSION)) - ErrorPrintf("Trouble setting up zlib compression\n"); + FatalError("Trouble setting up zlib compression\n"); zout_stream.next_out = zout_buffer; zout_stream.avail_out = sizeof(zout_buffer); @@ -2680,7 +2680,7 @@ void ZLibAppendLump(const void *data, int length) int err = deflate(&zout_stream, Z_NO_FLUSH); if (err != Z_OK) - ErrorPrintf("Trouble compressing %d bytes (zlib)\n", length); + FatalError("Trouble compressing %d bytes (zlib)\n", length); if (zout_stream.avail_out == 0) { @@ -2716,7 +2716,7 @@ void ZLibFinishLump(void) break; if (err != Z_OK) - ErrorPrintf("Trouble finishing compression (zlib)\n"); + FatalError("Trouble finishing compression (zlib)\n"); if (zout_stream.avail_out == 0) { @@ -2820,14 +2820,14 @@ void OpenWad(std::string filename) { cur_wad = Wad_file::Open(filename.c_str(), 'a'); if (cur_wad == NULL) - ErrorPrintf("Cannot open file: %s\n", filename.c_str()); + FatalError("Cannot open file: %s\n", filename.c_str()); if (cur_wad->IsReadOnly()) { delete cur_wad; cur_wad = NULL; - ErrorPrintf("file is read only: %s\n", filename.c_str()); + FatalError("file is read only: %s\n", filename.c_str()); } } @@ -2835,7 +2835,7 @@ void CreateXWA(const char *filename) { xwa_wad = Wad_file::Open(filename, 'w'); if (xwa_wad == NULL) - ErrorPrintf("Cannot create file: %s\n", filename); + FatalError("Cannot create file: %s\n", filename); xwa_wad->BeginWrite(); xwa_wad->AddLump("XG_START")->Finish(); @@ -2915,12 +2915,12 @@ build_result_e BuildLevel(int lev_idx) if (ret == BUILD_OK) { - LogPrintf(" Built %d NODES, %d SSECTORS, %d SEGS, %d VERTEXES\n", num_nodes, num_subsecs, num_segs, + LogPrint(" Built %d NODES, %d SSECTORS, %d SEGS, %d VERTEXES\n", num_nodes, num_subsecs, num_segs, num_old_vert + num_new_vert); if (root_node != NULL) { - LogPrintf(" Heights of subtrees: %d / %d\n", ComputeBspHeight(root_node->r.node), + LogPrint(" Heights of subtrees: %d / %d\n", ComputeBspHeight(root_node->r.node), ComputeBspHeight(root_node->l.node)); } diff --git a/source/bsp_local.h b/source/bsp_local.h index 4276dd1b1..7c3a540f2 100644 --- a/source/bsp_local.h +++ b/source/bsp_local.h @@ -39,16 +39,6 @@ extern buildinfo_t *cur_info; extern Wad_file *cur_wad; -//------------------------------------------------------------------------ -// UTILITY : general purpose functions -//------------------------------------------------------------------------ - -// Assertion macros - -void Failure(const char *fmt, ...); -void Warning(const char *fmt, ...); -void MinorIssue(const char *fmt, ...); - //------------------------------------------------------------------------ // BLOCKMAP : Generate the blockmap //------------------------------------------------------------------------ diff --git a/source/bsp_misc.cc b/source/bsp_misc.cc index 4f9813479..7dfaf368a 100644 --- a/source/bsp_misc.cc +++ b/source/bsp_misc.cc @@ -37,50 +37,6 @@ namespace ajbsp { -#define SYS_MSG_BUFLEN 4000 - -static char message_buf[SYS_MSG_BUFLEN]; - -void Failure(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - vsnprintf(message_buf, sizeof(message_buf), fmt, args); - va_end(args); - - LogPrintf(" FAILURE: %s", message_buf); -} - -void Warning(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - vsnprintf(message_buf, sizeof(message_buf), fmt, args); - va_end(args); - - LogPrintf(" WARNING: %s", message_buf); - - cur_info->total_warnings++; -} - -void MinorIssue(const char *fmt, ...) -{ - if (cur_info->verbosity >= 3) - { - va_list args; - - va_start(args, fmt); - vsnprintf(message_buf, sizeof(message_buf), fmt, args); - va_end(args); - - LogPrintf(" ISSUE: %s", message_buf); - } - - cur_info->total_minor_issues++; -} - //------------------------------------------------------------------------ // ANALYZE : Analyzing level structures //------------------------------------------------------------------------ @@ -95,7 +51,7 @@ void MarkPolyobjSector(sector_t *sector) return; #if DEBUG_POLYOBJ - DebugPrintf(" Marking SECTOR %d\n", sector->index); + DebugPrint(" Marking SECTOR %d\n", sector->index); #endif /* already marked ? */ @@ -143,7 +99,7 @@ void MarkPolyobjPoint(double x, double y) (int)L->end->y)) { #if DEBUG_POLYOBJ - DebugPrintf(" Touching line was %d\n", L->index); + DebugPrint(" Touching line was %d\n", L->index); #endif if (L->left != NULL) @@ -195,7 +151,7 @@ void MarkPolyobjPoint(double x, double y) if (best_match == NULL) { - Warning("Bad polyobj thing at (%1.0f,%1.0f).\n", x, y); + LogPrint("Bad polyobj thing at (%1.0f,%1.0f).\n", x, y); return; } @@ -203,14 +159,14 @@ void MarkPolyobjPoint(double x, double y) double y2 = best_match->end->y; #if DEBUG_POLYOBJ - DebugPrintf(" Closest line was %d Y=%1.0f..%1.0f (dist=%1.1f)\n", best_match->index, y1, y2, best_dist); + DebugPrint(" Closest line was %d Y=%1.0f..%1.0f (dist=%1.1f)\n", best_match->index, y1, y2, best_dist); #endif /* sanity check: shouldn't be directly on the line */ #if DEBUG_POLYOBJ if (fabs(best_dist) < DIST_EPSILON) { - DebugPrintf(" Polyobj FAILURE: directly on the line (%d)\n", best_match->index); + DebugPrint(" Polyobj FAILURE: directly on the line (%d)\n", best_match->index); } #endif @@ -223,12 +179,12 @@ void MarkPolyobjPoint(double x, double y) sector = best_match->left ? best_match->left->sector : NULL; #if DEBUG_POLYOBJ - DebugPrintf(" Sector %d contains the polyobj.\n", sector ? sector->index : -1); + DebugPrint(" Sector %d contains the polyobj.\n", sector ? sector->index : -1); #endif if (sector == NULL) { - Warning("Invalid Polyobj thing at (%1.0f,%1.0f).\n", x, y); + LogPrint("Invalid Polyobj thing at (%1.0f,%1.0f).\n", x, y); return; } @@ -293,7 +249,7 @@ void DetectPolyobjSectors(bool is_udmf) } #if DEBUG_POLYOBJ - DebugPrintf("Using %s style polyobj things\n", hexen_style ? "HEXEN" : "ZDOOM"); + DebugPrint("Using %s style polyobj things\n", hexen_style ? "HEXEN" : "ZDOOM"); #endif for (i = 0; i < num_things; i++) @@ -318,7 +274,7 @@ void DetectPolyobjSectors(bool is_udmf) } #if DEBUG_POLYOBJ - DebugPrintf("Thing %d at (%1.0f,%1.0f) is a polyobj spawner.\n", i, x, y); + DebugPrint("Thing %d at (%1.0f,%1.0f) is a polyobj spawner.\n", i, x, y); #endif MarkPolyobjPoint(x, y); @@ -373,7 +329,7 @@ void DetectOverlappingVertices(void) B->overlap = A->overlap ? A->overlap : A; #if DEBUG_OVERLAPS - LogPrintf("Overlap: #%d + #%d\n", array[i]->index, array[i + 1]->index); + LogPrint("Overlap: #%d + #%d\n", array[i]->index, array[i + 1]->index); #endif } } @@ -422,7 +378,7 @@ void PruneVerticesAtEnd(void) if (unused > 0) { - LogPrintf(" Pruned %d unused vertices at end\n", unused); + LogPrint(" Pruned %d unused vertices at end\n", unused); } num_old_vert = num_vertices; @@ -481,7 +437,7 @@ void DetectOverlappingLines(void) if (count > 0) { - LogPrintf(" Detected %d overlapped linedefs\n", count); + LogPrint(" Detected %d overlapped linedefs\n", count); } } @@ -555,11 +511,11 @@ void CalculateWallTips() { vertex_t *V = lev_vertices[k]; - DebugPrintf("WallTips for vertex %d:\n", k); + DebugPrint("WallTips for vertex %d:\n", k); for (walltip_t *tip = V->tip_set; tip; tip = tip->next) { - DebugPrintf(" Angle=%1.1f left=%d right=%d\n", tip->angle, tip->open_left ? 1 : 0, + DebugPrint(" Angle=%1.1f left=%d right=%d\n", tip->angle, tip->open_left ? 1 : 0, tip->open_right ? 1 : 0); } } @@ -625,7 +581,7 @@ vertex_t *NewVertexDegenerate(vertex_t *start, vertex_t *end) vert->y = start->x; if (dlen == 0) - ErrorPrintf("NewVertexDegenerate: bad delta!\n"); + FatalError("NewVertexDegenerate: bad delta!\n"); dx /= dlen; dy /= dlen; diff --git a/source/bsp_node.cc b/source/bsp_node.cc index b73f52c34..cefcd9918 100644 --- a/source/bsp_node.cc +++ b/source/bsp_node.cc @@ -123,7 +123,7 @@ void seg_t::Recompute() p_length = hypot(pdx, pdy); if (p_length <= 0) - ErrorPrintf("Seg %p has zero p_length.\n", this); + FatalError("Seg %p has zero p_length.\n", this); p_perp = psy * pdx - psx * pdy; p_para = -psx * pdx - psy * pdy; @@ -145,9 +145,9 @@ seg_t *SplitSeg(seg_t *old_seg, double x, double y) { #if DEBUG_SPLIT if (old_seg->linedef) - DebugPrintf("Splitting Linedef %d (%p) at (%1.1f,%1.1f)\n", old_seg->linedef->index, old_seg, x, y); + DebugPrint("Splitting Linedef %d (%p) at (%1.1f,%1.1f)\n", old_seg->linedef->index, old_seg, x, y); else - DebugPrintf("Splitting Miniseg %p at (%1.1f,%1.1f)\n", old_seg, x, y); + DebugPrint("Splitting Miniseg %p at (%1.1f,%1.1f)\n", old_seg, x, y); #endif vertex_t *new_vert = NewVertexFromSplitSeg(old_seg, x, y); @@ -164,7 +164,7 @@ seg_t *SplitSeg(seg_t *old_seg, double x, double y) new_seg->Recompute(); #if DEBUG_SPLIT - DebugPrintf("Splitting Vertex is %04X at (%1.1f,%1.1f)\n", new_vert->index, new_vert->x, new_vert->y); + DebugPrint("Splitting Vertex is %04X at (%1.1f,%1.1f)\n", new_vert->index, new_vert->x, new_vert->y); #endif // handle partners @@ -172,7 +172,7 @@ seg_t *SplitSeg(seg_t *old_seg, double x, double y) if (old_seg->partner) { #if DEBUG_SPLIT - DebugPrintf("Splitting Partner %p\n", old_seg->partner); + DebugPrint("Splitting Partner %p\n", old_seg->partner); #endif new_seg->partner = NewSeg(); @@ -828,12 +828,12 @@ void AddMinisegs(intersection_t *cut_list, seg_t *part, seg_t **left_list, seg_t intersection_t *cut, *next; #if DEBUG_CUTLIST - DebugPrintf("CUT LIST:\n"); - DebugPrintf("PARTITION: (%1.1f,%1.1f) += (%1.1f,%1.1f)\n", part->psx, part->psy, part->pdx, part->pdy); + DebugPrint("CUT LIST:\n"); + DebugPrint("PARTITION: (%1.1f,%1.1f) += (%1.1f,%1.1f)\n", part->psx, part->psy, part->pdx, part->pdy); for (cut = cut_list; cut; cut = cut->next) { - DebugPrintf(" Vertex %8X (%1.1f,%1.1f) Along %1.2f [%d/%d] %s\n", cut->vertex->index, cut->vertex->x, + DebugPrint(" Vertex %8X (%1.1f,%1.1f) Along %1.2f [%d/%d] %s\n", cut->vertex->index, cut->vertex->x, cut->vertex->y, cut->along_dist, cut->open_before ? 1 : 0, cut->open_after ? 1 : 0, cut->self_ref ? "SELFREF" : ""); } @@ -849,7 +849,7 @@ void AddMinisegs(intersection_t *cut_list, seg_t *part, seg_t **left_list, seg_t double len = next->along_dist - cut->along_dist; if (len < -0.001) { - ErrorPrintf("Bad order in intersect list: %1.3f > %1.3f\n", cut->along_dist, next->along_dist); + FatalError("Bad order in intersect list: %1.3f > %1.3f\n", cut->along_dist, next->along_dist); } bool A = cut->open_after; @@ -862,7 +862,7 @@ void AddMinisegs(intersection_t *cut_list, seg_t *part, seg_t **left_list, seg_t if (A != B) { // a mismatch indicates something wrong with level geometry. - // warning about it is probably not worth it, so ignore it. + // LogPrint about it is probably not worth it, so ignore it. continue; } @@ -895,10 +895,10 @@ void AddMinisegs(intersection_t *cut_list, seg_t *part, seg_t **left_list, seg_t ListAddSeg(left_list, buddy); #if DEBUG_CUTLIST - DebugPrintf("AddMiniseg: %p RIGHT (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->start->x, seg->start->y, + DebugPrint("AddMiniseg: %p RIGHT (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->start->x, seg->start->y, seg->end->x, seg->end->y); - DebugPrintf("AddMiniseg: %p LEFT (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", buddy->start->x, buddy->start->y, + DebugPrint("AddMiniseg: %p LEFT (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", buddy->start->x, buddy->start->y, buddy->end->x, buddy->end->y); #endif } @@ -1141,7 +1141,7 @@ seg_t *CreateOneSeg(linedef_t *line, vertex_t *start, vertex_t *end, sidedef_t * // check for bad sidedef if (side->sector == NULL) { - Warning("Bad sidedef on linedef #%d (Z_CheckHeap error)\n", line->index); + LogPrint("Bad sidedef on linedef #%d (Z_CheckHeap error)\n", line->index); } // handle overlapping vertices, pick a nominal one @@ -1190,7 +1190,7 @@ seg_t *CreateSegs() // check for extremely long lines if (hypot(line->start->x - line->end->x, line->start->y - line->end->y) >= 32000) { - Warning("Linedef #%d is VERY long, it may cause problems\n", line->index); + LogPrint("Linedef #%d is VERY long, it may cause problems\n", line->index); } if (line->right != NULL) @@ -1200,7 +1200,7 @@ seg_t *CreateSegs() } else { - Warning("Linedef #%d has no right sidedef!\n", line->index); + LogPrint("Linedef #%d has no right sidedef!\n", line->index); } if (line->left != NULL) @@ -1222,7 +1222,7 @@ seg_t *CreateSegs() { if (line->two_sided) { - Warning("Linedef #%d is 2s but has no left sidedef\n", line->index); + LogPrint("Linedef #%d is 2s but has no left sidedef\n", line->index); line->two_sided = false; } } @@ -1285,7 +1285,7 @@ void subsec_t::ClockwiseOrder() seg_t *seg; #if DEBUG_SUBSEC - DebugPrintf("Subsec: Clockwising %d\n", index); + DebugPrint("Subsec: Clockwising %d\n", index); #endif std::vector array; @@ -1358,11 +1358,11 @@ void subsec_t::ClockwiseOrder() } #if DEBUG_SORTER - DebugPrintf("Sorted SEGS around (%1.1f,%1.1f)\n", mid_x, mid_y); + DebugPrint("Sorted SEGS around (%1.1f,%1.1f)\n", mid_x, mid_y); for (seg = seg_list; seg; seg = seg->next) { - DebugPrintf(" Seg %p: Angle %1.6f (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg, seg->cmp_angle, seg->start->x, + DebugPrint(" Seg %p: Angle %1.6f (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg, seg->cmp_angle, seg->start->x, seg->start->y, seg->end->x, seg->end->y); } #endif @@ -1390,14 +1390,14 @@ void subsec_t::SanityCheckClosed() const if (gaps > 0) { - MinorIssue("Subsector #%d near (%1.1f,%1.1f) is not closed " + LogPrint("Subsector #%d near (%1.1f,%1.1f) is not closed " "(%d gaps, %d segs)\n", index, mid_x, mid_y, gaps, total); #if DEBUG_SUBSEC for (seg = seg_list; seg; seg = seg->next) { - DebugPrintf(" SEG %p (%1.1f,%1.1f) --> (%1.1f,%1.1f)\n", seg, seg->start->x, seg->start->y, + DebugPrint(" SEG %p (%1.1f,%1.1f) --> (%1.1f,%1.1f)\n", seg, seg->start->x, seg->start->y, seg->end->x, seg->end->y); } #endif @@ -1410,13 +1410,13 @@ void subsec_t::SanityCheckHasRealSeg() const if (seg->linedef != NULL) return; - ErrorPrintf("Subsector #%d near (%1.1f,%1.1f) has no real seg!\n", index, mid_x, mid_y); + FatalError("Subsector #%d near (%1.1f,%1.1f) has no real seg!\n", index, mid_x, mid_y); } void subsec_t::RenumberSegs(int &cur_seg_index) { #if DEBUG_SUBSEC - DebugPrintf("Subsec: Renumbering %d\n", index); + DebugPrint("Subsec: Renumbering %d\n", index); #endif seg_count = 0; @@ -1429,7 +1429,7 @@ void subsec_t::RenumberSegs(int &cur_seg_index) seg_count++; #if DEBUG_SUBSEC - DebugPrintf("Subsec: %d: Seg %p Index %d\n", seg_count, seg, seg->index); + DebugPrint("Subsec: %d: Seg %p Index %d\n", seg_count, seg, seg->index); #endif } } @@ -1451,7 +1451,7 @@ subsec_t *CreateSubsec(quadtree_c *tree) sub->DetermineMiddle(); #if DEBUG_SUBSEC - DebugPrintf("Subsec: Creating %d\n", sub->index); + DebugPrint("Subsec: Creating %d\n", sub->index); #endif return sub; @@ -1473,7 +1473,7 @@ void DebugShowSegs(const seg_t *list) { for (const seg_t *seg = list; seg; seg = seg->next) { - DebugPrintf("Build: %sSEG %p (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->linedef ? "" : "MINI", seg, + DebugPrint("Build: %sSEG %p (%1.1f,%1.1f) -> (%1.1f,%1.1f)\n", seg->linedef ? "" : "MINI", seg, seg->start->x, seg->start->y, seg->end->x, seg->end->y); } } @@ -1488,7 +1488,7 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n return BUILD_Cancelled; #if DEBUG_BUILDER - DebugPrintf("Build: BEGUN @ %d\n", depth); + DebugPrint("Build: BEGUN @ %d\n", depth); DebugShowSegs(list); #endif @@ -1506,7 +1506,7 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n if (part == NULL) { #if DEBUG_BUILDER - DebugPrintf("Build: CONVEX\n"); + DebugPrint("Build: CONVEX\n"); #endif *S = CreateSubsec(tree); @@ -1516,7 +1516,7 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n } #if DEBUG_BUILDER - DebugPrintf("Build: PARTITION %p (%1.0f,%1.0f) -> (%1.0f,%1.0f)\n", part, part->start->x, part->start->y, + DebugPrint("Build: PARTITION %p (%1.0f,%1.0f) -> (%1.0f,%1.0f)\n", part, part->start->x, part->start->y, part->end->x, part->end->y); #endif @@ -1535,10 +1535,10 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n /* sanity checks... */ if (rights == NULL) - ErrorPrintf("Separated seg-list has empty RIGHT side\n"); + FatalError("Separated seg-list has empty RIGHT side\n"); if (lefts == NULL) - ErrorPrintf("Separated seg-list has empty LEFT side\n"); + FatalError("Separated seg-list has empty LEFT side\n"); if (cut_list != NULL) AddMinisegs(cut_list, part, &lefts, &rights); @@ -1546,7 +1546,7 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n node->SetPartition(part); #if DEBUG_BUILDER - DebugPrintf("Build: Going LEFT\n"); + DebugPrint("Build: Going LEFT\n"); #endif build_result_e ret; @@ -1557,7 +1557,7 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n return ret; #if DEBUG_BUILDER - DebugPrintf("Build: Going RIGHT\n"); + DebugPrint("Build: Going RIGHT\n"); #endif // recursively build the right side @@ -1566,7 +1566,7 @@ build_result_e BuildNodes(seg_t *list, int depth, bbox_t *bounds /* output */, n return ret; #if DEBUG_BUILDER - DebugPrintf("Build: DONE\n"); + DebugPrint("Build: DONE\n"); #endif return BUILD_OK; @@ -1596,7 +1596,7 @@ void subsec_t::Normalise() seg_t *new_tail = NULL; #if DEBUG_SUBSEC - DebugPrintf("Subsec: Normalising %d\n", index); + DebugPrint("Subsec: Normalising %d\n", index); #endif while (seg_list) @@ -1609,7 +1609,7 @@ void subsec_t::Normalise() if (seg->linedef == NULL) { #if DEBUG_SUBSEC - DebugPrintf("Subsec: Removing miniseg %p\n", seg); + DebugPrint("Subsec: Removing miniseg %p\n", seg); #endif // this causes SortSegs() to remove the seg seg->index = SEG_IS_GARBAGE; @@ -1631,7 +1631,7 @@ void subsec_t::Normalise() } if (new_head == NULL) - ErrorPrintf("Subsector %d normalised to being EMPTY\n", index); + FatalError("Subsector %d normalised to being EMPTY\n", index); seg_list = new_head; } @@ -1680,7 +1680,7 @@ void subsec_t::RoundOff() int degen_total = 0; #if DEBUG_SUBSEC - DebugPrintf("Subsec: Rounding off %d\n", index); + DebugPrint("Subsec: Rounding off %d\n", index); #endif // do an initial pass, just counting the degenerates @@ -1704,7 +1704,7 @@ void subsec_t::RoundOff() } #if DEBUG_SUBSEC - DebugPrintf("Subsec: degen=%d real=%d\n", degen_total, real_total); + DebugPrint("Subsec: degen=%d real=%d\n", degen_total, real_total); #endif // handle the (hopefully rare) case where all of the real segs @@ -1712,10 +1712,10 @@ void subsec_t::RoundOff() if (real_total == 0) { if (last_real_degen == NULL) - ErrorPrintf("Subsector %d rounded off with NO real segs\n", index); + FatalError("Subsector %d rounded off with NO real segs\n", index); #if DEBUG_SUBSEC - DebugPrintf("Degenerate before: (%1.2f,%1.2f) -> (%1.2f,%1.2f)\n", last_real_degen->start->x, + DebugPrint("Degenerate before: (%1.2f,%1.2f) -> (%1.2f,%1.2f)\n", last_real_degen->start->x, last_real_degen->start->y, last_real_degen->end->x, last_real_degen->end->y); #endif @@ -1723,7 +1723,7 @@ void subsec_t::RoundOff() last_real_degen->end = NewVertexDegenerate(last_real_degen->start, last_real_degen->end); #if DEBUG_SUBSEC - DebugPrintf("Degenerate after: (%d,%d) -> (%d,%d)\n", RoundToInteger(last_real_degen->start->x), + DebugPrint("Degenerate after: (%d,%d) -> (%d,%d)\n", RoundToInteger(last_real_degen->start->x), RoundToInteger(last_real_degen->start->y), RoundToInteger(last_real_degen->end->x), RoundToInteger(last_real_degen->end->y)); #endif @@ -1741,7 +1741,7 @@ void subsec_t::RoundOff() if (seg->is_degenerate) { #if DEBUG_SUBSEC - DebugPrintf("Subsec: Removing degenerate %p\n", seg); + DebugPrint("Subsec: Removing degenerate %p\n", seg); #endif // this causes SortSegs() to remove the seg seg->index = SEG_IS_GARBAGE; @@ -1763,7 +1763,7 @@ void subsec_t::RoundOff() } if (new_head == NULL) - ErrorPrintf("Subsector %d rounded off to being EMPTY\n", index); + FatalError("Subsector %d rounded off to being EMPTY\n", index); seg_list = new_head; } diff --git a/source/bsp_wad.cc b/source/bsp_wad.cc index 39bcb95ef..418c47498 100644 --- a/source/bsp_wad.cc +++ b/source/bsp_wad.cc @@ -36,8 +36,8 @@ namespace ajbsp { #if DEBUG_WAD -#define FileMessage DebugPrintf -#define LumpWarning DebugPrintf +#define FileMessage DebugPrint +#define LumpWarning DebugPrint #else void FileMessage(const char *fmt, ...) { @@ -73,7 +73,7 @@ Lump_c::Lump_c(Wad_file *_par, const raw_wad_entry_s *entry) : parent(_par) l_length = LE_U32(entry->size); #if DEBUG_WAD - DebugPrintf("new lump '%s' @ %d len:%d\n", name, l_start, l_length); + DebugPrint("new lump '%s' @ %d len:%d\n", name, l_start, l_length); #endif } @@ -243,16 +243,16 @@ Wad_file *Wad_file::Open(const char *filename, char mode) // determine total size (seek to end) if (fseek(fp, 0, SEEK_END) != 0) - ErrorPrintf("Error determining WAD size.\n"); + FatalError("Error determining WAD size.\n"); w->total_size = (int)ftell(fp); #if DEBUG_WAD - DebugPrintf("total_size = %d\n", w->total_size); + DebugPrint("total_size = %d\n", w->total_size); #endif if (w->total_size < 0) - ErrorPrintf("Error determining WAD size.\n"); + FatalError("Error determining WAD size.\n"); w->ReadDirectory(); w->DetectLevels(); @@ -537,7 +537,7 @@ Lump_c *Wad_file::FindLumpInNamespace(const char *name, char group) break; default: - ErrorPrintf("FindLumpInNamespace: bad group '%c'\n", group); + FatalError("FindLumpInNamespace: bad group '%c'\n", group); } return NULL; // not found! @@ -552,7 +552,7 @@ void Wad_file::ReadDirectory() raw_wad_header_t header; if (fread(&header, sizeof(header), 1, fp) != 1) - ErrorPrintf("Error reading WAD header.\n"); + FatalError("Error reading WAD header.\n"); // WISH: check ident for PWAD or IWAD @@ -562,17 +562,17 @@ void Wad_file::ReadDirectory() dir_count = LE_S32(header.num_entries); if (dir_count < 0 || dir_count > 32000) - ErrorPrintf("Bad WAD header, too many entries (%d)\n", dir_count); + FatalError("Bad WAD header, too many entries (%d)\n", dir_count); if (fseek(fp, dir_start, SEEK_SET) != 0) - ErrorPrintf("Error seeking to WAD directory.\n"); + FatalError("Error seeking to WAD directory.\n"); for (int i = 0; i < dir_count; i++) { raw_wad_entry_t entry; if (fread(&entry, sizeof(entry), 1, fp) != 1) - ErrorPrintf("Error reading WAD directory.\n"); + FatalError("Error reading WAD directory.\n"); Lump_c *lump = new Lump_c(this, &entry); @@ -599,7 +599,7 @@ void Wad_file::DetectLevels() { levels.push_back(k); #if DEBUG_WAD - DebugPrintf("Detected level : %s (UDMF)\n", directory[k]->name); + DebugPrint("Detected level : %s (UDMF)\n", directory[k]->name); #endif continue; } @@ -628,7 +628,7 @@ void Wad_file::DetectLevels() levels.push_back(k); #if DEBUG_WAD - DebugPrintf("Detected level : %s\n", directory[k]->name); + DebugPrint("Detected level : %s\n", directory[k]->name); #endif } } @@ -750,7 +750,7 @@ void Wad_file::ProcessNamespaces() } #if DEBUG_WAD - DebugPrintf("Namespace %c lump : %s\n", active, name); + DebugPrint("Namespace %c lump : %s\n", active, name); #endif switch (active) @@ -769,7 +769,7 @@ void Wad_file::ProcessNamespaces() break; default: - ErrorPrintf("ProcessNamespaces: active = 0x%02x\n", (int)active); + FatalError("ProcessNamespaces: active = 0x%02x\n", (int)active); } } } @@ -791,10 +791,10 @@ bool Wad_file::WasExternallyModified() void Wad_file::BeginWrite() { if (mode == 'r') - ErrorPrintf("Wad_file::BeginWrite() called on read-only file\n"); + FatalError("Wad_file::BeginWrite() called on read-only file\n"); if (begun_write) - ErrorPrintf("Wad_file::BeginWrite() called again without EndWrite()\n"); + FatalError("Wad_file::BeginWrite() called again without EndWrite()\n"); // put the size into a quantum state total_size = 0; @@ -805,7 +805,7 @@ void Wad_file::BeginWrite() void Wad_file::EndWrite() { if (!begun_write) - ErrorPrintf("Wad_file::EndWrite() called without BeginWrite()\n"); + FatalError("Wad_file::EndWrite() called without BeginWrite()\n"); begun_write = false; @@ -1094,12 +1094,12 @@ int Wad_file::PositionForWrite(int max_size) // needlessly complex and hard to follow. if (fseek(fp, 0, SEEK_END) < 0) - ErrorPrintf("Error seeking to new write position.\n"); + FatalError("Error seeking to new write position.\n"); total_size = (int)ftell(fp); if (total_size < 0) - ErrorPrintf("Error seeking to new write position.\n"); + FatalError("Error seeking to new write position.\n"); if (want_pos > total_size) { @@ -1114,11 +1114,11 @@ int Wad_file::PositionForWrite(int max_size) else { if (fseek(fp, want_pos, SEEK_SET) < 0) - ErrorPrintf("Error seeking to new write position.\n"); + FatalError("Error seeking to new write position.\n"); } #if DEBUG_WAD - DebugPrintf("POSITION FOR WRITE: %d (total_size %d)\n", want_pos, total_size); + DebugPrint("POSITION FOR WRITE: %d (total_size %d)\n", want_pos, total_size); #endif return want_pos; @@ -1131,7 +1131,7 @@ bool Wad_file::FinishLump(int final_size) // sanity check if (begun_max_size >= 0) if (final_size > begun_max_size) - ErrorPrintf("Internal Error: wrote too much in lump (%d > %d)\n", final_size, begun_max_size); + FatalError("Internal Error: wrote too much in lump (%d > %d)\n", final_size, begun_max_size); int pos = (int)ftell(fp); @@ -1174,8 +1174,8 @@ void Wad_file::WriteDirectory() dir_count = NumLumps(); #if DEBUG_WAD - DebugPrintf("WriteDirectory...\n"); - DebugPrintf("dir_start:%d dir_count:%d\n", dir_start, dir_count); + DebugPrint("WriteDirectory...\n"); + DebugPrint("dir_start:%d dir_count:%d\n", dir_start, dir_count); #endif for (int k = 0; k < dir_count; k++) @@ -1188,7 +1188,7 @@ void Wad_file::WriteDirectory() lump->MakeEntry(&entry); if (fwrite(&entry, sizeof(entry), 1, fp) != 1) - ErrorPrintf("Error writing WAD directory.\n"); + FatalError("Error writing WAD directory.\n"); } fflush(fp); @@ -1196,11 +1196,11 @@ void Wad_file::WriteDirectory() total_size = (int)ftell(fp); #if DEBUG_WAD - DebugPrintf("total_size: %d\n", total_size); + DebugPrint("total_size: %d\n", total_size); #endif if (total_size < 0) - ErrorPrintf("Error determining WAD size.\n"); + FatalError("Error determining WAD size.\n"); // update header at start of file @@ -1214,7 +1214,7 @@ void Wad_file::WriteDirectory() header.num_entries = LE_U32(dir_count); if (fwrite(&header, sizeof(header), 1, fp) != 1) - ErrorPrintf("Error writing WAD header.\n"); + FatalError("Error writing WAD header.\n"); fflush(fp); } diff --git a/source/csg_bsp.cc b/source/csg_bsp.cc index 13f7df14c..da403bba0 100644 --- a/source/csg_bsp.cc +++ b/source/csg_bsp.cc @@ -113,7 +113,7 @@ snag_c::snag_c(brush_vert_c *side, double _x1, double _y1, double _x2, double _y { if (Length() < SNAG_EPSILON) { - Main::FatalError("Line loop contains zero-length line! (%1.2f %1.2f)\n", x1, y1); + FatalError("Line loop contains zero-length line! (%1.2f %1.2f)\n", x1, y1); } sides.push_back(side); @@ -1086,7 +1086,7 @@ static void DivideOneRegion(region_c *R, partition_c *part, group_c &front, grou if (R->snags.size() < 3) { R->degenerate = true; - LogPrintf("WARNING: region degenerated (%zu snags)\n", R->snags.size()); + LogPrint("WARNING: region degenerated (%zu snags)\n", R->snags.size()); } else { @@ -1096,7 +1096,7 @@ static void DivideOneRegion(region_c *R, partition_c *part, group_c &front, grou if (N->snags.size() < 3) { N->degenerate = true; - LogPrintf("WARNING: region degenerated (%zu snags)\n", N->snags.size()); + LogPrint("WARNING: region degenerated (%zu snags)\n", N->snags.size()); } else { @@ -1251,7 +1251,7 @@ static void SplitGroup(group_c &group, bool reached_chunk, region_c **leaf_out, { if (!group.ents.empty()) { - DebugPrintf("SplitGroup: lost %zu entities\n", group.ents.size()); + DebugPrint("SplitGroup: lost %zu entities\n", group.ents.size()); } return; @@ -1433,7 +1433,7 @@ static bool TestOverlap(std::vector &list, int i, int k) snag_c *S = list[i]; if (S && S->partner == B) { - DebugPrintf("TestOverlap: FOUND DANGLING PARTNER (%zu, %d)\n", i, k); + DebugPrint("TestOverlap: FOUND DANGLING PARTNER (%zu, %d)\n", i, k); S->partner = NULL; } } @@ -1696,11 +1696,11 @@ static void RemoveDeadRegions() int after = (int)all_regions.size(); int count = before - after; - LogPrintf("Removed %d dead regions (of %d)\n", count, before); + LogPrint("Removed %d dead regions (of %d)\n", count, before); if (lost_ents > 0) { - LogPrintf("WARNING: %d entities in dead region\n", lost_ents); + LogPrint("WARNING: %d entities in dead region\n", lost_ents); } /// PruneBSPTree(bsp_root); @@ -1758,7 +1758,7 @@ void CSG_SwallowBrushes() } } - LogPrintf("Swallowed %d brushes (of %d)\n", count, total); + LogPrint("Swallowed %d brushes (of %d)\n", count, total); } static gap_c *GapForEntity(const region_c *R, csg_entity_c *E) @@ -1812,7 +1812,7 @@ static void MarkGapsWithEntities() { if (!csg_is_clip_hull) { - LogPrintf("WARNING: entity '%s' is inside solid @ " + LogPrint("WARNING: entity '%s' is inside solid @ " "(%1.0f,%1.0f,%1.0f)\n", E->id.c_str(), E->x, E->y, E->z); } @@ -1995,10 +1995,10 @@ static void RemoveUnusedGaps() if (filled == total) { - Main::FatalError("CSG: all gaps were unreachable (no entities?)\n"); + FatalError("CSG: all gaps were unreachable (no entities?)\n"); } - LogPrintf("Filled %d gaps (of %d total)\n", filled, total); + LogPrint("Filled %d gaps (of %d total)\n", filled, total); } struct csg_brush_bz_Compare diff --git a/source/csg_doom.cc b/source/csg_doom.cc index bc16d93e6..809ee6ab1 100644 --- a/source/csg_doom.cc +++ b/source/csg_doom.cc @@ -1785,7 +1785,7 @@ static void MergeColinearLines(bool show_count = true) if (show_count) { - LogPrintf("Merged %d colinear lines\n", count); + LogPrint("Merged %d colinear lines\n", count); } } @@ -1915,7 +1915,7 @@ static void AlignTextures() count += prev_count + next_count; } - LogPrintf("Aligned %d textures\n", count); + LogPrint("Aligned %d textures\n", count); } } // namespace Doom @@ -2246,7 +2246,7 @@ static void RoundCorners() } } - LogPrintf("Rounded %d square corners\n", count); + LogPrint("Rounded %d square corners\n", count); // need this again, since we often create co-linear diagonals MergeColinearLines(false /* show_count */); @@ -2839,7 +2839,7 @@ static sector_c *FindDepotPeer() } } - LogPrintf("WARNING: cannot find peer for monster depot.\n"); + LogPrint("WARNING: cannot find peer for monster depot.\n"); return NULL; } @@ -2987,7 +2987,7 @@ static void AddThing_FraggleScript(int x, int y, int z, csg_entity_c *E, int typ if (fs_name.empty()) { - LogPrintf("WARNING: entity lost (no fragglescript name for type #%d)\n", type); + LogPrint("WARNING: entity lost (no fragglescript name for type #%d)\n", type); return; } @@ -3016,7 +3016,7 @@ static void WriteThing(sector_c *S, csg_entity_c *E) if (type <= 0) { - LogPrintf("WARNING: bad doom entity number: '%s'\n", E->id.c_str()); + LogPrint("WARNING: bad doom entity number: '%s'\n", E->id.c_str()); return; } @@ -3194,7 +3194,7 @@ void CSG_DOOM_Write() /// Doom_TestRegions(); /// return; - LogPrintf("DOOM CSG...\n"); + LogPrint("DOOM CSG...\n"); Doom::FreeStuff(); diff --git a/source/csg_main.cc b/source/csg_main.cc index d4d28c0b9..bb9b266d8 100644 --- a/source/csg_main.cc +++ b/source/csg_main.cc @@ -1697,7 +1697,7 @@ void CSG_LinkBrushToEntity(csg_brush_c *B, std::string link_key) } // not found - LogPrintf("WARNING: brush has unknown link entity '%s'\n", link_key.c_str()); + LogPrint("WARNING: brush has unknown link entity '%s'\n", link_key.c_str()); // ensure we ignore this brush B->bkind = BKIND_Light; diff --git a/source/csg_shade.cc b/source/csg_shade.cc index 99aaecf94..d128cbfe3 100644 --- a/source/csg_shade.cc +++ b/source/csg_shade.cc @@ -338,7 +338,7 @@ static void SHADE_LightWorld() if (no_light) { - LogPrintf("LIGHTING DISABLED (-nolight specified)\n"); + LogPrint("LIGHTING DISABLED (-nolight specified)\n"); } for (unsigned int i = 0; i < all_regions.size(); i++) @@ -362,7 +362,7 @@ static void SHADE_LightWorld() void CSG_Shade() { - LogPrintf("Lighting level...\n"); + LogPrint("Lighting level...\n"); // SHADE_CollectLights(); diff --git a/source/csg_spots.cc b/source/csg_spots.cc index ae144c945..2a17071db 100644 --- a/source/csg_spots.cc +++ b/source/csg_spots.cc @@ -117,7 +117,7 @@ void SPOT_FreeGrid() void SPOT_DumpGrid(const char *info) { - DebugPrintf("%s: (%d %d) .. (%d %d)\n", info, grid_min_x, grid_min_y, grid_max_x, grid_max_y); + DebugPrint("%s: (%d %d) .. (%d %d)\n", info, grid_min_x, grid_min_y, grid_max_x, grid_max_y); const int MAX_WIDTH = 256; @@ -163,10 +163,10 @@ void SPOT_DumpGrid(const char *info) buffer[width] = 0; - DebugPrintf(" % 3d %s\n", y, buffer); + DebugPrint(" % 3d %s\n", y, buffer); } - DebugPrintf("\n"); + DebugPrint("\n"); } class grid_point_c @@ -224,7 +224,7 @@ static void test_item_spot(int x, int y, std::vector &spots) int real_x = grid_min_x + (x + 0) * GRID_SIZE; int real_y = grid_min_y + (y + 0) * GRID_SIZE; - DebugPrintf("Item spot ---> [%d %d] real: (%d %d)\n", x, y, real_x, real_y); + DebugPrint("Item spot ---> [%d %d] real: (%d %d)\n", x, y, real_x, real_y); spots.push_back(grid_point_c(real_x, real_y)); @@ -559,7 +559,7 @@ void SPOT_MonsterSpots(std::vector &spots, int want) spots.push_back(grid_point_c(real_x1, real_y1)); spots.push_back(grid_point_c(real_x2, real_y2)); - DebugPrintf("Monster spot ---> [%d %d] size [%d %d]\n", x1, y1, x2 - x1 + 1, y2 - y1 + 1); + DebugPrint("Monster spot ---> [%d %d] size [%d %d]\n", x1, y1, x2 - x1 + 1, y2 - y1 + 1); } else { diff --git a/source/dm_extra.cc b/source/dm_extra.cc index 8656ffffa..4ae0ad7a9 100644 --- a/source/dm_extra.cc +++ b/source/dm_extra.cc @@ -1216,12 +1216,12 @@ static void DoMergeSection(char ch, const char *start1, const char *start2, cons if (end < 0) { - LogPrintf("WARNING: %s found but %s is missing.\n", start1, end1); + LogPrint("WARNING: %s found but %s is missing.\n", start1, end1); return; } else if (end < start) { - LogPrintf("WARNING: %s marker found before %s!\n", end1, start1); + LogPrint("WARNING: %s marker found before %s!\n", end1, start1); return; } @@ -1249,7 +1249,7 @@ int wad_merge_sections(lua_State *L) std::string pkg_name = luaL_checkstring(L, 1); - LogPrintf("Merging WAD sections from: %s\n", pkg_name.c_str()); + LogPrint("Merging WAD sections from: %s\n", pkg_name.c_str()); if (GetExtension(pkg_name) != ".wad") { diff --git a/source/dm_prefab.cc b/source/dm_prefab.cc index 72fd9e579..685bcb24a 100644 --- a/source/dm_prefab.cc +++ b/source/dm_prefab.cc @@ -74,42 +74,6 @@ #include "sys_assert.h" #include "sys_macro.h" -// callbacks for AJ-Polygonator - -static char appl_message[MSG_BUF_LEN]; - -void Appl_FatalError(const char *str, ...) -{ - va_list args; - - va_start(args, str); - vsnprintf(appl_message, MSG_BUF_LEN, str, args); - va_end(args); - - appl_message[MSG_BUF_LEN - 1] = 0; - - Main::FatalError("AJ-Polygonator Failure:\n%s", appl_message); - /* NOT REACHED */ -} - -void Appl_Printf(const char *str, ...) -{ - if (debug_messages) - { - va_list args; - - va_start(args, str); - vsnprintf(appl_message, MSG_BUF_LEN, str, args); - va_end(args); - - appl_message[MSG_BUF_LEN - 1] = 0; - - DebugPrintf("AJPOLY: %s", appl_message); - } -} - -//------------------------------------------------------------------------ - int wadfab_free(lua_State *L) { ajpoly::CloseMap(); diff --git a/source/g_doom.cc b/source/g_doom.cc index b39f5ae88..192be0832 100644 --- a/source/g_doom.cc +++ b/source/g_doom.cc @@ -305,7 +305,7 @@ void Send_Prog_Nodes(int progress, int num_maps) bool BuildNodes(std::string filename) { - LogPrintf("\n"); + LogPrint("\n"); if (!build_nodes) { @@ -334,7 +334,7 @@ bool BuildNodes(std::string filename) if (AJBSP_BuildNodes(filename, &build_info) != 0) { - Main::ProgStatus(_("AJBSP Error!")); + ProgStatus(_("AJBSP Error!")); return false; } @@ -455,7 +455,7 @@ void Doom::AddSectionLump(char ch, std::string name, qLump_c *lump) break; default: - Main::FatalError("DM_AddSectionLump: bad section '%c'\n", ch); + FatalError("DM_AddSectionLump: bad section '%c'\n", ch); } lump->name = name; @@ -631,7 +631,7 @@ void Doom::EndLevel(std::string level_name) ZIPF_CloseWrite(); FileDelete(game_object->ZIP_Filename()); FileDelete(game_object->Filename()); - Main::FatalError(_("Error writing map WAD to %s\n"), game_object->ZIP_Filename().c_str()); + FatalError(_("Error writing map WAD to %s\n"), game_object->ZIP_Filename().c_str()); } else { @@ -1380,7 +1380,7 @@ bool Doom::game_interface_c::Start(const char *preset) if (filename.empty()) { - Main::ProgStatus(_("Cancelled")); + ProgStatus(_("Cancelled")); return false; } @@ -1429,14 +1429,14 @@ bool Doom::game_interface_c::Start(const char *preset) } if (!ZIPF_OpenWrite(zip_filename)) { - Main::ProgStatus(_("Error (create PK3/ZIP)"), zip_filename.c_str()); + ProgStatus(_("Error (create PK3/ZIP)"), zip_filename.c_str()); return false; } } if (!StartWAD(filename)) { - Main::ProgStatus(_("Error (create file)")); + ProgStatus(_("Error (create file)")); return false; } @@ -1516,7 +1516,7 @@ bool Doom::game_interface_c::Finish(bool build_ok) { if (!ZIPF_AddFile(filename, "")) { - LogPrintf("Adding WAD to PK3 failed! Retaining original " + LogPrint("Adding WAD to PK3 failed! Retaining original " "WAD.\n"); ZIPF_CloseWrite(); FileDelete(zip_filename); @@ -1525,7 +1525,7 @@ bool Doom::game_interface_c::Finish(bool build_ok) { if (!ZIPF_CloseWrite()) { - LogPrintf("Corrupt PK3! Retaining original WAD.\n"); + LogPrint("Corrupt PK3! Retaining original WAD.\n"); FileDelete(zip_filename); } else @@ -1578,7 +1578,7 @@ void Doom::game_interface_c::Property(std::string key, std::string value) } else { - LogPrintf("WARNING: unknown DOOM sub_format '%s'\n", value.c_str()); + LogPrint("WARNING: unknown DOOM sub_format '%s'\n", value.c_str()); } } else if (StringCompare(key, "offset_map") == 0) @@ -1599,7 +1599,7 @@ void Doom::game_interface_c::Property(std::string key, std::string value) } else { - LogPrintf("WARNING: unknown DOOM property: %s=%s\n", key.c_str(), value.c_str()); + LogPrint("WARNING: unknown DOOM property: %s=%s\n", key.c_str(), value.c_str()); } } @@ -1617,7 +1617,7 @@ void Doom::game_interface_c::EndLevel() { if (level_name.empty()) { - Main::FatalError("Script problem: did not set level name!\n"); + FatalError("Script problem: did not set level name!\n"); } #ifndef CONSOLE_ONLY diff --git a/source/g_wolf.cc b/source/g_wolf.cc index 5d95040ff..914e4ff15 100644 --- a/source/g_wolf.cc +++ b/source/g_wolf.cc @@ -153,7 +153,7 @@ static void WF_WritePlane(uint16_t *plane, int *offset, int *length) if (write_errors_seen < 10) { write_errors_seen += 1; - LogPrintf("Failure writing to map file! (%d bytes)\n", *length); + LogPrint("Failure writing to map file! (%d bytes)\n", *length); } } } @@ -346,7 +346,7 @@ static void WF_DumpMap(void) line_buf[64] = 0; - DebugPrintf("%s\n", line_buf); + DebugPrint("%s\n", line_buf); } } @@ -430,12 +430,12 @@ bool wolf_game_interface_c::Start(const char *ext) switch (result) { case -1: - LogPrintf("%s\n", _("Error choosing directory:")); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("%s\n", _("Error choosing directory:")); + LogPrint(" %s\n", chooser.errmsg()); break; case 1: - Main::ProgStatus(_("Cancelled")); + ProgStatus(_("Cancelled")); return false; default: @@ -446,7 +446,7 @@ bool wolf_game_interface_c::Start(const char *ext) if (dir_name.empty()) { - LogPrintf("%s\n",_("Empty directory provided???")); + LogPrint("%s\n",_("Empty directory provided???")); dir_name = Resolve_DefaultOutputPath(); } @@ -470,9 +470,9 @@ bool wolf_game_interface_c::Start(const char *ext) if (!map_fp) { - LogPrintf("Unable to create map file:\n%s", strerror(errno)); + LogPrint("Unable to create map file:\n%s", strerror(errno)); - Main::ProgStatus(_("Error (create file)")); + ProgStatus(_("Error (create file)")); return false; } @@ -482,9 +482,9 @@ bool wolf_game_interface_c::Start(const char *ext) { fclose(map_fp); - LogPrintf("Unable to create %s:\n%s", TEMP_HEADFILE, strerror(errno)); + LogPrint("Unable to create %s:\n%s", TEMP_HEADFILE, strerror(errno)); - Main::ProgStatus(_("Error (create file)")); + ProgStatus(_("Error (create file)")); return false; } @@ -529,7 +529,7 @@ bool wolf_game_interface_c::Finish(bool build_ok) if (write_errors_seen > 0) { - Main::ProgStatus(_("Error (write file)")); + ProgStatus(_("Error (write file)")); Tidy(); return false; } @@ -623,7 +623,7 @@ void wolf_game_interface_c::Property(std::string key, std::string value) } else { - LogPrintf("WARNING: unknown WOLF3D property: %s=%s\n", key.c_str(), value.c_str()); + LogPrint("WARNING: unknown WOLF3D property: %s=%s\n", key.c_str(), value.c_str()); } } diff --git a/source/lib_tga.cc b/source/lib_tga.cc index d0f6d2c27..d40a2f89b 100644 --- a/source/lib_tga.cc +++ b/source/lib_tga.cc @@ -117,7 +117,7 @@ tga_image_c *TGA_LoadImage(const char *path) if (targa_header.image_type != TGA_INDEXED && targa_header.image_type != TGA_INDEXED_RLE && targa_header.image_type != TGA_RGB && targa_header.image_type != TGA_RGB_RLE) { - Main::FatalError("Bad tga file: type {} is not supported\n", targa_header.image_type); + FatalError("Bad tga file: type {} is not supported\n", targa_header.image_type); } int width = targa_header.width; @@ -125,7 +125,7 @@ tga_image_c *TGA_LoadImage(const char *path) if (width == 0 || height == 0) { - Main::FatalError("Bad tga file: width or height is zero\n"); + FatalError("Bad tga file: width or height is zero\n"); } tga_image_c *img = new tga_image_c(width, height); @@ -144,17 +144,17 @@ tga_image_c *TGA_LoadImage(const char *path) { if (targa_header.colormap_type != 1) { - Main::FatalError("Bad tga file: colormap type != 1\n"); + FatalError("Bad tga file: colormap type != 1\n"); } if (targa_header.colormap_length > 256) { - Main::FatalError("Bad tga file: too many colors (over 256)\n"); + FatalError("Bad tga file: too many colors (over 256)\n"); } if (targa_header.pixel_bits != 8 || targa_header.colormap_bits < 24) { - Main::FatalError("Bad tga file: unsupported colormap size\n"); + FatalError("Bad tga file: unsupported colormap size\n"); } memset(palette, 255, sizeof(palette)); @@ -187,7 +187,7 @@ tga_image_c *TGA_LoadImage(const char *path) { if (targa_header.pixel_bits != 24 && targa_header.pixel_bits != 32) { - Main::FatalError("Bad tga file: only 24 or 32 bit images supported\n"); + FatalError("Bad tga file: only 24 or 32 bit images supported\n"); } for (int y = height - 1; y >= 0; y--) @@ -223,7 +223,7 @@ tga_image_c *TGA_LoadImage(const char *path) { if (targa_header.pixel_bits != 24 && targa_header.pixel_bits != 32) { - Main::FatalError("Bad tga file: only 24 or 32 bit images supported\n"); + FatalError("Bad tga file: only 24 or 32 bit images supported\n"); } uint8_t r = 0, g = 0, b = 0, a = 0; diff --git a/source/lib_util.cc b/source/lib_util.cc index 6e42b1573..db81d9db4 100644 --- a/source/lib_util.cc +++ b/source/lib_util.cc @@ -316,7 +316,7 @@ char *CStringNew(int length) char *s = (char *)calloc(length + 1, 1); if (!s) - Main::FatalError("Out of memory (%d bytes for string)\n", length); + FatalError("Out of memory (%d bytes for string)\n", length); return s; } @@ -331,7 +331,7 @@ char *CStringDup(const char *original, int limit) char *s = strdup(original); if (!s) - Main::FatalError("Out of memory (copy string)\n"); + FatalError("Out of memory (copy string)\n"); return s; } @@ -374,7 +374,7 @@ std::wstring UTF8ToWString(std::string_view instring) u32c = 0; size_t res = grapheme_decode_utf8(utf8ptr + utf8pos, utf8len, &u32c); if (res < 0) - Main::FatalError("Failed to convert %s to a wide string!\n", std::string(instring).c_str()); + FatalError("Failed to convert %s to a wide string!\n", std::string(instring).c_str()); else utf8pos += res; if (u32c < 0x10000) @@ -409,9 +409,9 @@ std::string WStringToUTF8(std::wstring_view instring) { // print what was safely converted if present if (!outstring.empty()) - Main::FatalError("Failure to convert %s from a wide string!\n", outstring.c_str()); + FatalError("Failure to convert %s from a wide string!\n", outstring.c_str()); else - Main::FatalError("Wide string to UTF-8 conversion failure!\n"); + FatalError("Wide string to UTF-8 conversion failure!\n"); } } else @@ -926,7 +926,7 @@ void *UtilCalloc(int size) void *ret = calloc(1, size); if (!ret) - Main::FatalError("Out of memory (cannot allocate %d bytes)\n", size); + FatalError("Out of memory (cannot allocate %d bytes)\n", size); return ret; } @@ -939,7 +939,7 @@ void *UtilRealloc(void *old, int size) void *ret = realloc(old, size); if (!ret) - Main::FatalError("Out of memory (cannot reallocate %d bytes)\n", size); + FatalError("Out of memory (cannot reallocate %d bytes)\n", size); return ret; } @@ -950,7 +950,7 @@ void *UtilRealloc(void *old, int size) void UtilFree(void *data) { if (data == NULL) - Main::FatalError("Trying to free a NULL pointer\n"); + FatalError("Trying to free a NULL pointer\n"); free(data); } diff --git a/source/lib_wad.cc b/source/lib_wad.cc index 621ba9196..642ba2abb 100644 --- a/source/lib_wad.cc +++ b/source/lib_wad.cc @@ -30,8 +30,6 @@ #include "sys_assert.h" #include "sys_endian.h" -// #define LogPrintf printf - //------------------------------------------------------------------------ // WAD READING //------------------------------------------------------------------------ @@ -47,22 +45,22 @@ bool WAD_OpenRead(std::string filename) if (!wad_R_fp) { - LogPrintf("WAD_OpenRead: no such file: %s\n", filename.c_str()); + LogPrint("WAD_OpenRead: no such file: %s\n", filename.c_str()); return false; } - LogPrintf("Opened WAD file: %s\n", filename.c_str()); + LogPrint("Opened WAD file: %s\n", filename.c_str()); if ((PHYSFS_readBytes(wad_R_fp, &wad_R_header, sizeof(wad_R_header)) / sizeof(wad_R_header)) != 1) { - LogPrintf("WAD_OpenRead: failed reading header\n"); + LogPrint("WAD_OpenRead: failed reading header\n"); PHYSFS_close(wad_R_fp); return false; } if (0 != memcmp(wad_R_header.ident + 1, "WAD", 3)) { - LogPrintf("WAD_OpenRead: not a WAD file!\n"); + LogPrint("WAD_OpenRead: not a WAD file!\n"); PHYSFS_close(wad_R_fp); return false; } @@ -74,14 +72,14 @@ bool WAD_OpenRead(std::string filename) if (wad_R_header.num_entries >= 5000) // sanity check { - LogPrintf("WAD_OpenRead: bad header (%u entries?)\n", static_cast(wad_R_header.num_entries)); + LogPrint("WAD_OpenRead: bad header (%u entries?)\n", static_cast(wad_R_header.num_entries)); PHYSFS_close(wad_R_fp); return false; } if (!PHYSFS_seek(wad_R_fp, wad_R_header.dir_start)) { - LogPrintf("WAD_OpenRead: cannot seek to directory (at 0x%u)\n", + LogPrint("WAD_OpenRead: cannot seek to directory (at 0x%u)\n", static_cast(wad_R_header.dir_start)); PHYSFS_close(wad_R_fp); return false; @@ -98,12 +96,12 @@ bool WAD_OpenRead(std::string filename) { if (i == 0) { - LogPrintf("WAD_OpenRead: could not read any dir-entries!\n"); + LogPrint("WAD_OpenRead: could not read any dir-entries!\n"); WAD_CloseRead(); return false; } - LogPrintf("WAD_OpenRead: hit EOF reading dir-entry %d\n", i); + LogPrint("WAD_OpenRead: hit EOF reading dir-entry %d\n", i); // truncate directory wad_R_header.num_entries = i; @@ -121,7 +119,7 @@ void WAD_CloseRead(void) { PHYSFS_close(wad_R_fp); - LogPrintf("Closed WAD file\n"); + LogPrint("Closed WAD file\n"); delete[] wad_R_dir; wad_R_dir = NULL; @@ -206,11 +204,11 @@ bool WAD_OpenWrite(std::string filename) if (!wad_W_fp) { - LogPrintf("WAD_OpenWrite: cannot create file: %s\n", filename.c_str()); + LogPrint("WAD_OpenWrite: cannot create file: %s\n", filename.c_str()); return false; } - LogPrintf("Created WAD file: %s\n", filename.c_str()); + LogPrint("Created WAD file: %s\n", filename.c_str()); // write out a dummy header raw_wad_header_t header; @@ -228,7 +226,7 @@ void WAD_CloseWrite(void) // write the directory - LogPrintf("Writing WAD directory\n"); + LogPrint("Writing WAD directory\n"); raw_wad_header_t header; @@ -264,7 +262,7 @@ void WAD_CloseWrite(void) fclose(wad_W_fp); wad_W_fp = nullptr; - LogPrintf("Closed WAD file\n"); + LogPrint("Closed WAD file\n"); wad_W_directory.clear(); } @@ -273,7 +271,7 @@ void WAD_NewLump(std::string name) { if (name.size() > 8) { - Main::FatalError("WAD_NewLump: name too long: '%s'\n", name.c_str()); + FatalError("WAD_NewLump: name too long: '%s'\n", name.c_str()); } memset(&wad_W_lump, 0, sizeof(wad_W_lump)); diff --git a/source/m_addons.cc b/source/m_addons.cc index d19f6f51b..4a83238c3 100644 --- a/source/m_addons.cc +++ b/source/m_addons.cc @@ -46,12 +46,12 @@ void VFS_AddFolder(std::string name) if (!PHYSFS_mount(path.c_str(), mount.c_str(), 0)) { - Main::FatalError("Failed to mount '%s' folder in PhysFS:\n%s\n", name.c_str(), + FatalError("Failed to mount '%s' folder in PhysFS:\n%s\n", name.c_str(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); return; /* NOT REACHED */ } - DebugPrintf("mounted folder '%s'\n", name.c_str()); + DebugPrint("mounted folder '%s'\n", name.c_str()); } // install and home directories if different @@ -61,19 +61,19 @@ void VFS_AddBothFolders(std::string name) std::string mount = StringFormat("/%s", name.c_str()); if (!PHYSFS_mount(path.c_str(), mount.c_str(), 0)) { - Main::FatalError("Failed to mount '%s' folder in PhysFS:\n%s\n", name.c_str(), + FatalError("Failed to mount '%s' folder in PhysFS:\n%s\n", name.c_str(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); return; /* NOT REACHED */ } path = PathAppend(home_dir, name); PHYSFS_mount(path.c_str(), mount.c_str(), 0); // this one can fail if not present, that's fine - DebugPrintf("mounted folder '%s'\n", name.c_str()); + DebugPrint("mounted folder '%s'\n", name.c_str()); } bool VFS_AddArchive(std::string filename, bool options_file) { - LogPrintf(" using: %s\n", filename.c_str()); + LogPrint(" using: %s\n", filename.c_str()); // when handling "bare" filenames from the command line (i.e. ones // containing no paths or drive spec) and the file does not exist in @@ -92,12 +92,12 @@ bool VFS_AddArchive(std::string filename, bool options_file) { if (options_file) { - LogPrintf("Failed to mount '%s' archive in PhysFS:\n%s\n", filename.c_str(), + LogPrint("Failed to mount '%s' archive in PhysFS:\n%s\n", filename.c_str(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); } else { - Main::FatalError("Failed to mount '%s' archive in PhysFS:\n%s\n", filename.c_str(), + FatalError("Failed to mount '%s' archive in PhysFS:\n%s\n", filename.c_str(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); } @@ -109,7 +109,7 @@ bool VFS_AddArchive(std::string filename, bool options_file) void VFS_InitAddons(std::string search_dir) { - LogPrintf("Initializing VFS...\n"); + LogPrint("Initializing VFS...\n"); VFS_AddFolder("scripts"); VFS_AddFolder("games"); @@ -120,7 +120,7 @@ void VFS_InitAddons(std::string search_dir) VFS_AddBothFolders("presets"); VFS_AddBothFolders("addons"); - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } void VFS_ParseCommandLine() @@ -135,7 +135,7 @@ void VFS_ParseCommandLine() arg++; - LogPrintf("Command-line addons....\n"); + LogPrint("Command-line addons....\n"); for (; arg < argv::list.size() && !argv::IsOption(arg); arg++, count++) { @@ -144,10 +144,10 @@ void VFS_ParseCommandLine() if (!count) { - Main::FatalError("Missing filename for --addon option\n"); + FatalError("Missing filename for --addon option\n"); } - LogPrintf("DONE\n\n"); + LogPrint("DONE\n\n"); } void VFS_OptParse(std::string name) @@ -178,7 +178,7 @@ void VFS_OptWrite(FILE *fp) void VFS_ScanForPresets() { - LogPrintf("Scanning for presets....\n"); + LogPrint("Scanning for presets....\n"); all_presets.clear(); @@ -187,7 +187,7 @@ void VFS_ScanForPresets() // seems this only happens on out-of-memory error if (!got_names) { - LogPrintf("DONE (none found)\n"); + LogPrint("DONE (none found)\n"); } char **p; @@ -204,19 +204,19 @@ void VFS_ScanForPresets() if (all_presets.size() == 0) { - LogPrintf("DONE (none found)\n"); + LogPrint("DONE (none found)\n"); } else { - LogPrintf("DONE\n"); + LogPrint("DONE\n"); } - LogPrintf("\n"); + LogPrint("\n"); } void VFS_ScanForAddons() { - LogPrintf("Scanning for addons....\n"); + LogPrint("Scanning for addons....\n"); all_addons.clear(); @@ -225,7 +225,7 @@ void VFS_ScanForAddons() // seems this only happens on out-of-memory error if (!got_names) { - LogPrintf("DONE (none found)\n"); + LogPrint("DONE (none found)\n"); } char **p; @@ -245,7 +245,7 @@ void VFS_ScanForAddons() info.enabled = true; } - LogPrintf(" found: %s%s\n", info.name.c_str(), info.enabled ? " (Enabled)" : " (Disabled)"); + LogPrint(" found: %s%s\n", info.name.c_str(), info.enabled ? " (Enabled)" : " (Disabled)"); all_addons.push_back(info); @@ -261,14 +261,14 @@ void VFS_ScanForAddons() if (all_addons.size() == 0) { - LogPrintf("DONE (none found)\n"); + LogPrint("DONE (none found)\n"); } else { - LogPrintf("DONE\n"); + LogPrint("DONE\n"); } - LogPrintf("\n"); + LogPrint("\n"); } //---------------------------------------------------------------------- diff --git a/source/m_cookie.cc b/source/m_cookie.cc index a96799f8e..d4ca3590b 100644 --- a/source/m_cookie.cc +++ b/source/m_cookie.cc @@ -53,11 +53,11 @@ static void Cookie_SetValue(std::string name, std::string value) { if (context == cookie_context_e::Load) { - DebugPrintf("CONFIG: Name: [%s] Value: [%s]\n", name.c_str(), value.c_str()); + DebugPrint("CONFIG: Name: [%s] Value: [%s]\n", name.c_str(), value.c_str()); } else if (context == cookie_context_e::Arguments) { - DebugPrintf("ARGUMENT: Name: [%s] Value: [%s]\n", name.c_str(), value.c_str()); + DebugPrint("ARGUMENT: Name: [%s] Value: [%s]\n", name.c_str(), value.c_str()); } // the new style module syntax @@ -101,13 +101,13 @@ static void Cookie_SetValue(std::string name, std::string value) } else { - LogPrintf("Invalid argument. Will generate new seed.\n"); + LogPrint("Invalid argument. Will generate new seed.\n"); } } catch (std::out_of_range &e) { (void)e; - LogPrintf("Resulting number would be out of range. Will generate new " + LogPrint("Resulting number would be out of range. Will generate new " "seed.\n"); } } @@ -133,7 +133,7 @@ static bool Cookie_ParseLine(std::string buf) if (!(isalpha(buf.front()) || buf.front() == '@')) { - LogPrintf("Weird config line: [%s]\n", buf.c_str()); + LogPrint("Weird config line: [%s]\n", buf.c_str()); return false; } @@ -158,7 +158,7 @@ static bool Cookie_ParseLine(std::string buf) if (name.empty() || value.empty()) { - LogPrintf("Name or value missing!\n"); + LogPrint("Name or value missing!\n"); return false; } @@ -187,7 +187,7 @@ bool Cookie_Load(std::string filename) if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("Loading config file: %s\n", filename.c_str()); + LogPrint("Loading config file: %s\n", filename.c_str()); } int error_count = 0; @@ -219,11 +219,11 @@ bool Cookie_Load(std::string filename) { if (error_count > 0) { - LogPrintf("DONE (found %d parse errors)\n\n", error_count); + LogPrint("DONE (found %d parse errors)\n\n", error_count); } else { - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } } setlocale(LC_NUMERIC, numeric_locale.c_str()); @@ -237,7 +237,7 @@ bool Cookie_LoadString(std::string str, bool _keep_seed) active_module.clear(); - LogPrintf("Reading config data...\n"); + LogPrint("Reading config data...\n"); std::string::size_type oldpos = 0; std::string::size_type pos = 0; @@ -251,7 +251,7 @@ bool Cookie_LoadString(std::string str, bool _keep_seed) } } - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); return true; } @@ -264,13 +264,13 @@ bool Cookie_Save(std::string filename) if (!cookie_fp) { - LogPrintf("Error: unable to create file: %s\n(%s)\n\n", filename.c_str(), strerror(errno)); + LogPrint("Error: unable to create file: %s\n(%s)\n\n", filename.c_str(), strerror(errno)); return false; } if (main_action == MAIN_HARD_RESTART || main_action == MAIN_QUIT) { - LogPrintf("Saving config file...\n"); + LogPrint("Saving config file...\n"); } // header... @@ -291,7 +291,7 @@ bool Cookie_Save(std::string filename) if (main_action == MAIN_HARD_RESTART || main_action == MAIN_QUIT) { - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } fclose(cookie_fp); @@ -355,7 +355,7 @@ void Cookie_ParseArguments(void) if (name[0] == 0 || value[0] == 0) { - Main::FatalError("Bad setting on command line: '%s'\n", arg.c_str()); + FatalError("Bad setting on command line: '%s'\n", arg.c_str()); } Cookie_SetValue(name.c_str(), value); diff --git a/source/m_dialog.cc b/source/m_dialog.cc index 9b2d849da..762a0e9e0 100644 --- a/source/m_dialog.cc +++ b/source/m_dialog.cc @@ -205,7 +205,7 @@ void DLG_ShowError(const char *msg, ...) buffer[MSG_BUF_LEN - 2] = 0; - LogPrintf("\n%s\n\n", buffer); + LogPrint("\n%s\n\n", buffer); const char *link_title = NULL; const char *link_url = NULL; @@ -278,8 +278,8 @@ std::string DLG_OutputFilename(const char *ext, const char *preset) switch (result) { case -1: - LogPrintf("%s\n", _("Error choosing output file:")); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("%s\n", _("Error choosing output file:")); + LogPrint(" %s\n", chooser.errmsg()); DLG_ShowError(_("Unable to create the file:\n\n%s"), chooser.errmsg()); return ""; diff --git a/source/m_lua.cc b/source/m_lua.cc index c641ed46f..a372fdb65 100644 --- a/source/m_lua.cc +++ b/source/m_lua.cc @@ -125,7 +125,7 @@ int gui_ref_print(lua_State *L) res += 2; } - RefPrintf("%s", res); + RefPrint("%s", res); } return 0; @@ -148,7 +148,7 @@ int gui_raw_log_print(lua_State *L) res += 2; } - LogPrintf("%s", res); + LogPrint("%s", res); } return 0; @@ -165,7 +165,7 @@ int gui_raw_debug_print(lua_State *L) const char *res = luaL_checkstring(L, 1); SYS_ASSERT(res); - DebugPrintf("%s", res); + DebugPrint("%s", res); } return 0; @@ -371,7 +371,7 @@ static bool scan_dir_process_name(const std::string &name, const std::string &pa return GetExtension(name) == "." + std::string{match.begin() + 2, match.end()}; } - Main::FatalError("gui.scan_directory: unsupported match expression: %s\n", match.c_str()); + FatalError("gui.scan_directory: unsupported match expression: %s\n", match.c_str()); return false; /* NOT REACHED */ } @@ -472,7 +472,7 @@ int gui_add_choice(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_choice called late.\n"); + FatalError("Script problem: gui.add_choice called late.\n"); } if (!main_win->game_box->AddChoice(button, id, label)) @@ -568,7 +568,7 @@ int gui_add_module(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_module called late.\n"); + FatalError("Script problem: gui.add_module called late.\n"); } if (StringCompare(where, "arch") == 0) @@ -705,7 +705,7 @@ int gui_add_module_header(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_module_header called late.\n"); + FatalError("Script problem: gui.add_module_header called late.\n"); } for (int i = 0; i < main_win->mod_tabs->children(); i++) @@ -722,7 +722,7 @@ int gui_add_module_header(lua_State *L) } } - Main::FatalError("Script problem: gui.add_module_header_option called for " + FatalError("Script problem: gui.add_module_header_option called for " "non-existent module!\n"); #endif return 0; @@ -751,7 +751,7 @@ int gui_add_module_url(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_module_url called late.\n"); + FatalError("Script problem: gui.add_module_url called late.\n"); } for (int i = 0; i < main_win->mod_tabs->children(); i++) @@ -768,7 +768,7 @@ int gui_add_module_url(lua_State *L) } } - Main::FatalError("Script problem: gui.add_module_url called for " + FatalError("Script problem: gui.add_module_url called for " "non-existent module!\n"); #endif return 0; @@ -801,7 +801,7 @@ int gui_add_module_option(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_module_option called late.\n"); + FatalError("Script problem: gui.add_module_option called late.\n"); } for (int i = 0; i < main_win->mod_tabs->children(); i++) @@ -818,7 +818,7 @@ int gui_add_module_option(lua_State *L) } } - Main::FatalError("Script problem: gui.add_module_option called for " + FatalError("Script problem: gui.add_module_option called for " "non-existent module!\n"); #endif return 0; @@ -859,7 +859,7 @@ int gui_add_module_slider_option(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_module_option called late.\n"); + FatalError("Script problem: gui.add_module_option called late.\n"); } for (int i = 0; i < main_win->mod_tabs->children(); i++) @@ -877,7 +877,7 @@ int gui_add_module_slider_option(lua_State *L) } } - Main::FatalError("Script problem: gui.add_module_slider_option called for " + FatalError("Script problem: gui.add_module_slider_option called for " "non-existent module!\n"); #endif return 0; @@ -910,7 +910,7 @@ int gui_add_module_button_option(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_module_option called late.\n"); + FatalError("Script problem: gui.add_module_option called late.\n"); } for (int i = 0; i < main_win->mod_tabs->children(); i++) @@ -927,7 +927,7 @@ int gui_add_module_button_option(lua_State *L) } } - Main::FatalError("Script problem: gui.add_module_button_option called for " + FatalError("Script problem: gui.add_module_button_option called for " "non-existent module!\n"); #endif return 0; @@ -954,7 +954,7 @@ int gui_add_option_choice(lua_State *L) // only allowed during startup if (has_added_buttons) { - Main::FatalError("Script problem: gui.add_option_choice called late.\n"); + FatalError("Script problem: gui.add_option_choice called late.\n"); } for (int i = 0; i < main_win->mod_tabs->children(); i++) @@ -1165,7 +1165,7 @@ int gui_at_level(lua_State *L) int index = luaL_checkinteger(L, 2); int total = luaL_checkinteger(L, 3); - Main::ProgStatus("%s %s", _("Making"), name.c_str()); + ProgStatus("%s %s", _("Making"), name.c_str()); #ifndef CONSOLE_ONLY if (main_win) { @@ -1691,14 +1691,14 @@ static bool Script_CallFunc(std::string func_name, int nresult = 0, std::string if (lua_type(LUA_ST, -1) == LUA_TNIL) { - Main::FatalError("Script problem: missing function 'ob_traceback'"); + FatalError("Script problem: missing function 'ob_traceback'"); } lua_getglobal(LUA_ST, func_name.c_str()); if (lua_type(LUA_ST, -1) == LUA_TNIL) { - Main::FatalError("Script problem: missing function '%s'", func_name.c_str()); + FatalError("Script problem: missing function '%s'", func_name.c_str()); } int nargs = 0; @@ -1728,7 +1728,7 @@ static bool Script_CallFunc(std::string func_name, int nresult = 0, std::string if (batch_mode) { - LogPrintf("ERROR MESSAGE: %s\n", err_msg); + LogPrint("ERROR MESSAGE: %s\n", err_msg); } // this will appear in the log file too @@ -1845,7 +1845,7 @@ void Script_Load(std::string script_name) std::string filename = PathAppend(import_dir, script_name); - DebugPrintf(" loading script: '%s'\n", filename.c_str()); + DebugPrint(" loading script: '%s'\n", filename.c_str()); int status = my_loadfile(LUA_ST, filename); @@ -1858,7 +1858,7 @@ void Script_Load(std::string script_name) { const char *msg = lua_tolstring(LUA_ST, -1, NULL); - Main::FatalError("Unable to load script '%s'\n%s", filename.c_str(), msg); + FatalError("Unable to load script '%s'\n%s", filename.c_str(), msg); } } @@ -1866,7 +1866,7 @@ void Script_Open() { if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("\n--- OPENING LUA VM ---\n\n"); + LogPrint("\n--- OPENING LUA VM ---\n\n"); } // create Lua state @@ -1874,13 +1874,13 @@ void Script_Open() LUA_ST = luaL_newstate(); if (!LUA_ST) { - Main::FatalError("LUA Init failed: cannot create new state"); + FatalError("LUA Init failed: cannot create new state"); } int status = p_init_lua(LUA_ST); if (status != 0) { - Main::FatalError("LUA Init failed: cannot load standard libs (%d)", status); + FatalError("LUA Init failed: cannot load standard libs (%d)", status); } // load main scripts @@ -1889,14 +1889,14 @@ void Script_Open() if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("Loading initial script: init.lua\n"); + LogPrint("Loading initial script: init.lua\n"); } Script_Load("init.lua"); if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("Loading main script: obsidian.lua\n"); + LogPrint("Loading main script: obsidian.lua\n"); } Script_Load("obsidian.lua"); @@ -1904,7 +1904,7 @@ void Script_Open() has_loaded = true; if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } // ob_init() will load all the game-specific scripts, engine scripts, and @@ -1914,14 +1914,14 @@ void Script_Open() { if (!Script_CallFunc("ob_restart")) { - Main::FatalError("The ob_init script failed.\n"); + FatalError("The ob_init script failed.\n"); } } else { if (!Script_CallFunc("ob_init")) { - Main::FatalError("The ob_init script failed.\n"); + FatalError("The ob_init script failed.\n"); } } @@ -1937,7 +1937,7 @@ void Script_Close() if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("\n--- CLOSED LUA VM ---\n\n"); + LogPrint("\n--- CLOSED LUA VM ---\n\n"); } LUA_ST = NULL; @@ -1957,7 +1957,7 @@ bool ob_set_config(std::string key, std::string value) if (!has_loaded) { - DebugPrintf("ob_set_config(%s) called before loaded!\n", key.c_str()); + DebugPrint("ob_set_config(%s) called before loaded!\n", key.c_str()); return false; } @@ -1974,7 +1974,7 @@ bool ob_set_mod_option(std::string module, std::string option, std::string value { if (!has_loaded) { - DebugPrintf("ob_set_mod_option() called before loaded!\n"); + DebugPrint("ob_set_mod_option() called before loaded!\n"); return false; } @@ -1987,7 +1987,7 @@ bool ob_read_all_config(std::vector *lines, bool need_full) { if (!has_loaded) { - DebugPrintf("ob_read_all_config() called before loaded!\n"); + DebugPrint("ob_read_all_config() called before loaded!\n"); return false; } @@ -2160,7 +2160,7 @@ void ob_invoke_hook(std::string hookname) if (!Script_CallFunc("ob_invoke_hook", 0, ¶ms[0])) { - Main::ProgStatus(_("Script Error")); + ProgStatus(_("Script Error")); } } @@ -2176,7 +2176,7 @@ bool ob_build_cool_shit() .c_str()); } #endif - Main::ProgStatus(_("Script Error")); + ProgStatus(_("Script Error")); #ifndef CONSOLE_ONLY if (main_win) { @@ -2201,7 +2201,7 @@ bool ob_build_cool_shit() return true; } - Main::ProgStatus(_("Cancelled")); + ProgStatus(_("Cancelled")); return false; } diff --git a/source/m_manage.cc b/source/m_manage.cc index 141c69b70..5b975e06e 100644 --- a/source/m_manage.cc +++ b/source/m_manage.cc @@ -423,8 +423,8 @@ class UI_Manage_Config : public Fl_Double_Window switch (chooser.show()) { case -1: - LogPrintf("%s\n", _("Error choosing save file:")); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("%s\n", _("Error choosing save file:")); + LogPrint(" %s\n", chooser.errmsg()); DLG_ShowError(_("Unable to save the file:\n\n%s"), chooser.errmsg()); return NULL; @@ -489,8 +489,8 @@ class UI_Manage_Config : public Fl_Double_Window switch (chooser.show()) { case -1: - LogPrintf("%s\n", _("Error choosing load file:")); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("%s\n", _("Error choosing load file:")); + LogPrint(" %s\n", chooser.errmsg()); DLG_ShowError(_("Unable to load the file:\n\n%s"), chooser.errmsg()); return ""; diff --git a/source/m_options.cc b/source/m_options.cc index a00bdee8b..9e9d8a10d 100644 --- a/source/m_options.cc +++ b/source/m_options.cc @@ -184,13 +184,13 @@ bool Options_Save(std::string filename) if (!option_fp) { - LogPrintf("Error: unable to create file: %s\n(%s)\n\n", filename.c_str(), strerror(errno)); + LogPrint("Error: unable to create file: %s\n(%s)\n\n", filename.c_str(), strerror(errno)); return false; } if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("Saving options file...\n"); + LogPrint("Saving options file...\n"); } fprintf(option_fp, "-- OPTIONS FILE : OBSIDIAN %s \"%s\"\n", OBSIDIAN_SHORT_VERSION, OBSIDIAN_CODE_NAME.c_str()); @@ -227,7 +227,7 @@ bool Options_Save(std::string filename) if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } return true; @@ -587,8 +587,8 @@ class UI_OptionsWin : public Fl_Window switch (result) { case -1: - LogPrintf("%s\n", _("Error choosing directory:")); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("%s\n", _("Error choosing directory:")); + LogPrint(" %s\n", chooser.errmsg()); return; @@ -603,7 +603,7 @@ class UI_OptionsWin : public Fl_Window if (dir_name.empty()) { - LogPrintf("%s\n", _("Empty default directory provided???")); + LogPrint("%s\n", _("Empty default directory provided???")); return; } diff --git a/source/m_theme.cc b/source/m_theme.cc index 657e74c07..bd305b2a2 100644 --- a/source/m_theme.cc +++ b/source/m_theme.cc @@ -63,8 +63,8 @@ std::string Theme_OutputFilename() switch (chooser.show()) { case -1: - LogPrintf("Error choosing output file:\n"); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("Error choosing output file:\n"); + LogPrint(" %s\n", chooser.errmsg()); DLG_ShowError(_("Unable to create the file:\n\n%s"), chooser.errmsg()); return ""; @@ -107,8 +107,8 @@ std::string Theme_AskLoadFilename() switch (result) { case -1: - LogPrintf("Error choosing load file:\n"); - LogPrintf(" %s\n", chooser.errmsg()); + LogPrint("Error choosing load file:\n"); + LogPrint(" %s\n", chooser.errmsg()); DLG_ShowError(_("Unable to load the file:\n\n%s"), chooser.errmsg()); return ""; @@ -254,7 +254,7 @@ static void Parse_Theme_Option(std::string name, std::string value) } else { - LogPrintf("Unknown option: '%s'\n", name.c_str()); + LogPrint("Unknown option: '%s'\n", name.c_str()); } } @@ -276,7 +276,7 @@ static bool Theme_Options_ParseLine(std::string buf) if (!(isalpha(buf.front()) || buf.front() == '@')) { - LogPrintf("Weird theme option line: [%s]\n", buf.c_str()); + LogPrint("Weird theme option line: [%s]\n", buf.c_str()); return false; } @@ -286,7 +286,7 @@ static bool Theme_Options_ParseLine(std::string buf) if (name.empty() || value.empty()) { - LogPrintf("Name or value missing!\n"); + LogPrint("Name or value missing!\n"); return false; } @@ -300,11 +300,11 @@ bool Theme_Options_Load(std::string filename) if (!option_fp) { - LogPrintf("Missing Theme file -- using defaults.\n\n"); + LogPrint("Missing Theme file -- using defaults.\n\n"); return false; } - LogPrintf("Loading theme file: %s\n", filename.c_str()); + LogPrint("Loading theme file: %s\n", filename.c_str()); int error_count = 0; @@ -331,11 +331,11 @@ bool Theme_Options_Load(std::string filename) if (error_count > 0) { - LogPrintf("DONE (found %d parse errors)\n\n", error_count); + LogPrint("DONE (found %d parse errors)\n\n", error_count); } else { - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } fclose(option_fp); @@ -349,13 +349,13 @@ bool Theme_Options_Save(std::string filename) if (!option_fp) { - LogPrintf("Error: unable to create file: %s\n(%s)\n\n", filename.c_str(), strerror(errno)); + LogPrint("Error: unable to create file: %s\n(%s)\n\n", filename.c_str(), strerror(errno)); return false; } if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("Saving theme file...\n"); + LogPrint("Saving theme file...\n"); } fprintf(option_fp, "-- THEME FILE : OBSIDIAN %s \"%s\"\n", OBSIDIAN_SHORT_VERSION, OBSIDIAN_CODE_NAME.c_str()); @@ -400,7 +400,7 @@ bool Theme_Options_Save(std::string filename) if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } return true; diff --git a/source/m_trans.cc b/source/m_trans.cc index 6ddc25ac5..db1a79ce8 100644 --- a/source/m_trans.cc +++ b/source/m_trans.cc @@ -884,7 +884,7 @@ struct po_parse_state_t if (*p++ != '"') { - LogPrintf("WARNING: missing string on line %d\n", line_number); + LogPrint("WARNING: missing string on line %d\n", line_number); return; } @@ -892,13 +892,13 @@ struct po_parse_state_t { if (*p == 0) { - LogPrintf("WARNING: unterminated string on line %d\n", line_number); + LogPrint("WARNING: unterminated string on line %d\n", line_number); break; } if (dest >= dest_end) { - LogPrintf("WARNING: string too long on line %d\n", line_number); + LogPrint("WARNING: string too long on line %d\n", line_number); break; } @@ -913,7 +913,7 @@ struct po_parse_state_t if (*p == 0) { - LogPrintf("WARNING: unterminated string on line %d\n", line_number); + LogPrint("WARNING: unterminated string on line %d\n", line_number); break; } @@ -950,7 +950,7 @@ struct po_parse_state_t break; default: - LogPrintf("WARNING: strange escape sequence on line %d\n", line_number); + LogPrint("WARNING: strange escape sequence on line %d\n", line_number); break; } } @@ -971,7 +971,7 @@ struct po_parse_state_t } else { - LogPrintf("WARNING: unexpected string on line %d\n", line_number); + LogPrint("WARNING: unexpected string on line %d\n", line_number); } } @@ -1060,7 +1060,7 @@ void Trans_Read_PO_File(FILE *fp) } else { - LogPrintf("WARNING: unsupported keyword on line %d\n", po_state.line_number); + LogPrint("WARNING: unsupported keyword on line %d\n", po_state.line_number); } if (feof(fp) || ferror(fp)) @@ -1077,7 +1077,7 @@ void Trans_Init() #ifndef WIN32 if (!setlocale(LC_ALL, "")) { - LogPrintf("WARNING : failed to initialize locale (check localdef)\n\n"); + LogPrint("WARNING : failed to initialize locale (check localdef)\n\n"); } #endif @@ -1087,7 +1087,7 @@ void Trans_Init() if (!FileExists(path)) { - LogPrintf("WARNING: missing language/LANGS.txt file\n"); + LogPrint("WARNING: missing language/LANGS.txt file\n"); return; } @@ -1095,11 +1095,11 @@ void Trans_Init() if (!trans_fp) { - LogPrintf("WARNING: Error opening LANGS.txt!\n"); + LogPrint("WARNING: Error opening LANGS.txt!\n"); return; } - LogPrintf("Loading language list: %s\n", path.c_str()); + LogPrint("Loading language list: %s\n", path.c_str()); std::string buffer; int c = EOF; @@ -1122,7 +1122,7 @@ void Trans_Init() fclose(trans_fp); - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } void Trans_SetLanguage() @@ -1135,7 +1135,7 @@ void Trans_SetLanguage() { langcode = Trans_GetUserLanguage(); - LogPrintf("Detected user language: '%s'\n", langcode.c_str()); + LogPrint("Detected user language: '%s'\n", langcode.c_str()); } std::string lang_plain = remove_territory(langcode); @@ -1144,7 +1144,7 @@ void Trans_SetLanguage() if (lang_plain == "UNKNOWN" || lang_plain == "en") { - LogPrintf("Using the default language (English)\n\n"); + LogPrint("Using the default language (English)\n\n"); selected_lang = "en"; return; } @@ -1163,21 +1163,21 @@ void Trans_SetLanguage() FILE *fp = FileOpen(path, "rb"); if (!fp) { - LogPrintf("No translation file: language/%s.po\n", lang_plain.c_str()); - LogPrintf("Using the default language (English)\n\n"); + LogPrint("No translation file: language/%s.po\n", lang_plain.c_str()); + LogPrint("Using the default language (English)\n\n"); selected_lang = "en"; return; } selected_lang = lang_plain; - LogPrintf("Loading translation: %s\n", path.c_str()); + LogPrint("Loading translation: %s\n", path.c_str()); Trans_Read_PO_File(fp); fclose(fp); - LogPrintf("DONE.\n\n"); + LogPrint("DONE.\n\n"); } std::string Trans_GetAvailCode(int idx) diff --git a/source/main.cc b/source/main.cc index c689bde29..124ff1ae6 100644 --- a/source/main.cc +++ b/source/main.cc @@ -372,7 +372,7 @@ std::string Resolve_DefaultOutputPath() { if (default_output_path.empty()) { - default_output_path = install_dir; + default_output_path = home_dir; } if (default_output_path[0] == '$') { @@ -435,7 +435,7 @@ bool Main::BackupFile(const std::string &filename) ReplaceExtension(backup_name, StringFormat("%s.%s", GetExtension(backup_name).c_str(), ".bak")); - LogPrintf("Backing up existing file to: %s\n", backup_name.c_str()); + LogPrint("Backing up existing file to: %s\n", backup_name.c_str()); FileDelete(backup_name); FileRename(filename, backup_name); @@ -1053,7 +1053,7 @@ bool Build_Cool_Shit() if (format.empty()) { - Main::FatalError("ERROR: missing 'format' for game?!?\n"); + FatalError("ERROR: missing 'format' for game?!?\n"); } // create game object @@ -1068,7 +1068,7 @@ bool Build_Cool_Shit() } else { - Main::FatalError("ERROR: unknown format: '%s'\n", format.c_str()); + FatalError("ERROR: unknown format: '%s'\n", format.c_str()); } } @@ -1140,12 +1140,12 @@ bool Build_Cool_Shit() } if (was_ok) { - Main::ProgStatus(_("Success")); + ProgStatus(_("Success")); const uint32_t end_time = TimeGetMillies(); const uint32_t total_time = end_time - start_time; - LogPrintf("\nTOTAL TIME: %g seconds\n\n", total_time / 1000.0); + LogPrint("\nTOTAL TIME: %g seconds\n\n", total_time / 1000.0); string_seed.clear(); @@ -1190,7 +1190,7 @@ bool Build_Cool_Shit() .c_str()); } #endif - Main::ProgStatus(_("Cancelled")); + ProgStatus(_("Cancelled")); } // Insurance in case the build process errored/cancelled @@ -1283,7 +1283,7 @@ hardrestart:; if (!PHYSFS_init(argv::list[0].c_str())) { - Main::FatalError("Failed to init PhysFS:\n%s\n", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); + FatalError("Failed to init PhysFS:\n%s\n", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); } if (argv::Find('?', NULL) >= 0 || argv::Find('h', "help") >= 0) @@ -1335,7 +1335,7 @@ hardrestart:; { if (batch_arg + 1 >= argv::list.size() || argv::IsOption(batch_arg + 1)) { - ErrorPrintf("OBSIDIAN ERROR: missing filename for --batch\n"); + FatalError("OBSIDIAN ERROR: missing filename for --batch\n"); exit(EXIT_FAILURE); } @@ -1370,19 +1370,19 @@ hardrestart:; if (update_arg + 3 >= argv::list.size() || argv::IsOption(update_arg + 1) || argv::IsOption(update_arg + 2) || argv::IsOption(update_arg + 3)) { - ErrorPrintf("OBSIDIAN ERROR: missing one or more args for --update " + FatalError("OBSIDIAN ERROR: missing one or more args for --update " "
\n"); exit(EXIT_FAILURE); } if (argv::list[update_arg + 1].length() > 1) { - ErrorPrintf("OBSIDIAN ERROR: section name must be one character\n"); + FatalError("OBSIDIAN ERROR: section name must be one character\n"); exit(EXIT_FAILURE); } char section = argv::list[update_arg + 1][0]; if (section != 'c' && section != 'o') { - ErrorPrintf("OBSIDIAN ERROR: section name must be 'c' or 'o'\n"); + FatalError("OBSIDIAN ERROR: section name must be 'c' or 'o'\n"); exit(EXIT_FAILURE); } update_kv.section = section; @@ -1431,20 +1431,20 @@ hardrestart:; LogEnableTerminal(true); } - LogPrintf("\n"); - LogPrintf("********************************************************\n"); - LogPrintf("** %s %s \"%s\" **\n", OBSIDIAN_TITLE.c_str(), OBSIDIAN_SHORT_VERSION, OBSIDIAN_CODE_NAME.c_str()); - LogPrintf("** Build %s **\n", OBSIDIAN_VERSION); - LogPrintf("********************************************************\n"); - LogPrintf("\n"); + LogPrint("\n"); + LogPrint("********************************************************\n"); + LogPrint("** %s %s \"%s\" **\n", OBSIDIAN_TITLE.c_str(), OBSIDIAN_SHORT_VERSION, OBSIDIAN_CODE_NAME.c_str()); + LogPrint("** Build %s **\n", OBSIDIAN_VERSION); + LogPrint("********************************************************\n"); + LogPrint("\n"); #ifndef CONSOLE_ONLY - LogPrintf("Library versions: FLTK %d.%d.%d\n\n", FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION); + LogPrint("Library versions: FLTK %d.%d.%d\n\n", FL_MAJOR_VERSION, FL_MINOR_VERSION, FL_PATCH_VERSION); #endif - LogPrintf("home_dir: %s\n", home_dir.c_str()); - LogPrintf("install_dir: %s\n", install_dir.c_str()); - LogPrintf("config_file: %s\n\n", config_file.c_str()); + LogPrint("home_dir: %s\n", home_dir.c_str()); + LogPrint("install_dir: %s\n", install_dir.c_str()); + LogPrint("config_file: %s\n\n", config_file.c_str()); if (!batch_mode) { @@ -1484,7 +1484,7 @@ softrestart:; { if (load_arg + 1 >= argv::list.size() || argv::IsOption(load_arg + 1)) { - ErrorPrintf("OBSIDIAN ERROR: missing filename for --load\n"); + FatalError("OBSIDIAN ERROR: missing filename for --load\n"); exit(EXIT_FAILURE); } @@ -1545,7 +1545,7 @@ softrestart:; { if (!Cookie_Load(load_file)) { - Main::FatalError(_("No such config file: %s\n"), load_file.c_str()); + FatalError(_("No such config file: %s\n"), load_file.c_str()); } } else @@ -1556,7 +1556,7 @@ softrestart:; } if (!Cookie_Load(config_file)) { - Main::FatalError(_("No such config file: %s\n"), config_file.c_str()); + FatalError(_("No such config file: %s\n"), config_file.c_str()); } } @@ -1581,9 +1581,9 @@ softrestart:; if (batch_output_file.empty()) { - ErrorPrintf("\nNo output filename given! Did you forget the --batch " + FatalError("\nNo output filename given! Did you forget the --batch " "parameter?\n"); - LogPrintf("\nNo output filename given! Did you forget the --batch " + LogPrint("\nNo output filename given! Did you forget the --batch " "parameter?\n"); Main::Shutdown(false); @@ -1599,8 +1599,8 @@ softrestart:; Main_SetSeed(); if (!Build_Cool_Shit()) { - ErrorPrintf("FAILED!\n"); - LogPrintf("FAILED!\n"); + FatalError("FAILED!\n"); + LogPrint("FAILED!\n"); Main::Shutdown(false); #if defined WIN32 && !defined CONSOLE_ONLY @@ -1665,14 +1665,14 @@ softrestart:; // load config after creating window (will set widget values) if (!Cookie_Load(config_file)) { - LogPrintf("Missing config file -- using defaults.\n\n"); + LogPrint("Missing config file -- using defaults.\n\n"); } if (!load_file.empty()) { if (!Cookie_Load(load_file)) { - Main::FatalError(_("No such config file: %s\n"), load_file.c_str()); + FatalError(_("No such config file: %s\n"), load_file.c_str()); } } @@ -1940,12 +1940,12 @@ softrestart:; } catch (std::exception &e) { - Main::FatalError(_("An exception occurred: \n%s"), e.what()); + FatalError(_("An exception occurred: \n%s"), e.what()); } if (main_action != MAIN_SOFT_RESTART) { - LogPrintf("\nQuit......\n\n"); + LogPrint("\nQuit......\n\n"); } #ifndef CONSOLE_ONLY Theme_Options_Save(theme_file); diff --git a/source/main.h b/source/main.h index 8aebc13b7..81a8b68da 100644 --- a/source/main.h +++ b/source/main.h @@ -192,47 +192,8 @@ namespace Main { void Shutdown(bool error); - -template [[noreturn]] void FatalError(std::string_view msg, Args &&...args) -{ -#ifndef CONSOLE_ONLY - auto buffer = StringFormat(msg, std::forward(args)...); - DLG_ShowError("%s", buffer.c_str()); -#endif - Shutdown(true); - - if (batch_mode) - { - printf("ERROR!\n"); -#ifdef WIN32 - printf("\nClose window when finished..."); - do - { - } while (true); -#endif - } - - exit(9); -} - -template void ProgStatus(std::string_view msg, Args &&...args) -{ - const std::string buffer = StringFormat(msg, std::forward(args)...); - -#ifndef CONSOLE_ONLY - if (main_win) - { - main_win->build_box->SetStatus(buffer.c_str()); - } - else if (batch_mode) - { - ErrorPrintf("%s\n", buffer.c_str()); - } -#else - ErrorPrintf("%s\n", buffer.c_str()); -#endif -} bool BackupFile(const std::string &filename); + #if defined WIN32 && !defined CONSOLE_ONLY void Blinker(); #endif @@ -240,6 +201,7 @@ void Blinker(); #if !defined(CONSOLE_ONLY) && !defined(__APPLE__) bool LoadInternalFont(const char *fontpath, int fontnum, const char *fontname); #endif + #ifndef CONSOLE_ONLY void SetupFLTK(); int DetermineScaling(); diff --git a/source/poly.cc b/source/poly.cc index e9cd30e64..d50cc8a84 100644 --- a/source/poly.cc +++ b/source/poly.cc @@ -20,6 +20,7 @@ #include "lib_util.h" #include "poly_local.h" +#include "sys_debug.h" #include "sys_macro.h" #define DEBUG_POLY 0 @@ -103,7 +104,7 @@ void DumpEdges(edge_c *edge_list) { for (edge_c *cur = edge_list; cur; cur = cur->next) { - Appl_Printf(" edge #%d (%s) sector=%d (%1.1f %1.1f) -> (%1.1f %1.1f)\n", cur->index, + LogPrint(" edge #%d (%s) sector=%d (%1.1f %1.1f) -> (%1.1f %1.1f)\n", cur->index, cur->linedef ? "LINE" : "mini", cur->sector->index, cur->start->x, cur->start->y, cur->end->x, cur->end->y); } @@ -124,7 +125,7 @@ void edge_c::Recompute() if (p_length <= 0) { - Appl_FatalError("INTERNAL ERROR: edge has zero length!\n"); + FatalError("INTERNAL ERROR: edge has zero length!\n"); } p_perp = psy * pdx - psx * pdy; @@ -154,7 +155,7 @@ void edge_c::CopyInfo(const edge_c *other) edge_c *SplitEdge(edge_c *old_edge, double x, double y) { #if DEBUG_POLY - Appl_Printf("Splitting Edge #%d (line #%d) at (%1.1f,%1.1f)\n", old_edge->index, + LogPrint("Splitting Edge #%d (line #%d) at (%1.1f,%1.1f)\n", old_edge->index, old_edge->linedef ? old_edge->linedef->index : -1, x, y); #endif @@ -171,7 +172,7 @@ edge_c *SplitEdge(edge_c *old_edge, double x, double y) new_edge->Recompute(); #if DEBUG_POLY - Appl_Printf("Splitting Vertex is %04X at (%1.1f,%1.1f)\n", vert->index, vert->x, vert->y); + LogPrint("Splitting Vertex is %04X at (%1.1f,%1.1f)\n", vert->index, vert->x, vert->y); #endif // handle partners @@ -179,7 +180,7 @@ edge_c *SplitEdge(edge_c *old_edge, double x, double y) if (old_edge->partner) { #if DEBUG_POLY - Appl_Printf("Splitting partner #%d\n", old_edge->partner->index); + LogPrint("Splitting partner #%d\n", old_edge->partner->index); #endif new_edge->partner = NewEdge(); @@ -401,7 +402,7 @@ int EvalPartition(edge_c *part, edge_c *edge_list) if (real_left == 0 || real_right == 0) { #if DEBUG_POLY - Appl_Printf("Eval : No linedefs on %s%sside\n", real_left ? "" : "left ", real_right ? "" : "right "); + LogPrint("Eval : No linedefs on %s%sside\n", real_left ? "" : "left ", real_right ? "" : "right "); #endif return -1; @@ -419,7 +420,7 @@ int EvalPartition(edge_c *part, edge_c *edge_list) } #if DEBUG_POLY - Appl_Printf("Eval %p: splits=%d near_miss=%d left=%d+%d right=%d+%d " + LogPrint("Eval %p: splits=%d near_miss=%d left=%d+%d right=%d+%d " "cost=%d.%02d\n", part, splits, near_miss, real_left, mini_left, real_right, mini_right, cost / 100, cost % 100); #endif @@ -526,7 +527,7 @@ edge_c *ChoosePartition(edge_c *edge_list, int depth) int best_cost = 1 << 30; #if DEBUG_POLY - Appl_Printf("ChoosePartition: BEGUN (depth %d)\n", depth); + LogPrint("ChoosePartition: BEGUN (depth %d)\n", depth); #endif for (edge_c *part = edge_list; part; part = part->next) @@ -540,7 +541,7 @@ edge_c *ChoosePartition(edge_c *edge_list, int depth) int cost = EvalPartition(part, edge_list); #if DEBUG_POLY - Appl_Printf("ChoosePartition: EDGE #%d -> cost:%d | sector:%d (%1.1f %1.1f) " + LogPrint("ChoosePartition: EDGE #%d -> cost:%d | sector:%d (%1.1f %1.1f) " "-> (%1.1f %1.1f)\n", part->index, cost, part->sector->index, part->start->x, part->start->y, part->end->x, part->end->y); #endif @@ -558,11 +559,11 @@ edge_c *ChoosePartition(edge_c *edge_list, int depth) #if DEBUG_POLY if (!best) { - Appl_Printf("ChoosePartition: NO BEST FOUND\n"); + LogPrint("ChoosePartition: NO BEST FOUND\n"); } else { - Appl_Printf("ChoosePartition: Best has score %d.%02d (%1.1f %1.1f) -> (%1.1f " + LogPrint("ChoosePartition: Best has score %d.%02d (%1.1f %1.1f) -> (%1.1f " "%1.1f)\n", best_cost / 100, best_cost % 100, best->start->x, best->start->y, best->end->x, best->end->y); } @@ -594,12 +595,12 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, } #if DEBUG_POLY - Appl_Printf("CUT LIST:\n"); - Appl_Printf("PARTITION: (%1.1f %1.1f) += (%1.1f %1.1f)\n", part->psx, part->psy, part->pdx, part->pdy); + LogPrint("CUT LIST:\n"); + LogPrint("PARTITION: (%1.1f %1.1f) += (%1.1f %1.1f)\n", part->psx, part->psy, part->pdx, part->pdy); for (intersect_c *I = cut_list; I; I = I->next) { - Appl_Printf(" Vertex %8X (%1.1f,%1.1f) Along %1.2f [%d/%d]\n", I->vertex->index, I->vertex->x, I->vertex->y, + LogPrint(" Vertex %8X (%1.1f,%1.1f) Along %1.2f [%d/%d]\n", I->vertex->index, I->vertex->x, I->vertex->y, I->along_dist, I->before, I->after); } #endif @@ -615,7 +616,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, if (len < -0.1) { - Appl_FatalError("INTERNAL ERROR: intersect list not sorted\n"); + FatalError("INTERNAL ERROR: intersect list not sorted\n"); } if (len > 0.2) @@ -628,7 +629,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, // merge the two intersections into one #if DEBUG_POLY - Appl_Printf("Merging cut (%1.0f,%1.0f) [%d/%d] with %p (%1.0f,%1.0f) [%d/%d]\n", cur->vertex->x, cur->vertex->y, + LogPrint("Merging cut (%1.0f,%1.0f) [%d/%d] with %p (%1.0f,%1.0f) [%d/%d]\n", cur->vertex->x, cur->vertex->y, cur->before, cur->after, next->vertex, next->vertex->x, next->vertex->y, next->before, next->after); #endif @@ -643,7 +644,7 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, } #if DEBUG_POLY - Appl_Printf("---> merged (%1.0f,%1.0f) [%d/%d]\n", cur->vertex->x, cur->vertex->y, cur->before, cur->after); + LogPrint("---> merged (%1.0f,%1.0f) [%d/%d]\n", cur->vertex->x, cur->vertex->y, cur->before, cur->after); #endif // free the unused cut @@ -704,12 +705,12 @@ void EdgesAlongPartition(edge_c *part, edge_c **left_list, edge_c **right_list, InsertEdge(left_list, buddy); #if DEBUG_POLY - Appl_Printf("EdgesAlongPartition: %p RIGHT sector %d (%1.1f %1.1f) -> (%1.1f " + LogPrint("EdgesAlongPartition: %p RIGHT sector %d (%1.1f %1.1f) -> (%1.1f " "%1.1f)\n", edge, edge->sector ? edge->sector->index : -1, edge->start->x, edge->start->y, edge->end->x, edge->end->y); - Appl_Printf("EdgesAlongPartition: %p LEFT sector %d (%1.1f %1.1f) -> (%1.1f " + LogPrint("EdgesAlongPartition: %p LEFT sector %d (%1.1f %1.1f) -> (%1.1f " "%1.1f)\n", buddy, buddy->sector ? buddy->sector->index : -1, buddy->start->x, buddy->start->y, buddy->end->x, buddy->end->y); @@ -790,7 +791,7 @@ void polygon_c::ClockwiseOrder() int total = 0; #if DEBUG_POLY - Appl_Printf("Polygon: Clockwising #%d (sector #%d)\n", index, sector->index); + LogPrint("Polygon: Clockwising #%d (sector #%d)\n", index, sector->index); #endif // count edges and create an array to manipulate them @@ -816,7 +817,7 @@ void polygon_c::ClockwiseOrder() if (i != total) { - Appl_FatalError("INTERNAL ERROR: ClockwiseOrder miscounted\n"); + FatalError("INTERNAL ERROR: ClockwiseOrder miscounted\n"); } // sort them by angle (from the middle point to the start vertex). @@ -866,13 +867,13 @@ void polygon_c::ClockwiseOrder() } #if 0 // DEBUGGING - Appl_Printf("Sorted edges around (%1.1f %1.1f)\n", poly->mid_x, poly->mid_y); + LogPrint("Sorted edges around (%1.1f %1.1f)\n", poly->mid_x, poly->mid_y); for (cur = edge_list ; cur ; cur = cur->next) { double angle = ComputeAngle(cur->start->x - mid_x, cur->start->y - mid_y); - Appl_Printf(" edge #%d : angle %1.6f (%1.1f %1.1f) -> (%1.1f %1.1f)\n", + LogPrint(" edge #%d : angle %1.6f (%1.1f %1.1f) -> (%1.1f %1.1f)\n", cur->index, angle, cur->start->x, cur->start->y, cur->end->x, cur->end->y); @@ -890,7 +891,7 @@ polygon_c *CreatePolygon(edge_c *edge_list) poly->CalcMiddle(); #if DEBUG_POLY - Appl_Printf("Created Polygon #%d @ (%1.1f %1.1f)\n", poly->index, poly->mid_x, poly->mid_y); + LogPrint("Created Polygon #%d @ (%1.1f %1.1f)\n", poly->index, poly->mid_x, poly->mid_y); DumpEdges(edge_list); #endif @@ -900,7 +901,7 @@ polygon_c *CreatePolygon(edge_c *edge_list) bool RecursiveDivideEdges(edge_c *edge_list, int depth) { #if DEBUG_POLY - Appl_Printf("Build: BEGUN @ %d\n", depth); + LogPrint("Build: BEGUN @ %d\n", depth); DumpEdges(edge_list); #endif @@ -912,14 +913,14 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) if (!part) { #if DEBUG_POLY - Appl_Printf("Build: CONVEX\n"); + LogPrint("Build: CONVEX\n"); #endif CreatePolygon(edge_list); return true; // OK } #if DEBUG_POLY - Appl_Printf("Build: PARTITION %p (%1.0f,%1.0f) -> (%1.0f,%1.0f)\n", part, part->start->x, part->start->y, + LogPrint("Build: PARTITION %p (%1.0f,%1.0f) -> (%1.0f,%1.0f)\n", part, part->start->x, part->start->y, part->end->x, part->end->y); #endif @@ -935,18 +936,18 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) /* sanity checks... */ if (!rights) { - Appl_FatalError("INTERNAL ERROR: Separated edge-list has no RIGHT side\n"); + FatalError("INTERNAL ERROR: Separated edge-list has no RIGHT side\n"); } if (!lefts) { - Appl_FatalError("INTERNAL ERROR: Separated edge-list has no LEFT side\n"); + FatalError("INTERNAL ERROR: Separated edge-list has no LEFT side\n"); } EdgesAlongPartition(part, &lefts, &rights, cut_list); #if DEBUG_POLY - Appl_Printf("Build: Going LEFT\n"); + LogPrint("Build: Going LEFT\n"); #endif if (!RecursiveDivideEdges(lefts, depth + 1)) @@ -955,7 +956,7 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) } #if DEBUG_POLY - Appl_Printf("Build: Going RIGHT\n"); + LogPrint("Build: Going RIGHT\n"); #endif if (!RecursiveDivideEdges(rights, depth + 1)) @@ -964,7 +965,7 @@ bool RecursiveDivideEdges(edge_c *edge_list, int depth) } #if DEBUG_POLY - Appl_Printf("Build: DONE\n"); + LogPrint("Build: DONE\n"); #endif return true; // OK @@ -998,9 +999,9 @@ bool ProcessSectors() } #if DEBUG_POLY - Appl_Printf("-------------------------------\n"); - Appl_Printf("Processing Sector #%d\n", i); - Appl_Printf("-------------------------------\n"); + LogPrint("-------------------------------\n"); + LogPrint("Processing Sector #%d\n", i); + LogPrint("-------------------------------\n"); #endif if (!ProcessOneSector(sec)) @@ -1051,7 +1052,7 @@ void CreateEdges() edge_c *left, *right; - Appl_Printf("Creating Edges...\n"); + LogPrint("Creating Edges...\n"); for (i = 0; i < num_linedefs; i++) { @@ -1162,9 +1163,9 @@ bool Polygonate(bool require_border) { ClockwisePolygons(); - Appl_Printf("Built %d POLYGONS, %d EDGES, %d SPLIT-VERTS\n", num_polygons, num_edges, num_splits); + LogPrint("Built %d POLYGONS, %d EDGES, %d SPLIT-VERTS\n", num_polygons, num_edges, num_splits); - Appl_Printf("\n"); + LogPrint("\n"); } FreeQuickAllocCuts(); diff --git a/source/poly.h b/source/poly.h index 343befc5f..bcbb1270e 100644 --- a/source/poly.h +++ b/source/poly.h @@ -26,9 +26,6 @@ #include #include -void Appl_FatalError(const char *str, ...); -void Appl_Printf(const char *str, ...); - namespace ajpoly { diff --git a/source/poly_map.cc b/source/poly_map.cc index 4af0f9f0e..b6d2d839f 100644 --- a/source/poly_map.cc +++ b/source/poly_map.cc @@ -72,7 +72,7 @@ int num_wall_tips; static vertex_c *SafeLookupVertex(int num) { if (num >= num_vertices) - Main::FatalError("illegal vertex number #%d\n", num); + FatalError("illegal vertex number #%d\n", num); return all_vertices[num]; } @@ -83,7 +83,7 @@ static sector_c *SafeLookupSector(uint16_t num) return NULL; if (num >= num_sectors) - Main::FatalError("illegal sector number #%d\n", (int)num); + FatalError("illegal sector number #%d\n", (int)num); return all_sectors[num]; } @@ -279,7 +279,7 @@ void ParseSidedefField(sidedef_c *side, const std::string &key, ajparse::token_k int num = ajparse::LEX_Double(value); if (num < 0 || num >= num_sectors) - Main::FatalError("AJ_Poly: illegal sector number #%d\n", (int)num); + FatalError("AJ_Poly: illegal sector number #%d\n", (int)num); side->sector = all_sectors[num]; } @@ -437,21 +437,21 @@ void ParseUDMF_Block(ajparse::lexer_c &lex, int cur_type) ajparse::token_kind_e tok = lex.Next(key); if (tok == ajparse::TOK_EOF) - Main::FatalError("Malformed TEXTMAP lump: unclosed block\n"); + FatalError("Malformed TEXTMAP lump: unclosed block\n"); if (tok != ajparse::TOK_Ident) - Main::FatalError("Malformed TEXTMAP lump: missing key\n"); + FatalError("Malformed TEXTMAP lump: missing key\n"); if (!lex.Match("=")) - Main::FatalError("Malformed TEXTMAP lump: missing '='\n"); + FatalError("Malformed TEXTMAP lump: missing '='\n"); tok = lex.Next(value); if (tok == ajparse::TOK_EOF || tok == ajparse::TOK_ERROR || value == "}") - Main::FatalError("Malformed TEXTMAP lump: missing value\n"); + FatalError("Malformed TEXTMAP lump: missing value\n"); if (!lex.Match(";")) - Main::FatalError("Malformed TEXTMAP lump: missing ';'\n"); + FatalError("Malformed TEXTMAP lump: missing ';'\n"); switch (cur_type) { @@ -481,7 +481,7 @@ void ParseUDMF_Block(ajparse::lexer_c &lex, int cur_type) if (line != NULL) { if (line->start == NULL || line->end == NULL) - Main::FatalError("Linedef #%d is missing a vertex!\n", line->index); + FatalError("Linedef #%d is missing a vertex!\n", line->index); } } @@ -503,7 +503,7 @@ void ParseUDMF_Pass(const std::string &data, int pass) if (tok != ajparse::TOK_Ident) { - Main::FatalError("Malformed TEXTMAP lump.\n"); + FatalError("Malformed TEXTMAP lump.\n"); return; } @@ -512,12 +512,12 @@ void ParseUDMF_Pass(const std::string &data, int pass) { lex.Next(section); if (!lex.Match(";")) - Main::FatalError("Malformed TEXTMAP lump: missing ;\n"); + FatalError("Malformed TEXTMAP lump: missing ;\n"); continue; } if (!lex.Match("{")) - Main::FatalError("Malformed TEXTMAP lump: missing opening bracket, instead %s\n", section.c_str()); + FatalError("Malformed TEXTMAP lump: missing opening bracket, instead %s\n", section.c_str()); int cur_type = 0; @@ -555,7 +555,7 @@ void ParseUDMF_Pass(const std::string &data, int pass) void ParseUDMF(uint8_t *lump, int length) { if (!lump || length <= 0) - Main::FatalError("Error parsing TEXTMAP lump.\n"); + FatalError("Error parsing TEXTMAP lump.\n"); // load the lump into this string std::string data; @@ -578,7 +578,7 @@ vertex_c *Vertex(int index) { if (index < 0 || index >= num_vertices) { - Appl_FatalError("No such vertex: #%d\n", index); + FatalError("No such vertex: #%d\n", index); } return all_vertices[index]; @@ -588,7 +588,7 @@ linedef_c *Linedef(int index) { if (index < 0 || index >= num_linedefs) { - Appl_FatalError("No such linedef: #%d\n", index); + FatalError("No such linedef: #%d\n", index); } return all_linedefs[index]; @@ -598,7 +598,7 @@ sidedef_c *Sidedef(int index) { if (index < 0 || index >= num_sidedefs) { - Appl_FatalError("No such sidedef: #%d\n", index); + FatalError("No such sidedef: #%d\n", index); } return all_sidedefs[index]; @@ -608,7 +608,7 @@ sector_c *Sector(int index) { if (index < 0 || index >= num_sectors) { - Appl_FatalError("No such sector: #%d\n", index); + FatalError("No such sector: #%d\n", index); } return all_sectors[index]; @@ -618,7 +618,7 @@ thing_c *Thing(int index) { if (index < 0 || index >= num_things) { - Appl_FatalError("No such thing: #%d\n", index); + FatalError("No such thing: #%d\n", index); } return all_things[index]; @@ -628,7 +628,7 @@ edge_c *Edge(int index) { if (index < 0 || index >= num_edges) { - Appl_FatalError("No such edge: #%d\n", index); + FatalError("No such edge: #%d\n", index); } return all_edges[index]; @@ -638,7 +638,7 @@ polygon_c *Polygon(int index) { if (index < 0 || index >= num_polygons) { - Appl_FatalError("No such polygon: #%d\n", index); + FatalError("No such polygon: #%d\n", index); } return all_polygons[index]; @@ -770,7 +770,7 @@ bool LoadVertices() int count = length / sizeof(raw_vertex_t); #if DEBUG_LOAD - Appl_Printf("LoadVertices: num = %d\n", count); + LogPrint("LoadVertices: num = %d\n", count); #endif raw_vertex_t *raw = (raw_vertex_t *)data; @@ -801,7 +801,7 @@ bool LoadSectors() int count = length / sizeof(raw_sector_t); #if DEBUG_LOAD - Appl_Printf("LoadSectors: num = %d\n", count); + LogPrint("LoadSectors: num = %d\n", count); #endif raw_sector_t *raw = (raw_sector_t *)data; @@ -844,7 +844,7 @@ bool LoadThings() int count = length / sizeof(raw_thing_t); #if DEBUG_LOAD - Appl_Printf("LoadThings: num = %d\n", count); + LogPrint("LoadThings: num = %d\n", count); #endif raw_thing_t *raw = (raw_thing_t *)data; @@ -879,7 +879,7 @@ bool LoadThingsHexen() int count = length / sizeof(raw_hexen_thing_t); #if DEBUG_LOAD - Appl_Printf("LoadThingsHexen: num = %d\n", count); + LogPrint("LoadThingsHexen: num = %d\n", count); #endif raw_hexen_thing_t *raw = (raw_hexen_thing_t *)data; @@ -921,7 +921,7 @@ bool LoadSidedefs() int count = length / sizeof(raw_sidedef_t); #if DEBUG_LOAD - Appl_Printf("LoadSidedefs: num = %d\n", count); + LogPrint("LoadSidedefs: num = %d\n", count); #endif raw_sidedef_t *raw = (raw_sidedef_t *)data; @@ -964,7 +964,7 @@ bool LoadLinedefs() int count = length / sizeof(raw_linedef_t); #if DEBUG_LOAD - Appl_Printf("LoadLinedefs: num = %d\n", count); + LogPrint("LoadLinedefs: num = %d\n", count); #endif raw_linedef_t *raw = (raw_linedef_t *)data; @@ -985,7 +985,7 @@ bool LoadLinedefs() /* check for zero-length line */ if ((fabs(start->x - end->x) < DIST_EPSILON) && (fabs(start->y - end->y) < DIST_EPSILON)) { - Appl_FatalError("Linedef #%d has zero length.\n", i); + FatalError("Linedef #%d has zero length.\n", i); } line->flags = LE_U16(raw->flags); @@ -1014,7 +1014,7 @@ bool LoadLinedefsHexen() int count = length / sizeof(raw_hexen_linedef_t); #if DEBUG_LOAD - Appl_Printf("LoadLinedefsHexen: num = %d\n", count); + LogPrint("LoadLinedefsHexen: num = %d\n", count); #endif raw_hexen_linedef_t *raw = (raw_hexen_linedef_t *)data; @@ -1035,7 +1035,7 @@ bool LoadLinedefsHexen() /* check for zero-length line */ if ((fabs(start->x - end->x) < DIST_EPSILON) && (fabs(start->y - end->y) < DIST_EPSILON)) { - Appl_FatalError("Linedef #%d has zero length.\n", i); + FatalError("Linedef #%d has zero length.\n", i); } line->flags = LE_U16(raw->flags); @@ -1092,7 +1092,7 @@ void DetermineMapLimits() limit_y2 = OBSIDIAN_MAX(limit_y2, OBSIDIAN_MAX(y1, y2)); } - Appl_Printf("Map goes from (%d,%d) to (%d,%d)\n", limit_x1, limit_y1, limit_x2, limit_y2); + LogPrint("Map goes from (%d,%d) to (%d,%d)\n", limit_x1, limit_y1, limit_x2, limit_y2); } void CheckSectorIsDummy(sector_c *sec) @@ -1533,12 +1533,12 @@ bool ValidateWallTip(const vertex_c *vert) if (!vert->tip_set) { - Appl_FatalError("INTERNAL ERROR: vertex #%d got no wall tips\n", vert->index); + FatalError("INTERNAL ERROR: vertex #%d got no wall tips\n", vert->index); } if (!vert->tip_set->next) { - Appl_FatalError("INTERNAL ERROR: vertex #%d only has one linedef\n", vert->index); + FatalError("INTERNAL ERROR: vertex #%d only has one linedef\n", vert->index); } first_right = vert->tip_set->right; @@ -1549,7 +1549,7 @@ bool ValidateWallTip(const vertex_c *vert) { if (tip->left != tip->next->right) { - Appl_FatalError("Sector #%d not closed at vertex #%d\n", + FatalError("Sector #%d not closed at vertex #%d\n", tip->left ? tip->left->index : tip->right ? tip->right->index : -1, @@ -1560,7 +1560,7 @@ bool ValidateWallTip(const vertex_c *vert) { if (tip->left != first_right) { - Appl_FatalError("Sector #%d not closed at vertex #%d\n", + FatalError("Sector #%d not closed at vertex #%d\n", tip->left ? tip->left->index : tip->right ? tip->right->index : -1, @@ -1616,11 +1616,11 @@ bool CalculateWallTips() vertex_c *vert = Vertex(i); wall_tip_c *tip; - Appl_Printf("WallTips for vertex #%d :\n", i); + LogPrint("WallTips for vertex #%d :\n", i); for (tip = vert->tip_set; tip; tip = tip->next) { - Appl_Printf(" angle=%1.1f left=%d right=%d\n", tip->angle, tip->left ? tip->left->index : -1, + LogPrint(" angle=%1.1f left=%d right=%d\n", tip->angle, tip->left ? tip->left->index : -1, tip->right ? tip->right->index : -1); } } @@ -1685,7 +1685,7 @@ sector_c *vertex_c::CheckOpen(double dx, double dy) const /* cannot get here (in theory) */ - Appl_FatalError("INTERNAL ERROR: Bad wall tips at vertex #%d\n", index); + FatalError("INTERNAL ERROR: Bad wall tips at vertex #%d\n", index); return NULL; } @@ -1826,7 +1826,7 @@ bool OpenMap(const char *level_name) } } - Appl_Printf("Loaded %d vertices, %d sectors, %d sides, %d lines, %d things\n", num_vertices, num_sectors, + LogPrint("Loaded %d vertices, %d sectors, %d sides, %d lines, %d things\n", num_vertices, num_sectors, num_sidedefs, num_linedefs, num_things); FindDummySectors(); diff --git a/source/poly_wad.cc b/source/poly_wad.cc index b9df6d7e6..22c52449f 100644 --- a/source/poly_wad.cc +++ b/source/poly_wad.cc @@ -18,6 +18,7 @@ #include "lib_util.h" #include "poly_local.h" +#include "sys_debug.h" #define DEBUG_WAD 0 @@ -117,7 +118,7 @@ bool wad_c::ReadDirEntry() lump_c *lump = new lump_c(name_buf, start, length); #if DEBUG_WAD - Appl_Printf("Read dir... %s\n", lump->name); + LogPrint("Read dir... %s\n", lump->name); #endif lumps.push_back(lump); @@ -145,7 +146,7 @@ bool wad_c::ReadDirectory() int num_entries = LE_U32(header.num_entries); int dir_start = LE_U32(header.dir_start); - Appl_Printf("Reading %d dir entries at 0x%X\n", num_entries, dir_start); + LogPrint("Reading %d dir entries at 0x%X\n", num_entries, dir_start); PHYSFS_seek(fp, dir_start); @@ -201,7 +202,7 @@ void wad_c::DetermineLevels() } #if DEBUG_WAD - Appl_Printf("Found level name: %s\n", L->name); + LogPrint("Found level name: %s\n", L->name); #endif // collect the children lumps @@ -237,7 +238,7 @@ wad_c *wad_c::Open(const char *filename) return NULL; } - Appl_Printf("Opened WAD file : %s\n", filename); + LogPrint("Opened WAD file : %s\n", filename); wad_c *wad = new wad_c(); @@ -306,7 +307,7 @@ uint8_t *wad_c::ReadLump(const char *name, int *length, int level) lump_c *L = lumps[index]; #if DEBUG_WAD - Appl_Printf("Reading lump: %s (%d bytes)\n", L->name, L->length); + LogPrint("Reading lump: %s (%d bytes)\n", L->name, L->length); #endif if (length) diff --git a/source/sys_assert.cc b/source/sys_assert.cc index 850c11ba6..84bc802f8 100644 --- a/source/sys_assert.cc +++ b/source/sys_assert.cc @@ -36,7 +36,7 @@ void AssertFail(const char *msg, ...) buffer[MSG_BUF_LEN - 2] = 0; - Main::FatalError("Sorry, an internal error occurred.\n%s", buffer); + FatalError("Sorry, an internal error occurred.\n%s", buffer); } //--- editor settings --- diff --git a/source/sys_debug.cc b/source/sys_debug.cc index efbddce85..09e41fda3 100644 --- a/source/sys_debug.cc +++ b/source/sys_debug.cc @@ -54,9 +54,9 @@ bool LogInit(const std::string &filename) time_t result = time(nullptr); - LogPrintf("====== START OF OBSIDIAN LOGS ======\n\n"); + LogPrint("====== START OF OBSIDIAN LOGS ======\n\n"); - LogPrintf("Initialized on %s", ctime(&result)); + LogPrint("Initialized on %s", ctime(&result)); return true; } @@ -81,7 +81,7 @@ bool RefInit(const std::string &filename) } } - RefPrintf("====== OBSIDIAN REFERENCE for V%s BUILD %s ======\n\n", OBSIDIAN_SHORT_VERSION, OBSIDIAN_VERSION); + RefPrint("====== OBSIDIAN REFERENCE for V%s BUILD %s ======\n\n", OBSIDIAN_SHORT_VERSION, OBSIDIAN_VERSION); return true; } @@ -97,11 +97,11 @@ void LogEnableDebug(bool enable) if (debugging) { - LogPrintf("=== DEBUGGING ENABLED ===\n\n"); + LogPrint("=== DEBUGGING ENABLED ===\n\n"); } else { - LogPrintf("=== DEBUGGING DISABLED ===\n\n"); + LogPrint("=== DEBUGGING DISABLED ===\n\n"); } } @@ -112,7 +112,7 @@ void LogEnableTerminal(bool enable) void LogClose(void) { - LogPrintf("\n====== END OF OBSIDIAN LOGS ======\n\n"); + LogPrint("\n====== END OF OBSIDIAN LOGS ======\n\n"); fclose(log_file); log_file = nullptr; @@ -122,7 +122,7 @@ void LogClose(void) void RefClose(void) { - RefPrintf("\n====== END OF REFERENCE ======\n\n"); + RefPrint("\n====== END OF REFERENCE ======\n\n"); fclose(ref_file); ref_file = nullptr; @@ -130,7 +130,7 @@ void RefClose(void) ref_filename.clear(); } -void LogPrintf(const char *message, ...) +void LogPrint(const char *message, ...) { if (!log_file && !terminal) return; @@ -162,7 +162,7 @@ void LogPrintf(const char *message, ...) } } -void RefPrintf(const char *message, ...) +void RefPrint(const char *message, ...) { if (!ref_file && !terminal) return; @@ -194,7 +194,7 @@ void RefPrintf(const char *message, ...) } } -void DebugPrintf(const char *message, ...) +void DebugPrint(const char *message, ...) { if (!debugging || (!log_file && !terminal)) return; @@ -226,7 +226,57 @@ void DebugPrintf(const char *message, ...) } } -[[noreturn]] void ErrorPrintf(const char *message, ...) +void ProgStatus(const char *message, ...) +{ + char message_buf[4096]; + + message_buf[4095] = 0; + + // Print the message into a text string + va_list argptr; + + va_start(argptr, message); + vsprintf(message_buf, message, argptr); + va_end(argptr); + + // I hope nobody is printing strings longer than 4096 chars... + SYS_ASSERT(message_buf[4095] == 0); + +#ifndef CONSOLE_ONLY + if (main_win) + { + main_win->build_box->SetStatus(message_buf); + } + else if (batch_mode) + { + if (log_file) + { + fprintf(log_file, "%s", message_buf); + fflush(log_file); + } + + if (terminal) + { + printf("%s", message_buf); + fflush(stdout); + } + } +#else + if (log_file) + { + fprintf(log_file, "%s", message_buf); + fflush(log_file); + } + + if (terminal) + { + printf("%s", message_buf); + fflush(stdout); + } +#endif +} + +[[noreturn]] void FatalError(const char *message, ...) { char message_buf[4096]; @@ -251,6 +301,10 @@ void DebugPrintf(const char *message, ...) if (terminal) printf("ERROR: %s", message_buf); +#ifndef CONSOLE_ONLY + DLG_ShowError("%s", message_buf); +#endif + Main::Shutdown(true); #if defined WIN32 && !defined CONSOLE_ONLY if (batch_mode) diff --git a/source/sys_debug.h b/source/sys_debug.h index 906e85201..a990d7cc1 100644 --- a/source/sys_debug.h +++ b/source/sys_debug.h @@ -35,15 +35,17 @@ void LogEnableDebug(bool enable); void LogEnableTerminal(bool enable); #ifdef __GNUC__ -void LogPrintf(const char *message, ...) __attribute__((format(printf, 1, 2))); -void RefPrintf(const char *message, ...) __attribute__((format(printf, 1, 2))); -void DebugPrintf(const char *message, ...) __attribute__((format(printf, 1, 2))); -[[noreturn]] void ErrorPrintf(const char *message, ...) __attribute__((format(printf, 1, 2))); +void LogPrint(const char *message, ...) __attribute__((format(printf, 1, 2))); +void RefPrint(const char *message, ...) __attribute__((format(printf, 1, 2))); +void DebugPrint(const char *message, ...) __attribute__((format(printf, 1, 2))); +void ProgStatus(const char *message, ...) __attribute__((format(printf, 1, 2))); +[[noreturn]] void FatalError(const char *message, ...) __attribute__((format(printf, 1, 2))); #else -void LogPrintf(const char *message, ...); -void RefPrintf(const char *message, ...); -void DebugPrintf(const char *message, ...); -[[noreturn]] void ErrorPrintf(const char *message, ...); +void LogPrint(const char *message, ...); +void RefPrint(const char *message, ...); +void DebugPrint(const char *message, ...); +void ProgStatus(const char *message, ...); +[[noreturn]] void FatalError(const char *message, ...); #endif using log_display_func_t = void (*)(std::string_view line, void *priv_data); diff --git a/source/tx_forge.cc b/source/tx_forge.cc index 8cfe36bc1..a5f5e5051 100644 --- a/source/tx_forge.cc +++ b/source/tx_forge.cc @@ -336,7 +336,7 @@ void TX_SpectralSynth(unsigned long long seed, float *buf, int width, double fra { if (test & 1) { - Main::FatalError("TX_SpectralSynth: width '%d' is not a power of two\n", width); + FatalError("TX_SpectralSynth: width '%d' is not a power of two\n", width); } } @@ -362,7 +362,7 @@ void TX_TestSynth(unsigned long long seed) TX_SpectralSynth(seed, buf, 128); - LogPrintf("P6\n128 128 255\n"); + LogPrint("P6\n128 128 255\n"); for (int y = 0; y < 128; y++) { @@ -372,7 +372,7 @@ void TX_TestSynth(unsigned long long seed) int ity = (int)(1 + f * 253); - LogPrintf("ITY: %d\n", ity); + LogPrint("ITY: %d\n", ity); } } diff --git a/source/ui_hyper.cc b/source/ui_hyper.cc index 87bbb3b72..f6a724309 100644 --- a/source/ui_hyper.cc +++ b/source/ui_hyper.cc @@ -155,7 +155,7 @@ void UI_HyperLink::callback_Link(Fl_Widget *w, void *data) if (!fl_open_uri(link->url.c_str())) { - LogPrintf("\nOpen URL failed: %s\n\n", link->url.c_str()); + LogPrint("\nOpen URL failed: %s\n\n", link->url.c_str()); } } @@ -199,7 +199,7 @@ void UI_ModHyperLink::callback_Link(Fl_Widget *w, void *data) if (!fl_open_uri(link->url.c_str())) { - LogPrintf("\nOpen URL failed: %s\n\n", link->url.c_str()); + LogPrint("\nOpen URL failed: %s\n\n", link->url.c_str()); } } diff --git a/source/ui_module.cc b/source/ui_module.cc index 679b5be72..6b3e060e3 100644 --- a/source/ui_module.cc +++ b/source/ui_module.cc @@ -633,7 +633,7 @@ void UI_Module::AddOptionChoice(std::string option, std::string id, std::string if (!rch) { - LogPrintf("Warning: module '%s' lacks option '%s' (for choice '%s')\n", id_name.c_str(), option.c_str(), + LogPrint("Warning: module '%s' lacks option '%s' (for choice '%s')\n", id_name.c_str(), option.c_str(), id.c_str()); return; }