Jump to content
  • 0
Brynner

advance item check

Question

this source is from rAthena. when i try to patch it on hercules i got a warnings.

 

Index: conf/battle/items.conf===================================================================--- conf/battle/items.conf	(revision 17269)+++ conf/battle/items.conf	(working copy)@@ -51,12 +51,16 @@ // NOTE: Wedding Rings and Whips/Musical Instruments will check gender regardless of setting. ignore_items_gender: yes -// Item check? (Note 1)+// Item check? (Note 3) // On map change it will check for items not tagged as "available" and -// auto-delete them from inventory/cart.+// auto-delete them from inventory/cart. Items are auto-deleted from+// storage when the character data is saved. // NOTE: An item is not available if it was not loaded from the item_db or you  // specify it as unavailable in db/item_avail.txt-item_check: no+// 1: Inventory+// 2: Cart+// 4: Storage+item_check: 0  // How much time must pass between item uses? // Only affects the delay between using items, prevents healing item abuse. Recommended ~500 msIndex: conf/msg_conf/map_msg.conf===================================================================--- conf/msg_conf/map_msg.conf	(revision 17269)+++ conf/msg_conf/map_msg.conf	(working copy)@@ -635,7 +635,9 @@ 678: You are no longer the Guild Master. 679: You have become the Guild Master! 680: You have been recovered!-//681-899 free+681: Item %d has been removed from your inventory.+682: Item %d has been removed from your cart.+//683-899 free  681: Rune Knight T 682: Warlock TIndex: src/map/battle.c===================================================================--- src/map/battle.c	(revision 17269)+++ src/map/battle.c	(working copy)@@ -5668,7 +5668,7 @@ 	{ "max_heal_lv",                        &battle_config.max_heal_lv,                     11,     1,      INT_MAX,        }, 	{ "max_heal",                           &battle_config.max_heal,                        9999,   0,      INT_MAX,        }, 	{ "combo_delay_rate",                   &battle_config.combo_delay_rate,                100,    0,      INT_MAX,        },-	{ "item_check",                         &battle_config.item_check,                      0,      0,      1,              },+	{ "item_check",                         &battle_config.item_check,                      0,      0,      7,              }, 	{ "item_use_interval",                  &battle_config.item_use_interval,               100,    0,      INT_MAX,        }, 	{ "cashfood_use_interval",              &battle_config.cashfood_use_interval,           60000,  0,      INT_MAX,        }, 	{ "wedding_modifydisplay",              &battle_config.wedding_modifydisplay,           0,      0,      1,              },Index: src/map/chrif.c===================================================================--- src/map/chrif.c	(revision 17269)+++ src/map/chrif.c	(working copy)@@ -26,6 +26,7 @@ #include "chrif.h" #include "quest.h" #include "storage.h"+#include "itemdb.h"  #include <stdio.h> #include <stdlib.h>@@ -284,6 +285,8 @@ 	chrif_check(-1); //Character is saved on reconnect.  	//For data sync+	itemdb_check(sd, 4); // Check for invalid(ated) items in storage.+ 	if (sd->state.storage_flag == 2) 		storage_guild_storagesave(sd->status.account_id, sd->status.guild_id, flag); Index: src/map/clif.c===================================================================--- src/map/clif.c	(revision 17269)+++ src/map/clif.c	(working copy)@@ -14313,7 +14313,7 @@ 		return; 	} -	if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) )+	if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && itemdb_available(sd->status.inventory[idx].nameid) && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) ) 	{ // Consumable or pets are not allowed 		clif_Auction_setitem(sd->fd, idx, true); 		return;Index: src/map/itemdb.c===================================================================--- src/map/itemdb.c	(revision 17269)+++ src/map/itemdb.c	(working copy)@@ -13,6 +13,7 @@ #include "cashshop.h" #include "script.h" // item script processing #include "pc.h"     // W_MUSICAL, W_WHIP+#include "storage.h"  #include <stdio.h> #include <stdlib.h>@@ -182,6 +183,55 @@ 	return item; } +/*==========================================+ * Checks for unavailable items and removes them.+ *------------------------------------------*/+void itemdb_check(struct map_session_data *sd, int flag)+{+	int i, id;+	char output[256];++	if( battle_config.item_check&(flag&1) ) { // Check for invalid(ated) items in inventory.+		for( i = 0; i < MAX_INVENTORY; i++ ) {+			id = sd->status.inventory[i].nameid;++			if( id && !itemdb_available(id) ) {+				sprintf(output, msg_txt(sd, 681), id);+				clif_displaymessage(sd->fd, output);+				ShowWarning("Removed invalid/disabled item id %d from inventory (amount=%d, char_id=%d).n", id, sd->status.inventory[i].amount, sd->status.char_id);+				pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);+			}+		}+	}++	if( battle_config.item_check&(flag&2) ) { // Check for invalid(ated) items in cart.+		for( i = 0; i < MAX_CART; i++ ) {+			id = sd->status.cart[i].nameid;++			if( id && !itemdb_available(id) ) {+				sprintf(output, msg_txt(sd, 682), id);+				clif_displaymessage(sd->fd, output);+				ShowWarning("Removed invalid/disabled item id %d from cart (amount=%d, char_id=%d).n", id, sd->status.cart[i].amount, sd->status.char_id);+				pc_cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER);+			}+		}+	}++	if( battle_config.item_check&(flag&4) ) { // Check for invalid(ated) items in storage.+		if( !storage_storageopen(sd) ) {+			for( i = 0; i < MAX_STORAGE; i++ ) {+				id = sd->status.storage.items[i].nameid;++				if( id && !itemdb_available(id) ) {+					ShowWarning("Removed invalid/disabled item id %d from storage (amount=%d, char_id=%d).n", id, sd->status.storage.items[i].amount, sd->status.char_id);+					storage_delitem(sd, i, sd->status.storage.items[i].amount);+				}+			}+			storage_storageclose(sd);+		}+	}+}+ /// Returns human readable name for given item type. /// @param type Type id to retrieve name for ( IT_* ). const char* itemdb_typename(int type)Index: src/map/itemdb.h===================================================================--- src/map/itemdb.h	(revision 17269)+++ src/map/itemdb.h	(working copy)@@ -162,6 +162,7 @@ struct item_data* itemdb_load(int nameid); struct item_data* itemdb_search(int nameid); struct item_data* itemdb_exists(int nameid);+void itemdb_check(struct map_session_data *sd, int flag); #define itemdb_name(n) itemdb_search(n)->name #define itemdb_jname(n) itemdb_search(n)->jname #define itemdb_type(n) itemdb_search(n)->typeIndex: src/map/mail.c===================================================================--- src/map/mail.c	(revision 17269)+++ src/map/mail.c	(working copy)@@ -78,7 +78,7 @@ 			return 1; 		if( amount < 0 || amount > sd->status.inventory[idx].amount ) 			return 1;-		if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||+		if( !pc_can_give_items(sd) || !itemdb_available(sd->status.inventory[idx].nameid) || sd->status.inventory[idx].expire_time || 				!itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd)) ) 			return 1; Index: src/map/pc.c===================================================================--- src/map/pc.c	(revision 17269)+++ src/map/pc.c	(working copy)@@ -8850,33 +8850,15 @@  *------------------------------------------*/ int pc_checkitem(struct map_session_data *sd) {-	int i,id,calc_flag = 0;+	int i,calc_flag = 0;  	nullpo_ret(sd);  	if( sd->state.vending ) //Avoid reorganizing items when we are vending, as that leads to exploits (pointed out by End of Exam) 		return 0; -	if( battle_config.item_check ) {// check for invalid(ated) items-		for( i = 0; i < MAX_INVENTORY; i++ ) {-			id = sd->status.inventory[i].nameid;+	itemdb_check(sd, 3); // Check for invalid(ated) items in inventory/cart. -			if( id && !itemdb_available(id) ) {-				ShowWarning("Removed invalid/disabled item id %d from inventory (amount=%d, char_id=%d).n", id, sd->status.inventory[i].amount, sd->status.char_id);-				pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);-			}-		}--		for( i = 0; i < MAX_CART; i++ ) {-			id = sd->status.cart[i].nameid;--			if( id && !itemdb_available(id) ) {-				ShowWarning("Removed invalid/disabled item id %d from cart (amount=%d, char_id=%d).n", id, sd->status.cart[i].amount, sd->status.char_id);-				pc_cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER);-			}-		}-	}- 	for( i = 0; i < MAX_INVENTORY; i++) {  		if( sd->status.inventory[i].nameid == 0 )

 

