From 01035a7325be3257571d7980a7b61f43b775ea71 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 May 2016 20:49:47 +0200 Subject: [PATCH] password reading from external file is active, but broken. yikes --- src/kernel/save.c | 5 ++--- src/kernel/version.h | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 1619b3622..3930a5993 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1185,15 +1185,14 @@ static char * getpasswd(int fno) { static void read_password(gamedata *data, faction *f) { char name[128]; READ_STR(data->store, name, sizeof(name)); - if (data->version == BADCRYPT_VERSION) { + if (name[0]=='$' && data->version == BADCRYPT_VERSION) { char * pass = getpasswd(f->no); if (pass) { faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT)); free(pass); // TODO: remove this allocation! } else { - free(f->_password); - f->_password = NULL; + log_error("data version is BADCRYPT but %s not in password.txt", itoa36(f->no)); } } else { diff --git a/src/kernel/version.h b/src/kernel/version.h index f758bf0e9..aa0de93ab 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -33,10 +33,13 @@ #define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */ #define OWNER_3_VERSION 349 /* regions store last owner, not last alliance */ #define ATTRIBOWNER_VERSION 351 /* all attrib_type functions know who owns the attribute */ -#define BADCRYPT_VERSION 351 /* passwords are encrypted, poorly */ -#define CRYPT_VERSION 352 /* passwords are encrypted */ -#define RELEASE_VERSION ATTRIBOWNER_VERSION /* current datafile */ +#define BADCRYPT_VERSION 351 /* passwords are broken, 969.dat only. */ +#define NOCRYPT_VERSION 352 /* passwords are plaintext again */ +/* unfinished: */ +#define CRYPT_VERSION 400 /* passwords are encrypted */ + +#define RELEASE_VERSION NOCRYPT_VERSION /* current datafile */ #define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */ -#define MAX_VERSION BADCRYPT_VERSION /* change this if we can need to read the future datafile, and we can do so */ +#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ #define STREAM_VERSION 2 /* internal encoding of binary files */