E2 turn 966 desaster: code was writing a bad datafile

This commit is contained in:
Enno Rehling 2016-02-13 22:07:51 +01:00
parent 64937fac3a
commit 54e4b7a508
2 changed files with 4 additions and 4 deletions

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_BUILD 2 #define VERSION_BUILD 3

View File

@ -1221,7 +1221,7 @@ faction *readfaction(struct gamedata * data)
} }
READ_STR(data->store, name, sizeof(name)); READ_STR(data->store, name, sizeof(name));
faction_setpassword(f, (data->version >= CRYPT_VERSION) ? name : password_hash(name, 0, PASSWORD_DEFAULT)); faction_setpassword(f, (data->version > CRYPT_VERSION) ? name : password_hash(name, 0, PASSWORD_DEFAULT));
if (data->version < NOOVERRIDE_VERSION) { if (data->version < NOOVERRIDE_VERSION) {
READ_STR(data->store, 0, 0); READ_STR(data->store, 0, 0);
} }
@ -1407,7 +1407,7 @@ int readgame(const char *filename, bool backup)
create_backup(path); create_backup(path);
} }
F = fopen(path, "r"); F = fopen(path, "rb");
if (!F) { if (!F) {
perror(path); perror(path);
return -1; return -1;
@ -1753,7 +1753,7 @@ int writegame(const char *filename)
/* make sure we don't overwrite an existing file (hard links) */ /* make sure we don't overwrite an existing file (hard links) */
unlink(path); unlink(path);
#endif #endif
F = fopen(path, "w"); F = fopen(path, "wb");
if (!F) { if (!F) {
perror(path); perror(path);
return -1; return -1;