summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Habel <mail@exceptionfault.de>2008-09-15 10:43:11 +0000
committerAndreas Habel <mail@exceptionfault.de>2008-09-15 10:43:11 +0000
commita613c53609185c436dcdca7eae3221b792ad523d (patch)
tree8a367e8663fa96c955914f3179e80a80e4523be7
parentbfc0c10184442fba0b53e0aaafcf2532610e5cd7 (diff)
downloadmanaserv-a613c53609185c436dcdca7eae3221b792ad523d.tar.gz
manaserv-a613c53609185c436dcdca7eae3221b792ad523d.tar.bz2
manaserv-a613c53609185c436dcdca7eae3221b792ad523d.tar.xz
manaserv-a613c53609185c436dcdca7eae3221b792ad523d.zip
* Added doxygen file, docu will be generated under docs/api/html
* Added table definition "tmw_world_states" to store map and world-specific variables * Extended DALStorage to set and get those new variables * Applied Kess's diff file from mantis #424 with modifications for PostgreSQL support
-rw-r--r--ChangeLog9
-rw-r--r--Doxyfile286
-rw-r--r--src/account-server/dalstorage.cpp80
-rw-r--r--src/account-server/dalstorage.hpp32
-rw-r--r--src/account-server/dalstoragesql.hpp269
-rw-r--r--src/account-server/main-account.cpp13
6 files changed, 568 insertions, 121 deletions
diff --git a/ChangeLog b/ChangeLog
index 0bc6c3ce..468fbb1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-15 Andreas Habel <mail@exceptionfault.de>
+
+ * Doxyfile: added doxygen file, docu will be generated under docs/api/html
+ * src/account-server/dalstorage.cpp, src/account-server/dalstorage.hpp,
+ src/account-server/dalstoragesql.hpp, src/account-server/main-account.cpp:
+ added table tmw_world_states to store map and world-specific variables,
+ extended DALStorage to set and get those new variables, applied Kess's diff
+ file from mantis #424 with modifications for PostgreSQL support.
+
2008-09-10 Andreas Habel <mail@exceptionfault.de>
* src/account-server/dalstorage.cpp, src/account-server/account.cpp,
diff --git a/Doxyfile b/Doxyfile
new file mode 100644
index 00000000..8004ba66
--- /dev/null
+++ b/Doxyfile
@@ -0,0 +1,286 @@
+# Doxyfile 1.5.6
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING = UTF-8
+PROJECT_NAME = "The Mana World - Server"
+PROJECT_NUMBER = 0.1.*
+OUTPUT_DIRECTORY = Z:/xampp/htdocs/TMW/tmwserv/trunk/docs/api
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = YES
+STRIP_FROM_PATH = C:/Programme/doxygen/bin/
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = NO
+QT_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = NO
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+OPTIMIZE_FOR_FORTRAN = NO
+OPTIMIZE_OUTPUT_VHDL = NO
+BUILTIN_STL_SUPPORT = NO
+CPP_CLI_SUPPORT = NO
+SIP_SUPPORT = NO
+IDL_PROPERTY_SUPPORT = YES
+DISTRIBUTE_GROUP_DOC = NO
+SUBGROUPING = YES
+TYPEDEF_HIDES_STRUCT = NO
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = NO
+EXTRACT_ANON_NSPACES = NO
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_GROUP_NAMES = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = NO
+SHOW_FILES = YES
+SHOW_NAMESPACES = YES
+FILE_VERSION_FILTER =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = Z:/xampp/htdocs/TMW/tmwserv/trunk
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.mm \
+ *.dox \
+ *.py \
+ *.f90 \
+ *.f \
+ *.vhd \
+ *.vhdl
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXCLUDE_SYMBOLS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+GENERATE_DOCSET = NO
+DOCSET_FEEDNAME = "Doxygen generated docs"
+DOCSET_BUNDLE_ID = org.doxygen.Project
+HTML_DYNAMIC_SECTIONS = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+CHM_INDEX_ENCODING =
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NONE
+TREEVIEW_WIDTH = 250
+FORMULA_FONTSIZE = 10
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = YES
+USE_PDFLATEX = YES
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+MSCGEN_PATH =
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+DOT_FONTNAME = FreeSans
+DOT_FONTPATH =
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+CALLER_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+DOT_GRAPH_MAX_NODES = 50
+MAX_DOT_GRAPH_DEPTH = 1000
+DOT_TRANSPARENT = YES
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index 26f99a12..601c0bb6 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -130,6 +130,8 @@ void DALStorage::open()
createTable(GUILDS_TBL_NAME, SQL_GUILDS_TABLE);
createTable(GUILD_MEMBERS_TBL_NAME, SQL_GUILD_MEMBERS_TABLE);
createTable(QUESTS_TBL_NAME, SQL_QUESTS_TABLE);
+ createTable(WORLD_STATES_TBL_NAME, SQL_WORLD_STATES_TABLE);
+
// TODO: this is not the prefered way, but currently the complete
// generation and maintenance of the database is a little dirty so
@@ -1122,6 +1124,84 @@ std::string DALStorage::getQuestVar(int id, std::string const &name)
return std::string();
}
+std::string DALStorage::getWorldStateVar(std::string const &name)
+{
+ return getWorldStateVar(name, -1);
+}
+
+std::string DALStorage::getWorldStateVar(std::string const &name, int map_id)
+{
+ try
+ {
+ std::ostringstream query;
+ query << "SELECT value "
+ << " FROM " << WORLD_STATES_TBL_NAME
+ << " WHERE state_name = '" << name << "'";
+
+ // add map filter if map_id is given
+ if (map_id >= 0)
+ {
+ query << " AND map_id = '" << map_id << "'";
+ }
+
+ query << ";";
+ dal::RecordSet const &info = mDb->execSql(query.str());
+
+ if (!info.isEmpty()) return info(0, 0);
+ }
+ catch (dal::DbSqlQueryExecFailure const &e)
+ {
+ LOG_ERROR("(DALStorage::getWorldStateVar) SQL query failure: " << e.what());
+ }
+
+ return std::string();
+}
+
+void DALStorage::setWorldStateVar(std::string const &name, std::string const &value)
+{
+ return setWorldStateVar(name, -1, value);
+}
+
+void DALStorage::setWorldStateVar(std::string const &name,
+ int map_id,
+ std::string const &value)
+{
+ try
+ {
+ std::ostringstream query1;
+ query1 << "DELETE FROM " << WORLD_STATES_TBL_NAME
+ << " WHERE state_name = '" << name << "'";
+ if (map_id >= 0)
+ {
+ query1 << " AND map_id = '" << map_id << "'";
+ }
+ query1 << ";";
+ mDb->execSql(query1.str());
+
+ if (value.empty()) return;
+
+ std::ostringstream query2;
+ query2 << "INSERT INTO " << WORLD_STATES_TBL_NAME
+ << " (state_name, map_id, value , moddate) VALUES ("
+ << "'" << name << "', ";
+ if (map_id >= 0)
+ {
+ query2 << "'" << map_id << "', ";
+ }
+ else
+ {
+ query2 << "NULL , ";
+ }
+ query2 << "'" << value << "', "
+ << "'" << time(NULL) << "');";
+ mDb->execSql(query2.str());
+ }
+ catch (dal::DbSqlQueryExecFailure const &e)
+ {
+ LOG_ERROR("(DALStorage::setWorldStateVar) SQL query failure: " << e.what());
+ }
+}
+
void DALStorage::setQuestVar(int id, std::string const &name,
std::string const &value)
{
diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp
index 7a8208ff..099ec14a 100644
--- a/src/account-server/dalstorage.hpp
+++ b/src/account-server/dalstorage.hpp
@@ -223,6 +223,38 @@ class DALStorage
*/
void setQuestVar(int id, std::string const &, std::string const &);
+ /**
+ * Gets the string value of a world state variable.
+ *
+ * @param name Name of the requested world-state variable.
+ */
+ std::string getWorldStateVar(std::string const &name);
+
+ /**
+ * Gets the string value of a map specific world state variable.
+ *
+ * @param name Name of the requested world-state variable.
+ * @param map_id Id of the specific map.
+ */
+ std::string getWorldStateVar(std::string const &name, int map_id);
+
+ /**
+ * Sets the value of a world state variable.
+ *
+ * @param name Name of the world-state vairable.
+ * @param value New value of the world-state variable.
+ */
+ void setWorldStateVar(std::string const &name, std::string const &value);
+
+ /**
+ * Sets the value of a world state variable of a specific map.
+ *
+ * @param name Name of the world-state vairable.
+ * @param map_id ID of the specific map
+ * @param value New value of the world-state variable.
+ */
+ void setWorldStateVar(std::string const &name, int map_id,
+ std::string const &value);
private:
/**
diff --git a/src/account-server/dalstoragesql.hpp b/src/account-server/dalstoragesql.hpp
index 311546ec..b773770f 100644
--- a/src/account-server/dalstoragesql.hpp
+++ b/src/account-server/dalstoragesql.hpp
@@ -70,33 +70,37 @@ static char const *SQL_ACCOUNTS_TABLE =
"CREATE TABLE tmw_accounts \n "
"( \n"
#if defined (MYSQL_SUPPORT)
- "id INTEGER PRIMARY KEY AUTO_INCREMENT,"
- "username VARCHAR(32) NOT NULL UNIQUE,"
- "password VARCHAR(32) NOT NULL,"
- "email VARCHAR(64) NOT NULL,"
- "level TINYINT UNSIGNED NOT NULL,"
- "banned TINYINT UNSIGNED NOT NULL,"
-// "activation VARCHAR(32),"
+ "id INTEGER PRIMARY KEY AUTO_INCREMENT,"
+ "username VARCHAR(32) NOT NULL UNIQUE,"
+ "password VARCHAR(32) NOT NULL,"
+ "email VARCHAR(64) NOT NULL,"
+ "level TINYINT UNSIGNED NOT NULL,"
+ "banned TINYINT UNSIGNED NOT NULL,"
+ "registration INTEGER NOT NULL,"
+ "lastlogin INTEGER NOT NULL,"
+// "activation VARCHAR(32),"
"INDEX (id)"
#error "Incorrect definition. Please fix the types."
#elif defined (SQLITE_SUPPORT)
- "id INTEGER PRIMARY KEY, \n"
- "username TEXT NOT NULL UNIQUE, \n"
- "password TEXT NOT NULL, \n"
- "email TEXT NOT NULL, \n"
- "level INTEGER NOT NULL, \n"
- "banned INTEGER NOT NULL, \n"
- "registration INTEGER NOT NULL, \n"
- "lastlogin INTEGER NOT NULL \n"
-// "activation TEXT"
+ "id INTEGER PRIMARY KEY, \n"
+ "username TEXT NOT NULL UNIQUE, \n"
+ "password TEXT NOT NULL, \n"
+ "email TEXT NOT NULL, \n"
+ "level INTEGER NOT NULL, \n"
+ "banned INTEGER NOT NULL, \n"
+ "registration INTEGER NOT NULL, \n"
+ "lastlogin INTEGER NOT NULL \n"
+// "activation TEXT"
#elif defined (POSTGRESQL_SUPPORT)
- "id SERIAL PRIMARY KEY,"
- "username TEXT NOT NULL UNIQUE,"
- "password TEXT NOT NULL,"
- "email TEXT NOT NULL,"
- "level INTEGER NOT NULL,"
- "banned INTEGER NOT NULL,"
-// "activation TEXT"
+ "id SERIAL PRIMARY KEY,"
+ "username TEXT NOT NULL UNIQUE,"
+ "password TEXT NOT NULL,"
+ "email TEXT NOT NULL,"
+ "level SMALLINT NOT NULL,"
+ "banned SMALLINT NOT NULL,"
+ "registration INTEGER NOT NULL,"
+ "lastlogin INTEGER NOT NULL"
+// "activation TEXT"
#endif
");";
@@ -109,9 +113,9 @@ static char const *CHARACTERS_TBL_NAME = "tmw_characters";
static char const *SQL_CHARACTERS_TABLE =
"CREATE TABLE tmw_characters ("
#if defined (MYSQL_SUPPORT)
- "id INTEGER PRIMARY KEY AUTO_INCREMENT,"
- "user_id INTEGER UNSIGNED NOT NULL,"
- "name VARCHAR(32) NOT NULL UNIQUE,"
+ "id INTEGER PRIMARY KEY AUTO_INCREMENT,"
+ "user_id INTEGER UNSIGNED NOT NULL,"
+ "name VARCHAR(32) NOT NULL UNIQUE,"
// general information about the character
"gender TINYINT UNSIGNED NOT NULL,"
"hair_style TINYINT UNSIGNED NOT NULL,"
@@ -119,39 +123,38 @@ static char const *SQL_CHARACTERS_TABLE =
"level INTEGER UNSIGNED NOT NULL,"
"char_pts INTEGER UNSIGNED NOT NULL,"
"correct_pts INTEGER UNSIGNED NOT NULL,"
- "money INTEGER UNSIGNED NOT NULL,"
+ "money INTEGER UNSIGNED NOT NULL,"
// location on the map
- "x SMALLINT UNSIGNED NOT NULL,"
- "y SMALLINT UNSIGNED NOT NULL,"
- "map_id TINYINT NOT NULL,"
+ "x SMALLINT UNSIGNED NOT NULL,"
+ "y SMALLINT UNSIGNED NOT NULL,"
+ "map_id TINYINT NOT NULL,"
// attributes
- "str SMALLINT UNSIGNED NOT NULL,"
- "agi SMALLINT UNSIGNED NOT NULL,"
- "dex SMALLINT UNSIGNED NOT NULL,"
- "vit SMALLINT UNSIGNED NOT NULL,"
+ "str SMALLINT UNSIGNED NOT NULL,"
+ "agi SMALLINT UNSIGNED NOT NULL,"
+ "dex SMALLINT UNSIGNED NOT NULL,"
+ "vit SMALLINT UNSIGNED NOT NULL,"
// note: int must be backquoted as it's a MySQL keyword
- "`int` SMALLINT UNSIGNED NOT NULL,"
- "will SMALLINT UNSIGNED NOT NULL,"
+ "`int` SMALLINT UNSIGNED NOT NULL,"
+ "will SMALLINT UNSIGNED NOT NULL,"
//skill experience
- "unarmedExp INTEGER UNSIGNED NOT NULL,"
- "knife_exp INTEGER UNSIGNED NOT NULL,"
- "sword_exp INTEGER UNSIGNED NOT NULL,"
- "polearm_exp INTEGER UNSIGNED NOT NULL,"
- "staff_exp INTEGER UNSIGNED NOT NULL,"
- "whip_exp INTEGER UNSIGNED NOT NULL,"
- "bow_exp INTEGER UNSIGNED NOT NULL,"
- "shoot_exp INTEGER UNSIGNED NOT NULL,"
- "mace_exp INTEGER UNSIGNED NOT NULL,"
- "axe_exp INTEGER UNSIGNED NOT NULL,"
- "thrown_exp INTEGER UNSIGNED NOT NULL,"
-
+ "unarmedExp INTEGER UNSIGNED NOT NULL,"
+ "knife_exp INTEGER UNSIGNED NOT NULL,"
+ "sword_exp INTEGER UNSIGNED NOT NULL,"
+ "polearm_exp INTEGER UNSIGNED NOT NULL,"
+ "staff_exp INTEGER UNSIGNED NOT NULL,"
+ "whip_exp INTEGER UNSIGNED NOT NULL,"
+ "bow_exp INTEGER UNSIGNED NOT NULL,"
+ "shoot_exp INTEGER UNSIGNED NOT NULL,"
+ "mace_exp INTEGER UNSIGNED NOT NULL,"
+ "axe_exp INTEGER UNSIGNED NOT NULL,"
+ "thrown_exp INTEGER UNSIGNED NOT NULL,"
"FOREIGN KEY (user_id) REFERENCES tmw_accounts(id),"
"FOREIGN KEY (map_id) REFERENCES tmw_maps(id),"
"INDEX (id)"
#elif defined (SQLITE_SUPPORT)
- "id INTEGER PRIMARY KEY,"
- "user_id INTEGER NOT NULL,"
- "name TEXT NOT NULL UNIQUE,"
+ "id INTEGER PRIMARY KEY,"
+ "user_id INTEGER NOT NULL,"
+ "name TEXT NOT NULL UNIQUE,"
// general information about the character
"gender INTEGER NOT NULL,"
"hair_style INTEGER NOT NULL,"
@@ -159,68 +162,67 @@ static char const *SQL_CHARACTERS_TABLE =
"level INTEGER NOT NULL,"
"char_pts INTEGER NOT NULL,"
"correct_pts INTEGER NOT NULL,"
- "money INTEGER NOT NULL,"
+ "money INTEGER NOT NULL,"
// location on the map
- "x INTEGER NOT NULL,"
- "y INTEGER NOT NULL,"
- "map_id INTEGER NOT NULL,"
+ "x INTEGER NOT NULL,"
+ "y INTEGER NOT NULL,"
+ "map_id INTEGER NOT NULL,"
// attributes
- "str INTEGER NOT NULL,"
- "agi INTEGER NOT NULL,"
- "dex INTEGER NOT NULL,"
- "vit INTEGER NOT NULL,"
- "int INTEGER NOT NULL,"
- "will INTEGER NOT NULL,"
+ "str INTEGER NOT NULL,"
+ "agi INTEGER NOT NULL,"
+ "dex INTEGER NOT NULL,"
+ "vit INTEGER NOT NULL,"
+ "int INTEGER NOT NULL,"
+ "will INTEGER NOT NULL,"
//skill experience
- "unarmed_exp INTEGER NOT NULL,"
- "knife_exp INTEGER NOT NULL,"
- "sword_exp INTEGER NOT NULL,"
- "polearm_exp INTEGER NOT NULL,"
- "staff_exp INTEGER NOT NULL,"
- "whip_exp INTEGER NOT NULL,"
- "bow_exp INTEGER NOT NULL,"
- "shoot_exp INTEGER NOT NULL,"
- "mace_exp INTEGER NOT NULL,"
- "axe_exp INTEGER NOT NULL,"
- "thrown_exp INTEGER NOT NULL,"
+ "unarmed_exp INTEGER NOT NULL,"
+ "knife_exp INTEGER NOT NULL,"
+ "sword_exp INTEGER NOT NULL,"
+ "polearm_exp INTEGER NOT NULL,"
+ "staff_exp INTEGER NOT NULL,"
+ "whip_exp INTEGER NOT NULL,"
+ "bow_exp INTEGER NOT NULL,"
+ "shoot_exp INTEGER NOT NULL,"
+ "mace_exp INTEGER NOT NULL,"
+ "axe_exp INTEGER NOT NULL,"
+ "thrown_exp INTEGER NOT NULL,"
"FOREIGN KEY (user_id) REFERENCES tmw_accounts(id),"
"FOREIGN KEY (map_id) REFERENCES tmw_maps(id)"
#elif defined (POSTGRESQL_SUPPORT)
- "id SERIAL PRIMARY KEY,"
- "user_id INTEGER NOT NULL,"
- "name TEXT NOT NULL UNIQUE,"
+ "id SERIAL PRIMARY KEY,"
+ "user_id INTEGER NOT NULL,"
+ "name TEXT NOT NULL UNIQUE,"
// general information about the character
- "gender INTEGER NOT NULL,"
- "hair_style INTEGER NOT NULL,"
+ "gender SMALLINT NOT NULL,"
+ "hair_style SMALLINT NOT NULL,"
"hair_color INTEGER NOT NULL,"
- "level INTEGER NOT NULL,"
-
- "char_pts INTEGER NOT NULL,"
- "correct_pts INTEGER NOT NULL,"
- "money INTEGER NOT NULL,"
+ "level INTEGER NOT NULL,"
+ "char_pts INTEGER NOT NULL,"
+ "correct_pts INTEGER NOT NULL,"
+ "money INTEGER NOT NULL,"
// location on the map
- "x INTEGER NOT NULL,"
- "y INTEGER NOT NULL,"
- "map_id INTEGER NOT NULL,"
+ "x SMALLINT NOT NULL,"
+ "y SMALLINT NOT NULL,"
+ "map_id SMALLINT NOT NULL,"
// attributes
- "str INTEGER NOT NULL,"
- "agi INTEGER NOT NULL,"
- "dex INTEGER NOT NULL,"
- "vit INTEGER NOT NULL,"
- "int INTEGER NOT NULL,"
- "will INTEGER NOT NULL,"
+ "str SMALLINT NOT NULL,"
+ "agi SMALLINT NOT NULL,"
+ "dex SMALLINT NOT NULL,"
+ "vit SMALLINT NOT NULL,"
+ "int SMALLINT NOT NULL,"
+ "will SMALLINT NOT NULL,"
//skill experience
- "unarmed_exp INTEGER NOT NULL,"
- "knife_exp INTEGER NOT NULL,"
- "sword_exp INTEGER NOT NULL,"
- "polearm_exp INTEGER NOT NULL,"
- "staff_exp INTEGER NOT NULL,"
- "whip_exp INTEGER NOT NULL,"
- "bow_exp INTEGER NOT NULL,"
- "shoot_exp INTEGER NOT NULL,"
- "mace_exp INTEGER NOT NULL,"
- "axe_exp INTEGER NOT NULL,"
- "thrown_exp INTEGER NOT NULL,"
+ "unarmed_exp INTEGER NOT NULL,"
+ "knife_exp INTEGER NOT NULL,"
+ "sword_exp INTEGER NOT NULL,"
+ "polearm_exp INTEGER NOT NULL,"
+ "staff_exp INTEGER NOT NULL,"
+ "whip_exp INTEGER NOT NULL,"
+ "bow_exp INTEGER NOT NULL,"
+ "shoot_exp INTEGER NOT NULL,"
+ "mace_exp INTEGER NOT NULL,"
+ "axe_exp INTEGER NOT NULL,"
+ "thrown_exp INTEGER NOT NULL,"
"FOREIGN KEY (user_id) REFERENCES tmw_accounts(id),"
"FOREIGN KEY (map_id) REFERENCES tmw_maps(id)"
#endif
@@ -249,11 +251,11 @@ static char const *SQL_INVENTORIES_TABLE =
"amount INTEGER NOT NULL,"
"FOREIGN KEY (owner_id) REFERENCES tmw_characters(id)"
#elif defined (POSTGRESQL_SUPPORT)
- "id SERIAL PRIMARY KEY,"
+ "id SERIAL PRIMARY KEY,"
"owner_id INTEGER NOT NULL,"
- "slot INTEGER NOT NULL,"
+ "slot SMALLINT NOT NULL,"
"class_id INTEGER NOT NULL,"
- "amount INTEGER NOT NULL,"
+ "amount SMALLINT NOT NULL,"
"FOREIGN KEY (owner_id) REFERENCES tmw_characters(id)"
#endif
");";
@@ -266,14 +268,14 @@ static char const *GUILDS_TBL_NAME = "tmw_guilds";
static char const *SQL_GUILDS_TABLE =
"CREATE TABLE tmw_guilds ("
#if defined (MYSQL_SUPPORT)
- "id INTEGER PRIMARY KEY AUTO_INCREMENT,"
- "name VARCHAR(32) NOT NULL UNIQUE"
+ "id INTEGER PRIMARY KEY AUTO_INCREMENT,"
+ "name VARCHAR(32) NOT NULL UNIQUE"
#elif defined (SQLITE_SUPPORT)
- "id INTEGER PRIMARY KEY,"
- "name TEXT NOT NULL UNIQUE"
+ "id INTEGER PRIMARY KEY,"
+ "name TEXT NOT NULL UNIQUE"
#elif defined (POSTGRESQL_SUPPORT)
- "id SERIAL PRIMARY KEY,"
- "name TEXT NOT NULL UNIQUE"
+ "id SERIAL PRIMARY KEY,"
+ "name TEXT NOT NULL UNIQUE"
#endif
");";
@@ -285,21 +287,21 @@ static char const *GUILD_MEMBERS_TBL_NAME = "tmw_guild_members";
static char const *SQL_GUILD_MEMBERS_TABLE =
"CREATE TABLE tmw_guild_members ("
#if defined (MYSQL_SUPPORT)
- "guild_id INTEGER NOT NULL,"
- "member_id INTEGER NOT NULL,"
- "rights INTEGER NOT NULL,"
+ "guild_id INTEGER NOT NULL,"
+ "member_id INTEGER NOT NULL,"
+ "rights INTEGER NOT NULL,"
"FOREIGN KEY (guild_id) REFERENCES tmw_guilds(id),"
"FOREIGN KEY (member_id) REFERENCES tmw_characters(id)"
#elif defined (SQLITE_SUPPORT)
- "guild_id INTEGER NOT NULL,"
- "member_id INTEGER NOT NULL,"
- "rights INTEGER NOT NULL,"
+ "guild_id INTEGER NOT NULL,"
+ "member_id INTEGER NOT NULL,"
+ "rights INTEGER NOT NULL,"
"FOREIGN KEY (guild_id) REFERENCES tmw_guilds(id),"
"FOREIGN KEY (member_id) REFERENCES tmw_characters(id)"
#elif defined (POSTGRESQL_SUPPORT)
- "guild_id INTEGER NOT NULL,"
- "member_id INTEGER NOT NULL,"
- "rights INTEGER NOT NULL,"
+ "guild_id INTEGER NOT NULL,"
+ "member_id INTEGER NOT NULL,"
+ "rights INTEGER NOT NULL,"
"FOREIGN KEY (guild_id) REFERENCES tmw_guilds(id),"
"FOREIGN KEY (member_id) REFERENCES tmw_characters(id)"
#endif
@@ -319,7 +321,32 @@ static char const *SQL_QUESTS_TABLE =
"value TEXT NOT NULL,"
"FOREIGN KEY (owner_id) REFERENCES tmw_characters(id)"
#elif defined (POSTGRESQL_SUPPORT)
-#error "Missing definition. Please fill the blanks."
+ "owner_id INTEGER NOT NULL,"
+ "name TEXT NOT NULL,"
+ "value TEXT NOT NULL,"
+ "FOREIGN KEY (owner_id) REFERENCES tmw_characters(id)"
+#endif
+ ");";
+
+/**
+ * TABLE: tmw_world_states
+ */
+static char const *WORLD_STATES_TBL_NAME = "tmw_world_states";
+static char const *SQL_WORLD_STATES_TABLE =
+ "CREATE TABLE tmw_world_states \n"
+ "( \n"
+#if defined (MYSQL_SUPPORT)
+ "state_name VARCHAR(100) NOT NULL, \n"
+ "map_id SMALLINT UNSIGNED NULL, \n"
+ "value VARCHAR(255) NULL, \n"
+ "moddate INT UNSIGNED NOT NULL, \n"
+ "PRIMARY KEY(state_name) \n"
+#elif defined (SQLITE_SUPPORT)
+ "state_name TEXT PRIMARY KEY, \n"
+ "map_id INTEGER NULL, \n"
+ "value TEXT NULL, \n"
+ "moddate INTEGER NOT NULL \n"
+#elif defined (POSTGRESQL_SUPPORT)
#endif
");";
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index 5bd8a080..c4c451ee 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -143,6 +143,7 @@ static void initialize()
storage = new DALStorage;
storage->open();
+
// --- Initialize the managers
// Initialize the slang's and double quotes filter.
stringFilter = new StringFilter;
@@ -311,6 +312,18 @@ int main(int argc, char *argv[])
// Check for expired bans every 30 seconds
utils::Timer banTimer(30000);
+ // -------------------------------------------------------------------------
+ // FIXME: for testing purposes only...
+ // writing accountserver startup time and svn revision to database as global
+ // world state variable
+ const time_t startup = time(NULL);
+ std::stringstream timestamp;
+ timestamp << startup;
+ storage->setWorldStateVar("accountserver_startup", timestamp.str());
+ const std::string revision = "$Revision$";
+ storage->setWorldStateVar("accountserver_version", revision);
+ // -------------------------------------------------------------------------
+
while (running) {
AccountClientHandler::process();
GameServerHandler::process();