summaryrefslogtreecommitdiff
path: root/src/sql/sqlite/updates/update_24_to_25.sql
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-03-10 10:27:51 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-09-08 10:19:40 +0200
commitf712d68495dd8e040c32da3b1c85bcb7845543ec (patch)
treef1a314bc1ef895c31851428b4ceff8b63d209f66 /src/sql/sqlite/updates/update_24_to_25.sql
parent8ddda85d923a528c7497a628d2fe10fc40b80a1f (diff)
downloadmanaserv-f712d68495dd8e040c32da3b1c85bcb7845543ec.tar.gz
manaserv-f712d68495dd8e040c32da3b1c85bcb7845543ec.tar.bz2
manaserv-f712d68495dd8e040c32da3b1c85bcb7845543ec.tar.xz
manaserv-f712d68495dd8e040c32da3b1c85bcb7845543ec.zip
Cleaned up the inventory handling
Things done: - Removed the equips table and added another column which keeps track about whether the item is equipped or not - Added a message to notify the client about failing equips instead of hardcoding to chat notification - Removed the move possibillity. It was a quite long function and our future idea of the inventory does not need any moves - Removed the inInventory and inEquipment parameters from chr_inv_count, but added a equipped key to the table that chr_get_inventory returns This change makes equipped items still being in the inventory. This means in-inventory triggers are still active! However it makes no sense to disable this triggers during equipping since it will appear as still in the inventory to the client.
Diffstat (limited to 'src/sql/sqlite/updates/update_24_to_25.sql')
-rw-r--r--src/sql/sqlite/updates/update_24_to_25.sql47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/sql/sqlite/updates/update_24_to_25.sql b/src/sql/sqlite/updates/update_24_to_25.sql
new file mode 100644
index 00000000..955d9c59
--- /dev/null
+++ b/src/sql/sqlite/updates/update_24_to_25.sql
@@ -0,0 +1,47 @@
+BEGIN;
+
+CREATE TABLE mana_inventories_backup
+(
+ id INTEGER PRIMARY KEY,
+ owner_id INTEGER NOT NULL,
+ slot INTEGER NOT NULL,
+ class_id INTEGER NOT NULL,
+ amount INTEGER NOT NULL,
+ equipped INTEGER NOT NULL,
+ --
+ FOREIGN KEY (owner_id) REFERENCES mana_characters(id)
+);
+
+INSERT INTO mana_inventories_backup SELECT
+ id, owner_id, slot, class_id, amount, 0 FROM mana_inventories;
+
+DROP TABLE mana_inventories;
+
+CREATE TABLE mana_inventories
+(
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ owner_id INTEGER NOT NULL,
+ slot INTEGER NOT NULL,
+ class_id INTEGER NOT NULL,
+ amount INTEGER NOT NULL,
+ equipped INTEGER NOT NULL,
+ --
+ FOREIGN KEY (owner_id) REFERENCES mana_characters(id)
+);
+
+INSERT INTO mana_inventories SELECT * FROM mana_inventories_backup;
+DROP TABLE mana_inventories_backup;
+
+
+INSERT INTO mana_inventories (owner_id, slot, class_id, amount, equipped)
+SELECT owner_id, (SELECT CASE WHEN COUNT(slot) = 0 THEN 1 ELSE MAX(slot) + 1 END as slot FROM mana_inventories
+ WHERE owner_id=owner_id),
+ item_id, 1, 1 FROM mana_char_equips;
+
+-- Update the database version, and set date of update
+UPDATE mana_world_states
+ SET value = '25',
+ moddate = strftime('%s','now')
+ WHERE state_name = 'database_version';
+
+END;