summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql-files/main.sql2
-rw-r--r--sql-files/upgrades/2019-10-05--19-01.sql28
-rw-r--r--sql-files/upgrades/index.txt1
-rw-r--r--src/char/char.c23
-rw-r--r--src/common/mmo.h1
-rw-r--r--src/map/chrif.c5
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/clif.h3
-rw-r--r--src/map/status.c47
-rw-r--r--src/map/status.h4
10 files changed, 102 insertions, 30 deletions
diff --git a/sql-files/main.sql b/sql-files/main.sql
index 27839afa3..4627799aa 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -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',
@@ -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`
diff --git a/sql-files/upgrades/2019-10-05--19-01.sql b/sql-files/upgrades/2019-10-05--19-01.sql
new file mode 100644
index 000000000..4cb7c1c51
--- /dev/null
+++ b/sql-files/upgrades/2019-10-05--19-01.sql
@@ -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);
diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt
index 85bd2a245..10eb30762 100644
--- a/sql-files/upgrades/index.txt
+++ b/sql-files/upgrades/index.txt
@@ -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
diff --git a/src/char/char.c b/src/char/char.c
index c5afc0f63..37db77300 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -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) )
{
@@ -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)
@@ -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);
@@ -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);
}
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 66736bff0..ed74f11df 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -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 {
diff --git a/src/map/chrif.c b/src/map/chrif.c
index a3277d4c2..ddc106d0c 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -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;
@@ -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);
diff --git a/src/map/clif.c b/src/map/clif.c
index f6caa502e..7d98fcb82 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -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;
@@ -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;
@@ -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;
@@ -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)
@@ -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:
@@ -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;
diff --git a/src/map/clif.h b/src/map/clif.h
index 4bc3abdeb..0dfc00c01 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -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);
diff --git a/src/map/status.c b/src/map/status.c
index d24da4180..a2c11de14 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -7515,7 +7515,7 @@ static void status_display_remove(struct map_session_data *sd, enum sc_type type
}
/**
- * Starts a status change.
+ * Starts a status change with a set remaining time.
*
* @param src Status change source bl.
* @param bl Status change target bl.
@@ -7525,13 +7525,14 @@ static void status_display_remove(struct map_session_data *sd, enum sc_type type
* @param val2 Additional value (meaning depends on type).
* @param val3 Additional value (meaning depends on type).
* @param val4 Additional value (meaning depends on type).
- * @param total_tick Total duration (milliseconds).
+ * @param tick Remaining duration (miliseconds). (if flag doesn't contain SCFLAG_LOADED, it will become the final total_tick)
+ * @param total_tick Base duration (milliseconds).
* @param flag Special flags (@see enum scstart_flag).
*
* @retval 0 if no status change happened.
* @retval 1 if the status change was successfully applied.
*/
-static int status_change_start(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int total_tick, int flag)
+static int status_change_start_sub(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int total_tick, int flag)
{
struct map_session_data *sd = NULL;
struct status_change* sc;
@@ -7545,7 +7546,7 @@ static int status_change_start(struct block_list *src, struct block_list *bl, en
st = status->get_status_data(bl);
if (type <= SC_NONE || type >= SC_MAX) {
- ShowError("status_change_start: invalid status change (%d)!\n", type);
+ ShowError("status_change_start_sub: invalid status change (%d)!\n", type);
return 0;
}
@@ -9670,14 +9671,16 @@ static int status_change_start(struct block_list *src, struct block_list *bl, en
}
#endif
- if(!(flag&SCFLAG_NOICON) && !(flag&SCFLAG_LOADED && status->dbs->DisplayType[type]))
- clif->status_change(bl,status->dbs->IconChangeTable[type],1,total_tick,(val_flag&1)?val1:1,(val_flag&2)?val2:0,(val_flag&4)?val3:0);
+ if (!(flag & SCFLAG_LOADED))
+ tick = total_tick; // When starting a new SC (not loading), its remaining duration is the same as the total
+ if(!(flag & SCFLAG_NOICON) && !(flag & SCFLAG_LOADED && status->dbs->DisplayType[type]))
+ clif->status_change_sub(bl, status->dbs->IconChangeTable[type], 1, tick, total_tick, (val_flag & 1) ? val1 : 1, (val_flag & 2) ? val2 : 0, (val_flag & 4) ? val3 : 0);
/**
* used as temporary storage for scs with interval ticks, so that the actual duration is sent to the client first.
**/
- if( tick_time )
- total_tick = tick_time;
+ if(tick_time)
+ tick = tick_time;
//Don't trust the previous sce assignment, in case the SC ended somewhere between there and here.
if((sce=sc->data[type])) {// reuse old sc
@@ -9692,9 +9695,10 @@ static int status_change_start(struct block_list *src, struct block_list *bl, en
sce->val2 = val2;
sce->val3 = val3;
sce->val4 = val4;
+ sce->total_tick = total_tick;
- if (total_tick >= 0) {
- sce->timer = timer->add(timer->gettick() + total_tick, status->change_timer, bl->id, type);
+ if (tick >= 0) {
+ sce->timer = timer->add(timer->gettick() + tick, status->change_timer, bl->id, type);
sce->infinite_duration = false;
} else {
sce->timer = INVALID_TIMER; //Infinite duration
@@ -9811,6 +9815,28 @@ static bool status_change_start_unknown_sc(struct block_list *src, struct block_
return false;
}
+/**
+ * Starts a status change in its full duration.
+ *
+ * @param src Status change source bl.
+ * @param bl Status change target bl.
+ * @param type Status change type.
+ * @param rate Base success rate. 1 means 0.01%, 10000 means 100%.
+ * @param val1 Additional value (meaning depends on type).
+ * @param val2 Additional value (meaning depends on type).
+ * @param val3 Additional value (meaning depends on type).
+ * @param val4 Additional value (meaning depends on type).
+ * @param tick Base duration (milliseconds).
+ * @param flag Special flags (@see enum scstart_flag).
+ *
+ * @retval 0 if no status change happened.
+ * @retval 1 if the status change was successfully applied.
+ */
+static int status_change_start(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int flag)
+{
+ return status->change_start_sub(src, bl, type, rate, val1, val2, val3, val4, 0, tick, flag);
+}
+
static void status_change_start_display(struct map_session_data *sd, enum sc_type type, int val1, int val2, int val3, int val4)
{
Assert_retv(type >= SC_NONE && type < SC_MAX);
@@ -13633,6 +13659,7 @@ void status_defaults(void)
status->get_sc_def = status_get_sc_def;
status->change_start = status_change_start;
+ status->change_start_sub = status_change_start_sub;
status->change_end_ = status_change_end_;
status->kaahi_heal_timer = kaahi_heal_timer;
status->change_timer = status_change_timer;
diff --git a/src/map/status.h b/src/map/status.h
index 67cc3b3b4..e2280e409 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -2138,6 +2138,7 @@ struct sc_display_entry {
struct status_change_entry {
int timer;
+ int total_tick;
int val1,val2,val3,val4;
bool infinite_duration;
};
@@ -2305,7 +2306,8 @@ struct status_interface {
int (*isdead) (struct block_list *bl);
int (*isimmune) (struct block_list *bl);
int (*get_sc_def) (struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int tick, int flag);
- int (*change_start) (struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int total_tick, int flag);
+ int (*change_start) (struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int flag);
+ int (*change_start_sub) (struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int total_tick, int flag);
int (*change_end_) (struct block_list* bl, enum sc_type type, int tid, const char* file, int line);
bool (*is_immune_to_status) (struct status_change* sc, enum sc_type type);
bool (*is_boss_resist_sc) (enum sc_type type);