Brynner Posted April 14, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Share Posted April 14, 2013 // Item check? (Note 1) // On map change it will check for items not tagged as "available" and // auto-delete them from inventory/cart. // 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: yes is there any chances to include the storage on checking item? because the current item check works only on inventory and cart. but when the item is located on storage it will not included to check. which means the item that does not exist still on your storage unless you remove it inside your storage. Link to comment Share on other sites More sharing options...
Lemongrass Posted April 14, 2013 Group: Developer Topic Count: 28 Topics Per Day: 0.01 Content Count: 547 Reputation: 270 Joined: 11/08/11 Last Seen: June 10, 2024 Share Posted April 14, 2013 As it is right now there is not. But I agree that there should be such a thing for storage, guild storage, mail, cart and every other thing that allows item storage. Maybe this should be applied on character saving? What do you guys think? 1 Link to comment Share on other sites More sharing options...
Brynner Posted April 15, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 15, 2013 bump for this topic. Link to comment Share on other sites More sharing options...
Aleos Posted April 15, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 15, 2013 I agree. Cart and inventory aren't the only places items may be corrupted. The map-change part is fine since players stats are recalculated each time they change maps. 1 Link to comment Share on other sites More sharing options...
Lemongrass Posted April 15, 2013 Group: Developer Topic Count: 28 Topics Per Day: 0.01 Content Count: 547 Reputation: 270 Joined: 11/08/11 Last Seen: June 10, 2024 Share Posted April 15, 2013 I think its a little to CPU consuming if we add all those checks. Items dont get changed so often during runtime and even when it is enough to remove them on logout/relog etc since they arent useable anyway. 1 Link to comment Share on other sites More sharing options...
Brynner Posted April 16, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 16, 2013 any news regarding on this? Link to comment Share on other sites More sharing options...
Aleos Posted April 17, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 17, 2013 Here is what I had in mind. The battle config item_check is now a bit flag type so it can be set to check inventory, cart, or storage. I talked with Lighta and we both agreed guild storage isn't needed since it will end up in an inventory, cart, or storage and be removed from there. Item in storage are cleared out when chrif_save() is ran (on character logout). Rather than adding an itemdb_check() for mail and auction there we can just include another check to when mail and auctions are created to determine if the item is bad or not before inserting the item. If people agree with the change we can commit it. It's also open to more ideas! Link to comment Share on other sites More sharing options...
Brynner Posted April 17, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 17, 2013 Here is what I had in mind. The battle config item_check is now a bit flag type so it can be set to check inventory, cart, or storage. I talked with Lighta and we both agreed guild storage isn't needed since it will end up in an inventory, cart, or storage and be removed from there. Item in storage are cleared out when chrif_save() is ran (on character logout). Rather than adding an itemdb_check() for mail and auction there we can just include another check to when mail and auctions are created to determine if the item is bad or not before inserting the item. If people agree with the change we can commit it. It's also open to more ideas! wow finally thanks. but how can i enable all item check for inventory, cart and storage at the same time? // 1: Inventory // 2: Cart // 4: Storage item_check: 0 Link to comment Share on other sites More sharing options...
Aleos Posted April 17, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 17, 2013 It's a bit flag like I said, so 3 would be inventory and cart, 5 would be inventory and storage, 6 would be cart and storage, and 7 would be all. Link to comment Share on other sites More sharing options...
Brynner Posted April 18, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 18, 2013 there It's a bit flag like I said, so 3 would be inventory and cart, 5 would be inventory and storage, 6 would be cart and storage, and 7 would be all. there is a problem when i try to compile. 1>\src\map\pc.c(8860) : warning C4013: 'itemdb_check' undefined; assuming extern returning int1>\src\map\pc.c(8853) : warning C4101: 'id' : unreferenced local variable1>party.c1>npc_chat.c1>npc.c1>mob.c1>mercenary.c1>mapreg_sql.c1>map.c1>mail.c1>log.c1>itemdb.c1>intif.c1>\src\map\itemdb.c(195) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(197) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(197) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(198) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(198) : warning C4020: 'clif_displaymessage' : too many actual parameters1>\src\map\itemdb.c(199) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(207) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(209) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(209) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(210) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(210) : warning C4020: 'clif_displaymessage' : too many actual parameters1>\src\map\itemdb.c(211) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(219) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(221) : error C2065: 'id' : undeclared identifier1>\src\map\itemdb.c(221) : error C2065: 'id' : undeclared identifier Link to comment Share on other sites More sharing options...
Aleos Posted April 18, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 18, 2013 Sorry, forgot to declare the variable. Updated the original diff. Link to comment Share on other sites More sharing options...
Brynner Posted April 18, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 18, 2013 Sorry, forgot to declare the variable. Updated the original diff. still have a problem sir. 1>path.c 1>\src\map\pc.c(8860) : warning C4013: 'itemdb_check' undefined; assuming extern returning int 1>\src\map\pc.c(8853) : warning C4101: 'id' : unreferenced local variable 1>party.c 1>npc_chat.c 1>npc.c 1>mob.c 1>mercenary.c 1>mapreg_sql.c 1>map.c 1>mail.c 1>log.c 1>itemdb.c 1>intif.c 1>\src\map\itemdb.c(198) : warning C4020: 'clif_displaymessage' : too many actual parameters 1>\src\map\itemdb.c(210) : warning C4020: 'clif_displaymessage' : too many actual parameters 1>instance.c 1>homunculus.c 1>guild.c 1>elemental.c 1>duel.c 1>date.c 1>clif.c 1>chrif.c 1>\src\map\chrif.c(288) : warning C4013: 'itemdb_check' undefined; assuming extern returning int 1>\src\map\chrif.c(290) : error C2143: syntax error : missing ';' before 'if' 1>chat.c Link to comment Share on other sites More sharing options...
Aleos Posted April 18, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 18, 2013 Updated again. Thanks. Link to comment Share on other sites More sharing options...
Brynner Posted April 18, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 18, 2013 (edited) Updated again. Thanks. still not fix sir. 1>\src\map\itemdb.c(199) : error C2065: 'atcmd_output' : undeclared identifier 1>\src\map\itemdb.c(199) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int' 1>\src\map\itemdb.c(199) : warning C4024: 'sprintf' : different types for formal and actual parameter 1 1>\src\map\itemdb.c(200) : warning C4047: 'function' : 'const int' differs in levels of indirection from 'char [256]' 1>\src\map\itemdb.c(200) : warning C4024: 'clif_displaymessage' : different types for formal and actual parameter 1 1>\src\map\itemdb.c(200) : error C2198: 'clif_displaymessage' : too few arguments for call 1>\src\map\itemdb.c(212) : error C2065: 'atcmd_output' : undeclared identifier 1>\src\map\itemdb.c(212) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int' 1>\src\map\itemdb.c(212) : warning C4024: 'sprintf' : different types for formal and actual parameter 1 1>\src\map\itemdb.c(213) : warning C4047: 'function' : 'const int' differs in levels of indirection from 'char [256]' 1>\src\map\itemdb.c(213) : warning C4024: 'clif_displaymessage' : different types for formal and actual parameter 1 1>\src\map\itemdb.c(213) : error C2198: 'clif_displaymessage' : too few arguments for call Error 1 error C2065: 'atcmd_output' : undeclared identifier \src\map\itemdb.c 199 map-server_sql Error 6 error C2198: 'clif_displaymessage' : too few arguments for call \src\map\itemdb.c 200 map-server_sql Error 7 error C2065: 'atcmd_output' : undeclared identifier \src\map\itemdb.c 212 map-server_sql Error 12 error C2198: 'clif_displaymessage' : too few arguments for call \src\map\itemdb.c 213 map-server_sql line 199 and line 200 sprintf(atcmd_output, msg_txt(sd, 681), id); clif_displaymessage(output); line 212 and line 213 sprintf(atcmd_output, msg_txt(sd, 682), id); clif_displaymessage(output); alternative fix. merging your 2nd and 3rd diff. 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 ms Index: 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,10 @@ 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: Item %d has been removed from your storage. +//684-899 free 681: Rune Knight T 682: Warlock T Index: 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,51 @@ 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) ) { + clif_displaymessage(sd->fd, msg_txt(sd, 681), 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); + } + } + } + + 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) ) { + clif_displaymessage(sd->fd, msg_txt(sd, 682), 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); + } + } + } + + if( battle_config.item_check&(flag&4) ) { // Check for invalid(ated) items in storage. + for( i = 0; i < MAX_STORAGE; i++ ) { + id = sd->status.storage.items[i].nameid; + + if( id && !itemdb_available(id) ) { + clif_displaymessage(sd->fd, msg_txt(sd, 683), 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); + } + } + } +} + /// 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)->type Index: 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 ) but there is a bug. the item in the storage will became apple because it became unknown item and it will be moved to misc. -normal when you click close it became bug. the storage is not close and you will get display message Ranger T another bug. the deleted item from your storage, cart, inventory will not be displayed. Edited April 18, 2013 by Brynner Link to comment Share on other sites More sharing options...
Aleos Posted April 18, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 18, 2013 Sorry, it should be good now. I didn't have an IDE to test all the issues so I was just throwing it together from what I had in mind. Fixed the storage issue too. Link to comment Share on other sites More sharing options...
Brynner Posted April 18, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 18, 2013 Sorry, it should be good now. I didn't have an IDE to test all the issues so I was just throwing it together from what I had in mind. Fixed the storage issue too. ok sir i'll try it when i got home. if i find another bug or issue ill tell you again. Sorry, it should be good now. I didn't have an IDE to test all the issues so I was just throwing it together from what I had in mind. Fixed the storage issue too. there still a problem for your latest diff. Error 5 error C2084: function 'void itemdb_check(map_session_data *,int)' already has a body \src\map\itemdb.c 235 map-server_sql on line 235 { Link to comment Share on other sites More sharing options...
Aleos Posted April 19, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 19, 2013 Are you sure you ran a cleanup? I applied the diff to a clean svn and it compiled just fine. Link to comment Share on other sites More sharing options...
Brynner Posted April 19, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 19, 2013 Are you sure you ran a cleanup? I applied the diff to a clean svn and it compiled just fine. haha sorry i forgot that part. by the ways it's working now. Link to comment Share on other sites More sharing options...
Brynner Posted April 21, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 21, 2013 sir th Are you sure you ran a cleanup? I applied the diff to a clean svn and it compiled just fine. sir the code is now working. but i notice something. for example: i put apple on my cart, inventory and storage. then disable it on itemdb then @reloaditemdb then the item will be gone. try to character select. it will ask for pincode? pincode system will only ask when you login on your account on rAthena right? and i noticed that there is an error on char server. [Error]: parse_from_map (save-char): Received data for non-existant/offline char acter. i think it's a bug sir. Link to comment Share on other sites More sharing options...
Aleos Posted April 22, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted April 22, 2013 Ok. Thanks. I haven't really had time to test it but I'm going to clean it up and remove it from checking at every map change to save CPU memory. I'll look into it further when I get some free time. Link to comment Share on other sites More sharing options...
Brynner Posted April 22, 2013 Group: Members Topic Count: 120 Topics Per Day: 0.02 Content Count: 1960 Reputation: 202 Joined: 01/08/12 Last Seen: 4 hours ago Author Share Posted April 22, 2013 Ok. Thanks. I haven't really had time to test it but I'm going to clean it up and remove it from checking at every map change to save CPU memory. I'll look into it further when I get some free time. ok sir np. just inform me if you already had a update for this. Link to comment Share on other sites More sharing options...
Aleos Posted November 4, 2013 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted November 4, 2013 Completed in cdccf88. Link to comment Share on other sites More sharing options...
Recommended Posts