summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mapScore.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mapScore.c b/mapScore.c
index 88e7b7d..21b0490 100644
--- a/mapScore.c
+++ b/mapScore.c
@@ -4,7 +4,7 @@
 #define BUFSIZE 1024
 char buffer[BUFSIZE];
 // TODO: Support UTF-8.
-int map[256][2];
+int map[256][3];
 
 void makeMap(FILE *f) {
 	int x = 0; int y = 0;
@@ -16,6 +16,7 @@ void makeMap(FILE *f) {
 		default:
 			map[c][0] = x;
 			map[c][1] = y;
+			map[c][2] = 1;
 			break;
 		}
 	}
@@ -24,9 +25,13 @@ void makeMap(FILE *f) {
 int scoreWord(char *word, int (*fun)(int*,int*)) {
 	char *c = word;
 	int score = 0;
+	char *p = c;
 	for (c++;*c;c++) {
 		if (*c == '\n') break;
-		score += (*fun)(map[c[-1]],map[c[0]]);
+		// pass over ignore unset chars.
+		if(map[(unsigned)*c][3] == 0) continue;
+		score += (*fun)(map[(unsigned)*p],map[(unsigned)*c]);
+		p=c;
 	}
 	return score;
 }