Use the '=' operator (not memcpy()) to shallow-copy structs.
This commit is contained in:
parent
87c6d3fb1e
commit
26bf324e07
2 changed files with 7 additions and 13 deletions
|
@ -36,7 +36,7 @@ int savefile(FILE *fp, long version)
|
|||
save.mode = -1;
|
||||
save.version = (version == 0) ? VRSION : version;
|
||||
|
||||
memcpy(&save.game, &game, sizeof(struct game_t));
|
||||
save.game = game;
|
||||
IGNORE(fwrite(&save, sizeof(struct save_t), 1, fp));
|
||||
return (0);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ int restore(FILE* fp)
|
|||
if (save.version != VRSION) {
|
||||
rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10));
|
||||
} else {
|
||||
memcpy(&game, &save.game, sizeof(struct game_t));
|
||||
game = save.game;
|
||||
}
|
||||
return GO_TOP;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue