/
2018_08_13_inventory_update.sql
72 lines (59 loc) · 4.31 KB
/
2018_08_13_inventory_update.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- 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,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 21)) bit21,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 22)) bit22;
UPDATE `items` SET `slots` = (`slots` ^ (3 << 21)) WHERE (`slots` & (3 << 21)) IN ((1 << 21), (1 << 22)); -- transform
SELECT 'post-transform count..',
(SELECT COUNT(id) FROM `items` WHERE `slots` & (3 << 21)) total,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 21)) bit21,
(SELECT COUNT(id) FROM `items` WHERE `slots` & (1 << 22)) bit22;
-- update `inventory` slots
UPDATE `inventory` SET `slotid` = 33 WHERE `slotid` = 30; -- adjust cursor
UPDATE `inventory` SET `slotid` = (`slotid` + 20) WHERE `slotid` >= 331 AND `slotid` <= 340; -- adjust cursor bags
UPDATE `inventory` SET `slotid` = 30 WHERE `slotid` = 29; -- adjust general8 slot
UPDATE `inventory` SET `slotid` = 29 WHERE `slotid` = 28; -- adjust general7 slot
UPDATE `inventory` SET `slotid` = 28 WHERE `slotid` = 27; -- adjust general6 slot
UPDATE `inventory` SET `slotid` = 27 WHERE `slotid` = 26; -- adjust general5 slot
UPDATE `inventory` SET `slotid` = 26 WHERE `slotid` = 25; -- adjust general4 slot
UPDATE `inventory` SET `slotid` = 25 WHERE `slotid` = 24; -- adjust general3 slot
UPDATE `inventory` SET `slotid` = 24 WHERE `slotid` = 23; -- adjust general2 slot
UPDATE `inventory` SET `slotid` = 23 WHERE `slotid` = 22; -- adjust general1 slot
-- current general bags remain the same
UPDATE `inventory` SET `slotid` = 22 WHERE `slotid` = 21; -- adjust ammo slot
UPDATE `inventory` 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
UPDATE `character_corpse_items` SET `equip_slot` = 30 WHERE `equip_slot` = 29; -- adjust general8 slot
UPDATE `character_corpse_items` SET `equip_slot` = 29 WHERE `equip_slot` = 28; -- adjust general7 slot
UPDATE `character_corpse_items` SET `equip_slot` = 28 WHERE `equip_slot` = 27; -- adjust general6 slot
UPDATE `character_corpse_items` SET `equip_slot` = 27 WHERE `equip_slot` = 26; -- adjust general5 slot
UPDATE `character_corpse_items` SET `equip_slot` = 26 WHERE `equip_slot` = 25; -- adjust general4 slot
UPDATE `character_corpse_items` SET `equip_slot` = 25 WHERE `equip_slot` = 24; -- adjust general3 slot
UPDATE `character_corpse_items` SET `equip_slot` = 24 WHERE `equip_slot` = 23; -- adjust general2 slot
UPDATE `character_corpse_items` SET `equip_slot` = 23 WHERE `equip_slot` = 22; -- adjust general1 slot
-- current general bags remain the same
UPDATE `character_corpse_items` SET `equip_slot` = 22 WHERE `equip_slot` = 21; -- adjust ammo slot
UPDATE `character_corpse_items` SET `equip_slot` = 21 WHERE `equip_slot` = 9999; -- adjust powersource slot
-- update `character_pet_inventory` slots
UPDATE `character_pet_inventory` SET `slot` = 22 WHERE `slot` = 21; -- adjust ammo slot
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`;