Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .auragroup command db update (#102)
Required db update for last core modif (add .auragroup command)
- Loading branch information
Showing
1 changed file
with
135 additions
and
0 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
World/Updates/Rel21/Rel21_22_001_New_Command_auragroup.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
-- ---------------------------------------------------------------- | ||
-- This is an attempt to create a full transactional MaNGOS update | ||
-- Now compatible with newer MySql Databases (v1.5) | ||
-- ---------------------------------------------------------------- | ||
DROP PROCEDURE IF EXISTS `update_mangos`; | ||
|
||
DELIMITER $$ | ||
|
||
CREATE DEFINER=`root`@`localhost` PROCEDURE `update_mangos`() | ||
BEGIN | ||
DECLARE bRollback BOOL DEFAULT FALSE ; | ||
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `bRollback` = TRUE; | ||
|
||
-- Current Values (TODO - must be a better way to do this) | ||
SET @cCurVersion := (SELECT `version` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurStructure := (SELECT `structure` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurContent := (SELECT `content` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
|
||
-- Expected Values | ||
SET @cOldVersion = '21'; | ||
SET @cOldStructure = '21'; | ||
SET @cOldContent = '014'; | ||
|
||
-- New Values | ||
SET @cNewVersion = '21'; | ||
SET @cNewStructure = '22'; | ||
SET @cNewContent = '001'; | ||
-- DESCRIPTION IS 30 Characters MAX | ||
SET @cNewDescription = 'New_Command_auragroup'; | ||
|
||
-- COMMENT is 150 Characters MAX | ||
SET @cNewComment = 'Add command .auragroup and .unauragroup'; | ||
|
||
-- Evaluate all settings | ||
SET @cCurResult := (SELECT `description` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cOldResult := (SELECT `description` FROM `db_version` WHERE `version`=@cOldVersion AND `structure`=@cOldStructure AND `content`=@cOldContent); | ||
SET @cNewResult := (SELECT `description` FROM `db_version` WHERE `version`=@cNewVersion AND `structure`=@cNewStructure AND `content`=@cNewContent); | ||
|
||
IF (@cCurResult = @cOldResult) THEN -- Does the current version match the expected version | ||
-- APPLY UPDATE | ||
START TRANSACTION; | ||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ||
-- -- PLACE UPDATE SQL BELOW -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ||
|
||
/* | ||
Add the .auragroup and .unauragroup command to teh command table | ||
*/ | ||
REPLACE INTO `command` (`id`,`command_text`,`security`,`help_text`) | ||
VALUES | ||
(806, 'auragroup', 3, 'Syntax: .auragroup #spellId - Adds the aura to all players in the selected target player group. Adds the aura to player alone if he is not in a group.' ) , | ||
(807, 'unauragroup', 3, 'Syntax: .unauragroup #spellId | all - Removes the auras from spellId or all auras of all spells depending on the provided parameter to all players in the selected target player group. ' ) | ||
; | ||
|
||
|
||
/* | ||
Add the localization in locale table if not present | ||
Add also the french trad since Elmsroth is French... Hahah | ||
*/ | ||
REPLACE INTO `locales_command` (`id`, `help_text_loc2`) | ||
VALUES | ||
(806, 'Syntaxe : .auragroup #spellId - Ajoute l''aura à tous les joueurs du groupe dont le joueur ciblé fait partie.'), | ||
(807, 'Syntaxe : .unauragroup #spellId | all - Enlève les auras du spell (ou toutes les auras de tous les spells) à tous les joueurs du groupe dont le joueur ciblé fait partie.') | ||
; | ||
|
||
/* | ||
Needed comamnd strings for .auragroup and .unauragroup | ||
*/ | ||
|
||
REPLACE INTO `mangos_string` (`entry`, `content_default`,`content_loc0`, `content_loc2`, `source_file`,`source_enum_wrapper`,`source_enum_tag`) | ||
VALUES | ||
(1701, '%s is Dead - cannot apply aura.', '%s is Dead - cannot apply aura.', '%s est mort - l''aura ne peut pas être appliquée.', 'Language.h', 'MangosStrings', 'LANG_COMMAND_AURAGROUP_CANNOT_APPLY_AURA_PLAYER_IS_DEAD') | ||
, (1702, 'Aura from spell %u has been applied to %s.', 'Aura from spell %u has been applied to %s.', 'L''aura du spell %u a été appliquée à %s.', 'Language.h', 'MangosStrings', 'LANG_COMMAND_AURAGROUP_AURA_APPLIED') | ||
, (1703, 'Cannot remove aura(s) from %s because the player is dead.', 'Cannot remove aura(s) from %s because the player is dead.', 'Impossible de de retirer le/les aura(s) du joueur %s car il est mort.', 'Language.h', 'MangosStrings', 'LANG_COMMAND_AURAGROUP_CANNOT_UNAURA_DEAD_PLAYER') | ||
, (1704, 'All auras have been removed from %s.', 'All auras have been removed from %s.', 'Toutes les auras ont été retirées de %s.', 'Language.h', 'MangosStrings', 'LANG_COMMAND_AURAGROUP_ALL_AURA_REMOVED') | ||
, (1705, 'Aura from spell %u has been removedfrom %s', 'Aura from spell %u has been removed from %s', 'L''aura du spell %u a été enlevée de %s.', 'Language.h', 'MangosStrings', 'LANG_COMMAND_AURAGROUP_AURA_REMOVED_FOR_SPELL') | ||
; | ||
|
||
|
||
|
||
|
||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ||
-- -- PLACE UPDATE SQL ABOVE -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ||
|
||
-- If we get here ok, commit the changes | ||
IF bRollback = TRUE THEN | ||
ROLLBACK; | ||
SHOW ERRORS; | ||
SELECT '* UPDATE FAILED *' AS `===== Status =====`,@cCurResult AS `===== DB is on Version: =====`; | ||
ELSE | ||
COMMIT; | ||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ||
-- UPDATE THE DB VERSION | ||
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | ||
INSERT INTO `db_version` VALUES (@cNewVersion, @cNewStructure, @cNewContent, @cNewDescription, @cNewComment); | ||
SET @cNewResult := (SELECT `description` FROM `db_version` WHERE `version`=@cNewVersion AND `structure`=@cNewStructure AND `content`=@cNewContent); | ||
|
||
SELECT '* UPDATE COMPLETE *' AS `===== Status =====`,@cNewResult AS `===== DB is now on Version =====`; | ||
END IF; | ||
ELSE -- Current version is not the expected version | ||
IF (@cCurResult = @cNewResult) THEN -- Does the current version match the new version | ||
SELECT '* UPDATE SKIPPED *' AS `===== Status =====`,@cCurResult AS `===== DB is already on Version =====`; | ||
ELSE -- Current version is not one related to this update | ||
IF(@cCurResult IS NULL) THEN -- Something has gone wrong | ||
SELECT '* UPDATE FAILED *' AS `===== Status =====`,'Unable to locate DB Version Information' AS `============= Error Message =============`; | ||
ELSE | ||
IF(@cOldResult IS NULL) THEN -- Something has gone wrong | ||
SET @cCurVersion := (SELECT `version` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurStructure := (SELECT `STRUCTURE` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurContent := (SELECT `Content` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurOutput = CONCAT(@cCurVersion, '_', @cCurStructure, '_', @cCurContent, ' - ',@cCurResult); | ||
SET @cOldResult = CONCAT('Rel',@cOldVersion, '_', @cOldStructure, '_', @cOldContent, ' - ','IS NOT APPLIED'); | ||
SELECT '* UPDATE SKIPPED *' AS `===== Status =====`,@cOldResult AS `=== Expected ===`,@cCurOutput AS `===== Found Version =====`; | ||
ELSE | ||
SET @cCurVersion := (SELECT `version` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurStructure := (SELECT `STRUCTURE` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurContent := (SELECT `Content` FROM `db_version` ORDER BY `version` DESC, `STRUCTURE` DESC, `CONTENT` DESC LIMIT 0,1); | ||
SET @cCurOutput = CONCAT(@cCurVersion, '_', @cCurStructure, '_', @cCurContent, ' - ',@cCurResult); | ||
SELECT '* UPDATE SKIPPED *' AS `===== Status =====`,@cOldResult AS `=== Expected ===`,@cCurOutput AS `===== Found Version =====`; | ||
END IF; | ||
END IF; | ||
END IF; | ||
END IF; | ||
END $$ | ||
|
||
DELIMITER ; | ||
|
||
-- Execute the procedure | ||
CALL update_mangos(); | ||
|
||
-- Drop the procedure | ||
DROP PROCEDURE IF EXISTS `update_mangos`; | ||
|
||
|