summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-12-02 22:00:37 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-12-02 22:00:37 +0000
commit649707be73a83190a818640438c4bb60569c3663 (patch)
tree97d25e645e5243dca8765d9c46fd328112aacc3a
parent73495c824375268df060e792a44a631443268b98 (diff)
downloadmanaserv-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.
-rw-r--r--ChangeLog72
-rw-r--r--src/accounthandler.cpp12
-rw-r--r--src/configuration.h2
-rw-r--r--src/main.cpp2
4 files changed, 54 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index 02421401..5313280a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,51 +1,57 @@
+2005-12-02 Yohann Ferreira <bertram@cegetel.net>
+
+ * src/main.cpp, src/accounthandler.h, src/accounthandler.cpp,
+ src/configuration.h: Made the accounthandler reopen the db for
+ SQLite to enable registering ! Now working.
+
2005-11-21 Aaron Marks <nymacro@gmail.com>
- * src/state.cpp: Re-ordered a few statements to work better.
- * src/dalstorage.cpp: Now sets being's current map when getting a
- player's account.
-
+ * src/state.cpp: Re-ordered a few statements to work better.
+ * src/dalstorage.cpp: Now sets being's current map when getting a
+ player's account.
+
2005-11-16 Aaron Marks <nymacro@gmail.com>
- * src/state.h, src/state.cpp: Updated world related functions.
- * src/accounthandler.cpp: Now adds players who have selected a
- character to the game world.
- * src/object.h: Updated to include member variable for current map
- the object is located.
+ * src/state.h, src/state.cpp: Updated world related functions.
+ * src/accounthandler.cpp: Now adds players who have selected a
+ character to the game world.
+ * src/object.h: Updated to include member variable for current map
+ the object is located.
2005-11-15 Aaron Marks <nymacro@gmail.com>
- * src/state.h, src/state.cpp: Updated world representation, added
- various methods which provide easy access to the game world.
- * src/defines.h: Added "private message" message.
- * src/client.cpp, scripts/init.rb: Added experimental remote access
- to Ruby's functionality.
+ * src/state.h, src/state.cpp: Updated world representation, added
+ various methods which provide easy access to the game world.
+ * src/defines.h: Added "private message" message.
+ * src/client.cpp, scripts/init.rb: Added experimental remote access
+ to Ruby's functionality.
2005-11-14 Aaron Marks <nymacro@gmail.com>
- * src/bindings.i: Enabled "directors", allowing scripting language
- to override virtual functions.
+ * src/bindings.i: Enabled "directors", allowing scripting language
+ to override virtual functions.
2005-11-12 Aaron Marks <nymacro@gmail.com>
- * src/main.cpp: Added scripting with Ruby support
- * src/bindings.i: Created basic SWIG bindings.
- * src/Makefile.am: Updated to support Ruby & generate SWIG
- bindings.
- * configure.ac: Updated to detect SWIG & Ruby, using them
- appropriately.
- * scripts/init.rb: Server initialization test script.
+ * src/main.cpp: Added scripting with Ruby support
+ * src/bindings.i: Created basic SWIG bindings.
+ * src/Makefile.am: Updated to support Ruby & generate SWIG
+ bindings.
+ * configure.ac: Updated to detect SWIG & Ruby, using them
+ appropriately.
+ * scripts/init.rb: Server initialization test script.
2005-11-10 Aaron Marks <nymacro@gmail.com>
- * src/client.cpp: Updated client to support moving and equipping.
- * src/being.h, src/being.cpp: Added "hasItem"
- * src/state.cpp: Added beings updating.
-
+ * src/client.cpp: Updated client to support moving and equipping.
+ * src/being.h, src/being.cpp: Added "hasItem"
+ * src/state.cpp: Added beings updating.
+
2005-10-24 Yohann Ferreira <Bertram@cegetel.net>
- * src/main.cpp: Added more useful infos at startup.
- * src/dal/dataprovider.h, src/dal/dataprovider.cpp,
- src/dal/sqlitedataprovider.cpp, src/dal/mysqldataprovider.cpp,
- src/dal/pqdataprovider.cpp, src/main.cpp, src/client.cpp:
- Grammar corrections, and a little bit of work on getting the name
- of the Db.
+ * src/main.cpp: Added more useful infos at startup.
+ * src/dal/dataprovider.h, src/dal/dataprovider.cpp,
+ src/dal/sqlitedataprovider.cpp, src/dal/mysqldataprovider.cpp,
+ src/dal/pqdataprovider.cpp, src/main.cpp, src/client.cpp:
+ Grammar corrections, and a little bit of work on getting the name
+ of the Db.
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