diff options
-rw-r--r-- | src/account-server/dalstorage.cpp | 31 | ||||
-rw-r--r-- | src/game-server/itemmanager.cpp | 10 | ||||
-rw-r--r-- | src/sql/mysql/createTables.sql | 4 | ||||
-rw-r--r-- | src/sql/sqlite/createTables.sql | 5 | ||||
-rw-r--r-- | src/sql/sqlite/tmw.db | bin | 51200 -> 51200 bytes |
5 files changed, 26 insertions, 24 deletions
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp index b0a02c4e..940f0ff7 100644 --- a/src/account-server/dalstorage.cpp +++ b/src/account-server/dalstorage.cpp @@ -17,7 +17,7 @@ * with The Mana World; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id$ + * $Id: dalstorage.cpp 4924 2008-11-05 16:36:36Z Exceptionfault $ */ #include <cassert> @@ -41,6 +41,11 @@ // TODO: make data/items.xml a constant or read it from config file #define DEFAULT_ITEM_FILE "data/items.xml" +// defines the supported db version +#define DB_VERSION_PARAMETER "database_version" +#define SUPPORTED_DB_VERSION "1" + + /** * Constructor. @@ -87,7 +92,17 @@ void DALStorage::open() // open a connection to the database. mDb->connect(); - //TODO: check database version here + //check database version here + std::string dbversion = getWorldStateVar(DB_VERSION_PARAMETER); + if (dbversion != SUPPORTED_DB_VERSION) + { + std::ostringstream errmsg; + errmsg << "Database version is not supported. " << + "Needed version: " << SUPPORTED_DB_VERSION << ", current version: " << + dbversion; + LOG_ERROR(errmsg.str()); + throw errmsg.str(); + } // synchronize base data from xml files SyncDatabase(); @@ -1484,17 +1499,7 @@ void DALStorage::SyncDatabase(void) if (xmlStrEqual(node->name, BAD_CAST "version")) { std::string revision = XML::getProperty(node, "revision", std::string()); - size_t found = revision.find("$Revision: "); - - if (found == std::string::npos) - { - LOG_ERROR("Itemdatabase has wrong version format string!"); - xmlFreeDoc(doc); - continue; - } - - // position 11 is the first numeric character in the SVN tag - mItemDbVersion = atoi(revision.substr(11).c_str()); + mItemDbVersion = atoi(revision.c_str()); LOG_INFO("Loading item database version " << mItemDbVersion); } diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp index a86a01ed..3fbd13e0 100644 --- a/src/game-server/itemmanager.cpp +++ b/src/game-server/itemmanager.cpp @@ -87,15 +87,7 @@ void ItemManager::reload() if (xmlStrEqual(node->name, BAD_CAST "version")) { std::string revision = XML::getProperty(node, "revision", std::string()); - size_t found = revision.find("$Revision: "); - - if (found==std::string::npos) - { - LOG_ERROR("Itemdatabase has wrong version format string!"); - continue; - } - // position 11 is the first numeric character in the SVN tag - itemDatabaseVersion = atoi(revision.substr(11).c_str()); + itemDatabaseVersion = atoi(revision.c_str()); LOG_INFO("Loading item database version " << itemDatabaseVersion); continue; diff --git a/src/sql/mysql/createTables.sql b/src/sql/mysql/createTables.sql index ba0cb251..79510792 100644 --- a/src/sql/mysql/createTables.sql +++ b/src/sql/mysql/createTables.sql @@ -156,6 +156,10 @@ CREATE TABLE IF NOT EXISTS `tmw_world_states` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +INSERT INTO tmw_world_states VALUES('accountserver_startup',NULL,NULL,1226042339); +INSERT INTO tmw_world_states VALUES('accountserver_version',NULL,NULL,1226042339); +INSERT INTO tmw_world_states VALUES('database_version', NULL,'1', 1226042339); + -- -- table: `tmw_guilds` -- diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql index 253750a8..d22ba99b 100644 --- a/src/sql/sqlite/createTables.sql +++ b/src/sql/sqlite/createTables.sql @@ -140,8 +140,9 @@ CREATE TABLE tmw_world_states moddate INTEGER NOT NULL ); -INSERT INTO "tmw_world_states" VALUES('accountserver_startup',NULL,NULL,1221633910); -INSERT INTO "tmw_world_states" VALUES('accountserver_version',NULL,NULL,1221633910); +INSERT INTO tmw_world_states VALUES('accountserver_startup',NULL,NULL,1226042339); +INSERT INTO tmw_world_states VALUES('accountserver_version',NULL,NULL,1226042339); +INSERT INTO tmw_world_states VALUES('database_version', NULL,'1', 1226042339); CREATE TABLE tmw_auctions ( diff --git a/src/sql/sqlite/tmw.db b/src/sql/sqlite/tmw.db Binary files differindex 93ae76d5..6e2da247 100644 --- a/src/sql/sqlite/tmw.db +++ b/src/sql/sqlite/tmw.db |