Mercurial > hg > batmud > maputils
changeset 2607:f08dfd76b456
Constify.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 16 Feb 2024 12:27:55 +0200 |
parents | 5ee3c098dab9 |
children | ca5cc3978926 |
files | src/mkloc.c |
diffstat | 1 files changed, 23 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mkloc.c Fri Feb 16 11:54:30 2024 +0200 +++ b/src/mkloc.c Fri Feb 16 12:27:55 2024 +0200 @@ -250,7 +250,9 @@ } -int locPrintType(FILE *outFile, LocMarker *loc, bool adjust, int (*func)(const char *, FILE *), bool label) +int locPrintType(FILE *outFile, const LocMarker *loc, + const bool adjust, int (*func)(const char *, FILE *), + const bool label) { const char *type = locGetTypePrefix(loc->flags); int len = 0; @@ -264,7 +266,7 @@ if (func != NULL) { - char *name = (loc->names[0].name != NULL) ? loc->names[0].name : "UNKNOWN"; + const char *name = (loc->names[0].name != NULL) ? loc->names[0].name : "UNKNOWN"; if (outFile != NULL) func(name, outFile); len += strlen(name); @@ -341,17 +343,16 @@ /* Check for adjacent markers */ -int checkForAdjacent(MapLocations *world, int cx, int cy, int mask) +int checkForAdjacent(const MapLocations *world, const int cx, const int cy, const int mask) { - int x, y, n; - - for (y = -1; y <= 1; y++) - for (x = -1; x <= 1; x++) + for (int y = -1; y <= 1; y++) + for (int x = -1; x <= 1; x++) { + int n; if (!(y == 0 && x == 0) && (n = locFindByCoords(world, cx + x, cy + y, true)) >= 0) { - LocMarker *loc = world->locations[n]; + const LocMarker *loc = world->locations[n]; if ((loc->flags & mask) == mask) return n; } @@ -364,7 +365,7 @@ /* Scan given map and update location list with new locations, * if any are found. */ -void updateLocations(MapBlock *worldMap, MapLocations *worldLoc) +void updateLocations(const MapBlock *worldMap, MapLocations *worldLoc) { int n, numNewLoc = 0, numInvLoc = 0, numNoMarker = 0; size_t noptLocMarkers = strlen(optLocMarkers); @@ -476,11 +477,11 @@ /* Sort locations by name */ -void maplocSort(MapLocations *l) +void maplocSort(MapLocations *lp) { - for (int i = 0; i < l->nlocations; i++) + for (int i = 0; i < lp->nlocations; i++) { - LocMarker *loc = l->locations[i]; + LocMarker *loc = lp->locations[i]; loc->vsort.v_int = 2; switch (loc->flags & LOCF_M_MASK) @@ -500,14 +501,14 @@ } } - qsort(l->locations, l->nlocations, sizeof(LocMarker *), maplocCompare); + qsort(lp->locations, lp->nlocations, sizeof(LocMarker *), maplocCompare); } /* Output the map with labels and location markers, etc. in * special ASCII-CTRL format understood by colormap utility. */ -void outputMapCTRL(FILE *outFile, MapBlock *map, MapLocations *lp) +void outputMapCTRL(FILE *outFile, const MapBlock *map, const MapLocations *lp) { for (int yc = 0; yc < map->height; yc++) { @@ -603,13 +604,13 @@ /* Print out location list as HTML option list. */ -void outputMapLocHTML(FILE *outFile, MapLocations *lp) +void outputMapLocHTML(FILE *outFile, const MapLocations *lp) { fprintf(outFile, "<option value=\"\">-</option>\n"); for (int i = 0; i < lp->nlocations; i++) { - LocMarker *loc = lp->locations[i]; + const LocMarker *loc = lp->locations[i]; if (loc->flags & LOCF_INVIS) continue; @@ -623,7 +624,7 @@ /* Output generated locations into given file stream */ -void printLocNameEsc(FILE *outFile, LocName *name) +void printLocNameEsc(FILE *outFile, const LocName *name) { fputs(locGetAreaCreatorRole(name->flags, false), outFile); fputsesc2(name->name, outFile); @@ -870,7 +871,8 @@ } -static char *addQuestLink(char **buf, size_t *bufSize, size_t *bufLen, char *ptr, char *start, char *end) +static const char *addQuestLink(char **buf, size_t *bufSize, size_t *bufLen, + const char *ptr, const char *start, const char *end) { if (start != NULL && end != NULL) { @@ -887,7 +889,7 @@ return ptr; } -void outputGMapsHTML(FILE *outFile, LocMarker *loc, +void outputGMapsHTML(FILE *outFile, const LocMarker *loc, int (*fpr)(FILE *, const char *fmt, ...), int (*fps)(const char *, FILE *)) { @@ -967,13 +969,13 @@ // Print out freeform information field if (loc->freeform) { - char *ptr = loc->freeform; + const char *ptr = loc->freeform; char *buf = NULL; size_t bufLen = 0, bufSize = 0; while (*ptr != 0) { - char *start; + const char *start; // Detect AQ and LQ strings if (ptr[0] == 'A' && ptr[1] == 'Q' && th_isspace(ptr[2]) &&