diff options
Diffstat (limited to 'src')
41 files changed, 1895 insertions, 1088 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h index 687f5a187..25ad350c0 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -64,7 +64,7 @@ // 20120307 - 2012-03-07aRagexeRE+ - 0x970 #ifndef PACKETVER - #define PACKETVER 20141022 + #define PACKETVER 20190530 #endif // PACKETVER //Uncomment the following line if your client is ragexeRE instead of ragexe (required because of conflicting packets in ragexe vs ragexeRE). diff --git a/src/common/packets/packets2020_len_main.h b/src/common/packets/packets2020_len_main.h index 3349c9872..2a6058f65 100644 --- a/src/common/packets/packets2020_len_main.h +++ b/src/common/packets/packets2020_len_main.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2018-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2018-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -4631,5 +4631,20 @@ packetLen(0x0b71, 177) packetLen(0x0b72, 4) #endif +// Packet: 0x0b73 +#if PACKETVER >= 20200212 +packetLen(0x0b73, 8) +#endif + +// Packet: 0x0b74 +#if PACKETVER >= 20200304 +packetLen(0x0b74, 1026) +#endif + +// Packet: 0x0b75 +#if PACKETVER >= 20200304 +packetLen(0x0b75, 1026) +#endif + #endif /* COMMON_PACKETS2020_LEN_MAIN_H */ diff --git a/src/common/packets/packets2020_len_re.h b/src/common/packets/packets2020_len_re.h index b33278c1c..2c21b1c67 100644 --- a/src/common/packets/packets2020_len_re.h +++ b/src/common/packets/packets2020_len_re.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2018-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2018-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -4637,5 +4637,20 @@ packetLen(0x0b71, 177) packetLen(0x0b72, 4) #endif +// Packet: 0x0b73 +#if PACKETVER >= 20200212 +packetLen(0x0b73, 8) +#endif + +// Packet: 0x0b74 +#if PACKETVER >= 20200304 +packetLen(0x0b74, 1026) +#endif + +// Packet: 0x0b75 +#if PACKETVER >= 20200304 +packetLen(0x0b75, 1026) +#endif + #endif /* COMMON_PACKETS2020_LEN_RE_H */ diff --git a/src/common/packets/packets2020_len_zero.h b/src/common/packets/packets2020_len_zero.h index 153b66286..c1ffbecf6 100644 --- a/src/common/packets/packets2020_len_zero.h +++ b/src/common/packets/packets2020_len_zero.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2018-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2018-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -4631,5 +4631,20 @@ packetLen(0x0b71, 177) packetLen(0x0b72, 4) #endif +// Packet: 0x0b73 +#if PACKETVER >= 20200212 +packetLen(0x0b73, 8) +#endif + +// Packet: 0x0b74 +#if PACKETVER >= 20200304 +packetLen(0x0b74, 1026) +#endif + +// Packet: 0x0b75 +#if PACKETVER >= 20200304 +packetLen(0x0b75, 1026) +#endif + #endif /* COMMON_PACKETS2020_LEN_ZERO_H */ diff --git a/src/common/packets/packets_len_main.h b/src/common/packets/packets_len_main.h index 7b93b35b0..365b0af6f 100644 --- a/src/common/packets/packets_len_main.h +++ b/src/common/packets/packets_len_main.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2018-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2018-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/common/packets/packets_len_re.h b/src/common/packets/packets_len_re.h index 23a507886..302381722 100644 --- a/src/common/packets/packets_len_re.h +++ b/src/common/packets/packets_len_re.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2018-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2018-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/common/packets/packets_len_zero.h b/src/common/packets/packets_len_zero.h index 9f1595459..c07f89e3f 100644 --- a/src/common/packets/packets_len_zero.h +++ b/src/common/packets/packets_len_zero.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2018-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2018-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 707522423..410cd7af7 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4123,16 +4123,36 @@ ACMD(mapinfo) for (i = 0; i < map->list[m_id].npc_num;) { struct npc_data *nd = map->list[m_id].npc[i]; switch(nd->dir) { - case 0: strcpy(direction, msg_fd(fd,1101)); break; // North - case 1: strcpy(direction, msg_fd(fd,1102)); break; // North West - case 2: strcpy(direction, msg_fd(fd,1103)); break; // West - case 3: strcpy(direction, msg_fd(fd,1104)); break; // South West - case 4: strcpy(direction, msg_fd(fd,1105)); break; // South - case 5: strcpy(direction, msg_fd(fd,1106)); break; // South East - case 6: strcpy(direction, msg_fd(fd,1107)); break; // East - case 7: strcpy(direction, msg_fd(fd,1108)); break; // North East - case 9: strcpy(direction, msg_fd(fd,1109)); break; // North - default: strcpy(direction, msg_fd(fd,1110)); break; // Unknown + case UNIT_DIR_NORTH: + strcpy(direction, msg_fd(fd, 1101)); // North + break; + case UNIT_DIR_NORTHWEST: + strcpy(direction, msg_fd(fd, 1102)); // North West + break; + case UNIT_DIR_WEST: + strcpy(direction, msg_fd(fd, 1103)); // West + break; + case UNIT_DIR_SOUTHWEST: + strcpy(direction, msg_fd(fd, 1104)); // South West + break; + case UNIT_DIR_SOUTH: + strcpy(direction, msg_fd(fd, 1105)); // South + break; + case UNIT_DIR_SOUTHEAST: + strcpy(direction, msg_fd(fd, 1106)); // South East + break; + case UNIT_DIR_EAST: + strcpy(direction, msg_fd(fd, 1107)); // East + break; + case UNIT_DIR_NORTHEAST: + strcpy(direction, msg_fd(fd, 1108)); // North East + break; + case 9: // is this actually used? [skyleo] + strcpy(direction, msg_fd(fd, 1109)); // North + break; + default: + strcpy(direction, msg_fd(fd, 1110)); // Unknown + break; } if(strcmp(nd->name,nd->exname) == 0) safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d @@ -6899,7 +6919,7 @@ ACMD(identify) } } } - + if (num == 0) clif->message(fd,msg_fd(fd,1238)); // There are no items to appraise. else if (!identifyall) diff --git a/src/map/battle.c b/src/map/battle.c index 40e7d3161..985d2bca4 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3231,12 +3231,11 @@ static int64 battle_calc_damage(struct block_list *src, struct block_list *bl, s if (!damage) return 0; if( (sce = sc->data[SC_LIGHTNINGWALK]) && flag&BF_LONG && rnd()%100 < sce->val1 ) { - int dx[8]={0,-1,-1,-1,0,1,1,1}; - int dy[8]={1,1,0,-1,-1,-1,0,1}; - uint8 dir = map->calc_dir(bl, src->x, src->y); - if( unit->movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) { - clif->slide(bl,src->x-dx[dir],src->y-dy[dir]); - unit->setdir(bl, dir); + enum unit_dir dir = map->calc_dir(bl, src->x, src->y); + Assert_ret(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); + if (unit->movepos(bl, src->x - dirx[dir], src->y - diry[dir], 1, 1)) { + clif->slide(bl, src->x - dirx[dir], src->y - diry[dir]); + unit->set_dir(bl, dir); } d->dmg_lv = ATK_DEF; status_change_end(bl, SC_LIGHTNINGWALK, INVALID_TIMER); @@ -5858,10 +5857,10 @@ static void battle_reflect_damage(struct block_list *target, struct block_list * if( wd->flag & BF_SHORT ) { if( !is_boss(src) ) { if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION ) { - uint8 dir = map->calc_dir(target,src->x,src->y), - t_dir = unit->getdir(target); + enum unit_dir dir = map->calc_dir(target, src->x, src->y); + enum unit_dir t_dir = unit->getdir(target); - if( !map->check_dir(dir,t_dir) ) { + if (map->check_dir(dir, t_dir) == 0) { int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. trdamage += rdamage = rd1 - (damage = rd1 * 30 / 100); // not normalized as intended. @@ -6229,10 +6228,10 @@ static enum damage_lv battle_weapon_attack(struct block_list *src, struct block_ status_change_end(src, SC_CLOAKINGEXCEED, INVALID_TIMER); } if( tsc && tsc->data[SC_AUTOCOUNTER] && status->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) { - uint8 dir = map->calc_dir(target,src->x,src->y); - int t_dir = unit->getdir(target); + enum unit_dir dir = map->calc_dir(target, src->x, src->y); + enum unit_dir t_dir = unit->getdir(target); int dist = distance_bl(src, target); - if(dist <= 0 || (!map->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) { + if(dist <= 0 || (map->check_dir(dir, t_dir) == 0 && dist <= tstatus->rhw.range + 1)) { uint16 skill_lv = tsc->data[SC_AUTOCOUNTER]->val1; clif->skillcastcancel(target); //Remove the casting bar. [Skotlex] clif->damage(src, target, sstatus->amotion, 1, 0, 1, BDT_NORMAL, 0); //Display MISS. @@ -6601,10 +6600,6 @@ static int battle_check_target(struct block_list *src, struct block_list *target m = target->m; - if (flag & BCT_ENEMY && (map->getcell(m, src, src->x, src->y, CELL_CHKBASILICA) || map->getcell(m, src, target->x, target->y, CELL_CHKBASILICA))) { - return -1; - } - //t_bl/s_bl hold the 'master' of the attack, while src/target are the actual //objects involved. if( (t_bl = battle->get_master(target)) == NULL ) @@ -6613,6 +6608,11 @@ static int battle_check_target(struct block_list *src, struct block_list *target if( (s_bl = battle->get_master(src)) == NULL ) s_bl = src; + if ((flag & BCT_ENEMY) != 0 && (status_get_mode(s_bl) & MD_BOSS) == 0 && (map->getcell(m, src, src->x, src->y, CELL_CHKBASILICA) != 0 + || map->getcell(m, src, target->x, target->y, CELL_CHKBASILICA) != 0)) { + return -1; + } + if (s_bl->type == BL_PC) { const struct map_session_data *s_sd = BL_UCCAST(BL_PC, s_bl); switch (t_bl->type) { 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 diff --git a/src/map/elemental.c b/src/map/elemental.c index 1c1d98634..f176bb9e2 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -788,8 +788,8 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 0; //Already walking to him if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 ) return 0; //Can't move yet. - if( map->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) - && unit->walktoxy(&ed->bl, x, y, 0) ) + if (map->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) != 0 + && unit->walk_toxy(&ed->bl, x, y, 0) == 0) return 0; } diff --git a/src/map/map.c b/src/map/map.c index 70623ae22..defa56b2e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1670,7 +1670,7 @@ static int map_search_freecell(struct block_list *src, int16 m, int16 *x, int16 *------------------------------------------*/ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, int16 *y, int type, int flag) { - uint8 dir = 6; + enum unit_dir dir = UNIT_DIR_EAST; int16 tx; int16 ty; int costrange = 10; @@ -1689,7 +1689,7 @@ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, short dy = diry[dir]; //Linear search - if(dir%2 == 0 && costrange%MOVE_COST == 0) { + if (!unit_is_diagonal_dir(dir) && (costrange % MOVE_COST) == 0) { tx = *x+dx*(costrange/MOVE_COST); ty = *y+dy*(costrange/MOVE_COST); if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) { @@ -1699,7 +1699,7 @@ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, } } //Full diagonal search - else if(dir%2 == 1 && costrange%MOVE_DIAGONAL_COST == 0) { + else if (unit_is_diagonal_dir(dir) && (costrange % MOVE_DIAGONAL_COST) == 0) { tx = *x+dx*(costrange/MOVE_DIAGONAL_COST); ty = *y+dy*(costrange/MOVE_DIAGONAL_COST); if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) { @@ -1709,16 +1709,24 @@ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, } } //One cell diagonal, rest linear (TODO: Find a better algorithm for this) - else if(dir%2 == 1 && costrange%MOVE_COST == 4) { - tx = *x+dx*((dir%4==3)?(costrange/MOVE_COST):1); - ty = *y+dy*((dir%4==1)?(costrange/MOVE_COST):1); + else if (unit_is_diagonal_dir(dir) && (costrange % MOVE_COST) == 4) { + tx = *x + dx; + ty = *y + dy; + if (unit_is_dir_or_opposite(dir, UNIT_DIR_SOUTHWEST)) + tx *= costrange / MOVE_COST; + if (unit_is_dir_or_opposite(dir, UNIT_DIR_NORTHWEST)) + ty *= costrange / MOVE_COST; if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) { *x = tx; *y = ty; return true; } - tx = *x+dx*((dir%4==1)?(costrange/MOVE_COST):1); - ty = *y+dy*((dir%4==3)?(costrange/MOVE_COST):1); + tx = *x + dx; + ty = *y + dy; + if (unit_is_dir_or_opposite(dir, UNIT_DIR_NORTHWEST)) + tx *= costrange / MOVE_COST; + if (unit_is_dir_or_opposite(dir, UNIT_DIR_SOUTHWEST)) + ty *= costrange / MOVE_COST; if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) { *x = tx; *y = ty; @@ -1727,17 +1735,17 @@ static bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, } //Get next direction - if (dir == 5) { + if (dir == UNIT_DIR_SOUTHEAST) { //Diagonal search complete, repeat with higher cost range if(costrange == 14) costrange += 6; else if(costrange == 28 || costrange >= 38) costrange += 2; else costrange += 4; - dir = 6; - } else if (dir == 4) { + dir = UNIT_DIR_EAST; + } else if (dir == UNIT_DIR_SOUTH) { //Linear search complete, switch to diagonal directions - dir = 7; + dir = UNIT_DIR_NORTHEAST; } else { - dir = (dir+2)%8; + dir = unit_get_ccw90_dir(dir); } } @@ -2845,63 +2853,70 @@ static int map_mapname2ipport(unsigned short name, uint32 *ip, uint16 *port) return 0; } -/*========================================== +/** * Checks if both dirs point in the same direction. - *------------------------------------------*/ -static int map_check_dir(int s_dir, int t_dir) + * @param s_dir: direction source is facing + * @param t_dir: direction target is facing + * @return 0: success(both face the same direction), 1: failure + **/ +static int map_check_dir(enum unit_dir s_dir, enum unit_dir t_dir) { - if(s_dir == t_dir) + if (s_dir == t_dir || ((t_dir + UNIT_DIR_MAX - 1) % UNIT_DIR_MAX) == s_dir + || ((t_dir + UNIT_DIR_MAX + 1) % UNIT_DIR_MAX) == s_dir) return 0; - switch(s_dir) { - case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break; - case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break; - case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break; - case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break; - case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break; - case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break; - case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break; - case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break; - } return 1; } -/*========================================== +/** * Returns the direction of the given cell, relative to 'src' - *------------------------------------------*/ -static uint8 map_calc_dir(struct block_list *src, int16 x, int16 y) + * @param src: object to put in relation between coordinates + * @param x: x-coordinate of cell + * @param y: y-coordinate of cell + * @return the direction of the given cell, relative to 'src' + **/ +static enum unit_dir map_calc_dir(const struct block_list *src, int16 x, int16 y) { - uint8 dir = 0; - int dx, dy; - - nullpo_ret(src); + nullpo_retr(UNIT_DIR_NORTH, src); + enum unit_dir dir = UNIT_DIR_NORTH; - dx = x-src->x; - dy = y-src->y; + int dx = x - src->x; + int dy = y - src->y; if (dx == 0 && dy == 0) { // both are standing on the same spot. // aegis-style, makes knockback default to the left. // athena-style, makes knockback default to behind 'src'. - dir = (battle_config.knockback_left ? 6 : unit->getdir(src)); - } else if (dx >= 0 && dy >=0) { - // upper-right - if( dx*2 < dy || dx == 0 ) dir = 0; // up - else if( dx > dy*2+1 || dy == 0 ) dir = 6; // right - else dir = 7; // up-right + if (battle_config.knockback_left != 0) + dir = UNIT_DIR_EAST; + else + dir = unit->getdir(src); + } else if (dx >= 0 && dy >= 0) { + if (dx * 2 < dy || dx == 0) + dir = UNIT_DIR_NORTH; + else if (dx > dy * 2 + 1 || dy == 0) + dir = UNIT_DIR_EAST; + else + dir = UNIT_DIR_NORTHEAST; } else if (dx >= 0 && dy <= 0) { - // lower-right - if( dx*2 < -dy || dx == 0 ) dir = 4; // down - else if( dx > -dy*2+1 || dy == 0 ) dir = 6; // right - else dir = 5; // down-right + if (dx * 2 < -dy || dx == 0) + dir = UNIT_DIR_SOUTH; + else if (dx > -dy * 2 + 1 || dy == 0) + dir = UNIT_DIR_EAST; + else + dir = UNIT_DIR_SOUTHEAST; } else if (dx <= 0 && dy <= 0) { - // lower-left - if( dx*2 > dy || dx == 0 ) dir = 4; // down - else if( dx < dy*2-1 || dy == 0 ) dir = 2; // left - else dir = 3; // down-left + if (dx * 2 > dy || dx == 0 ) + dir = UNIT_DIR_SOUTH; + else if (dx < dy * 2 + 1 || dy == 0) + dir = UNIT_DIR_WEST; + else + dir = UNIT_DIR_SOUTHWEST; } else { - // upper-left - if( -dx*2 < dy || dx == 0 ) dir = 0; // up - else if( -dx > dy*2+1 || dy == 0) dir = 2; // left - else dir = 1; // up-left + if (-dx * 2 < dy || dx == 0 ) + dir = UNIT_DIR_NORTH; + else if (-dx > dy * 2 + 1 || dy == 0) + dir = UNIT_DIR_WEST; + else + dir = UNIT_DIR_NORTHWEST; } return dir; } @@ -2929,11 +2944,11 @@ static int map_random_dir(struct block_list *bl, int16 *x, int16 *y) if (dist < 1) dist =1; do { - int j = 1 + 2*(rnd()%4); //Pick a random diagonal direction + enum unit_dir dir = unit_get_rnd_diagonal_dir(); short segment = 1+(rnd()%dist); //Pick a random interval from the whole vector in that direction - xi = bl->x + segment*dirx[j]; + xi = bl->x + segment * dirx[dir]; segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment - yi = bl->y + segment*diry[j]; + yi = bl->y + segment * diry[dir]; } while ((map->getcell(bl->m, bl, xi, yi, CELL_CHKNOPASS) || !path->search(NULL, bl, bl->m, bl->x, bl->y, xi, yi, 1, CELL_CHKNOREACH)) && (++i)<100); diff --git a/src/map/map.h b/src/map/map.h index dbd9c0fba..a876539d0 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -27,6 +27,7 @@ #include "common/db.h" #include "common/mapindex.h" #include "common/mmo.h" +#include "map/unitdefines.h" // enum unit_dir #include <stdio.h> #include <stdarg.h> @@ -1216,8 +1217,8 @@ END_ZEROED_BLOCK; // reload config file looking only for npcs void (*reloadnpc) (bool clear); - int (*check_dir) (int s_dir,int t_dir); - uint8 (*calc_dir) (struct block_list *src,int16 x,int16 y); + int (*check_dir) (enum unit_dir s_dir, enum unit_dir t_dir); + enum unit_dir (*calc_dir) (const struct block_list *src, int16 x, int16 y); int (*random_dir) (struct block_list *bl, short *x, short *y); // [Skotlex] int (*cleanup_sub) (struct block_list *bl, va_list ap); diff --git a/src/map/mapdefines.h b/src/map/mapdefines.h index f5a8149d4..8a363e2d4 100644 --- a/src/map/mapdefines.h +++ b/src/map/mapdefines.h @@ -30,7 +30,15 @@ #define DAMAGELOG_SIZE 30 #define LOOTITEM_SIZE 10 #define MAX_MOBSKILL 50 + +#ifndef MAX_MOB_LIST_PER_MAP +#ifdef RENEWAL #define MAX_MOB_LIST_PER_MAP 100 +#else +#define MAX_MOB_LIST_PER_MAP 115 +#endif +#endif + #define MAX_EVENTQUEUE 2 #define MAX_EVENTTIMER 32 #define NATURAL_HEAL_INTERVAL 500 diff --git a/src/map/messages_main.h b/src/map/messages_main.h index 6fc0310e7..9f5a17662 100644 --- a/src/map/messages_main.h +++ b/src/map/messages_main.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ /* This file is autogenerated, please do not commit manual changes -Latest version: 20200129 +Latest version: 20200304 */ enum clif_messages { @@ -22521,6 +22521,97 @@ Search */ MSG_ID_ECE = 0xece, #endif +#if PACKETVER >= 20200212 +/*20200212 to latest +합주를 혼자 사용할 수 있습니다. +*/ + MSG_ID_ECF = 0xecf, +/*20200212 to latest +크바시르의 지혜가 사라집니다. +*/ + MSG_ID_ED0 = 0xed0, +/*20200212 to latest +미스틱 심포니의 효과가 부여됩니다. +*/ + MSG_ID_ED1 = 0xed1, +/*20200212 to latest +미스틱 심포니의 효과가 사라집니다. +*/ + MSG_ID_ED2 = 0xed2, +/*20200212 to latest +마법 저항력이 감소했습니다. +*/ + MSG_ID_ED3 = 0xed3, +/*20200212 to latest +게페니아 녹턴의 효과가 해제 되었습니다. +*/ + MSG_ID_ED4 = 0xed4, +/*20200212 to latest +물리 저항력이 감소했습니다. +*/ + MSG_ID_ED5 = 0xed5, +/*20200212 to latest +마인워커 랩소디 상태가 해제되었습니다. +*/ + MSG_ID_ED6 = 0xed6, +/*20200212 to latest +물리 저항력이 증가했습니다. +*/ + MSG_ID_ED7 = 0xed7, +/*20200212 to latest +뮤지컬 인터루드 상태가 해제되었습니다. +*/ + MSG_ID_ED8 = 0xed8, +/*20200212 to latest +특성 마법 공격력과 이동 속도가 증가합니다. +*/ + MSG_ID_ED9 = 0xed9, +/*20200212 to latest +저녁 노을의 세레나데 효과가 해제되었습니다. +*/ + MSG_ID_EDA = 0xeda, +/*20200212 to latest +특성 물리 공격력과 이동 속도가 증가합니다. +*/ + MSG_ID_EDB = 0xedb, +/*20200212 to latest + 프론테라의 행진곡 효과가 해제되었습니다. +*/ + MSG_ID_EDC = 0xedc, +/*20200212 to latest +바람의 분노가 시전자에게 흘러 들어옵니다. +*/ + MSG_ID_EDD = 0xedd, +/*20200212 to latest +캘러미티 가일 상태가 해제되었습니다. +*/ + MSG_ID_EDE = 0xede, +/*20200212 to latest +바람에 의해 약점과 모습이 드러납니다. +*/ + MSG_ID_EDF = 0xedf, +/*20200212 to latest +윈드 사인 효과가 사라집니다. +*/ + MSG_ID_EE0 = 0xee0, +#endif +#if PACKETVER >= 20200304 +/*20200304 to latest +E X P : %.1f%% ( basic 100.0%% %s %.1f%%) +EXP: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE1 = 0xee1, +/*20200304 to latest +DROP : %.1f%% ( basic 100.0%% %s %.1f%%) +DROP: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE2 = 0xee2, +/*20200304 to latest +DEATH : %.1f%% ( basic 100.0%% %s %.1f%%) +DEATH: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE3 = 0xee3, +#endif }; #endif /* MAP_MESSAGES_MAIN_H */ diff --git a/src/map/messages_re.h b/src/map/messages_re.h index f4cc62d68..e32f6b275 100644 --- a/src/map/messages_re.h +++ b/src/map/messages_re.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ /* This file is autogenerated, please do not commit manual changes -Latest version: 20200205 +Latest version: 20200304 */ enum clif_messages { @@ -21998,6 +21998,97 @@ Search */ MSG_ID_ECE = 0xece, #endif +#if PACKETVER >= 20200212 +/*20200212 to latest +합주를 혼자 사용할 수 있습니다. +*/ + MSG_ID_ECF = 0xecf, +/*20200212 to latest +크바시르의 지혜가 사라집니다. +*/ + MSG_ID_ED0 = 0xed0, +/*20200212 to latest +미스틱 심포니의 효과가 부여됩니다. +*/ + MSG_ID_ED1 = 0xed1, +/*20200212 to latest +미스틱 심포니의 효과가 사라집니다. +*/ + MSG_ID_ED2 = 0xed2, +/*20200212 to latest +마법 저항력이 감소했습니다. +*/ + MSG_ID_ED3 = 0xed3, +/*20200212 to latest +게페니아 녹턴의 효과가 해제 되었습니다. +*/ + MSG_ID_ED4 = 0xed4, +/*20200212 to latest +물리 저항력이 감소했습니다. +*/ + MSG_ID_ED5 = 0xed5, +/*20200212 to latest +마인워커 랩소디 상태가 해제되었습니다. +*/ + MSG_ID_ED6 = 0xed6, +/*20200212 to latest +물리 저항력이 증가했습니다. +*/ + MSG_ID_ED7 = 0xed7, +/*20200212 to latest +뮤지컬 인터루드 상태가 해제되었습니다. +*/ + MSG_ID_ED8 = 0xed8, +/*20200212 to latest +특성 마법 공격력과 이동 속도가 증가합니다. +*/ + MSG_ID_ED9 = 0xed9, +/*20200212 to latest +저녁 노을의 세레나데 효과가 해제되었습니다. +*/ + MSG_ID_EDA = 0xeda, +/*20200212 to latest +특성 물리 공격력과 이동 속도가 증가합니다. +*/ + MSG_ID_EDB = 0xedb, +/*20200212 to latest + 프론테라의 행진곡 효과가 해제되었습니다. +*/ + MSG_ID_EDC = 0xedc, +/*20200212 to latest +바람의 분노가 시전자에게 흘러 들어옵니다. +*/ + MSG_ID_EDD = 0xedd, +/*20200212 to latest +캘러미티 가일 상태가 해제되었습니다. +*/ + MSG_ID_EDE = 0xede, +/*20200212 to latest +바람에 의해 약점과 모습이 드러납니다. +*/ + MSG_ID_EDF = 0xedf, +/*20200212 to latest +윈드 사인 효과가 사라집니다. +*/ + MSG_ID_EE0 = 0xee0, +#endif +#if PACKETVER >= 20200304 +/*20200304 to latest +E X P : %.1f%% ( basic 100.0%% %s %.1f%%) +EXP: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE1 = 0xee1, +/*20200304 to latest +DROP : %.1f%% ( basic 100.0%% %s %.1f%%) +DROP: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE2 = 0xee2, +/*20200304 to latest +DEATH : %.1f%% ( basic 100.0%% %s %.1f%%) +DEATH: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE3 = 0xee3, +#endif }; #endif /* MAP_MESSAGES_RE_H */ diff --git a/src/map/messages_zero.h b/src/map/messages_zero.h index 55c0329ee..babe9384c 100644 --- a/src/map/messages_zero.h +++ b/src/map/messages_zero.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ /* This file is autogenerated, please do not commit manual changes -Latest version: 20200129 +Latest version: 20200304 */ enum clif_messages { @@ -18605,6 +18605,102 @@ Search */ MSG_ID_ECD = 0xecd, #endif +#if PACKETVER >= 20200212 +/*20200212 to latest +검색 +Search +*/ + MSG_ID_ECE = 0xece, +/*20200212 to latest +합주를 혼자 사용할 수 있습니다. +*/ + MSG_ID_ECF = 0xecf, +/*20200212 to latest +크바시르의 지혜가 사라집니다. +*/ + MSG_ID_ED0 = 0xed0, +/*20200212 to latest +미스틱 심포니의 효과가 부여됩니다. +*/ + MSG_ID_ED1 = 0xed1, +/*20200212 to latest +미스틱 심포니의 효과가 사라집니다. +*/ + MSG_ID_ED2 = 0xed2, +/*20200212 to latest +마법 저항력이 감소했습니다. +*/ + MSG_ID_ED3 = 0xed3, +/*20200212 to latest +게페니아 녹턴의 효과가 해제 되었습니다. +*/ + MSG_ID_ED4 = 0xed4, +/*20200212 to latest +물리 저항력이 감소했습니다. +*/ + MSG_ID_ED5 = 0xed5, +/*20200212 to latest +마인워커 랩소디 상태가 해제되었습니다. +*/ + MSG_ID_ED6 = 0xed6, +/*20200212 to latest +물리 저항력이 증가했습니다. +*/ + MSG_ID_ED7 = 0xed7, +/*20200212 to latest +뮤지컬 인터루드 상태가 해제되었습니다. +*/ + MSG_ID_ED8 = 0xed8, +/*20200212 to latest +특성 마법 공격력과 이동 속도가 증가합니다. +*/ + MSG_ID_ED9 = 0xed9, +/*20200212 to latest +저녁 노을의 세레나데 효과가 해제되었습니다. +*/ + MSG_ID_EDA = 0xeda, +/*20200212 to latest +특성 물리 공격력과 이동 속도가 증가합니다. +*/ + MSG_ID_EDB = 0xedb, +/*20200212 to latest + 프론테라의 행진곡 효과가 해제되었습니다. +*/ + MSG_ID_EDC = 0xedc, +/*20200212 to latest +바람의 분노가 시전자에게 흘러 들어옵니다. +*/ + MSG_ID_EDD = 0xedd, +/*20200212 to latest +캘러미티 가일 상태가 해제되었습니다. +*/ + MSG_ID_EDE = 0xede, +/*20200212 to latest +바람에 의해 약점과 모습이 드러납니다. +*/ + MSG_ID_EDF = 0xedf, +/*20200212 to latest +윈드 사인 효과가 사라집니다. +*/ + MSG_ID_EE0 = 0xee0, +#endif +#if PACKETVER >= 20200304 +/*20200304 to latest +E X P : %.1f%% ( basic 100.0%% %s %.1f%%) +EXP: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE1 = 0xee1, +/*20200304 to latest +DROP : %.1f%% ( basic 100.0%% %s %.1f%%) +DROP: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE2 = 0xee2, +/*20200304 to latest +DEATH : %.1f%% ( basic 100.0%% %s %.1f%%) +DEATH: %.1f%% (basic: 100.0%%, %s: %.1f%%) +*/ + MSG_ID_EE3 = 0xee3, +#endif }; #endif /* MAP_MESSAGES_ZERO_H */ diff --git a/src/map/mob.c b/src/map/mob.c index 0830e5a5a..51a32abd9 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1462,7 +1462,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick) // If master is BL_MOB and in battle, lock & chase to master's target instead, unless configured not to. if ((battle_config.slave_chase_masters_chasetarget == 0 || (m_md != NULL && !mob->is_in_battle_state(m_md))) && map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) - && unit->walktoxy(&md->bl, x, y, 0)) + && unit->walk_toxy(&md->bl, x, y, 0) == 0) return 1; } } else if (bl->m != md->bl.m && map_flag_gvg(md->bl.m)) { @@ -1544,7 +1544,7 @@ static int mob_unlocktarget(struct mob_data *md, int64 tick) unit->set_target(&md->ud, 0); } if(battle_config.official_cell_stack_limit && map->count_oncell(md->bl.m, md->bl.x, md->bl.y, BL_CHAR|BL_NPC, 0x1 | 0x2) > battle_config.official_cell_stack_limit) { - unit->walktoxy(&md->bl, md->bl.x, md->bl.y, 8); + unit->walk_toxy(&md->bl, md->bl.x, md->bl.y, 8); } return 0; @@ -1576,9 +1576,9 @@ static int mob_randomwalk(struct mob_data *md, int64 tick) x+=md->bl.x; y+=md->bl.y; - if (((x != md->bl.x) || (y != md->bl.y)) && map->getcell(md->bl.m, &md->bl, x, y, CELL_CHKPASS) && unit->walktoxy(&md->bl, x, y, 8)) { + if ((x != md->bl.x || y != md->bl.y) && map->getcell(md->bl.m, &md->bl, x, y, CELL_CHKPASS) != 0 + && unit->walk_toxy(&md->bl, x, y, 8) == 0) break; - } } if(i==retrycount){ md->move_fail_count++; diff --git a/src/map/npc.c b/src/map/npc.c index e66888a74..2ac99948b 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3391,7 +3391,7 @@ static bool npc_viewisid(const char *viewid) * @param class_ The NPC view class. * @return A pointer to the created NPC data (ownership passed to the caller). */ -static struct npc_data *npc_create_npc(enum npc_subtype subtype, int m, int x, int y, uint8 dir, int class_) +static struct npc_data *npc_create_npc(enum npc_subtype subtype, int m, int x, int y, enum unit_dir dir, int class_) { struct npc_data *nd; diff --git a/src/map/npc.h b/src/map/npc.h index 65c9796d9..1585a2bc8 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -95,7 +95,7 @@ struct npc_data { int chat_id; int touching_id; int64 next_walktime; - uint8 dir; + enum unit_dir dir; uint8 area_size; int clan_id; @@ -281,7 +281,7 @@ struct npc_interface { void (*parsename) (struct npc_data *nd, const char *name, const char *start, const char *buffer, const char *filepath); int (*parseview) (const char *w4, const char *start, const char *buffer, const char *filepath); bool (*viewisid) (const char *viewid); - struct npc_data *(*create_npc) (enum npc_subtype subtype, int m, int x, int y, uint8 dir, int class_); + struct npc_data *(*create_npc) (enum npc_subtype subtype, int m, int x, int y, enum unit_dir dir, int class_); struct npc_data* (*add_warp) (char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); const char *(*parse_warp) (const char *w1, const char *w2, const char *w3, const char *w4, const char *start, const char *buffer, const char *filepath, int *retval); const char *(*parse_shop) (const char *w1, const char *w2, const char *w3, const char *w4, const char *start, const char *buffer, const char *filepath, int *retval); diff --git a/src/map/packets_keys_main.h b/src/map/packets_keys_main.h index a72d9bf5f..5fddf9eaf 100644 --- a/src/map/packets_keys_main.h +++ b/src/map/packets_keys_main.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ packetKeys(0x49357d72,0x22c370a1,0x5f836591); #endif -// 2010-11-23aRagexeRE, 2010-11-24aRagexeRE, 2010-11-24bRagexeRE, 2010-11-25aRagexeRE, 2010-11-26aRagexeRE, 2010-11-30aRagexeRE, 2010-12-07aRagexeRE, 2010-12-14aRagexeRE, 2010-12-21aRagexeRE, 2010-12-23aRagexeRE, 2010-12-28aRagexeRE, 2011-01-04aRagexeRE, 2011-01-05aRagexeRE, 2011-01-11aRagexeRE, 2011-01-18aRagexeRE, 2011-01-25aRagexeRE, 2011-01-26aRagexeRE, 2011-01-26bRagexeRE, 2011-01-31aRagexeRE, 2011-01-31bRagexeRE, 2011-01-31cRagexeRE, 2011-02-08aRagexeRE, 2011-02-15aRagexeRE, 2011-02-22aRagexeRE, 2011-02-23aRagexeRE, 2011-02-23bRagexeRE, 2011-02-24aRagexeRE, 2011-02-25aRagexeRE, 2011-02-28aRagexeRE, 2011-03-08aRagexeRE, 2011-03-09aRagexeRE, 2011-03-09bRagexeRE, 2011-03-09cRagexeRE, 2011-03-09dRagexeRE, 2011-03-15aRagexeRE, 2011-03-22aRagexeRE, 2011-03-29aRagexeRE, 2011-03-30aRagexeRE, 2011-03-30cRagexeRE, 2011-04-05aRagexeRE, 2011-04-12aRagexeRE, 2011-04-19aRagexeRE, 2011-04-20aRagexeRE, 2011-04-26aRagexeRE, 2011-04-27aRagexeRE, 2011-05-03aRagexeRE, 2011-05-11aRagexeRE, 2011-05-17bRagexeRE, 2011-05-24aRagexeRE, 2011-05-26aRagexeRE, 2011-05-31aRagexeRE, 2011-06-07aRagexeRE, 2011-06-08aRagexeRE, 2011-06-08bRagexeRE, 2011-06-08cRagexeRE, 2011-06-09aRagexeRE, 2011-06-14bRagexeRE, 2011-06-22aRagexeRE, 2011-06-28aRagexeRE, 2011-07-06aRagexeRE, 2011-07-13aRagexeRE, 2011-07-13bRagexeRE, 2011-07-13cRagexeRE, 2011-07-19aRagexeRE, 2011-07-26aRagexeRE, 2011-08-03aRagexeRE, 2011-08-03bRagexeRE, 2011-08-10aRagexeRE, 2013-12-23aRagexeRE, 2014-05-08aRagexe, 2014-05-08aRagexeRE, 2014-06-11eRagexe, 2015-02-25hRagexe, 2018-03-15aRagexe, 2018-03-21aRagexe, 2018-03-21aRagexeRE, 2018-03-28bRagexe, 2018-03-28bRagexeRE, 2018-04-04bRagexe, 2018-04-04cRagexeRE, 2018-04-18aRagexe, 2018-04-18bRagexeRE, 2018-04-25cRagexe, 2018-04-25cRagexeRE, 2018-05-02bRagexe, 2018-05-02bRagexeRE, 2018-05-02dRagexeRE, 2018-05-09aRagexe, 2018-05-16cRagexe, 2018-05-16cRagexeRE, 2018-05-23aRagexe, 2018-05-23aRagexeRE, 2018-05-30aRagexe, 2018-05-30bRagexeRE, 2018-05-30cRagexeRE, 2018-06-05bRagexe, 2018-06-05bRagexeRE, 2018-06-12aRagexeRE, 2018-06-12bRagexeRE, 2018-06-20cRagexe, 2018-06-20dRagexeRE, 2018-06-20eRagexe, 2018-06-20eRagexeRE, 2018-06-21aRagexe, 2018-06-21aRagexeRE, 2018-07-04aRagexe, 2018-07-04aRagexeRE, 2018-07-11aRagexeRE, 2018-07-18bRagexe, 2018-07-18bRagexeRE, 2018-07-18bRagexeRE1, 2018-07-18cRagexe, 2018-07-18cRagexeRE, 2018-08-01cRagexe, 2018-08-01cRagexeRE, 2018-08-08bRagexe, 2018-08-08bRagexeRE, 2018-08-22cRagexe, 2018-08-22cRagexeRE, 2018-08-29aRagexe, 2018-08-29aRagexeRE, 2018-08-29bRagexeRE, 2018-08-31aRagexe, 2018-09-12dRagexe, 2018-09-12dRagexeRE, 2018-09-19aRagexe, 2018-09-19aRagexeRE, 2018-10-02aRagexe, 2018-10-02aRagexeRE, 2018-10-02bRagexe, 2018-10-02bRagexeRE, 2018-10-17_02aRagexe, 2018-10-17_02aRagexeRE, 2018-10-17_03aRagexe, 2018-10-17_03aRagexeRE, 2018-10-17bRagexe, 2018-10-17bRagexeRE, 2018-10-24bRagexe, 2018-10-31aRagexe, 2018-10-31bRagexe, 2018-10-31cRagexeRE, 2018-11-07aRagexe, 2018-11-07aRagexeRE, 2018-11-14cRagexe, 2018-11-14cRagexeRE, 2018-11-14dRagexe, 2018-11-14dRagexeRE, 2018-11-21bRagexe, 2018-11-21cRagexeRE, 2018-11-28aRagexe, 2018-11-28aRagexeRE, 2018-11-28bRagexe, 2018-11-28cRagexe, 2018-12-05aRagexe, 2018-12-05bRagexeRE, 2018-12-12aRagexe, 2018-12-12aRagexeRE, 2018-12-12bRagexe, 2018-12-12bRagexeRE, 2018-12-19bRagexe, 2018-12-19bRagexeRE, 2018-12-26aRagexe, 2018-12-26aRagexeRE, 2019-01-09aRagexe, 2019-01-09bRagexeRE, 2019-01-16bRagexe, 2019-01-16bRagexeRE, 2019-01-16cRagexe, 2019-01-16cRagexeRE, 2019-01-23dRagexe, 2019-01-23dRagexeRE, 2019-02-13IRagexeRE, 2019-02-13bRagexe, 2019-02-13eRagexe, 2019-02-20aRagexeRE, 2019-02-27aRagexe, 2019-02-27bRagexeRE, 2019-02-28aRagexe, 2019-02-28aRagexeRE, 2019-03-06bRagexe, 2019-03-06bRagexeRE, 2019-03-06cRagexe, 2019-03-06cRagexeRE, 2019-03-13aRagexe, 2019-03-20aRagexe, 2019-03-20aRagexeRE, 2019-03-22aRagexe, 2019-03-22aRagexeRE, 2019-03-27bRagexe, 2019-03-27bRagexeRE, 2019-04-03aRagexe, 2019-04-03bRagexeRE, 2019-04-03cRagexeRE, 2019-04-17aRagexe, 2019-04-17cRagexeRE, 2019-04-18aRagexe, 2019-04-18aRagexeRE, 2019-05-08cRagexe, 2019-05-08dRagexeRE, 2019-05-08eRagexeRE, 2019-05-22bRagexe, 2019-05-22bRagexeRE, 2019-05-22cRagexe, 2019-05-22cRagexeRE, 2019-05-23aRagexe, 2019-05-29aRagexe, 2019-05-29bRagexeRE, 2019-05-29cRagexe, 2019-05-29cRagexeRE, 2019-05-30aRagexe, 2019-05-30aRagexeRE, 2019-06-05JRagexeRE, 2019-06-05KRagexe, 2019-06-05LRagexeRE, 2019-06-05fRagexe, 2019-06-05hRagexeRE, 2019-06-19bRagexe, 2019-06-19cRagexeRE, 2019-06-19eRagexe, 2019-06-19hRagexe, 2019-06-26bRagexeRE, 2019-07-03aRagexe, 2019-07-03bRagexeRE, 2019-07-17aRagexe, 2019-07-17cRagexeRE, 2019-07-17dRagexe, 2019-07-17dRagexeRE, 2019-07-24aRagexe, 2019-07-24bRagexeRE, 2019-07-31bRagexe, 2019-07-31bRagexeRE, 2019-08-02aRagexe, 2019-08-02aRagexeRE, 2019-08-07aRagexe, 2019-08-07dRagexeRE, 2019-08-21aRagexe, 2019-08-21cRagexeRE, 2019-08-21dRagexeRE, 2019-08-28aRagexe, 2019-08-28aRagexeRE, 2019-09-04aRagexe, 2019-09-04bRagexe, 2019-09-04bRagexeRE, 2019-09-18bRagexe, 2019-09-18cRagexeRE, 2019-09-25aRagexe, 2019-09-25aRagexeRE, 2019-09-25bRagexe, 2019-09-25bRagexeRE, 2019-10-02bRagexeRE, 2019-10-02cRagexe, 2019-10-02dRagexe, 2019-10-02dRagexeRE, 2019-10-02dRagexeRE_2, 2019-10-16fRagexe, 2019-10-16fRagexeRE, 2019-10-16gRagexe, 2019-10-16gRagexeRE, 2019-10-18aRagexe, 2019-10-23aRagexe, 2019-10-23aRagexeRE, 2019-10-30bRagexeRE, 2019-10-30cRagexe, 2019-11-06aRagexe, 2019-11-06bRagexeRE, 2019-11-07aRagexe, 2019-11-07aRagexeRE, 2019-11-13cRagexe, 2019-11-13eRagexe, 2019-11-13eRagexeRE, 2019-11-20aRagexe, 2019-11-20cRagexeRE, 2019-11-20dRagexe, 2019-11-27aRagexe, 2019-11-27aRagexeRE, 2019-11-27bRagexe, 2019-12-04aRagexe, 2019-12-04aRagexeRE, 2019-12-04bRagexe, 2019-12-04bRagexeRE, 2019-12-04cRagexeRE, 2019-12-11aRagexe, 2019-12-11fRagexeRE, 2019-12-18bRagexe, 2019-12-18bRagexeRE, 2019-12-24aRagexe, 2019-12-24aRagexeRE, 2019-12-24bRagexe, 2019-12-24bRagexeRE, 2020-01-08aRagexe, 2020-01-08bRagexeRE, 2020-01-22cRagexe, 2020-01-22cRagexeRE, 2020-01-29bRagexe, 2020-01-30aRagexe, 2020-02-05aRagexe, 2020-02-05aRagexeRE, 2020-02-06aRagexe +// 2010-11-23aRagexeRE, 2010-11-24aRagexeRE, 2010-11-24bRagexeRE, 2010-11-25aRagexeRE, 2010-11-26aRagexeRE, 2010-11-30aRagexeRE, 2010-12-07aRagexeRE, 2010-12-14aRagexeRE, 2010-12-21aRagexeRE, 2010-12-23aRagexeRE, 2010-12-28aRagexeRE, 2011-01-04aRagexeRE, 2011-01-05aRagexeRE, 2011-01-11aRagexeRE, 2011-01-18aRagexeRE, 2011-01-25aRagexeRE, 2011-01-26aRagexeRE, 2011-01-26bRagexeRE, 2011-01-31aRagexeRE, 2011-01-31bRagexeRE, 2011-01-31cRagexeRE, 2011-02-08aRagexeRE, 2011-02-15aRagexeRE, 2011-02-22aRagexeRE, 2011-02-23aRagexeRE, 2011-02-23bRagexeRE, 2011-02-24aRagexeRE, 2011-02-25aRagexeRE, 2011-02-28aRagexeRE, 2011-03-08aRagexeRE, 2011-03-09aRagexeRE, 2011-03-09bRagexeRE, 2011-03-09cRagexeRE, 2011-03-09dRagexeRE, 2011-03-15aRagexeRE, 2011-03-22aRagexeRE, 2011-03-29aRagexeRE, 2011-03-30aRagexeRE, 2011-03-30cRagexeRE, 2011-04-05aRagexeRE, 2011-04-12aRagexeRE, 2011-04-19aRagexeRE, 2011-04-20aRagexeRE, 2011-04-26aRagexeRE, 2011-04-27aRagexeRE, 2011-05-03aRagexeRE, 2011-05-11aRagexeRE, 2011-05-17bRagexeRE, 2011-05-24aRagexeRE, 2011-05-26aRagexeRE, 2011-05-31aRagexeRE, 2011-06-07aRagexeRE, 2011-06-08aRagexeRE, 2011-06-08bRagexeRE, 2011-06-08cRagexeRE, 2011-06-09aRagexeRE, 2011-06-14bRagexeRE, 2011-06-22aRagexeRE, 2011-06-28aRagexeRE, 2011-07-06aRagexeRE, 2011-07-13aRagexeRE, 2011-07-13bRagexeRE, 2011-07-13cRagexeRE, 2011-07-19aRagexeRE, 2011-07-26aRagexeRE, 2011-08-03aRagexeRE, 2011-08-03bRagexeRE, 2011-08-10aRagexeRE, 2013-12-23aRagexeRE, 2014-05-08aRagexe, 2014-05-08aRagexeRE, 2014-06-11eRagexe, 2015-02-25hRagexe, 2018-03-15aRagexe, 2018-03-21aRagexe, 2018-03-21aRagexeRE, 2018-03-28bRagexe, 2018-03-28bRagexeRE, 2018-04-04bRagexe, 2018-04-04cRagexeRE, 2018-04-18aRagexe, 2018-04-18bRagexeRE, 2018-04-25cRagexe, 2018-04-25cRagexeRE, 2018-05-02bRagexe, 2018-05-02bRagexeRE, 2018-05-02dRagexeRE, 2018-05-09aRagexe, 2018-05-16cRagexe, 2018-05-16cRagexeRE, 2018-05-23aRagexe, 2018-05-23aRagexeRE, 2018-05-30aRagexe, 2018-05-30bRagexeRE, 2018-05-30cRagexeRE, 2018-06-05bRagexe, 2018-06-05bRagexeRE, 2018-06-12aRagexeRE, 2018-06-12bRagexeRE, 2018-06-20cRagexe, 2018-06-20dRagexeRE, 2018-06-20eRagexe, 2018-06-20eRagexeRE, 2018-06-21aRagexe, 2018-06-21aRagexeRE, 2018-07-04aRagexe, 2018-07-04aRagexeRE, 2018-07-11aRagexeRE, 2018-07-18bRagexe, 2018-07-18bRagexeRE, 2018-07-18bRagexeRE1, 2018-07-18cRagexe, 2018-07-18cRagexeRE, 2018-08-01cRagexe, 2018-08-01cRagexeRE, 2018-08-08bRagexe, 2018-08-08bRagexeRE, 2018-08-22cRagexe, 2018-08-22cRagexeRE, 2018-08-29aRagexe, 2018-08-29aRagexeRE, 2018-08-29bRagexeRE, 2018-08-31aRagexe, 2018-09-12dRagexe, 2018-09-12dRagexeRE, 2018-09-19aRagexe, 2018-09-19aRagexeRE, 2018-10-02aRagexe, 2018-10-02aRagexeRE, 2018-10-02bRagexe, 2018-10-02bRagexeRE, 2018-10-17_02aRagexe, 2018-10-17_02aRagexeRE, 2018-10-17_03aRagexe, 2018-10-17_03aRagexeRE, 2018-10-17bRagexe, 2018-10-17bRagexeRE, 2018-10-24bRagexe, 2018-10-31aRagexe, 2018-10-31bRagexe, 2018-10-31cRagexeRE, 2018-11-07aRagexe, 2018-11-07aRagexeRE, 2018-11-14cRagexe, 2018-11-14cRagexeRE, 2018-11-14dRagexe, 2018-11-14dRagexeRE, 2018-11-21bRagexe, 2018-11-21cRagexeRE, 2018-11-28aRagexe, 2018-11-28aRagexeRE, 2018-11-28bRagexe, 2018-11-28cRagexe, 2018-12-05aRagexe, 2018-12-05bRagexeRE, 2018-12-12aRagexe, 2018-12-12aRagexeRE, 2018-12-12bRagexe, 2018-12-12bRagexeRE, 2018-12-19bRagexe, 2018-12-19bRagexeRE, 2018-12-26aRagexe, 2018-12-26aRagexeRE, 2019-01-09aRagexe, 2019-01-09bRagexeRE, 2019-01-16bRagexe, 2019-01-16bRagexeRE, 2019-01-16cRagexe, 2019-01-16cRagexeRE, 2019-01-23dRagexe, 2019-01-23dRagexeRE, 2019-02-13IRagexeRE, 2019-02-13bRagexe, 2019-02-13eRagexe, 2019-02-20aRagexeRE, 2019-02-27aRagexe, 2019-02-27bRagexeRE, 2019-02-28aRagexe, 2019-02-28aRagexeRE, 2019-03-06bRagexe, 2019-03-06bRagexeRE, 2019-03-06cRagexe, 2019-03-06cRagexeRE, 2019-03-13aRagexe, 2019-03-20aRagexe, 2019-03-20aRagexeRE, 2019-03-22aRagexe, 2019-03-22aRagexeRE, 2019-03-27bRagexe, 2019-03-27bRagexeRE, 2019-04-03aRagexe, 2019-04-03bRagexeRE, 2019-04-03cRagexeRE, 2019-04-17aRagexe, 2019-04-17cRagexeRE, 2019-04-18aRagexe, 2019-04-18aRagexeRE, 2019-05-08cRagexe, 2019-05-08dRagexeRE, 2019-05-08eRagexeRE, 2019-05-22bRagexe, 2019-05-22bRagexeRE, 2019-05-22cRagexe, 2019-05-22cRagexeRE, 2019-05-23aRagexe, 2019-05-29aRagexe, 2019-05-29bRagexeRE, 2019-05-29cRagexe, 2019-05-29cRagexeRE, 2019-05-30aRagexe, 2019-05-30aRagexeRE, 2019-06-05JRagexeRE, 2019-06-05KRagexe, 2019-06-05LRagexeRE, 2019-06-05fRagexe, 2019-06-05hRagexeRE, 2019-06-19bRagexe, 2019-06-19cRagexeRE, 2019-06-19eRagexe, 2019-06-19hRagexe, 2019-06-26bRagexeRE, 2019-07-03aRagexe, 2019-07-03bRagexeRE, 2019-07-17aRagexe, 2019-07-17cRagexeRE, 2019-07-17dRagexe, 2019-07-17dRagexeRE, 2019-07-24aRagexe, 2019-07-24bRagexeRE, 2019-07-31bRagexe, 2019-07-31bRagexeRE, 2019-08-02aRagexe, 2019-08-02aRagexeRE, 2019-08-07aRagexe, 2019-08-07dRagexeRE, 2019-08-21aRagexe, 2019-08-21cRagexeRE, 2019-08-21dRagexeRE, 2019-08-28aRagexe, 2019-08-28aRagexeRE, 2019-09-04aRagexe, 2019-09-04bRagexe, 2019-09-04bRagexeRE, 2019-09-18bRagexe, 2019-09-18cRagexeRE, 2019-09-25aRagexe, 2019-09-25aRagexeRE, 2019-09-25bRagexe, 2019-09-25bRagexeRE, 2019-10-02bRagexeRE, 2019-10-02cRagexe, 2019-10-02dRagexe, 2019-10-02dRagexeRE, 2019-10-02dRagexeRE_2, 2019-10-16fRagexe, 2019-10-16fRagexeRE, 2019-10-16gRagexe, 2019-10-16gRagexeRE, 2019-10-18aRagexe, 2019-10-23aRagexe, 2019-10-23aRagexeRE, 2019-10-30bRagexeRE, 2019-10-30cRagexe, 2019-11-06aRagexe, 2019-11-06bRagexeRE, 2019-11-07aRagexe, 2019-11-07aRagexeRE, 2019-11-13cRagexe, 2019-11-13eRagexe, 2019-11-13eRagexeRE, 2019-11-20aRagexe, 2019-11-20cRagexeRE, 2019-11-20dRagexe, 2019-11-27aRagexe, 2019-11-27aRagexeRE, 2019-11-27bRagexe, 2019-12-04aRagexe, 2019-12-04aRagexeRE, 2019-12-04bRagexe, 2019-12-04bRagexeRE, 2019-12-04cRagexeRE, 2019-12-11aRagexe, 2019-12-11fRagexeRE, 2019-12-18bRagexe, 2019-12-18bRagexeRE, 2019-12-24aRagexe, 2019-12-24aRagexeRE, 2019-12-24bRagexe, 2019-12-24bRagexeRE, 2020-01-08aRagexe, 2020-01-08bRagexeRE, 2020-01-22cRagexe, 2020-01-22cRagexeRE, 2020-01-29bRagexe, 2020-01-30aRagexe, 2020-02-05aRagexe, 2020-02-05aRagexeRE, 2020-02-06aRagexe, 2020-02-12aRagexe, 2020-02-12aRagexeRE, 2020-02-19dRagexe, 2020-02-19eRagexeRE, 2020-03-04aRagexe, 2020-03-04aRagexeRE #if PACKETVER == 20101123 || \ PACKETVER == 20101124 || \ PACKETVER == 20101125 || \ @@ -186,7 +186,10 @@ PACKETVER == 20200129 || \ PACKETVER == 20200130 || \ PACKETVER == 20200205 || \ - PACKETVER >= 20200206 + PACKETVER == 20200206 || \ + PACKETVER == 20200212 || \ + PACKETVER == 20200219 || \ + PACKETVER >= 20200304 packetKeys(0x00000000,0x00000000,0x00000000); #endif diff --git a/src/map/packets_keys_zero.h b/src/map/packets_keys_zero.h index 90d226c92..facf0e151 100644 --- a/src/map/packets_keys_zero.h +++ b/src/map/packets_keys_zero.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ /* This file is autogenerated, please do not commit manual changes */ -// 2017-10-18aRagexe_zero, 2017-10-19aRagexe_zero, 2017-10-23aRagexe_zero, 2017-10-23bRagexe_zero, 2017-10-23cRagexe_zero, 2017-10-24aRagexe_2_zero, 2017-10-24aRagexe_zero, 2017-10-25bRagexe_zero, 2017-10-27aRagexe_zero, 2017-10-27bRagexe_zero, 2017-10-30aRagexe_zero, 2017-10-31aRagexe_zero, 2017-11-09aRagexe_zero, 2017-11-13aRagexe_zero, 2017-11-13bRagexe_zero, 2018-03-15aRagexe_zero, 2018-03-21aRagexe_zero, 2018-03-21bRagexe_zero, 2018-03-28_1aRagexe_zero, 2018-03-28cRagexe_zero, 2018-04-11aRagexe_zero, 2018-04-25_3aRagexe_zero, 2018-05-09_3aRagexe_zero, 2018-05-23aRagexe_zero, 2018-06-05bRagexe_zero, 2018-06-05cRagexe_zero, 2018-06-27aRagexe_zero, 2018-07-03aRagexe_zero, 2018-07-11_2aRagexe_zero, 2018-07-25_2aRagexe_zero, 2018-08-01aRagexe_zero, 2018-08-08_2aRagexe_zero, 2018-08-22aRagexe_zero, 2018-08-29aRagexe_zero, 2018-09-05aRagexe_zero, 2018-09-12aRagexe_zero, 2018-09-19aRagexe_zero, 2018-09-28aRagexe_zero, 2018-10-10_2aRagexe_zero, 2018-10-24_2aRagexe_zero, 2018-11-14aRagexe_zero, 2018-11-20aRagexe_zero, 2018-11-28aRagexe_zero, 2018-12-12aRagexe_zero, 2018-12-19aRagexe_zero, 2018-12-26_2aRagexe_zero, 2019-01-16_2aRagexe_zero, 2019-01-17_1aRagexe_zero, 2019-01-30_2aRagexe_zero, 2019-02-13aRagexe_zero, 2019-02-20aRagexe_zero, 2019-02-27aRagexe_zero, 2019-03-13aRagexe_zero, 2019-03-27_2aRagexe_zero, 2019-03-27_3aRagexe_zero, 2019-04-03aRagexe_zero, 2019-04-10bRagexe_zero, 2019-04-24aRagexe_zero, 2019-05-02aRagexe_zero, 2019-05-08_2aRagexe_zero, 2019-05-08aRagexe_zero, 2019-05-15aRagexe_zero, 2019-05-29aRagexe_zero, 2019-05-30aRagexe_zero, 2019-06-05_2aRagexe_zero, 2019-06-26_2aRagexe_zero, 2019-06-26_3aRagexe_zero, 2019-07-09aRagexe_zero, 2019-07-10_3aRagexe_zero, 2019-07-17aRagexe_zero, 2019-07-24aRagexe_zero, 2019-08-14_3aRagexe_zero, 2019-08-28_2aRagexe_zero, 2019-08-28_3aRagexe_zero, 2019-09-11aRagexe_zero, 2019-09-18_2aRagexe_zero, 2019-09-18aRagexe_zero, 2019-09-25_3aRagexe_zero, 2019-09-25_5aRagexe_zero, 2019-10-08_2aRagexe_zero, 2019-10-23_2aRagexe_zero, 2019-11-06aRagexe_zero, 2019-11-13aRagexe_zero, 2019-11-27_2aRagexe_zero, 2019-11-27aRagexe_zero, 2019-12-04aRagexe_zero, 2019-12-11_2aRagexe_zero, 2019-12-24_4aRagexe_zero, 2019-12-24_5aRagexe_zero, 2020-01-15_2aRagexe_zero, 2020-01-15aRagexe_zero, 2020-01-29_2aRagexe_zero, 2020-01-29aRagexe_zero +// 2017-10-18aRagexe_zero, 2017-10-19aRagexe_zero, 2017-10-23aRagexe_zero, 2017-10-23bRagexe_zero, 2017-10-23cRagexe_zero, 2017-10-24aRagexe_2_zero, 2017-10-24aRagexe_zero, 2017-10-25bRagexe_zero, 2017-10-27aRagexe_zero, 2017-10-27bRagexe_zero, 2017-10-30aRagexe_zero, 2017-10-31aRagexe_zero, 2017-11-09aRagexe_zero, 2017-11-13aRagexe_zero, 2017-11-13bRagexe_zero, 2018-03-15aRagexe_zero, 2018-03-21aRagexe_zero, 2018-03-21bRagexe_zero, 2018-03-28_1aRagexe_zero, 2018-03-28cRagexe_zero, 2018-04-11aRagexe_zero, 2018-04-25_3aRagexe_zero, 2018-05-09_3aRagexe_zero, 2018-05-23aRagexe_zero, 2018-06-05bRagexe_zero, 2018-06-05cRagexe_zero, 2018-06-27aRagexe_zero, 2018-07-03aRagexe_zero, 2018-07-11_2aRagexe_zero, 2018-07-25_2aRagexe_zero, 2018-08-01aRagexe_zero, 2018-08-08_2aRagexe_zero, 2018-08-22aRagexe_zero, 2018-08-29aRagexe_zero, 2018-09-05aRagexe_zero, 2018-09-12aRagexe_zero, 2018-09-19aRagexe_zero, 2018-09-28aRagexe_zero, 2018-10-10_2aRagexe_zero, 2018-10-24_2aRagexe_zero, 2018-11-14aRagexe_zero, 2018-11-20aRagexe_zero, 2018-11-28aRagexe_zero, 2018-12-12aRagexe_zero, 2018-12-19aRagexe_zero, 2018-12-26_2aRagexe_zero, 2019-01-16_2aRagexe_zero, 2019-01-17_1aRagexe_zero, 2019-01-30_2aRagexe_zero, 2019-02-13aRagexe_zero, 2019-02-20aRagexe_zero, 2019-02-27aRagexe_zero, 2019-03-13aRagexe_zero, 2019-03-27_2aRagexe_zero, 2019-03-27_3aRagexe_zero, 2019-04-03aRagexe_zero, 2019-04-10bRagexe_zero, 2019-04-24aRagexe_zero, 2019-05-02aRagexe_zero, 2019-05-08_2aRagexe_zero, 2019-05-08aRagexe_zero, 2019-05-15aRagexe_zero, 2019-05-29aRagexe_zero, 2019-05-30aRagexe_zero, 2019-06-05_2aRagexe_zero, 2019-06-26_2aRagexe_zero, 2019-06-26_3aRagexe_zero, 2019-07-09aRagexe_zero, 2019-07-10_3aRagexe_zero, 2019-07-17aRagexe_zero, 2019-07-24aRagexe_zero, 2019-08-14_3aRagexe_zero, 2019-08-28_2aRagexe_zero, 2019-08-28_3aRagexe_zero, 2019-09-11aRagexe_zero, 2019-09-18_2aRagexe_zero, 2019-09-18aRagexe_zero, 2019-09-25_3aRagexe_zero, 2019-09-25_5aRagexe_zero, 2019-10-08_2aRagexe_zero, 2019-10-23_2aRagexe_zero, 2019-11-06aRagexe_zero, 2019-11-13aRagexe_zero, 2019-11-27_2aRagexe_zero, 2019-11-27aRagexe_zero, 2019-12-04aRagexe_zero, 2019-12-11_2aRagexe_zero, 2019-12-24_4aRagexe_zero, 2019-12-24_5aRagexe_zero, 2020-01-15_2aRagexe_zero, 2020-01-15aRagexe_zero, 2020-01-29_2aRagexe_zero, 2020-01-29aRagexe_zero, 2020-02-12aRagexe_zero, 2020-02-26aRagexe_zero, 2020-02-26bRagexe_zero, 2020-03-04aRagexe_zero #if PACKETVER == 20171018 || \ PACKETVER == 20171019 || \ PACKETVER == 20171023 || \ @@ -105,7 +105,10 @@ PACKETVER == 20191211 || \ PACKETVER == 20191224 || \ PACKETVER == 20200115 || \ - PACKETVER >= 20200129 + PACKETVER == 20200129 || \ + PACKETVER == 20200212 || \ + PACKETVER == 20200226 || \ + PACKETVER >= 20200304 packetKeys(0x00000000,0x00000000,0x00000000); #endif diff --git a/src/map/packets_shuffle_main.h b/src/map/packets_shuffle_main.h index 2d7f1d6ec..25024c9f9 100644 --- a/src/map/packets_shuffle_main.h +++ b/src/map/packets_shuffle_main.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -9794,7 +9794,7 @@ packet(0x083c,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK // 14 #endif -// 2019-09-04aRagexe, 2019-09-04bRagexe, 2019-09-18bRagexe, 2019-09-25aRagexe, 2019-09-25bRagexe, 2019-10-02cRagexe, 2019-10-02dRagexe, 2019-10-16fRagexe, 2019-10-16gRagexe, 2019-10-18aRagexe, 2019-10-23aRagexe, 2019-10-30cRagexe, 2019-11-06aRagexe, 2019-11-07aRagexe, 2019-11-13cRagexe, 2019-11-13eRagexe, 2019-11-20aRagexe, 2019-11-20dRagexe, 2019-11-27aRagexe, 2019-11-27bRagexe, 2019-12-04aRagexe, 2019-12-04bRagexe, 2019-12-11aRagexe, 2019-12-18bRagexe, 2019-12-24aRagexe, 2019-12-24bRagexe, 2020-01-08aRagexe, 2020-01-22cRagexe, 2020-01-29bRagexe, 2020-01-30aRagexe, 2020-02-05aRagexe, 2020-02-06aRagexe +// 2019-09-04aRagexe, 2019-09-04bRagexe, 2019-09-18bRagexe, 2019-09-25aRagexe, 2019-09-25bRagexe, 2019-10-02cRagexe, 2019-10-02dRagexe, 2019-10-16fRagexe, 2019-10-16gRagexe, 2019-10-18aRagexe, 2019-10-23aRagexe, 2019-10-30cRagexe, 2019-11-06aRagexe, 2019-11-07aRagexe, 2019-11-13cRagexe, 2019-11-13eRagexe, 2019-11-20aRagexe, 2019-11-20dRagexe, 2019-11-27aRagexe, 2019-11-27bRagexe, 2019-12-04aRagexe, 2019-12-04bRagexe, 2019-12-11aRagexe, 2019-12-18bRagexe, 2019-12-24aRagexe, 2019-12-24bRagexe, 2020-01-08aRagexe, 2020-01-22cRagexe, 2020-01-29bRagexe, 2020-01-30aRagexe, 2020-02-05aRagexe, 2020-02-06aRagexe, 2020-02-12aRagexe, 2020-02-19dRagexe, 2020-03-04aRagexe #if PACKETVER == 20190904 || \ PACKETVER == 20190918 || \ PACKETVER == 20190925 || \ @@ -9817,7 +9817,10 @@ PACKETVER == 20200129 || \ PACKETVER == 20200130 || \ PACKETVER == 20200205 || \ - PACKETVER == 20200206 + PACKETVER == 20200206 || \ + PACKETVER == 20200212 || \ + PACKETVER == 20200219 || \ + PACKETVER == 20200304 packet(0x0202,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS // 26 packet(0x022d,clif->pHomMenu,2,4); // CZ_COMMAND_MER // 5 packet(0x023b,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD // 36 diff --git a/src/map/packets_shuffle_re.h b/src/map/packets_shuffle_re.h index 757cfee55..490d517fd 100644 --- a/src/map/packets_shuffle_re.h +++ b/src/map/packets_shuffle_re.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -9744,7 +9744,7 @@ packet(0x083c,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK // 14 #endif -// 2019-09-04bRagexeRE, 2019-09-18cRagexeRE, 2019-09-25aRagexeRE, 2019-09-25bRagexeRE, 2019-10-02bRagexeRE, 2019-10-02dRagexeRE, 2019-10-02dRagexeRE_2, 2019-10-16fRagexeRE, 2019-10-16gRagexeRE, 2019-10-23aRagexeRE, 2019-10-30bRagexeRE, 2019-11-06bRagexeRE, 2019-11-07aRagexeRE, 2019-11-13eRagexeRE, 2019-11-20cRagexeRE, 2019-11-27aRagexeRE, 2019-12-04aRagexeRE, 2019-12-04bRagexeRE, 2019-12-04cRagexeRE, 2019-12-11fRagexeRE, 2019-12-18bRagexeRE, 2019-12-24aRagexeRE, 2019-12-24bRagexeRE, 2020-01-08bRagexeRE, 2020-01-22cRagexeRE, 2020-02-05aRagexeRE +// 2019-09-04bRagexeRE, 2019-09-18cRagexeRE, 2019-09-25aRagexeRE, 2019-09-25bRagexeRE, 2019-10-02bRagexeRE, 2019-10-02dRagexeRE, 2019-10-02dRagexeRE_2, 2019-10-16fRagexeRE, 2019-10-16gRagexeRE, 2019-10-23aRagexeRE, 2019-10-30bRagexeRE, 2019-11-06bRagexeRE, 2019-11-07aRagexeRE, 2019-11-13eRagexeRE, 2019-11-20cRagexeRE, 2019-11-27aRagexeRE, 2019-12-04aRagexeRE, 2019-12-04bRagexeRE, 2019-12-04cRagexeRE, 2019-12-11fRagexeRE, 2019-12-18bRagexeRE, 2019-12-24aRagexeRE, 2019-12-24bRagexeRE, 2020-01-08bRagexeRE, 2020-01-22cRagexeRE, 2020-02-05aRagexeRE, 2020-02-12aRagexeRE, 2020-02-19eRagexeRE, 2020-03-04aRagexeRE #if PACKETVER == 20190904 || \ PACKETVER == 20190918 || \ PACKETVER == 20190925 || \ @@ -9763,7 +9763,10 @@ PACKETVER == 20191224 || \ PACKETVER == 20200108 || \ PACKETVER == 20200122 || \ - PACKETVER == 20200205 + PACKETVER == 20200205 || \ + PACKETVER == 20200212 || \ + PACKETVER == 20200219 || \ + PACKETVER == 20200304 packet(0x0202,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS // 26 packet(0x022d,clif->pHomMenu,2,4); // CZ_COMMAND_MER // 5 packet(0x023b,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD // 36 diff --git a/src/map/packets_shuffle_zero.h b/src/map/packets_shuffle_zero.h index 602264a8f..b7c26dbe7 100644 --- a/src/map/packets_shuffle_zero.h +++ b/src/map/packets_shuffle_zero.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2020 Hercules Dev Team - * Copyright (C) 2018-2020 Andrei Karas (4144) + * Copyright (C) 2013-2020 Hercules Dev Team + * Copyright (C) 2018-2020 Andrei Karas (4144) * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -803,7 +803,7 @@ packet(0x083c,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK // 14 #endif -// 2019-08-28_2aRagexe_zero, 2019-08-28_3aRagexe_zero, 2019-09-11aRagexe_zero, 2019-09-18_2aRagexe_zero, 2019-09-18aRagexe_zero, 2019-09-25_3aRagexe_zero, 2019-09-25_5aRagexe_zero, 2019-10-08_2aRagexe_zero, 2019-10-23_2aRagexe_zero, 2019-11-06aRagexe_zero, 2019-11-13aRagexe_zero, 2019-11-27_2aRagexe_zero, 2019-11-27aRagexe_zero, 2019-12-04aRagexe_zero, 2019-12-11_2aRagexe_zero, 2019-12-24_4aRagexe_zero, 2019-12-24_5aRagexe_zero, 2020-01-15_2aRagexe_zero, 2020-01-15aRagexe_zero, 2020-01-29_2aRagexe_zero, 2020-01-29aRagexe_zero +// 2019-08-28_2aRagexe_zero, 2019-08-28_3aRagexe_zero, 2019-09-11aRagexe_zero, 2019-09-18_2aRagexe_zero, 2019-09-18aRagexe_zero, 2019-09-25_3aRagexe_zero, 2019-09-25_5aRagexe_zero, 2019-10-08_2aRagexe_zero, 2019-10-23_2aRagexe_zero, 2019-11-06aRagexe_zero, 2019-11-13aRagexe_zero, 2019-11-27_2aRagexe_zero, 2019-11-27aRagexe_zero, 2019-12-04aRagexe_zero, 2019-12-11_2aRagexe_zero, 2019-12-24_4aRagexe_zero, 2019-12-24_5aRagexe_zero, 2020-01-15_2aRagexe_zero, 2020-01-15aRagexe_zero, 2020-01-29_2aRagexe_zero, 2020-01-29aRagexe_zero, 2020-02-12aRagexe_zero, 2020-02-26aRagexe_zero, 2020-02-26bRagexe_zero, 2020-03-04aRagexe_zero #if PACKETVER == 20190828 || \ PACKETVER == 20190911 || \ PACKETVER == 20190918 || \ @@ -817,7 +817,10 @@ PACKETVER == 20191211 || \ PACKETVER == 20191224 || \ PACKETVER == 20200115 || \ - PACKETVER == 20200129 + PACKETVER == 20200129 || \ + PACKETVER == 20200212 || \ + PACKETVER == 20200226 || \ + PACKETVER == 20200304 packet(0x0202,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS // 26 packet(0x022d,clif->pHomMenu,2,4); // CZ_COMMAND_MER // 5 packet(0x023b,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD // 36 diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index b604c77b8..71f986a90 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -3819,9 +3819,15 @@ struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub { uint32 index; uint32 zeny; uint32 currency_count; - struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2 currencies[]; + // Workaround for fix Visual Studio bug (error C2233). Here should be currencies[] + struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2 currencies[1]; } __attribute__((packed)); +// Workaround check for Visual Studio bug (error C2233) +STATIC_ASSERT(sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2[1]) == + sizeof(struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2), + "Wrong PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub size"); + struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN { int16 packetType; int16 packetLength; diff --git a/src/map/pc.c b/src/map/pc.c index c96e957c7..c604e16dc 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -998,20 +998,23 @@ static bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data return false; // Job Change Fail } -/*================================================= - * Checks if the player can equip the item at index n in inventory. - * Returns 0 (no) or 1 (yes). - *------------------------------------------------*/ +/** + * Checks if a character can equip an item. + * + * @param sd The related character. + * @param n The item's inventory index. + * @retval 0 Character can't equip the item. + * @retval 1 Character can equip the item. + * + **/ static int pc_isequip(struct map_session_data *sd, int n) { - struct item_data *item; - nullpo_ret(sd); Assert_ret(n >= 0 && n < sd->status.inventorySize); - item = sd->inventory_data[n]; + struct item_data *item = sd->inventory_data[n]; - if(item == NULL) + if (item == NULL) return 0; #if PACKETVER <= 20100707 @@ -1019,31 +1022,34 @@ static int pc_isequip(struct map_session_data *sd, int n) return 0; #endif - if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) + if (pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) return 1; - if (item->elv && sd->status.base_level < item->elv) { + if (item->elv != 0 && sd->status.base_level < item->elv) { #if PACKETVER >= 20100525 clif->msgtable(sd, MSG_CANNOT_EQUIP_ITEM_LEVEL); #endif return 0; } - if (item->elvmax && sd->status.base_level > item->elvmax) { + + if (item->elvmax != 0 && sd->status.base_level > item->elvmax) { #if PACKETVER >= 20100525 clif->msgtable(sd, MSG_CANNOT_EQUIP_ITEM_LEVEL); #endif return 0; } - if(item->sex != 2 && sd->status.sex != item->sex) + + if (item->sex != SEX_SERVER && sd->status.sex != item->sex) return 0; - if ( item->equip & EQP_AMMO ) { - if (sd->state.active && !pc_iscarton(sd) && (sd->job & MAPID_THIRDMASK) == MAPID_GENETIC) { // check if sc data is already loaded. + if ((item->equip & EQP_AMMO) != 0) { + if (sd->state.active != 0 && !pc_iscarton(sd) && (sd->job & MAPID_THIRDMASK) == MAPID_GENETIC) { // Check if sc data is already loaded. #if PACKETVER_RE_NUM >= 20090529 || PACKETVER_MAIN_NUM >= 20090603 || defined(PACKETVER_ZERO) clif->msgtable(sd, MSG_USESKILL_FAIL_CART); #endif return 0; } + if (!pc_ismadogear(sd) && (sd->job & MAPID_THIRDMASK) == MAPID_MECHANIC) { #if PACKETVER_RE_NUM >= 20090226 || PACKETVER_MAIN_NUM >= 20090304 || defined(PACKETVER_ZERO) clif->msgtable(sd, MSG_USESKILL_FAIL_MADOGEAR); @@ -1051,76 +1057,85 @@ static int pc_isequip(struct map_session_data *sd, int n) return 0; } } - if (sd->sc.count) { - if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_NOEQUIPWEAPON]) // Also works with left-hand weapons [DracoRPG] + if ((battle_config.unequip_restricted_equipment & 1) != 0) { + for (int i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++) + if (map->list[sd->bl.m].zone->disabled_items[i] == item->nameid) + return 0; + } + + if ((battle_config.unequip_restricted_equipment & 2) != 0 && !itemdb_isspecial(sd->status.inventory[n].card[0])) { + for (int slot = 0; slot < item->slot; slot++) + for (int i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++) + if (map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].card[slot]) + return 0; + } + + if (sd->sc.count != 0) { + if ((item->equip & EQP_ARMS) != 0 && item->type == IT_WEAPON && sd->sc.data[SC_NOEQUIPWEAPON] != NULL) // Also works with left-hand weapons. [DracoRPG] return 0; - if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.data[SC_NOEQUIPSHIELD]) + + if ((item->equip & EQP_SHIELD) != 0 && item->type == IT_ARMOR && sd->sc.data[SC_NOEQUIPSHIELD] != NULL) return 0; - if(item->equip & EQP_ARMOR && sd->sc.data[SC_NOEQUIPARMOR]) + + if ((item->equip & EQP_ARMOR) != 0 && sd->sc.data[SC_NOEQUIPARMOR] != NULL) return 0; - if(item->equip & EQP_HEAD_TOP && sd->sc.data[SC_NOEQUIPHELM]) + + if ((item->equip & EQP_HEAD_TOP) != 0 && sd->sc.data[SC_NOEQUIPHELM] != NULL) return 0; - if(item->equip & EQP_ACC && sd->sc.data[SC__STRIPACCESSARY]) + + if ((item->equip & EQP_ACC) != 0 && sd->sc.data[SC__STRIPACCESSARY] != NULL) return 0; - if(item->equip && sd->sc.data[SC_KYOUGAKU]) + + if (item->equip != 0 && sd->sc.data[SC_KYOUGAKU] != NULL) return 0; - if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SUPERNOVICE) { - //Spirit of Super Novice equip bonuses. [Skotlex] - if (sd->status.base_level > 90 && item->equip & EQP_HELM) - return 1; //Can equip all helms - - if (sd->status.base_level > 96 && item->equip & EQP_ARMS && item->type == IT_WEAPON) - switch (item->subtype) { //In weapons, the look determines type of weapon. - case W_DAGGER: //Level 4 Knives are equippable.. this means all knives, I'd guess? - case W_1HSWORD: //All 1H swords - case W_1HAXE: //All 1H Axes - case W_MACE: //All 1H Maces - case W_STAFF: //All 1H Staves + if (sd->sc.data[SC_SOULLINK] != NULL && sd->sc.data[SC_SOULLINK]->val2 == SL_SUPERNOVICE) { // Spirit of Super Novice equip bonuses. [Skotlex] + if (sd->status.base_level > 90 && (item->equip & EQP_HELM) != 0) + return 1; // Can equip all helms. + + if (sd->status.base_level > 96 && (item->equip & EQP_ARMS) != 0 && item->type == IT_WEAPON) { + switch (item->subtype) { // In weapons, the look determines type of weapon. + case W_DAGGER: // Level 4 Knives are equippable.. this means all knives, I'd guess? + case W_1HSWORD: // All 1H swords. + case W_1HAXE: // All 1H axes. + case W_MACE: // All 1H maces. + case W_STAFF: // All 1H staffs. return 1; } + } } } - //Not equipable by class. [Skotlex] - if (((1ULL<<(sd->job & MAPID_BASEMASK)) & item->class_base[(sd->job & JOBL_2_1) != 0 ? 1 : ((sd->job & JOBL_2_2) != 0 ? 2 : 0)]) == 0) + + uint64 mask_job = 1ULL << (sd->job & MAPID_BASEMASK); + uint64 mask_item = item->class_base[((sd->job & JOBL_2_1) != 0) ? 1 : (((sd->job & JOBL_2_2) != 0) ? 2 : 0)]; + + if ((mask_job & mask_item) == 0) // Not equipable by class. [Skotlex] return 0; - //Not usable by upper class. [Inkfish] - while( 1 ) { + + // Not usable by upper class. [Inkfish] + while (1) { if ((item->class_upper & ITEMUPPER_NORMAL) != 0) { - if ((sd->job & (JOBL_UPPER|JOBL_THIRD|JOBL_BABY)) == 0) + if ((sd->job & (JOBL_UPPER | JOBL_THIRD | JOBL_BABY)) == 0) break; } + if ((item->class_upper & ITEMUPPER_UPPER) != 0) { - if ((sd->job & (JOBL_UPPER|JOBL_THIRD)) != 0) + if ((sd->job & (JOBL_UPPER | JOBL_THIRD)) != 0) break; } + if ((item->class_upper & ITEMUPPER_BABY) != 0) { if ((sd->job & JOBL_BABY) != 0) break; } + if ((item->class_upper & ITEMUPPER_THIRD) != 0) { if ((sd->job & JOBL_THIRD) != 0) break; } - return 0; - } - if ( battle_config.unequip_restricted_equipment & 1 ) { - int i; - for ( i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++ ) - if ( map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid ) - return 0; - } - - if ( battle_config.unequip_restricted_equipment & 2 ) { - if ( !itemdb_isspecial( sd->status.inventory[n].card[0] ) ) { - int i, slot; - for ( slot = 0; slot < MAX_SLOTS; slot++ ) - for ( i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++ ) - if ( map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].card[slot] ) - return 0; - } + return 0; } return 1; @@ -5334,7 +5349,7 @@ static int pc_itemskill_clear(struct map_session_data *sd) sd->itemskill_id = 0; sd->itemskill_lv = 0; sd->state.itemskill_conditions_checked = 0; - sd->state.itemskill_no_conditions = 0; + sd->state.itemskill_check_conditions = 0; sd->state.itemskill_no_casttime = 0; sd->state.itemskill_castonself = 0; @@ -5688,18 +5703,26 @@ static int pc_steal_coin(struct map_session_data *sd, struct block_list *target, return 0; } -/*========================================== - * Set's a player position. - * Return values: - * 0 - Success. - * 1 - Invalid map index. - * 2 - Map not in this map-server, and failed to locate alternate map-server. - *------------------------------------------*/ + /** + * Sets a character's position. + * + * @param sd The related character. + * @param map_index The target map's index. + * @param x The target x-coordinate. + * @param y The target y-coordinate. + * @param clrtype The unit clear type, which should be used. + * @retval 0 Success. + * @retval 1 Invalid map index. + * @retval 2 Map not in this map-server, and failed to locate alternative map-server. + * @retval 3 No character data. (Parameter sd is a NULL pointer.) + * @retval 4 Character is jailed. + * + **/ static int pc_setpos(struct map_session_data *sd, unsigned short map_index, int x, int y, enum clr_type clrtype) { int16 m; - nullpo_ret(sd); + nullpo_retr(3, sd); if( !map_index || !mapindex_id2name(map_index) || ( m = map->mapindex2mapid(map_index) ) == -1 ) { ShowDebug("pc_setpos: Passed mapindex(%d) is invalid!\n", map_index); @@ -5788,7 +5811,7 @@ static int pc_setpos(struct map_session_data *sd, unsigned short map_index, int map->cellfromcache(&map->list[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) - return 1; //You may not get out! + return 4; //You may not get out! status_change_end(&sd->bl, SC_CASH_BOSS_ALARM, INVALID_TIMER); status_change_end(&sd->bl, SC_WARM, INVALID_TIMER); status_change_end(&sd->bl, SC_SUN_COMFORT, INVALID_TIMER); @@ -10144,141 +10167,163 @@ static void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, } } -/*========================================== - * Equip item on player sd at req_pos from inventory index n - * Return: - * 0 = fail - * 1 = success - *------------------------------------------*/ +/** + * Attempts to equip an item. + * + * @param sd The related character. + * @param n The item's inventory index. + * @param req_pos The equipment slot, where the item should be equipped. (See enum equip_pos.) + * @return 0 on failure, 1 on success. + * + **/ static int pc_equipitem(struct map_session_data *sd, int n, int req_pos) { - int i,pos,flag=0,iflag; - struct item_data *id; - nullpo_ret(sd); if (n < 0 || n >= sd->status.inventorySize) { - clif->equipitemack(sd,0,0,EIA_FAIL); + clif->equipitemack(sd, 0, 0, EIA_FAIL); return 0; } - if( DIFF_TICK(sd->canequip_tick,timer->gettick()) > 0 ) - { - clif->equipitemack(sd,n,0,EIA_FAIL); + // If the character is in berserk mode, the item can't be equipped. + if (sd->sc.count != 0 && (sd->sc.data[SC_BERSERK] != NULL || sd->sc.data[SC_NO_SWITCH_EQUIP] != NULL)) { + clif->equipitemack(sd, n, 0, EIA_FAIL); return 0; } - id = sd->inventory_data[n]; - pos = pc->equippoint(sd,n); //With a few exceptions, item should go in all specified slots. + if (battle_config.battle_log != 0) + ShowInfo("equip %d(%d) %x:%x\n", sd->status.inventory[n].nameid, n, sd->status.inventory[n].equip, + (unsigned int)req_pos); - if(battle_config.battle_log) - ShowInfo("equip %d(%d) %x:%x\n", sd->status.inventory[n].nameid, n, (unsigned int)(id ? id->equip : 0), (unsigned int)req_pos); - if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0 ) { // [Valaris] - // FIXME: pc->isequip: equip level failure uses 2 instead of 0 - clif->equipitemack(sd,n,0,EIA_FAIL); // fail + if (DIFF_TICK(sd->canequip_tick, timer->gettick()) > 0) { + clif->equipitemack(sd, n, 0, EIA_FAIL); return 0; } - if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP]) - { - clif->equipitemack(sd,n,0,EIA_FAIL); // fail + int pos = pc->equippoint(sd, n); // With a few exceptions, item should go in all specified slots. + + if (pc->isequip(sd,n) == 0 || (pos & req_pos) == 0 || sd->status.inventory[n].equip != 0 + || (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0) { + clif->equipitemack(sd, n, 0, EIA_FAIL); return 0; + } + + if (sd->inventory_data[n]->flag.bindonequip != 0 && sd->status.inventory[n].bound == 0) { + sd->status.inventory[n].bound = IBT_CHARACTER; + clif->notify_bounditem(sd, n); + } + + if (pos == EQP_ACC) { // Accesories should only go in one of the two. + pos = req_pos & EQP_ACC; + + if (pos == EQP_ACC) // User specified both slots. + pos = (sd->equip_index[EQI_ACC_R] >= 0) ? EQP_ACC_L : EQP_ACC_R; + } else if (pos == EQP_ARMS && sd->inventory_data[n]->equip == EQP_HAND_R) { // Dual wield capable weapon. + pos = req_pos & EQP_ARMS; + + if (pos == EQP_ARMS) // User specified both slots, pick one for them. + pos = (sd->equip_index[EQI_HAND_R] >= 0) ? EQP_HAND_L : EQP_HAND_R; + } else if (pos == EQP_SHADOW_ACC) { // Accesories should only go in one of the two, + pos = req_pos & EQP_SHADOW_ACC; + + if (pos == EQP_SHADOW_ACC) // User specified both slots. + pos = (sd->equip_index[EQI_SHADOW_ACC_R] >= 0) ? EQP_SHADOW_ACC_L : EQP_SHADOW_ACC_R; + } else if (pos == EQP_SHADOW_ARMS && sd->inventory_data[n]->equip == EQP_SHADOW_WEAPON) { // Dual wield capable weapon. + pos = req_pos & EQP_SHADOW_ARMS; + + if (pos == EQP_SHADOW_ARMS) // User specified both slots, pick one for them. + pos = (sd->equip_index[EQI_SHADOW_WEAPON] >= 0) ? EQP_SHADOW_SHIELD : EQP_SHADOW_WEAPON; } - /* won't fail from this point onwards */ - if( id->flag.bindonequip && !sd->status.inventory[n].bound ) { - sd->status.inventory[n].bound = (unsigned char)IBT_CHARACTER; - clif->notify_bounditem(sd,n); - } - - if(pos == EQP_ACC) { //Accesories should only go in one of the two, - pos = req_pos&EQP_ACC; - if (pos == EQP_ACC) //User specified both slots.. - pos = sd->equip_index[EQI_ACC_R] >= 0 ? EQP_ACC_L : EQP_ACC_R; - } else if(pos == EQP_ARMS && id->equip == EQP_HAND_R) { //Dual wield capable weapon. - pos = (req_pos&EQP_ARMS); - if (pos == EQP_ARMS) //User specified both slots, pick one for them. - pos = sd->equip_index[EQI_HAND_R] >= 0 ? EQP_HAND_L : EQP_HAND_R; - } else if(pos == EQP_SHADOW_ACC) { //Accesories should only go in one of the two, - pos = req_pos&EQP_SHADOW_ACC; - if (pos == EQP_SHADOW_ACC) //User specified both slots.. - pos = sd->equip_index[EQI_SHADOW_ACC_R] >= 0 ? EQP_SHADOW_ACC_L : EQP_SHADOW_ACC_R; - } else if( pos == EQP_SHADOW_ARMS && id->equip == EQP_SHADOW_WEAPON) { //Dual wield capable weapon. - pos = (req_pos&EQP_SHADOW_ARMS); - if (pos == EQP_SHADOW_ARMS) //User specified both slots, pick one for them. - pos = sd->equip_index[EQI_SHADOW_WEAPON] >= 0 ? EQP_SHADOW_SHIELD : EQP_SHADOW_WEAPON; - } - - if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC) { - //Update skill-block range database when weapon range changes. [Skotlex] - i = sd->equip_index[EQI_HAND_R]; - if (i < 0 || !sd->inventory_data[i]) //No data, or no weapon equipped + int flag = 0; + + // Update skill-block range database when weapon range changes. [Skotlex] + if ((pos & EQP_HAND_R) != 0 && (battle_config.use_weapon_skill_range & BL_PC) != 0) { + int idx = sd->equip_index[EQI_HAND_R]; + + if (idx < 0 || sd->inventory_data[idx] == NULL) // No data, or no weapon equipped. flag = 1; else - flag = id->range != sd->inventory_data[i]->range; + flag = (sd->inventory_data[n]->range != sd->inventory_data[idx]->range) ? 1 : 0; } - for(i=0;i<EQI_MAX;i++) { - if(pos & pc->equip_pos[i]) { - if(sd->equip_index[i] >= 0) //Slot taken, remove item from there. + for (int i = 0; i < EQI_MAX; i++) { + if ((pos & pc->equip_pos[i]) != 0) { + if (sd->equip_index[i] >= 0) // Slot taken, remove item from there. pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_FORCE); sd->equip_index[i] = n; } } - if(pos==EQP_AMMO){ - clif->arrowequip(sd,n); - clif->arrow_fail(sd,3); + if (pos == EQP_AMMO) { + clif->arrowequip(sd, n); + clif->arrow_fail(sd, 3); + } else { + clif->equipitemack(sd, n, pos, EIA_SUCCESS); } - else - clif->equipitemack(sd,n,pos,EIA_SUCCESS); - sd->status.inventory[n].equip=pos; + sd->status.inventory[n].equip = pos; + pc->equipitem_pos(sd, sd->inventory_data[n], n, pos); + pc->checkallowskill(sd); // Check if status changes should be halted. - pc->equipitem_pos(sd, id, n, pos); + int iflag = sd->npc_item_flag; - pc->checkallowskill(sd); //Check if status changes should be halted. - iflag = sd->npc_item_flag; + // Check for combos. (MUST be done before status->calc_pc()!) + if (sd->inventory_data[n]->combos_count != 0) + pc->checkcombo(sd, sd->inventory_data[n]); - /* check for combos (MUST be before status_calc_pc) */ - if( id->combos_count ) - pc->checkcombo(sd,id); - if(itemdb_isspecial(sd->status.inventory[n].card[0])) - ; //No cards - else { - for( i = 0; i < id->slot; i++ ) { - struct item_data *data; - if (!sd->status.inventory[n].card[i]) + if (!itemdb_isspecial(sd->status.inventory[n].card[0])) { + for (int i = 0; i < sd->inventory_data[n]->slot; i++) { + if (sd->status.inventory[n].card[i] == 0) continue; - if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if( data->combos_count ) - pc->checkcombo(sd,data); - } + + struct item_data *data = itemdb->exists(sd->status.inventory[n].card[i]); + + if (data != NULL && data->combos_count != 0) + pc->checkcombo(sd, data); } } - status_calc_pc(sd,SCO_NONE); - if (flag) //Update skill data + status_calc_pc(sd, SCO_NONE); + + if (flag != 0) // Update skill data. clif->skillinfoblock(sd); + + // Execute equip script. [Skotlex] + struct item_data *equip_data = sd->inventory_data[n]; + struct map_zone_data *zone = map->list[sd->bl.m].zone; + int dis_items_cnt = zone->disabled_items_count; - //OnEquip script [Skotlex] - if (id->equip_script) - script->run_item_equip_script(sd, id, npc->fake_nd->bl.id); + if (equip_data->equip_script != NULL) { + int idx; - if(itemdb_isspecial(sd->status.inventory[n].card[0])) - ; //No cards - else { - for( i = 0; i < id->slot; i++ ) { - struct item_data *data; - if (!sd->status.inventory[n].card[i]) + ARR_FIND(0, dis_items_cnt, idx, zone->disabled_items[idx] == equip_data->nameid); + + if (idx == dis_items_cnt) + script->run_item_equip_script(sd, equip_data, npc->fake_nd->bl.id); + } + + struct item *equip = &sd->status.inventory[n]; + + if (!itemdb_isspecial(equip->card[0])) { + for (int slot = 0; slot < equip_data->slot; slot++) { + if (equip->card[slot] == 0) continue; - if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if (data->equip_script) - script->run_item_equip_script(sd, data, npc->fake_nd->bl.id); + + struct item_data *card_data = itemdb->exists(equip->card[slot]); + + if (card_data != NULL && card_data->equip_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_equip_script(sd, card_data, npc->fake_nd->bl.id); } } } + sd->npc_item_flag = iflag; return 1; @@ -10350,19 +10395,17 @@ static void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) } } -/*========================================== - * Called when attemting to unequip an item from player - * type: @see enum pc_unequipitem_flag - * Return: - * 0 = fail - * 1 = success - *------------------------------------------*/ +/** + * Attempts to unequip an item. + * + * @param sd The related character. + * @param n The item's inventory index. + * @param flag Modifier for additional actions. (See enum pc_unequipitem_flag.) + * @return 0 on failure, 1 on success. + * + **/ static int pc_unequipitem(struct map_session_data *sd, int n, int flag) { - int i, iflag; - bool status_calc = false; - int pos; - nullpo_ret(sd); if (n < 0 || n >= sd->status.inventorySize) { @@ -10370,127 +10413,128 @@ static int pc_unequipitem(struct map_session_data *sd, int n, int flag) return 0; } - // if player is berserk then cannot unequip - if (!(flag & PCUNEQUIPITEM_FORCE) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP])) { + // If the character is in berserk mode, the item can't be unequipped. + if (sd->sc.count != 0 && (sd->sc.data[SC_BERSERK] != NULL || sd->sc.data[SC_NO_SWITCH_EQUIP] != NULL) + && (flag & PCUNEQUIPITEM_FORCE) == 0) { clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - if (!(flag & PCUNEQUIPITEM_FORCE) && sd->sc.count && sd->sc.data[SC_KYOUGAKU]) { + if ((flag & PCUNEQUIPITEM_FORCE) == 0 && sd->sc.count != 0 && sd->sc.data[SC_KYOUGAKU] != NULL) { clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - if (battle_config.battle_log) + if (battle_config.battle_log != 0) ShowInfo("unequip %d %x:%x\n", n, (unsigned int)(pc->equippoint(sd, n)), sd->status.inventory[n].equip); - if (sd->status.inventory[n].equip == 0) { //Nothing to unequip + if (sd->status.inventory[n].equip == 0) { // Nothing to unequip. clif->unequipitemack(sd, n, 0, UIA_FAIL); return 0; } - for (i = 0; i < EQI_MAX; i++) { - if (sd->status.inventory[n].equip & pc->equip_pos[i]) + for (int i = 0; i < EQI_MAX; i++) { + if ((sd->status.inventory[n].equip & pc->equip_pos[i]) != 0) sd->equip_index[i] = -1; } - pos = sd->status.inventory[n].equip; - pc->unequipitem_pos(sd, n, pos); + int pos = sd->status.inventory[n].equip; + pc->unequipitem_pos(sd, n, pos); clif->unequipitemack(sd, n, pos, UIA_SUCCESS); - if ((pos & EQP_ARMS) && - sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST && (sd->sc.data[SC_TK_SEVENWIND] == NULL || sd->sc.data[SC_ASPERSIO] != NULL)) //Check for seven wind (but not level seven!) + if ((pos & EQP_ARMS) != 0 && sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST + && (sd->sc.data[SC_TK_SEVENWIND] == NULL || sd->sc.data[SC_ASPERSIO] != NULL)) { // Check for Seven Wind. (But not level seven!) skill->enchant_elemental_end(&sd->bl, -1); + } - if (pos & EQP_ARMOR) { - // On Armor Change... + if ((pos & EQP_ARMOR) != 0) { status_change_end(&sd->bl, SC_BENEDICTIO, INVALID_TIMER); status_change_end(&sd->bl, SC_ARMOR_RESIST, INVALID_TIMER); } #ifdef RENEWAL - if (battle->bc->bow_unequip_arrow && pos&EQP_ARMS && sd->equip_index[EQI_AMMO] > 0) + if (battle->bc->bow_unequip_arrow != 0 && (pos & EQP_ARMS) != 0 && sd->equip_index[EQI_AMMO] > 0) pc->unequipitem(sd, sd->equip_index[EQI_AMMO], PCUNEQUIPITEM_FORCE); #endif - if( sd->state.autobonus&pos ) - sd->state.autobonus &= ~sd->status.inventory[n].equip; //Check for activated autobonus [Inkfish] + if ((sd->state.autobonus & pos) != 0) // Check for activated autobonus. [Inkfish] + sd->state.autobonus &= ~sd->status.inventory[n].equip; sd->status.inventory[n].equip = 0; - iflag = sd->npc_item_flag; - /* check for combos (MUST be before status_calc_pc) */ + bool status_calc = false; + int iflag = sd->npc_item_flag; + + // Check for combos. (MUST be done before status->calc_pc()!) if (sd->inventory_data[n] != NULL) { - if (sd->inventory_data[n]->combos_count) { - if (pc->removecombo(sd, sd->inventory_data[n])) - status_calc = true; - } - if (itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { - for (i = 0; i < sd->inventory_data[n]->slot; i++) { - struct item_data *data; + if (sd->inventory_data[n]->combos_count != 0 && pc->removecombo(sd, sd->inventory_data[n]) != 0) + status_calc = true; + + if (!itemdb_isspecial(sd->status.inventory[n].card[0])) { + for (int i = 0; i < sd->inventory_data[n]->slot; i++) { if (sd->status.inventory[n].card[i] == 0) continue; - if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) { - if (data->combos_count) { - if (pc->removecombo(sd, data)) - status_calc = true; - } - } + + struct item_data *data = itemdb->exists(sd->status.inventory[n].card[i]); + + if (data != NULL && data->combos_count != 0 && pc->removecombo(sd, data) != 0) + status_calc = true; } } - /* Item Options checking */ - for (i = 0; i < MAX_ITEM_OPTIONS; i++) { - struct itemdb_option *ito = NULL; - int16 item_option = sd->status.inventory[n].option[i].index; - if (item_option <= 0) + // Check item options. + for (int i = 0; i < MAX_ITEM_OPTIONS; i++) { + if (sd->status.inventory[n].option[i].index <= 0) continue; - if ((ito = itemdb->option_exists(sd->status.inventory[n].option[i].index)) == NULL) + + if (itemdb->option_exists(sd->status.inventory[n].option[i].index) == NULL) continue; status_calc = true; } } - if (flag & PCUNEQUIPITEM_RECALC || status_calc) { + if ((flag & PCUNEQUIPITEM_RECALC) != 0 || status_calc) { pc->checkallowskill(sd); status_calc_pc(sd, SCO_NONE); } - if (sd->sc.data[SC_CRUCIS] && battle->check_undead(sd->battle_status.race, sd->battle_status.def_ele) == false) + if (sd->sc.data[SC_CRUCIS] != NULL && !battle->check_undead(sd->battle_status.race, sd->battle_status.def_ele)) status_change_end(&sd->bl, SC_CRUCIS, INVALID_TIMER); - //OnUnEquip script [Skotlex] + // Execute unequip script. [Skotlex] if (sd->inventory_data[n] != NULL) { - if (sd->inventory_data[n]->unequip_script != NULL) { - if (battle_config.unequip_restricted_equipment & 1) { - ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid); - if (i == map->list[sd->bl.m].zone->disabled_items_count) - script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); - } - else - script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); + struct item_data *equip_data = sd->inventory_data[n]; + struct map_zone_data *zone = map->list[sd->bl.m].zone; + int dis_items_cnt = zone->disabled_items_count; + + 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 (itemdb_isspecial(sd->status.inventory[n].card[0]) == false) { - for (i = 0; i < sd->inventory_data[n]->slot; i++) { - struct item_data *data = NULL; - if (sd->status.inventory[n].card[i] == 0) + + struct item *equip = &sd->status.inventory[n]; + + if (!itemdb_isspecial(equip->card[0])) { + for (int slot = 0; slot < equip_data->slot; slot++) { + if (equip->card[slot] == 0) continue; - if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) { - if (data->unequip_script) { - if (battle_config.unequip_restricted_equipment & 2) { - int j; - ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]); - if (j == map->list[sd->bl.m].zone->disabled_items_count) - script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); - } else { - script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); - } - } - } + 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); + } } } } diff --git a/src/map/pc.h b/src/map/pc.h index e940c3310..8d1ae3607 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -241,7 +241,7 @@ struct map_session_data { unsigned int npc_unloaded : 1; ///< The player is talking with an unloaded NPCs (respawned tombstones) unsigned int lapine_ui : 1; unsigned int itemskill_conditions_checked : 1; // Used by itemskill() script command, to prevent second check of conditions after target was selected. - unsigned int itemskill_no_conditions : 1; // Used by itemskill() script command, to ignore skill conditions and don't consume them. + unsigned int itemskill_check_conditions : 1; // Used by itemskill() script command, to check skill conditions and consume them. unsigned int itemskill_no_casttime : 1; // Used by itemskill() script command, to cast skill instantaneously. unsigned int itemskill_castonself : 1; // Used by itemskill() script command, to forcefully cast skill on invoking character. } state; diff --git a/src/map/pet.c b/src/map/pet.c index f20de2650..aeb372c05 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -891,7 +891,8 @@ static int pet_randomwalk(struct pet_data *pd, int64 tick) int r=rnd(); int x=pd->bl.x+r%(d*2+1)-d; int y=pd->bl.y+r/(d*2+1)%(d*2+1)-d; - if(map->getcell (pd->bl.m, &pd->bl, x, y, CELL_CHKPASS) && unit->walktoxy(&pd->bl, x, y, 0)) { + if (map->getcell(pd->bl.m, &pd->bl, x, y, CELL_CHKPASS) != 0 + && unit->walk_toxy(&pd->bl, x, y, 0) == 0) { pd->move_fail_count=0; break; } @@ -991,7 +992,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int return 0; //Already walking to him unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); - if(!unit->walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0)) + if (unit->walk_toxy(&pd->bl, pd->ud.to_x, pd->ud.to_y, 0) != 0) pet->randomwalk(pd,tick); return 0; diff --git a/src/map/script.c b/src/map/script.c index c1eb2e8b7..b8a7979a7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11001,17 +11001,19 @@ static BUILDIN(itemskill) if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; + pc->itemskill_clear(sd); sd->skillitem = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); sd->skillitemlv = script_getnum(st, 3); sd->state.itemskill_conditions_checked = 0; // Skill casting items will check the conditions prior to the target selection in AEGIS. Thus we need a flag to prevent checking them twice. int flag = script_hasdata(st, 4) ? script_getnum(st, 4) : ISF_NONE; - sd->state.itemskill_no_conditions = ((flag & ISF_IGNORECONDITIONS) == ISF_IGNORECONDITIONS) ? 1 : 0; // Unset in pc_itemskill_clear(). + sd->state.itemskill_check_conditions = ((flag & ISF_CHECKCONDITIONS) == ISF_CHECKCONDITIONS) ? 1 : 0; // Unset in pc_itemskill_clear(). - if (sd->state.itemskill_no_conditions == 0) { + if (sd->state.itemskill_check_conditions == 1) { if (skill->check_condition_castbegin(sd, sd->skillitem, sd->skillitemlv) == 0 || skill->check_condition_castend(sd, sd->skillitem, sd->skillitemlv) == 0) { + pc->itemskill_clear(sd); return true; } @@ -14780,24 +14782,34 @@ static BUILDIN(getitemslots) return true; } -// TODO: add matk here if needed - -/*========================================== - * Returns some values of an item [Lupus] - * Price, Weight, etc... - *------------------------------------------*/ +/** + * Returns various information about an item. + * + * @code{.herc} + * getiteminfo(<item ID>, <type>); + * getiteminfo("<item name>", <type>); + * @endcode + * + **/ static BUILDIN(getiteminfo) { - int item_id = script_getnum(st, 2); - int n = script_getnum(st, 3); - struct item_data *it = itemdb->exists(item_id); + struct item_data *it; + + if (script_isstringtype(st, 2)) { /// Item name. + const char *name = script_getstr(st, 2); + it = itemdb->search_name(name); + } else { /// Item ID. + it = itemdb->exists(script_getnum(st, 2)); + } if (it == NULL) { script_pushint(st, -1); return true; } - switch (n) { + int type = script_getnum(st, 3); + + switch (type) { case ITEMINFO_BUYPRICE: script_pushint(st, it->value_buy); break; @@ -14909,16 +14921,24 @@ static BUILDIN(getiteminfo) case ITEMINFO_STACK_AMOUNT: script_pushint(st, it->stack.amount); break; - case ITEMINFO_STACK_FLAG: - { - int stack_flag = 0; - if (it->stack.inventory != 0) stack_flag |= 1; - if (it->stack.cart != 0) stack_flag |= 2; - if (it->stack.storage != 0) stack_flag |= 4; - if (it->stack.guildstorage != 0) stack_flag |= 8; - script_pushint(st, stack_flag); - } + case ITEMINFO_STACK_FLAG: { + int stack_flag = 0; + + if (it->stack.inventory != 0) + stack_flag |= 1; + + if (it->stack.cart != 0) + stack_flag |= 2; + + if (it->stack.storage != 0) + stack_flag |= 4; + + if (it->stack.guildstorage != 0) + stack_flag |= 8; + + script_pushint(st, stack_flag); break; + } case ITEMINFO_ITEM_USAGE_FLAG: script_pushint(st, it->item_usage.flag); break; @@ -14928,11 +14948,21 @@ static BUILDIN(getiteminfo) case ITEMINFO_GM_LV_TRADE_OVERRIDE: script_pushint(st, it->gm_lv_trade_override); break; + case ITEMINFO_ID: + script_pushint(st, it->nameid); + break; + case ITEMINFO_AEGISNAME: + script_pushstr(st, it->name); + break; + case ITEMINFO_NAME: + script_pushstr(st, it->jname); + break; default: - ShowError("buildin_getiteminfo: Invalid item type %d.\n", n); - script_pushint(st,-1); + ShowError("buildin_getiteminfo: Invalid item info type %d.\n", type); + script_pushint(st, -1); return false; } + return true; } @@ -16558,7 +16588,7 @@ static BUILDIN(npcwalkto) } else { status_calc_npc(nd, SCO_NONE); } - unit->walktoxy(&nd->bl, x, y, 0); + unit->walk_toxy(&nd->bl, x, y, 0); } return true; @@ -19680,7 +19710,7 @@ static BUILDIN(setunitdata) unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT); break; case UDT_WALKTOXY: - if (!unit->walktoxy(bl, (short) val, (short) val2, 2)) + if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0) unit->movepos(bl, (short) val, (short) val2, 0, 0); break; case UDT_SPEED: @@ -19727,7 +19757,7 @@ static BUILDIN(setunitdata) clif->changelook(bl, LOOK_WEAPON, val); break; case UDT_LOOKDIR: - unit->setdir(bl, (uint8) val); + unit->set_dir(bl, (enum unit_dir)val); break; case UDT_CANMOVETICK: md->ud.canmove_tick = val; @@ -19851,7 +19881,7 @@ static BUILDIN(setunitdata) unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT); break; case UDT_WALKTOXY: - if (!unit->walktoxy(bl, (short) val, (short) val2, 2)) + if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0) unit->movepos(bl, (short) val, (short) val2, 0, 0); break; case UDT_SPEED: @@ -19859,7 +19889,7 @@ static BUILDIN(setunitdata) status->calc_misc(bl, &hd->base_status, hd->homunculus.level); break; case UDT_LOOKDIR: - unit->setdir(bl, (unsigned char) val); + unit->set_dir(bl, (enum unit_dir)val); break; case UDT_CANMOVETICK: hd->ud.canmove_tick = val; @@ -19990,7 +20020,7 @@ static BUILDIN(setunitdata) unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT); break; case UDT_WALKTOXY: - if (!unit->walktoxy(bl, (short) val, (short) val2, 2)) + if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0) unit->movepos(bl, (short) val, (short) val2, 0, 0); break; case UDT_SPEED: @@ -19998,7 +20028,7 @@ static BUILDIN(setunitdata) status->calc_misc(bl, &pd->status, pd->pet.level); break; case UDT_LOOKDIR: - unit->setdir(bl, (unsigned char) val); + unit->set_dir(bl, (enum unit_dir)val); break; case UDT_CANMOVETICK: pd->ud.canmove_tick = val; @@ -20123,7 +20153,7 @@ static BUILDIN(setunitdata) unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT); break; case UDT_WALKTOXY: - if (!unit->walktoxy(bl, (short) val, (short) val2, 2)) + if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0) unit->movepos(bl, (short) val, (short) val2, 0, 0); break; case UDT_SPEED: @@ -20131,7 +20161,7 @@ static BUILDIN(setunitdata) status->calc_misc(bl, &mc->base_status, mc->db->lv); break; case UDT_LOOKDIR: - unit->setdir(bl, (unsigned char) val); + unit->set_dir(bl, (enum unit_dir)val); break; case UDT_CANMOVETICK: mc->ud.canmove_tick = val; @@ -20257,7 +20287,7 @@ static BUILDIN(setunitdata) unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT); break; case UDT_WALKTOXY: - if (!unit->walktoxy(bl, (short) val, (short) val2, 2)) + if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0) unit->movepos(bl, (short) val, (short) val2, 0, 0); break; case UDT_SPEED: @@ -20265,7 +20295,7 @@ static BUILDIN(setunitdata) status->calc_misc(bl, &ed->base_status, ed->db->lv); break; case UDT_LOOKDIR: - unit->setdir(bl, (unsigned char) val); + unit->set_dir(bl, (enum unit_dir)val); break; case UDT_CANMOVETICK: ed->ud.canmove_tick = val; @@ -20386,7 +20416,7 @@ static BUILDIN(setunitdata) unit->warp(bl, (short) val, (short) val2, (short) val3, CLR_TELEPORT); break; case UDT_WALKTOXY: - if (!unit->walktoxy(bl, (short) val, (short) val2, 2)) + if (unit->walk_toxy(bl, (short)val, (short)val2, 2) != 0) unit->movepos(bl, (short) val, (short) val2, 0, 0); break; case UDT_CLASS: @@ -20397,7 +20427,7 @@ static BUILDIN(setunitdata) status->calc_misc(bl, &nd->status, nd->level); break; case UDT_LOOKDIR: - unit->setdir(bl, (unsigned char) val); + unit->set_dir(bl, (enum unit_dir)val); break; case UDT_STR: nd->status.str = (unsigned short) val; @@ -21121,7 +21151,10 @@ static BUILDIN(unitwalk) if (script_hasdata(st, 4)) { int x = script_getnum(st, 3); int y = script_getnum(st, 4); - script_pushint(st, unit->walktoxy(bl, x, y, 0));// We'll use harder calculations. + if (unit->walk_toxy(bl, x, y, 0) == 0) // We'll use harder calculations. + script_pushint(st, 1); + else + script_pushint(st, 0); } else { int target_id = script_getnum(st, 3); @@ -21131,6 +21164,38 @@ static BUILDIN(unitwalk) return true; } +/** + * Checks if a unit is walking. + * + * Returns 1 if unit is walking, 0 if unit is not walking and -1 on error. + * + * @code{.herc} + * unitiswalking({<GID>}); + * @endcode + * + **/ +static BUILDIN(unitiswalking) +{ + int gid = script_hasdata(st, 2) ? script_getnum(st, 2) : st->rid; + struct block_list *bl = map->id2bl(gid); + + if (bl == NULL) { + ShowWarning("buildin_unitiswalking: Error in finding object for GID %d!\n", gid); + script_pushint(st, -1); + return false; + } + + if (unit->bl2ud(bl) == NULL) { + ShowWarning("buildin_unitiswalking: Error in finding unit_data for GID %d!\n", gid); + script_pushint(st, -1); + return false; + } + + script_pushint(st, unit->is_walking(bl)); + + return true; +} + /// Kills the unit /// /// unitkill <unit_id>; @@ -23250,7 +23315,6 @@ static BUILDIN(progressbar_unit) } static BUILDIN(pushpc) { - uint8 dir; int cells, dx, dy; struct map_session_data* sd; @@ -23259,14 +23323,14 @@ static BUILDIN(pushpc) return true; } - dir = script_getnum(st,2); - cells = script_getnum(st,3); + enum unit_dir dir = script_getnum(st, 2); + cells = script_getnum(st,3); - if (dir > 7) { + if (dir >= UNIT_DIR_MAX) { ShowWarning("buildin_pushpc: Invalid direction %d specified.\n", dir); script->reportsrc(st); - dir%= 8; // trim spin-over + dir %= UNIT_DIR_MAX; // trim spin-over } if(!cells) @@ -23275,10 +23339,11 @@ static BUILDIN(pushpc) } else if(cells<0) {// pushing backwards - dir = (dir+4)%8; // turn around - cells = -cells; + dir = unit_get_opposite_dir(dir); + cells = -cells; } + Assert_retr(false, dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); dx = dirx[dir]; dy = diry[dir]; @@ -26970,7 +27035,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(setnpcdisplay,"sv??"), BUILDIN_DEF(compare,"ss"), // Lordalfa - To bring strstr to scripting Engine. BUILDIN_DEF(strcmp,"ss"), - BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info + BUILDIN_DEF(getiteminfo,"vi"), //[Lupus] returns Items Buy / sell Price, etc info BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item BUILDIN_DEF(getequippedoptioninfo, "i"), @@ -27033,6 +27098,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(getunittitle,"i"), BUILDIN_DEF(setunittitle,"is"), BUILDIN_DEF(unitwalk,"ii?"), + BUILDIN_DEF(unitiswalking, "?"), BUILDIN_DEF(unitkill,"i"), BUILDIN_DEF(unitwarp,"isii"), BUILDIN_DEF(unitattack,"iv?"), @@ -27615,6 +27681,9 @@ static void script_hardcoded_constants(void) script->set_constant("ITEMINFO_ITEM_USAGE_FLAG", ITEMINFO_ITEM_USAGE_FLAG, false, false); script->set_constant("ITEMINFO_ITEM_USAGE_OVERRIDE", ITEMINFO_ITEM_USAGE_OVERRIDE, false, false); script->set_constant("ITEMINFO_GM_LV_TRADE_OVERRIDE", ITEMINFO_GM_LV_TRADE_OVERRIDE, false, false); + script->set_constant("ITEMINFO_ID", ITEMINFO_ID, false, false); + script->set_constant("ITEMINFO_AEGISNAME", ITEMINFO_AEGISNAME, false, false); + script->set_constant("ITEMINFO_NAME", ITEMINFO_NAME, false, false); script->constdb_comment("getmercinfo options"); script->set_constant("MERCINFO_ID,", MERCINFO_ID, false, false); @@ -27858,10 +27927,17 @@ static void script_hardcoded_constants(void) script->constdb_comment("itemskill option flags"); script->set_constant("ISF_NONE", ISF_NONE, false, false); - script->set_constant("ISF_IGNORECONDITIONS", ISF_IGNORECONDITIONS, false, false); + script->set_constant("ISF_CHECKCONDITIONS", ISF_CHECKCONDITIONS, false, false); script->set_constant("ISF_INSTANTCAST", ISF_INSTANTCAST, false, false); script->set_constant("ISF_CASTONSELF", ISF_CASTONSELF, false, false); + script->constdb_comment("Item Bound Types"); + script->set_constant("IBT_ANY", IBT_NONE, false, false); // for *checkbound() + script->set_constant("IBT_ACCOUNT", IBT_ACCOUNT, false, false); + script->set_constant("IBT_GUILD", IBT_GUILD, false, false); + script->set_constant("IBT_PARTY", IBT_PARTY, false, false); + script->set_constant("IBT_CHARACTER", IBT_CHARACTER, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); diff --git a/src/map/script.h b/src/map/script.h index 857d22c61..511497a66 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -484,6 +484,9 @@ enum script_iteminfo_types { ITEMINFO_ITEM_USAGE_FLAG, ITEMINFO_ITEM_USAGE_OVERRIDE, ITEMINFO_GM_LV_TRADE_OVERRIDE, + ITEMINFO_ID, + ITEMINFO_AEGISNAME, + ITEMINFO_NAME, ITEMINFO_MAX }; @@ -569,7 +572,7 @@ enum mado_type { **/ enum itemskill_flag { ISF_NONE = 0x00, - ISF_IGNORECONDITIONS = 0x01, // Ignore skill conditions and don't consume them. + ISF_CHECKCONDITIONS = 0x01, // Check skill conditions and consume them. ISF_INSTANTCAST = 0x02, // Cast skill instantaneously. ISF_CASTONSELF = 0x04, // Forcefully cast skill on invoking character without showing the target selection cursor. }; diff --git a/src/map/skill.c b/src/map/skill.c index a8dbefbd7..a1a22f74f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1180,7 +1180,6 @@ static int skillnotok_mercenary(uint16 skill_id, struct mercenary_data *md) static struct s_skill_unit_layout *skill_get_unit_layout(uint16 skill_id, uint16 skill_lv, struct block_list *src, int x, int y) { int pos = skill->get_unit_layout_type(skill_id,skill_lv); - uint8 dir; nullpo_retr(&skill->dbs->unit_layout[0], src); if (pos < -1 || pos >= MAX_SKILL_UNIT_LAYOUT) { @@ -1191,7 +1190,9 @@ static struct s_skill_unit_layout *skill_get_unit_layout(uint16 skill_id, uint16 if (pos != -1) // simple single-definition layout return &skill->dbs->unit_layout[pos]; - dir = (src->x == x && src->y == y) ? 6 : map->calc_dir(src,x,y); // 6 - default aegis direction + enum unit_dir dir = UNIT_DIR_EAST; // default aegis direction + if (src->x != x || src->y != y) + dir = map->calc_dir(src, x, y); if (skill_id == MG_FIREWALL) return &skill->dbs->unit_layout [skill->firewall_unit_pos + dir]; @@ -2626,11 +2627,11 @@ static int skill_strip_equip(struct block_list *bl, unsigned short where, int ra /*========================================================================= * Used to knock back players, monsters, traps, etc * 'count' is the number of squares to knock back - * 'direction' indicates the way OPPOSITE to the knockback direction (or -1 for default behavior) + * 'direction' indicates the way OPPOSITE to the knockback direction (or UNIT_DIR_UNDEFINED for default behavior) * if 'flag&0x1', position update packets must not be sent. * if 'flag&0x2', skill blown ignores players' special_state.no_knockback */ -static int skill_blown(struct block_list *src, struct block_list *target, int count, int8 dir, int flag) +static int skill_blown(struct block_list *src, struct block_list *target, int count, enum unit_dir dir, int flag) { int dx = 0, dy = 0; struct status_change *tsc = status->get_sc(target); @@ -2672,10 +2673,10 @@ static int skill_blown(struct block_list *src, struct block_list *target, int co break; } - if (dir == -1) // <optimized>: do the computation here instead of outside + if (dir == UNIT_DIR_UNDEFINED) // <optimized>: do the computation here instead of outside dir = map->calc_dir(target, src->x, src->y); // direction from src to target, reversed - if (dir >= 0 && dir < 8) { + if (dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX) { // take the reversed 'direction' and reverse it dx = -dirx[dir]; dy = -diry[dir]; @@ -3297,7 +3298,7 @@ static int skill_attack(int attack_type, struct block_list *src, struct block_li //Only knockback if it's still alive, otherwise a "ghost" is left behind. [Skotlex] //Reflected spells do not bounce back (bl == dsrc since it only happens for direct skills) if (dmg.blewcount > 0 && bl!=dsrc && !status->isdead(bl)) { - int8 dir = -1; // default + enum unit_dir dir = UNIT_DIR_UNDEFINED; // default switch(skill_id) {//direction case MG_FIREWALL: case PR_SANCTUARY: @@ -3310,13 +3311,13 @@ static int skill_attack(int attack_type, struct block_list *src, struct block_li // This ensures the storm randomly pushes instead of exactly a cell backwards per official mechanics. case WZ_STORMGUST: if(!battle_config.stormgust_knockback) - dir = rnd()%8; + dir = rnd() % UNIT_DIR_MAX; break; case WL_CRIMSONROCK: dir = map->calc_dir(bl,skill->area_temp[4],skill->area_temp[5]); break; case MC_CARTREVOLUTION: - dir = 6; // Official servers push target to the West + dir = UNIT_DIR_EAST; // Official servers push target to the West break; default: dir = skill->attack_dir_unknown(&attack_type, src, dsrc, bl, &skill_id, &skill_lv, &tick, &flag); @@ -3337,8 +3338,12 @@ static int skill_attack(int attack_type, struct block_list *src, struct block_li case SR_KNUCKLEARROW: if( skill->blown(dsrc,bl,dmg.blewcount,dir,0) && !(flag&4) ) { short dir_x, dir_y; - dir_x = dirx[(dir+4)%8]; - dir_y = diry[(dir+4)%8]; + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; + } + dir_x = dirx[unit_get_opposite_dir(dir)]; + dir_y = diry[unit_get_opposite_dir(dir)]; if (map->getcell(bl->m, bl, bl->x + dir_x, bl->y + dir_y, CELL_CHKNOPASS) != 0) skill->addtimerskill(src, tick + 300 * ((flag&2) ? 1 : 2), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag|4); } @@ -3498,10 +3503,12 @@ static int skill_attack_copy_unknown(int *attack_type, struct block_list *src, s static int skill_attack_dir_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag) { - return -1; + return UNIT_DIR_UNDEFINED; } -static void skill_attack_blow_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir) +static void skill_attack_blow_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, + uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, + struct Damage *dmg, int64 *damage, enum unit_dir *dir) { nullpo_retv(bl); nullpo_retv(dmg); @@ -3512,7 +3519,7 @@ static void skill_attack_blow_unknown(int *attack_type, struct block_list *src, if (!dmg->blewcount && bl->type == BL_SKILL && *damage > 0){ struct skill_unit *su = BL_UCAST(BL_SKILL, bl); if (su->group && su->group->skill_id == HT_BLASTMINE) - skill->blown(src, bl, 3, -1, 0); + skill->blown(src, bl, 3, UNIT_DIR_UNDEFINED, 0); } } @@ -4406,7 +4413,7 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl case KN_CHARGEATK: { bool path_exists = path->search_long(NULL, src, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL); unsigned int dist = distance_bl(src, bl); - uint8 dir = map->calc_dir(bl, src->x, src->y); + enum unit_dir dir = map->calc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) @@ -4418,7 +4425,7 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl skill->blown(src, bl, dist, dir, 0); //HACK: since knockback officially defaults to the left, the client also turns to the left... therefore, // make the caster look in the direction of the target - unit->setdir(src, (dir+4)%8); + unit->set_dir(src, unit_get_opposite_dir(dir)); } } @@ -4457,12 +4464,13 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl case RG_BACKSTAP: { - uint8 dir = map->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl); - if ((!check_distance_bl(src, bl, 0) && !map->check_dir(dir, t_dir)) || bl->type == BL_SKILL) { + enum unit_dir dir = map->calc_dir(src, bl->x, bl->y); + enum unit_dir t_dir = unit->getdir(bl); + if ((!check_distance_bl(src, bl, 0) && map->check_dir(dir, t_dir) == 0) || bl->type == BL_SKILL) { status_change_end(src, SC_HIDING, INVALID_TIMER); skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); - dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest] - unit->setdir(bl,dir); + dir = unit_get_opposite_dir(dir); // change direction [Celest] + unit->set_dir(bl, dir); } else if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0, 0); @@ -4489,7 +4497,6 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl { short x, y, i = 2; // Move 2 cells for Issen(from target) struct block_list *mbl = bl; - short dir = 0; skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); @@ -4511,13 +4518,13 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl status->set_hp(src, 1, STATUS_HEAL_DEFAULT); #endif // RENEWAL } - dir = map->calc_dir(src,bl->x,bl->y); - if( dir > 0 && dir < 4) x = -i; - else if( dir > 4 ) x = i; - else x = 0; - if( dir > 2 && dir < 6 ) y = -i; - else if( dir == 7 || dir < 2 ) y = i; - else y = 0; + enum unit_dir dir = map->calc_dir(src, bl->x, bl->y); + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; + } + x = i * dirx[dir]; + y = i * diry[dir]; if ((mbl == src || (!map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground))) { // only NJ_ISSEN don't have slide effect in GVG if (!(unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1))) { // The cell is not reachable (wall, object, ...), move next to the target @@ -4744,12 +4751,12 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl if(idb_exists(skill->bowling_db, bl->id)) break; // Random direction - dir = rnd()%8; + dir = rnd() % UNIT_DIR_MAX; } else { // Create an empty list of already hit targets db_clear(skill->bowling_db); // Direction is walkpath - dir = (unit->getdir(src)+4)%8; + dir = unit_get_opposite_dir(unit->getdir(src)); } // Add current target to the list of already hit targets idb_put(skill->bowling_db, bl->id, bl); @@ -4758,6 +4765,10 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl ty = bl->y; for(i=0;i<c;i++) { // Target coordinates (get changed even if knockback fails) + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; + } tx -= dirx[dir]; ty -= diry[dir]; // If target cell is a wall then break @@ -4786,18 +4797,24 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl if (bl->id==skill->area_temp[1]) break; if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,SD_ANIMATION)) - skill->blown(src,bl,skill->area_temp[2],-1,0); + skill->blown(src, bl, skill->area_temp[2], UNIT_DIR_UNDEFINED, 0); } else { - int x=bl->x,y=bl->y,i,dir; - dir = map->calc_dir(bl,src->x,src->y); + int x = bl->x; + int y = bl->y; + int i; + enum unit_dir dir = map->calc_dir(bl, src->x, src->y); skill->area_temp[1] = bl->id; skill->area_temp[2] = skill->get_blewcount(skill_id,skill_lv); // all the enemies between the caster and the target are hit, as well as the target if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0)) - skill->blown(src,bl,skill->area_temp[2],-1,0); + skill->blown(src, bl, skill->area_temp[2], UNIT_DIR_UNDEFINED, 0); for (i=0;i<4;i++) { map->foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR,src,skill_id,skill_lv, tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; + } x += dirx[dir]; y += diry[dir]; } @@ -5019,7 +5036,7 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl if(rnd()%100 < (10 + 3*skill_lv)) { if( !sd || pc->checkskill(sd,KN_SPEARBOOMERANG) == 0 ) break; // Spear Boomerang auto cast chance only works if you have mastered Spear Boomerang. - skill->blown(src,bl,6,-1,0); + skill->blown(src, bl, 6, UNIT_DIR_UNDEFINED, 0); skill->addtimerskill(src,tick+800,bl->id,0,0,skill_id,skill_lv,BF_WEAPON,flag); skill->castend_damage_id(src,bl,KN_SPEARBOOMERANG,1,tick,0); } @@ -5027,7 +5044,7 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl case RK_PHANTOMTHRUST: { struct map_session_data *tsd = BL_CAST(BL_PC, bl); - unit->setdir(src,map->calc_dir(src, bl->x, bl->y)); + unit->set_dir(src, map->calc_dir(src, bl->x, bl->y)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill->blown(src,bl,distance_bl(src,bl)-1,unit->getdir(src),0); @@ -5041,16 +5058,13 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl case KO_JYUMONJIKIRI: case GC_DARKILLUSION: { - short x, y; - short dir = map->calc_dir(bl, src->x, src->y); - - if ( dir < 4 ) { - x = bl->x + 2 * (dir > 0) - 3 * (dir > 0); - y = bl->y + 1 - (dir / 2) - (dir > 2); - } else { - x = bl->x + 2 * (dir > 4) - 1 * (dir > 4); - y = bl->y + (dir / 6) - 1 + (dir > 6); + enum unit_dir dir = map->calc_dir(bl, src->x, src->y); + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; } + short x = bl->x + dirx[dir]; + short y = bl->y + diry[dir]; if ( unit->movepos(src, x, y, 1, 1) ) { clif->slide(src, x, y); @@ -5207,14 +5221,16 @@ static int skill_castend_damage_id(struct block_list *src, struct block_list *bl skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag|ELE_DARK); break; case RA_WUGSTRIKE: - if( sd && pc_isridingwug(sd) ){ - short x[8]={0,-1,-1,-1,0,1,1,1}; - short y[8]={1,1,0,-1,-1,-1,0,1}; - uint8 dir = map->calc_dir(bl, src->x, src->y); - - if( unit->movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) - { - clif->slide(src, bl->x+x[dir], bl->y+y[dir]); + if (sd != NULL && pc_isridingwug(sd)) { + enum unit_dir dir = map->calc_dir(bl, src->x, src->y); + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; + } + short x = bl->x + dirx[dir]; + short y = bl->y + diry[dir]; + if (unit->movepos(src, x, y, 1, 1) != 0) { + clif->slide(src, x, y); clif->fixpos(src); skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); } @@ -5657,8 +5673,9 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) } if(ud->skill_id == RG_BACKSTAP) { - uint8 dir = map->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target); - if(check_distance_bl(src, target, 0) || map->check_dir(dir,t_dir)) { + enum unit_dir dir = map->calc_dir(src, target->x, target->y); + enum unit_dir t_dir = unit->getdir(target); + if (check_distance_bl(src, target, 0) || map->check_dir(dir, t_dir) != 0) { break; } } @@ -5854,7 +5871,7 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) // Asura Strike caster doesn't look to their target in the end if (src->id != target->id && !is_asura) - unit->setdir(src, map->calc_dir(src, target->x, target->y)); + unit->set_dir(src, map->calc_dir(src, target->x, target->y)); map->freeblock_unlock(); return 1; @@ -5877,25 +5894,13 @@ static int skill_castend_id(int tid, int64 tick, int id, intptr_t data) } if (target && target->m == src->m) { //Move character to target anyway. - int dir, x, y; + enum unit_dir dir = map->calc_dir(src, target->x, target->y); + Assert_ret(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); int dist = 3; // number of cells that asura caster will walk + int x = dist * dirx[dir]; + int y = dist * diry[dir]; - dir = map->calc_dir(src,target->x,target->y); - if (dir > 0 && dir < 4) - x = -dist; - else if (dir > 4) - x = dist; - else - x = 0; - - if (dir > 2 && dir < 6) - y = -dist; - else if (dir == 7 || dir < 2) - y = dist; - else - y = 0; - - if (unit->movepos(src, src->x + x, src->y + y, 1, 1) == 1) { + if (unit->movepos(src, src->x + x, src->y + y, 1, 1) != 0) { //Display movement + animation. clif->slide(src, src->x, src->y); clif->spiritball(src); @@ -7835,7 +7840,9 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * case TK_HIGHJUMP: { - int x,y, dir = unit->getdir(src); + int x; + int y; + enum unit_dir dir = unit->getdir(src); //Fails on noteleport maps, except for GvG and BG maps [Skotlex] if( map->list[src->m].flag.noteleport @@ -8084,11 +8091,19 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * case NPC_RUN: { - const int mask[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}}; - uint8 dir = (bl == src)?unit->getdir(src):map->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. + enum unit_dir dir; + if (bl == src) //If cast on self, run forward, else run away. + dir = unit->getdir(src); + else + dir = map->calc_dir(src, bl->x, bl->y); + if (Assert_chk(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX)) { + map->freeblock_unlock(); // unblock before assert-returning + return 0; + } unit->stop_attack(src); //Run skillv tiles overriding the can-move check. - if (unit->walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md) + if (unit->walk_toxy(src, src->x + skill_lv * -dirx[dir], src->y + skill_lv * -diry[dir], 2) == 0 + && md != NULL) md->state.skillstate = MSS_WALK; //Otherwise it isn't updated in the AI. } break; @@ -9449,7 +9464,9 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list * case NC_F_SIDESLIDE: case NC_B_SIDESLIDE: { - uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit->getdir(src)+4)%8 : unit->getdir(src); + enum unit_dir dir = unit->getdir(src); + if (skill_id == NC_F_SIDESLIDE) + dir = unit_get_opposite_dir(dir); skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),dir,0); clif->slide(src,src->x,src->y); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -10827,7 +10844,7 @@ static int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) if( sd && sd->skillitem != AL_WARP ) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] sd->skillitem = sd->skillitemlv = 0; - unit->setdir(src, map->calc_dir(src, ud->skillx, ud->skilly)); + unit->set_dir(src, map->calc_dir(src, ud->skillx, ud->skilly)); if (ud->skilltimer == INVALID_TIMER) { if (md) md->skill_idx = -1; @@ -11606,17 +11623,16 @@ static int skill_castend_pos2(struct block_list *src, int x, int y, uint16 skill case WL_EARTHSTRAIN: { - int i, wave = skill_lv + 4, dir = map->calc_dir(src,x,y); + int i; + int wave = skill_lv + 4; + enum unit_dir dir = map->calc_dir(src, x, y); + Assert_ret(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); int sx = x = src->x, sy = y = src->y; // Store first caster's location to avoid glitch on unit setting - for( i = 1; i <= wave; i++ ) - { - switch( dir ){ - case 0: case 1: case 7: sy = y + i; break; - case 3: case 4: case 5: sy = y - i; break; - case 2: sx = x - i; break; - case 6: sx = x + i; break; - } + for (i = 1; i <= wave; i++) { + sy = y + i * diry[dir]; + if (dir == UNIT_DIR_WEST || dir == UNIT_DIR_EAST) + sx = x + i * dirx[dir]; skill->addtimerskill(src,timer->gettick() + (140 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2); } } @@ -13835,12 +13851,14 @@ static int skill_check_condition_char_sub(struct block_list *bl, va_list ap) } else { switch(skill_id) { - case PR_BENEDICTIO: { - uint8 dir = map->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); - dir = (unit->getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. - if ((tsd->job & MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest. - && sd->status.sp >= 10) + case PR_BENEDICTIO: + { + enum unit_dir dir = map->calc_dir(&sd->bl, tsd->bl.x, tsd->bl.y); + dir = (unit->getdir(&sd->bl) + dir) % UNIT_DIR_MAX; //This adjusts dir to account for the direction the sd is facing. + if ((tsd->job & MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == UNIT_DIR_WEST || dir == UNIT_DIR_EAST) //Must be standing to the left/right of Priest. + && sd->status.sp >= 10) { p_sd[(*c)++]=tsd->bl.id; + } return 1; } case AB_ADORAMUS: @@ -14024,7 +14042,7 @@ static int skill_check_condition_castbegin(struct map_session_data *sd, uint16 s if (sd->chat_id != 0) return 0; - if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_no_conditions == 1) + if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_check_conditions == 0) && skill->is_item_skill(sd, skill_id, skill_lv)) { return 1; } @@ -15013,7 +15031,7 @@ static int skill_check_condition_castend(struct map_session_data *sd, uint16 ski if (sd->chat_id != 0) return 0; - if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_no_conditions == 1) + if ((sd->state.itemskill_conditions_checked == 1 || sd->state.itemskill_check_conditions == 0) && skill->is_item_skill(sd, skill_id, skill_lv)) { return 1; } @@ -15219,7 +15237,7 @@ static int skill_consume_requirement(struct map_session_data *sd, uint16 skill_i nullpo_ret(sd); - if (sd->state.itemskill_no_conditions == 1 && skill->is_item_skill(sd, skill_id, skill_lv)) + if (sd->state.itemskill_check_conditions == 0 && skill->is_item_skill(sd, skill_id, skill_lv)) return 1; req = skill->get_requirement(sd,skill_id,skill_lv); @@ -15976,11 +15994,11 @@ struct square { int val2[5]; }; -static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int16 y) +static void skill_brandishspear_first(struct square *tc, enum unit_dir dir, int16 x, int16 y) { nullpo_retv(tc); - if(dir == 0){ + if (dir == UNIT_DIR_NORTH) { tc->val1[0]=x-2; tc->val1[1]=x-1; tc->val1[2]=x; @@ -15991,7 +16009,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]= tc->val2[3]= tc->val2[4]=y-1; - } else if(dir==2){ + } else if (dir == UNIT_DIR_WEST) { tc->val1[0]= tc->val1[1]= tc->val1[2]= @@ -16002,7 +16020,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]=y; tc->val2[3]=y-1; tc->val2[4]=y-2; - } else if(dir==4){ + } else if (dir == UNIT_DIR_SOUTH) { tc->val1[0]=x-2; tc->val1[1]=x-1; tc->val1[2]=x; @@ -16013,7 +16031,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]= tc->val2[3]= tc->val2[4]=y+1; - } else if(dir==6){ + } else if (dir == UNIT_DIR_EAST) { tc->val1[0]= tc->val1[1]= tc->val1[2]= @@ -16024,7 +16042,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]=y; tc->val2[3]=y-1; tc->val2[4]=y-2; - } else if(dir==1){ + } else if (dir == UNIT_DIR_NORTHWEST) { tc->val1[0]=x-1; tc->val1[1]=x; tc->val1[2]=x+1; @@ -16035,7 +16053,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]=y-1; tc->val2[3]=y; tc->val2[4]=y+1; - } else if(dir==3){ + } else if (dir == UNIT_DIR_SOUTHWEST) { tc->val1[0]=x+3; tc->val1[1]=x+2; tc->val1[2]=x+1; @@ -16046,7 +16064,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]=y+1; tc->val2[3]=y+2; tc->val2[4]=y+3; - } else if(dir==5){ + } else if (dir == UNIT_DIR_SOUTHEAST) { tc->val1[0]=x+1; tc->val1[1]=x; tc->val1[2]=x-1; @@ -16057,7 +16075,7 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int tc->val2[2]=y+1; tc->val2[3]=y; tc->val2[4]=y-1; - } else if(dir==7){ + } else if (dir == UNIT_DIR_NORTHEAST) { tc->val1[0]=x-3; tc->val1[1]=x-2; tc->val1[2]=x-1; @@ -16072,36 +16090,27 @@ static void skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int } -static void skill_brandishspear_dir(struct square *tc, uint8 dir, int are) +static void skill_brandishspear_dir(struct square *tc, enum unit_dir dir, int are) { - int c; nullpo_retv(tc); + Assert_retv(dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); - for( c = 0; c < 5; c++ ) { - switch( dir ) { - case 0: tc->val2[c]+=are; break; - case 1: tc->val1[c]-=are; tc->val2[c]+=are; break; - case 2: tc->val1[c]-=are; break; - case 3: tc->val1[c]-=are; tc->val2[c]-=are; break; - case 4: tc->val2[c]-=are; break; - case 5: tc->val1[c]+=are; tc->val2[c]-=are; break; - case 6: tc->val1[c]+=are; break; - case 7: tc->val1[c]+=are; tc->val2[c]+=are; break; - } + for (int c = 0; c < 5; c++) { + tc->val1[c] += dirx[dir] * are; + tc->val2[c] += diry[dir] * are; } } static void skill_brandishspear(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { int c,n=4; - uint8 dir; struct square tc; int x, y; nullpo_retv(bl); x = bl->x; y = bl->y; - dir = map->calc_dir(src, x, y); + enum unit_dir dir = map->calc_dir(src, x, y); skill->brandishspear_first(&tc,dir,x,y); skill->brandishspear_dir(&tc,dir,4); skill->area_temp[1] = bl->id; diff --git a/src/map/skill.h b/src/map/skill.h index eff9ed7fc..c65547181 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -23,6 +23,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // enum sc_type +#include "map/unitdefines.h" // enum unit_dir #include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // MAX_SKILL_DB, struct square @@ -2002,7 +2003,7 @@ struct skill_interface { int (*addtimerskill) (struct block_list *src, int64 tick, int target, int x, int y, uint16 skill_id, uint16 skill_lv, int type, int flag); int (*additional_effect) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int dmg_lv, int64 tick); int (*counter_additional_effect) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int64 tick); - int (*blown) (struct block_list* src, struct block_list* target, int count, int8 dir, int flag); + int (*blown) (struct block_list* src, struct block_list* target, int count, enum unit_dir dir, int flag); int (*break_equip) (struct block_list *bl, unsigned short where, int rate, int flag); int (*strip_equip) (struct block_list *bl, unsigned short where, int rate, int lv, int time); struct skill_unit_group* (*id2group) (int group_id); @@ -2085,8 +2086,8 @@ struct skill_interface { bool (*dance_switch) (struct skill_unit* su, int flag); int (*check_condition_char_sub) (struct block_list *bl, va_list ap); int (*check_condition_mob_master_sub) (struct block_list *bl, va_list ap); - void (*brandishspear_first) (struct square *tc, uint8 dir, int16 x, int16 y); - void (*brandishspear_dir) (struct square* tc, uint8 dir, int are); + void (*brandishspear_first) (struct square *tc, enum unit_dir dir, int16 x, int16 y); + void (*brandishspear_dir) (struct square* tc, enum unit_dir dir, int are); int (*get_fixed_cast) (int skill_id, int skill_lv); int (*sit_count) (struct block_list *bl, va_list ap); int (*sit_in) (struct block_list *bl, va_list ap); @@ -2163,7 +2164,7 @@ struct skill_interface { void (*attack_display_unknown) (int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage); int (*attack_copy_unknown) (int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); int (*attack_dir_unknown) (int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); - void (*attack_blow_unknown) (int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir); + void (*attack_blow_unknown) (int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, enum unit_dir *dir); void (*attack_post_unknown) (int *attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); bool (*timerskill_dead_unknown) (struct block_list *src, struct unit_data *ud, struct skill_timerskill *skl); void (*timerskill_target_unknown) (int tid, int64 tick, struct block_list *src, struct block_list *target, struct unit_data *ud, struct skill_timerskill *skl); diff --git a/src/map/status.c b/src/map/status.c index 1f0f31119..4d798b606 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -801,21 +801,21 @@ static void initChangeTables(void) set_sc_with_vfx( GN_ILLUSIONDOPING , SC_ILLUSIONDOPING , SCB_HIT ); // Storing the target job rather than simply SC_SOULLINK simplifies code later on. - status->dbs->Skill2SCTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST, - status->dbs->Skill2SCTable[SL_MONK] = (sc_type)MAPID_MONK, - status->dbs->Skill2SCTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR, - status->dbs->Skill2SCTable[SL_SAGE] = (sc_type)MAPID_SAGE, - status->dbs->Skill2SCTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER, - status->dbs->Skill2SCTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE, - status->dbs->Skill2SCTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT, - status->dbs->Skill2SCTable[SL_WIZARD] = (sc_type)MAPID_WIZARD, - status->dbs->Skill2SCTable[SL_PRIEST] = (sc_type)MAPID_PRIEST, - status->dbs->Skill2SCTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER, - status->dbs->Skill2SCTable[SL_ROGUE] = (sc_type)MAPID_ROGUE, - status->dbs->Skill2SCTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN, - status->dbs->Skill2SCTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH, - status->dbs->Skill2SCTable[SL_HUNTER] = (sc_type)MAPID_HUNTER, - status->dbs->Skill2SCTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER, + status->dbs->Skill2SCTable[skill->get_index(SL_ALCHEMIST)] = (sc_type)MAPID_ALCHEMIST, + status->dbs->Skill2SCTable[skill->get_index(SL_MONK)] = (sc_type)MAPID_MONK, + status->dbs->Skill2SCTable[skill->get_index(SL_STAR)] = (sc_type)MAPID_STAR_GLADIATOR, + status->dbs->Skill2SCTable[skill->get_index(SL_SAGE)] = (sc_type)MAPID_SAGE, + status->dbs->Skill2SCTable[skill->get_index(SL_CRUSADER)] = (sc_type)MAPID_CRUSADER, + status->dbs->Skill2SCTable[skill->get_index(SL_SUPERNOVICE)] = (sc_type)MAPID_SUPER_NOVICE, + status->dbs->Skill2SCTable[skill->get_index(SL_KNIGHT)] = (sc_type)MAPID_KNIGHT, + status->dbs->Skill2SCTable[skill->get_index(SL_WIZARD)] = (sc_type)MAPID_WIZARD, + status->dbs->Skill2SCTable[skill->get_index(SL_PRIEST)] = (sc_type)MAPID_PRIEST, + status->dbs->Skill2SCTable[skill->get_index(SL_BARDDANCER)] = (sc_type)MAPID_BARDDANCER, + status->dbs->Skill2SCTable[skill->get_index(SL_ROGUE)] = (sc_type)MAPID_ROGUE, + status->dbs->Skill2SCTable[skill->get_index(SL_ASSASIN)] = (sc_type)MAPID_ASSASSIN, + status->dbs->Skill2SCTable[skill->get_index(SL_BLACKSMITH)] = (sc_type)MAPID_BLACKSMITH, + status->dbs->Skill2SCTable[skill->get_index(SL_HUNTER)] = (sc_type)MAPID_HUNTER, + status->dbs->Skill2SCTable[skill->get_index(SL_SOULLINKER)] = (sc_type)MAPID_SOUL_LINKER, // Other SC which are not necessarily associated to skills. status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION1] |= SCB_ASPD; diff --git a/src/map/unit.c b/src/map/unit.c index 29a01aea7..d2cfcb03d 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -57,6 +57,7 @@ #include "common/showmsg.h" #include "common/socket.h" #include "common/timer.h" +#include "common/utils.h" #include <stdio.h> #include <stdlib.h> @@ -71,20 +72,65 @@ struct unit_interface *unit; /** * Returns the unit_data for the given block_list. If the object is using * shared unit_data (i.e. in case of BL_NPC), it returns the shared data. - * @param bl block_list to process + * + * __Warning:__ if bl->type is not known or NULL, + * an assertion will be triggered and NULL returned. + * @param bl block_list to process, it is expected to be not NULL. * @return a pointer to the given object's unit_data **/ static struct unit_data *unit_bl2ud(struct block_list *bl) { - if (bl == NULL) return NULL; - if (bl->type == BL_PC) return &BL_UCAST(BL_PC, bl)->ud; - if (bl->type == BL_MOB) return &BL_UCAST(BL_MOB, bl)->ud; - if (bl->type == BL_PET) return &BL_UCAST(BL_PET, bl)->ud; - if (bl->type == BL_NPC) return BL_UCAST(BL_NPC, bl)->ud; - if (bl->type == BL_HOM) return &BL_UCAST(BL_HOM, bl)->ud; - if (bl->type == BL_MER) return &BL_UCAST(BL_MER, bl)->ud; - if (bl->type == BL_ELEM) return &BL_UCAST(BL_ELEM, bl)->ud; - return NULL; + Assert_retr(NULL, bl != NULL); + switch (bl->type) { + case BL_PC: + return &BL_UCAST(BL_PC, bl)->ud; + case BL_MOB: + return &BL_UCAST(BL_MOB, bl)->ud; + case BL_PET: + return &BL_UCAST(BL_PET, bl)->ud; + case BL_NPC: + return BL_UCAST(BL_NPC, bl)->ud; + case BL_HOM: + return &BL_UCAST(BL_HOM, bl)->ud; + case BL_MER: + return &BL_UCAST(BL_MER, bl)->ud; + case BL_ELEM: + return &BL_UCAST(BL_ELEM, bl)->ud; + default: + Assert_retr(NULL, false); + } +} + +/** + * Returns the const unit_data for the given const block_list. If the object is using + * shared unit_data (i.e. in case of BL_NPC), it returns the shared data. + * + * __Warning:__ if bl->type is not known or NULL, + * an assertion will be triggered and NULL returned. + * @param bl block_list to process, it is expected to be not NULL. + * @return a pointer to the given object's unit_data + **/ +static const struct unit_data *unit_cbl2ud(const struct block_list *bl) +{ + Assert_retr(NULL, bl != NULL); + switch (bl->type) { + case BL_PC: + return &BL_UCCAST(BL_PC, bl)->ud; + case BL_MOB: + return &BL_UCCAST(BL_MOB, bl)->ud; + case BL_PET: + return &BL_UCCAST(BL_PET, bl)->ud; + case BL_NPC: + return BL_UCCAST(BL_NPC, bl)->ud; + case BL_HOM: + return &BL_UCCAST(BL_HOM, bl)->ud; + case BL_MER: + return &BL_UCCAST(BL_MER, bl)->ud; + case BL_ELEM: + return &BL_UCCAST(BL_ELEM, bl)->ud; + default: + Assert_retr(NULL, false); + } } /** @@ -105,42 +151,46 @@ static struct unit_data *unit_bl2ud2(struct block_list *bl) return unit->bl2ud(bl); } -static int unit_walktoxy_sub(struct block_list *bl) +/** + * TODO: understand purpose of this function + * @param bl block_list to process + * @return 0: success, 1: fail, 2: nullpointer + */ +static int unit_walk_toxy_sub(struct block_list *bl) { - int i; - struct walkpath_data wpd; - struct unit_data *ud = NULL; - - nullpo_retr(1, bl); - ud = unit->bl2ud(bl); - if(ud == NULL) return 0; + nullpo_retr(2, bl); + struct unit_data *ud = unit->bl2ud(bl); + if (ud == NULL) + return 2; - memset(&wpd, 0, sizeof(wpd)); + struct walkpath_data wpd = {0}; - if( !path->search(&wpd,bl,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) ) - return 0; + if (!path->search(&wpd, bl, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, ud->state.walk_easy, CELL_CHKNOPASS)) + return 1; #ifdef OFFICIAL_WALKPATH - if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, CELL_CHKNOPASS) // Check if there is an obstacle between - && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] - && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. - return 0; + if (bl->type != BL_NPC // If type is an NPC, disregard. + && !path->search_long(NULL, bl, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, CELL_CHKNOPASS) // Check if there is an obstacle between + && wpd.path_len > 14) { // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] + return 1; + } #endif - memcpy(&ud->walkpath,&wpd,sizeof(wpd)); + ud->walkpath = wpd; - if (ud->target_to && ud->chaserange>1) { - //Generally speaking, the walk path is already to an adjacent tile - //so we only need to shorten the path if the range is greater than 1. + if (ud->target_to != 0 && ud->chaserange > 1) { + // Generally speaking, the walk path is already to an adjacent tile + // so we only need to shorten the path if the range is greater than 1. - //Trim the last part of the path to account for range, - //but always move at least one cell when requested to move. - for (i = (ud->chaserange*10)-10; i > 0 && ud->walkpath.path_len>1;) { - uint8 dir; + // Trim the last part of the path to account for range, + // but always move at least one cell when requested to move. + for (int i = ud->chaserange * 10 - 10; i > 0 && ud->walkpath.path_len > 1;) { + enum unit_dir dir; ud->walkpath.path_len--; dir = ud->walkpath.path[ud->walkpath.path_len]; - if (dir&1) - i -= MOVE_COST*20; //When chasing, units will target a diamond-shaped area in range [Playtester] + Assert_retr(1, dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); + if (unit_is_diagonal_dir(dir)) + i -= MOVE_COST * 20; // When chasing, units will target a diamond-shaped area in range [Playtester] else i -= MOVE_COST; ud->to_x -= dirx[dir]; @@ -148,7 +198,7 @@ static int unit_walktoxy_sub(struct block_list *bl) } } - ud->state.change_walk_target=0; + ud->state.change_walk_target = 0; if (bl->type == BL_PC) { struct map_session_data *sd = BL_UCAST(BL_PC, bl); @@ -157,15 +207,17 @@ static int unit_walktoxy_sub(struct block_list *bl) } clif->move(ud); - if(ud->walkpath.path_pos>=ud->walkpath.path_len) - i = -1; - else if(ud->walkpath.path[ud->walkpath.path_pos]&1) - i = status->get_speed(bl)*MOVE_DIAGONAL_COST/MOVE_COST; + int timer_delay; + if (ud->walkpath.path_pos >= ud->walkpath.path_len) + timer_delay = -1; + else if ((ud->walkpath.path[ud->walkpath.path_pos] & 1) != 0) + timer_delay = status->get_speed(bl) * MOVE_DIAGONAL_COST / MOVE_COST; else - i = status->get_speed(bl); - if( i > 0) - ud->walktimer = timer->add(timer->gettick()+i,unit->walktoxy_timer,bl->id,i); - return 1; + timer_delay = status->get_speed(bl); + + if (timer_delay > 0) + ud->walktimer = timer->add(timer->gettick() + timer_delay, unit->walk_toxy_timer, bl->id, 0); //TODO: check if unit->walk_toxy_timer uses any intptr data + return 0; } /** @@ -173,289 +225,278 @@ static int unit_walktoxy_sub(struct block_list *bl) * @param tid: Timer ID * @param tick: Unused * @param id: ID of bl to do the action - * @param data: Not used - * @return 1: Success 0: Fail (No valid bl) + * @param data: Unused + * @return 0: success, 1: fail, 2: nullpointer */ -static int unit_step_timer(int tid, int64 tick, int id, intptr_t data) +static int unit_steptimer(int tid, int64 tick, int id, intptr_t data) { - struct block_list *bl; - struct unit_data *ud; - int target_id; - - bl = map->id2bl(id); - - if (!bl || bl->prev == NULL) - return 0; - - ud = unit->bl2ud(bl); - - if(!ud) - return 0; + struct block_list *bl = map->id2bl(id); + if (bl == NULL || bl->prev == NULL) + return 2; + struct unit_data *ud = unit->bl2ud(bl); + if (ud == NULL) + return 2; - if(ud->steptimer != tid) { - ShowError("unit_step_timer mismatch %d != %d\n",ud->steptimer,tid); - return 0; + if (ud->steptimer != tid) { + ShowError("unit_steptimer mismatch %d != %d\n", ud->steptimer, tid); + return 1; } ud->steptimer = INVALID_TIMER; - if(!ud->stepaction) - return 0; + if (!ud->stepaction) + return 1; - //Set to false here because if an error occurs, it should not be executed again + // Set to false here because if an error occurs, it should not be executed again ud->stepaction = false; - if(!ud->target_to) - return 0; + if (ud->target_to == 0) + return 1; - //Flush target_to as it might contain map coordinates which should not be used by other functions - target_id = ud->target_to; + // Flush target_to as it might contain map coordinates which should not be used by other functions + int target_id = ud->target_to; ud->target_to = 0; - //If stepaction is set then we remembered a client request that should be executed on the next step - //Execute request now if target is in attack range - if(ud->stepskill_id && skill->get_inf(ud->stepskill_id) & INF_GROUND_SKILL) { - //Execute ground skill + // If stepaction is set then we remembered a client request that should be executed on the next step + // Execute request now if target is in attack range + if (ud->stepskill_id != 0 && (skill->get_inf(ud->stepskill_id) & INF_GROUND_SKILL) != 0) { + // Execute ground skill struct map_data *md = &map->list[bl->m]; - unit->skilluse_pos(bl, target_id%md->xs, target_id/md->xs, ud->stepskill_id, ud->stepskill_lv); + unit->skilluse_pos(bl, target_id % md->xs, target_id / md->xs, ud->stepskill_id, ud->stepskill_lv); } else { - //If a player has target_id set and target is in range, attempt attack + // If a player has target_id set and target is in range, attempt attack struct block_list *tbl = map->id2bl(target_id); - if (!tbl || !status->check_visibility(bl, tbl)) { - return 0; - } - if(ud->stepskill_id == 0) { - //Execute normal attack - unit->attack(bl, tbl->id, (ud->state.attack_continue) + 2); - } else { - //Execute non-ground skill - unit->skilluse_id(bl, tbl->id, ud->stepskill_id, ud->stepskill_lv); - } + nullpo_retr(2, tbl); + if (status->check_visibility(bl, tbl) == 0) // Target not visible + return 1; + if (ud->stepskill_id == 0) + unit->attack(bl, tbl->id, ud->state.attack_continue + 2); // Execute normal attack + else + unit->skilluse_id(bl, tbl->id, ud->stepskill_id, ud->stepskill_lv); // Execute non-ground skill } - return 1; + return 0; } -static int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) +/** + * Warps homunculus or mercenary towards his master in case he's too far away for 3 seconds. + * @param master_bl: block_list of master + * @param slave_bl: block_list of homunculus/mercenary master owns + * @return 0: success, 1: fail + */ +static int unit_warpto_master(struct block_list *master_bl, struct block_list *slave_bl) { - int i; - int x,y,dx,dy; - unsigned char icewall_walk_block; - uint8 dir; - struct block_list *bl; - struct map_session_data *sd; - struct mob_data *md; - struct unit_data *ud; - struct mercenary_data *mrd; + nullpo_retr(1, master_bl); + nullpo_retr(1, slave_bl); + int64 *masterteleport_timer; + struct homun_data *hd = BL_CAST(BL_HOM, slave_bl); + struct mercenary_data *md = BL_CAST(BL_MER, slave_bl); + + bool check = true; + if (hd != NULL) { + masterteleport_timer = &hd->masterteleport_timer; + check = homun_alive(hd); + } else if (md != NULL) { + masterteleport_timer = &md->masterteleport_timer; + } else { + return 1; + } - bl = map->id2bl(id); - if(bl == NULL) - return 0; - sd = BL_CAST(BL_PC, bl); - md = BL_CAST(BL_MOB, bl); - mrd = BL_CAST(BL_MER, bl); - ud = unit->bl2ud(bl); + if (check && !check_distance_bl(master_bl, slave_bl, MAX_MER_DISTANCE)) { + if (*masterteleport_timer == 0) { + *masterteleport_timer = timer->gettick(); + return 0; + } else if (DIFF_TICK(timer->gettick(), *masterteleport_timer) > 3000) { + unit->warp(slave_bl, master_bl->m, master_bl->x, master_bl->y, CLR_TELEPORT); + } + } + *masterteleport_timer = 0; // resets tick in case he isn't far anymore. - if(ud == NULL) return 0; + return 0; +} + +/** + * Timer for walking to target coordinates or object. + * @param tid: timer id + * @param tick: tick + * @param id: id of bl to do the action + * @param data: unused + * @return 0: success, 1: fail + */ +static int unit_walk_toxy_timer(int tid, int64 tick, int id, intptr_t data) +{ + struct block_list *bl = map->id2bl(id); + if (bl == NULL || bl->prev == NULL) // Stop moved because it is missing from the block_list + return 1; + struct unit_data *ud = unit->bl2ud(bl); + if (ud == NULL) + return 1; - if(ud->walktimer != tid){ + if (ud->walktimer != tid) { ShowError("unit_walk_timer mismatch %d != %d\n",ud->walktimer,tid); - return 0; + return 1; } ud->walktimer = INVALID_TIMER; - if (bl->prev == NULL) return 0; // Stop moved because it is missing from the block_list - - if(ud->walkpath.path_pos>=ud->walkpath.path_len) - return 0; - if(ud->walkpath.path[ud->walkpath.path_pos]>=8) + if (ud->walkpath.path_pos >= ud->walkpath.path_len) return 1; - x = bl->x; - y = bl->y; - dir = ud->walkpath.path[ud->walkpath.path_pos]; + enum unit_dir dir = ud->walkpath.path[ud->walkpath.path_pos]; + Assert_retr(1, dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); + int x = bl->x; + int y = bl->y; + ud->dir = dir; - dx = dirx[(int)dir]; - dy = diry[(int)dir]; + int dx = dirx[dir]; + int dy = diry[dir]; - //Get icewall walk block depending on boss mode (players can't be trapped) - if(md && md->status.mode&MD_BOSS) - icewall_walk_block = battle_config.boss_icewall_walk_block; - else if(md) - icewall_walk_block = battle_config.mob_icewall_walk_block; - else - icewall_walk_block = 0; + // Get icewall walk block depending on boss mode (players can't be trapped) + unsigned char icewall_walk_block = 0; + struct mob_data *md = BL_CAST(BL_MOB, bl); + if (md != NULL) { + if ((md->status.mode & MD_BOSS) != 0) + icewall_walk_block = battle_config.boss_icewall_walk_block; + else + icewall_walk_block = battle_config.mob_icewall_walk_block; + } - //Monsters will walk into an icewall from the west and south if they already started walking + // Monsters will walk into an icewall from the west and south if they already started walking if (map->getcell(bl->m, bl, x + dx, y + dy, CELL_CHKNOPASS) && (icewall_walk_block == 0 || !map->getcell(bl->m, bl, x + dx, y + dy, CELL_CHKICEWALL) || dx < 0 || dy < 0)) - return unit->walktoxy_sub(bl); + return unit->walk_toxy_sub(bl); - //Monsters can only leave icewalls to the west and south - //But if movement fails more than icewall_walk_block times, they can ignore this rule - if (md && md->walktoxy_fail_count < icewall_walk_block && map->getcell(bl->m, bl, x, y, CELL_CHKICEWALL) && (dx > 0 || dy > 0)) { - //Needs to be done here so that rudeattack skills are invoked + // Monsters can only leave icewalls to the west and south + // But if movement fails more than icewall_walk_block times, they can ignore this rule + if (md != NULL && md->walktoxy_fail_count < icewall_walk_block && map->getcell(bl->m, bl, x, y, CELL_CHKICEWALL) != 0 && (dx > 0 || dy > 0)) { + // Needs to be done here so that rudeattack skills are invoked md->walktoxy_fail_count++; clif->fixpos(bl); - //Monsters in this situation first use a chase skill, then unlock target and then use an idle skill - if (!(++ud->walk_count%WALK_SKILL_INTERVAL)) + // Monsters in this situation first use a chase skill, then unlock target and then use an idle skill + if ((++ud->walk_count % WALK_SKILL_INTERVAL) == 0) mob->skill_use(md, tick, -1); mob->unlocktarget(md, tick); - if (!(++ud->walk_count%WALK_SKILL_INTERVAL)) + if ((++ud->walk_count % WALK_SKILL_INTERVAL) != 0) mob->skill_use(md, tick, -1); - return 0; + return 1; } + struct map_session_data *sd = BL_CAST(BL_PC, bl); //Refresh view for all those we lose sight - map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, (sd != NULL ? BL_ALL : BL_PC), bl); x += dx; y += dy; map->moveblock(bl, x, y, tick); - ud->walk_count++; //walked cell counter, to be used for walk-triggered skills. [Skotlex] + ud->walk_count++; // walked cell counter, to be used for walk-triggered skills. [Skotlex] status_change_end(bl, SC_ROLLINGCUTTER, INVALID_TIMER); //If you move, you lose your counters. [malufett] if (bl->x != x || bl->y != y || ud->walktimer != INVALID_TIMER) - return 0; //map->moveblock has altered the object beyond what we expected (moved/warped it) + return 1; // map->moveblock has altered the object beyond what we expected (moved/warped it) ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets - map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, (sd != NULL ? BL_ALL : BL_PC), bl); ud->walktimer = INVALID_TIMER; - if(sd) { - if( sd->touching_id ) - npc->touchnext_areanpc(sd,false); + struct mercenary_data *mrd = BL_CAST(BL_MER, bl); + if (sd != NULL) { + if (sd->touching_id != 0) + npc->touchnext_areanpc(sd, false); if (map->getcell(bl->m, bl, x, y, CELL_CHKNPC)) { - npc->touch_areanpc(sd,bl->m,x,y); + npc->touch_areanpc(sd, bl->m, x, y); if (bl->prev == NULL) //Script could have warped char, abort remaining of the function. return 0; - } else + } else { npc->untouch_areanpc(sd, bl->m, x, y); - - if( sd->md ) { // mercenary should be warped after being 3 seconds too far from the master [greenbox] - if( !check_distance_bl(&sd->bl, &sd->md->bl, MAX_MER_DISTANCE) ) { - if (sd->md->masterteleport_timer == 0) - sd->md->masterteleport_timer = timer->gettick(); - else if (DIFF_TICK(timer->gettick(), sd->md->masterteleport_timer) > 3000) { - sd->md->masterteleport_timer = 0; - unit->warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); - } - } else // reset the tick, he is not far anymore - sd->md->masterteleport_timer = 0; - } - if( sd->hd ) { - if( homun_alive(sd->hd) && !check_distance_bl(&sd->bl, &sd->hd->bl, MAX_MER_DISTANCE) ) { - if (sd->hd->masterteleport_timer == 0) - sd->hd->masterteleport_timer = timer->gettick(); - else if (DIFF_TICK(timer->gettick(), sd->hd->masterteleport_timer) > 3000) { - sd->hd->masterteleport_timer = 0; - unit->warp( &sd->hd->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); - } - } else - sd->hd->masterteleport_timer = 0; } + + if (sd->md != NULL) // mercenary should be warped after being 3 seconds too far from the master [greenbox] + unit->warpto_master(bl, &sd->md->bl); + if (sd->hd != NULL) + unit->warpto_master(bl, &sd->hd->bl); } else if (md) { - //Movement was successful, reset walktoxy_fail_count + // Movement was successful, reset walktoxy_fail_count md->walktoxy_fail_count = 0; - if (map->getcell(bl->m, bl, x, y, CELL_CHKNPC)) { - if( npc->touch_areanpc2(md) ) return 0; // Warped - } else + + if (map->getcell(bl->m, bl, x, y, CELL_CHKNPC) != 0 && npc->touch_areanpc2(md)) + return 0; // Warped + else md->areanpc_id = 0; - if (md->min_chase > md->db->range3) md->min_chase--; - //Walk skills are triggered regardless of target due to the idle-walk mob state. - //But avoid triggering on stop-walk calls. - if (tid != INVALID_TIMER - && !(ud->walk_count%WALK_SKILL_INTERVAL) - && map->list[bl->m].users > 0 - && mob->skill_use(md, tick, -1) - ) { + + if (md->min_chase > md->db->range3) + md->min_chase--; + // Walk skills are triggered regardless of target due to the idle-walk mob state. + // But avoid triggering on stop-walk calls. + if (tid != INVALID_TIMER && (ud->walk_count % WALK_SKILL_INTERVAL) == 0 + && map->list[bl->m].users > 0 && mob->skill_use(md, tick, -1) == 1) { + // Walk skills are supposed to be used while walking if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER) - && md->state.skillstate != MSS_WALK //Walk skills are supposed to be used while walking - ) { - //Skill used, abort walking - clif->fixpos(bl); //Fix position as walk has been canceled. - return 0; + && md->state.skillstate != MSS_WALK) { + // Skill used, abort walking + clif->fixpos(bl); // Fix position as walk has been canceled. + return 1; } - //Resend walk packet for proper Self Destruction display. + // Resend walk packet for proper Self Destruction display. clif->move(ud); } - } - else if( mrd && mrd->master ) - { - if (!check_distance_bl(&mrd->master->bl, bl, MAX_MER_DISTANCE)) - { - // mercenary should be warped after being 3 seconds too far from the master [greenbox] - if (mrd->masterteleport_timer == 0) - { - mrd->masterteleport_timer = timer->gettick(); - } - else if (DIFF_TICK(timer->gettick(), mrd->masterteleport_timer) > 3000) - { - mrd->masterteleport_timer = 0; - unit->warp( bl, mrd->master->bl.m, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); - } - } - else - { - mrd->masterteleport_timer = 0; - } + } else if (mrd != NULL && mrd->master != NULL) { + unit->warpto_master(&mrd->master->bl, bl); } - if(tid == INVALID_TIMER) //A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant. + if(tid == INVALID_TIMER) // A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant. return 0; - //If stepaction is set then we remembered a client request that should be executed on the next step - if (ud->stepaction && ud->target_to) { - //Delete old stepaction even if not executed yet, the latest command is what counts - if(ud->steptimer != INVALID_TIMER) { - timer->delete(ud->steptimer, unit->step_timer); + // If stepaction is set then we remembered a client request that should be executed on the next step + if (ud->stepaction && ud->target_to != 0) { + // Delete old stepaction even if not executed yet, the latest command is what counts + if (ud->steptimer != INVALID_TIMER) { + timer->delete(ud->steptimer, unit->steptimer); ud->steptimer = INVALID_TIMER; } - //Delay stepactions by half a step (so they are executed at full step) - if(ud->walkpath.path[ud->walkpath.path_pos]&1) - i = status->get_speed(bl)*14/20; + // Delay stepactions by half a step (so they are executed at full step) + int timer_delay; + if ((ud->walkpath.path[ud->walkpath.path_pos] & 1) != 0) + timer_delay = status->get_speed(bl) * 14 / 20; else - i = status->get_speed(bl)/2; - ud->steptimer = timer->add(tick+i, unit->step_timer, bl->id, 0); + timer_delay = status->get_speed(bl) / 2; + ud->steptimer = timer->add(tick + timer_delay, unit->steptimer, bl->id, 0); } - if(ud->state.change_walk_target) { - if(unit->walktoxy_sub(bl)) { - return 1; - } else { - clif->fixpos(bl); + if (ud->state.change_walk_target) { + if (unit->walk_toxy_sub(bl) == 0) return 0; - } + clif->fixpos(bl); + return 1; } + int timer_delay; ud->walkpath.path_pos++; if(ud->walkpath.path_pos>=ud->walkpath.path_len) - i = -1; - else if(ud->walkpath.path[ud->walkpath.path_pos]&1) - i = status->get_speed(bl)*14/10; + timer_delay = -1; + else if ((ud->walkpath.path[ud->walkpath.path_pos] & 1) != 0) + timer_delay = status->get_speed(bl) * 14 / 10; else - i = status->get_speed(bl); + timer_delay = status->get_speed(bl); - if(i > 0) { - ud->walktimer = timer->add(tick+i,unit->walktoxy_timer,id,i); - if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently + if (timer_delay > 0) { + ud->walktimer = timer->add(tick + timer_delay, unit->walk_toxy_timer, id, 0); + if (md != NULL && DIFF_TICK(tick, md->dmgtick) < 3000) // not required not damaged recently clif->move(ud); - } else if(ud->state.running) { - //Keep trying to run. - if ( !(unit->run(bl, NULL, SC_RUN) || unit->run(bl, sd, SC_WUGDASH)) ) + } else if (ud->state.running != 0) { + // Keep trying to run. + if (!(unit->run(bl, NULL, SC_RUN) || unit->run(bl, sd, SC_WUGDASH))) ud->state.running = 0; - } else if (!ud->stepaction && ud->target_to) { - //Update target trajectory. + } else if (!ud->stepaction && ud->target_to != 0) { + // Update target trajectory. struct block_list *tbl = map->id2bl(ud->target_to); - if (!tbl || !status->check_visibility(bl, tbl)) { - //Cancel chase. + if (tbl == NULL || status->check_visibility(bl, tbl) == 0) { // not visible + // Cancel chase. ud->to_x = bl->x; ud->to_y = bl->y; - if (tbl && bl->type == BL_MOB && mob->warpchase(BL_UCAST(BL_MOB, bl), tbl)) + if (tbl != NULL && bl->type == BL_MOB && mob->warpchase(BL_UCAST(BL_MOB, bl), tbl) != 0) return 0; ud->target_to = 0; - return 0; + return 1; } if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) { //Reached destination. @@ -466,81 +507,106 @@ static int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) clif->fixpos(bl); unit->attack(bl, tbl->id, ud->state.attack_continue); } - } else { //Update chase-path - unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue? 1 : 0)); + } else { // Update chase-path + unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy | ud->state.attack_continue); return 0; } } else { - //Stopped walking. Update to_x and to_y to current location [Skotlex] + // Stopped walking. Update to_x and to_y to current location [Skotlex] ud->to_x = bl->x; ud->to_y = bl->y; - if (battle_config.official_cell_stack_limit && map->count_oncell(bl->m, x, y, BL_CHAR|BL_NPC, 0x1 | 0x2) > battle_config.official_cell_stack_limit) { - //Walked on occupied cell, call unit_walktoxy again - if(ud->steptimer != INVALID_TIMER) { - //Execute step timer on next step instead - timer->delete(ud->steptimer, unit->step_timer); + if (battle_config.official_cell_stack_limit != 0 && map->count_oncell(bl->m, x, y, BL_CHAR | BL_NPC, 0x1 | 0x2) > battle_config.official_cell_stack_limit) { + // Walked on occupied cell, call unit->walk_toxy again + if (ud->steptimer != INVALID_TIMER) { + // Execute step timer on next step instead + timer->delete(ud->steptimer, unit->steptimer); ud->steptimer = INVALID_TIMER; } - return unit->walktoxy(bl, x, y, 8); + return unit->walk_toxy(bl, x, y, 8); } } return 0; } -static int unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) +/** + * Timer for delayed execution of unit->walk_toxy once triggered + * @param tid: Timer ID, unused + * @param tick: Tick, unused + * @param id: ID of block_list to execute the action + * @param data: uint32 data cast to intptr_t with x-coord in lowest 16 bits and y-coord in highest 16 bits + * @return 0: success, 1: failure + */ +static int unit_delay_walk_toxy_timer(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = map->id2bl(id); - - if (!bl || bl->prev == NULL) - return 0; - unit->walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0); - return 1; + if (bl == NULL || bl->prev == NULL) + return 1; + short x = (short)GetWord((uint32)data, 0); + short y = (short)GetWord((uint32)data, 1); + unit->walk_toxy(bl, x, y, 0); + return 0; } -//flag parameter: -//&1 -> 1/0 = easy/hard -//&2 -> force walking -//&4 -> Delay walking if the reason you can't walk is the canwalk delay -//&8 -> Search for an unoccupied cell and cancel if none available -static int unit_walktoxy(struct block_list *bl, short x, short y, int flag) +/** + * Makes a unit walk to (x, y) coordinates + * @param bl: block_list of unit to move + * @param x: x-coordinate + * @param y: y-coordinate + * @param flag: flag paramater with following options: + * - `& 1` -> 1/0 = easy / hard + * - `& 2` -> Force walking + * - `& 4` -> Delay walking, if the reason you can't walk is the `canwalk delay` + * - `& 8` -> Search for an unoccupied cell and cancel if none available + * . + * @return 0: success, 1: failure + */ +static int unit_walk_toxy(struct block_list *bl, short x, short y, int flag) { + // TODO: change flag to enum? [skyleo] struct unit_data* ud = NULL; struct status_change* sc = NULL; struct walkpath_data wpd; - nullpo_ret(bl); + nullpo_retr(1, bl); ud = unit->bl2ud(bl); - if( ud == NULL) return 0; + if (ud == NULL) + return 1; - if (battle_config.check_occupied_cells && (flag&8) && !map->closest_freecell(bl->m, bl, &x, &y, BL_CHAR|BL_NPC, 1)) //This might change x and y - return 0; + if ((flag & 8) != 0 && battle_config.check_occupied_cells != 0) { + if (!map->closest_freecell(bl->m, bl, &x, &y, BL_CHAR | BL_NPC, 1)) // This might change x and y + return 1; + } - if (!path->search(&wpd, bl, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells - return 0; + if (!path->search(&wpd, bl, bl->m, bl->x, bl->y, x, y, flag & 1, CELL_CHKNOPASS)) // Count walk path cells + return 1; + if (bl->type != BL_NPC) { #ifdef OFFICIAL_WALKPATH - if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between - && (wpd.path_len > (battle_config.max_walk_path/17)*14) // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] - && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. - return 0; + // Check if there is an obstacle between + // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] + if (!path->search_long(NULL, bl, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) + && (wpd.path_len > (battle_config.max_walk_path / 17) * 14)) + return 1; #endif - if ((wpd.path_len > battle_config.max_walk_path) && (bl->type != BL_NPC)) - return 0; + if (wpd.path_len > battle_config.max_walk_path) + return 1; + } - if (flag&4 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 && - DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { + if ((flag & 4) != 0 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 + && DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { // Delay walking command. [Skotlex] - timer->add(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); - return 1; + timer->add(ud->canmove_tick + 1, unit->delay_walk_toxy_timer, bl->id, + (intptr_t)MakeDWord((uint16)x, (uint16)y)); + return 0; } - if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit->can_move(bl))) - return 0; + if ((flag & 2) == 0 && ((status_get_mode(bl) & MD_CANMOVE) == 0 || unit->can_move(bl) == 0)) + return 1; - ud->state.walk_easy = flag&1; + ud->state.walk_easy = flag & 1; ud->to_x = x; ud->to_y = y; unit->stop_attack(bl); //Sets target to 0 @@ -548,44 +614,63 @@ static int unit_walktoxy(struct block_list *bl, short x, short y, int flag) unit->stop_stepaction(bl); // unit->walktoxy removes any remembered stepaction and resets ud->target_to sc = status->get_sc(bl); - if( sc ) { - if( sc->data[SC_CONFUSION] || sc->data[SC__CHAOS] ) //Randomize the target position + if (sc != NULL) { + if (sc->data[SC_CONFUSION] != NULL || sc->data[SC__CHAOS] != NULL) // Randomize the target position map->random_dir(bl, &ud->to_x, &ud->to_y); - if( sc->data[SC_COMBOATTACK] ) + if (sc->data[SC_COMBOATTACK] != NULL) status_change_end(bl, SC_COMBOATTACK, INVALID_TIMER); } - if(ud->walktimer != INVALID_TIMER) { + if (ud->walktimer != INVALID_TIMER) { // When you come to the center of the grid because the change of destination while you're walking right now - // Call a function from a timer unit->walktoxy_sub + // Call a function from a timer unit->walk_toxy_sub ud->state.change_walk_target = 1; - return 1; + return 0; } - return unit->walktoxy_sub(bl); + return unit->walk_toxy_sub(bl); } -//To set Mob's CHASE/FOLLOW states (shouldn't be done if there's no path to reach) -static inline void set_mobstate(struct block_list *bl, int flag) +/** + * Sets CHASE / FOLLOW states, in case bl is a mob. + * WARNING: This shouldn't be done if there's no path to reach + * @param bl: block_list of mob + */ +static inline void set_mobstate(struct block_list *bl) { - struct mob_data* md = BL_CAST(BL_MOB,bl); + struct mob_data* md = BL_CAST(BL_MOB, bl); - if( md && flag ) - md->state.skillstate = md->state.aggressive ? MSS_FOLLOW : MSS_RUSH; + if (md != NULL) { + if (md->state.aggressive != 0) + md->state.skillstate = MSS_FOLLOW; + else + md->state.skillstate = MSS_RUSH; + } } -static int unit_walktobl_sub(int tid, int64 tick, int id, intptr_t data) +/** + * Timer used for when a unit can't walk towards its target yet due to it's canmove_tick, + * keeps retrying until it works or target changes. + * @param tid: Timer ID, unused + * @param tick: Tick, unused + * @param id: ID of block_list to execute the action + * @param data: ID of block_list to walk towards + * @return 0: success, 1: failure + */ +static int unit_walktobl_timer(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = map->id2bl(id); - struct unit_data *ud = bl?unit->bl2ud(bl):NULL; - - if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { - if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? - timer->add(ud->canmove_tick+1, unit->walktobl_sub, id, data); - else if (unit->can_move(bl)) { - if (unit->walktoxy_sub(bl)) - set_mobstate(bl, ud->state.attack_continue); - } + if (bl == NULL) + return 1; + struct unit_data *ud = unit->bl2ud(bl); + if (ud == NULL) + return 1; + + if (ud->walktimer == INVALID_TIMER && ud->target == data) { + if (DIFF_TICK(ud->canmove_tick, tick) > 0) // Keep waiting? + timer->add(ud->canmove_tick + 1, unit->walktobl_timer, id, data); + else if (unit->can_move(bl) != 0 && unit->walk_toxy_sub(bl) == 0 && ud->state.attack_continue != 0) + set_mobstate(bl); } return 0; } @@ -629,22 +714,23 @@ static int unit_walktobl(struct block_list *bl, struct block_list *tbl, int rang if(ud->walktimer != INVALID_TIMER) { ud->state.change_walk_target = 1; - set_mobstate(bl, flag&2); + if ((flag & 2) != 0) + set_mobstate(bl); return 1; } if (DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) { //Can't move, wait a bit before invoking the movement. - timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); + timer->add(ud->canmove_tick + 1, unit->walktobl_timer, bl->id, ud->target); return 1; } if(!unit->can_move(bl)) return 0; - if (unit->walktoxy_sub(bl)) { - set_mobstate(bl, flag&2); - return 1; + if (unit->walk_toxy_sub(bl) == 0 && (flag & 2) != 0) { + set_mobstate(bl); + return 0; } return 0; } @@ -732,14 +818,14 @@ static bool unit_run(struct block_list *bl, struct map_session_data *sd, enum sc return false; } - if( unit->walktoxy(bl, to_x, to_y, 1) ) + if (unit->walk_toxy(bl, to_x, to_y, 1) == 0) return true; //There must be an obstacle nearby. Attempt walking one cell at a time. do { to_x -= dir_x; to_y -= dir_y; - } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1)); + } while (--i > 0 && unit->walk_toxy(bl, to_x, to_y, 1) != 0); if ( i == 0 ) { unit->run_hit(bl, sc, sd, type); @@ -752,19 +838,21 @@ static bool unit_run(struct block_list *bl, struct map_session_data *sd, enum sc //Makes bl attempt to run dist cells away from target. Uses hard-paths. static int unit_escape(struct block_list *bl, struct block_list *target, short dist) { - uint8 dir; nullpo_ret(bl); - dir = map->calc_dir(target, bl->x, bl->y); + enum unit_dir dir = map->calc_dir(target, bl->x, bl->y); + Assert_retr(1, dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); while (dist > 0 && map->getcell(bl->m, bl, bl->x + dist * dirx[dir], bl->y + dist * diry[dir], CELL_CHKNOREACH)) dist--; - return ( dist > 0 && unit->walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); + if (dist > 0 && unit->walk_toxy(bl, bl->x + dist * dirx[dir], bl->y + dist * diry[dir], 0) == 0) + return 1; + else + return 0; } //Instant warp function. static int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath) { short dx,dy; - uint8 dir; struct unit_data *ud = NULL; struct map_session_data *sd = NULL; @@ -783,7 +871,7 @@ static int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int eas ud->to_x = dst_x; ud->to_y = dst_y; - dir = map->calc_dir(bl, dst_x, dst_y); + enum unit_dir dir = map->calc_dir(bl, dst_x, dst_y); ud->dir = dir; dx = dst_x - bl->x; @@ -825,12 +913,18 @@ static int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int eas return 1; } -static int unit_setdir(struct block_list *bl, unsigned char dir) +/** + * Sets the facing direction of a unit + * @param bl: unit to modify + * @param dir: the facing direction @see enum unit_dir + * @return 0: success, 1: failure + */ +static int unit_set_dir(struct block_list *bl, enum unit_dir dir) { - struct unit_data *ud; - nullpo_ret(bl ); - ud = unit->bl2ud(bl); - if (!ud) return 0; + nullpo_retr(1, bl); + struct unit_data *ud = unit->bl2ud(bl); + if (ud == NULL) + return 1; ud->dir = dir; if (bl->type == BL_PC) BL_UCAST(BL_PC, bl)->head_dir = 0; @@ -838,15 +932,20 @@ static int unit_setdir(struct block_list *bl, unsigned char dir) return 0; } -static uint8 unit_getdir(struct block_list *bl) +/** + * Get the facing direction of a unit + * @param bl: unit to request data from + * @return the facing direction @see enum unit_dir + */ +static enum unit_dir unit_getdir(const struct block_list *bl) { - struct unit_data *ud; - nullpo_ret(bl); + nullpo_retr(UNIT_DIR_NORTH, bl); - if( bl->type == BL_NPC ) + if (bl->type == BL_NPC) return BL_UCCAST(BL_NPC, bl)->dir; - ud = unit->bl2ud(bl); - if (!ud) return 0; + const struct unit_data *ud = unit->cbl2ud(bl); + if (ud == NULL) + return UNIT_DIR_NORTH; return ud->dir; } @@ -1010,7 +1109,7 @@ static int unit_stop_walking(struct block_list *bl, int flag) //timer->delete function does not messes with it. If the function's //behavior changes in the future, this code could break! td = timer->get(ud->walktimer); - timer->delete(ud->walktimer, unit->walktoxy_timer); + timer->delete(ud->walktimer, unit->walk_toxy_timer); ud->walktimer = INVALID_TIMER; ud->state.change_walk_target = 0; tick = timer->gettick(); @@ -1018,7 +1117,7 @@ static int unit_stop_walking(struct block_list *bl, int flag) || (flag&STOPWALKING_FLAG_NEXTCELL && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell ) { ud->walkpath.path_len = ud->walkpath.path_pos+1; - unit->walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); + unit->walk_toxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); } if(flag&STOPWALKING_FLAG_FIXPOS) @@ -1046,7 +1145,7 @@ static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_ int ret = unit->skilluse_id2(src, target_id, skill_id, skill_lv, casttime, castcancel); struct map_session_data *sd = BL_CAST(BL_PC, src); - if (sd != NULL) + if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) pc->itemskill_clear(sd); return ret; @@ -1235,7 +1334,7 @@ static int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int } else { unit->stop_walking(bl, STOPWALKING_FLAG_NEXTCELL); if (ud->target) - timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); + timer->add(ud->canmove_tick + 1, unit->walktobl_timer, bl->id, ud->target); } } } @@ -1450,7 +1549,7 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill ud->target_to = target_id; ud->stepskill_id = skill_id; ud->stepskill_lv = skill_lv; - return 0; // Attacking will be handled by unit_walktoxy_timer in this case + return 0; // Attacking will be handled by unit_walk_toxy_timer in this case } //Check range when not using skill on yourself or is a combo-skill during attack @@ -1663,7 +1762,7 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill if( casttime > 0 ) { if (src->id != target->id) // self-targeted skills shouldn't show different direction - unit->setdir(src, map->calc_dir(src, target->x, target->y)); + unit->set_dir(src, map->calc_dir(src, target->x, target->y)); ud->skilltimer = timer->add( tick+casttime, skill->castend_id, src->id, 0 ); if (sd && (pc->checkskill(sd, SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0)) status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); @@ -1683,7 +1782,7 @@ static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_ int ret = unit->skilluse_pos2(src, skill_x, skill_y, skill_id, skill_lv, casttime, castcancel); struct map_session_data *sd = BL_CAST(BL_PC, src); - if (sd != NULL) + if (sd != NULL && (ret == 0 || !skill->is_item_skill(sd, skill_id, skill_lv))) pc->itemskill_clear(sd); return ret; @@ -1757,7 +1856,7 @@ static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill ud->target_to = (skill_x + skill_y*md->xs); ud->stepskill_id = skill_id; ud->stepskill_lv = skill_lv; - return 0; // Attacking will be handled by unit_walktoxy_timer in this case + return 0; // Attacking will be handled by unit_walk_toxy_timer in this case } if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) { @@ -1818,7 +1917,7 @@ static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill // in official this is triggered even if no cast time. clif->useskill(src, src->id, 0, skill_x, skill_y, skill_id, skill_lv, casttime); if( casttime > 0 ) { - unit->setdir(src, map->calc_dir(src, skill_x, skill_y)); + unit->set_dir(src, map->calc_dir(src, skill_x, skill_y)); ud->skilltimer = timer->add( tick+casttime, skill->castend_pos, src->id, 0 ); if ((sd && pc->checkskill(sd, SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK || (skill->get_inf2(ud->skill_id) & INF2_FREE_CAST_REDUCED) != 0) { status_calc_bl(&sd->bl, SCB_SPEED|SCB_ASPD); @@ -1897,7 +1996,7 @@ static void unit_stop_stepaction(struct block_list *bl) return; //Clear timer - timer->delete(ud->steptimer, unit->step_timer); + timer->delete(ud->steptimer, unit->steptimer); ud->steptimer = INVALID_TIMER; } @@ -1981,7 +2080,7 @@ static int unit_attack(struct block_list *src, int target_id, int continuous) ud->target_to = ud->target; ud->stepskill_id = 0; ud->stepskill_lv = 0; - return 0; // Attacking will be handled by unit_walktoxy_timer in this case + return 0; // Attacking will be handled by unit_walk_toxy_timer in this case } if(DIFF_TICK(ud->attackabletime, timer->gettick()) > 0) @@ -2082,14 +2181,13 @@ static bool unit_can_reach_bl(struct block_list *bl, struct block_list *tbl, int /*========================================== * Calculates position of Pet/Mercenary/Homunculus/Elemental *------------------------------------------*/ -static int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) +static int unit_calc_pos(struct block_list *bl, int tx, int ty, enum unit_dir dir) { int dx, dy, x, y; struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(ud); - if(dir > 7) - return 1; + Assert_retr(1, dir >= UNIT_DIR_FIRST && dir < UNIT_DIR_MAX); ud->to_x = tx; ud->to_y = ty; @@ -2106,7 +2204,7 @@ static int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) if (!unit->can_reach_pos(bl, x, y, 0)) { int i; for (i = 0; i < 12; i++) { - int k = rnd()%8; // Pick a Random Dir + enum unit_dir k = rnd() % UNIT_DIR_MAX; // Pick a Random Dir dx = -dirx[k] * 2; dy = -diry[k] * 2; x = tx + dx; @@ -2272,7 +2370,7 @@ static int unit_attack_timer_sub(struct block_list *src, int tid, int64 tick) } if(ud->state.attack_continue) { - unit->setdir(src, map->calc_dir(src, target->x, target->y)); + unit->set_dir(src, map->calc_dir(src, target->x, target->y)); if( src->type == BL_PC ) pc->update_idle_time(sd, BCIDLE_ATTACK); ud->attacktimer = timer->add(ud->attackabletime,unit->attack_timer,src->id,0); @@ -2969,10 +3067,10 @@ static int do_init_unit(bool minimal) return 0; timer->add_func_list(unit->attack_timer, "unit_attack_timer"); - timer->add_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); - timer->add_func_list(unit->walktobl_sub, "unit_walktobl_sub"); - timer->add_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); - timer->add_func_list(unit->step_timer,"unit_step_timer"); + timer->add_func_list(unit->walk_toxy_timer, "unit_walk_toxy_timer"); + timer->add_func_list(unit->walktobl_timer, "unit_walktobl_timer"); + timer->add_func_list(unit->delay_walk_toxy_timer, "unit_delay_walk_toxy_timer"); + timer->add_func_list(unit->steptimer, "unit_steptimer"); return 0; } @@ -2990,26 +3088,28 @@ void unit_defaults(void) unit->final = do_final_unit; /* */ unit->bl2ud = unit_bl2ud; + unit->cbl2ud = unit_cbl2ud; unit->bl2ud2 = unit_bl2ud2; unit->init_ud = unit_init_ud; unit->attack_timer = unit_attack_timer; - unit->walktoxy_timer = unit_walktoxy_timer; - unit->walktoxy_sub = unit_walktoxy_sub; - unit->delay_walktoxy_timer = unit_delay_walktoxy_timer; - unit->walktoxy = unit_walktoxy; - unit->walktobl_sub = unit_walktobl_sub; + unit->walk_toxy_timer = unit_walk_toxy_timer; + unit->walk_toxy_sub = unit_walk_toxy_sub; + unit->delay_walk_toxy_timer = unit_delay_walk_toxy_timer; + unit->walk_toxy = unit_walk_toxy; + unit->walktobl_timer = unit_walktobl_timer; unit->walktobl = unit_walktobl; unit->run = unit_run; unit->run_hit = unit_run_hit; unit->escape = unit_escape; unit->movepos = unit_movepos; - unit->setdir = unit_setdir; + unit->set_dir = unit_set_dir; unit->getdir = unit_getdir; unit->blown = unit_blown; unit->warp = unit_warp; + unit->warpto_master = unit_warpto_master; unit->stop_walking = unit_stop_walking; unit->skilluse_id = unit_skilluse_id; - unit->step_timer = unit_step_timer; + unit->steptimer = unit_steptimer; unit->stop_stepaction = unit_stop_stepaction; unit->is_walking = unit_is_walking; unit->can_move = unit_can_move; diff --git a/src/map/unit.h b/src/map/unit.h index 5437a172a..3f288e0d3 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -24,6 +24,7 @@ #include "map/clif.h" // clr_type #include "map/path.h" // struct walkpath_data #include "map/skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "map/unitdefines.h" // enum unit_dir #include "common/hercules.h" struct map_session_data; @@ -67,7 +68,7 @@ struct unit_data { int64 attackabletime; int64 canact_tick; int64 canmove_tick; - uint8 dir; + enum unit_dir dir; unsigned char walk_count; unsigned char target_count; struct { @@ -102,26 +103,28 @@ struct unit_interface { int (*final) (void); /* */ struct unit_data* (*bl2ud) (struct block_list *bl); + const struct unit_data* (*cbl2ud) (const struct block_list *bl); struct unit_data* (*bl2ud2) (struct block_list *bl); void (*init_ud) (struct unit_data *ud); int (*attack_timer) (int tid, int64 tick, int id, intptr_t data); - int (*walktoxy_timer) (int tid, int64 tick, int id, intptr_t data); - int (*walktoxy_sub) (struct block_list *bl); - int (*delay_walktoxy_timer) (int tid, int64 tick, int id, intptr_t data); - int (*walktoxy) (struct block_list *bl, short x, short y, int flag); - int (*walktobl_sub) (int tid, int64 tick, int id, intptr_t data); + int (*walk_toxy_timer) (int tid, int64 tick, int id, intptr_t data); + int (*walk_toxy_sub) (struct block_list *bl); + int (*delay_walk_toxy_timer) (int tid, int64 tick, int id, intptr_t data); + int (*walk_toxy) (struct block_list *bl, short x, short y, int flag); + int (*walktobl_timer) (int tid, int64 tick, int id, intptr_t data); int (*walktobl) (struct block_list *bl, struct block_list *tbl, int range, int flag); bool (*run) (struct block_list *bl, struct map_session_data *sd, enum sc_type type); void (*run_hit) (struct block_list *bl, struct status_change *sc, struct map_session_data *sd, enum sc_type type); int (*escape) (struct block_list *bl, struct block_list *target, short dist); int (*movepos) (struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); - int (*setdir) (struct block_list *bl, unsigned char dir); - uint8 (*getdir) (struct block_list *bl); + int (*set_dir) (struct block_list *bl, enum unit_dir dir); + enum unit_dir (*getdir) (const struct block_list *bl); int (*blown) (struct block_list *bl, int dx, int dy, int count, int flag); int (*warp) (struct block_list *bl, short m, short x, short y, enum clr_type type); + int (*warpto_master) (struct block_list *master_bl, struct block_list *slave_bl); int (*stop_walking) (struct block_list *bl, int type); int (*skilluse_id) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); - int (*step_timer) (int tid, int64 tick, int id, intptr_t data); + int (*steptimer) (int tid, int64 tick, int id, intptr_t data); void (*stop_stepaction) (struct block_list *bl); int (*is_walking) (struct block_list *bl); int (*can_move) (struct block_list *bl); @@ -137,7 +140,7 @@ struct unit_interface { int (*cancel_combo) (struct block_list *bl); bool (*can_reach_pos) (struct block_list *bl, int x, int y, int easy); bool (*can_reach_bl) (struct block_list *bl, struct block_list *tbl, int range, int easy, short *x, short *y); - int (*calc_pos) (struct block_list *bl, int tx, int ty, uint8 dir); + int (*calc_pos) (struct block_list *bl, int tx, int ty, enum unit_dir dir); int (*attack_timer_sub) (struct block_list *src, int tid, int64 tick); int (*skillcastcancel) (struct block_list *bl, int type); void (*dataset) (struct block_list *bl); diff --git a/src/map/unitdefines.h b/src/map/unitdefines.h new file mode 100644 index 000000000..0ee30998c --- /dev/null +++ b/src/map/unitdefines.h @@ -0,0 +1,58 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2012-2019 Hercules Dev Team + * Copyright (C) Athena Dev Teams + * + * 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/>. + */ +#ifndef MAP_UNITDEFINES_H +#define MAP_UNITDEFINES_H + +/** + * Used for directions, @see unit_data.dir + */ +enum unit_dir { + UNIT_DIR_UNDEFINED = -1, + UNIT_DIR_FIRST = 0, + UNIT_DIR_NORTH = 0, + UNIT_DIR_NORTHWEST = 1, + UNIT_DIR_WEST = 2, + UNIT_DIR_SOUTHWEST = 3, + UNIT_DIR_SOUTH = 4, + UNIT_DIR_SOUTHEAST = 5, + UNIT_DIR_EAST = 6, + UNIT_DIR_NORTHEAST = 7, + UNIT_DIR_MAX = 8, + /* IMPORTANT: Changing the order would break the above macros + * and several usages of directions anywhere */ +}; + +/* Returns the opposite of the facing direction */ +#define unit_get_opposite_dir(dir) ( ((dir) + 4) % UNIT_DIR_MAX ) + +/* Returns true when direction is diagonal/combined (ex. UNIT_DIR_NORTHWEST, UNIT_DIR_SOUTHWEST, ...) */ +#define unit_is_diagonal_dir(dir) ( ((dir) % 2) == UNIT_DIR_NORTHWEST ) + +/* Returns true if direction equals val or the opposite direction of val */ +#define unit_is_dir_or_opposite(dir, val) ( ((dir) % 4) == (val) ) + +/* Returns the next direction after 90° CCW on a compass */ +#define unit_get_ccw90_dir(dir) ( ((dir) + 2) % UNIT_DIR_MAX ) + +/* Returns a random diagonal direction */ +#define unit_get_rnd_diagonal_dir() ( UNIT_DIR_NORTHWEST + 2 * (rnd() % 4) ) + +#endif /* MAP_UNITDEFINES_H */ diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 7996a59f9..28f81b97f 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -4734,10 +4734,10 @@ typedef uint32 (*HPMHOOK_pre_map_race_id2mask) (int *race); typedef uint32 (*HPMHOOK_post_map_race_id2mask) (uint32 retVal___, int race); typedef void (*HPMHOOK_pre_map_reloadnpc) (bool *clear); typedef void (*HPMHOOK_post_map_reloadnpc) (bool clear); -typedef int (*HPMHOOK_pre_map_check_dir) (int *s_dir, int *t_dir); -typedef int (*HPMHOOK_post_map_check_dir) (int retVal___, int s_dir, int t_dir); -typedef uint8 (*HPMHOOK_pre_map_calc_dir) (struct block_list **src, int16 *x, int16 *y); -typedef uint8 (*HPMHOOK_post_map_calc_dir) (uint8 retVal___, struct block_list *src, int16 x, int16 y); +typedef int (*HPMHOOK_pre_map_check_dir) (enum unit_dir *s_dir, enum unit_dir *t_dir); +typedef int (*HPMHOOK_post_map_check_dir) (int retVal___, enum unit_dir s_dir, enum unit_dir t_dir); +typedef enum unit_dir (*HPMHOOK_pre_map_calc_dir) (const struct block_list **src, int16 *x, int16 *y); +typedef enum unit_dir (*HPMHOOK_post_map_calc_dir) (enum unit_dir retVal___, const struct block_list *src, int16 x, int16 y); typedef int (*HPMHOOK_pre_map_random_dir) (struct block_list **bl, short **x, short **y); typedef int (*HPMHOOK_post_map_random_dir) (int retVal___, struct block_list *bl, short *x, short *y); typedef int (*HPMHOOK_pre_map_cleanup_sub) (struct block_list **bl, va_list ap); @@ -5708,8 +5708,8 @@ typedef int (*HPMHOOK_pre_npc_parseview) (const char **w4, const char **start, c typedef int (*HPMHOOK_post_npc_parseview) (int retVal___, const char *w4, const char *start, const char *buffer, const char *filepath); typedef bool (*HPMHOOK_pre_npc_viewisid) (const char **viewid); typedef bool (*HPMHOOK_post_npc_viewisid) (bool retVal___, const char *viewid); -typedef struct npc_data* (*HPMHOOK_pre_npc_create_npc) (enum npc_subtype *subtype, int *m, int *x, int *y, uint8 *dir, int *class_); -typedef struct npc_data* (*HPMHOOK_post_npc_create_npc) (struct npc_data* retVal___, enum npc_subtype subtype, int m, int x, int y, uint8 dir, int class_); +typedef struct npc_data* (*HPMHOOK_pre_npc_create_npc) (enum npc_subtype *subtype, int *m, int *x, int *y, enum unit_dir *dir, int *class_); +typedef struct npc_data* (*HPMHOOK_post_npc_create_npc) (struct npc_data* retVal___, enum npc_subtype subtype, int m, int x, int y, enum unit_dir dir, int class_); typedef struct npc_data* (*HPMHOOK_pre_npc_add_warp) (char **name, short *from_mapid, short *from_x, short *from_y, short *xs, short *ys, unsigned short *to_mapindex, short *to_x, short *to_y); typedef struct npc_data* (*HPMHOOK_post_npc_add_warp) (struct npc_data* retVal___, char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); typedef const char* (*HPMHOOK_pre_npc_parse_warp) (const char **w1, const char **w2, const char **w3, const char **w4, const char **start, const char **buffer, const char **filepath, int **retval); @@ -7298,8 +7298,8 @@ typedef int (*HPMHOOK_pre_skill_additional_effect) (struct block_list **src, str typedef int (*HPMHOOK_post_skill_additional_effect) (int retVal___, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int dmg_lv, int64 tick); typedef int (*HPMHOOK_pre_skill_counter_additional_effect) (struct block_list **src, struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int *attack_type, int64 *tick); typedef int (*HPMHOOK_post_skill_counter_additional_effect) (int retVal___, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int64 tick); -typedef int (*HPMHOOK_pre_skill_blown) (struct block_list **src, struct block_list **target, int *count, int8 *dir, int *flag); -typedef int (*HPMHOOK_post_skill_blown) (int retVal___, struct block_list *src, struct block_list *target, int count, int8 dir, int flag); +typedef int (*HPMHOOK_pre_skill_blown) (struct block_list **src, struct block_list **target, int *count, enum unit_dir *dir, int *flag); +typedef int (*HPMHOOK_post_skill_blown) (int retVal___, struct block_list *src, struct block_list *target, int count, enum unit_dir dir, int flag); typedef int (*HPMHOOK_pre_skill_break_equip) (struct block_list **bl, unsigned short *where, int *rate, int *flag); typedef int (*HPMHOOK_post_skill_break_equip) (int retVal___, struct block_list *bl, unsigned short where, int rate, int flag); typedef int (*HPMHOOK_pre_skill_strip_equip) (struct block_list **bl, unsigned short *where, int *rate, int *lv, int *time); @@ -7464,10 +7464,10 @@ typedef int (*HPMHOOK_pre_skill_check_condition_char_sub) (struct block_list **b typedef int (*HPMHOOK_post_skill_check_condition_char_sub) (int retVal___, struct block_list *bl, va_list ap); typedef int (*HPMHOOK_pre_skill_check_condition_mob_master_sub) (struct block_list **bl, va_list ap); typedef int (*HPMHOOK_post_skill_check_condition_mob_master_sub) (int retVal___, struct block_list *bl, va_list ap); -typedef void (*HPMHOOK_pre_skill_brandishspear_first) (struct square **tc, uint8 *dir, int16 *x, int16 *y); -typedef void (*HPMHOOK_post_skill_brandishspear_first) (struct square *tc, uint8 dir, int16 x, int16 y); -typedef void (*HPMHOOK_pre_skill_brandishspear_dir) (struct square **tc, uint8 *dir, int *are); -typedef void (*HPMHOOK_post_skill_brandishspear_dir) (struct square *tc, uint8 dir, int are); +typedef void (*HPMHOOK_pre_skill_brandishspear_first) (struct square **tc, enum unit_dir *dir, int16 *x, int16 *y); +typedef void (*HPMHOOK_post_skill_brandishspear_first) (struct square *tc, enum unit_dir dir, int16 x, int16 y); +typedef void (*HPMHOOK_pre_skill_brandishspear_dir) (struct square **tc, enum unit_dir *dir, int *are); +typedef void (*HPMHOOK_post_skill_brandishspear_dir) (struct square *tc, enum unit_dir dir, int are); typedef int (*HPMHOOK_pre_skill_get_fixed_cast) (int *skill_id, int *skill_lv); typedef int (*HPMHOOK_post_skill_get_fixed_cast) (int retVal___, int skill_id, int skill_lv); typedef int (*HPMHOOK_pre_skill_sit_count) (struct block_list **bl, va_list ap); @@ -7608,8 +7608,8 @@ typedef int (*HPMHOOK_pre_skill_attack_copy_unknown) (int **attack_type, struct typedef int (*HPMHOOK_post_skill_attack_copy_unknown) (int retVal___, int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); typedef int (*HPMHOOK_pre_skill_attack_dir_unknown) (int **attack_type, struct block_list **src, struct block_list **dsrc, struct block_list **bl, uint16 **skill_id, uint16 **skill_lv, int64 **tick, int **flag); typedef int (*HPMHOOK_post_skill_attack_dir_unknown) (int retVal___, int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); -typedef void (*HPMHOOK_pre_skill_attack_blow_unknown) (int **attack_type, struct block_list **src, struct block_list **dsrc, struct block_list **bl, uint16 **skill_id, uint16 **skill_lv, int64 **tick, int **flag, int **type, struct Damage **dmg, int64 **damage, int8 **dir); -typedef void (*HPMHOOK_post_skill_attack_blow_unknown) (int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir); +typedef void (*HPMHOOK_pre_skill_attack_blow_unknown) (int **attack_type, struct block_list **src, struct block_list **dsrc, struct block_list **bl, uint16 **skill_id, uint16 **skill_lv, int64 **tick, int **flag, int **type, struct Damage **dmg, int64 **damage, enum unit_dir **dir); +typedef void (*HPMHOOK_post_skill_attack_blow_unknown) (int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, enum unit_dir *dir); typedef void (*HPMHOOK_pre_skill_attack_post_unknown) (int **attack_type, struct block_list **src, struct block_list **dsrc, struct block_list **bl, uint16 **skill_id, uint16 **skill_lv, int64 **tick, int **flag); typedef void (*HPMHOOK_post_skill_attack_post_unknown) (int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag); typedef bool (*HPMHOOK_pre_skill_timerskill_dead_unknown) (struct block_list **src, struct unit_data **ud, struct skill_timerskill **skl); @@ -8288,22 +8288,24 @@ typedef int (*HPMHOOK_pre_unit_final) (void); typedef int (*HPMHOOK_post_unit_final) (int retVal___); typedef struct unit_data* (*HPMHOOK_pre_unit_bl2ud) (struct block_list **bl); typedef struct unit_data* (*HPMHOOK_post_unit_bl2ud) (struct unit_data* retVal___, struct block_list *bl); +typedef const struct unit_data* (*HPMHOOK_pre_unit_cbl2ud) (const struct block_list **bl); +typedef const struct unit_data* (*HPMHOOK_post_unit_cbl2ud) (const struct unit_data* retVal___, const struct block_list *bl); typedef struct unit_data* (*HPMHOOK_pre_unit_bl2ud2) (struct block_list **bl); typedef struct unit_data* (*HPMHOOK_post_unit_bl2ud2) (struct unit_data* retVal___, struct block_list *bl); typedef void (*HPMHOOK_pre_unit_init_ud) (struct unit_data **ud); typedef void (*HPMHOOK_post_unit_init_ud) (struct unit_data *ud); typedef int (*HPMHOOK_pre_unit_attack_timer) (int *tid, int64 *tick, int *id, intptr_t *data); typedef int (*HPMHOOK_post_unit_attack_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); -typedef int (*HPMHOOK_pre_unit_walktoxy_timer) (int *tid, int64 *tick, int *id, intptr_t *data); -typedef int (*HPMHOOK_post_unit_walktoxy_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); -typedef int (*HPMHOOK_pre_unit_walktoxy_sub) (struct block_list **bl); -typedef int (*HPMHOOK_post_unit_walktoxy_sub) (int retVal___, struct block_list *bl); -typedef int (*HPMHOOK_pre_unit_delay_walktoxy_timer) (int *tid, int64 *tick, int *id, intptr_t *data); -typedef int (*HPMHOOK_post_unit_delay_walktoxy_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); -typedef int (*HPMHOOK_pre_unit_walktoxy) (struct block_list **bl, short *x, short *y, int *flag); -typedef int (*HPMHOOK_post_unit_walktoxy) (int retVal___, struct block_list *bl, short x, short y, int flag); -typedef int (*HPMHOOK_pre_unit_walktobl_sub) (int *tid, int64 *tick, int *id, intptr_t *data); -typedef int (*HPMHOOK_post_unit_walktobl_sub) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef int (*HPMHOOK_pre_unit_walk_toxy_timer) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_unit_walk_toxy_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef int (*HPMHOOK_pre_unit_walk_toxy_sub) (struct block_list **bl); +typedef int (*HPMHOOK_post_unit_walk_toxy_sub) (int retVal___, struct block_list *bl); +typedef int (*HPMHOOK_pre_unit_delay_walk_toxy_timer) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_unit_delay_walk_toxy_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef int (*HPMHOOK_pre_unit_walk_toxy) (struct block_list **bl, short *x, short *y, int *flag); +typedef int (*HPMHOOK_post_unit_walk_toxy) (int retVal___, struct block_list *bl, short x, short y, int flag); +typedef int (*HPMHOOK_pre_unit_walktobl_timer) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_unit_walktobl_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); typedef int (*HPMHOOK_pre_unit_walktobl) (struct block_list **bl, struct block_list **tbl, int *range, int *flag); typedef int (*HPMHOOK_post_unit_walktobl) (int retVal___, struct block_list *bl, struct block_list *tbl, int range, int flag); typedef bool (*HPMHOOK_pre_unit_run) (struct block_list **bl, struct map_session_data **sd, enum sc_type *type); @@ -8314,20 +8316,22 @@ typedef int (*HPMHOOK_pre_unit_escape) (struct block_list **bl, struct block_lis typedef int (*HPMHOOK_post_unit_escape) (int retVal___, struct block_list *bl, struct block_list *target, short dist); typedef int (*HPMHOOK_pre_unit_movepos) (struct block_list **bl, short *dst_x, short *dst_y, int *easy, bool *checkpath); typedef int (*HPMHOOK_post_unit_movepos) (int retVal___, struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); -typedef int (*HPMHOOK_pre_unit_setdir) (struct block_list **bl, unsigned char *dir); -typedef int (*HPMHOOK_post_unit_setdir) (int retVal___, struct block_list *bl, unsigned char dir); -typedef uint8 (*HPMHOOK_pre_unit_getdir) (struct block_list **bl); -typedef uint8 (*HPMHOOK_post_unit_getdir) (uint8 retVal___, struct block_list *bl); +typedef int (*HPMHOOK_pre_unit_set_dir) (struct block_list **bl, enum unit_dir *dir); +typedef int (*HPMHOOK_post_unit_set_dir) (int retVal___, struct block_list *bl, enum unit_dir dir); +typedef enum unit_dir (*HPMHOOK_pre_unit_getdir) (const struct block_list **bl); +typedef enum unit_dir (*HPMHOOK_post_unit_getdir) (enum unit_dir retVal___, const struct block_list *bl); typedef int (*HPMHOOK_pre_unit_blown) (struct block_list **bl, int *dx, int *dy, int *count, int *flag); typedef int (*HPMHOOK_post_unit_blown) (int retVal___, struct block_list *bl, int dx, int dy, int count, int flag); typedef int (*HPMHOOK_pre_unit_warp) (struct block_list **bl, short *m, short *x, short *y, enum clr_type *type); typedef int (*HPMHOOK_post_unit_warp) (int retVal___, struct block_list *bl, short m, short x, short y, enum clr_type type); +typedef int (*HPMHOOK_pre_unit_warpto_master) (struct block_list **master_bl, struct block_list **slave_bl); +typedef int (*HPMHOOK_post_unit_warpto_master) (int retVal___, struct block_list *master_bl, struct block_list *slave_bl); typedef int (*HPMHOOK_pre_unit_stop_walking) (struct block_list **bl, int *type); typedef int (*HPMHOOK_post_unit_stop_walking) (int retVal___, struct block_list *bl, int type); typedef int (*HPMHOOK_pre_unit_skilluse_id) (struct block_list **src, int *target_id, uint16 *skill_id, uint16 *skill_lv); typedef int (*HPMHOOK_post_unit_skilluse_id) (int retVal___, struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); -typedef int (*HPMHOOK_pre_unit_step_timer) (int *tid, int64 *tick, int *id, intptr_t *data); -typedef int (*HPMHOOK_post_unit_step_timer) (int retVal___, int tid, int64 tick, int id, intptr_t data); +typedef int (*HPMHOOK_pre_unit_steptimer) (int *tid, int64 *tick, int *id, intptr_t *data); +typedef int (*HPMHOOK_post_unit_steptimer) (int retVal___, int tid, int64 tick, int id, intptr_t data); typedef void (*HPMHOOK_pre_unit_stop_stepaction) (struct block_list **bl); typedef void (*HPMHOOK_post_unit_stop_stepaction) (struct block_list *bl); typedef int (*HPMHOOK_pre_unit_is_walking) (struct block_list **bl); @@ -8358,8 +8362,8 @@ typedef bool (*HPMHOOK_pre_unit_can_reach_pos) (struct block_list **bl, int *x, typedef bool (*HPMHOOK_post_unit_can_reach_pos) (bool retVal___, struct block_list *bl, int x, int y, int easy); typedef bool (*HPMHOOK_pre_unit_can_reach_bl) (struct block_list **bl, struct block_list **tbl, int *range, int *easy, short **x, short **y); typedef bool (*HPMHOOK_post_unit_can_reach_bl) (bool retVal___, struct block_list *bl, struct block_list *tbl, int range, int easy, short *x, short *y); -typedef int (*HPMHOOK_pre_unit_calc_pos) (struct block_list **bl, int *tx, int *ty, uint8 *dir); -typedef int (*HPMHOOK_post_unit_calc_pos) (int retVal___, struct block_list *bl, int tx, int ty, uint8 dir); +typedef int (*HPMHOOK_pre_unit_calc_pos) (struct block_list **bl, int *tx, int *ty, enum unit_dir *dir); +typedef int (*HPMHOOK_post_unit_calc_pos) (int retVal___, struct block_list *bl, int tx, int ty, enum unit_dir dir); typedef int (*HPMHOOK_pre_unit_attack_timer_sub) (struct block_list **src, int *tid, int64 *tick); typedef int (*HPMHOOK_post_unit_attack_timer_sub) (int retVal___, struct block_list *src, int tid, int64 tick); typedef int (*HPMHOOK_pre_unit_skillcastcancel) (struct block_list **bl, int *type); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 6d8776f18..f94606bab 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -6786,22 +6786,24 @@ struct { struct HPMHookPoint *HP_unit_final_post; struct HPMHookPoint *HP_unit_bl2ud_pre; struct HPMHookPoint *HP_unit_bl2ud_post; + struct HPMHookPoint *HP_unit_cbl2ud_pre; + struct HPMHookPoint *HP_unit_cbl2ud_post; struct HPMHookPoint *HP_unit_bl2ud2_pre; struct HPMHookPoint *HP_unit_bl2ud2_post; struct HPMHookPoint *HP_unit_init_ud_pre; struct HPMHookPoint *HP_unit_init_ud_post; struct HPMHookPoint *HP_unit_attack_timer_pre; struct HPMHookPoint *HP_unit_attack_timer_post; - struct HPMHookPoint *HP_unit_walktoxy_timer_pre; - struct HPMHookPoint *HP_unit_walktoxy_timer_post; - struct HPMHookPoint *HP_unit_walktoxy_sub_pre; - struct HPMHookPoint *HP_unit_walktoxy_sub_post; - struct HPMHookPoint *HP_unit_delay_walktoxy_timer_pre; - struct HPMHookPoint *HP_unit_delay_walktoxy_timer_post; - struct HPMHookPoint *HP_unit_walktoxy_pre; - struct HPMHookPoint *HP_unit_walktoxy_post; - struct HPMHookPoint *HP_unit_walktobl_sub_pre; - struct HPMHookPoint *HP_unit_walktobl_sub_post; + struct HPMHookPoint *HP_unit_walk_toxy_timer_pre; + struct HPMHookPoint *HP_unit_walk_toxy_timer_post; + struct HPMHookPoint *HP_unit_walk_toxy_sub_pre; + struct HPMHookPoint *HP_unit_walk_toxy_sub_post; + struct HPMHookPoint *HP_unit_delay_walk_toxy_timer_pre; + struct HPMHookPoint *HP_unit_delay_walk_toxy_timer_post; + struct HPMHookPoint *HP_unit_walk_toxy_pre; + struct HPMHookPoint *HP_unit_walk_toxy_post; + struct HPMHookPoint *HP_unit_walktobl_timer_pre; + struct HPMHookPoint *HP_unit_walktobl_timer_post; struct HPMHookPoint *HP_unit_walktobl_pre; struct HPMHookPoint *HP_unit_walktobl_post; struct HPMHookPoint *HP_unit_run_pre; @@ -6812,20 +6814,22 @@ struct { struct HPMHookPoint *HP_unit_escape_post; struct HPMHookPoint *HP_unit_movepos_pre; struct HPMHookPoint *HP_unit_movepos_post; - struct HPMHookPoint *HP_unit_setdir_pre; - struct HPMHookPoint *HP_unit_setdir_post; + struct HPMHookPoint *HP_unit_set_dir_pre; + struct HPMHookPoint *HP_unit_set_dir_post; struct HPMHookPoint *HP_unit_getdir_pre; struct HPMHookPoint *HP_unit_getdir_post; struct HPMHookPoint *HP_unit_blown_pre; struct HPMHookPoint *HP_unit_blown_post; struct HPMHookPoint *HP_unit_warp_pre; struct HPMHookPoint *HP_unit_warp_post; + struct HPMHookPoint *HP_unit_warpto_master_pre; + struct HPMHookPoint *HP_unit_warpto_master_post; struct HPMHookPoint *HP_unit_stop_walking_pre; struct HPMHookPoint *HP_unit_stop_walking_post; struct HPMHookPoint *HP_unit_skilluse_id_pre; struct HPMHookPoint *HP_unit_skilluse_id_post; - struct HPMHookPoint *HP_unit_step_timer_pre; - struct HPMHookPoint *HP_unit_step_timer_post; + struct HPMHookPoint *HP_unit_steptimer_pre; + struct HPMHookPoint *HP_unit_steptimer_post; struct HPMHookPoint *HP_unit_stop_stepaction_pre; struct HPMHookPoint *HP_unit_stop_stepaction_post; struct HPMHookPoint *HP_unit_is_walking_pre; @@ -13657,22 +13661,24 @@ struct { int HP_unit_final_post; int HP_unit_bl2ud_pre; int HP_unit_bl2ud_post; + int HP_unit_cbl2ud_pre; + int HP_unit_cbl2ud_post; int HP_unit_bl2ud2_pre; int HP_unit_bl2ud2_post; int HP_unit_init_ud_pre; int HP_unit_init_ud_post; int HP_unit_attack_timer_pre; int HP_unit_attack_timer_post; - int HP_unit_walktoxy_timer_pre; - int HP_unit_walktoxy_timer_post; - int HP_unit_walktoxy_sub_pre; - int HP_unit_walktoxy_sub_post; - int HP_unit_delay_walktoxy_timer_pre; - int HP_unit_delay_walktoxy_timer_post; - int HP_unit_walktoxy_pre; - int HP_unit_walktoxy_post; - int HP_unit_walktobl_sub_pre; - int HP_unit_walktobl_sub_post; + int HP_unit_walk_toxy_timer_pre; + int HP_unit_walk_toxy_timer_post; + int HP_unit_walk_toxy_sub_pre; + int HP_unit_walk_toxy_sub_post; + int HP_unit_delay_walk_toxy_timer_pre; + int HP_unit_delay_walk_toxy_timer_post; + int HP_unit_walk_toxy_pre; + int HP_unit_walk_toxy_post; + int HP_unit_walktobl_timer_pre; + int HP_unit_walktobl_timer_post; int HP_unit_walktobl_pre; int HP_unit_walktobl_post; int HP_unit_run_pre; @@ -13683,20 +13689,22 @@ struct { int HP_unit_escape_post; int HP_unit_movepos_pre; int HP_unit_movepos_post; - int HP_unit_setdir_pre; - int HP_unit_setdir_post; + int HP_unit_set_dir_pre; + int HP_unit_set_dir_post; int HP_unit_getdir_pre; int HP_unit_getdir_post; int HP_unit_blown_pre; int HP_unit_blown_post; int HP_unit_warp_pre; int HP_unit_warp_post; + int HP_unit_warpto_master_pre; + int HP_unit_warpto_master_post; int HP_unit_stop_walking_pre; int HP_unit_stop_walking_post; int HP_unit_skilluse_id_pre; int HP_unit_skilluse_id_post; - int HP_unit_step_timer_pre; - int HP_unit_step_timer_post; + int HP_unit_steptimer_pre; + int HP_unit_steptimer_post; int HP_unit_stop_stepaction_pre; int HP_unit_stop_stepaction_post; int HP_unit_is_walking_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 672b94dd8..a360b3f53 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -3475,26 +3475,28 @@ struct HookingPointData HookingPoints[] = { { HP_POP(unit->init, HP_unit_init) }, { HP_POP(unit->final, HP_unit_final) }, { HP_POP(unit->bl2ud, HP_unit_bl2ud) }, + { HP_POP(unit->cbl2ud, HP_unit_cbl2ud) }, { HP_POP(unit->bl2ud2, HP_unit_bl2ud2) }, { HP_POP(unit->init_ud, HP_unit_init_ud) }, { HP_POP(unit->attack_timer, HP_unit_attack_timer) }, - { HP_POP(unit->walktoxy_timer, HP_unit_walktoxy_timer) }, - { HP_POP(unit->walktoxy_sub, HP_unit_walktoxy_sub) }, - { HP_POP(unit->delay_walktoxy_timer, HP_unit_delay_walktoxy_timer) }, - { HP_POP(unit->walktoxy, HP_unit_walktoxy) }, - { HP_POP(unit->walktobl_sub, HP_unit_walktobl_sub) }, + { HP_POP(unit->walk_toxy_timer, HP_unit_walk_toxy_timer) }, + { HP_POP(unit->walk_toxy_sub, HP_unit_walk_toxy_sub) }, + { HP_POP(unit->delay_walk_toxy_timer, HP_unit_delay_walk_toxy_timer) }, + { HP_POP(unit->walk_toxy, HP_unit_walk_toxy) }, + { HP_POP(unit->walktobl_timer, HP_unit_walktobl_timer) }, { HP_POP(unit->walktobl, HP_unit_walktobl) }, { HP_POP(unit->run, HP_unit_run) }, { HP_POP(unit->run_hit, HP_unit_run_hit) }, { HP_POP(unit->escape, HP_unit_escape) }, { HP_POP(unit->movepos, HP_unit_movepos) }, - { HP_POP(unit->setdir, HP_unit_setdir) }, + { HP_POP(unit->set_dir, HP_unit_set_dir) }, { HP_POP(unit->getdir, HP_unit_getdir) }, { HP_POP(unit->blown, HP_unit_blown) }, { HP_POP(unit->warp, HP_unit_warp) }, + { HP_POP(unit->warpto_master, HP_unit_warpto_master) }, { HP_POP(unit->stop_walking, HP_unit_stop_walking) }, { HP_POP(unit->skilluse_id, HP_unit_skilluse_id) }, - { HP_POP(unit->step_timer, HP_unit_step_timer) }, + { HP_POP(unit->steptimer, HP_unit_steptimer) }, { HP_POP(unit->stop_stepaction, HP_unit_stop_stepaction) }, { HP_POP(unit->is_walking, HP_unit_is_walking) }, { HP_POP(unit->can_move, HP_unit_can_move) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 423490182..592279cc4 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -48284,11 +48284,11 @@ void HP_map_reloadnpc(bool clear) { } return; } -int HP_map_check_dir(int s_dir, int t_dir) { +int HP_map_check_dir(enum unit_dir s_dir, enum unit_dir t_dir) { int hIndex = 0; int retVal___ = 0; if (HPMHooks.count.HP_map_check_dir_pre > 0) { - int (*preHookFunc) (int *s_dir, int *t_dir); + int (*preHookFunc) (enum unit_dir *s_dir, enum unit_dir *t_dir); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_map_check_dir_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_map_check_dir_pre[hIndex].func; @@ -48303,7 +48303,7 @@ int HP_map_check_dir(int s_dir, int t_dir) { retVal___ = HPMHooks.source.map.check_dir(s_dir, t_dir); } if (HPMHooks.count.HP_map_check_dir_post > 0) { - int (*postHookFunc) (int retVal___, int s_dir, int t_dir); + int (*postHookFunc) (int retVal___, enum unit_dir s_dir, enum unit_dir t_dir); for (hIndex = 0; hIndex < HPMHooks.count.HP_map_check_dir_post; hIndex++) { postHookFunc = HPMHooks.list.HP_map_check_dir_post[hIndex].func; retVal___ = postHookFunc(retVal___, s_dir, t_dir); @@ -48311,11 +48311,11 @@ int HP_map_check_dir(int s_dir, int t_dir) { } return retVal___; } -uint8 HP_map_calc_dir(struct block_list *src, int16 x, int16 y) { +enum unit_dir HP_map_calc_dir(const struct block_list *src, int16 x, int16 y) { int hIndex = 0; - uint8 retVal___ = 0; + enum unit_dir retVal___ = UNIT_DIR_UNDEFINED; if (HPMHooks.count.HP_map_calc_dir_pre > 0) { - uint8 (*preHookFunc) (struct block_list **src, int16 *x, int16 *y); + enum unit_dir (*preHookFunc) (const struct block_list **src, int16 *x, int16 *y); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_map_calc_dir_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_map_calc_dir_pre[hIndex].func; @@ -48330,7 +48330,7 @@ uint8 HP_map_calc_dir(struct block_list *src, int16 x, int16 y) { retVal___ = HPMHooks.source.map.calc_dir(src, x, y); } if (HPMHooks.count.HP_map_calc_dir_post > 0) { - uint8 (*postHookFunc) (uint8 retVal___, struct block_list *src, int16 x, int16 y); + enum unit_dir (*postHookFunc) (enum unit_dir retVal___, const struct block_list *src, int16 x, int16 y); for (hIndex = 0; hIndex < HPMHooks.count.HP_map_calc_dir_post; hIndex++) { postHookFunc = HPMHooks.list.HP_map_calc_dir_post[hIndex].func; retVal___ = postHookFunc(retVal___, src, x, y); @@ -57108,11 +57108,11 @@ bool HP_npc_viewisid(const char *viewid) { } return retVal___; } -struct npc_data* HP_npc_create_npc(enum npc_subtype subtype, int m, int x, int y, uint8 dir, int class_) { +struct npc_data* HP_npc_create_npc(enum npc_subtype subtype, int m, int x, int y, enum unit_dir dir, int class_) { int hIndex = 0; struct npc_data* retVal___ = NULL; if (HPMHooks.count.HP_npc_create_npc_pre > 0) { - struct npc_data* (*preHookFunc) (enum npc_subtype *subtype, int *m, int *x, int *y, uint8 *dir, int *class_); + struct npc_data* (*preHookFunc) (enum npc_subtype *subtype, int *m, int *x, int *y, enum unit_dir *dir, int *class_); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_npc_create_npc_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_npc_create_npc_pre[hIndex].func; @@ -57127,7 +57127,7 @@ struct npc_data* HP_npc_create_npc(enum npc_subtype subtype, int m, int x, int y retVal___ = HPMHooks.source.npc.create_npc(subtype, m, x, y, dir, class_); } if (HPMHooks.count.HP_npc_create_npc_post > 0) { - struct npc_data* (*postHookFunc) (struct npc_data* retVal___, enum npc_subtype subtype, int m, int x, int y, uint8 dir, int class_); + struct npc_data* (*postHookFunc) (struct npc_data* retVal___, enum npc_subtype subtype, int m, int x, int y, enum unit_dir dir, int class_); for (hIndex = 0; hIndex < HPMHooks.count.HP_npc_create_npc_post; hIndex++) { postHookFunc = HPMHooks.list.HP_npc_create_npc_post[hIndex].func; retVal___ = postHookFunc(retVal___, subtype, m, x, y, dir, class_); @@ -77704,11 +77704,11 @@ int HP_skill_counter_additional_effect(struct block_list *src, struct block_list } return retVal___; } -int HP_skill_blown(struct block_list *src, struct block_list *target, int count, int8 dir, int flag) { +int HP_skill_blown(struct block_list *src, struct block_list *target, int count, enum unit_dir dir, int flag) { int hIndex = 0; int retVal___ = 0; if (HPMHooks.count.HP_skill_blown_pre > 0) { - int (*preHookFunc) (struct block_list **src, struct block_list **target, int *count, int8 *dir, int *flag); + int (*preHookFunc) (struct block_list **src, struct block_list **target, int *count, enum unit_dir *dir, int *flag); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_blown_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_skill_blown_pre[hIndex].func; @@ -77723,7 +77723,7 @@ int HP_skill_blown(struct block_list *src, struct block_list *target, int count, retVal___ = HPMHooks.source.skill.blown(src, target, count, dir, flag); } if (HPMHooks.count.HP_skill_blown_post > 0) { - int (*postHookFunc) (int retVal___, struct block_list *src, struct block_list *target, int count, int8 dir, int flag); + int (*postHookFunc) (int retVal___, struct block_list *src, struct block_list *target, int count, enum unit_dir dir, int flag); for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_blown_post; hIndex++) { postHookFunc = HPMHooks.list.HP_skill_blown_post[hIndex].func; retVal___ = postHookFunc(retVal___, src, target, count, dir, flag); @@ -80034,10 +80034,10 @@ int HP_skill_check_condition_mob_master_sub(struct block_list *bl, va_list ap) { } return retVal___; } -void HP_skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int16 y) { +void HP_skill_brandishspear_first(struct square *tc, enum unit_dir dir, int16 x, int16 y) { int hIndex = 0; if (HPMHooks.count.HP_skill_brandishspear_first_pre > 0) { - void (*preHookFunc) (struct square **tc, uint8 *dir, int16 *x, int16 *y); + void (*preHookFunc) (struct square **tc, enum unit_dir *dir, int16 *x, int16 *y); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_brandishspear_first_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_skill_brandishspear_first_pre[hIndex].func; @@ -80052,7 +80052,7 @@ void HP_skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int16 y HPMHooks.source.skill.brandishspear_first(tc, dir, x, y); } if (HPMHooks.count.HP_skill_brandishspear_first_post > 0) { - void (*postHookFunc) (struct square *tc, uint8 dir, int16 x, int16 y); + void (*postHookFunc) (struct square *tc, enum unit_dir dir, int16 x, int16 y); for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_brandishspear_first_post; hIndex++) { postHookFunc = HPMHooks.list.HP_skill_brandishspear_first_post[hIndex].func; postHookFunc(tc, dir, x, y); @@ -80060,10 +80060,10 @@ void HP_skill_brandishspear_first(struct square *tc, uint8 dir, int16 x, int16 y } return; } -void HP_skill_brandishspear_dir(struct square *tc, uint8 dir, int are) { +void HP_skill_brandishspear_dir(struct square *tc, enum unit_dir dir, int are) { int hIndex = 0; if (HPMHooks.count.HP_skill_brandishspear_dir_pre > 0) { - void (*preHookFunc) (struct square **tc, uint8 *dir, int *are); + void (*preHookFunc) (struct square **tc, enum unit_dir *dir, int *are); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_brandishspear_dir_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_skill_brandishspear_dir_pre[hIndex].func; @@ -80078,7 +80078,7 @@ void HP_skill_brandishspear_dir(struct square *tc, uint8 dir, int are) { HPMHooks.source.skill.brandishspear_dir(tc, dir, are); } if (HPMHooks.count.HP_skill_brandishspear_dir_post > 0) { - void (*postHookFunc) (struct square *tc, uint8 dir, int are); + void (*postHookFunc) (struct square *tc, enum unit_dir dir, int are); for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_brandishspear_dir_post; hIndex++) { postHookFunc = HPMHooks.list.HP_skill_brandishspear_dir_post[hIndex].func; postHookFunc(tc, dir, are); @@ -81995,10 +81995,10 @@ int HP_skill_attack_dir_unknown(int *attack_type, struct block_list *src, struct } return retVal___; } -void HP_skill_attack_blow_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir) { +void HP_skill_attack_blow_unknown(int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, enum unit_dir *dir) { int hIndex = 0; if (HPMHooks.count.HP_skill_attack_blow_unknown_pre > 0) { - void (*preHookFunc) (int **attack_type, struct block_list **src, struct block_list **dsrc, struct block_list **bl, uint16 **skill_id, uint16 **skill_lv, int64 **tick, int **flag, int **type, struct Damage **dmg, int64 **damage, int8 **dir); + void (*preHookFunc) (int **attack_type, struct block_list **src, struct block_list **dsrc, struct block_list **bl, uint16 **skill_id, uint16 **skill_lv, int64 **tick, int **flag, int **type, struct Damage **dmg, int64 **damage, enum unit_dir **dir); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_attack_blow_unknown_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_skill_attack_blow_unknown_pre[hIndex].func; @@ -82013,7 +82013,7 @@ void HP_skill_attack_blow_unknown(int *attack_type, struct block_list *src, stru HPMHooks.source.skill.attack_blow_unknown(attack_type, src, dsrc, bl, skill_id, skill_lv, tick, flag, type, dmg, damage, dir); } if (HPMHooks.count.HP_skill_attack_blow_unknown_post > 0) { - void (*postHookFunc) (int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, int8 *dir); + void (*postHookFunc) (int *attack_type, struct block_list *src, struct block_list *dsrc, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag, int *type, struct Damage *dmg, int64 *damage, enum unit_dir *dir); for (hIndex = 0; hIndex < HPMHooks.count.HP_skill_attack_blow_unknown_post; hIndex++) { postHookFunc = HPMHooks.list.HP_skill_attack_blow_unknown_post[hIndex].func; postHookFunc(attack_type, src, dsrc, bl, skill_id, skill_lv, tick, flag, type, dmg, damage, dir); @@ -90806,6 +90806,33 @@ struct unit_data* HP_unit_bl2ud(struct block_list *bl) { } return retVal___; } +const struct unit_data* HP_unit_cbl2ud(const struct block_list *bl) { + int hIndex = 0; + const struct unit_data* retVal___ = NULL; + if (HPMHooks.count.HP_unit_cbl2ud_pre > 0) { + const struct unit_data* (*preHookFunc) (const struct block_list **bl); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_cbl2ud_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_cbl2ud_pre[hIndex].func; + retVal___ = preHookFunc(&bl); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.unit.cbl2ud(bl); + } + if (HPMHooks.count.HP_unit_cbl2ud_post > 0) { + const struct unit_data* (*postHookFunc) (const struct unit_data* retVal___, const struct block_list *bl); + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_cbl2ud_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_cbl2ud_post[hIndex].func; + retVal___ = postHookFunc(retVal___, bl); + } + } + return retVal___; +} struct unit_data* HP_unit_bl2ud2(struct block_list *bl) { int hIndex = 0; struct unit_data* retVal___ = NULL; @@ -90886,14 +90913,14 @@ int HP_unit_attack_timer(int tid, int64 tick, int id, intptr_t data) { } return retVal___; } -int HP_unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { +int HP_unit_walk_toxy_timer(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_walktoxy_timer_pre > 0) { + if (HPMHooks.count.HP_unit_walk_toxy_timer_pre > 0) { int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktoxy_timer_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_walktoxy_timer_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walk_toxy_timer_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_walk_toxy_timer_pre[hIndex].func; retVal___ = preHookFunc(&tid, &tick, &id, &data); } if (*HPMforce_return) { @@ -90902,25 +90929,25 @@ int HP_unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { } } { - retVal___ = HPMHooks.source.unit.walktoxy_timer(tid, tick, id, data); + retVal___ = HPMHooks.source.unit.walk_toxy_timer(tid, tick, id, data); } - if (HPMHooks.count.HP_unit_walktoxy_timer_post > 0) { + if (HPMHooks.count.HP_unit_walk_toxy_timer_post > 0) { int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktoxy_timer_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_walktoxy_timer_post[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walk_toxy_timer_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_walk_toxy_timer_post[hIndex].func; retVal___ = postHookFunc(retVal___, tid, tick, id, data); } } return retVal___; } -int HP_unit_walktoxy_sub(struct block_list *bl) { +int HP_unit_walk_toxy_sub(struct block_list *bl) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_walktoxy_sub_pre > 0) { + if (HPMHooks.count.HP_unit_walk_toxy_sub_pre > 0) { int (*preHookFunc) (struct block_list **bl); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktoxy_sub_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_walktoxy_sub_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walk_toxy_sub_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_walk_toxy_sub_pre[hIndex].func; retVal___ = preHookFunc(&bl); } if (*HPMforce_return) { @@ -90929,25 +90956,25 @@ int HP_unit_walktoxy_sub(struct block_list *bl) { } } { - retVal___ = HPMHooks.source.unit.walktoxy_sub(bl); + retVal___ = HPMHooks.source.unit.walk_toxy_sub(bl); } - if (HPMHooks.count.HP_unit_walktoxy_sub_post > 0) { + if (HPMHooks.count.HP_unit_walk_toxy_sub_post > 0) { int (*postHookFunc) (int retVal___, struct block_list *bl); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktoxy_sub_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_walktoxy_sub_post[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walk_toxy_sub_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_walk_toxy_sub_post[hIndex].func; retVal___ = postHookFunc(retVal___, bl); } } return retVal___; } -int HP_unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { +int HP_unit_delay_walk_toxy_timer(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_delay_walktoxy_timer_pre > 0) { + if (HPMHooks.count.HP_unit_delay_walk_toxy_timer_pre > 0) { int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_delay_walktoxy_timer_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_delay_walktoxy_timer_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_delay_walk_toxy_timer_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_delay_walk_toxy_timer_pre[hIndex].func; retVal___ = preHookFunc(&tid, &tick, &id, &data); } if (*HPMforce_return) { @@ -90956,25 +90983,25 @@ int HP_unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { } } { - retVal___ = HPMHooks.source.unit.delay_walktoxy_timer(tid, tick, id, data); + retVal___ = HPMHooks.source.unit.delay_walk_toxy_timer(tid, tick, id, data); } - if (HPMHooks.count.HP_unit_delay_walktoxy_timer_post > 0) { + if (HPMHooks.count.HP_unit_delay_walk_toxy_timer_post > 0) { int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_delay_walktoxy_timer_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_delay_walktoxy_timer_post[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_delay_walk_toxy_timer_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_delay_walk_toxy_timer_post[hIndex].func; retVal___ = postHookFunc(retVal___, tid, tick, id, data); } } return retVal___; } -int HP_unit_walktoxy(struct block_list *bl, short x, short y, int flag) { +int HP_unit_walk_toxy(struct block_list *bl, short x, short y, int flag) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_walktoxy_pre > 0) { + if (HPMHooks.count.HP_unit_walk_toxy_pre > 0) { int (*preHookFunc) (struct block_list **bl, short *x, short *y, int *flag); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktoxy_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_walktoxy_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walk_toxy_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_walk_toxy_pre[hIndex].func; retVal___ = preHookFunc(&bl, &x, &y, &flag); } if (*HPMforce_return) { @@ -90983,25 +91010,25 @@ int HP_unit_walktoxy(struct block_list *bl, short x, short y, int flag) { } } { - retVal___ = HPMHooks.source.unit.walktoxy(bl, x, y, flag); + retVal___ = HPMHooks.source.unit.walk_toxy(bl, x, y, flag); } - if (HPMHooks.count.HP_unit_walktoxy_post > 0) { + if (HPMHooks.count.HP_unit_walk_toxy_post > 0) { int (*postHookFunc) (int retVal___, struct block_list *bl, short x, short y, int flag); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktoxy_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_walktoxy_post[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walk_toxy_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_walk_toxy_post[hIndex].func; retVal___ = postHookFunc(retVal___, bl, x, y, flag); } } return retVal___; } -int HP_unit_walktobl_sub(int tid, int64 tick, int id, intptr_t data) { +int HP_unit_walktobl_timer(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_walktobl_sub_pre > 0) { + if (HPMHooks.count.HP_unit_walktobl_timer_pre > 0) { int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktobl_sub_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_walktobl_sub_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktobl_timer_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_walktobl_timer_pre[hIndex].func; retVal___ = preHookFunc(&tid, &tick, &id, &data); } if (*HPMforce_return) { @@ -91010,12 +91037,12 @@ int HP_unit_walktobl_sub(int tid, int64 tick, int id, intptr_t data) { } } { - retVal___ = HPMHooks.source.unit.walktobl_sub(tid, tick, id, data); + retVal___ = HPMHooks.source.unit.walktobl_timer(tid, tick, id, data); } - if (HPMHooks.count.HP_unit_walktobl_sub_post > 0) { + if (HPMHooks.count.HP_unit_walktobl_timer_post > 0) { int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktobl_sub_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_walktobl_sub_post[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_walktobl_timer_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_walktobl_timer_post[hIndex].func; retVal___ = postHookFunc(retVal___, tid, tick, id, data); } } @@ -91155,14 +91182,14 @@ int HP_unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, b } return retVal___; } -int HP_unit_setdir(struct block_list *bl, unsigned char dir) { +int HP_unit_set_dir(struct block_list *bl, enum unit_dir dir) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_setdir_pre > 0) { - int (*preHookFunc) (struct block_list **bl, unsigned char *dir); + if (HPMHooks.count.HP_unit_set_dir_pre > 0) { + int (*preHookFunc) (struct block_list **bl, enum unit_dir *dir); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_setdir_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_setdir_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_set_dir_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_set_dir_pre[hIndex].func; retVal___ = preHookFunc(&bl, &dir); } if (*HPMforce_return) { @@ -91171,22 +91198,22 @@ int HP_unit_setdir(struct block_list *bl, unsigned char dir) { } } { - retVal___ = HPMHooks.source.unit.setdir(bl, dir); + retVal___ = HPMHooks.source.unit.set_dir(bl, dir); } - if (HPMHooks.count.HP_unit_setdir_post > 0) { - int (*postHookFunc) (int retVal___, struct block_list *bl, unsigned char dir); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_setdir_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_setdir_post[hIndex].func; + if (HPMHooks.count.HP_unit_set_dir_post > 0) { + int (*postHookFunc) (int retVal___, struct block_list *bl, enum unit_dir dir); + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_set_dir_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_set_dir_post[hIndex].func; retVal___ = postHookFunc(retVal___, bl, dir); } } return retVal___; } -uint8 HP_unit_getdir(struct block_list *bl) { +enum unit_dir HP_unit_getdir(const struct block_list *bl) { int hIndex = 0; - uint8 retVal___ = 0; + enum unit_dir retVal___ = UNIT_DIR_UNDEFINED; if (HPMHooks.count.HP_unit_getdir_pre > 0) { - uint8 (*preHookFunc) (struct block_list **bl); + enum unit_dir (*preHookFunc) (const struct block_list **bl); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_getdir_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_unit_getdir_pre[hIndex].func; @@ -91201,7 +91228,7 @@ uint8 HP_unit_getdir(struct block_list *bl) { retVal___ = HPMHooks.source.unit.getdir(bl); } if (HPMHooks.count.HP_unit_getdir_post > 0) { - uint8 (*postHookFunc) (uint8 retVal___, struct block_list *bl); + enum unit_dir (*postHookFunc) (enum unit_dir retVal___, const struct block_list *bl); for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_getdir_post; hIndex++) { postHookFunc = HPMHooks.list.HP_unit_getdir_post[hIndex].func; retVal___ = postHookFunc(retVal___, bl); @@ -91263,6 +91290,33 @@ int HP_unit_warp(struct block_list *bl, short m, short x, short y, enum clr_type } return retVal___; } +int HP_unit_warpto_master(struct block_list *master_bl, struct block_list *slave_bl) { + int hIndex = 0; + int retVal___ = 0; + if (HPMHooks.count.HP_unit_warpto_master_pre > 0) { + int (*preHookFunc) (struct block_list **master_bl, struct block_list **slave_bl); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_warpto_master_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_warpto_master_pre[hIndex].func; + retVal___ = preHookFunc(&master_bl, &slave_bl); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.unit.warpto_master(master_bl, slave_bl); + } + if (HPMHooks.count.HP_unit_warpto_master_post > 0) { + int (*postHookFunc) (int retVal___, struct block_list *master_bl, struct block_list *slave_bl); + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_warpto_master_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_warpto_master_post[hIndex].func; + retVal___ = postHookFunc(retVal___, master_bl, slave_bl); + } + } + return retVal___; +} int HP_unit_stop_walking(struct block_list *bl, int type) { int hIndex = 0; int retVal___ = 0; @@ -91317,14 +91371,14 @@ int HP_unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, } return retVal___; } -int HP_unit_step_timer(int tid, int64 tick, int id, intptr_t data) { +int HP_unit_steptimer(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; - if (HPMHooks.count.HP_unit_step_timer_pre > 0) { + if (HPMHooks.count.HP_unit_steptimer_pre > 0) { int (*preHookFunc) (int *tid, int64 *tick, int *id, intptr_t *data); *HPMforce_return = false; - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_step_timer_pre; hIndex++) { - preHookFunc = HPMHooks.list.HP_unit_step_timer_pre[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_steptimer_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_unit_steptimer_pre[hIndex].func; retVal___ = preHookFunc(&tid, &tick, &id, &data); } if (*HPMforce_return) { @@ -91333,12 +91387,12 @@ int HP_unit_step_timer(int tid, int64 tick, int id, intptr_t data) { } } { - retVal___ = HPMHooks.source.unit.step_timer(tid, tick, id, data); + retVal___ = HPMHooks.source.unit.steptimer(tid, tick, id, data); } - if (HPMHooks.count.HP_unit_step_timer_post > 0) { + if (HPMHooks.count.HP_unit_steptimer_post > 0) { int (*postHookFunc) (int retVal___, int tid, int64 tick, int id, intptr_t data); - for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_step_timer_post; hIndex++) { - postHookFunc = HPMHooks.list.HP_unit_step_timer_post[hIndex].func; + for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_steptimer_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_unit_steptimer_post[hIndex].func; retVal___ = postHookFunc(retVal___, tid, tick, id, data); } } @@ -91747,11 +91801,11 @@ bool HP_unit_can_reach_bl(struct block_list *bl, struct block_list *tbl, int ran } return retVal___; } -int HP_unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) { +int HP_unit_calc_pos(struct block_list *bl, int tx, int ty, enum unit_dir dir) { int hIndex = 0; int retVal___ = 0; if (HPMHooks.count.HP_unit_calc_pos_pre > 0) { - int (*preHookFunc) (struct block_list **bl, int *tx, int *ty, uint8 *dir); + int (*preHookFunc) (struct block_list **bl, int *tx, int *ty, enum unit_dir *dir); *HPMforce_return = false; for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_calc_pos_pre; hIndex++) { preHookFunc = HPMHooks.list.HP_unit_calc_pos_pre[hIndex].func; @@ -91766,7 +91820,7 @@ int HP_unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) { retVal___ = HPMHooks.source.unit.calc_pos(bl, tx, ty, dir); } if (HPMHooks.count.HP_unit_calc_pos_post > 0) { - int (*postHookFunc) (int retVal___, struct block_list *bl, int tx, int ty, uint8 dir); + int (*postHookFunc) (int retVal___, struct block_list *bl, int tx, int ty, enum unit_dir dir); for (hIndex = 0; hIndex < HPMHooks.count.HP_unit_calc_pos_post; hIndex++) { postHookFunc = HPMHooks.list.HP_unit_calc_pos_post[hIndex].func; retVal___ = postHookFunc(retVal___, bl, tx, ty, dir); |