warnings that i got.

1>d:herculessrcmapitemdb.c(196) : warning C4047: 'function' : 'int' differs in levels of indirection from 'map_session_data *'1>d:herculessrcmapitemdb.c(196) : warning C4024: 'msg_txt' : different types for formal and actual parameter 11>d:herculessrcmapitemdb.c(196) : warning C4020: 'msg_txt' : too many actual parameters1>d:herculessrcmapitemdb.c(209) : warning C4047: 'function' : 'int' differs in levels of indirection from 'map_session_data *'1>d:herculessrcmapitemdb.c(209) : warning C4024: 'msg_txt' : different types for formal and actual parameter 11>d:herculessrcmapitemdb.c(209) : warning C4020: 'msg_txt' : too many actual parameters

 

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

You can't patch rAthena diffs into Hercules so easily. Hercules' Source has gone through some major overhauling and to simply put it in real terms, you can't patch diffs that were made for rAthena automatically towards Hercules. You would need to change the diff a little bit to fit Hercules' source code since Hercules and rAthena has a different source structure.

Share this post


Link to post
Share on other sites
  • 0

You can't patch rAthena diffs into Hercules so easily. Hercules' Source has gone through some major overhauling and to simply put it in real terms, you can't patch diffs that were made for rAthena automatically towards Hercules. You would need to change the diff a little bit to fit Hercules' source code since Hercules and rAthena has a different source structure.

 

that's why i post it here sir to ask for some support.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.