فهرست منبع

Storage optimization clean ups
* Cleaned up some of the script command documentation.
* Adjusted some checks to use constants.

aleos89 8 سال پیش
والد
کامیت
7ffb943343
2فایلهای تغییر یافته به همراه32 افزوده شده و 32 حذف شده
  1. 4 4
      doc/script_commands.txt
  2. 28 28
      src/map/script.c

+ 4 - 4
doc/script_commands.txt

@@ -4608,7 +4608,7 @@ database. If the name is not found, nothing will be deleted.
 *guildstoragedelitem "<item name>",<amount>{,<account ID>};
 
 This command behaves identically to 'delitem', but deletes items from the player's
-cart or storage.
+cart, storage, or guild storage.
 
 If no cart is mounted, 'cartdelitem' will return -1.
 If player is not in a guild or storage is open, 'guildstoragedelitem' will return -1.
@@ -4631,7 +4631,7 @@ See 'getitem2' for an explanation of the expanded parameters.
 *guildstoragedelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
 
 This command behaves identically to 'delitem2', but deletes items from the player's
-cart or storage.
+cart, storage, or guild storage.
 
 If no cart is mounted, 'cartdelitem2' will return -1.
 If player is not in a guild or storage is open, 'guildstoragedelitem2' will return -1.
@@ -4668,7 +4668,7 @@ adding up strings:
 *guildstoragecountitem("<item name>"{,<accountID>})
 
 This command behaves identically to 'countitem', but counts items from the player's
-cart, storage or guild storage.
+cart, storage, or guild storage.
 
 If no cart is mounted, 'cartcountitem' will return -1.
 If player is not in a guild or storage is open, 'guildstoragecountitem' will return -1.
@@ -4694,7 +4694,7 @@ See 'getitem2' for an explanation of the expanded parameters.
 *guildstoragecountitem2("<item name>",<Identified>,<Refine>,<Attribute>,<Card0>,<Card1>,<Card2>,<Card3>{,<accountID>})
 
 This command behaves identically to 'countitem2', but counts items from the player's
-cart, storage or guild storage.
+cart, storage, or guild storage.
 
 If no cart is mounted, 'cartcountitem2' will return -1.
 If player is not in a guild or storage is open, 'guildstoragecountitem2' will return -1.

+ 28 - 28
src/map/script.c

@@ -6522,12 +6522,12 @@ BUILDIN_FUNC(countitem)
 	}
 	
 	if( !strncmp(command, "cart", 4) ) {
-		loc = 1;
+		loc = TABLE_CART;
 		size = MAX_CART;
 		items = sd->cart.u.items_cart;
 	}
 	else if( !strncmp(command, "storage", 7) ) {
-		loc = 2;
+		loc = TABLE_STORAGE;
 		size = MAX_STORAGE;
 		items = sd->storage.u.items_storage;
 	}
@@ -6535,7 +6535,7 @@ BUILDIN_FUNC(countitem)
 		gstor = guild2storage2(sd->status.guild_id);
 
 		if (gstor && !sd->state.storage_flag) {
-			loc = 3;
+			loc = TABLE_GUILD_STORAGE;
 			size = MAX_GUILD_STORAGE;
 			items = gstor->u.items_guild;
 		} else {
@@ -6548,7 +6548,7 @@ BUILDIN_FUNC(countitem)
 		items = sd->inventory.u.items_inventory;
 	}
 
-	if( loc == 1 && !pc_iscarton(sd) ) {
+	if( loc == TABLE_CART && !pc_iscarton(sd) ) {
 		ShowError("buildin_%s: Player doesn't have cart (CID:%d).\n", command, sd->status.char_id);
 		script_pushint(st,-1);
 		return SCRIPT_CMD_SUCCESS;
@@ -6568,7 +6568,7 @@ BUILDIN_FUNC(countitem)
 		return SCRIPT_CMD_FAILURE;
 	}
 
-	if (loc == 3)
+	if (loc == TABLE_GUILD_STORAGE)
 		gstor->lock = true;
 
 	if( !i ) { // For count/cart/storagecountitem function
@@ -6601,7 +6601,7 @@ BUILDIN_FUNC(countitem)
 			}
 	}
 
