1: /*
   2:  * Copyright (c) 1983 Regents of the University of California,
   3:  * All rights reserved.  Redistribution permitted subject to
   4:  * the terms of the Berkeley Software License Agreement.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)room.c	1.3 4/24/85";
   9: #endif
  10: 
  11: #include "externs.h"
  12: 
  13: writedes()
  14: {
  15:     int compass;
  16:     register char *p;
  17:     register c;
  18: 
  19:     printf("\n\t%s\n", location[position].name);
  20:     if (beenthere[position] < 3) {
  21:         compass = NORTH;
  22:         for (p = location[position].desc; c = *p++;)
  23:             if (c != '-' && c != '*' && c != '+')
  24:                 putchar(c);
  25:             else {
  26:                 if (c != '*')
  27:                     printf(truedirec(compass, c));
  28:                 compass++;
  29:             }
  30:     }
  31: }
  32: 
  33: printobjs()
  34: {
  35:     register unsigned int *p = location[position].objects;
  36:     register n;
  37: 
  38:     printf("\n");
  39:     for (n = 0; n < NUMOFOBJECTS; n++)
  40:         if (testbit(p, n) && objdes[n])
  41:             puts(objdes[n]);
  42: }
  43: 
  44: whichway(here)
  45: struct room here;
  46: {
  47:     switch(direction) {
  48: 
  49:         case NORTH:
  50:             left = here.west;
  51:             right = here.east;
  52:             ahead = here.north;
  53:             back = here.south;
  54:             break;
  55: 
  56:         case SOUTH:
  57:             left = here.east;
  58:             right = here.west;
  59:             ahead = here.south;
  60:             back = here.north;
  61:             break;
  62: 
  63:         case EAST:
  64:             left = here.north;
  65:             right = here.south;
  66:             ahead = here.east;
  67:             back = here.west;
  68:             break;
  69: 
  70:         case WEST:
  71:             left = here.south;
  72:             right = here.north;
  73:             ahead = here.west;
  74:             back = here.east;
  75:             break;
  76: 
  77:     }
  78: }
  79: 
  80: char *
  81: truedirec(way, option)
  82: int way;
  83: char option;
  84: {
  85:     switch(way) {
  86: 
  87:         case NORTH:
  88:             switch(direction) {
  89:                 case NORTH:
  90:                     return("ahead");
  91:                 case SOUTH:
  92:                     return(option == '+' ? "behind you" : "back");
  93:                 case EAST:
  94:                     return("left");
  95:                 case WEST:
  96:                     return("right");
  97:             }
  98: 
  99:         case SOUTH:
 100:             switch(direction) {
 101:                 case NORTH:
 102:                     return(option == '+' ? "behind you" : "back");
 103:                 case SOUTH:
 104:                     return("ahead");
 105:                 case EAST:
 106:                     return("right");
 107:                 case WEST:
 108:                     return("left");
 109:             }
 110: 
 111:         case EAST:
 112:             switch(direction) {
 113:                 case NORTH:
 114:                     return("right");
 115:                 case SOUTH:
 116:                     return("left");
 117:                 case EAST:
 118:                     return("ahead");
 119:                 case WEST:
 120:                     return(option == '+' ? "behind you" : "back");
 121:             }
 122: 
 123:         case WEST:
 124:             switch(direction) {
 125:                 case NORTH:
 126:                     return("left");
 127:                 case SOUTH:
 128:                     return("right");
 129:                 case EAST:
 130:                     return(option == '+' ? "behind you" : "back");
 131:                 case WEST:
 132:                     return("ahead");
 133:             }
 134: 
 135:         default:
 136:             printf("Error: room %d.  More than four directions wanted.", position);
 137:             return("!!");
 138:       }
 139: }
 140: 
 141: newway(thisway)
 142: int thisway;
 143: {
 144:     switch(direction){
 145: 
 146:         case NORTH:
 147:             switch(thisway){
 148:                 case LEFT:
 149:                     direction = WEST;
 150:                     break;
 151:                 case RIGHT:
 152:                     direction = EAST;
 153:                     break;
 154:                 case BACK:
 155:                     direction = SOUTH;
 156:                     break;
 157:             }
 158:             break;
 159:         case SOUTH:
 160:             switch(thisway){
 161:                 case LEFT:
 162:                     direction = EAST;
 163:                     break;
 164:                 case RIGHT:
 165:                     direction = WEST;
 166:                     break;
 167:                 case BACK:
 168:                     direction = NORTH;
 169:                     break;
 170:             }
 171:             break;
 172:         case EAST:
 173:             switch(thisway){
 174:                 case LEFT:
 175:                     direction = NORTH;
 176:                     break;
 177:                 case RIGHT:
 178:                     direction = SOUTH;
 179:                     break;
 180:                 case BACK:
 181:                     direction = WEST;
 182:                     break;
 183:             }
 184:             break;
 185:         case WEST:
 186:             switch(thisway){
 187:                 case LEFT:
 188:                     direction = SOUTH;
 189:                     break;
 190:                 case RIGHT:
 191:                     direction = NORTH;
 192:                     break;
 193:                 case BACK:
 194:                     direction = EAST;
 195:                     break;
 196:             }
 197:             break;
 198:       }
 199: }

Defined functions

newway defined in line 141; used 2 times
truedirec defined in line 80; used 3 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-04-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 980
Valid CSS Valid XHTML 1.0 Strict