From 10e9633963797cac6bb94bb2950e7a1fcc25c1d3 Mon Sep 17 00:00:00 2001 From: mycroft Date: Tue, 20 Apr 1993 22:00:26 +0000 Subject: Don't modify string constants. --- larn/data.c | 137 ++++++++++++++++++++++++++++++---------------------------- larn/diag.c | 4 +- larn/header.h | 7 +-- larn/main.c | 4 +- larn/object.c | 8 ++-- larn/scores.c | 4 +- 6 files changed, 86 insertions(+), 78 deletions(-) (limited to 'larn') diff --git a/larn/data.c b/larn/data.c index a8739bab..d0f19c28 100644 --- a/larn/data.c +++ b/larn/data.c @@ -295,74 +295,81 @@ struct monst monster[] = { /* name array for scrolls */ -char *scrollname[] = { -"\0enchant armor", -"\0enchant weapon", -"\0enlightenment", -"\0blank paper", -"\0create monster", -"\0create artifact", -"\0aggravate monsters", -"\0time warp", -"\0teleportation", -"\0expanded awareness", -"\0haste monsters", -"\0monster healing", -"\0spirit protection", -"\0undead protection", -"\0stealth", -"\0magic mapping", -"\0hold monsters", -"\0gem perfection", -"\0spell extension", -"\0identify", -"\0remove curse", -"\0annihilation", -"\0pulverization", -"\0life protection", -"\0 ", -"\0 ", -"\0 ", -"\0 " +char *scrollname[] = {"","","","","","","","","","","","","","", + "","","","","","","","","","","","","",""}; + +char *scrollhide[] = { +" enchant armor", +" enchant weapon", +" enlightenment", +" blank paper", +" create monster", +" create artifact", +" aggravate monsters", +" time warp", +" teleportation", +" expanded awareness", +" haste monsters", +" monster healing", +" spirit protection", +" undead protection", +" stealth", +" magic mapping", +" hold monsters", +" gem perfection", +" spell extension", +" identify", +" remove curse", +" annihilation", +" pulverization", +" life protection", +" ", +" ", +" ", +" " }; +char *potionname[] = {"","","","","","","","","","","","","","", + "","","","","","","","","","","","","","", + "","","","","","",""}; + /* name array for magic potions */ -char *potionname[] = { -"\0sleep", -"\0healing", -"\0raise level", -"\0increase ability", -"\0wisdom", -"\0strength", -"\0raise charisma", -"\0dizziness", -"\0learning", -"\0gold detection", -"\0monster detection", -"\0forgetfulness", -"\0water", -"\0blindness", -"\0confusion", -"\0heroism", -"\0sturdiness", -"\0giant strength", -"\0fire resistance", -"\0treasure finding", -"\0instant healing", -" cure dianthroritis", -"\0poison", -"\0see invisible", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 ", -"\0 " +char *potionhide[] = { +" sleep", +" healing", +" raise level", +" increase ability", +" wisdom", +" strength", +" raise charisma", +" dizziness", +" learning", +" gold detection", +" monster detection", +" forgetfulness", +" water", +" blindness", +" confusion", +" heroism", +" sturdiness", +" giant strength", +" fire resistance", +" treasure finding", +" instant healing", +" ure dianthroritis", +" poison", +" see invisible", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" " }; diff --git a/larn/diag.c b/larn/diag.c index 4ed557d1..52daf121 100644 --- a/larn/diag.c +++ b/larn/diag.c @@ -213,8 +213,8 @@ restoregame(fname) level = c[CAVELEVEL] = lgetc(); playerx = lgetc(); playery = lgetc(); lrfill((char*)iven,26); lrfill((char*)ivenarg,26*sizeof(short)); - for (k=0; k2) /* no null items */ diff --git a/larn/object.c b/larn/object.c index 9bf7c3c5..cbe7c60b 100644 --- a/larn/object.c +++ b/larn/object.c @@ -391,7 +391,7 @@ quaffpotion(pot) { register int i,j,k; if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */ - potionname[pot][0] = ' '; + potionname[pot] = potionhide[pot]; switch(pot) { case 9: lprcat("\nYou feel greedy . . ."); nap(2000); @@ -550,7 +550,7 @@ read_scroll(typ) { register int i,j; if (typ<0 || typ>=MAXSCROLL) return; /* be sure we are within bounds */ - scrollname[typ][0] = ' '; + scrollname[typ] = scrollhide[typ]; switch(typ) { case 0: lprcat("\nYour armor glows for a moment"); enchantarmor(); return; @@ -615,8 +615,8 @@ read_scroll(typ) case 19: for (i=0; i<26; i++) /* identify */ { - if (iven[i]==OPOTION) potionname[ivenarg[i]][0] = ' '; - if (iven[i]==OSCROLL) scrollname[ivenarg[i]][0] = ' '; + if (iven[i]==OPOTION) potionname[ivenarg[i]] = potionhide[ivenarg[i]]; + if (iven[i]==OSCROLL) scrollname[ivenarg[i]] = scrollhide[ivenarg[i]]; } break; diff --git a/larn/scores.c b/larn/scores.c index f6cf15c1..7ffa4b77 100644 --- a/larn/scores.c +++ b/larn/scores.c @@ -290,8 +290,8 @@ showallscores() register int i,j; lflush(); lcreat((char*)0); if (readboard()<0) return; c[WEAR] = c[WIELD] = c[SHIELD] = -1; /* not wielding or wearing anything */ - for (i=0; i