From 63c80c42c18ec3ab899fdfaf2d0975c75f1d9fd7 Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Tue, 28 Jun 2005 00:38:48 +0000 Subject: Updated PostgreSQL defines in source to work with updated configure. Added XML configuration loader from tmw. --- src/main.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index d83b87e9..4b6ec0d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,15 +28,19 @@ #include #include +#include + #include "netsession.h" #include "connectionhandler.h" #include "accounthandler.h" #include "storage.h" +#include "configuration.h" #include "skill.h" #include "utils/logger.h" + // Scripting #ifdef SCRIPT_SUPPORT @@ -68,6 +72,7 @@ bool running = true; /**< Determines if server keeps running */ Skill skillTree("base"); /**< Skill tree */ +Configuration config; /**< XML config reader */ /** * SDL timer callback, sends a TMW_WORLD_TICK event. @@ -123,6 +128,17 @@ void initialize() script = new ScriptSquirrel("main.nut"); } #endif + + // initialize configuration + // initialize configuration defaults + config.setValue("dbuser", ""); + config.setValue("dbpass", ""); + config.setValue("dbhost", ""); + + char *home = getenv("HOME"); + std::string configPath = home; + configPath += "/.tmwserv.xml"; + config.init(configPath); } @@ -131,6 +147,9 @@ void initialize() */ void deinitialize() { + // Write configuration file + config.write(); + // Stop world timer SDL_RemoveTimer(worldTimerID); @@ -183,7 +202,13 @@ int main(int argc, char *argv[]) using namespace tmwserv; - //Storage& store = Storage::instance("tmw"); + // create storage wrapper + Storage& store = Storage::instance("tmw"); + store.setUser(config.getValue("dbuser", "")); + store.setPassword(config.getValue("dbpass", "")); + store.close(); + store.open(); + // SDL_Event event; -- cgit v1.2.3-70-g09d2