diff options
author | Ibrahim Zidan <brahem@aotsw.com> | 2019-04-08 22:14:16 +0200 |
---|---|---|
committer | Ibrahim Zidan <brahem@aotsw.com> | 2019-04-08 23:37:17 +0200 |
commit | 9e934f3608a4a67667573514909911130493e174 (patch) | |
tree | 7ae7346a08f389c5d48413a1fbd473808b169426 | |
parent | ab81d4012eac5c2c00c485971fc9b89bf69761be (diff) | |
download | hercules-9e934f3608a4a67667573514909911130493e174.tar.gz hercules-9e934f3608a4a67667573514909911130493e174.tar.bz2 hercules-9e934f3608a4a67667573514909911130493e174.tar.xz hercules-9e934f3608a4a67667573514909911130493e174.zip |
Fix an issue with named/brewed/forged items getting saved with the wrong character id
The isue was triggered by the refactoring of old undocumented code that
relied on the overflow behavior during assignment from int32 to int16
and from uint16 to int16, and by a subsequent clamping to SMALLINT range
operated by the SQL server.
Credits: Haru <haru@dotalux.com>
Fixes #2409
Signed-off-by: Ibrahim Zidan <brahem@aotsw.com>
-rw-r--r-- | sql-files/main.sql | 1 | ||||
-rw-r--r-- | sql-files/upgrades/2019-04-08--21-52.sql | 29 | ||||
-rw-r--r-- | sql-files/upgrades/index.txt | 1 | ||||
-rw-r--r-- | src/map/atcommand.c | 6 | ||||
-rw-r--r-- | src/map/script.c | 12 |
5 files changed, 40 insertions, 9 deletions
diff --git a/sql-files/main.sql b/sql-files/main.sql index a08ec60ba..5d466f4cd 100644 --- a/sql-files/main.sql +++ b/sql-files/main.sql @@ -925,6 +925,7 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1532403228); -- 2018-07-2 INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1535865732); -- 2018-09-01--05-22.sql INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1544738447); -- 2018-12-14--01-02.sql INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1546059075); -- 2018-12-29--07-51.sql +INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1554760320); -- 2019-04-08--21-52.sql -- -- Table structure for table `storage` diff --git a/sql-files/upgrades/2019-04-08--21-52.sql b/sql-files/upgrades/2019-04-08--21-52.sql new file mode 100644 index 000000000..bd015acf8 --- /dev/null +++ b/sql-files/upgrades/2019-04-08--21-52.sql @@ -0,0 +1,29 @@ +#1554760320 + +-- This file is part of Hercules. +-- http://herc.ws - http://github.com/HerculesWS/Hercules +-- +-- Copyright (C) 2013-2019 Hercules Dev Team +-- +-- Hercules is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +UPDATE `auction` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); +UPDATE `cart_inventory` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); +UPDATE `inventory` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); +UPDATE `guild_storage` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); +UPDATE `mail` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); +UPDATE `rodex_items` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); +UPDATE `storage` SET `card3` = `card2` >> 16, `card2` = `card2` % 65536 WHERE `card2` > 65536 AND (`card0` = 255 OR `card0` = 254); + +INSERT INTO `sql_updates` (`timestamp`, `ignored`) VALUES (1554760320, 'No'); diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt index 3a2fc4c33..a77a7635f 100644 --- a/sql-files/upgrades/index.txt +++ b/sql-files/upgrades/index.txt @@ -52,3 +52,4 @@ 2018-09-01--05-22.sql 2018-12-14--01-02.sql 2018-12-29--07-51.sql +2019-04-08--21-52.sql diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a9bbff7bd..b670d64dc 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5599,9 +5599,9 @@ static void atcommand_getring(struct map_session_data *sd) memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = item_id; item_tmp.identify = 1; - item_tmp.card[0] = 255; - item_tmp.card[2] = sd->status.partner_id; - item_tmp.card[3] = sd->status.partner_id >> 16; + item_tmp.card[0] = CARD0_FORGE; + item_tmp.card[2] = GetWord(sd->status.partner_id, 0); + item_tmp.card[3] = GetWord(sd->status.partner_id, 1); if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) { clif->additem(sd,0,0,flag); diff --git a/src/map/script.c b/src/map/script.c index fe8638ac3..76b07fa37 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8177,12 +8177,12 @@ static BUILDIN(getnameditem) } memset(&item_tmp,0,sizeof(item_tmp)); - item_tmp.nameid=nameid; - item_tmp.amount=1; - item_tmp.identify=1; - item_tmp.card[0]=CARD0_CREATE; //we don't use 255! because for example SIGNED WEAPON shouldn't get TOP10 BS Fame bonus [Lupus] - item_tmp.card[2]=tsd->status.char_id; - item_tmp.card[3]=tsd->status.char_id >> 16; + item_tmp.nameid = nameid; + item_tmp.amount = 1; + item_tmp.identify = 1; + item_tmp.card[0] = CARD0_CREATE; //we don't use 255! because for example SIGNED WEAPON shouldn't get TOP10 BS Fame bonus [Lupus] + item_tmp.card[2] = GetWord(tsd->status.char_id, 0); + item_tmp.card[3] = GetWord(tsd->status.char_id, 1); if(pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT)) { script_pushint(st,0); return true; //Failed to add item, we will not drop if they don't fit |