From 4a69b84e5a1284c9f7fbc972dba265b45c747fd4 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 4 Oct 2022 21:42:08 -0300 Subject: [PATCH 1/2] Fix market duplication money and some scripts lua modifications --- data/migrations/20.lua | 5 ++++- data/migrations/21.lua | 3 +++ .../dark_trails/death_priest_shargon.lua | 2 +- .../dark_trails/kill_death_priest_shargon.lua | 21 ++++++++++++++----- schema.sql | 4 ++-- 5 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 data/migrations/21.lua diff --git a/data/migrations/20.lua b/data/migrations/20.lua index 2c7477d68..391e51564 100644 --- a/data/migrations/20.lua +++ b/data/migrations/20.lua @@ -1,3 +1,6 @@ function onUpdateDatabase() - return false -- true = There are others migrations file | false = this is the last migration file + Spdlog.info("Updating database to version 21 (Fix market price size)") + db.query("ALTER TABLE `market_history` CHANGE `price` `price` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0';") + db.query("ALTER TABLE `market_offers` CHANGE `price` `price` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0';") + return true end diff --git a/data/migrations/21.lua b/data/migrations/21.lua new file mode 100644 index 000000000..2c7477d68 --- /dev/null +++ b/data/migrations/21.lua @@ -0,0 +1,3 @@ +function onUpdateDatabase() + return false -- true = There are others migrations file | false = this is the last migration file +end diff --git a/data/monster/quests/dark_trails/death_priest_shargon.lua b/data/monster/quests/dark_trails/death_priest_shargon.lua index 13fe2d28a..0f3bafc9e 100644 --- a/data/monster/quests/dark_trails/death_priest_shargon.lua +++ b/data/monster/quests/dark_trails/death_priest_shargon.lua @@ -53,7 +53,7 @@ monster.flags = { } monster.events = { - "DeathPriestShargonDeath" + "ShargonKill" } monster.light = { diff --git a/data/scripts/creaturescripts/quests/dark_trails/kill_death_priest_shargon.lua b/data/scripts/creaturescripts/quests/dark_trails/kill_death_priest_shargon.lua index cee7efb1c..8ae2a4a8c 100644 --- a/data/scripts/creaturescripts/quests/dark_trails/kill_death_priest_shargon.lua +++ b/data/scripts/creaturescripts/quests/dark_trails/kill_death_priest_shargon.lua @@ -1,5 +1,14 @@ +local config = { + teleportId = 1949, + teleportPosition = {x = 33487, y = 32101, z = 9}, + destinationPosition = Position(33489, 32088, 9), + storageKey = Storage.DarkTrails.Mission18, + getStorageValue = 1, + setStorageValue = 2 +} + local function removeTeleport(position) - local teleportItem = Tile({x = 33487, y = 32101, z = 9}):getItemById(1949) + local teleportItem = Tile(config.teleportPosition):getItemById(config.teleportId) if teleportItem then teleportItem:remove() position:sendMagicEffect(CONST_ME_POFF) @@ -14,12 +23,14 @@ function deathPriestShargon.onKill(creature, target) local position = target:getPosition() position:sendMagicEffect(CONST_ME_TELEPORT) - local item = Game.createItem(1949, 1, {x = 33487, y = 32101, z = 9}) + local item = Game.createItem(config.teleportId, 1, config.teleportPosition) if item:isTeleport() then - item:setDestination(Position(33489,32088,9)) + item:setDestination(config.destinationPosition) end - if creature:getStorageValue(Storage.DarkTrails.Mission18) < 1 then - creature:setStorageValue(Storage.DarkTrails.Mission18, 1) + if config.storageKey ~= nil then + if creature:getStorageValue(config.storageKey) < config.getStorageValue then + creature:setStorageValue(config.storageKey, config.setStorageValue) + end end addEvent(removeTeleport, 5 * 60 * 1000, position) return true diff --git a/schema.sql b/schema.sql index 2e8e30184..c6e8cd175 100644 --- a/schema.sql +++ b/schema.sql @@ -524,7 +524,7 @@ CREATE TABLE IF NOT EXISTS `market_history` ( `sale` tinyint(1) NOT NULL DEFAULT '0', `itemtype` int(10) UNSIGNED NOT NULL, `amount` smallint(5) UNSIGNED NOT NULL, - `price` int(10) UNSIGNED NOT NULL DEFAULT '0', + `price` bigint(20) UNSIGNED NOT NULL DEFAULT '0', `expires_at` bigint(20) UNSIGNED NOT NULL, `inserted` bigint(20) UNSIGNED NOT NULL, `state` tinyint(1) UNSIGNED NOT NULL, @@ -549,7 +549,7 @@ CREATE TABLE IF NOT EXISTS `market_offers` ( `amount` smallint(5) UNSIGNED NOT NULL, `created` bigint(20) UNSIGNED NOT NULL, `anonymous` tinyint(1) NOT NULL DEFAULT '0', - `price` int(10) UNSIGNED NOT NULL DEFAULT '0', + `price` bigint(20) UNSIGNED NOT NULL DEFAULT '0', INDEX `sale` (`sale`,`itemtype`), INDEX `created` (`created`), INDEX `player_id` (`player_id`), From 60bf06350e3e930482b648440f38a407b88e3450 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 4 Oct 2022 21:46:24 -0300 Subject: [PATCH 2/2] Fix db version --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index c6e8cd175..80d542f94 100644 --- a/schema.sql +++ b/schema.sql @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `server_config` ( CONSTRAINT `server_config_pk` PRIMARY KEY (`config`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '20'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); +INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '21'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); -- --------------------------------------------------------