118724Sedward /* 260750Sbostic * Copyright (c) 1983, 1993 360750Sbostic * The Regents of the University of California. All rights reserved. 434234Sbostic * 542571Sbostic * %sccs.include.redist.c% 618724Sedward */ 718724Sedward 817389Sedward #ifndef lint 9*69066Sbostic static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 04/28/95"; 1034234Sbostic #endif /* not lint */ 1117389Sedward 12*69066Sbostic #include "extern.h" 1317389Sedward writedes()1417389Sedwardwritedes() 1517389Sedward { 1617389Sedward int compass; 1717389Sedward register char *p; 1817389Sedward register c; 1917389Sedward 2017389Sedward printf("\n\t%s\n", location[position].name); 2117441Sedward if (beenthere[position] < 3) { 2217389Sedward compass = NORTH; 2317389Sedward for (p = location[position].desc; c = *p++;) 2417389Sedward if (c != '-' && c != '*' && c != '+') 2517389Sedward putchar(c); 2617389Sedward else { 2717389Sedward if (c != '*') 2817389Sedward printf(truedirec(compass, c)); 2917389Sedward compass++; 3017389Sedward } 3117389Sedward } 3217389Sedward } 3317389Sedward printobjs()3417389Sedwardprintobjs() 3517389Sedward { 3617441Sedward register unsigned int *p = location[position].objects; 3717389Sedward register n; 3817389Sedward 3917389Sedward printf("\n"); 4017441Sedward for (n = 0; n < NUMOFOBJECTS; n++) 4117441Sedward if (testbit(p, n) && objdes[n]) 4217441Sedward puts(objdes[n]); 4317389Sedward } 4417389Sedward 4517389Sedward whichway(here) 4617389Sedward struct room here; 4717389Sedward { 4817389Sedward switch(direction) { 4917389Sedward 5017389Sedward case NORTH: 5117389Sedward left = here.west; 5217389Sedward right = here.east; 5317389Sedward ahead = here.north; 5417389Sedward back = here.south; 5517389Sedward break; 5617389Sedward 5717389Sedward case SOUTH: 5817389Sedward left = here.east; 5917389Sedward right = here.west; 6017389Sedward ahead = here.south; 6117389Sedward back = here.north; 6217389Sedward break; 6317389Sedward 6417389Sedward case EAST: 6517389Sedward left = here.north; 6617389Sedward right = here.south; 6717389Sedward ahead = here.east; 6817389Sedward back = here.west; 6917389Sedward break; 7017389Sedward 7117389Sedward case WEST: 7217389Sedward left = here.south; 7317389Sedward right = here.north; 7417389Sedward ahead = here.west; 7517389Sedward back = here.east; 7617389Sedward break; 7717389Sedward 7817389Sedward } 7917389Sedward } 8017389Sedward 8117389Sedward char * truedirec(way,option)8217389Sedwardtruedirec(way, option) 8317389Sedward int way; 8417389Sedward char option; 8517389Sedward { 8617389Sedward switch(way) { 8717389Sedward 8817389Sedward case NORTH: 8917389Sedward switch(direction) { 9017389Sedward case NORTH: 9117389Sedward return("ahead"); 9217389Sedward case SOUTH: 9317389Sedward return(option == '+' ? "behind you" : "back"); 9417389Sedward case EAST: 9517389Sedward return("left"); 9617389Sedward case WEST: 9717389Sedward return("right"); 9817389Sedward } 9917389Sedward 10017389Sedward case SOUTH: 10117389Sedward switch(direction) { 10217389Sedward case NORTH: 10317389Sedward return(option == '+' ? "behind you" : "back"); 10417389Sedward case SOUTH: 10517389Sedward return("ahead"); 10617389Sedward case EAST: 10717389Sedward return("right"); 10817389Sedward case WEST: 10917389Sedward return("left"); 11017389Sedward } 11117389Sedward 11217389Sedward case EAST: 11317389Sedward switch(direction) { 11417389Sedward case NORTH: 11517389Sedward return("right"); 11617389Sedward case SOUTH: 11717389Sedward return("left"); 11817389Sedward case EAST: 11917389Sedward return("ahead"); 12017389Sedward case WEST: 12117389Sedward return(option == '+' ? "behind you" : "back"); 12217389Sedward } 12317389Sedward 12417389Sedward case WEST: 12517389Sedward switch(direction) { 12617389Sedward case NORTH: 12717389Sedward return("left"); 12817389Sedward case SOUTH: 12917389Sedward return("right"); 13017389Sedward case EAST: 13117389Sedward return(option == '+' ? "behind you" : "back"); 13217389Sedward case WEST: 13317389Sedward return("ahead"); 13417389Sedward } 13517389Sedward 13617389Sedward default: 13717389Sedward printf("Error: room %d. More than four directions wanted.", position); 13817389Sedward return("!!"); 13917389Sedward } 14017389Sedward } 14117389Sedward newway(thisway)14217389Sedwardnewway(thisway) 14317389Sedward int thisway; 14417389Sedward { 14517389Sedward switch(direction){ 14617389Sedward 14717389Sedward case NORTH: 14817389Sedward switch(thisway){ 14917389Sedward case LEFT: 15017389Sedward direction = WEST; 15117389Sedward break; 15217389Sedward case RIGHT: 15317389Sedward direction = EAST; 15417389Sedward break; 15517389Sedward case BACK: 15617389Sedward direction = SOUTH; 15717389Sedward break; 15817389Sedward } 15917389Sedward break; 16017389Sedward case SOUTH: 16117389Sedward switch(thisway){ 16217389Sedward case LEFT: 16317389Sedward direction = EAST; 16417389Sedward break; 16517389Sedward case RIGHT: 16617389Sedward direction = WEST; 16717389Sedward break; 16817389Sedward case BACK: 16917389Sedward direction = NORTH; 17017389Sedward break; 17117389Sedward } 17217389Sedward break; 17317389Sedward case EAST: 17417389Sedward switch(thisway){ 17517389Sedward case LEFT: 17617389Sedward direction = NORTH; 17717389Sedward break; 17817389Sedward case RIGHT: 17917389Sedward direction = SOUTH; 18017389Sedward break; 18117389Sedward case BACK: 18217389Sedward direction = WEST; 18317389Sedward break; 18417389Sedward } 18517389Sedward break; 18617389Sedward case WEST: 18717389Sedward switch(thisway){ 18817389Sedward case LEFT: 18917389Sedward direction = SOUTH; 19017389Sedward break; 19117389Sedward case RIGHT: 19217389Sedward direction = NORTH; 19317389Sedward break; 19417389Sedward case BACK: 19517389Sedward direction = EAST; 19617389Sedward break; 19717389Sedward } 19817389Sedward break; 19917389Sedward } 20017389Sedward } 201