From 800714abfe7b6e665d6997c314fc26a0ae519a7f Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Thu, 13 Oct 2016 23:53:34 +0200 Subject: [PATCH] Reverted a lot of e8f4500 Wasted 11 bytes of network traffic to keep the code clean. Process: 1) A player tries to open a vending store and is now in the pre-vend state. 2) If all items in the cart are saved then he can proceed to opening the store. 3) If not a request to save the cart data is sent to the inter server. 4) If the acknowledgment packet from the inter server is received then check if the player is still online and in pre-vend state and open the vending dialog --- src/char/char.c | 1 - src/char/int_storage.c | 15 +++------------ src/map/intif.c | 18 ++++++++++-------- src/map/skill.c | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/char/char.c b/src/char/char.c index 923a8b3f34..f0354d07eb 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -531,7 +531,6 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl selectoption = "char_id"; break; case TABLE_CART: - case TABLE_CART_: tablename = schema_config.cart_db; selectoption = "char_id"; break; diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 216638e96c..e33d5c1676 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -687,12 +687,6 @@ void mapif_storage_saved(int fd, uint32 account_id, uint32 char_id, bool sucess, WFIFOB(fd, 6) = sucess; WFIFOB(fd, 7) = type; WFIFOSET(fd,8); - - if (type == TABLE_CART_) { - struct s_storage stor; - memset(&stor, 0, sizeof(struct s_storage)); - mapif_storage_data_loaded(fd, account_id, type, stor, cart_fromsql(char_id, &stor)); - } } /** @@ -743,12 +737,9 @@ bool mapif_parse_StorageSave(int fd) { //ShowInfo("Saving storage data for AID=%d.\n", aid); switch(type){ - case TABLE_INVENTORY: inventory_tosql(cid, &stor); break; - case TABLE_STORAGE: storage_tosql(aid, &stor); break; - case TABLE_CART: - case TABLE_CART_: - cart_tosql(cid, &stor); - break; + case TABLE_INVENTORY: inventory_tosql(cid, &stor); break; + case TABLE_STORAGE: storage_tosql(aid, &stor); break; + case TABLE_CART: cart_tosql(cid, &stor); break; default: return false; } mapif_storage_saved(fd, aid, cid, true, type); diff --git a/src/map/intif.c b/src/map/intif.c index 92f69aea93..81ee6f9164 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -3163,7 +3163,6 @@ static bool intif_parse_StorageReceived(int fd) case TABLE_INVENTORY: stor = &sd->inventory; break; case TABLE_STORAGE: stor = &sd->storage; break; case TABLE_CART: - case TABLE_CART_: stor = &sd->cart; break; default: return false; @@ -3216,13 +3215,11 @@ static bool intif_parse_StorageReceived(int fd) if (sd->state.autotrade) { clif_parse_LoadEndAck(sd->fd, sd); sd->autotrade_tid = add_timer(gettick() + battle_config.feature_autotrade_open_delay, pc_autotrade_timer, sd->bl.id, 0); + }else if( sd->state.prevend ){ + clif_openvendingreq(sd, sd->vend_skill_lv+2); } break; - case TABLE_CART_: - clif_openvendingreq(sd, sd->vend_skill_lv+2); - break; - case TABLE_STORAGE: pc_check_available_item(sd, ITMCHK_STORAGE); break; @@ -3246,8 +3243,14 @@ static void intif_parse_StorageSaved(int fd) //ShowInfo("Storage has been saved (AID: %d).\n", RFIFOL(fd, 2)); break; case TABLE_CART: // cart - case TABLE_CART_: //ShowInfo("Cart has been saved (AID: %d).\n", RFIFOL(fd, 2)); + { + struct map_session_data *sd = map_id2sd(RFIFOL(fd, 2)); + + if( sd && sd->state.prevend ){ + intif_storage_request(sd,TABLE_CART); + } + } break; default: break; @@ -3301,8 +3304,7 @@ bool intif_storage_save(struct map_session_data *sd, enum storage_type type) case TABLE_STORAGE: stor = &sd->storage; break; - case TABLE_CART: - case TABLE_CART_: + case TABLE_CART: stor = &sd->cart; break; default: diff --git a/src/map/skill.c b/src/map/skill.c index 3cdf771088..2cc66b5f4f 100755 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -7319,7 +7319,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sd->vend_skill_lv = skill_lv; ARR_FIND(0, MAX_CART, i, sd->cart.u.items_cart[i].nameid && sd->cart.u.items_cart[i].id == 0); if (i < MAX_CART) - intif_storage_save(sd, TABLE_CART_); + intif_storage_save(sd, TABLE_CART); else clif_openvendingreq(sd,2+skill_lv); }