From 88688558373a72d36dbf7ad83b5c5c54ca164236 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Mar 2019 18:14:37 +0200 Subject: [PATCH] allow setting password to null --- src/bind_faction.c | 3 ++- src/kernel/faction.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index 9cc6bdd97..518dddc27 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -383,7 +383,8 @@ static int tolua_faction_set_password(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, NULL); const char * passw = tolua_tostring(L, 2, NULL); - faction_setpassword(self, password_hash(passw, PASSWORD_DEFAULT)); + faction_setpassword(self, + passw ? password_hash(passw, PASSWORD_DEFAULT) : NULL); return 0; } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index fc1de186a..238ba834b 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -564,8 +564,12 @@ const char *faction_getpassword(const faction *f) { void faction_setpassword(faction * f, const char *pwhash) { - assert(pwhash); - f->password_id = dbstring_save(pwhash); + if (pwhash) { + f->password_id = dbstring_save(pwhash); + } + else { + f->password_id = 0; + } } bool valid_race(const struct faction *f, const struct race *rc)