# HG changeset patch # User Matti Hamalainen # Date 1670412226 -7200 # Node ID d0aad04c3e61f4d218f671755298d09d6a1c9584 # Parent 5fda9849125f3c46f810216e7b88fc49f635ab3a th-libs now uses stdbool.h if possible, so we need to rename all BOOL/TRUE/FALSE to bool/true/false. diff -r 5fda9849125f -r d0aad04c3e61 src/colormap.c --- a/src/colormap.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/colormap.c Wed Dec 07 13:23:46 2022 +0200 @@ -15,13 +15,13 @@ { char *fmtName; char *fmtDescription; - BOOL supBackColor; + bool supBackColor; void (*putTagMarker) (FILE *, const char *, const int color, const int marker); void (*putTagLocation) (FILE *, const char *, const int color); void (*putTagLocationEnd) (FILE *, const char *); void (*putTagStart) (FILE *, const int color); void (*putTagEnd) (FILE *); - BOOL (*putTagEOL) (FILE *); + bool (*putTagEOL) (FILE *); void (*putFileStart) (FILE *); void (*putFileEnd) (FILE *); int (*putString) (const char *str, FILE *); @@ -35,13 +35,13 @@ *optMapTitle = NULL, *optUrchinFile = NULL; -BOOL optPerformAnalysis = FALSE, - optUseOldFormat = FALSE, - optCheatMode = FALSE, - optNoHeaders = FALSE, - optPosGlue = FALSE, - optCityFormat = FALSE, - optUseJS = FALSE; +bool optPerformAnalysis = false, + optUseOldFormat = false, + optCheatMode = false, + optNoHeaders = false, + optPosGlue = false, + optCityFormat = false, + optUseJS = false; int optOutputFormat = 0, optBackColor = 0; @@ -100,10 +100,10 @@ */ } -BOOL putEOLANSI(FILE *outFile) +bool putEOLANSI(FILE *outFile) { fprintf(outFile, "\n"); - return TRUE; + return true; } void putFileStartANSI(FILE *outFile) @@ -140,10 +140,10 @@ // fprintf(outFile, "$"); } -BOOL putEOLText(FILE *outFile) +bool putEOLText(FILE *outFile) { fprintf(outFile, "\n"); - return FALSE; + return false; } void putFileStartText(FILE *outFile) @@ -203,10 +203,10 @@ fprintf(outFile, ""); } -BOOL putEOLXHTML(FILE *outFile) +bool putEOLXHTML(FILE *outFile) { fprintf(outFile, "\n"); - return FALSE; + return false; } void putFileGenericHTML(FILE *outFile) @@ -358,7 +358,7 @@ void putFileStartXHTML(FILE *outFile) { - muPrintHTMLhead(outFile, optMapTitle, FALSE); + muPrintHTMLhead(outFile, optMapTitle, false); putFileGenericHTML(outFile); } @@ -378,7 +378,7 @@ */ void putFileStartHTML5(FILE *outFile) { - muPrintHTMLhead(outFile, optMapTitle, TRUE); + muPrintHTMLhead(outFile, optMapTitle, true); putFileGenericHTML(outFile); } @@ -393,7 +393,7 @@ } -BOOL getTagStr(FILE *inFile, char *tmpStr, const size_t len, const int endch) +bool getTagStr(FILE *inFile, char *tmpStr, const size_t len, const int endch) { size_t i; int mch = EOF; @@ -411,20 +411,20 @@ if (mch == EOF) { THERR("Unexpected end of file.\n"); - return FALSE; + return false; } else if (mch != endch) { THERR("No end tag 0x%02x found.\n", endch); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL processData(FILE *inFile, FILE *outFile, const CMapOutFormat *fmt) +bool processData(FILE *inFile, FILE *outFile, const CMapOutFormat *fmt) { int k, currColor, prevColor; @@ -447,7 +447,7 @@ // Get location marker tag if (!getTagStr(inFile, tmpStr, SET_MAX_STRLEN, 0xfc)) - return FALSE; + return false; // Get marker character mch = fgetc(inFile); @@ -456,7 +456,7 @@ if (k != 0xfe) { THERR("Expected location tag '%s' end, but did not find one.\n", tmpStr); - return FALSE; + return false; } currColor = muGetMapPieceColor(mch, optUseOldFormat, optCityFormat); @@ -483,21 +483,21 @@ // Get location marker tag if (!getTagStr(inFile, tmpStr, SET_MAX_STRLEN, 0xfc)) - return FALSE; + return false; // Get color mcol = fgetc(inFile); if (mcol == EOF) { THERR("Unexpected end of file (location tag colour).\n"); - return FALSE; + return false; } // Get location name if (!getTagStr(inFile, tmpStr2, SET_MAX_STRLEN, 0xfe)) { THERR("Expected location tag '%s' end, but did not find one.\n", tmpStr); - return FALSE; + return false; } if (!fmt->putTagLocation && fmt->putTagStart) @@ -539,13 +539,13 @@ checkEndTag(outFile, fmt, prevColor); - return TRUE; + return true; } /* Get a symbol */ -char getSymbol(int i, BOOL useOld) +char getSymbol(int i, bool useOld) { if (useOld) return mapPieces[i].oldSymbol; @@ -558,27 +558,27 @@ */ CMapOutFormat outputFormats[] = { - { "xhtml", "XHTML+CSS", TRUE, + { "xhtml", "XHTML+CSS", true, putTagMarkerXHTML, putTagLocationXHTML, putTagLocationEndXHTML, putTagStartXHTML, putTagEndXHTML, putEOLXHTML, putFileStartXHTML, putFileEndXHTML, fputse }, - { "html5", "HTML5+CSS", TRUE, + { "html5", "HTML5+CSS", true, putTagMarkerXHTML, putTagLocationXHTML, putTagLocationEndXHTML, putTagStartXHTML, putTagEndXHTML, putEOLXHTML, putFileStartHTML5, putFileEndXHTML, fputse }, - { "ansi", "ANSI text", FALSE, + { "ansi", "ANSI text", false, NULL, NULL, NULL, putTagStartANSI, putTagEndANSI, putEOLANSI, putFileStartANSI, putFileEndANSI, NULL }, - { "text", "Plain ASCII text", FALSE, + { "text", "Plain ASCII text", false, NULL, NULL, NULL, putTagStartText, putTagEndText, putEOLText, putFileStartText, NULL, NULL @@ -609,7 +609,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -632,7 +632,7 @@ if (tmp == NULL) { THERR("Can't set HTML tag to empty string.\n"); - return FALSE; + return false; } th_free(optXHTMLTagName); @@ -642,12 +642,12 @@ break; case 4: - optPerformAnalysis = TRUE; + optPerformAnalysis = true; THMSG(2, "Analysis enabled.\n"); break; case 6: - optUseOldFormat = TRUE; + optUseOldFormat = true; THMSG(2, "Input is using old map symbols/colors.\n"); break; @@ -667,7 +667,7 @@ if (n < 0) { THERR("Invalid output format '%s'.\n", optArg); - return FALSE; + return false; } optOutputFormat = n; @@ -681,22 +681,22 @@ break; case 10: - optCheatMode = TRUE; + optCheatMode = true; THMSG(2, "HTML cheats mode enabled!\n"); break; case 11: - optNoHeaders = TRUE; + optNoHeaders = true; THMSG(2, "Not outputting headers/footers\n"); break; case 12: - optPosGlue = TRUE; + optPosGlue = true; THMSG(2, "Generating JavaScript junk for positioning glue\n"); break; case 13: - optCityFormat = TRUE; + optCityFormat = true; THMSG(2, "Input is handled as a city map\n"); break; @@ -706,30 +706,30 @@ break; case 15: - optUseJS = TRUE; + optUseJS = true; THMSG(2, "Including Javascript bits.\n"); break; default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (!inFilename) inFilename = currArg; else { THERR("Too many input map files specified!\n"); - return FALSE; + return false; } - return TRUE; + return true; } diff -r 5fda9849125f -r d0aad04c3e61 src/combine.c --- a/src/combine.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/combine.c Wed Dec 07 13:23:46 2022 +0200 @@ -25,7 +25,7 @@ MapFile srcFiles[SET_MAX_FILES]; char *dstFile = NULL; int optFillChar = -1; -BOOL optInputIsDiff = FALSE; +bool optInputIsDiff = false; int optWorldMinW = 0, optWorldMinH = 0; @@ -56,7 +56,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -82,7 +82,7 @@ if (optArg[1] != 0) { THERR("Fill character is not a string, dumbass!\n"); - return FALSE; + return false; } optFillChar = optArg[0]; @@ -91,7 +91,7 @@ case 5: THMSG(1, "Assuming all input files are diffs.\n"); - optInputIsDiff = TRUE; + optInputIsDiff = true; break; case 6: @@ -113,7 +113,7 @@ if (v < 0 || v > 128 * 1024) { THERR("Invalid %s setting %d!\n", s, v); - return FALSE; + return false; } THMSG(1, "Using world minimum %s %d\n", s, v); @@ -122,15 +122,15 @@ default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; break; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { char *tmpArg = NULL; @@ -201,11 +201,11 @@ } th_free(tmpArg); - return TRUE; + return true; err: th_free(tmpArg); - return FALSE; + return false; } diff -r 5fda9849125f -r d0aad04c3e61 src/diffmap.c --- a/src/diffmap.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/diffmap.c Wed Dec 07 13:23:46 2022 +0200 @@ -17,8 +17,8 @@ char *srcFilename1 = NULL, *srcFilename2 = NULL, *destFilename = NULL; -BOOL optUseOldFormat = FALSE, - optAlwaysDiff = FALSE; +bool optUseOldFormat = false, + optAlwaysDiff = false; char *optFilter1 = "", *optFilter2 = SET_DEF_FILTER; @@ -49,7 +49,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -67,7 +67,7 @@ break; case 3: - optUseOldFormat = TRUE; + optUseOldFormat = true; THMSG(2, "Input is using old map symbols/colors.\n"); break; @@ -87,20 +87,20 @@ break; case 7: - optAlwaysDiff = TRUE; + optAlwaysDiff = true; THMSG(2, "Outputting diff file even with no changes.\n"); break; default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (srcFilename1 == NULL) srcFilename1 = currArg; @@ -110,15 +110,15 @@ else { THERR("Too many input map files specified!\n"); - return FALSE; + return false; } - return TRUE; + return true; } MapBlock * diffBlocks(const MapBlock *map1, const MapBlock *map2, - const BOOL useOld, const char *filter1, const char *filter2, + const bool useOld, const char *filter1, const char *filter2, size_t *count) { MapBlock *res; @@ -157,14 +157,14 @@ !muStrChr((unsigned char *) filter1, nfilter1, *p1) && !muStrChr((unsigned char *) filter2, nfilter2, *p2)) { - c = muGetMapPieceIndex(*p2, useOld, FALSE); + c = muGetMapPieceIndex(*p2, useOld, false); *pd = (c < 0) ? 0xfd : (c | 64); THMSG(2, "[%d,%d]: %d -> %d\n", x+1, y+1, *p1, *p2); (*count)++; } else { - c = muGetMapPieceIndex(*p1, useOld, FALSE); + c = muGetMapPieceIndex(*p1, useOld, false); *pd = (c < 0) ? 0xfd : c; } @@ -194,7 +194,7 @@ // Parse arguments if (!th_args_process(argc, argv, optList, optListN, - argHandleOpt, argHandleFile, TRUE)) + argHandleOpt, argHandleFile, true)) { res = 1; goto exit; @@ -208,8 +208,8 @@ } // Read mapfiles - if ((srcMap1 = mapBlockParseFile(srcFilename1, FALSE)) == NULL || - (srcMap2 = mapBlockParseFile(srcFilename2, FALSE)) == NULL) + if ((srcMap1 = mapBlockParseFile(srcFilename1, false)) == NULL || + (srcMap2 = mapBlockParseFile(srcFilename2, false)) == NULL) { res = 2; goto exit; diff -r 5fda9849125f -r d0aad04c3e61 src/liblocfile.c --- a/src/liblocfile.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/liblocfile.c Wed Dec 07 13:23:46 2022 +0200 @@ -14,13 +14,13 @@ char *filename; FILE *fp; unsigned int line; - BOOL versionSet; + bool versionSet; int ch, parseMode, prevMode, nextMode, field, subField, sep; char *fieldSep; } LocFileParseContext; -const char * locGetAreaNameType(const int flags, const BOOL type) +const char * locGetAreaNameType(const int flags, const bool type) { const char *pfx; const char *desc; @@ -52,7 +52,7 @@ } -const char * locGetAreaCreatorRole(const int flags, const BOOL type) +const char * locGetAreaCreatorRole(const int flags, const bool type) { const char *pfx; const char *desc; @@ -174,8 +174,8 @@ } -BOOL locAddNew(MapLocations *l, int xc, int yc, int dir, int flags, - LocName *names, LocName *creators, LocDateStruct *added, BOOL valid, +bool locAddNew(MapLocations *l, int xc, int yc, int dir, int flags, + LocName *names, LocName *creators, LocDateStruct *added, bool valid, const char *uri, const char *freeform, LocFileInfo *file) { LocMarker *tmp; @@ -183,7 +183,7 @@ // Allocate location struct if ((tmp = th_malloc0(sizeof(LocMarker))) == NULL) - return FALSE; + return false; tmp->xc = tmp->ox = xc; tmp->yc = tmp->oy = yc; @@ -209,7 +209,7 @@ tmp->added.day = tmpTime->tm_mday; tmp->added.month = tmpTime->tm_mon + 1; tmp->added.year = tmpTime->tm_year + 1900; - tmp->valid = TRUE; + tmp->valid = true; } tmp->uri = th_strdup(uri); tmp->freeform = th_strdup(freeform); @@ -219,16 +219,16 @@ sizeof(LocMarker*) * (l->nlocations+1)); if (l->locations == NULL) - return FALSE; + return false; l->locations[l->nlocations] = tmp; l->nlocations++; - return TRUE; + return true; } -int locFindByCoords(const MapLocations *l, const int xc, const int yc, const BOOL locTrue) +int locFindByCoords(const MapLocations *l, const int xc, const int yc, const bool locTrue) { for (int i = 0; i < l->nlocations; i++) { @@ -320,7 +320,7 @@ } -static BOOL locCheckFlag(int flags, int mask, int flag) +static bool locCheckFlag(int flags, int mask, int flag) { if (mask) return (flags & mask) == flag; @@ -329,28 +329,28 @@ } -static BOOL locCheckMutex(LocFileParseContext *f, int *flags, int mask, int flag) +static bool locCheckMutex(LocFileParseContext *f, int *flags, int mask, int flag) { if (!locCheckFlag(*flags, mask, 0) && !locCheckFlag(*flags, mask, flag)) { locPMErr(f, "Invalid flags setting.\n"); - return FALSE; + return false; } else { *flags |= flag; - return TRUE; + return true; } } -static BOOL parseFieldInt(LocFileParseContext *f, int *val) +static bool parseFieldInt(LocFileParseContext *f, int *val) { int res = 0; if (!isdigit(f->ch)) - return FALSE; + return false; while (isdigit(f->ch)) { @@ -360,14 +360,14 @@ } *val = res; - return TRUE; + return true; } static char * parseFieldString(LocFileParseContext *f, const char *endch) { char res[4096]; - BOOL end = FALSE; + bool end = false; size_t pos = 0; int i; @@ -425,12 +425,12 @@ } -static BOOL locParseFlags(LocFileParseContext *ctx, int *flags) +static bool locParseFlags(LocFileParseContext *ctx, int *flags) { - BOOL endFlags; + bool endFlags; *flags = LOCF_NONE; - endFlags = FALSE; + endFlags = false; while (!endFlags) { switch (ctx->ch) @@ -438,45 +438,45 @@ // Scenic marker flags case '?': if (!locCheckMutex(ctx, flags, LOCF_M_MASK, LOCF_M_SCENIC1)) - return FALSE; + return false; break; case '%': if (!locCheckMutex(ctx, flags, LOCF_M_MASK, LOCF_M_SCENIC2)) - return FALSE; + return false; break; case 'C': if (!locCheckMutex(ctx, flags, LOCF_M_MASK, LOCF_M_PCITY)) - return FALSE; + return false; break; case 'c': if (!locCheckMutex(ctx, flags, LOCF_M_MASK, LOCF_M_CITY)) - return FALSE; + return false; break; // Marker type flags case 'S': if (!locCheckMutex(ctx, flags, LOCF_T_MASK, LOCF_T_SHRINE)) - return FALSE; + return false; break; case 'G': if (!locCheckMutex(ctx, flags, LOCF_T_MASK, LOCF_T_GUILD)) - return FALSE; + return false; break; case 'P': if (!locCheckMutex(ctx, flags, LOCF_T_MASK, LOCF_T_SS)) - return FALSE; + return false; break; case 'M': if (!locCheckMutex(ctx, flags, LOCF_T_MASK, LOCF_T_MONSTER)) - return FALSE; + return false; break; case 'T': if (!locCheckMutex(ctx, flags, LOCF_T_MASK, LOCF_T_TRAINER)) - return FALSE; + return false; break; case 'F': if (!locCheckMutex(ctx, flags, LOCF_T_MASK, LOCF_T_FORT)) - return FALSE; + return false; break; // Additional flags @@ -493,14 +493,14 @@ break; default: - endFlags = TRUE; + endFlags = true; break; } ctx->ch = locFGetc(ctx); } - return TRUE; + return true; } @@ -538,7 +538,7 @@ static void locParseLocField(LocFileParseContext *ctx, MapLocations *l, LocMarker *marker) { - BOOL res = FALSE; + bool res = false; char *tmpStr; int i; @@ -596,12 +596,12 @@ break; case 6: // Date - marker->valid = FALSE; + marker->valid = false; tmpStr = parseFieldString(ctx, ctx->fieldSep); if (tmpStr && tmpStr[0]) { if (sscanf(tmpStr, LOC_TIMEFMT, &marker->added.day, &marker->added.month, &marker->added.year) == 3) - marker->valid = TRUE; + marker->valid = true; else { locPMErr(ctx, "Warning, invalid timestamp '%s' in '%s'.\n", @@ -634,7 +634,7 @@ marker->xc = marker->xc + marker->ox - 1; marker->yc = marker->yc + marker->oy - 1; - i = locFindByCoords(l, marker->xc, marker->yc, TRUE); + i = locFindByCoords(l, marker->xc, marker->yc, true); if (i >= 0) { LocMarker *tloc = l->locations[i]; @@ -661,7 +661,7 @@ } -BOOL locParseLocStream(FILE *fp, LocFileInfo *file, MapLocations *l, const int offX, const int offY) +bool locParseLocStream(FILE *fp, LocFileInfo *file, MapLocations *l, const int offX, const int offY) { LocFileParseContext ctx; LocMarker marker; @@ -798,7 +798,7 @@ ctx.parseMode = PM_ERROR; } th_free(tmp); - ctx.versionSet = TRUE; + ctx.versionSet = true; break; } break; diff -r 5fda9849125f -r d0aad04c3e61 src/liblocfile.h --- a/src/liblocfile.h Mon Nov 28 01:50:11 2022 +0200 +++ b/src/liblocfile.h Wed Dec 07 13:23:46 2022 +0200 @@ -123,7 +123,7 @@ int flags; // Flags (see LOCF_*) LocDateStruct added; // Date / time information - BOOL valid; + bool valid; int nnames, ncreators; LocName names[LOC_MAX_NAMES], creators[LOC_MAX_NAMES]; @@ -147,8 +147,8 @@ /* Location file parsing and data handling */ -const char * locGetAreaNameType(const int flags, const BOOL type); -const char * locGetAreaCreatorRole(const int flags, const BOOL type); +const char * locGetAreaNameType(const int flags, const bool type); +const char * locGetAreaCreatorRole(const int flags, const bool type); const char * locGetTypePrefix(const int flags); const char * locGetTypeName(const int flags); @@ -156,15 +156,15 @@ LocMarker *locCopyLocMarker(const LocMarker *); void locCopyLocations(MapLocations *dst, const MapLocations *src); -BOOL locAddNew(MapLocations *l, int xc, int yc, int dir, int flags, - LocName *names, LocName *creators, LocDateStruct *added, BOOL valid, +bool locAddNew(MapLocations *l, int xc, int yc, int dir, int flags, + LocName *names, LocName *creators, LocDateStruct *added, bool valid, const char *uri, const char *freeform, LocFileInfo *file); -BOOL locParseLocStream(FILE *fp, LocFileInfo *file, MapLocations *l, const int offX, const int offY); +bool locParseLocStream(FILE *fp, LocFileInfo *file, MapLocations *l, const int offX, const int offY); void locFreeMarkerData(LocMarker *marker); void locFreeMapLocations(MapLocations *loc); -int locFindByCoords(const MapLocations *l, const int x, const int y, const BOOL locTrue); +int locFindByCoords(const MapLocations *l, const int x, const int y, const bool locTrue); void locSetFileInfo(LocFileInfo *file, const char *filename, const char *continent); void locFreeFileInfo(LocFileInfo *file); diff -r 5fda9849125f -r d0aad04c3e61 src/libmaputils.c --- a/src/libmaputils.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/libmaputils.c Wed Dec 07 13:23:46 2022 +0200 @@ -8,26 +8,26 @@ const MapColor mapColors[] = { - { 0x00, 0x00, 0x00, 30, ANSI_OFF, FALSE }, // col_black - { 0x00, 0x00, 0xaa, 34, ANSI_OFF, FALSE }, // col_blue - { 0xaa, 0x00, 0x00, 31, ANSI_OFF, FALSE }, // col_red - { 0xaa, 0xaa, 0x00, 33, ANSI_OFF, FALSE }, // col_yellow - { 0x00, 0xaa, 0x00, 32, ANSI_OFF, FALSE }, // col_green - { 0xaa, 0xaa, 0xaa, 37, ANSI_OFF, FALSE }, // col_white - { 0x00, 0xff, 0xff, 36, ANSI_OFF, FALSE }, // col_cyan - { 0x77, 0x00, 0x77, 35, ANSI_OFF, FALSE }, // col_magenta + { 0x00, 0x00, 0x00, 30, ANSI_OFF, false }, // col_black + { 0x00, 0x00, 0xaa, 34, ANSI_OFF, false }, // col_blue + { 0xaa, 0x00, 0x00, 31, ANSI_OFF, false }, // col_red + { 0xaa, 0xaa, 0x00, 33, ANSI_OFF, false }, // col_yellow + { 0x00, 0xaa, 0x00, 32, ANSI_OFF, false }, // col_green + { 0xaa, 0xaa, 0xaa, 37, ANSI_OFF, false }, // col_white + { 0x00, 0xff, 0xff, 36, ANSI_OFF, false }, // col_cyan + { 0x77, 0x00, 0x77, 35, ANSI_OFF, false }, // col_magenta - { 0x77, 0x77, 0x77, 30, ANSI_BOLD, FALSE }, // col_light_black - { 0x00, 0x00, 0xff, 34, ANSI_BOLD, FALSE }, // col_light_blue - { 0xee, 0x00, 0x00, 31, ANSI_BOLD, FALSE }, // col_light_red - { 0xff, 0xff, 0x00, 33, ANSI_BOLD, FALSE }, // col_light_yellow - { 0x00, 0xff, 0x00, 32, ANSI_BOLD, FALSE }, // col_light_green - { 0xff, 0xff, 0xff, 37, ANSI_BOLD, FALSE }, // col_light_white - { 0x00, 0xff, 0xff, 36, ANSI_BOLD, FALSE }, // col_light_cyan - { 0xff, 0x00, 0xff, 35, ANSI_BOLD, FALSE }, // col_light_magenta + { 0x77, 0x77, 0x77, 30, ANSI_BOLD, false }, // col_light_black + { 0x00, 0x00, 0xff, 34, ANSI_BOLD, false }, // col_light_blue + { 0xee, 0x00, 0x00, 31, ANSI_BOLD, false }, // col_light_red + { 0xff, 0xff, 0x00, 33, ANSI_BOLD, false }, // col_light_yellow + { 0x00, 0xff, 0x00, 32, ANSI_BOLD, false }, // col_light_green + { 0xff, 0xff, 0xff, 37, ANSI_BOLD, false }, // col_light_white + { 0x00, 0xff, 0xff, 36, ANSI_BOLD, false }, // col_light_cyan + { 0xff, 0x00, 0xff, 35, ANSI_BOLD, false }, // col_light_magenta // extra colors, not in ANSI - { 0xff, 0x00, 0x00, 31, ANSI_BOLD, TRUE }, // col_very_light_red + { 0xff, 0x00, 0x00, 31, ANSI_BOLD, true }, // col_very_light_red }; const int nmapColors = sizeof(mapColors) / sizeof(mapColors[0]); @@ -191,13 +191,13 @@ while (*s) { - BOOL found = FALSE; + bool found = false; for (int i = 0; i < numHTMLEntities; i++) if (HTMLEntities[i].c == *s) { fprintf(outFile, "&%s;", HTMLEntities[i].ent); - found = TRUE; + found = true; break; } @@ -329,7 +329,7 @@ } -static int muGetPieceFromList(const MapPiece pieces[], const int npieces, int symbol, BOOL getOld) +static int muGetPieceFromList(const MapPiece pieces[], const int npieces, int symbol, bool getOld) { for (int i = 0; i < npieces; i++) { @@ -348,7 +348,7 @@ } -int muGetMapPieceIndex(int symbol, BOOL getOld, BOOL getCity) +int muGetMapPieceIndex(int symbol, bool getOld, bool getCity) { int n; @@ -359,7 +359,7 @@ } -static int muGetColorFromList(const MapPiece pieces[], const int npieces, int symbol, BOOL getOld) +static int muGetColorFromList(const MapPiece pieces[], const int npieces, int symbol, bool getOld) { if (getOld) { @@ -376,7 +376,7 @@ } -int muGetMapPieceColor(int symbol, BOOL getOld, BOOL getCity) +int muGetMapPieceColor(int symbol, bool getOld, bool getCity) { int n; @@ -387,7 +387,7 @@ } -void muPrintHTMLhead(FILE *outFile, const char *title, BOOL html5) +void muPrintHTMLhead(FILE *outFile, const char *title, bool html5) { static const char *strCharSet = "utf-8"; assert(outFile != NULL); @@ -464,13 +464,13 @@ } -BOOL muStrChr(const unsigned char *symbols, const size_t nsymbols, const unsigned char ch) +bool muStrChr(const unsigned char *symbols, const size_t nsymbols, const unsigned char ch) { for (size_t n = 0; n < nsymbols; n++) if (symbols[n] == ch) - return TRUE; + return true; - return FALSE; + return false; } @@ -544,7 +544,7 @@ /* Parse single arbitrary sized block from given mapfile */ -MapBlock * mapBlockParseFile(const char *filename, BOOL isDiff) +MapBlock * mapBlockParseFile(const char *filename, bool isDiff) { MapBlock *block; FILE *inFile; @@ -563,12 +563,12 @@ } -MapBlock * mapBlockParseStream(const char *filename, FILE *inFile, BOOL isDiff) +MapBlock * mapBlockParseStream(const char *filename, FILE *inFile, bool isDiff) { MapBlock *res; unsigned char *o; long pos = 0L; - BOOL flag; + bool flag; int x, y, resW, resH, c; assert(filename != NULL); @@ -600,14 +600,14 @@ resH = 1; resW = -1; x = 0; - flag = FALSE; + flag = false; while ((c = fgetc(inFile)) != EOF) { if ((!isDiff && c == '\n') || (isDiff && c == 0xff)) { if (x > resW) resW = x; - flag = TRUE; + flag = true; } else { @@ -615,7 +615,7 @@ { x = 0; resH++; - flag = FALSE; + flag = false; } x++; } @@ -641,7 +641,7 @@ o = res->data; y = 0; x = 0; - flag = FALSE; + flag = false; while ((c = fgetc(inFile)) != EOF && (y < res->height)) { if ((!isDiff && c == '\n') || (isDiff && c == 0xff)) @@ -653,7 +653,7 @@ mapBlockFree(res); return NULL; } - flag = TRUE; + flag = true; } else { @@ -662,7 +662,7 @@ x = 0; y++; o = res->data + (y * res->scansize); - flag = FALSE; + flag = false; } o[x++] = c; diff -r 5fda9849125f -r d0aad04c3e61 src/libmaputils.h --- a/src/libmaputils.h Mon Nov 28 01:50:11 2022 +0200 +++ b/src/libmaputils.h Wed Dec 07 13:23:46 2022 +0200 @@ -36,7 +36,7 @@ unsigned char *data; int width, height, scansize, size; int xc, yc; - BOOL mark; + bool mark; } MapBlock; @@ -45,7 +45,7 @@ int cr, cg, cb; int ansi; int ansiAttr; - BOOL bold; + bool bold; } MapColor; @@ -105,13 +105,13 @@ int fputsesc2(const char *str, FILE *f); int fputsesc3(const char *str, FILE *f); -int muGetMapPieceIndex(int symbol, BOOL getOld, BOOL getCity); -int muGetMapPieceColor(int symbol, BOOL getOld, BOOL getCity); -void muPrintHTMLhead(FILE *outFile, const char *title, BOOL html5); +int muGetMapPieceIndex(int symbol, bool getOld, bool getCity); +int muGetMapPieceColor(int symbol, bool getOld, bool getCity); +void muPrintHTMLhead(FILE *outFile, const char *title, bool html5); void muPrintHTMLcolors(FILE *outFile, const char *tagName, const char *propName, const char *extra); char * muColorToCSSColor(char *buf, const size_t len, const int c); int muCopyFileToStream(FILE *outFile, const char *filename); -BOOL muStrChr(const unsigned char *symbols, const size_t nsymbols, const unsigned char ch); +bool muStrChr(const unsigned char *symbols, const size_t nsymbols, const unsigned char ch); /* Mapblock handling @@ -119,8 +119,8 @@ MapBlock * mapBlockAlloc(int width, int height); MapBlock * mapBlockCopy(const MapBlock *block); void mapBlockFree(MapBlock *block); -MapBlock * mapBlockParseStream(const char *filename, FILE *fh, BOOL isDiff); -MapBlock * mapBlockParseFile(const char *filename, BOOL isDiff); +MapBlock * mapBlockParseStream(const char *filename, FILE *fh, bool isDiff); +MapBlock * mapBlockParseFile(const char *filename, bool isDiff); void mapBlockPrint(FILE *fh, const MapBlock *block); int mapBlockPutDo(MapBlock *map, const MapBlock *src, const int ox, const int oy); int mapBlockPut(MapBlock **pmap, const MapBlock *src, const int ox, const int oy); diff -r 5fda9849125f -r d0aad04c3e61 src/map2ppm.c --- a/src/map2ppm.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/map2ppm.c Wed Dec 07 13:23:46 2022 +0200 @@ -14,10 +14,10 @@ char *srcFilename = NULL, *dstFilename = NULL; -BOOL optUseOldFormat = FALSE, - optInputIsDiff = FALSE, - optUseANSI = FALSE, - optCityFormat = FALSE; +bool optUseOldFormat = false, + optInputIsDiff = false, + optUseANSI = false, + optCityFormat = false; int optScale = 1; #ifdef HAVE_LIBPNG int optPNGLevel = -1; @@ -55,7 +55,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -73,12 +73,12 @@ break; case 3: - optInputIsDiff = TRUE; + optInputIsDiff = true; THMSG(2, "Input is a 'diff', handling it as such.\n"); break; case 4: - optUseOldFormat = TRUE; + optUseOldFormat = true; THMSG(2, "Input is using old map symbols/colors.\n"); break; @@ -88,12 +88,12 @@ break; case 6: - optUseANSI = TRUE; + optUseANSI = true; THMSG(2, "Using ANSI colors.\n"); break; case 7: - optCityFormat = TRUE; + optCityFormat = true; THMSG(2, "Input is handled as a city map\n"); break; @@ -102,7 +102,7 @@ if (optScale < 1 || optScale > 50) { THERR("Invalid scale value %d, must be 1 < x < 50.\n", optScale); - return FALSE; + return false; } THMSG(2, "Output scaling set to %d.\n", optScale); break; @@ -114,7 +114,7 @@ if (optPNGLevel < 0 || optPNGLevel > 9) { THERR("Invalid PNG compression factor %d, must be 0 < x < 9.\n", optPNGLevel); - return FALSE; + return false; } THMSG(2, "Output format set to PNG, compression level %d.\n", optPNGLevel); break; @@ -122,29 +122,29 @@ default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (!srcFilename) srcFilename = currArg; else { THERR("Too many input map files specified!\n"); - return FALSE; + return false; } - return TRUE; + return true; } int writeImageData(const MapBlock *map, void *cbdata, - BOOL (*writeRowCB)(void *, const uint8_t *, const size_t), + bool (*writeRowCB)(void *, const uint8_t *, const size_t), const int scale) { int res = 0; @@ -228,7 +228,7 @@ } -BOOL writePPMRow(void *cbdata, const uint8_t *row, const size_t len) +bool writePPMRow(void *cbdata, const uint8_t *row, const size_t len) { return fwrite(row, sizeof(uint8_t), len, (FILE *) cbdata) == len; } @@ -247,17 +247,17 @@ #ifdef HAVE_LIBPNG -BOOL writePNGRow(void *cbdata, const uint8_t *row, const size_t len) +bool writePNGRow(void *cbdata, const uint8_t *row, const size_t len) { png_structp png_ptr = cbdata; (void) len; if (setjmp(png_jmpbuf(png_ptr))) - return FALSE; + return false; png_write_row(png_ptr, row); - return TRUE; + return true; } diff -r 5fda9849125f -r d0aad04c3e61 src/mapsearch.c --- a/src/mapsearch.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/mapsearch.c Wed Dec 07 13:23:46 2022 +0200 @@ -54,7 +54,7 @@ int ipvMode; // Enable/disable IPv4/6 support for this listener - BOOL useSSL; // Use SSL/TLS? + bool useSSL; // Use SSL/TLS? char *sslCertFile, // Certificate file *sslKeyFile, // Key file *sslCAFile; // CA file @@ -215,10 +215,10 @@ } -BOOL mapParseCoordPair(const char *str, int *xc, int *yc) +bool mapParseCoordPair(const char *str, int *xc, int *yc) { char *piece, *tmp, *fmt = th_strdup(str); - BOOL ret = FALSE; + bool ret = false; if ((piece = strchr(fmt, ':')) == NULL) goto err; @@ -232,7 +232,7 @@ *yc = atoi(tmp); th_free(tmp); - ret = TRUE; + ret = true; err: th_free(fmt); @@ -240,10 +240,10 @@ } -BOOL mapParseMapSpec(const char *str, MAPInfoCtx *info) +bool mapParseMapSpec(const char *str, MAPInfoCtx *info) { char *piece, *start, *fmt = th_strdup(str); - BOOL ret = FALSE; + bool ret = false; memset(info, 0, sizeof(MAPInfoCtx)); @@ -274,7 +274,7 @@ !mapParseCoordPair(piece, &info->locFile.xoffs, &info->locFile.yoffs)) goto err; - ret = TRUE; + ret = true; err: th_free(fmt); @@ -312,7 +312,7 @@ { char *start, *end, *flags, *port = NULL, *interface, *fmt = th_strdup(cfmt); - BOOL ret = FALSE; + bool ret = false; MAPListenerCtx *ctx; if ((ctx = mapNewListenCtx()) == NULL) @@ -433,7 +433,7 @@ // Get the rest ctx->sslKeyFile = th_strdup_trim(cstart, TH_TRIM_BOTH); ctx->sslCAFile = th_strdup_trim(cend, TH_TRIM_BOTH); - ctx->useSSL = TRUE; + ctx->useSSL = true; } // Check for duplicates @@ -450,7 +450,7 @@ goto out; } } - ret = TRUE; + ret = true; out: th_free(fmt); @@ -464,7 +464,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -484,12 +484,12 @@ if ((ctx = mapParseListenerSpec(optArg)) != NULL) optListenTo[optNListenTo++] = ctx; else - return FALSE; + return false; } else { mapERR("Maximum number of listener specs already specified.\n"); - return FALSE; + return false; } break; @@ -501,7 +501,7 @@ if (!mapParseCoordPair(optArg, &optWorldXC, &optWorldYC)) { mapERR("Invalid world origin coordinates '%s'.\n", optArg); - return FALSE; + return false; } break; @@ -515,7 +515,7 @@ if (tmp < 10) { mapERR("Invalid bechmark cycle count %d.\n", optBenchmark); - return FALSE; + return false; } optBenchmark = tmp; } @@ -530,7 +530,7 @@ else { mapERR("Invalid UID '%s'.\n", optArg); - return FALSE; + return false; } } break; @@ -544,7 +544,7 @@ else { mapERR("Invalid GID '%s'.\n", optArg); - return FALSE; + return false; } } break; @@ -555,37 +555,37 @@ default: mapERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (optNMaps < SET_MAX_MAPS) { if (!mapParseMapSpec(currArg, &optMaps[optNMaps])) { mapERR("Invalid map spec '%s'.\n", currArg); - return FALSE; + return false; } optNMaps++; - return TRUE; + return true; } else { mapERR("Maximum number of map specs already specified.\n"); - return FALSE; + return false; } } // Find the actual data boundaries of the block // ignoring any null characters around it. -void mapBlockFindBoundaries(const MapBlock *map, int *x0, int *y0, int *x1, int *y1, const BOOL precrop) +void mapBlockFindBoundaries(const MapBlock *map, int *x0, int *y0, int *x1, int *y1, const bool precrop) { if (!precrop) { @@ -628,15 +628,15 @@ } -BOOL mapBlockCrop(MapBlock **pdst, const MapBlock *src, const int x0, const int y0, const int x1, const int y1) +bool mapBlockCrop(MapBlock **pdst, const MapBlock *src, const int x0, const int y0, const int x1, const int y1) { // Check dimensions if (x1 - x0 < 0 || y1 - y0 < 0) - return FALSE; + return false; // Allocate new block and copy the cropped data if ((*pdst = mapBlockAlloc(x1 - x0 + 1, y1 - y0 + 1)) == NULL) - return FALSE; + return false; for (int yc = 0; yc < (*pdst)->height; yc++) { @@ -647,19 +647,19 @@ *dp++ = *sp++; } - return TRUE; + return true; } -BOOL mapBlockAutoCrop(MapBlock **pdst, const MapBlock *src, +bool mapBlockAutoCrop(MapBlock **pdst, const MapBlock *src, const unsigned char *symbols, const size_t nsymbols, - int x0, int y0, int x1, int y1, const BOOL precrop) + int x0, int y0, int x1, int y1, const bool precrop) { MapBlock *clean; // Step #1: Detect crop boundaries if ((clean = mapBlockCopy(src)) == NULL) - return FALSE; + return false; mapBlockClean(clean, symbols, nsymbols); mapBlockFindBoundaries(clean, &x0, &y0, &x1, &y1, precrop); @@ -669,13 +669,13 @@ // the current block size if (x0 == 0 && y0 == 0 && x1 == src->width - 1 && y1 == src->height - 1) - return FALSE; + return false; // Step #3: Crop it if (!mapBlockCrop(pdst, src, x0, y0, x1, y1)) - return FALSE; + return false; - return TRUE; + return true; } @@ -713,7 +713,7 @@ } -BOOL mapBlockParse(const unsigned char *data, const size_t len, MapBlock *res) +bool mapBlockParse(const unsigned char *data, const size_t len, MapBlock *res) { size_t offs = 0; @@ -743,8 +743,8 @@ // Find "center" coordinates (which may not be actual center) // for given map block based on list of center symbols. -// Returns TRUE if center marker matching one of the symbols found. -BOOL mapBlockFindCenter(const MapBlock *block, +// Returns true if center marker matching one of the symbols found. +bool mapBlockFindCenter(const MapBlock *block, const unsigned char *symbols, const size_t nsymbols, int *cx, int *cy, const int tolerance) { @@ -766,12 +766,12 @@ { *cx = xc; *cy = yc; - return TRUE; + return true; } } } - return FALSE; + return false; } @@ -812,9 +812,9 @@ // Match given "pattern" block against given "map" at -// specified offset coordinates (ox, oy). Return TRUE if -// there is a match, FALSE otherwise. -BOOL mapMatchBlock(const MapBlock *map, const MapBlock *pattern, const int ox, const int oy) +// specified offset coordinates (ox, oy). Return true if +// there is a match, false otherwise. +bool mapMatchBlock(const MapBlock *map, const MapBlock *pattern, const int ox, const int oy) { const unsigned char *sp = map->data + (oy * map->scansize) + ox, @@ -826,14 +826,14 @@ for (int xc = 0; xc < pattern->width; xc++) { if (dp[xc] != 0 && dp[xc] != sp[xc]) - return FALSE; + return false; } sp += map->scansize; dp += pattern->scansize; } - return TRUE; + return true; } @@ -842,13 +842,13 @@ { int value = 0; size_t i = 0; - BOOL neg = FALSE; + bool neg = false; while (th_isspace(str[i])) i++; if (str[i] == '-') { - neg = TRUE; + neg = true; i++; } @@ -890,7 +890,7 @@ // Creates a JSON format results string from the list of matches, // with additional information in the first array. void mapCreateResultStr(char **buf, size_t *bufLen, const MAPMatch *matches, - const int nmatches, const int nlimit, const BOOL type, const BOOL centered, + const int nmatches, const int nlimit, const bool type, const bool centered, const int centerX, const int centerY, const MapBlock *pattern) { size_t bufSize = 0; @@ -970,7 +970,7 @@ } -BOOL mapParseIntValue(const unsigned char *data, const size_t len, size_t *offs, int *val) +bool mapParseIntValue(const unsigned char *data, const size_t len, size_t *offs, int *val) { size_t start = *offs; @@ -978,10 +978,10 @@ (*offs)++; if (data[*offs] != ':' || *offs >= len) - return FALSE; + return false; *val = mapAtoI((char *) data + start, *offs); - return TRUE; + return true; } @@ -990,12 +990,12 @@ static const char *cleanChars = " *@?%CX"; size_t ncleanChars = strlen(cleanChars); MapBlock *pattern = NULL, *ptmp = NULL; - BOOL mapList[SET_MAX_MAPS]; + bool mapList[SET_MAX_MAPS]; MAPMatch matches[SET_MAX_MATCHES]; int width, height, centerX = 0, centerY = 0, nmatches = 0, nmapList, reqMatches, maxMatches = SET_MAX_MATCHES; - BOOL centered = FALSE; + bool centered = false; size_t offs = 0; // Get requested number of matches @@ -1018,7 +1018,7 @@ while (offs < len) { size_t offs2; - BOOL found = FALSE; + bool found = false; // Find next separator or end \n for (offs2 = offs; offs2 < len && data[offs2] != ':' && data[offs2] != '\n';) @@ -1036,9 +1036,9 @@ if (offs2 >= offs + slen && memcmp(data + offs, name, slen) == 0) { - mapList[nmap] = TRUE; + mapList[nmap] = true; nmapList++; - found = TRUE; + found = true; } } @@ -1108,7 +1108,7 @@ // Crop the pattern block if (mapBlockAutoCrop(&ptmp, pattern, (unsigned char *) cleanChars, ncleanChars, - 0, 0, 0, 0, FALSE)) + 0, 0, 0, 0, false)) { mapBlockFree(pattern); pattern = ptmp; @@ -1199,7 +1199,7 @@ mapCreateResultStr(&buf, &bufLen, matches, nmatches, maxMatches, - TRUE, centered, centerX, centerY, pattern); + true, centered, centerX, centerY, pattern); mapBlockFree(pattern); @@ -1339,7 +1339,7 @@ mapCreateResultStr(&buf, &bufLen, matches, nmatches, SET_MAX_MATCHES, - FALSE, FALSE, 0, 0, NULL); + false, false, 0, 0, NULL); mapMSG(2, "%s\n", buf); mapLWSWrite(wsi, (unsigned char *) buf, bufLen); @@ -1437,7 +1437,7 @@ mapCreateResultStr(&buf, &bufLen, matches, nnearest, SET_MAX_MATCHES, - FALSE, FALSE, 0, 0, NULL); + false, false, 0, 0, NULL); mapMSG(2, "%s\n", buf); mapLWSWrite(wsi, (unsigned char *) buf, bufLen); @@ -1629,7 +1629,7 @@ } -BOOL mapLoadMaps(void) +bool mapLoadMaps(void) { mapMSG(1, "Trying to load %d map specs. World origin at [%d, %d].\n", optNMaps, optWorldXC, optWorldYC); @@ -1645,23 +1645,23 @@ info->locFile.filename, info->locFile.xoffs, info->locFile.yoffs); - if ((info->map = mapBlockParseFile(info->mapFilename, FALSE)) == NULL) + if ((info->map = mapBlockParseFile(info->mapFilename, false)) == NULL) { mapERR("Could not read map data file '%s'.\n", info->mapFilename); - return FALSE; + return false; } if ((fh = fopen(info->locFile.filename, "rb")) == NULL) { mapERR("Could not open location file '%s' for reading.\n", info->locFile.filename); - return FALSE; + return false; } if (!locParseLocStream(fh, &info->locFile, &(info->loc), 0, 0)) { fclose(fh); - return FALSE; + return false; } fclose(fh); @@ -1685,7 +1685,7 @@ { mapERR("Could not allocate memory for location sorting buffer of %d entries.\n", optNMapLocations); - return FALSE; + return false; } for (int nmap = 0, index = 0; nmap < optNMaps; nmap++) @@ -1699,7 +1699,7 @@ } } - return TRUE; + return true; } @@ -1756,7 +1756,7 @@ memset(&optListenTo, 0, sizeof(optListenTo)); // Parse command line arguments - BOOL argsOK = th_args_process(argc, argv, optList, optListN, argHandleOpt, argHandleFile, 0); + bool argsOK = th_args_process(argc, argv, optList, optListN, argHandleOpt, argHandleFile, 0); if (!argsOK) return -2; diff -r 5fda9849125f -r d0aad04c3e61 src/mapstats.c --- a/src/mapstats.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/mapstats.c Wed Dec 07 13:23:46 2022 +0200 @@ -25,10 +25,10 @@ *dstFilename = NULL; int nsrcFilenames = 0; -BOOL optUseOldFormat = FALSE, - optInputIsDiff = FALSE, +bool optUseOldFormat = false, + optInputIsDiff = false, optSortBy = SORT_NONE, - optCityFormat = FALSE; + optCityFormat = false; typedef struct @@ -64,7 +64,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -82,12 +82,12 @@ break; case 3: - optInputIsDiff = TRUE; + optInputIsDiff = true; THMSG(2, "Input is a 'diff', handling it as such.\n"); break; case 4: - optUseOldFormat = TRUE; + optUseOldFormat = true; THMSG(2, "Input is using old map symbols/colors.\n"); break; @@ -115,20 +115,20 @@ break; case 7: - optCityFormat = TRUE; + optCityFormat = true; THMSG(2, "Input is handled as a city map\n"); break; default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (nsrcFilenames < SET_MAX_FILES) { @@ -137,10 +137,10 @@ else { THERR("Too many input map files specified!\n"); - return FALSE; + return false; } - return TRUE; + return true; } diff -r 5fda9849125f -r d0aad04c3e61 src/mkcitymap.c --- a/src/mkcitymap.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/mkcitymap.c Wed Dec 07 13:23:46 2022 +0200 @@ -14,7 +14,7 @@ *optLocFilename = NULL, *optHeadFilename = NULL, *optMapTitle = NULL; -BOOL optUseOldFormat = FALSE; +bool optUseOldFormat = false; /* Arguments @@ -41,7 +41,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -70,21 +70,21 @@ break; case 5: - optUseOldFormat = TRUE; + optUseOldFormat = true; THMSG(2, "Input is using old map symbols/colors.\n"); break; default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (!optMapFilename) optMapFilename = currArg; @@ -94,10 +94,10 @@ else { THERR("Too many filenames specified!\n"); - return FALSE; + return false; } - return TRUE; + return true; } @@ -105,7 +105,7 @@ { (void) locs; - muPrintHTMLhead(outFile, optMapTitle, TRUE); + muPrintHTMLhead(outFile, optMapTitle, true); if (optHeadFilename != NULL && muCopyFileToStream(outFile, optHeadFilename) < 0) @@ -279,14 +279,14 @@ void outputMapHTML(FILE *outFile, const MapBlock *map, const MapLocations *locs) { int n, p = -1; - BOOL span = FALSE; + bool span = false; for (int yc = 0; yc < map->height; yc++) { const unsigned char *dp = map->data + (map->scansize * yc); for (int xc = 0; xc < map->width; xc++) { - if ((n = locFindByCoords(locs, xc, yc, TRUE)) >= 0) + if ((n = locFindByCoords(locs, xc, yc, true)) >= 0) { LocMarker *marker = locs->locations[n]; unsigned char chr; @@ -314,7 +314,7 @@ { // If old format, use map piece color if (optUseOldFormat) - color = muGetMapPieceColor(*dp, optUseOldFormat, TRUE); + color = muGetMapPieceColor(*dp, optUseOldFormat, true); else // Otherwise use "link" color color = col_light_red; @@ -342,18 +342,18 @@ marker->xc, marker->yc, chr); } - span = FALSE; + span = false; p = -1; } else { if (p != *dp) { - int color = muGetMapPieceColor(*dp, optUseOldFormat, TRUE); + int color = muGetMapPieceColor(*dp, optUseOldFormat, true); if (span) fprintf(outFile, ""); fprintf(outFile, "", 'a' + color); - span = TRUE; + span = true; } fputc(*dp, outFile); p = *dp; @@ -362,7 +362,7 @@ } if (span) fprintf(outFile, "\n"); p = -1; - span = FALSE; + span = false; } } @@ -405,7 +405,7 @@ // Open mapfile - if ((map = mapBlockParseFile(optMapFilename, FALSE)) == NULL) + if ((map = mapBlockParseFile(optMapFilename, false)) == NULL) { THERR("Error parsing/opening mapfile '%s'.\n", optMapFilename); diff -r 5fda9849125f -r d0aad04c3e61 src/mkloc.c --- a/src/mkloc.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/mkloc.c Wed Dec 07 13:23:46 2022 +0200 @@ -41,12 +41,12 @@ LocFileInfo optLocFiles[LOC_MAX_FILES]; char *optLocMarkers = LOC_MARKERS; -BOOL optGetUpdateLoc = FALSE, - optOutput = OUTFMT_MAP, - optNoLabels = FALSE, - optNoAdjust = FALSE, - optLabelType = FALSE; -int optGMapsMode = -1; +bool optGetUpdateLoc = false, + optNoLabels = false, + optNoAdjust = false, + optLabelType = false; +int optOutput = OUTFMT_MAP, + optGMapsMode = -1; float optScale = -1, optUnitSize = 1.0f, optFontScale = 1.0f; @@ -91,7 +91,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { LocFileInfo *f; @@ -130,13 +130,13 @@ else { THERR("Too many location data files specified, maximum is %d.\n", LOC_MAX_FILES); - return FALSE; + return false; } break; case 4: THMSG(2, "Location updating/generation mode\n"); - optGetUpdateLoc = TRUE; + optGetUpdateLoc = true; break; case 7: @@ -167,7 +167,7 @@ else { THERR("No location files specified, but location option '-%s %s' given.\n", currArg, optArg); - return FALSE; + return false; } break; @@ -204,17 +204,17 @@ case 15: THMSG(2, "Not adding labels to locations\n"); - optNoLabels = TRUE; + optNoLabels = true; break; case 16: THMSG(2, "Not adjusting data under labels\n"); - optNoAdjust = TRUE; + optNoAdjust = true; break; case 18: THMSG(2, "Adding label type prefixes\n"); - optLabelType = TRUE; + optLabelType = true; break; case 19: @@ -235,7 +235,7 @@ if (optGMapsMode < 0) { THERR("Invalid GMaps mode '%s'.\n", optArg); - return FALSE; + return false; } THMSG(2, "GMaps output mode '%s' selected\n", gmapsModes[optGMapsMode]); break; @@ -243,14 +243,14 @@ default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -int locPrintType(FILE *outFile, LocMarker *loc, BOOL adjust, int (*func)(const char *, FILE *), BOOL label) +int locPrintType(FILE *outFile, LocMarker *loc, bool adjust, int (*func)(const char *, FILE *), bool label) { const char *type = locGetTypePrefix(loc->flags); int len = 0; @@ -293,7 +293,7 @@ len = strlen(tmp->names[0].name); if (optLabelType) - len += locPrintType(NULL, tmp, TRUE, NULL, FALSE); + len += locPrintType(NULL, tmp, true, NULL, false); // Compute text location switch (tmp->align) @@ -349,7 +349,7 @@ for (x = -1; x <= 1; x++) { if (!(y == 0 && x == 0) && - (n = locFindByCoords(world, cx + x, cy + y, TRUE)) >= 0) + (n = locFindByCoords(world, cx + x, cy + y, true)) >= 0) { LocMarker *loc = world->locations[n]; if ((loc->flags & mask) == mask) @@ -386,7 +386,7 @@ int tmpFlags; // Check for new locations - if (locFindByCoords(worldLoc, xc, yc, TRUE) >= 0) + if (locFindByCoords(worldLoc, xc, yc, true) >= 0) continue; @@ -427,12 +427,12 @@ memset(tmpNames, 0, sizeof(tmpNames)); tmpNames[0].name = tmpDesc; locAddNew(worldLoc, xc, yc, LOCD_NONE, tmpFlags, - tmpNames, NULL, NULL, FALSE, NULL, NULL, NULL); + tmpNames, NULL, NULL, false, NULL, NULL, NULL); } else { // Check for misplaced locations - if ((n = locFindByCoords(worldLoc, xc, yc, TRUE)) >= 0) + if ((n = locFindByCoords(worldLoc, xc, yc, true)) >= 0) { tmpl = worldLoc->locations[n]; @@ -516,7 +516,7 @@ for (int xc = 0; xc < map->width; xc++) { int n; - if ((n = locFindByCoords(lp, xc, yc, TRUE)) >= 0) + if ((n = locFindByCoords(lp, xc, yc, true)) >= 0) { LocMarker *tmp = lp->locations[n]; char chm = dp[xc]; @@ -541,7 +541,7 @@ fputc(0xfe, outFile); } else - if (!optNoLabels && (n = locFindByCoords(lp, xc, yc, FALSE)) >= 0) + if (!optNoLabels && (n = locFindByCoords(lp, xc, yc, false)) >= 0) { LocMarker *tmp = lp->locations[n]; @@ -578,7 +578,7 @@ if (optLabelType) { - xc += locPrintType(outFile, tmp, !optNoAdjust, NULL, FALSE); + xc += locPrintType(outFile, tmp, !optNoAdjust, NULL, false); } fputs(tmp->names[0].name, outFile); @@ -617,7 +617,7 @@ continue; fprintf(outFile, "\n"); } } @@ -627,7 +627,7 @@ */ void printLocNameEsc(FILE *outFile, LocName *name) { - fputs(locGetAreaCreatorRole(name->flags, FALSE), outFile); + fputs(locGetAreaCreatorRole(name->flags, false), outFile); fputsesc2(name->name, outFile); } @@ -894,13 +894,13 @@ if (tmp->uri != NULL) { fpr(outFile, "", tmp->uri); - locPrintType(outFile, tmp, FALSE, fps, TRUE); + locPrintType(outFile, tmp, false, fps, true); fpr(outFile, "
"); } else { fpr(outFile, ""); - locPrintType(outFile, tmp, FALSE, fps, TRUE); + locPrintType(outFile, tmp, false, fps, true); fpr(outFile, "
"); } @@ -1020,7 +1020,7 @@ // Primary location name fprintf(outFile, " name=\""); - locPrintType(outFile, tmp, FALSE, fputse, FALSE); + locPrintType(outFile, tmp, false, fputse, false); fprintf(outFile, "\""); // HTML @@ -1059,7 +1059,7 @@ fprintf(outFile, ""); for (int n = 1; n < tmp->nnames; n++) { - const char *tmps = locGetAreaNameType(tmp->names[n].flags, TRUE); + const char *tmps = locGetAreaNameType(tmp->names[n].flags, true); fprintf(outFile, "ncreators; n++) { fprintf(outFile, "", - locGetAreaCreatorRole(tmp->creators[n].flags, TRUE)); + locGetAreaCreatorRole(tmp->creators[n].flags, true)); fputse(tmp->creators[n].name, outFile); fprintf(outFile, ""); } @@ -1122,7 +1122,7 @@ tmp->ox, tmp->oy, tmp->align); // Location name - locPrintType(outFile, tmp, FALSE, fputsesc1, FALSE); + locPrintType(outFile, tmp, false, fputsesc1, false); fprintf(outFile, "\",\"html\":\""); outputGMapsHTML(outFile, tmp, fprintfesc1, fputsesc1); @@ -1194,7 +1194,7 @@ if (optInFilename != NULL) { THMSG(2, "Reading map '%s'\n", optInFilename); - worldMap = mapBlockParseFile(optInFilename, FALSE); + worldMap = mapBlockParseFile(optInFilename, false); if (worldMap == NULL) { THERR("World map could not be loaded!\n"); diff -r 5fda9849125f -r d0aad04c3e61 src/patchmap.c --- a/src/patchmap.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/patchmap.c Wed Dec 07 13:23:46 2022 +0200 @@ -12,7 +12,7 @@ char *mapFilename = NULL, *patchFilename = NULL, *destFilename = NULL; -BOOL optCheck = FALSE; +bool optCheck = false; /* Arguments @@ -38,7 +38,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -56,7 +56,7 @@ break; case 3: - optCheck = TRUE; + optCheck = true; THMSG(2, "Checking non-patched blocks for match.\n"); break; @@ -67,14 +67,14 @@ default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (mapFilename == NULL) mapFilename = currArg; @@ -84,10 +84,10 @@ else { THERR("Too many input map files specified!\n"); - return FALSE; + return false; } - return TRUE; + return true; } @@ -117,8 +117,8 @@ } // Read map and patch file - if ((map = mapBlockParseFile(mapFilename, FALSE)) == NULL || - (patch = mapBlockParseFile(patchFilename, TRUE)) == NULL) + if ((map = mapBlockParseFile(mapFilename, false)) == NULL || + (patch = mapBlockParseFile(patchFilename, true)) == NULL) { res = 2; goto exit; diff -r 5fda9849125f -r d0aad04c3e61 src/stitchmap.c --- a/src/stitchmap.c Mon Nov 28 01:50:11 2022 +0200 +++ b/src/stitchmap.c Wed Dec 07 13:23:46 2022 +0200 @@ -23,10 +23,10 @@ optMapFactor = 10, optRounds = 100, optReset = 50; -BOOL optHardDrop = FALSE, - optDumpRejected = FALSE, - optAdjustBlocks = FALSE, - optWalkMode = FALSE; +bool optHardDrop = false, + optDumpRejected = false, + optAdjustBlocks = false, + optWalkMode = false; float optMatch = 40.0; char *optInitialMap = NULL, *optCleanChars = " *@", @@ -67,7 +67,7 @@ } -BOOL argHandleOpt(const int optN, char *optArg, char *currArg) +bool argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { @@ -110,7 +110,7 @@ break; case 11: - optHardDrop = TRUE; + optHardDrop = true; THMSG(1, "Using hard dropping (instant bailout on mismatch).\n"); break; @@ -126,17 +126,17 @@ case 16: THMSG(1, "Dumping rejected blocks.\n"); - optDumpRejected = TRUE; + optDumpRejected = true; break; case 17: THMSG(1, "Handling variable size blocks via adjustment.\n"); - optAdjustBlocks = TRUE; + optAdjustBlocks = true; break; case 18: THMSG(1, "Walk mode enabled.\n"); - optWalkMode = TRUE; + optWalkMode = true; break; case 19: @@ -148,7 +148,7 @@ if (strlen(optArg) != 1) { THERR("Invalid argument '%s' for -C, only one character symbol can be specified.\n", optArg); - return FALSE; + return false; } else { @@ -159,15 +159,15 @@ default: THERR("Unknown option '%s'.\n", currArg); - return FALSE; + return false; break; } - return TRUE; + return true; } -BOOL argHandleFile(char *currArg) +bool argHandleFile(char *currArg) { if (nsrcFiles < MAX_FILES) { @@ -177,10 +177,10 @@ else { THERR("Too many input files specified (%d max)!\n", MAX_FILES); - return FALSE; + return false; } - return TRUE; + return true; } @@ -188,7 +188,7 @@ * with using specified x/y offsets. */ float matchBlock(MapBlock *map, MapBlock *match, - const int ox, const int oy, const BOOL hardDrop) + const int ox, const int oy, const bool hardDrop) { int n, k; @@ -236,7 +236,7 @@ } -BOOL adjustBlockCenter(MapBlock *block, const char centerCh) +bool adjustBlockCenter(MapBlock *block, const char centerCh) { for (int yc = 0; yc < block->height; yc++) for (int xc = 0; xc < block->width; xc++) @@ -246,26 +246,26 @@ { block->xc -= xc; block->yc -= yc; - return TRUE; + return true; } } - return FALSE; + return false; } /* Parse next block (marked by string optPattern) from * input stream into a mapblock, return NULL if not found or error. */ -BOOL getLineData(FILE *inFile, char *buf, const size_t bufSize) +bool getLineData(FILE *inFile, char *buf, const size_t bufSize) { if (feof(inFile) || !fgets(buf, bufSize, inFile)) { THERR("Unexpected end of file.\n"); - return FALSE; + return false; } else - return TRUE; + return true; } @@ -290,15 +290,15 @@ MapBlock *tmp = NULL; int xc, yc, tmpW, tmpH; char str[4096], *pos = NULL; - BOOL isFound; + bool isFound; size_t i; - isFound = FALSE; + isFound = false; while (!feof(inFile) && !isFound && fgets(str, sizeof(str), inFile)) { if ((pos = strstr(str, ": !!PLR: ")) != NULL && (strstr(str, "party") || strstr(str, "report"))) - isFound = TRUE; + isFound = true; } if (!isFound) @@ -414,7 +414,7 @@ int main(int argc, char *argv[]) { - BOOL isOK; + bool isOK; int i, currRounds, nmapBlocks = 0, currBlocks, worldX0, worldY0, worldX1, worldY1, offsetX = 0, offsetY = 0, @@ -444,7 +444,7 @@ if (optInitialMap) { THMSG(1, "Reading initial map '%s'\n", optInitialMap); - initialMap = mapBlockParseFile(optInitialMap, FALSE); + initialMap = mapBlockParseFile(optInitialMap, false); if (initialMap) { THMSG(2, "Initial dimensions %d x %d\n", @@ -560,7 +560,7 @@ // Clear marks for (i = 0; i < nmapBlocks; i++) - mapBlocks[i]->mark = FALSE; + mapBlocks[i]->mark = false; // Get world dimensions @@ -602,7 +602,7 @@ res = 9; goto exit; } - mapBlocks[i]->mark = TRUE; + mapBlocks[i]->mark = true; } THMSG(1, "Initialized world map of (%d x %d), offset (%d, %d)\n", @@ -611,7 +611,7 @@ // Start placing blocks currRounds = 0; - isOK = FALSE; + isOK = false; while (currRounds++ < optRounds && !isOK) { int usedBlocks; @@ -625,7 +625,7 @@ currRounds, usedBlocks, nmapBlocks); // Place and match blocks - isOK = TRUE; + isOK = true; currBlocks = 0; for (i = 0; i < nmapBlocks && currBlocks < optReset; i++) { @@ -636,7 +636,7 @@ int qx = offsetX + tmp->xc, qy = offsetY + tmp->yc; - isOK = FALSE; + isOK = false; if (matchBlock(worldMap, tmp, qx, qy, optHardDrop) >= optMatch) { @@ -647,7 +647,7 @@ res = 9; goto exit; } - tmp->mark = TRUE; + tmp->mark = true; currBlocks++; THPRINT(2, "X");