changeset 86:2519990b273e

Added support for old map symbols; Removed some functions that were only used in colormap etc.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 16 Dec 2006 12:16:50 +0000
parents b4318cb59c71
children d422585c19b9
files maputils.c maputils.h
diffstat 2 files changed, 70 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/maputils.c	Sat Dec 16 12:16:15 2006 +0000
+++ b/maputils.c	Sat Dec 16 12:16:50 2006 +0000
@@ -32,90 +32,86 @@
 
 
 mappiece_t mapPieces[] = {
-{ '!', "Mountain Peak",		col_white },
-{ '#', "Ruins",			col_light_black },
-{ '%', "Special Location",	col_light_white },
-{ '+', "Crossing",		col_light_black },
-{ '-', "Road",			col_light_black },
-{ '|', "Road",			col_light_black },
-{ '/', "Road",			col_light_black },
-{ '\\',"Road",			col_light_black },
-{ '.', "Plains",		col_green },
-{ '=', "Bridge",		col_light_black },
-{ '?', "Scenic Location",	col_light_white },
-{ '@', "Flowing Lava",		col_light_red },
-{ 'C', "Player City",		col_light_black },
-{ 'F', "Deep Forest",		col_green },
-{ 'H', "Highlands",		col_magenta },
-{ 'L', "Lava Lake",		col_light_red },
-{ 'R', "Deep River",		col_blue },
-{ 'S', "Shallows",		col_light_cyan },
-{ 'V', "Volcano",		col_red },
-{ '^', "Mountain",		col_light_magenta },
-{ 'b', "Beach",			col_yellow },
-{ 'c', "City",			col_light_black },
-{ 'd', "Desert",		col_yellow },
-{ 'f', "Forest",		col_light_green },
-{ 'h', "Hills",			col_magenta },
-{ 'i', "Ice",			col_light_blue },
-{ 'j', "Jungle",		col_green },
-{ 'l', "Lake",			col_light_blue },
-{ 'r', "River",			col_light_blue },
-{ 's', "Swamp",			col_light_red },
-{ 't', "Tundra",		col_white },
-{ 'v', "Valley",		col_light_green },
-{ 'w', "Waterfall",		col_light_cyan },
-{ 'x', "Badlands",		col_light_red },
-{ 'y', "Fields",		col_yellow },
-{ 'z', "Shore",			col_light_yellow },
-{ '~', "Sea",			col_blue },
-{ ',', "Muddy Trail",		col_light_yellow },
+{ '!', "Mountain Peak",		col_white,		-1,	-1 },
+{ '#', "Ruins",			col_light_black,	-1,	-1 },
+{ '%', "Special Location",	col_light_white,	-1,	-1 },
+{ '+', "Crossing",		col_light_black,	-1,	-1 },
+{ '-', "Road",			col_light_black,	-1,	-1 },
+{ '|', "Road",			col_light_black,	-1,	-1 },
+{ '/', "Road",			col_light_black,	-1,	-1 },
+{ '\\',"Road",			col_light_black,	-1,	-1 },
+{ '.', "Plains",		col_green,		'p',	col_light_green },
+{ '=', "Bridge",		col_light_black,	-1,	-1 },
+{ '?', "Scenic Location",	col_light_white,	-1,	-1 },
+{ '@', "Flowing Lava",		col_light_red,		-1,	-1 },
+{ 'C', "Player City",		col_light_black,	-1,	-1 },
+{ 'F', "Deep Forest",		col_green,		-1,	-1 },
+{ 'H', "Highlands",		col_magenta,		-1,	-1 },
+{ 'L', "Lava Lake",		col_light_red,		-1,	-1 },
+{ 'R', "Deep River",		col_blue,		-1,	-1 },
+{ 'S', "Shallows",		col_light_cyan,		-1,	-1 },
+{ 'V', "Volcano",		col_red,		-1,	-1 },
+{ '^', "Mountain",		col_light_magenta,	-1,	-1 },
+{ 'b', "Beach",			col_yellow,		-1,	-1 },
+{ 'c', "City",			col_light_black,	-1,	-1 },
+{ 'd', "Desert",		col_yellow,		-1,	-1 },
+{ 'f', "Forest",		col_light_green,	-1,	-1 },
+{ 'h', "Hills",			col_magenta,		-1,	-1 },
+{ 'i', "Ice",			col_light_blue,		-1,	-1 },
+{ 'j', "Jungle",		col_green,		-1,	-1 },
+{ 'l', "Lake",			col_light_blue,		-1,	-1 },
+{ 'r', "River",			col_light_blue,		-1,	-1 },
+{ 's', "Swamp",			col_light_red,		-1,	-1 },
+{ 't', "Tundra",		col_white,		-1,	-1 },
+{ 'v', "Valley",		col_light_green,	-1,	-1 },
+{ 'w', "Waterfall",		col_light_cyan,		-1,	-1 },
+{ 'x', "Badlands",		col_light_red,		-1,	-1 },
+{ 'y', "Fields",		col_yellow,		-1,	col_light_yellow },
+{ 'z', "Shore",			col_light_yellow,	-1,	-1 },
+{ '~', "Sea",			col_blue,		-1,	-1 },
+{ ',', "Muddy Trail",		col_light_yellow,	-1,	-1 },
 };
 
 const int nmapPieces = (sizeof(mapPieces) / sizeof(mappiece_t));
 
 
