Annotation of 43BSDReno/games/battlestar/room.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)room.c     5.3 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: #include "externs.h"
        !            25: 
        !            26: writedes()
        !            27: {
        !            28:        int compass;
        !            29:        register char *p;
        !            30:        register c;
        !            31: 
        !            32:        printf("\n\t%s\n", location[position].name);
        !            33:        if (beenthere[position] < 3) {
        !            34:                compass = NORTH;
        !            35:                for (p = location[position].desc; c = *p++;)
        !            36:                        if (c != '-' && c != '*' && c != '+')
        !            37:                                putchar(c);
        !            38:                        else {
        !            39:                                if (c != '*')
        !            40:                                        printf(truedirec(compass, c));
        !            41:                                compass++;
        !            42:                        }
        !            43:        }
        !            44: }
        !            45: 
        !            46: printobjs()
        !            47: {
        !            48:        register unsigned int *p = location[position].objects;
        !            49:        register n;
        !            50: 
        !            51:        printf("\n");
        !            52:        for (n = 0; n < NUMOFOBJECTS; n++)
        !            53:                if (testbit(p, n) && objdes[n])
        !            54:                        puts(objdes[n]);
        !            55: }
        !            56: 
        !            57: whichway(here)
        !            58: struct room here;
        !            59: {
        !            60:        switch(direction) {
        !            61: 
        !            62:                case NORTH:
        !            63:                        left = here.west;
        !            64:                        right = here.east;
        !            65:                        ahead = here.north;
        !            66:                        back = here.south;
        !            67:                        break;
        !            68:                
        !            69:                case SOUTH:
        !            70:                        left = here.east;
        !            71:                        right = here.west;
        !            72:                        ahead = here.south;
        !            73:                        back = here.north;
        !            74:                        break;
        !            75: 
        !            76:                case EAST:
        !            77:                        left = here.north;
        !            78:                        right = here.south;
        !            79:                        ahead = here.east;
        !            80:                        back = here.west;
        !            81:                        break;
        !            82: 
        !            83:                case WEST:
        !            84:                        left = here.south;
        !            85:                        right = here.north;
        !            86:                        ahead = here.west;
        !            87:                        back = here.east;
        !            88:                        break;
        !            89: 
        !            90:        }
        !            91: }
        !            92: 
        !            93: char *
        !            94: truedirec(way, option)
        !            95: int way;
        !            96: char option;
        !            97: {
        !            98:        switch(way) {
        !            99: 
        !           100:                case NORTH:
        !           101:                        switch(direction) {
        !           102:                                case NORTH:
        !           103:                                        return("ahead");
        !           104:                                case SOUTH:
        !           105:                                        return(option == '+' ? "behind you" : "back");
        !           106:                                case EAST:
        !           107:                                        return("left");
        !           108:                                case WEST:
        !           109:                                        return("right");
        !           110:                        }
        !           111: 
        !           112:                case SOUTH:
        !           113:                        switch(direction) {
        !           114:                                case NORTH:
        !           115:                                        return(option == '+' ? "behind you" : "back");
        !           116:                                case SOUTH:
        !           117:                                        return("ahead");
        !           118:                                case EAST:
        !           119:                                        return("right");
        !           120:                                case WEST:
        !           121:                                        return("left");
        !           122:                        }
        !           123: 
        !           124:                case EAST:
        !           125:                        switch(direction) {
        !           126:                                case NORTH:
        !           127:                                        return("right");
        !           128:                                case SOUTH:
        !           129:                                        return("left");
        !           130:                                case EAST:
        !           131:                                        return("ahead");
        !           132:                                case WEST:      
        !           133:                                        return(option == '+' ? "behind you" : "back");
        !           134:                        }
        !           135: 
        !           136:                case WEST:
        !           137:                        switch(direction) {
        !           138:                                case NORTH:
        !           139:                                        return("left");
        !           140:                                case SOUTH:
        !           141:                                        return("right");
        !           142:                                case EAST:
        !           143:                                        return(option == '+' ? "behind you" : "back");
        !           144:                                case WEST:
        !           145:                                        return("ahead");
        !           146:                        }
        !           147: 
        !           148:                default:
        !           149:                        printf("Error: room %d.  More than four directions wanted.", position);
        !           150:                        return("!!");
        !           151:       }
        !           152: }
        !           153: 
        !           154: newway(thisway)
        !           155: int thisway;
        !           156: {
        !           157:        switch(direction){
        !           158: 
        !           159:                case NORTH:
        !           160:                        switch(thisway){
        !           161:                                case LEFT:
        !           162:                                        direction = WEST;
        !           163:                                        break;
        !           164:                                case RIGHT:
        !           165:                                        direction = EAST;
        !           166:                                        break;
        !           167:                                case BACK:
        !           168:                                        direction = SOUTH;
        !           169:                                        break;
        !           170:                        }
        !           171:                        break;
        !           172:                case SOUTH:
        !           173:                        switch(thisway){
        !           174:                                case LEFT:
        !           175:                                        direction = EAST;
        !           176:                                        break;
        !           177:                                case RIGHT:
        !           178:                                        direction = WEST;
        !           179:                                        break;
        !           180:                                case BACK:
        !           181:                                        direction = NORTH;
        !           182:                                        break;
        !           183:                        }
        !           184:                        break;
        !           185:                case EAST:
        !           186:                        switch(thisway){
        !           187:                                case LEFT:
        !           188:                                        direction = NORTH;
        !           189:                                        break;
        !           190:                                case RIGHT:
        !           191:                                        direction = SOUTH;
        !           192:                                        break;
        !           193:                                case BACK:
        !           194:                                        direction = WEST;
        !           195:                                        break;
        !           196:                        }
        !           197:                        break;
        !           198:                case WEST:
        !           199:                        switch(thisway){
        !           200:                                case LEFT:
        !           201:                                        direction = SOUTH;
        !           202:                                        break;
        !           203:                                case RIGHT:
        !           204:                                        direction = NORTH;
        !           205:                                        break;
        !           206:                                case BACK:
        !           207:                                        direction = EAST;
        !           208:                                        break;
        !           209:                        }
        !           210:                        break;
        !           211:       }
        !           212: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.