From c8c4ec7d01d57b13025564ed3fae92c8171ee0c1 Mon Sep 17 00:00:00 2001 From: CPunch Date: Mon, 7 Sep 2020 12:23:00 -0500 Subject: [PATCH] updated readme & small refactor --- README.md | 4 ++++ src/CNLoginServer.cpp | 5 ++++- src/Database.cpp | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3c8faa4..5dfbf94 100644 --- a/README.md +++ b/README.md @@ -115,3 +115,7 @@ To make your landwalking experience more pleasant, you can make use of a few adm * `/nano_equip [id] (1-36) [slot] (0-2)` * `/nano_unequip [slot] (0-2)` * `/nano_active [slot] (0-2)` + +## Accounts + +A basic account system has been added, when logging in if the username doesn't exist in the database, a new account with the provided password will be made and you'll be automatically logged in. Otherwise a login attempt will be made. A username must be between 4 and 32 characters, and a password must be between 8 and 32 characters otherwise the account will be rejected. Characters currently save only upon creation, any items add/traded will not be saved. \ No newline at end of file diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index 98fc77a..5caa448 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -340,13 +340,16 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) { case P_CL2LS_REQ_PC_EXIT_DUPLICATE:{ if (data->size != sizeof(sP_CL2LS_REQ_PC_EXIT_DUPLICATE)) return; + sP_CL2LS_REQ_PC_EXIT_DUPLICATE* exit = (sP_CL2LS_REQ_PC_EXIT_DUPLICATE*)data->buf; auto account = Database::findAccount(U16toU8(exit->szID)); if (account == nullptr) break; + int accountId = account->AccountID; if (!exitDuplicate(accountId)) - PlayerManager::exitDuplicate(accountId); + PlayerManager::exitDuplicate(accountId); + break; } default: diff --git a/src/Database.cpp b/src/Database.cpp index 4142e46..7a55895 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -73,7 +73,7 @@ void Database::open() int Database::addAccount(std::string login, std::string password) { password = BCrypt::generateHash(password); - Account x; + Account x = {}; x.Login = login; x.Password = password; x.Selected = 1;