Mercurial > hg > batmud > maputils
changeset 65:cceeafe5b400
Use standard types and th-lib types instead of D*
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 15 Dec 2006 08:21:44 +0000 |
parents | 60853e54395e |
children | 9a824e7d1463 |
files | coloransi.c colormap.c diffmap.c maputils.c maputils.h mkbcmap.c mkloc.c mkmap.c mkspecial.c |
diffstat | 9 files changed, 197 insertions(+), 187 deletions(-) [+] |
line wrap: on
line diff
--- a/coloransi.c Fri Dec 15 07:49:14 2006 +0000 +++ b/coloransi.c Fri Dec 15 08:21:44 2006 +0000 @@ -6,13 +6,13 @@ #include "maputils.h" #include <string.h> -void putANSI(FILE *outFile, DCHAR *s) +void putANSI(FILE *outFile, char *s) { fputc(0x1b, outFile); fprintf(outFile, "[%s", s); } -void putANSIC(FILE *outFile, DINT c, DINT k) +void putANSIC(FILE *outFile, int c, int k) { fputc(0x1b, outFile); fprintf(outFile, "[%d;%dm%c", @@ -23,7 +23,7 @@ void processNormal(FILE *inFile, FILE *outFile) { - DINT k, c, p; + int k, c, p; c = p = -1; while ((k = fgetc(inFile)) != EOF) { @@ -55,7 +55,7 @@ } -DINT main(DINT argc, DCHAR *argv[]) +int main(int argc, char *argv[]) { FILE *inFile, *outFile;
--- a/colormap.c Fri Dec 15 07:49:14 2006 +0000 +++ b/colormap.c Fri Dec 15 08:21:44 2006 +0000 @@ -17,7 +17,7 @@ void processNormal(FILE *inFile, FILE *outFile) { - DINT k, c, p; + int k, c, p; c = p = -1; while ((k = fgetc(inFile)) != EOF) { @@ -62,7 +62,7 @@ void processDiff(FILE *inFile, FILE *outFile) { - DINT c, p; + int c, p; c = p = -1; while ((c = fgetc(inFile)) != EOF) { @@ -75,7 +75,7 @@ } if (c >= 0) { - DINT t = (c / 64), q = (c % 64); + int t = (c / 64), q = (c % 64); if (t > 0) { fprintf(outFile, "<i style='color:%s;background:%s'>", @@ -104,10 +104,10 @@ } -DINT main(DINT argc, DCHAR *argv[]) +int main(int argc, char *argv[]) { FILE *inFile, *outFile; - DBOOL optDiff; + BOOL optDiff; inFile = stdin; outFile = stdout;
--- a/diffmap.c Fri Dec 15 07:49:14 2006 +0000 +++ b/diffmap.c Fri Dec 15 08:21:44 2006 +0000 @@ -10,8 +10,8 @@ void printBlockRaw(FILE *f, mapblock_t *map) { - DCHAR *c; - DINT x, y; + char *c; + int x, y; c = map->d; @@ -27,9 +27,9 @@ mapblock_t * diffBlocks(mapblock_t *map1, mapblock_t *map2) { - DINT x, y; + int x, y; mapblock_t *res; - DCHAR *p1, *p2, *pd; + char *p1, *p2, *pd; if (map1->w != map2->w || map1->h != map2->h) { THERR("Mapblock size mismatch (%d, %d) vs (%d, %d)\n", @@ -61,7 +61,7 @@ } -DINT main(DINT argc, DCHAR *argv[]) +int main(int argc, char *argv[]) { mapblock_t *map1, *map2, *res;
--- a/maputils.c Fri Dec 15 07:49:14 2006 +0000 +++ b/maputils.c Fri Dec 15 08:21:44 2006 +0000 @@ -28,7 +28,7 @@ { "#ff00ff", 35, ANSI_BOLD }, }; -const DINT nmapColors = (sizeof(mapColors) / sizeof(color_t)); +const int nmapColors = (sizeof(mapColors) / sizeof(color_t)); mappiece_t mapPieces[] = { @@ -72,30 +72,30 @@ { ',', "Muddy Trail", col_light_yellow }, }; -const DINT nmapPieces = (sizeof(mapPieces) / sizeof(mappiece_t)); +const int nmapPieces = (sizeof(mapPieces) / sizeof(mappiece_t)); -DINT mcGet(DINT c) +int mcGet(int c) { - DINT i; + int i; for (i = 0; i < nmapPieces; i++) if (mapPieces[i].c == c) return i; return -1; } -DINT mcGetColor(DINT c) +int mcGetColor(int c) { - DINT i; + int i; for (i = 0; i < nmapPieces; i++) if (mapPieces[i].c == c) return mapPieces[i].col; return 0; } -void mcXHTMLcolors(FILE *o, DCHAR *element) +void mcXHTMLcolors(FILE *o, char *element) { - DINT n; + int n; for (n = 0; n < nmapColors; n++) { fprintf(o, @@ -106,7 +106,7 @@ } -void mcXHTMLhead(FILE *outFile, DCHAR *title) +void mcXHTMLhead(FILE *outFile, char *title) { fprintf(outFile, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" @@ -121,7 +121,7 @@ /* Map block handling */ -mapblock_t * allocBlock(DINT blockW, DINT blockH) +mapblock_t * allocBlock(int blockW, int blockH) { mapblock_t *blockRes; @@ -158,12 +158,12 @@ /* Parse single arbitrary sized block from given mapfile */ -mapblock_t * parseFile(DCHAR *mapFilename) +mapblock_t * parseFile(char *mapFilename) { FILE *inFile; mapblock_t *res; - DCHAR *o; - DINT x, y, resW, resH, maxW, c; + char *o; + int x, y, resW, resH, maxW, c; /* Open file */ if ((inFile = fopen(mapFilename, "rb")) == NULL) { @@ -204,7 +204,7 @@ o = res->d; y = x = 0; while ((c = fgetc(inFile)) != EOF && (y < res->h)) { - if (c == '\n' || c == '\r') { + if (c == '\n') { if (x != res->w) { THERR("Broken block, line width %d < %d!\n", x, res->w); @@ -240,8 +240,8 @@ */ void printBlock(FILE *f, mapblock_t *map) { - DCHAR *c; - DINT x, y; + char *c; + int x, y; c = map->d; @@ -262,18 +262,18 @@ /* Blit a block into another, assume that memory has been allocated * in sufficient way and other preparations are done. */ -DINT putBlockDo(mapblock_t *map, mapblock_t *b, DINT ox, DINT oy) +int putBlockDo(mapblock_t *map, mapblock_t *b, int ox, int oy) { - DINT x, y; + int x, y; for (y = 0; y < b->h; y++) for (x = 0; x < b->w; x++) { - DINT dx = (ox + x); - DINT dy = (oy + y); + int dx = (ox + x); + int dy = (oy + y); if ((dx >= 0) && (dx < map->w) && (dy >= 0) && (dy < map->h)) { - DCHAR c = b->d[(y * b->w) + x]; + char c = b->d[(y * b->w) + x]; if (c != 0) map->d[(dy * map->w) + dx] = c; } else @@ -286,10 +286,10 @@ } -DINT putBlock(mapblock_t **map, mapblock_t *b, DINT ox, DINT oy, DINT q) +int putBlock(mapblock_t **map, mapblock_t *b, int ox, int oy, int q) { mapblock_t *tmp; - DINT x0, y0, x1, y1, mx, my; + int x0, y0, x1, y1, mx, my; /* Determine new block size */ x0 = mx = y0 = my = 0; @@ -327,9 +327,9 @@ /* Clean given block from position markers and whitespaces */ -void cleanBlock(mapblock_t *map, DCHAR *symbols) +void cleanBlock(mapblock_t *map, char *symbols) { - DINT x, y; + int x, y; size_t o; o = 0;
--- a/maputils.h Fri Dec 15 07:49:14 2006 +0000 +++ b/maputils.h Fri Dec 15 08:21:44 2006 +0000 @@ -7,23 +7,23 @@ /* Typedefs */ typedef struct { - DCHAR c; - DCHAR *desc; - DINT col; + char c; + char *desc; + int col; } mappiece_t; typedef struct { - DCHAR *d; - DINT w, h, x, y; - DBOOL mark; + char *d; + int w, h, x, y; + BOOL mark; } mapblock_t; typedef struct { - DCHAR *css; - DINT ansi; - DINT ansi_attr; + char *css; + int ansi; + int ansi_attr; } color_t; @@ -60,25 +60,25 @@ /* Tables */ extern color_t mapColors[]; -extern const DINT nmapColors; +extern const int nmapColors; extern mappiece_t mapPieces[]; -extern const DINT nmapPieces; +extern const int nmapPieces; /* Functions */ -DINT mcGet(DINT); -DINT mcGetColor(DINT); -void mcXHTMLcolors(FILE *, DCHAR *); -void mcXHTMLhead(FILE *, DCHAR *); +int mcGet(int); +int mcGetColor(int); +void mcXHTMLcolors(FILE *, char *); +void mcXHTMLhead(FILE *, char *); -mapblock_t * allocBlock(DINT, DINT); +mapblock_t * allocBlock(int, int); void freeBlock(mapblock_t *); -mapblock_t * parseFile(DCHAR *); +mapblock_t * parseFile(char *); void printBlock(FILE *, mapblock_t *); -DINT putBlockDo(mapblock_t *, mapblock_t *, DINT, DINT); -DINT putBlock(mapblock_t **, mapblock_t *, DINT, DINT, DINT); -void cleanBlock(mapblock_t *, DCHAR *); +int putBlockDo(mapblock_t *, mapblock_t *, int, int); +int putBlock(mapblock_t **, mapblock_t *, int, int, int); +void cleanBlock(mapblock_t *, char *); #endif
--- a/mkbcmap.c Fri Dec 15 07:49:14 2006 +0000 +++ b/mkbcmap.c Fri Dec 15 08:21:44 2006 +0000 @@ -9,18 +9,18 @@ typedef struct { - DCHAR c; - DCHAR *desc; - DCHAR *extra; + char c; + char *desc; + char *extra; } location_t; #define MAX_LOC (256) -DINT nlocations = 0; +int nlocations = 0; location_t locations[MAX_LOC]; -void addLoc(DCHAR c, DCHAR *desc, DCHAR *extra) +void addLoc(char c, char *desc, char *extra) { if (nlocations < MAX_LOC) { locations[nlocations].c = c; @@ -35,9 +35,9 @@ } -DINT getLoc(DCHAR c) +int getLoc(char c) { - DINT i; + int i; for (i = 0; i < nlocations; i++) { if (locations[i].c == c) @@ -48,9 +48,9 @@ } -DINT getColor(DINT c) +int getColor(int c) { - DINT i; + int i; if (c >= '0' && c <= '9') i = (c - '0' + 1); @@ -66,10 +66,10 @@ return i; } -void putEnd(FILE *f, DINT c, DINT p) +void putEnd(FILE *f, int c, int p) { - DINT i, l; - DBOOL isURL; + int i, l; + BOOL isURL; if (p != -1) { fprintf(f, "</span>"); @@ -134,7 +134,7 @@ void processMapHTML(FILE *outFile, FILE *inFile) { - DINT c, p; + int c, p; c = p = -1; while ((c = fgetc(inFile)) != EOF) { @@ -158,9 +158,9 @@ } -void printBlockHTML(FILE *outFile, DINT nStart, DINT nEnd) +void printBlockHTML(FILE *outFile, int nStart, int nEnd) { - DINT n; + int n; fprintf(outFile, "<td style=\"font-size: small;\" valign=\"top\">\n"); @@ -210,7 +210,7 @@ } -void outputHTML(FILE *outFile, FILE *inFile, DCHAR *mapTitle) +void outputHTML(FILE *outFile, FILE *inFile, char *mapTitle) { /* Output XHTML header */ mcXHTMLhead(outFile, mapTitle); @@ -273,10 +273,10 @@ } -void outputASCII(FILE *outFile, FILE *inFile, DCHAR *mapTitle) +void outputASCII(FILE *outFile, FILE *inFile, char *mapTitle) { - DINT c, n, m; - DCHAR fmt[32]; + int c, n, m; + char fmt[32]; /* Output title */ fprintf(outFile, "%s\n\n", mapTitle); @@ -315,10 +315,10 @@ } -DINT parseLocFile(char *pcFilename) +int parseLocFile(char *pcFilename) { FILE *inFile; - DCHAR s[4096]; + char s[4096]; size_t i, j, k; if ((inFile = fopen(pcFilename, "rb")) == NULL) { @@ -357,10 +357,10 @@ } -DINT main(DINT argc, DCHAR *argv[]) +int main(int argc, char *argv[]) { FILE *inFile, *outFile; - DCHAR *mapTitle, *mapFilename, *descFilename; + char *mapTitle, *mapFilename, *descFilename; if (argc < 4) { fprintf(stderr,
--- a/mkloc.c Fri Dec 15 07:49:14 2006 +0000 +++ b/mkloc.c Fri Dec 15 08:21:44 2006 +0000 @@ -26,33 +26,33 @@ typedef struct { - DINT x, y, ox, oy; - DINT dir, flags; - DCHAR * desc; + int x, y, ox, oy; + int dir, flags; + char * desc; } locinfo_t; typedef struct { - DINT numLocations; + int numLocations; locinfo_t **locations; } locations_t; typedef struct { - DCHAR *fileName, *inLine; + char *fileName, *inLine; size_t lineNum, linePos; } fileinfo_t; /* Variables */ -DCHAR *progName = NULL; -DCHAR *srcFile = NULL, +char *progName = NULL; +char *srcFile = NULL, *destFile = NULL, *locFile = NULL; -DINT optOffsetX = 0, optOffsetY = 0; -DBOOL optGetLoc = FALSE; +int optOffsetX = 0, optOffsetY = 0; +BOOL optGetLoc = FALSE; /* Arguments @@ -69,7 +69,7 @@ { 8, 'y', "offset-y", "Location Y offset", 1 }, }; -const DINT optListN = (sizeof(optList) / sizeof(optarg_t)); +const int optListN = (sizeof(optList) / sizeof(optarg_t)); void argShowHelp() @@ -79,7 +79,7 @@ } -BOOL argHandleOpt(const DINT optN, DCHAR *optArg, DCHAR *currArg) +BOOL argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { case 0: @@ -133,8 +133,8 @@ } -DBOOL addLocation(locations_t *l, - DINT x, DINT y, DINT dir, DCHAR *desc, DINT flags) +BOOL addLocation(locations_t *l, + int x, int y, int dir, char *desc, int flags) { locinfo_t *tmp; @@ -159,9 +159,9 @@ } -DINT searchLocation(locations_t *l, DINT x, DINT y, DBOOL locTrue) +int searchLocation(locations_t *l, int x, int y, BOOL locTrue) { - DINT i; + int i; locinfo_t *tmp; for (i = 0; i < l->numLocations; i++) { @@ -176,7 +176,7 @@ return -1; } -void parseElement(fileinfo_t *f, DCHAR *ts, size_t tmax) +void parseElement(fileinfo_t *f, char *ts, size_t tmax) { size_t i = 0; @@ -185,9 +185,9 @@ ts[i] = 0; } -DBOOL parseValue(fileinfo_t *f, DINT *val) +BOOL parseValue(fileinfo_t *f, int *val) { - DCHAR tmpStr[NMAX+1]; + char tmpStr[NMAX+1]; if (!th_isdigit(f->inLine[f->linePos])) { THERR("Expected decimal value on column %d line #%d in '%s'\n", @@ -202,11 +202,11 @@ } -DBOOL parseLocationFile(DCHAR *fileName, locations_t *l, DINT offX, DINT offY) +BOOL parseLocationFile(char *fileName, locations_t *l, int offX, int offY) { FILE *inFile; size_t i; - DCHAR inLine[NMAX+1]; + char inLine[NMAX+1]; fileinfo_t f; f.fileName = fileName; @@ -230,7 +230,7 @@ th_findnext(inLine, &f.linePos); if (th_isdigit(inLine[f.linePos])) { - DINT tx, ty, td, tf, tn; + int tx, ty, td, tf, tn; /* Get X coordinate */ if (!parseValue(&f, &tx)) @@ -310,8 +310,8 @@ void outputMapCTRL(FILE *outFile, mapblock_t *map, locations_t *l) { - DCHAR *d; - DINT x, y, n; + char *d; + int x, y, n; d = map->d; @@ -351,7 +351,7 @@ void outputLocationFile(FILE *outFile, locations_t *l) { - DINT i; + int i; fprintf(outFile, "# Format of this file is one location per line:\n" @@ -381,10 +381,10 @@ void adjustLocInfoCoords(mapblock_t *map, locations_t *l) { - DINT i; + int i; for (i = 0; i < l->numLocations; i++) { - DINT y, x0, x1; + int y, x0, x1; locinfo_t *tmp = l->locations[i]; /* Compute text location */ @@ -462,8 +462,8 @@ /* What mode are we in? */ if (optGetLoc) { - DINT x, y, cloc = 0; - DCHAR *d = worldMap->d; + int x, y, cloc = 0; + char *d = worldMap->d; THMSG(2, "Updating location information ..\n"); @@ -472,7 +472,7 @@ for (x = 0; x < worldMap->w; x++) { if (*d == '?' || *d == '%') { if (searchLocation(&worldLocations, x, y, TRUE) < 0) { - DCHAR tmps[512]; + char tmps[512]; snprintf(tmps, sizeof(tmps), "UNK #%d", cloc); addLocation(&worldLocations,
--- a/mkmap.c Fri Dec 15 07:49:14 2006 +0000 +++ b/mkmap.c Fri Dec 15 08:21:44 2006 +0000 @@ -16,20 +16,20 @@ /* Variables */ -DCHAR *progName = NULL; -DINT nsrcFiles = 0; -DCHAR *srcFiles[MAX_FILES], +char *progName = NULL; +int nsrcFiles = 0; +char *srcFiles[MAX_FILES], *destFile = NULL; -DINT optBlockW = 21, +int optBlockW = 21, optBlockH = 21, optMapFactor = 2, optRounds = 100; -DBOOL optInverse = FALSE, +BOOL optInverse = FALSE, optHardDrop = FALSE; -DFLOAT optMatch = 90.0f, optFudge = 50.0f; -DCHAR *optPattern = "You quack 'pfs.'"; -DCHAR *optInitialMap = NULL; +float optMatch = 90.0f, optFudge = 50.0f; +char *optPattern = "You quack 'pfs.'"; +char *optInitialMap = NULL; /* Arguments @@ -50,7 +50,7 @@ { 10,'I', "initial", "Initial map file", OPT_ARGREQ }, }; -const DINT optListN = (sizeof(optList) / sizeof(optarg_t)); +const int optListN = (sizeof(optList) / sizeof(optarg_t)); void argShowHelp() @@ -60,7 +60,7 @@ } -BOOL argHandleOpt(const DINT optN, DCHAR *optArg, DCHAR *currArg) +BOOL argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { case 0: @@ -159,7 +159,7 @@ } -BOOL argHandleFile(DCHAR *currArg) +BOOL argHandleFile(char *currArg) { if (nsrcFiles < MAX_FILES) { srcFiles[nsrcFiles] = currArg; @@ -176,9 +176,9 @@ /* Calculate matching percentage of given block against a map, * with using specified x/y offsets. */ -DFLOAT matchBlock(mapblock_t *map, mapblock_t *match, DINT ox, DINT oy, DBOOL matchEmpty, DBOOL hardDrop) +float matchBlock(mapblock_t *map, mapblock_t *match, int ox, int oy, BOOL matchEmpty, BOOL hardDrop) { - DINT x, y, c1, c2, dy, dx, n, k; + int x, y, c1, c2, dy, dx, n, k; n = k = 0; @@ -213,7 +213,7 @@ } if (k > 0) - return ((DFLOAT) n * 100.0f) / (DFLOAT) k; + return ((float) n * 100.0f) / (float) k; else return 0.0f; } @@ -222,12 +222,12 @@ /* Parse next block (marked by string optPattern) from * input stream into a mapblock, return NULL if not found or error. */ -mapblock_t * parseBlock(FILE *inFile, DINT inW, DINT inH, DCHAR *inPattern) +mapblock_t * parseBlock(FILE *inFile, int inW, int inH, char *inPattern) { mapblock_t *tmp; - DINT x, y, o; - DBOOL isFound; - DCHAR s[4096]; + int y, o; + BOOL isFound; + char s[4096]; isFound = FALSE; while (!feof(inFile) && !isFound && fgets(s, sizeof(s), inFile)) { @@ -245,29 +245,32 @@ return NULL; } - o = y = x = 0; - while (!feof(inFile) && (y < tmp->h) && fgets(s, sizeof(s), inFile)) { - size_t i; + o = y = 0; + while (!feof(inFile) && (y < tmp->h)) { + int x, c = 0; - for (i = 0; i < sizeof(s) && s[i] && s[i] != '\r' && s[i] != '\n'; i++); - s[i] = 0; + for (x = 0; x < tmp->w; x++) { + c = fgetc(inFile); + if (c == '\n' || c == EOF) + break; + else + tmp->d[o++] = c; + } - if (i != (DUINT) tmp->w) { - THERR("Broken block, line width %d < %d!\n", - strlen(s), tmp->w, s); + if (c != '\n' && c != EOF) + c = fgetc(inFile); + + if (x != tmp->w) { + THERR("Broken block, line width %d != %d\n", x, tmp->w); freeBlock(tmp); return NULL; } - for (x = 0; x < tmp->w; x++) { - tmp->d[o++] = s[x]; - } - y++; } - if (y < tmp->h) { - THERR("Broken block, height %d < %d\n", + if (y != tmp->h) { + THERR("Broken block, height %d != %d\n", y, tmp->h); freeBlock(tmp); return NULL; @@ -279,10 +282,10 @@ /* Bruteforce search / block matching .. */ -DBOOL blockSearchBrute(mapblock_t *map, mapblock_t *b, DINT *x, DINT *y, DFLOAT m) +BOOL blockSearchBrute(mapblock_t *map, mapblock_t *b, int *x, int *y, float m) { - DINT ox, oy; - DFLOAT v; + int ox, oy; + float v; for (oy = -(b->h); oy < (map->h + b->h); oy++) for (ox = -(b->w); ox < (map->w + b->w); ox++) { @@ -297,13 +300,13 @@ return FALSE; } -DBOOL blockSearch(mapblock_t *map, mapblock_t *b, DINT *x, DINT *y, DFLOAT m, DFLOAT q) +BOOL blockSearch(mapblock_t *map, mapblock_t *b, int *x, int *y, float m, float q) { - DINT ox, oy, dx, dy; - DFLOAT v; + int ox, oy, dx, dy; + float v; - dx = ((DFLOAT) b->w) * q; - dy = ((DFLOAT) b->h) * q; + dx = ((float) b->w) * q; + dy = ((float) b->h) * q; for (oy = (*y - dy); oy < (*y + dy); oy++) for (ox = (*x - dx); ox < (*x + dx); ox++) { @@ -324,8 +327,8 @@ int main(int argc, char *argv[]) { FILE *tmpFile; - DBOOL isOK, isFirst; - DINT i, n, ox, oy, nmapBlocks = 0; + BOOL isOK, isFirst; + int i, n, ox, oy, nmapBlocks = 0; mapblock_t *map = NULL, *tmp = NULL, *initial = NULL; mapblock_t **mapBlocks = NULL; @@ -383,6 +386,7 @@ THMSG(1, "Total of %d mapblocks read.\n", nmapBlocks); + /* Start matching the blocks with bruteforce */ if (initial) { @@ -401,8 +405,14 @@ putBlockDo(map, tmp, (map->w / 2) - (tmp->w / 2), (map->h / 2) - (tmp->h / 2)); + } else { + if ((map = allocBlock(optBlockW * optMapFactor, optBlockH * optMapFactor)) == NULL) { + THERR("Could not allocate initial map.\n"); + exit(3); + } } + THMSG(1, "Initialized initial map of (%d x %d)\n", map->w, map->h); n = 0;
--- a/mkspecial.c Fri Dec 15 07:49:14 2006 +0000 +++ b/mkspecial.c Fri Dec 15 08:21:44 2006 +0000 @@ -16,19 +16,19 @@ /* Variables */ -DCHAR *progName = NULL; -DINT nsrcFiles = 0; -DCHAR *srcFiles[MAX_FILES], +char *progName = NULL; +int nsrcFiles = 0; +char *srcFiles[MAX_FILES], *destFile = NULL; -DINT optBlockW = 21, +int optBlockW = 21, optBlockH = 21, optMapFactor = 10, optRounds = 100, optReset = 50; -DBOOL optHardDrop = FALSE; -DFLOAT optMatch = 30.0, optMatchInit = 70.0; -DCHAR *optInitialMap = NULL; +BOOL optHardDrop = FALSE; +float optMatch = 30.0, optMatchInit = 70.0; +char *optInitialMap = NULL; /* Arguments @@ -48,7 +48,7 @@ { 10,'I', "initial", "Initial map file", 1 }, }; -const DINT optListN = (sizeof(optList) / sizeof(optarg_t)); +const int optListN = (sizeof(optList) / sizeof(optarg_t)); void argShowHelp() @@ -58,7 +58,7 @@ } -BOOL argHandleOpt(const DINT optN, DCHAR *optArg, DCHAR *currArg) +BOOL argHandleOpt(const int optN, char *optArg, char *currArg) { switch (optN) { case 0: @@ -129,7 +129,7 @@ } -BOOL argHandleFile(DCHAR *currArg) +BOOL argHandleFile(char *currArg) { if (nsrcFiles < MAX_FILES) { srcFiles[nsrcFiles] = currArg; @@ -146,9 +146,9 @@ /* Calculate matching percentage of given block against a map, * with using specified x/y offsets. */ -DFLOAT matchBlock(mapblock_t *map, mapblock_t *match, DINT ox, DINT oy, DBOOL matchEmpty, DBOOL hardDrop) +float matchBlock(mapblock_t *map, mapblock_t *match, int ox, int oy, BOOL matchEmpty, BOOL hardDrop) { - DINT x, y, c1, c2, dy, dx, n, k; + int x, y, c1, c2, dy, dx, n, k; n = k = 0; @@ -179,7 +179,7 @@ } if (k > 0) - return ((DFLOAT) n * 100.0f) / (DFLOAT) k; + return ((float) n * 100.0f) / (float) k; else return 0.0f; } @@ -188,13 +188,13 @@ /* Parse next block (marked by string optPattern) from * input stream into a mapblock, return NULL if not found or error. */ -mapblock_t * parseBlock(FILE *inFile, DINT inW, DINT inH) +mapblock_t * parseBlock(FILE *inFile, int inW, int inH) { mapblock_t *tmp; - DINT x, y, o; - DUINT i; - DBOOL isFound; - DCHAR s[4096]; + int x, y, o; + uint_t i; + BOOL isFound; + char s[4096]; isFound = FALSE; while (!feof(inFile) && !isFound && fgets(s, sizeof(s), inFile)) { @@ -229,7 +229,7 @@ for (i = 0; i < sizeof(s) && s[i] && s[i] != '\r' && s[i] != '\n'; i++); s[i] = 0; - if (i != (DUINT) tmp->w) { + if (i != (uint_t) tmp->w) { THERR("Broken block, line width %d < %d!\n", i, tmp->w, s); freeBlock(tmp); @@ -258,14 +258,14 @@ * block on another block (map) by sliding the block * [-bw...mapw+bw, -bh...maph+bw] */ -DBOOL blockSearchBrute(mapblock_t *map, mapblock_t *block, - DINT *x, DINT *y, DFLOAT *matchValue) +BOOL blockSearchBrute(mapblock_t *map, mapblock_t *block, + int *x, int *y, float *matchValue) { - DINT ox, oy; + int ox, oy; for (oy = -(block->h); oy < (map->h + block->h); oy++) for (ox = -(block->w); ox < (map->w + block->w); ox++) { - DFLOAT v; + float v; v = matchBlock(map, block, ox, oy, FALSE, optHardDrop); if (v >= *matchValue) { *matchValue = v; @@ -282,8 +282,8 @@ /* */ void findWorldSize(mapblock_t *tmp, - DINT *worldX0, DINT *worldY0, - DINT *worldX1, DINT *worldY1) + int *worldX0, int *worldY0, + int *worldX1, int *worldY1) { if (tmp->x < *worldX0) *worldX0 = tmp->x; if ((tmp->x + tmp->w) > *worldX1) *worldX1 = (tmp->x + tmp->w); @@ -295,8 +295,8 @@ int main(int argc, char *argv[]) { - DBOOL isOK; - DINT i, currRounds, nmapBlocks, currBlocks, + BOOL isOK; + int i, currRounds, nmapBlocks, currBlocks, worldX0, worldY0, worldX1, worldY1, offsetX, offsetY; mapblock_t *worldMap = NULL, *initialMap = NULL; @@ -396,8 +396,8 @@ /* If initial map is available, find a match and determine coords */ if (initialMap) { - DINT blockSkip = 256; - DFLOAT mv; + int blockSkip = 256; + float mv; mapblock_t *resBlock = NULL; THMSG(1, "Matching with initial map ...\n"); @@ -405,7 +405,7 @@ isOK = FALSE; currRounds = 0; while ((currRounds++ < optRounds) && !isOK) { - DINT usedBlocks; + int usedBlocks; /* Get number of used blocks */ for (usedBlocks = i = 0; i < nmapBlocks; i++) @@ -488,7 +488,7 @@ currRounds = 0; isOK = FALSE; while ((currRounds++ < optRounds) && !isOK) { - DINT usedBlocks; + int usedBlocks; /* Get number of used blocks */ for (usedBlocks = i = 0; i < nmapBlocks; i++) @@ -505,7 +505,7 @@ mapblock_t *tmp = mapBlocks[i]; if (!tmp->mark) { - DINT qx = offsetX + tmp->x, + int qx = offsetX + tmp->x, qy = offsetY + tmp->y; isOK = FALSE; @@ -524,7 +524,7 @@ #if 0 /* Debug unmatching blocks */ - DCHAR mysti[512]; + char mysti[512]; snprintf(mysti, sizeof(mysti), "[%d]: %d,%d (%d,%d)", i, qx, qy, tmp->x, tmp->y); @@ -543,7 +543,7 @@ /* Output generated map */ if (worldMap) { - DINT unusedBlocks; + int unusedBlocks; FILE *tmpFile; THMSG(1, "Outputting generated map of (%d x %d) ...\n",