-	if (loc == 3) {
+	if (loc == TABLE_GUILD_STORAGE) {
 		storage_guild_storageclose(sd);
 		gstor->lock = false;
 	}
@@ -7380,20 +7380,20 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
 	struct s_storage *gstor = NULL;
 
 	switch(loc) {
-		case 1:	// cart
+		case TABLE_CART:
 			itm = &sd->cart.u.items_cart[idx];
 			break;
-		case 2:	// storage
+		case TABLE_STORAGE:
 			itm = &sd->storage.u.items_storage[idx];
 			break;
-		case 3: // guild storage
+		case TABLE_GUILD_STORAGE:
 		{
 			gstor = guild2storage2(sd->status.guild_id);
 
 			itm = &gstor->u.items_guild[idx];
 		}
 			break;
-		default:	//inventory
+		default: // TABLE_INVENTORY
 			itm = &sd->inventory.u.items_inventory[idx];
 			break;
 	}
@@ -7407,21 +7407,21 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
 			intif_delete_petdata(MakeDWord(itm->card[1], itm->card[2]));
 		}
 		switch(loc) {
-			case 1:
+			case TABLE_CART:
 				pc_cart_delitem(sd,idx,delamount,0,LOG_TYPE_SCRIPT);
 				break;
-			case 2:
+			case TABLE_STORAGE:
 				storage_delitem(sd,idx,delamount);
 				log_pick_pc(sd,LOG_TYPE_SCRIPT,-delamount,itm);
 				break;
-			case 3:
+			case TABLE_GUILD_STORAGE:
 				gstor->lock = true;
 				storage_guild_delitem(sd, gstor, idx, delamount);
 				log_pick_pc(sd, LOG_TYPE_SCRIPT, -delamount, itm);
 				storage_guild_storageclose(sd);
 				gstor->lock = false;
 				break;
-			default:
+			default: // TABLE_INVENTORY
 				pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
 				break;
 		}
@@ -7455,15 +7455,15 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
 	}
 
 	switch(loc) {
-		case 1:	// cart
+		case TABLE_CART:
 			size = MAX_CART;
 			items = sd->cart.u.items_cart;
 			break;
-		case 2:	// storage
+		case TABLE_STORAGE:
 			size = MAX_STORAGE;
 			items = sd->storage.u.items_storage;
 			break;
-		case 3: // guild storage
+		case TABLE_GUILD_STORAGE:
 		{
 			struct s_storage *gstor = guild2storage2(sd->status.guild_id);
 
@@ -7471,7 +7471,7 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
 			items = gstor->u.items_guild;
 		}
 			break;
-		default:	//inventory
+		default: // TABLE_INVENTORY
 			size = MAX_INVENTORY;
 			items = sd->inventory.u.items_inventory;
 			break;
@@ -7592,11 +7592,11 @@ BUILDIN_FUNC(delitem)
 	char* command = (char*)script_getfuncname(st);
 
 	if(!strncmp(command, "cart", 4))
-		loc = 1;
+		loc = TABLE_CART;
 	else if(!strncmp(command, "storage", 7))
-		loc = 2;
+		loc = TABLE_STORAGE;
 	else if(!strncmp(command, "guildstorage", 12))
-		loc = 3;
+		loc = TABLE_GUILD_STORAGE;
 
 	if( script_hasdata(st,4) )
 	{
@@ -7616,12 +7616,12 @@ BUILDIN_FUNC(delitem)
 			return SCRIPT_CMD_SUCCESS;
 	}
 
-	if (loc == 1 && !pc_iscarton(sd)) {
+	if (loc == TABLE_CART && !pc_iscarton(sd)) {
 		ShowError("buildin_cartdelitem: player doesn't have cart (CID=%d).\n", sd->status.char_id);
 		script_pushint(st, -1);
 		return SCRIPT_CMD_FAILURE;
 	}
-	if (loc == 3) {
+	if (loc == TABLE_GUILD_STORAGE) {
 		struct s_storage *gstor = guild2storage2(sd->status.guild_id);
 
 		if (gstor == NULL || sd->state.storage_flag) {
@@ -7691,11 +7691,11 @@ BUILDIN_FUNC(delitem2)
 	char* command = (char*)script_getfuncname(st);
 
 	if(!strncmp(command, "cart", 4))
-		loc = 1;
+		loc = TABLE_CART;
 	else if(!strncmp(command, "storage", 7))
-		loc = 2;
+		loc = TABLE_STORAGE;
 	else if(!strncmp(command, "guildstorage", 12))
-		loc = 3;
+		loc = TABLE_GUILD_STORAGE;
 
 	if( script_hasdata(st,11) )
 	{
@@ -7715,12 +7715,12 @@ BUILDIN_FUNC(delitem2)
 			return SCRIPT_CMD_SUCCESS;
 	}
 
-	if (loc == 1 && !pc_iscarton(sd)) {
+	if (loc == TABLE_CART && !pc_iscarton(sd)) {
 		ShowError("buildin_cartdelitem: player doesn't have cart (CID=%d).\n", sd->status.char_id);
 		script_pushint(st,-1);
 		return SCRIPT_CMD_FAILURE;
 	}
-	if (loc == 3) {
+	if (loc == TABLE_GUILD_STORAGE) {
 		struct s_storage *gstor = guild2storage2(sd->status.guild_id);
 
 		if (gstor == NULL || sd->state.storage_flag) {