-int mcGet(int c)
+int mcGet(int symbol, BOOL getOld)
 {
 	int i;
+	
 	for (i = 0; i < nmapPieces; i++)
-		if (mapPieces[i].c == c)
+		if (getOld && mapPieces[i].oldSymbol == symbol)
 			return i;
+		else if (mapPieces[i].symbol == symbol)
+			return i;
+
 	return -1;
 }
 
-int mcGetColor(int c)
+
+int mcGetColor(int symbol, BOOL getOld)
 {
 	int i;
-	for (i = 0; i < nmapPieces; i++)
-		if (mapPieces[i].c == c)
-			return mapPieces[i].col;
-	return 0;
-}
-
-void mcXHTMLcolors(FILE *o, char *element)
-{
-	int n;
 	
-	for (n = 0; n < nmapColors; n++) {
-		fprintf(o,
-		"  %s.%c { color: %s; }\n",
-		element, 'a'+n, mapColors[n].css);
+	if (getOld) {
+		for (i = 0; i < nmapPieces; i++)
+		if (mapPieces[i].oldSymbol == symbol) {
+			if (mapPieces[i].oldColor >= 0)
+				return mapPieces[i].oldColor;
+			else
+				return mapPieces[i].color;
+		}
 	}
-	
-}
-
 
-void mcXHTMLhead(FILE *outFile, char *title)
-{
-	fprintf(outFile,
-	"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
-	"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
-	"<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n"
-	"<head>\n");
-	
-	if (title)
-	fprintf(outFile, "  <title>%s</title>\n", title);
+	for (i = 0; i < nmapPieces; i++)
+	if (mapPieces[i].symbol == symbol) {
+		if (getOld && mapPieces[i].oldColor >= 0)
+			return mapPieces[i].oldColor;
+		else
+			return mapPieces[i].color;
+	}
+
+	return 0;
 }
 
 
--- a/maputils.h	Sat Dec 16 12:16:15 2006 +0000
+++ b/maputils.h	Sat Dec 16 12:16:50 2006 +0000
@@ -7,9 +7,11 @@
 /* Typedefs
  */
 typedef struct {
-	char c;
+	char symbol;
 	char *desc;
-	int col;
+	int color;
+	char oldSymbol;
+	int oldColor;
 } mappiece_t;
 
 
@@ -23,7 +25,7 @@
 typedef struct {
 	char *css;
 	int ansi;
-	int ansi_attr;
+	int ansiAttr;
 } color_t;
 
 
@@ -68,10 +70,8 @@
 
 /* Functions
  */
-int	mcGet(int);
-int	mcGetColor(int);
-void	mcXHTMLcolors(FILE *, char *);
-void	mcXHTMLhead(FILE *, char *);
+int		mcGet(int, BOOL);
+int		mcGetColor(int, BOOL);
 
 mapblock_t *	allocBlock(int, int);
 void		freeBlock(mapblock_t *);