Rework of 'invsnapshot' command and implementation of automatic inventory snapshots

This commit is contained in:
Uleat
2018-09-03 20:57:20 -04:00
parent 79229235bd
commit feb4cc37c6
18 changed files with 826 additions and 99 deletions
+1
View File
@@ -31,6 +31,7 @@ friends
guild_members
instance_list_player
inventory
inventory_snapshots
keyring
mail
player_titlesets
+1 -1
View File
@@ -1,5 +1,5 @@
command_settings
inventory_version
inventory_versions
launcher
rule_sets
rule_values
+2 -2
View File
@@ -379,8 +379,8 @@
9123|2018_07_07_data_buckets.sql|SHOW TABLES LIKE 'data_buckets'|empty|
9124|2018_07_09_tasks.sql|SHOW COLUMNS FROM `tasks` LIKE 'type'|empty|
9125|2018_07_20_task_emote.sql|SHOW COLUMNS FROM `tasks` LIKE 'completion_emote'|empty|
9126|2018_08_13_inventory_version_update.sql|SHOW COLUMNS FROM `inventory_version` LIKE 'bot_step'|empty|
9127|2018_08_13_inventory_update.sql|SELECT * FROM `inventory_version` WHERE `version` = 2 and `step` = 0|not_empty|
9126|2018_08_13_inventory_version_update.sql|SHOW TABLES LIKE 'inventory_versions'|empty|
9127|2018_08_13_inventory_update.sql|SELECT * FROM `inventory_versions` WHERE `version` = 2 and `step` = 0|not_empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not
@@ -18,7 +18,7 @@
9017|2017_03_26_bots_spells_id_fix_for_saved_shadowknight_bots.sql|SELECT * FROM `bot_data` WHERE `class` = '5' AND `spells_id` = '3004'|not_empty|
9018|2018_02_02_Bot_Spells_Min_Max_HP.sql|SHOW COLUMNS FROM `bot_spells_entries` LIKE 'min_hp'|empty|
9019|2018_04_12_bots_stop_melee_level.sql|SHOW COLUMNS FROM `bot_data` LIKE 'stop_melee_level'|empty|
9020|2018_08_13_bots_inventory_update.sql|SELECT * FROM `inventory_version` WHERE `version` = 2 and `bot_step` = 0|not_empty|
9020|2018_08_13_bots_inventory_update.sql|SELECT * FROM `inventory_versions` WHERE `version` = 2 and `bot_step` = 0|not_empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not
@@ -2,4 +2,4 @@
UPDATE `bot_inventories` SET `slot_id` = 22 WHERE `slot_id` = 21; -- adjust ammo slot
UPDATE `bot_inventories` SET `slot_id` = 21 WHERE `slot_id` = 9999; -- adjust powersource slot
UPDATE `inventory_version` SET `bot_step` = 1 WHERE `version` = 2;
UPDATE `inventory_versions` SET `bot_step` = 1 WHERE `version` = 2;
@@ -1,3 +1,14 @@
-- create inventory v1 backup
SELECT @pre_timestamp := UNIX_TIMESTAMP(NOW());
INSERT INTO `inventory_snapshots_v1_bak`
(`time_index`,`charid`,`slotid`,`itemid`,`charges`,`color`,`augslot1`,`augslot2`,`augslot3`,`augslot4`,
`augslot5`,`augslot6`,`instnodrop`,`custom_data`,`ornamenticon`,`ornamentidfile`,`ornament_hero_model`)
SELECT
@pre_timestamp, `charid`, `slotid`, `itemid`, `charges`, `color`, `augslot1`, `augslot2`, `augslot3`, `augslot4`,
`augslot5`,`augslot6`,`instnodrop`,`custom_data`,`ornamenticon`,`ornamentidfile`,`ornament_hero_model`
FROM `inventory`;
-- update equipable slots in `items` table
SELECT 'pre-transform count..',
(SELECT COUNT(id) FROM `items` WHERE `slots` & (3 << 21)) total,
@@ -21,15 +32,6 @@ UPDATE `inventory` SET `slotid` = 22 WHERE `slotid` = 21; -- adjust ammo slot
UPDATE `inventory` SET `slotid` = 21 WHERE `slotid` = 9999; -- adjust powersource slot
-- update `inventory_snapshots` slots
UPDATE `inventory_snapshots` SET `slotid` = 33 WHERE `slotid` = 30; -- adjust cursor
UPDATE `inventory_snapshots` SET `slotid` = (`slotid` + 20) WHERE `slotid` >= 331 AND `slotid` <= 340; -- adjust cursor bags
UPDATE `inventory_snapshots` SET `slotid` = (`slotid` + 1) WHERE `slotid` >= 22 AND `slotid` <= 29; -- adjust general slots
-- current general bags remain the same
UPDATE `inventory_snapshots` SET `slotid` = 22 WHERE `slotid` = 21; -- adjust ammo slot
UPDATE `inventory_snapshots` SET `slotid` = 21 WHERE `slotid` = 9999; -- adjust powersource slot
-- update `character_corpse_items` slots
UPDATE `character_corpse_items` SET `equip_slot` = 33 WHERE `equip_slot` = 30; -- adjust cursor
UPDATE `character_corpse_items` SET `equip_slot` = (`equip_slot` + 20) WHERE `equip_slot` >= 331 AND `equip_slot` <= 340; -- adjust cursor bags
@@ -42,4 +44,15 @@ UPDATE `character_corpse_items` SET `equip_slot` = 21 WHERE `equip_slot` = 9999;
-- update `character_pet_inventory` slots
UPDATE `character_pet_inventory` SET `slot` = 22 WHERE `slot` = 21; -- adjust ammo slot
UPDATE `inventory_version` SET `step` = 1 WHERE `version` = 2;
UPDATE `inventory_versions` SET `step` = 1 WHERE `version` = 2;
-- create initial inventory v2 snapshots
SELECT @post_timestamp := UNIX_TIMESTAMP(NOW());
INSERT INTO `inventory_snapshots`
(`time_index`,`charid`,`slotid`,`itemid`,`charges`,`color`,`augslot1`,`augslot2`,`augslot3`,`augslot4`,
`augslot5`,`augslot6`,`instnodrop`,`custom_data`,`ornamenticon`,`ornamentidfile`,`ornament_hero_model`)
SELECT
@post_timestamp, `charid`, `slotid`, `itemid`, `charges`, `color`, `augslot1`, `augslot2`, `augslot3`, `augslot4`,
`augslot5`,`augslot6`,`instnodrop`,`custom_data`,`ornamenticon`,`ornamentidfile`,`ornament_hero_model`
FROM `inventory`;
@@ -1 +1,61 @@
ALTER TABLE `inventory_version` ADD COLUMN `bot_step` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `step`;
DROP TABLE IF EXISTS `inventory_version`;
DROP TABLE IF EXISTS `inventory_snapshots`;
CREATE TABLE `inventory_versions` (
`version` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`step` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`bot_step` INT(11) UNSIGNED NOT NULL DEFAULT '0'
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM;
INSERT INTO `inventory_versions` VALUES (2, 0, 0);
CREATE TABLE `inventory_snapshots` (
`time_index` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`charid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`slotid` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`itemid` INT(11) UNSIGNED NULL DEFAULT '0',
`charges` SMALLINT(3) UNSIGNED NULL DEFAULT '0',
`color` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`augslot1` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot2` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot3` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot4` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot5` MEDIUMINT(7) UNSIGNED NULL DEFAULT '0',
`augslot6` MEDIUMINT(7) NOT NULL DEFAULT '0',
`instnodrop` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`custom_data` TEXT NULL,
`ornamenticon` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`ornamentidfile` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`ornament_hero_model` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`time_index`, `charid`, `slotid`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;
CREATE TABLE `inventory_snapshots_v1_bak` (
`time_index` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`charid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`slotid` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`itemid` INT(11) UNSIGNED NULL DEFAULT '0',
`charges` SMALLINT(3) UNSIGNED NULL DEFAULT '0',
`color` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`augslot1` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot2` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot3` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot4` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augslot5` MEDIUMINT(7) UNSIGNED NULL DEFAULT '0',
`augslot6` MEDIUMINT(7) NOT NULL DEFAULT '0',
`instnodrop` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`custom_data` TEXT NULL,
`ornamenticon` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`ornamentidfile` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`ornament_hero_model` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`time_index`, `charid`, `slotid`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;
+1
View File
@@ -52,6 +52,7 @@ guild_members
hackers
instance_list_player
inventory
inventory_snapshots
item_tick
keyring
launcher_zones