diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 90 |
1 files changed, 73 insertions, 17 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 00cc4a3c4..c9e018f73 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4903,7 +4903,7 @@ static int clif_damage(struct block_list *src, struct block_list *dst, int sdela } if(src == dst) { - unit->setdir(src,unit->getdir(src)); + unit->set_dir(src, unit->getdir(src)); } //Return adjusted can't walk delay for further processing. @@ -10588,6 +10588,65 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) clif->updatestatus(sd, SP_CARTINFO); } + /** + * In official servers, an item's unequip script is executed when entering a zone where the item is restricted, + * even if the item won't be unequipped. + * + **/ + if (map->list[sd->bl.m].zone != NULL && map->list[sd->bl.m].zone->disabled_items_count != 0) { + struct map_zone_data *zone = map->list[sd->bl.m].zone; + int dis_items_cnt = zone->disabled_items_count; + int handled_equip = 0x00000000; + + for (int i = 0; i < EQI_MAX; i++) { + if (sd->equip_index[i] == INDEX_NOT_FOUND) + continue; + + int inv_idx = sd->equip_index[i]; + struct item_data *equip_data = sd->inventory_data[inv_idx]; + + if (equip_data == NULL) + continue; + + if ((handled_equip & equip_data->equip) != 0) + continue; // Equipment takes multiple slots and was already handled. + + handled_equip |= equip_data->equip; + + if (equip_data->unequip_script != NULL) { + int idx; + + ARR_FIND(0, dis_items_cnt, idx, zone->disabled_items[idx] == equip_data->nameid); + + if (idx < dis_items_cnt) + script->run_item_unequip_script(sd, equip_data, npc->fake_nd->bl.id); + } + + if (inv_idx != sd->equip_index[i]) + continue; // Unequip script execution corrupted the inventory index. + + struct item *equip = &sd->status.inventory[inv_idx]; + + if (equip != NULL && !itemdb_isspecial(equip->card[0])) { + for (int slot = 0; slot < equip_data->slot; slot++) { + if (equip->card[slot] == 0) + continue; + + struct item_data *card_data = itemdb->exists(equip->card[slot]); + + if (card_data != NULL && card_data->unequip_script != NULL) { + int idx; + + ARR_FIND(0, dis_items_cnt, idx, zone->disabled_items[idx] == card_data->nameid); + + if (idx < dis_items_cnt) + script->run_item_unequip_script(sd, card_data, npc->fake_nd->bl.id); + } + } + } + } + } + // Check for and delete unavailable/disabled items. pc->checkitem(sd); @@ -11133,7 +11192,7 @@ static void clif_parse_WalkToXY(int fd, struct map_session_data *sd) //Set last idle time... [Skotlex] pc->update_idle_time(sd, BCIDLE_WALK); - unit->walktoxy(&sd->bl, x, y, 4); + unit->walk_toxy(&sd->bl, x, y, 4); } /// Notification about the result of a disconnect request (ZC_ACK_REQ_DISCONNECT). @@ -11351,15 +11410,7 @@ static void clif_parse_MapMove(int fd, struct map_session_data *sd) /// 0 = straight /// 1 = turned CW /// 2 = turned CCW -/// dir: -/// 0 = north -/// 1 = northwest -/// 2 = west -/// 3 = southwest -/// 4 = south -/// 5 = southeast -/// 6 = east -/// 7 = northeast +/// dir: @see enum unit_dir static void clif_changed_dir(struct block_list *bl, enum send_target target) { unsigned char buf[64]; @@ -16462,7 +16513,7 @@ static void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) unit->calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir); ud = unit->bl2ud(bl); - unit->walktoxy(bl, ud->to_x, ud->to_y, 4); + unit->walk_toxy(bl, ud->to_x, ud->to_y, 4); } static void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -16486,7 +16537,7 @@ static void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) else return; - unit->walktoxy(bl, x, y, 4); + unit->walk_toxy(bl, x, y, 4); } static void clif_parse_HomAttack(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -23235,7 +23286,8 @@ static void clif_parse_npc_expanded_barter_closed(int fd, struct map_session_dat #if PACKETVER_MAIN_NUM >= 20191120 || PACKETVER_RE_NUM >= 20191106 || PACKETVER_ZERO_NUM >= 20191127 #define NEXT_EXPANDED_BARTER_ITEM(var, count) \ var = (struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub *)((char*)item + \ - sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) + \ + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) - \ + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2) + \ count * sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2)) #endif @@ -23255,7 +23307,11 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np packet->packetType = HEADER_ZC_NPC_EXPANDED_BARTER_OPEN; struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub *item = &packet->items[0]; - for (int i = 0; i < shop_size && buf_left >= sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub); i++) { + // Workaround for fix Visual Studio bug (error C2233) + // Here should be sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) + const int ptr_size = sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) - + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2); + for (int i = 0; i < shop_size && buf_left >= ptr_size; i++) { if (shop[i].nameid) { struct item_data *id = itemdb->exists(shop[i].nameid); if (id == NULL) @@ -23268,7 +23324,7 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np item->index = i; item->zeny = shop[i].value; item->currency_count = 0; - buf_left -= sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub); + buf_left -= ptr_size; items_count ++; int count = shop[i].value2; if (buf_left < sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2) * count) { @@ -23297,7 +23353,7 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np packet->items_count = items_count; packet->packetLength = sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN) + - sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub) * items_count + + ptr_size * items_count + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2) * currencies_count; clif->send(packet, packet->packetLength, &sd->bl, SELF); #endif |