diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-12-02 22:00:37 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-12-02 22:00:37 +0000 |
commit | 649707be73a83190a818640438c4bb60569c3663 (patch) | |
tree | 97d25e645e5243dca8765d9c46fd328112aacc3a /src | |
parent | 73495c824375268df060e792a44a631443268b98 (diff) | |
download | manaserv-649707be73a83190a818640438c4bb60569c3663.tar.gz manaserv-649707be73a83190a818640438c4bb60569c3663.tar.bz2 manaserv-649707be73a83190a818640438c4bb60569c3663.tar.xz manaserv-649707be73a83190a818640438c4bb60569c3663.zip |
Enabled registering under SQLite by reopening th db in the accounthandler. Should work the same way with the other handlers when inserting removing, altering in the database.
Diffstat (limited to 'src')
-rw-r--r-- | src/accounthandler.cpp | 12 | ||||
-rw-r--r-- | src/configuration.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/accounthandler.cpp b/src/accounthandler.cpp index 30e726d5..df4c1f9f 100644 --- a/src/accounthandler.cpp +++ b/src/accounthandler.cpp @@ -27,6 +27,7 @@ #include "account.h" #include "messageout.h" #include "state.h" +#include "configuration.h" #include <iostream> using tmwserv::Account; @@ -40,8 +41,18 @@ using tmwserv::Storage; */ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message) { + Storage &store = Storage::instance("tmw"); +#if defined (SQLITE_SUPPORT) + // Reopen the db in this thread for sqlite, to avoid + // Library Call out of sequence problem due to thread safe. + store.setUser(config.getValue("dbuser", "")); + store.setPassword(config.getValue("dbpass", "")); + store.close(); + store.open(); +#endif + MessageOut result; switch (message.getId()) @@ -59,6 +70,7 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message) // see if the account exists Account *acc = store.getAccount(username); + if (!acc) { // account doesn't exist -- send error to client std::cout << "Account does not exist " << username << std::endl; diff --git a/src/configuration.h b/src/configuration.h index 75699f30..4c26f714 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -116,4 +116,6 @@ class Configuration std::string configPath; /**< Location of config file */ }; +extern Configuration config; + #endif diff --git a/src/main.cpp b/src/main.cpp index 1909d057..f197b14c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -168,7 +168,7 @@ void initialize() config.setValue("dbhost", ""); #ifdef WIN32 - std::string configPath = ""; + std::string configPath = "."; #else std::string configPath = getenv("HOME"); #endif |