Use symbolic shortnames for locations.
[open-adventure.git] / actions.c
index 5000f1eb0f738cd0ff369cba0af05d1bdd119705..9cd6e0df4547afc21048ea9eac4a93d14ad712e4 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -21,9 +21,9 @@ static int attack(FILE *input, long verb, token_t obj)
  *  enemies, or no enemies but 2 others. */
 {
     int spk = ACTSPK[verb];
-    int i = ATDWRF(game.loc);
+    int d = ATDWRF(game.loc);
     if (obj == 0) {
-       if (i > 0)
+       if (d > 0)
            obj=DWARF;
        if (HERE(SNAKE))obj=obj*NOBJECTS+SNAKE;
        if (AT(DRAGON) && game.prop[DRAGON] == 0)obj=obj*NOBJECTS+DRAGON;
@@ -66,15 +66,15 @@ static int attack(FILE *input, long verb, token_t obj)
     if (obj == DRAGON)spk=ALREADY_DEAD;
     if (obj == TROLL)spk=ROCKY_TROLL;
     if (obj == OGRE)spk=OGRE_DOFGE;
-    if (obj == OGRE && i > 0) {
+    if (obj == OGRE && d > 0) {
        RSPEAK(spk);
        RSPEAK(KNIFE_THROWN);
        DSTROY(OGRE);
        int k=0;
-       for (i=1; i < PIRATE; i++) {
+       for (int i=1; i < PIRATE; i++) {
            if (game.dloc[i] == game.loc) {
                ++k;
-               game.dloc[i]=61;
+               game.dloc[i] = LOC_LONGWEST;
                game.dseen[i]=false;
            }
        }
@@ -150,14 +150,15 @@ static int bivalve(token_t verb, token_t obj)
 {
     int spk, k=0;
     if (obj == OYSTER)k=1;
-    spk=PEARL_FALLS+k;
+    /* FIXME: Arithmetic on message numbers in next lines */
+    spk=PEARL_FALLS+k;         
     if (TOTING(obj))spk=DROP_CLAM+k;
     if (!TOTING(TRIDNT))spk=CLAM_OPENER+k;
     if (verb == LOCK)spk=HUH_MAN;
-    if (spk == 124) {
+    if (spk == PEARL_FALLS) {
        DSTROY(CLAM);
        DROP(OYSTER,game.loc);
-       DROP(PEARL,105);
+       DROP(PEARL,LOC_CULDESAC);
     }
     RSPEAK(spk);
     return GO_CLEAROBJ;
@@ -172,7 +173,7 @@ static int blast(void)
        return GO_CLEAROBJ;
     }
     game.bonus=133;
-    if (game.loc == 115)
+    if (game.loc == LOC_NE)
        game.bonus=134;
     if (HERE(ROD2))
        game.bonus=135;
@@ -340,7 +341,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
                 if (TOTING(RUG))spk=RUG_WIGGLES;
                 if (obj == RUBY)spk=RUG_SETTLES;
                 RSPEAK(spk);
-                if (spk != 220) {
+                if (spk != RUG_WIGGLES) {
                     int k = 2-game.prop[RUG];
                     game.prop[RUG] = k;
                     if (k == 2) k = PLAC[SAPPH];
@@ -582,7 +583,7 @@ static int fly(token_t verb, token_t obj)
     if (obj == INTRANSITIVE) {
        if (game.prop[RUG] != 2)spk=RUG_NOTHING2;
        if (!HERE(RUG))spk=FLAP_ARMS;
-       if (spk/2 == 112) {
+       if (spk/2 == 112) {     /* FIXME: Arithmetic on message numbers */
            RSPEAK(spk);
            return GO_CLEAROBJ;
        }
@@ -603,16 +604,15 @@ static int fly(token_t verb, token_t obj)
     RSPEAK(spk);
     return GO_TERMINATE;
 }
-    
+
 static int inven(token_t obj)
 /* Inventory. If object, treat same as find.  Else report on current burden. */
 {
-    int i;
     int spk=NO_CARRY;
-    for (i=1; i<=NOBJECTS; i++) {
+    for (int i=1; i<=NOBJECTS; i++) {
        if (i == BEAR || !TOTING(i))
            continue;
-       if (spk == 98)
+       if (spk == NO_CARRY)
            RSPEAK(NOW_HOLDING);
        game.blklin=false;
        PSPEAK(i,-1);
@@ -660,13 +660,13 @@ int light(token_t verb, token_t obj)
            return GO_TOP;
        else
            return GO_CLEAROBJ;
-    }   
+    }
 }
 
 static int listen(void)
 /*  Listen.  Intransitive only.  Print stuff based on objsnd/locsnd. */
 {
-    int i, k;
+    int k;
     int spk=ALL_SILENT;
     k=LOCSND[game.loc];
     if (k != 0) {
@@ -675,7 +675,7 @@ static int listen(void)
        spk=ARB_0;
     }
     SETPRM(1,game.zzword,0);
-    for (i=1; i<=NOBJECTS; i++) {
+    for (int i=1; i<=NOBJECTS; i++) {
        if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0)
            continue;
        PSPEAK(i,OBJSND[i]+game.prop[i]);
@@ -1003,9 +1003,10 @@ int action(FILE *input, enum speechpart part, long verb, token_t obj)
        if (HERE(obj))
            /* FALL THROUGH */;
        else if (obj == GRATE) {
-           if (game.loc == 1 || game.loc == 4 || game.loc == 7)
+           if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT)
                obj=DPRSSN;
-           if (game.loc > 9 && game.loc < 15)
+           /* FIXME: Arithmetic on location numbers */
+           if (game.loc > LOC_BELOWGRATE && game.loc < LOC_MISTHALL)
                obj=ENTRNC;
            if (obj != GRATE)
                return GO_MOVE;