password reading from external file is active, but broken. yikes

This commit is contained in:
Enno Rehling 2016-05-20 20:49:47 +02:00
parent b5a84f07ba
commit 01035a7325
2 changed files with 9 additions and 7 deletions

View File

@ -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 {

View File

@ -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 */