diff options
author | Andrei Karas <akaras@inbox.ru> | 2019-01-23 21:38:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2019-01-23 21:38:21 +0300 |
commit | 3c0e3838f77a62a69130d7b2674e21e2133a7f83 (patch) | |
tree | 6f3ff1583e69e5ded625af59a78cbd5568acef51 | |
parent | 637fcbc9c0f4b042b38f9e900d08aee521305991 (diff) | |
download | evol-hercules-3c0e3838f77a62a69130d7b2674e21e2133a7f83.tar.gz evol-hercules-3c0e3838f77a62a69130d7b2674e21e2133a7f83.tar.bz2 evol-hercules-3c0e3838f77a62a69130d7b2674e21e2133a7f83.tar.xz evol-hercules-3c0e3838f77a62a69130d7b2674e21e2133a7f83.zip |
Update from hercules
-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/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 |
11 files changed, 48 insertions, 37 deletions
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/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) |