aboutsummaryrefslogtreecommitdiff
path: root/sql/updates
diff options
context:
space:
mode:
authorleak <leakzx@googlemail.com>2011-04-28 22:50:06 +0200
committerleak <leakzx@googlemail.com>2011-04-28 22:50:06 +0200
commit3ab83417f5d6e18cf055195aa35beefdc4f98b9b (patch)
treebfbdb1f744f4938f9d3222088c5389bcb250e221 /sql/updates
parentc8413a7f27cdb0de2f93d2437decdbc1628cb69e (diff)
Core/ObjectMgr: Refactor sCreatureInfoAddonStorage
Diffstat (limited to 'sql/updates')
-rw-r--r--sql/updates/world/2011_04_28_03_world_creature_template_addon.sql51
1 files changed, 51 insertions, 0 deletions
diff --git a/sql/updates/world/2011_04_28_03_world_creature_template_addon.sql b/sql/updates/world/2011_04_28_03_world_creature_template_addon.sql
new file mode 100644
index 00000000000..ee5cb61ccdc
--- /dev/null
+++ b/sql/updates/world/2011_04_28_03_world_creature_template_addon.sql
@@ -0,0 +1,51 @@
+CREATE TABLE `temp_auras` (
+ `spell` MEDIUMINT(8) UNSIGNED NOT NULL
+) ENGINE=MYISAM DEFAULT CHARSET=utf8;
+
+DELIMITER %%
+
+CREATE FUNCTION `ConvertAuras`(`auras` VARCHAR(1024))
+RETURNS VARCHAR(1024) CHARSET utf8
+DETERMINISTIC
+BEGIN
+ DECLARE tmp VARCHAR(1024);
+ DECLARE curr VARCHAR(10);
+ DECLARE k INT;
+ DECLARE pos INT;
+ DECLARE startp INT;
+
+ SET @k = 0;
+ SET @tmp = '';
+ SET @startp = 1;
+ SET @pos = LOCATE(' ', auras);
+
+ DELETE FROM temp_auras;
+
+ WHILE @pos > 0 DO
+ IF @k = 0 THEN
+ SET @curr = SUBSTR(auras, @startp, @pos - @startp);
+
+ IF NOT EXISTS(SELECT spell FROM temp_auras WHERE spell = @curr) THEN
+ SET @tmp = CONCAT(@tmp, @curr, ' ');
+ INSERT INTO temp_auras VALUES(@curr);
+ END IF;
+ END IF;
+
+ SET @k = 1-@k;
+ SET @startp = @pos+1;
+ SET @pos = LOCATE(' ', auras, @startp);
+ END WHILE;
+
+ SET @tmp = RTRIM(@tmp);
+ RETURN @tmp;
+END%%
+
+DELIMITER ;
+
+UPDATE `creature_template_addon` SET `auras` = REPLACE(`auras`, ' ', ' ');
+UPDATE `creature_template_addon` SET `auras` = TRIM(`auras`);
+UPDATE `creature_template_addon` SET `auras` = NULL WHERE `auras` = '';
+UPDATE `creature_template_addon` SET `auras` = ConvertAuras(`auras`) WHERE `auras` IS NOT NULL;
+
+DROP FUNCTION `ConvertAuras`;
+DROP TABLE `temp_auras`; \ No newline at end of file