arogue7, xrogue: fix uninitialized variables when restoring.
The save and restore code assumed sizeof(long) == 4, which is not the case on x64. Reading only 4 bytes from the savefile left the others uninitialized, which led to problems like billions of experience points or gold pieces.
This commit is contained in:
parent
c639303acf
commit
419a920e1d
2 changed files with 30 additions and 4 deletions
|
|
@ -549,7 +549,10 @@ rs_read_long(int inf, long *i)
|
|||
buf = bytes;
|
||||
}
|
||||
|
||||
*i = *((long *) buf);
|
||||
if (sizeof(long) == 8)
|
||||
*i = *((int *) buf);
|
||||
else
|
||||
*i = *((long *) buf);
|
||||
|
||||
return(READSTAT);
|
||||
}
|
||||
|
|
@ -641,7 +644,10 @@ rs_read_ulong(int inf, unsigned long *i)
|
|||
buf = bytes;
|
||||
}
|
||||
|
||||
*i = *((unsigned long *) buf);
|
||||
if ( (sizeof(long) == 8) && (sizeof(int) == 4) )
|
||||
*i = *((unsigned int *) buf);
|
||||
else
|
||||
*i = *((unsigned long *) buf);
|
||||
|
||||
return(READSTAT);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue