Browse Source

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
Lemongrass3110 8 years ago
parent
commit
800714abfe
4 changed files with 14 additions and 22 deletions
  1. 0 1
      src/char/char.c
  2. 3 12
      src/char/int_storage.c
  3. 10 8
      src/map/intif.c
  4. 1 1
      src/map/skill.c

+ 0 - 1
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;

+ 3 - 12
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);

+ 10 - 8
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:

+ 1 - 1
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);
 			}