Remove handlers for disused advent format specifiers.
[open-adventure.git] / misc.c
diff --git a/misc.c b/misc.c
index 91f2dfa6ad6406a3400c614495da52163410a124..ba9bed32991e7975275eeb064895714bea22b69c 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/time.h>
+#include <ctype.h>
 
 #include "advent.h"
 #include "database.h"
@@ -50,38 +51,12 @@ void SPEAK(vocab_t msg)
                return;
            if (prmtyp == ascii_to_advent['S']) {
                SHFTXT(LNPOSN+2,-1);
-               INLINE[LNPOSN] = 55;
+               INLINE[LNPOSN] = ascii_to_advent['s'];
                if (PARMS[nparms] == 1)
                    SHFTXT(LNPOSN+1,-1);
                ++nparms;
                continue;
            }
-           if (prmtyp == ascii_to_advent['T']) {
-               SHFTXT(LNPOSN+2,-2);
-               state=0;
-               casemake=2;
-
-               while (PARMS[nparms] > 0) {
-                   if (PARMS[nparms+1] < 0)
-                       casemake=0;
-                   PUTTXT(PARMS[nparms],&state,casemake);
-                   ++nparms;
-               }
-               ++nparms;
-               continue;
-           }
-           if (prmtyp == ascii_to_advent['B']) {
-               prmtyp=PARMS[nparms];
-               SHFTXT(LNPOSN+2,prmtyp-2);
-               if (prmtyp != 0) {
-                   for (i=1; i<=prmtyp; i++) {
-                       INLINE[LNPOSN]=0;
-                       ++LNPOSN;
-                   }
-               }
-               ++nparms;
-               continue;
-           }
            if (prmtyp == ascii_to_advent['W'] || prmtyp == ascii_to_advent['L'] || prmtyp == ascii_to_advent['U'] || prmtyp == ascii_to_advent['C']) {
                SHFTXT(LNPOSN+2,-2);
                state = 0;
@@ -94,7 +69,14 @@ void SPEAK(vocab_t msg)
                PUTTXT(PARMS[nparms],&state,casemake);
                PUTTXT(PARMS[nparms+1],&state,casemake);
                if (prmtyp == ascii_to_advent['C'] && INLINE[i] >= ascii_to_advent['a'] && INLINE[i] <= ascii_to_advent['z'])
-                   INLINE[i] -= 26;
+                 {
+                   // Convert to uppercase.
+                   // Round-trip to ASCII and back so that this code doesn't break when the mapping changes.
+                   // This can be simplified when mapping goes away.
+                   char this = advent_to_ascii[INLINE[i]];
+                   char uc_this = toupper(this);
+                   INLINE[i] = ascii_to_advent[uc_this];
+                 }
                nparms += 2;
                continue;
            }