changeset 793:0de9199f67d8

Constify and misc. cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 16 Jun 2009 17:36:21 +0000
parents f94c1d20de91
children 0b42f2952bde
files mapstats.c maputils.c maputils.h
diffstat 3 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mapstats.c	Tue Jun 16 16:05:31 2009 +0000
+++ b/mapstats.c	Tue Jun 16 17:36:21 2009 +0000
@@ -131,7 +131,7 @@
 int compareByName(const void *p1, const void *p2)
 {
     statpiece_t *vp1 = (statpiece_t *) p1, *vp2 = (statpiece_t *) p2;
-    mappiece_t *mp1 = &mapPieces[vp1->piece], *mp2 = &mapPieces[vp2->piece];
+    const mappiece_t *mp1 = &mapPieces[vp1->piece], *mp2 = &mapPieces[vp2->piece];
 
     if (optUseOldFormat) {
         if (mp1->oldSymbol >= 0 && mp2->oldSymbol >= 0)
@@ -150,7 +150,7 @@
 int compareBySymbol(const void *p1, const void *p2)
 {
     statpiece_t *vp1 = (statpiece_t *) p1, *vp2 = (statpiece_t *) p2;
-    mappiece_t *mp1 = &mapPieces[vp1->piece], *mp2 = &mapPieces[vp2->piece];
+    const mappiece_t *mp1 = &mapPieces[vp1->piece], *mp2 = &mapPieces[vp2->piece];
 
     if (optUseOldFormat) {
         if (mp1->oldSymbol >= 0 && mp2->oldSymbol >= 0)
--- a/maputils.c	Tue Jun 16 16:05:31 2009 +0000
+++ b/maputils.c	Tue Jun 16 17:36:21 2009 +0000
@@ -8,7 +8,7 @@
 #include "th_util.h"
 
 
-color_t mapColors[] = {
+const color_t mapColors[] = {
 { 0x00, 0x00, 0x00, 30,    ANSI_OFF },
 { 0x00, 0x00, 0xbb, 34,    ANSI_OFF },
 { 0xbb, 0x00, 0x00, 31,    ANSI_OFF },
@@ -31,10 +31,10 @@
 { 0xff, 0x80, 0x00, 31,    ANSI_BOLD },
 };
 
-const int nmapColors = (sizeof(mapColors) / sizeof(color_t));
+const int nmapColors = (sizeof(mapColors) / sizeof(mapColors[0]));
 
 
-mappiece_t mapPieces[] = {
+const mappiece_t mapPieces[] = {
 { '!', "Mountain Peak",     0xcc,0xff,0xff, col_white,          -1, -1,             NULL },
 { '#', "Ruins",             0x88,0x88,0x88, col_light_black,    -1, -1,             NULL },
 { '%', "Special Location",  0xff,0xff,0xff, col_light_white,    -1, -1,             NULL },
@@ -88,7 +88,7 @@
 
 const int nmapPieces = (sizeof(mapPieces) / sizeof(mapPieces[0]));
 
-mappiece_t mapCityPieces[] = {
+const mappiece_t mapCityPieces[] = {
 { '.', "Street",            0x00,0x00,0x00, col_yellow,         -1, col_white,      NULL },
 { '-', "Door/Gate",         0x00,0x00,0x00, col_light_yellow,   -1, col_yellow,     NULL },
 { '|', "Door/Gate",         0x00,0x00,0x00, col_light_yellow,   -1, col_yellow,     NULL },
@@ -114,7 +114,7 @@
 } html_entity_t;
 
 
-html_entity_t HTMLEntities[] = {
+static const html_entity_t HTMLEntities[] = {
     { '&', "amp" },
     { 'ä', "auml" },
     { 'ö', "ouml" },
@@ -124,13 +124,13 @@
     { '>', "gt" },
 };
 
-const int numHTMLEntities = (sizeof(HTMLEntities) / sizeof(html_entity_t));
+static const int numHTMLEntities = (sizeof(HTMLEntities) / sizeof(HTMLEntities[0]));
 
 
 void fprinte(FILE *outFile, char *fmt)
 {
     char *s = fmt;
-    if (!fmt) return;
+    if (fmt == NULL) return;
     
     while (*s) {
         int i;
@@ -162,7 +162,7 @@
 }
 
 
-int mcGetPieceFromList(mappiece_t pieces[], int npieces, int symbol, BOOL getOld)
+int mcGetPieceFromList(const mappiece_t pieces[], const int npieces, int symbol, BOOL getOld)
 {
     int i;
     
@@ -191,7 +191,7 @@
 }
 
 
-int mcGetColorFromList(mappiece_t pieces[], int npieces, int symbol, BOOL getOld)
+int mcGetColorFromList(const mappiece_t pieces[], const int npieces, int symbol, BOOL getOld)
 {
     int i;
     
--- a/maputils.h	Tue Jun 16 16:05:31 2009 +0000
+++ b/maputils.h	Tue Jun 16 17:36:21 2009 +0000
@@ -68,10 +68,10 @@
 
 /* Tables
  */
-extern color_t mapColors[];
+extern const color_t mapColors[];
 extern const int nmapColors;
 
-extern mappiece_t mapPieces[];
+extern const mappiece_t mapPieces[];
 extern const int nmapPieces;