farren@well.UUCP (Mike Farren) (06/06/89)
Having played the Amiga version of Wanderer all the way out to level 44,
a distressing fact emerged: the saved game file stores your score to date
as a 16-bit signed integer, making it impossible to have a score higher
than 32767 in a saved game. Weird - this is almost the only place in the
entire program that uses "short" variables. Also, the score display
routines all call sprintf with the format string "%d" for the score, which
in the Lattice 5.02 compiler, if not others, forces the output to a short
signed integer. So even if you DID get a score above 32767, you wouldn't
be able to see it!
These are the changes I've made to allow for 32-bit integers as your
score. Note that they will make old saved games unusable. I've also
included a short program which will convert old saved games to new
saved games.
By the way - has anyone successfully completed levels 26 and 44? HELP!
--------
CHANGES - in scores.c, save.c, game.c, display.c, and m.c:
In file "scores.c":
*** CHANGE 48 IN old:scores.c TO 48 IN scores.c ***
<addstr("\nNo. Score Level Names How they died\n");
---------------
>addstr("\nNo. Score Level Names How they died\n");
*** CHANGE 54 IN old:scores.c TO 54 IN scores.c ***
< sprintf(buffer,"%2d %5d %3d %-20s killed by %-s\n",(tot - num),table->score,table->level,table->name,table->howdead);
---------------
> sprintf(buffer,"%2d %6ld %3d %-20s killed by %-s\n",(tot - num),table->score,table->level,table->name,table->howdead);
In file "save.c":
*** CHANGE [9,13] IN old:save.c TO [9,13] IN save.c ***
< short num;
< short score;
< short bell;
< short maxmoves;
< short num_monsters;
---------------
> int num;
> int score;
> int bell;
> int maxmoves;
> int num_monsters;
In file "game.c":
*** CHANGE 236 IN old:game.c TO 236 IN game.c ***
<(void) sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
---------------
>(void) sprintf(buffer,"%ld\t %d\t %d ",*score,nf,diamonds);
*** CHANGE 491 IN old:game.c TO 491 IN game.c ***
< sprintf(buffer,"%d\t %d",*score,nf);
---------------
> sprintf(buffer,"%ld\t %d",*score,nf);
*** CHANGE 522 IN old:game.c TO 522 IN game.c ***
< sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
---------------
> sprintf(buffer,"%ld\t %d\t %d ",*score,nf,diamonds);
*** CHANGE 603 IN old:game.c TO 603 IN game.c ***
< sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
---------------
> sprintf(buffer,"%ld\t %d\t %d ",*score,nf,diamonds);
*** CHANGE 685 IN old:game.c TO 685 IN game.c ***
< sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
---------------
> sprintf(buffer,"%ld\t %d\t %d ",*score,nf,diamonds);
*** CHANGE 796 IN old:game.c TO 796 IN game.c ***
< sprintf(buffer,"%d\t %d\t",*score,nf);
---------------
> sprintf(buffer,"%ld\t %d\t",*score,nf);
*** CHANGE 914 IN old:game.c TO 914 IN game.c ***
< sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
---------------
> sprintf(buffer,"%ld\t %d\t %d ",*score,nf,diamonds);
In file "display.c":
*** CHANGE 231 IN old:display.c TO 231 IN display.c ***
<(void) sprintf(buffer,"%d\t %d\t %d ",score,nf,diamonds);
---------------
>(void) sprintf(buffer,"%ld\t %d\t %d ",score,nf,diamonds);
In file "m.c":
*** CHANGE 167 IN old:m.c TO 167 IN m.c ***
< sprintf(buffer,"%s killed by %s with a score of %d on level %d.\n",name,howdead,score,num);
---------------
> sprintf(buffer,"%s killed by %s with a score of %ld on level %d.\n",name,howdead,score,num);
--------
CONVERSION PROGRAM: (compile with long integers only, please!)
/* Usage: convert <old saved game> <new saved game>
Minimal error checking - this is quick and dirty. */
#include <stdio.h>
main(argc, argv)
int argc; char *argv[];
{
FILE *fi, *fo;
int x, i;
short y;
if(argc != 3) exit(20);
fi = fopen(argv[1], "r");
fo = fopen(argv[2], "w");
if((fi == NULL) || (fo == NULL)) exit(20);
for(i=0; i!=5; i++) {
fread(&y, 2, 1, fi);
x = (int)y;
if(i == 1) x &= 0xffff; /* if score is negative */
fwrite(&x, 4, 1, fo);
}
while((i=fgetc(fi))!=EOF) fputc(i, fo);
fclose(fi);
fclose(fo);
}
--
Mike Farren uucp: well!farren