diff options
author | Jesusaves <cpntb1@ymail.com> | 2019-01-24 17:20:28 -0200 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2019-01-24 17:20:28 -0200 |
commit | 7210863603075d782e8b38029cbfe3400bb4f9ff (patch) | |
tree | 74c3eece0592564a43ceb40af4d1cd2d4b834cbc | |
parent | a36c630622f2ab7772e461c77f21e7dea7b72335 (diff) | |
parent | 3c0e3838f77a62a69130d7b2674e21e2133a7f83 (diff) | |
download | evol-hercules-7210863603075d782e8b38029cbfe3400bb4f9ff.tar.gz evol-hercules-7210863603075d782e8b38029cbfe3400bb4f9ff.tar.bz2 evol-hercules-7210863603075d782e8b38029cbfe3400bb4f9ff.tar.xz evol-hercules-7210863603075d782e8b38029cbfe3400bb4f9ff.zip |
Merge branch 'master' into tmw2
-rw-r--r-- | .gitlab-ci.yml | 16 | ||||
-rw-r--r-- | src/echar/char.c | 3 | ||||
-rw-r--r-- | src/echar/char.h | 2 | ||||
-rw-r--r-- | src/echar/init.c | 2 | ||||
-rw-r--r-- | src/elogin/parse.c | 4 | ||||
-rw-r--r-- | src/emap/clif.c | 102 | ||||
-rw-r--r-- | src/emap/craft.c | 49 | ||||
-rw-r--r-- | src/emap/craft.h | 2 | ||||
-rw-r--r-- | src/emap/npc.c | 7 | ||||
-rw-r--r-- | src/emap/parse.c | 2 | ||||
-rw-r--r-- | src/emap/pc.c | 12 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 2 | ||||
-rw-r--r-- | src/emap/scriptdefines.h | 2 | ||||
-rw-r--r-- | src/emap/status.c | 2 |
14 files changed, 89 insertions, 118 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0952285..87bb6fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,7 @@ gcc-4.9: - ./tools/ci/jobs/gcc49.sh --enable-werror image: debian:jessie -gcc-5: +.gcc-5: stage: build script: - ./tools/ci/jobs/gcc5.sh --enable-werror @@ -131,7 +131,7 @@ gcc-4.9-sanitize: - ./tools/ci/jobs/gcc49.sh --enable-werror --enable-sanitize image: debian:jessie -gcc-5-sanitize: +.gcc-5-sanitize: stage: test script: - ./tools/ci/jobs/gcc5.sh --enable-werror --enable-sanitize @@ -155,7 +155,7 @@ gcc-4.9_lto-sanitize: - ./tools/ci/jobs/gcc49.sh --enable-werror --enable-lto --enable-sanitize image: debian:jessie -gcc-5_lto-sanitize: +.gcc-5_lto-sanitize: stage: test script: - ./tools/ci/jobs/gcc5.sh --enable-werror --enable-lto --enable-sanitize @@ -185,7 +185,7 @@ gcc-4.9-lto: - ./tools/ci/jobs/gcc49.sh --enable-werror --enable-lto image: debian:jessie -gcc-5-lto: +.gcc-5-lto: stage: test script: - ./tools/ci/jobs/gcc5.sh --enable-werror --enable-lto @@ -219,8 +219,14 @@ gcc-4.8_stable_lto-sanitize: - ./tools/ci/jobs/gcc48.sh --enable-werror --enable-lto --enable-sanitize image: debian:jessie -gcc-5_unstable_lto-sanitize: +.gcc-5_unstable_lto-sanitize: stage: legacy script: - ./tools/ci/jobs/gcc5.sh --enable-werror --enable-lto --enable-sanitize image: debian:unstable + +gcc-6_unstable_lto-sanitize: + stage: legacy + script: + - ./tools/ci/jobs/gcc6.sh --enable-werror --enable-lto --enable-sanitize + image: debian:unstable diff --git a/src/echar/char.c b/src/echar/char.c index efbe402..037aa05 100644 --- a/src/echar/char.c +++ b/src/echar/char.c @@ -124,6 +124,7 @@ void echar_creation_failed(int *fdPtr, int *result) /* 0x02 = Symbols in Character Names are forbidden */ /* 0x03 = You are not eligible to open the Character Slot. */ /* 0x0B = This service is only available for premium users. */ + /* 0x0C = Character name is invalid. */ switch (*result) { case -1: WFIFOB(fd, 2) = 0x00; break; // 'Charname already exists' @@ -176,7 +177,7 @@ void echar_parse_login_password_change_ack(int charFd) } } -void echar_mmo_char_send099d_post(int fd, struct char_session_data *sd) +void echar_send_HC_ACK_CHARINFO_PER_PAGE_post(int fd, struct char_session_data *sd) { send_additional_slots(fd, sd); } diff --git a/src/echar/char.h b/src/echar/char.h index 8726d93..708a558 100644 --- a/src/echar/char.h +++ b/src/echar/char.h @@ -13,7 +13,7 @@ void echar_parse_change_paassword(int fd); void echar_parse_login_password_change_ack(int charFd); -void echar_mmo_char_send099d_post(int fd, struct char_session_data *sd); +void echar_send_HC_ACK_CHARINFO_PER_PAGE_post(int fd, struct char_session_data *sd); int echar_mmo_char_send_characters_post(int retVal, int fd, struct char_session_data *sd); diff --git a/src/echar/init.c b/src/echar/init.c index d9f39c7..4e9faa6 100644 --- a/src/echar/init.c +++ b/src/echar/init.c @@ -61,7 +61,7 @@ HPExport void plugin_init (void) addHookPre(chr, creation_failed, echar_creation_failed); addHookPre(chr, parse_char_connect, echar_parse_char_connect_pre); - addHookPost(chr, mmo_char_send099d, echar_mmo_char_send099d_post); + addHookPost(chr, send_HC_ACK_CHARINFO_PER_PAGE, echar_send_HC_ACK_CHARINFO_PER_PAGE_post); addHookPost(chr, mmo_char_send_characters, echar_mmo_char_send_characters_post); addHookPost(chr, parse_char_connect, echar_parse_char_connect_post); } diff --git a/src/elogin/parse.c b/src/elogin/parse.c index b6e4b5d..d17434b 100644 --- a/src/elogin/parse.c +++ b/src/elogin/parse.c @@ -35,7 +35,7 @@ void login_parse_version(int fd) clientVersion = RFIFOL(fd, 2); // check for minimal supported version - if (clientVersion < 19) + if (clientVersion < 20) { lclif->login_error(fd, 5); return; @@ -60,7 +60,7 @@ bool elogin_client_login_pre(int *fdPtr, safestrncpy(username, RFIFOP(fd, 6), NAME_LENGTH); int len = (int)safestrnlen(username, NAME_LENGTH); // check for minimal supported version - if (clientVersion < 19) + if (clientVersion < 20) { lclif->login_error(fd, 5); hookStop(); diff --git a/src/emap/clif.c b/src/emap/clif.c index 4892549..d0d3cde 100644 --- a/src/emap/clif.c +++ b/src/emap/clif.c @@ -89,55 +89,26 @@ void eclif_quest_send_list_pre(TBL_PC **sdPtr) return; } - struct SessionExt *data = session_get_bysd(sd); - if (!data) - return; - if (data->clientVersion < 20) + int fd = sd->fd; + int info_len = 4 + 1 + 3 * 4 + 4; + int len = sd->avail_quests * info_len + 8; + WFIFOHEAD(fd, len); + WFIFOW(fd, 0) = 0xb23 + evolPacketOffset; + WFIFOW(fd, 2) = len; + WFIFOL(fd, 4) = sd->avail_quests; + for (int i = 0; i < sd->avail_quests; i++ ) { - int fd = sd->fd; - int i; - int info_len = 15; - int len = sd->avail_quests * info_len + 8; - WFIFOHEAD(fd, len); - WFIFOW(fd, 0) = 0x97a; - WFIFOW(fd, 2) = len; - WFIFOL(fd, 4) = sd->avail_quests; - for (i = 0; i < sd->avail_quests; i++ ) - { - struct quest_db *qi = quest->db(sd->quest_log[i].quest_id); - if (!qi) - continue; - WFIFOL(fd, i * info_len + 8) = sd->quest_log[i].quest_id; - WFIFOB(fd, i * info_len + 12) = sd->quest_log[i].count[0]; // was state - WFIFOL(fd, i * info_len + 13) = sd->quest_log[i].time - qi->time; - WFIFOL(fd, i * info_len + 17) = sd->quest_log[i].time; - WFIFOW(fd, i * info_len + 21) = 0; - } - WFIFOSET(fd, len); - } - else - { // data->clientVersion >= 20 - int fd = sd->fd; - int info_len = 4 + 1 + 3 * 4 + 4; - int len = sd->avail_quests * info_len + 8; - WFIFOHEAD(fd, len); - WFIFOW(fd, 0) = 0xb23 + evolPacketOffset; - WFIFOW(fd, 2) = len; - WFIFOL(fd, 4) = sd->avail_quests; - for (int i = 0; i < sd->avail_quests; i++ ) - { - struct quest_db *qi = quest->db(sd->quest_log[i].quest_id); - if (!qi) - continue; - WFIFOL(fd, i * info_len + 8) = sd->quest_log[i].quest_id; - WFIFOB(fd, i * info_len + 12) = sd->quest_log[i].state; - WFIFOL(fd, i * info_len + 13) = sd->quest_log[i].count[0]; - WFIFOL(fd, i * info_len + 17) = sd->quest_log[i].count[1]; - WFIFOL(fd, i * info_len + 21) = sd->quest_log[i].count[2]; - WFIFOL(fd, i * info_len + 25) = sd->quest_log[i].time; - } - WFIFOSET(fd, len); + struct quest_db *qi = quest->db(sd->quest_log[i].quest_id); + if (!qi) + continue; + WFIFOL(fd, i * info_len + 8) = sd->quest_log[i].quest_id; + WFIFOB(fd, i * info_len + 12) = sd->quest_log[i].state; + WFIFOL(fd, i * info_len + 13) = sd->quest_log[i].count[0]; + WFIFOL(fd, i * info_len + 17) = sd->quest_log[i].count[1]; + WFIFOL(fd, i * info_len + 21) = sd->quest_log[i].count[2]; + WFIFOL(fd, i * info_len + 25) = sd->quest_log[i].time; } + WFIFOSET(fd, len); hookStop(); } @@ -151,7 +122,6 @@ void eclif_quest_add_pre(TBL_PC **sdPtr, void eclif_quest_add(TBL_PC *sd, struct quest *qd) { - // for new client need send here: id, 3 counts, time if (!sd || !qd) { hookStop(); @@ -166,32 +136,16 @@ void eclif_quest_add(TBL_PC *sd, return; } - struct SessionExt *data = session_get_bysd(sd); - if (!data) - return; - if (data->clientVersion < 20) - { - WFIFOHEAD(fd, 107); - WFIFOW(fd, 0) = 0x2b3; - WFIFOL(fd, 2) = qd->quest_id; - WFIFOB(fd, 6) = qd->count[0]; // was state; - WFIFOB(fd, 7) = qd->time - qi->time; - WFIFOL(fd, 11) = qd->time; - WFIFOW(fd, 15) = 0; - WFIFOSET(fd, 107); - } - else - { // data->clientVersion >= 20 - WFIFOHEAD(fd, 23); - WFIFOW(fd, 0) = 0xb24 + evolPacketOffset; - WFIFOL(fd, 2) = qd->quest_id; - WFIFOB(fd, 6) = qd->state; - WFIFOL(fd, 7) = qd->count[0]; - WFIFOL(fd, 11) = qd->count[1]; - WFIFOL(fd, 15) = qd->count[2]; - WFIFOL(fd, 19) = qd->time; - WFIFOSET(fd, 23); - } + WFIFOHEAD(fd, 23); + WFIFOW(fd, 0) = 0xb24 + evolPacketOffset; + WFIFOL(fd, 2) = qd->quest_id; + WFIFOB(fd, 6) = qd->state; + WFIFOL(fd, 7) = qd->count[0]; + WFIFOL(fd, 11) = qd->count[1]; + WFIFOL(fd, 15) = qd->count[2]; + WFIFOL(fd, 19) = qd->time; + WFIFOSET(fd, 23); + hookStop(); } diff --git a/src/emap/craft.c b/src/emap/craft.c index c85be7e..5b6c7d8 100644 --- a/src/emap/craft.c +++ b/src/emap/craft.c @@ -89,7 +89,7 @@ bool craft_checkstr(TBL_PC *sd, const char *craftstr) const char *slotstr = VECTOR_INDEX(craftdata->parts, index + 1); if (!slotstr || !*slotstr) continue; - struct strutil_data *slotdata = strutil_split(slotstr, ';', MAX_INVENTORY + 1); + struct strutil_data *slotdata = strutil_split(slotstr, ';', sd->status.inventorySize + 1); if (!slotdata) { strutil_free(slotdata); @@ -110,7 +110,7 @@ bool craft_checkstr(TBL_PC *sd, const char *craftstr) index = atoi(itemstr); amount = 1; } - if (index < 0 || index >= MAX_INVENTORY) + if (index < 0 || index >= sd->status.inventorySize) { // wrong item index strutil_free(slotdata); strutil_free(craftdata); @@ -137,7 +137,7 @@ bool craft_checkstr(TBL_PC *sd, const char *craftstr) } strutil_free(craftdata); - for (f = 0; f < MAX_INVENTORY; f ++) + for (f = 0; f < sd->status.inventorySize; f ++) { const int amount = amounts[f]; if (!amount) @@ -152,9 +152,9 @@ bool craft_checkstr(TBL_PC *sd, const char *craftstr) return true; } -struct craft_vardata *craft_str_to_craft(const char *craftstr) +struct craft_vardata *craft_str_to_craft(TBL_PC *sd, const char *craftstr) { - if (!craftstr) + if (!sd || !craftstr) return false; struct strutil_data *craftdata = strutil_split(craftstr, '|', craft_inventory_size + 1); if (!craftdata) @@ -176,7 +176,7 @@ struct craft_vardata *craft_str_to_craft(const char *craftstr) const char *slotstr = VECTOR_INDEX(craftdata->parts, index + 1); if (!slotstr || !*slotstr) continue; - struct strutil_data *slotdata = strutil_split(slotstr, ';', MAX_INVENTORY + 1); + struct strutil_data *slotdata = strutil_split(slotstr, ';', sd->status.inventorySize + 1); if (!slotdata) { strutil_free(slotdata); @@ -199,7 +199,7 @@ struct craft_vardata *craft_str_to_craft(const char *craftstr) amount = 1; } if (index < 0 || - index >= MAX_INVENTORY) + index >= sd->status.inventorySize) { // wrong item index strutil_free(slotdata); strutil_free(craftdata); @@ -227,7 +227,7 @@ int str_to_craftvar(TBL_PC *sd, const char *craftstr) return -1; } - struct craft_vardata *craft = craft_str_to_craft(craftstr); + struct craft_vardata *craft = craft_str_to_craft(sd, craftstr); if (!craft) return -1; craft_counter ++; @@ -259,7 +259,7 @@ void craft_dump(TBL_PC *sd, const int id) struct item_pair *pair = &VECTOR_INDEX(crslot->items, slot); const int invIndex = pair->index; if (invIndex >= 0 && - invIndex < MAX_INVENTORY && + invIndex < sd->status.inventorySize && sd->status.inventory[invIndex].nameid) { const int item_id = sd->status.inventory[invIndex].nameid; @@ -340,7 +340,7 @@ bool craft_validate(TBL_PC *sd, const int id) struct item_pair *pair = &VECTOR_INDEX(crslot->items, slot); const int invIndex = pair->index; if (invIndex < 0 || - invIndex >= MAX_INVENTORY || + invIndex >= sd->status.inventorySize || !sd->status.inventory[invIndex].nameid || sd->status.inventory[invIndex].amount <= 0 || sd->status.inventory[invIndex].equip > 0) @@ -350,7 +350,7 @@ bool craft_validate(TBL_PC *sd, const int id) amounts[invIndex] += pair->amount; } } - for (f = 0; f < MAX_INVENTORY; f ++) + for (f = 0; f < sd->status.inventorySize; f ++) { const int amount = amounts[f]; if (!amount) @@ -372,7 +372,7 @@ static int find_inventory_item(TBL_PC *sd, int i; if (!sd) return -1; - for (i = 0; i < MAX_INVENTORY; i++) + for (i = 0; i < sd->status.inventorySize; i++) { if (sd->status.inventory[i].nameid == id && sd->status.inventory[i].amount >= amount && @@ -390,7 +390,7 @@ static int find_inventory_equipped_item(TBL_PC *sd, int i; if (!sd) return -1; - for (i = 0; i < MAX_INVENTORY; i++) + for (i = 0; i < sd->status.inventorySize; i++) { if (sd->status.inventory[i].nameid == id && sd->status.inventory[i].amount > 0 && @@ -402,13 +402,14 @@ static int find_inventory_equipped_item(TBL_PC *sd, return -1; } -static int find_local_inventory_item(struct item_pair *local_inventory, +static int find_local_inventory_item(TBL_PC *sd, + struct item_pair *local_inventory, const int id) { int i; - if (!local_inventory) + if (!sd || !local_inventory) return -1; - for (i = 0; i < MAX_INVENTORY; i++) + for (i = 0; i < sd->status.inventorySize; i++) { struct item_pair *pair = &local_inventory[i]; if (pair->index == id && @@ -420,13 +421,14 @@ static int find_local_inventory_item(struct item_pair *local_inventory, return -1; } -static bool check_items_collection(struct item_pair *local_inventory, +static bool check_items_collection(TBL_PC *sd, + struct item_pair *local_inventory, struct craft_items_collection *vector) { + if (!sd || !local_inventory) + return false; int len = VECTOR_LENGTH(*vector); int i; - if (!local_inventory) - return false; if (len > 0) { for (i = 0; i < len; i ++) @@ -435,7 +437,8 @@ static bool check_items_collection(struct item_pair *local_inventory, int needAmount = itemPair->amount; while (needAmount > 0) { - const int index = find_local_inventory_item(local_inventory, + const int index = find_local_inventory_item(sd, + local_inventory, itemPair->index); if (index < 0) return false; @@ -595,7 +598,7 @@ static void init_inventory_copy(TBL_PC *sd, int f; if (!sd || !local_inventory) return; - for (f = 0; f < MAX_INVENTORY; f ++) + for (f = 0; f < sd->status.inventorySize; f ++) { const int id = sd->status.inventory[f].nameid; const int amount = sd->status.inventory[f].amount; @@ -687,10 +690,10 @@ static int craft_get_recipe(TBL_PC *sd, if (!apply_craft_inventory(entry->selected_inventory, craft, &temp_inventory[0])) continue; //ShowInfo("apply craft correct\n"); - if (!check_items_collection(&temp_inventory[0], &entry->delete_items)) + if (!check_items_collection(sd, &temp_inventory[0], &entry->delete_items)) continue; //ShowInfo("delete_items correct\n"); - if (!check_items_collection(&temp_inventory[0], &entry->required_items)) + if (!check_items_collection(sd, &temp_inventory[0], &entry->required_items)) continue; //ShowInfo("required_items correct\n"); if (!check_equips(sd, &entry->required_equips)) diff --git a/src/emap/craft.h b/src/emap/craft.h index 329dbb4..52fd62a 100644 --- a/src/emap/craft.h +++ b/src/emap/craft.h @@ -35,7 +35,7 @@ void do_init_craft(void); void do_final_craft(void); bool craft_checkstr(TBL_PC *sd, const char *craftstr); int str_to_craftvar(TBL_PC *sd, const char *craftstr); -struct craft_vardata *craft_str_to_craft(const char *craftstr); +struct craft_vardata *craft_str_to_craft(TBL_PC *sd, const char *craftstr); void craft_dump(TBL_PC *sd, const int id); void craft_delete(const int id); struct craft_slot *craft_get_slot(const int id, const int slot); diff --git a/src/emap/npc.c b/src/emap/npc.c index 0c0c61e..5b6d66a 100644 --- a/src/emap/npc.c +++ b/src/emap/npc.c @@ -104,6 +104,13 @@ int enpc_buysellsel_pre(TBL_PC **sdPtr, hookStop(); return 0; } + else if (nd->u.scr.shop->type == NST_BARTER) + { + clif->npc_barter_open(sd, nd); + sd->npc_shopid = nd->bl.id; + hookStop(); + return 0; + } else if (nd->u.scr.shop->type == NST_CUSTOM) { clif->cashshop_show(sd, nd); diff --git a/src/emap/parse.c b/src/emap/parse.c index 299772e..833fe9c 100644 --- a/src/emap/parse.c +++ b/src/emap/parse.c @@ -239,7 +239,7 @@ void map_clif_parse_useitem2(int fd) // Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex] pc->update_idle_time(sd, BCIDLE_USEITEM); const int n = RFIFOW(fd, 2) - 2; - if (n < 0 || n >= MAX_INVENTORY) + if (n < 0 || n >= sd->status.inventorySize) return; struct item_data *item = itemdb->exists(sd->inventory_data[n]->nameid); diff --git a/src/emap/pc.c b/src/emap/pc.c index cd8ef2f..9149e1e 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -286,7 +286,7 @@ int epc_isequip_post(int retVal, if (!sd) return 0; - if (n < 0 || n >= MAX_INVENTORY) + if (n < 0 || n >= sd->status.inventorySize) return 0; struct ItemdExt *data = itemd_get(sd->inventory_data[n]); @@ -322,7 +322,7 @@ int epc_useitem_post(int retVal, if (!sd) return retVal; - if (n < 0 || n >= MAX_INVENTORY) + if (n < 0 || n >= sd->status.inventorySize) return retVal; struct ItemdExt *data = itemd_get(sd->inventory_data[n]); @@ -343,7 +343,7 @@ static void equippost_effect(struct map_session_data *const sd, if (!sd) return; - if (n < 0 || n >= MAX_INVENTORY) + if (n < 0 || n >= sd->status.inventorySize) return; struct ItemdExt *data = itemd_get(sd->inventory_data[n]); @@ -526,7 +526,7 @@ int epc_dropitem_pre(struct map_session_data **sdPtr, { struct map_session_data *sd = *sdPtr; const int n = *nPtr; - if (!sd || n < 0 || n >= MAX_INVENTORY) + if (!sd || n < 0 || n >= sd->status.inventorySize) { tempN = 0; tempId = 0; @@ -612,9 +612,9 @@ int epc_insert_card_pre(struct map_session_data **sdPtr, struct map_session_data *sd = *sdPtr; if (!sd || *idx_equip < 0 || - *idx_equip >= MAX_INVENTORY || + *idx_equip >= sd->status.inventorySize || *idx_card < 0 || - *idx_card >= MAX_INVENTORY) + *idx_card >= sd->status.inventorySize) { tempN = 0; tempId = 0; diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 78b9ac6..e1c9123 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1710,7 +1710,7 @@ BUILDIN(getInvIndexLink) int index = script_getnum (st, 2); - if (index < 0 || index >= MAX_INVENTORY) + if (index < 0 || index >= MAX_INVENTORY || (sd && index >= sd->status.inventorySize)) { script_pushstr(st, ""); return false; diff --git a/src/emap/scriptdefines.h b/src/emap/scriptdefines.h index 69c69b0..b70bec4 100644 --- a/src/emap/scriptdefines.h +++ b/src/emap/scriptdefines.h @@ -106,7 +106,7 @@ #define getInventoryIndex(idx) \ const int n = script_getnum(st, idx); \ - if (n < 0 || n >= MAX_INVENTORY) \ + if (n < 0 || n >= sd->status.inventorySize) \ { \ ShowWarning("Wrong inventory index\n"); \ script->reportsrc(st); \ diff --git a/src/emap/status.c b/src/emap/status.c index f782057..636a620 100644 --- a/src/emap/status.c +++ b/src/emap/status.c @@ -118,7 +118,7 @@ void estatus_calc_pc_additional_pre(struct map_session_data **sdPtr, return; } - for (f = 0; f < MAX_INVENTORY; f ++) + for (f = 0; f < sd->status.inventorySize; f ++) { struct item_data *const item = sd->inventory_data[f]; if (!item) |