summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-30 21:08:21 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-30 21:08:21 +0200
commit5661e7d0ce2c3233d302d65ac4cd7b016af27cde (patch)
tree41e376373bc56fb4a88c99e0d8e370edab942c93
parent800772fc10d923b315277490e7e009fe116e8ce5 (diff)
parent6204fdfdae8139083b48a114b954a844b0df707c (diff)
downloadmanaserv-5661e7d0ce2c3233d302d65ac4cd7b016af27cde.tar.gz
manaserv-5661e7d0ce2c3233d302d65ac4cd7b016af27cde.tar.xz
manaserv-5661e7d0ce2c3233d302d65ac4cd7b016af27cde.zip
Merge branch 'equipment-fix'
-rw-r--r--example/clientdata/equip.xml39
-rw-r--r--src/account-server/main-account.cpp5
-rw-r--r--src/account-server/storage.cpp11
-rw-r--r--src/common/manaserv_protocol.h5
-rw-r--r--src/sql/mysql/createTables.sql2
-rw-r--r--src/sql/mysql/updates/update_14_to_15.sql22
-rw-r--r--src/sql/sqlite/createTables.sql2
-rw-r--r--src/sql/sqlite/updates/update_14_to_15.sql21
8 files changed, 88 insertions, 19 deletions
diff --git a/example/clientdata/equip.xml b/example/clientdata/equip.xml
index be180a0..db7aecc 100644
--- a/example/clientdata/equip.xml
+++ b/example/clientdata/equip.xml
@@ -1,19 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Notes:
The id and name parameters must be unique.
- The count parameter indicates the 'size' of the slot.
+ The capacity parameter indicates the 'size' of the slot.
The visible parameter indicates whether the item is visible
on the map character. Hence, whether the server should send appearance
updates when making changes on it.
-->
<equip-slots>
- <slot id="1" name="Hand" capacity="2" visible="true" weapon="true" />
- <slot id="2" name="Torso" capacity="1" visible="true" />
- <slot id="3" name="Arms" capacity="1" />
- <slot id="4" name="Head" capacity="1" visible="true" />
- <slot id="5" name="Legs" capacity="1" visible="true" />
- <slot id="6" name="Ring" capacity="1" />
- <slot id="7" name="Necklace" capacity="1" />
- <slot id="8" name="Feet" capacity="1" visible="true" />
- <slot id="9" name="Ammo" capacity="1" ammo="true" />
+ <slot id="1" name="Hand" capacity="2" visible="true" weapon="true">
+ <box x="8" y="123" />
+ <box x="129" y="123" />
+ </slot>
+ <slot id="2" name="Torso" capacity="1" visible="true">
+ <box x="50" y="40" />
+ </slot>
+ <slot id="3" name="Arms" capacity="1">
+ <box x="8" y="78" />
+ </slot>
+ <slot id="4" name="Head" capacity="1" visible="true">
+ <box x="70" y="0" />
+ </slot>
+ <slot id="5" name="Legs" capacity="1" visible="true">
+ <box x="50" y="208" />
+ </slot>
+ <slot id="6" name="Ring" capacity="1">
+ <box x="129" y="78" />
+ </slot>
+ <slot id="7" name="Necklace" capacity="1">
+ <box x="90" y="40" />
+ </slot>
+ <slot id="8" name="Feet" capacity="1" visible="true">
+ <box x="90" y="208" />
+ </slot>
+ <slot id="9" name="Ammo" capacity="1" ammo="true">
+ <box x="8" y="168" />
+ </slot>
</equip-slots>
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index 5520fb8..6d46ec4 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -364,8 +364,9 @@ int main(int argc, char *argv[])
LOG_INFO("The Mana Account+Chat Server (unknown version)");
#endif
LOG_INFO("Manaserv Protocol version " << ManaServ::PROTOCOL_VERSION
- << ", " << "Enet version " << ENET_VERSION_MAJOR << "."
- << ENET_VERSION_MINOR << "." << ENET_VERSION_PATCH);
+ << ", Enet version " << ENET_VERSION_MAJOR << "."
+ << ENET_VERSION_MINOR << "." << ENET_VERSION_PATCH
+ << ", Database version " << ManaServ::SUPPORTED_DB_VERSION);
if (!options.verbosityChanged)
options.verbosity = static_cast<Logger::Level>(
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 05f8ec6..4f22964 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -28,10 +28,12 @@
#include "chat-server/guild.h"
#include "chat-server/post.h"
#include "common/configuration.h"
+#include "common/manaserv_protocol.h"
#include "dal/dalexcept.h"
#include "dal/dataproviderfactory.h"
#include "utils/functors.h"
#include "utils/point.h"
+#include "utils/string.h"
#include "utils/throwerror.h"
#include "utils/xml.h"
@@ -41,7 +43,6 @@ static const char *DEFAULT_ITEM_FILE = "items.xml";
// Defines the supported db version
static const char *DB_VERSION_PARAMETER = "database_version";
-static const char *SUPPORTED_DB_VERSION = "14";
/*
* MySQL specificities:
@@ -118,12 +119,14 @@ void Storage::open()
mDb->connect();
// Check database version here
- std::string dbversion = getWorldStateVar(DB_VERSION_PARAMETER);
- if (dbversion != SUPPORTED_DB_VERSION)
+ int dbversion = utils::stringToInt(
+ getWorldStateVar(DB_VERSION_PARAMETER));
+ int supportedDbVersion = ManaServ::SUPPORTED_DB_VERSION;
+ if (dbversion != supportedDbVersion)
{
std::ostringstream errmsg;
errmsg << "Database version is not supported. "
- << "Needed version: '" << SUPPORTED_DB_VERSION
+ << "Needed version: '" << supportedDbVersion
<< "', current version: '" << dbversion << "'";
utils::throwError(errmsg.str());
}
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h
index 2a340b8..e1e1f88 100644
--- a/src/common/manaserv_protocol.h
+++ b/src/common/manaserv_protocol.h
@@ -24,7 +24,10 @@
namespace ManaServ {
-enum { PROTOCOL_VERSION = 1 };
+enum {
+ PROTOCOL_VERSION = 1,
+ SUPPORTED_DB_VERSION = 15
+};
/**
* Enumerated type for communicated messages:
diff --git a/src/sql/mysql/createTables.sql b/src/sql/mysql/createTables.sql
index d017cee..041e88d 100644
--- a/src/sql/mysql/createTables.sql
+++ b/src/sql/mysql/createTables.sql
@@ -421,7 +421,7 @@ AUTO_INCREMENT=0 ;
INSERT INTO mana_world_states VALUES('accountserver_startup',NULL,NULL, NOW());
INSERT INTO mana_world_states VALUES('accountserver_version',NULL,NULL, NOW());
-INSERT INTO mana_world_states VALUES('database_version', NULL,'14', NOW());
+INSERT INTO mana_world_states VALUES('database_version', NULL,'15', NOW());
-- all known transaction codes
diff --git a/src/sql/mysql/updates/update_14_to_15.sql b/src/sql/mysql/updates/update_14_to_15.sql
new file mode 100644
index 0000000..1036817
--- /dev/null
+++ b/src/sql/mysql/updates/update_14_to_15.sql
@@ -0,0 +1,22 @@
+
+-- Dropping the table will only unequip characters, so it's not an issue.
+DROP TABLE mana_char_equips;
+
+-- Recreate the table using the latest definition.
+CREATE TABLE IF NOT EXISTS `mana_char_equips` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `owner_id` int(10) unsigned NOT NULL,
+ `slot_type` int(10) unsigned NOT NULL,
+ `item_id` int(10) unsigned NOT NULL,
+ `item_instance` int(10) unsigned NOT NULL,
+ --
+ PRIMARY KEY (`id`),
+ FOREIGN KEY (`owner_id`) REFERENCES `mana_characters` (`id`)
+) ENGINE=InnoDB
+DEFAULT CHARSET=utf8;
+
+-- Update database version.
+UPDATE mana_world_states
+SET value = '15',
+moddate = UNIX_TIMESTAMP()
+WHERE state_name = 'database_version';
diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql
index 1027b58..2b4f7aa 100644
--- a/src/sql/sqlite/createTables.sql
+++ b/src/sql/sqlite/createTables.sql
@@ -407,7 +407,7 @@ AS
INSERT INTO mana_world_states VALUES('accountserver_startup',NULL,NULL, strftime('%s','now'));
INSERT INTO mana_world_states VALUES('accountserver_version',NULL,NULL, strftime('%s','now'));
-INSERT INTO mana_world_states VALUES('database_version', NULL,'14', strftime('%s','now'));
+INSERT INTO mana_world_states VALUES('database_version', NULL,'15', strftime('%s','now'));
-- all known transaction codes
diff --git a/src/sql/sqlite/updates/update_14_to_15.sql b/src/sql/sqlite/updates/update_14_to_15.sql
new file mode 100644
index 0000000..777764d
--- /dev/null
+++ b/src/sql/sqlite/updates/update_14_to_15.sql
@@ -0,0 +1,21 @@
+
+-- Dropping the table will only unequip characters, so it's not an issue.
+DROP TABLE mana_char_equips;
+
+-- Recreate the table using the latest definition.
+CREATE TABLE mana_char_equips
+(
+ id INTEGER PRIMARY KEY,
+ owner_id INTEGER NOT NULL,
+ slot_type INTEGER NOT NULL,
+ item_id INTEGER NOT NULL,
+ item_instance INTEGER NOT NULL,
+ --
+ FOREIGN KEY (owner_id) REFERENCES mana_characters(id)
+);
+
+-- Update the database version, and set date of update
+UPDATE mana_world_states
+ SET value = '15',
+ moddate = strftime('%s','now')
+ WHERE state_name = 'database_version';