diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-09 22:05:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-09 22:05:22 +0300 |
commit | c95ac0d7e312aade368f7213eafa6476ef2cd3fe (patch) | |
tree | 6391aad9062c784f989d126938a4d9710865e3a4 /src/emap/parse.c | |
parent | b5c56b1147e6ec93d948c9e5eedcd5d68618b308 (diff) | |
download | evol-hercules-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.tar.gz evol-hercules-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.tar.bz2 evol-hercules-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.tar.xz evol-hercules-c95ac0d7e312aade368f7213eafa6476ef2cd3fe.zip |
Add support for different use actions for items.s20170810
Diffstat (limited to 'src/emap/parse.c')
-rw-r--r-- | src/emap/parse.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/emap/parse.c b/src/emap/parse.c index c893a5f..1d620f4 100644 --- a/src/emap/parse.c +++ b/src/emap/parse.c @@ -23,7 +23,9 @@ #include "emap/parse.h" #include "emap/send.h" #include "emap/map.h" +#include "emap/data/itemd.h" #include "emap/data/session.h" +#include "emap/struct/itemdext.h" #include "emap/struct/sessionext.h" void map_parse_version(int fd) @@ -225,3 +227,37 @@ void map_parse_homun_dir(int fd) else if (sd->hd && homun_alive(sd->hd)) unit->setdir(&sd->hd->bl, RFIFOB(fd, 8)); } + +void map_clif_parse_useitem2(int fd) +{ + TBL_PC* sd = (TBL_PC*)sockt->session[fd]->session_data; + if (!sd) + return; + + if (pc_isdead(sd)) + { + clif->clearunit_area(&sd->bl, CLR_DEAD); + return; + } + + if ((!sd->npc_id && pc_istrading(sd)) || sd->chat_id != 0) + return; + + // Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex] + pc->update_idle_time(sd, BCIDLE_USEITEM); + const int n = RFIFOW(fd, 2) - 2; + if (n < 0 || n >= MAX_INVENTORY) + return; + + struct item_data *item = itemdb->exists(sd->inventory_data[n]->nameid); + + if (!item) + return; + struct ItemdExt *data = itemd_get(item); + if (!data) + return; + + data->tmpUseType = RFIFOW(fd, 4); + if (!pc->useitem(sd, n)) + clif->useitemack(sd, n, 0, false); //Send an empty ack packet or the client gets stuck. +} |