Mercurial > hg > batmud > maputils
diff mkspecial.c @ 1770:cc59f80b0e78
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Oct 2017 04:35:51 +0300 |
parents | f5d432ccc9d6 |
children | 72adabd8e746 |
line wrap: on
line diff
--- a/mkspecial.c Thu Oct 26 22:20:25 2017 +0300 +++ b/mkspecial.c Fri Oct 27 04:35:51 2017 +0300 @@ -208,16 +208,16 @@ if (c1 == 0 || c2 == 0) { - /* Both empty ... */ + // Both empty ... } else if (c1 != 0 && c1 == c2) { - /* Exact match, increase % */ + // Exact match, increase % n++; } else if (hardDrop) { - /* Mismatch, return failure */ + // Mismatch, return failure return -1; } } @@ -303,7 +303,7 @@ return NULL; } - /* Check for discardable lines */ + // Check for discardable lines if (!getLineData(inFile, s, sizeof(s))) return NULL; @@ -313,7 +313,7 @@ return NULL; } - /* New 'map' output in city maps has an empty line before the data, ignore it */ + // New 'map' output in city maps has an empty line before the data, ignore it if ((tmpW = getLineWidth(s, sizeof(s))) <= 9) { if (!getLineData(inFile, s, sizeof(s))) @@ -401,7 +401,7 @@ th_init("mkspecial", "Yet Another ASCII Map Auto-Stitcher", "0.5", NULL, NULL); th_verbosityLevel = 1; - /* Parse arguments */ + // Parse arguments if (!th_args_process(argc, argv, optList, optListN, argHandleOpt, argHandleFile, OPTH_BAILOUT)) exit(1); @@ -412,7 +412,7 @@ exit(0); } - /* Read initial map */ + // Read initial map if (optInitialMap) { THMSG(1, "Reading initial map '%s'\n", optInitialMap); @@ -521,19 +521,19 @@ */ - /* If initial map is available, find a match and determine coords */ + // If initial map is available, find a match and determine coords if (initialMap) { initialMap->x = optInitialX; initialMap->y = optInitialY; } - /* Clear marks */ + // Clear marks for (i = 0; i < nmapBlocks; i++) mapBlocks[i]->mark = FALSE; - /* Get world dimensions */ + // Get world dimensions worldX0 = worldY0 = worldX1 = worldY1 = 0; for (i = 0; i < nmapBlocks; i++) findWorldSize(mapBlocks[i], &worldX0, &worldY0, &worldX1, &worldY1); @@ -541,8 +541,8 @@ if (initialMap) findWorldSize(initialMap, &worldX0, &worldY0, &worldX1, &worldY1); - /* Compute offsets, allocate world map */ - /* FIXME: check dimensions */ + // Compute offsets, allocate world map + // FIXME: check dimensions offsetX = -worldX0; offsetY = -worldY0; @@ -552,7 +552,7 @@ exit(4); } - /* Place optional initial map */ + // Place optional initial map if (initialMap) { if (mapBlockPut(&worldMap, initialMap, offsetX+initialMap->x, offsetY+initialMap->y) < 0) @@ -569,28 +569,29 @@ THERR("Initial map mapBlockPut() failed!\n"); exit(9); } + mapBlocks[i]->mark = TRUE; } THMSG(1, "Initialized world map of (%d x %d), offset (%d, %d)\n", worldMap->width, worldMap->height, offsetX, offsetY); - /* Start placing blocks */ + // Start placing blocks currRounds = 0; isOK = FALSE; - while ((currRounds++ < optRounds) && !isOK) + while (currRounds++ < optRounds && !isOK) { int usedBlocks; - /* Get number of used blocks */ + // Get number of used blocks for (usedBlocks = i = 0; i < nmapBlocks; i++) if (mapBlocks[i]->mark) usedBlocks++; - /* Print out status information */ + // Print out status information THPRINT(2, "#%d [%d/%d]: ", currRounds, usedBlocks, nmapBlocks); - /* Place and match blocks */ + // Place and match blocks isOK = TRUE; currBlocks = 0; for (i = 0; i < nmapBlocks && currBlocks < optReset; i++) @@ -599,7 +600,7 @@ if (!tmp->mark) { - int qx = offsetX + tmp->x, + int qx = offsetX + tmp->x, qy = offsetY + tmp->y; isOK = FALSE; @@ -612,6 +613,7 @@ offsetX, offsetY, i); exit(9); } + tmp->mark = TRUE; currBlocks++; THPRINT(2, "X"); @@ -621,7 +623,7 @@ THPRINT(2, "."); #if 0 - /* Debug unmatching blocks */ + // Debug unmatching blocks char mysti[512]; snprintf(mysti, sizeof(mysti), "[%d]: %d,%d (%d,%d)", @@ -661,20 +663,21 @@ fclose(tmpFile); - /* Compute number of unused blocks */ + // Compute number of unused blocks for (unusedBlocks = i = 0; i < nmapBlocks; i++) - if (!mapBlocks[i]->mark) + if (!mapBlocks[i]->mark) + { + if (optDumpRejected) { - if (optDumpRejected) - { - fprintf(stderr, "\n#%d: %d,%d (%d,%d)\n", - i, mapBlocks[i]->x, mapBlocks[i]->y, - mapBlocks[i]->x + offsetX, mapBlocks[i]->y + offsetY); + fprintf(stderr, "\n#%d: %d,%d (%d,%d)\n", + i, mapBlocks[i]->x, mapBlocks[i]->y, + mapBlocks[i]->x + offsetX, + mapBlocks[i]->y + offsetY); - mapBlockPrint(stderr, mapBlocks[i]); - } - unusedBlocks++; + mapBlockPrint(stderr, mapBlocks[i]); } + unusedBlocks++; + } THMSG(1, "%d mapblocks unused/discarded\n", unusedBlocks); }