]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
Don't modify string constants.
authormycroft <mycroft@NetBSD.org>
Tue, 20 Apr 1993 21:27:31 +0000 (21:27 +0000)
committermycroft <mycroft@NetBSD.org>
Tue, 20 Apr 1993 21:27:31 +0000 (21:27 +0000)
hack/hack.rip.c
hack/hack.u_init.c

index bdc282308c7e7904aab1efbfacc3da95a18b0bc2..7f729ba239910bffe345bd10546664261488198a 100644 (file)
@@ -6,31 +6,26 @@
 
 extern char plname[];
 
-static char *rip[] = {
-"                       ----------",
-"                      /          \\",
-"                     /    REST    \\",
-"                    /      IN      \\",
-"                   /     PEACE      \\",
-"                  /                  \\",
-"                  |                  |",
-"                  |                  |",
-"                  |                  |",
-"                  |                  |",
-"                  |                  |",
-"                  |       1001       |",
-"                 *|     *  *  *      | *",
-"        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n",
-0
-};
+static char *riptop= "\
+                       ----------\n\
+                      /          \\\n\
+                     /    REST    \\\n\
+                    /      IN      \\\n\
+                   /     PEACE      \\\n\
+                  /                  \\";
+
+static char *ripmid = "                  | %*s%*s |\n";
+
+static char *ripbot = "\
+                 *|     *  *  *      | *\n\
+        _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______";
 
 outrip(){
-       register char **dp = rip;
-       register char *dpx;
        char buf[BUFSZ];
-       register x,y;
 
        cls();
+       curs(1, 8);
+       puts(riptop);
        (void) strcpy(buf, plname);
        buf[16] = 0;
        center(6, buf);
@@ -42,40 +37,28 @@ outrip(){
                index(vowels, *killer) ? " an" : " a");
        center(8, buf);
        (void) strcpy(buf, killer);
-       if(strlen(buf) > 16) {
-           register int i,i0,i1;
-               i0 = i1 = 0;
-               for(i = 0; i <= 16; i++)
-                       if(buf[i] == ' ') i0 = i, i1 = i+1;
-               if(!i0) i0 = i1 = 16;
-               buf[i1 + 16] = 0;
+       {
+               register int i1;
+               if((i1 = strlen(buf)) > 16) {
+                       register int i,i0;
+                       i0 = i1 = 0;
+                       for(i = 0; i <= 16; i++)
+                               if(buf[i] == ' ') i0 = i, i1 = i+1;
+                       if(!i0) i0 = i1 = 16;
+                       buf[i1 + 16] = 0;
+                       buf[i0] = 0;
+               }
+               center(9, buf);
                center(10, buf+i1);
-               buf[i0] = 0;
        }
-       center(9, buf);
        (void) sprintf(buf, "%4d", getyear());
        center(11, buf);
-       for(y=8; *dp; y++,dp++){
-               x = 0;
-               dpx = *dp;
-               while(dpx[x]) {
-                       while(dpx[x] == ' ') x++;
-                       curs(x,y);
-                       while(dpx[x] && dpx[x] != ' '){
-                               extern int done_stopprint;
-                               if(done_stopprint)
-                                       return;
-                               curx++;
-                               (void) putchar(dpx[x++]);
-                       }
-               }
-       }
+       puts(ripbot);
        getret();
 }
 
 center(line, text) int line; char *text; {
-register char *ip,*op;
-       ip = text;
-       op = &rip[line][28 - ((strlen(text)+1)/2)];
-       while(*ip) *op++ = *ip++;
+       register int n = strlen(text)/2;
+       printf(ripmid, 8+n, text, 8-n, "");
 }
+
index bc06fa5ecfd5c92f32a8705c680b1fea5d88c215..4d664a614be1dadb6e4555c1b32ada4f9e423218 100644 (file)
@@ -15,7 +15,7 @@ extern char plname[];
 struct you zerou;
 char pl_character[PL_CSIZ];
 char *(roles[]) = {    /* must all have distinct first letter */
-                       /* roles[4] may be changed to -man */
+                       /* roles[4] may be changed to -woman */
        "Tourist", "Speleologist", "Fighter", "Knight",
        "Cave-man", "Wizard"
 };
@@ -103,7 +103,7 @@ extern char readchar();
        rolesyms[i] = 0;
 
        if(pc = pl_character[0]) {
-               if('a' <= pc && pc <= 'z') pc += 'A'-'a';
+               if(islower(pc)) pc = toupper(pc);
                if((i = role_index(pc)) >= 0)
                        goto got_suffix;        /* implies experienced */
                printf("\nUnknown role: %c\n", pc);
@@ -136,7 +136,7 @@ extern char readchar();
        printf("? [%s] ", rolesyms);
 
        while(pc = readchar()) {
-               if('a' <= pc && pc <= 'z') pc += 'A'-'a';
+               if(islower(pc)) pc = toupper(pc);
                if((i = role_index(pc)) >= 0) {
                        printf("%c\n", pc);     /* echo */
                        (void) fflush(stdout);  /* should be seen */
@@ -164,9 +164,13 @@ beginner:
                (void) putchar('\n');
                (void) fflush(stdout);
        }
+#if 0
+       /* Given the above code, I can't see why this would ever change
+          anything; it does core pretty well, though.  - cmh 4/20/93 */
        if(exper) {
                roles[i][0] = pc;
        }
+#endif
 
 got_suffix: