Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sql-files/main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ CREATE TABLE IF NOT EXISTS `sc_data` (
`char_id` INT(11) UNSIGNED NOT NULL,
`type` SMALLINT(11) UNSIGNED NOT NULL,
`tick` INT(11) NOT NULL,
`total_tick` INT(11) NOT NULL,
`val1` INT(11) NOT NULL DEFAULT '0',
`val2` INT(11) NOT NULL DEFAULT '0',
`val3` INT(11) NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -931,6 +932,7 @@ INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1554760320); -- 2019-04-0
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1556147483); -- 2019-04-25--02-12.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1557414445); -- 2019-05-09--18-07.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1565293394); -- 2019-08-08--19-43.sql
INSERT IGNORE INTO `sql_updates` (`timestamp`) VALUES (1570309293); -- 2019-10-05--19-01.sql

--
-- Table structure for table `storage`
Expand Down
28 changes: 28 additions & 0 deletions sql-files/upgrades/2019-10-05--19-01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#1570309293

-- This file is part of Hercules.
-- http://herc.ws - http://github.com/HerculesWS/Hercules
--
-- Copyright (C) 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/>.

-- Adds new total_tick column
ALTER TABLE `sc_data` ADD COLUMN `total_tick` INT(11) NOT NULL AFTER `tick`;

-- Copy current tick to total_tick so players doesn't lose their current
-- status_changes, although those will still appear wrong until they end
UPDATE `sc_data` SET `total_tick` = `tick`;

INSERT INTO `sql_updates` (`timestamp`) VALUES (1570309293);
1 change: 1 addition & 0 deletions sql-files/upgrades/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@
2019-04-25--02-12.sql
2019-05-09--18-07.sql
2019-08-08--19-43.sql
2019-10-05--19-01.sql
23 changes: 12 additions & 11 deletions src/char/char.c
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ static void char_parse_frommap_map_names(int fd, int id)
static void char_send_scdata(int fd, int aid, int cid)
{
#ifdef ENABLE_SC_SAVING
if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `total_tick`, `val1`, `val2`, `val3`, `val4` "
"FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
scdata_db, aid, cid) )
{
Expand All @@ -3170,10 +3170,11 @@ static void char_send_scdata(int fd, int aid, int cid)
{
SQL->GetData(inter->sql_handle, 0, &data, NULL); scdata.type = atoi(data);
SQL->GetData(inter->sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.total_tick = atoi(data);
SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val1 = atoi(data);
SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val2 = atoi(data);
SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val3 = atoi(data);
SQL->GetData(inter->sql_handle, 6, &data, NULL); scdata.val4 = atoi(data);
memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
}
if (count >= 50)
Expand Down Expand Up @@ -3743,14 +3744,14 @@ static void char_parse_frommap_save_status_change_data(int fd)
int i;

StrBuf->Init(&buf);
StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `total_tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
for( i = 0; i < count; ++i )
{
memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
if( i > 0 )
StrBuf->AppendStr(&buf, ", ");
StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
data.type, data.tick, data.val1, data.val2, data.val3, data.val4);
StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d','%d')", aid, cid,
data.type, data.tick, data.total_tick, data.val1, data.val2, data.val3, data.val4);
}
if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
Sql_ShowDebug(inter->sql_handle);
Expand Down Expand Up @@ -3883,9 +3884,9 @@ static void char_parse_frommap_scdata_update(int fd)
short type = RFIFOW(fd, 10);

if (SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s`"
" (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`)"
" VALUES ('%d','%d','%d','%d','%d','%d','%d','%d')",
scdata_db, account_id, char_id, type, INFINITE_DURATION, val1, val2, val3, val4)
" (`account_id`,`char_id`,`type`,`tick`,`total_tick`,`val1`,`val2`,`val3`,`val4`)"
" VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d')",
scdata_db, account_id, char_id, type, INFINITE_DURATION, INFINITE_DURATION, val1, val2, val3, val4)
) {
Sql_ShowDebug(inter->sql_handle);
}
Expand Down
1 change: 1 addition & 0 deletions src/common/mmo.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ struct status_change_data {
unsigned short type; ///< Status change type (@see enum sc_type)
int val1, val2, val3, val4; ///< Parameters (meaning depends on type).
int tick; ///< Remaining duration.
int total_tick; ///< Total duration.
};

struct storage_data {
Expand Down
5 changes: 3 additions & 2 deletions src/map/chrif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ static bool chrif_save_scdata(struct map_session_data *sd)
} else {
data.tick = INFINITE_DURATION;
}
data.total_tick = sc->data[i]->total_tick;
data.type = i;
data.val1 = sc->data[i]->val1;
data.val2 = sc->data[i]->val2;
Expand Down Expand Up @@ -1273,8 +1274,8 @@ static bool chrif_load_scdata(int fd)

for (i = 0; i < count; i++) {
const struct status_change_data *data = RFIFOP(fd,14 + i*sizeof(struct status_change_data));
status->change_start(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4,
data->tick, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE);
status->change_start_sub(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4,
data->tick, data->total_tick, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE);
}

pc->scdata_received(sd);
Expand Down
18 changes: 13 additions & 5 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -6041,7 +6041,7 @@ static void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 s
}
}

static void clif_status_change_notick(struct block_list *bl, int type, int flag, int tick, int val1, int val2, int val3)
static void clif_status_change_notick(struct block_list *bl, int type, int flag, int tick, int total_tick, int val1, int val2, int val3)
{
struct packet_sc_notick p;
struct map_session_data *sd;
Expand Down Expand Up @@ -6070,7 +6070,7 @@ static void clif_status_change_notick(struct block_list *bl, int type, int flag,
/// 08ff <id>.L <index>.W <remain msec>.L { <val>.L }*3 (PACKETVER >= 20111108)
/// 0983 <index>.W <id>.L <state>.B <total msec>.L <remain msec>.L { <val>.L }*3 (PACKETVER >= 20120618)
/// 0984 <id>.L <index>.W <total msec>.L <remain msec>.L { <val>.L }*3 (PACKETVER >= 20120618)
static void clif_status_change(struct block_list *bl, int type, int flag, int tick, int val1, int val2, int val3)
static void clif_status_change_sub(struct block_list *bl, int type, int flag, int tick, int total_tick, int val1, int val2, int val3)
{
struct packet_status_change p;
struct map_session_data *sd;
Expand All @@ -6094,7 +6094,7 @@ static void clif_status_change(struct block_list *bl, int type, int flag, int ti
p.state = (unsigned char)flag;

#if PACKETVER >= 20120618
p.Total = tick; /* at this stage remain and total are the same value I believe */
p.Total = total_tick;
#endif
#if PACKETVER >= 20090121
p.Left = tick;
Expand All @@ -6105,6 +6105,13 @@ static void clif_status_change(struct block_list *bl, int type, int flag, int ti
clif->send(&p,sizeof(p), bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
}

/// Notifies clients of a status change.
/// @see clif_status_change_sub
static void clif_status_change(struct block_list *bl, int type, int flag, int total_tick, int val1, int val2, int val3)
{
clif->status_change_sub(bl, type, flag, total_tick, total_tick, val1, val2, val3);
}

/// Send message (modified by [Yor]) (ZC_NOTIFY_PLAYERCHAT).
/// 008e <packet len>.W <message>.?B
static void clif_displaymessage(const int fd, const char *mes)
Expand Down Expand Up @@ -23676,9 +23683,9 @@ static void packetdb_loaddb(void)
static void clif_bc_ready(void)
{
if( battle_config.display_status_timers )
clif->status_change = clif_status_change;
clif->status_change_sub = clif_status_change_sub;
else
clif->status_change = clif_status_change_notick;
clif->status_change_sub = clif_status_change_notick;

switch( battle_config.packet_obfuscation ) {
case 0:
Expand Down Expand Up @@ -23896,6 +23903,7 @@ void clif_defaults(void)
clif->autospell = clif_autospell;
clif->combo_delay = clif_combo_delay;
clif->status_change = clif_status_change;
clif->status_change_sub = clif_status_change_sub;
clif->insert_card = clif_insert_card;
clif->inventoryList = clif_inventoryList;
clif->inventoryItems = clif_inventoryItems;
Expand Down
3 changes: 2 additions & 1 deletion src/map/clif.h
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,8 @@ struct clif_interface {
void (*cooking_list) (struct map_session_data *sd, int trigger, uint16 skill_id, int qty, int list_type);
void (*autospell) (struct map_session_data *sd,uint16 skill_lv);
void (*combo_delay) (struct block_list *bl,int wait);
void (*status_change) (struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3);
void (*status_change) (struct block_list *bl, int type, int flag, int total_tick, int val1, int val2, int val3);
void (*status_change_sub) (struct block_list *bl, int type, int flag, int tick, int total_tick, int val1, int val2, int val3);
void (*insert_card) (struct map_session_data *sd,int idx_equip,int idx_card,int flag);
void (*inventoryList) (struct map_session_data *sd);
void (*inventoryItems) (struct map_session_data *sd, enum inventory_type type);
Expand Down
Loading