Index: sql-files/restock.sql =================================================================== --- sql-files/restock.sql (revision 0) +++ sql-files/restock.sql (revision 0) @@ -0,0 +1,29 @@ +-- -------------------------------------------------------- +-- restock systeme +-- +-- Table structure for table `restock` +-- + +CREATE TABLE IF NOT EXISTS `restock_lists` ( + `list_id` int(11) NOT NULL AUTO_INCREMENT, + `list_name` varchar(200) NOT NULL, + `char_id` int(11) NOT NULL, + PRIMARY KEY (`list_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `restock_items` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `list_id` int(11) NOT NULL, + `slot` int(11) NOT NULL DEFAULT '0', + `item_id` int(11) NOT NULL DEFAULT '0', + `item_nb` int(11) NOT NULL DEFAULT '0', + `identify` smallint(6) unsigned NOT NULL DEFAULT '0', + `refine` tinyint(3) unsigned NOT NULL DEFAULT '0', + `attribute` tinyint(4) unsigned NOT NULL DEFAULT '0', + `card0` smallint(11) NOT NULL DEFAULT '0', + `card1` smallint(11) NOT NULL DEFAULT '0', + `card2` smallint(11) NOT NULL DEFAULT '0', + `card3` smallint(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + Index: npc/gro_custom/restock.txt =================================================================== --- npc/gro_custom/restock.txt (revision 0) +++ npc/gro_custom/restock.txt (revision 0) @@ -0,0 +1,334 @@ +- script Restock#00 80,{ + +cutin "job_dancer_eir01",2; +L_menu : + classchange 4060,0; + set @charid,getcharid(0); + set @charname$,strcharinfo(0); + menu "Restock",L_restk, + "Voir son enregistrement",L_seelist, + "Enregistrer ses consommables",L_record, + "Supprimer un Slot",L_delslot, + "Changer de liste d'enregistrement",L_mdflist, + "Supprimer une liste d'enregistrement",L_dellist, + "Quittez",-; + cutin "",255; + close; +//end L_menu + +L_record: + query_sql "select count(*) from `"+$restock_tl$+"` where char_id="+@charid+"",.@count; + mes "[Restockeur]"; + mes "Bonjour "+@charname$+""; + if(.@count < 5) { + mes "Vous pouvez ici enregistrer vos items à restock !"; + mes "Il vous suffit de mettre les items en nombre voulut dans votre inventaire !"; + mes "Tout d'abord, veuillez entrer un nom pour votre liste :"; + mes "Attention vous avez le droit au maximum à 5 listes différentes !"; + next; + do { + set .@ok,callsub(S_new_list); + } while(.@ok==0); + next; + query_sql "insert into `"+$restock_tl$+"`(list_name,char_id) values('"+escape_sql(@newlist$)+"',"+@charid+");"; + query_sql "select list_id from `"+$restock_tl$+"` where list_name='"+escape_sql(@newlist$)+"' and char_id="+@charid,.@list_id; + set .@memook,callsub(S_memo_list,.@list_id); //attemp to save list + next; + mes "[Restockeur]"; + if(.@memook){ + set restock_lsel,.@list_id; + mes "Liste Enregistrée !"; + } + else { + query_sql "delete `"+$restock_tl$+"` where list_id='"+.@list_id; //remove if association failed + mes "Failed to memorize your list"; + } + } + else { + mes "Vous ne pouvez pas enregistrer de nouvelle liste, vous avez plus de 5 listes différentes !"; + } + next; + goto L_menu; +//end L_record + + +L_restk: + callsub S_countlist; + set .@query$,"select item_id,item_nb,refine,identify,attribute,card0,card1,card2,card3 from `"+$restock_ti$+"` where list_id="+restock_lsel; + debugmes .@query$; + query_sql .@query$,.@item_id[0],.@item_nb[0],.@item_ref[0],.@item_iden[0],.@item_att[0],.@item_c0[0],.@item_c1[0],.@item_c2[0],.@item_c3[0]; //that the query man ! + set .@nbitems,getarraysize(.@item_id); + debugmes ".@nbitems="+.@nbitems; + + for(set .@item_it,0; .@item_it<.@nbitems; set .@item_it, .@item_it+1){ + set .@item_id, .@item_id[.@item_it]; //current item for iteration + set .@list_nb, .@item_nb[.@item_it]; //list amount for item + + set .@ref,.@item_ref[.@item_it]; + set .@iden, .@item_iden[.@item_it]; + set .@att, .@item_att[.@item_it]; + set .@c0, .@item_c0[.@item_it]; + set .@c1, .@item_c1[.@item_it]; + set .@c2, .@item_c2[.@item_it]; + set .@c3, .@item_c3[.@item_it]; + set .@inv_nb, countitem2(.@item_id,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3); //inventory amount for item + debugmes "item_id="+.@item_id+" .@list_nb="+.@list_nb+" .@inv_nb="+.@inv_nb; + if (.@inv_nb > .@list_nb) { //put extra in storage + set .@diff_it, .@inv_nb - .@list_nb; + set .@ok,inv2stor(.@item_id,.@diff_it,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3); + debugmes "storeitem id="+.@item_id+" amount="+.@diff_it+" .@ok="+.@ok; + } + else if (.@inv_nb < .@list_nb) { //try to retrive diff from storage + set .@diff_it, .@list_nb - .@inv_nb; + set .@stor_nb,countstorageitem(0,.@item_id,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3); + debugmes ".@diff_it="+.@diff_it+" .@stor_nb="+.@stor_nb; + if(.@stor_nb >= .@diff_it){ + set .@ok,stor2inv(.@item_id,.@diff_it,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3); + debugmes "retriveitem id="+.@item_id+" amount="+.@diff_it+" .@ok="+.@ok; + } + else { + dispbottom "You don't have enough item="+.@item_id+"in storage, retirving rest"; + set .@ok,stor2inv(.@item_id,.@stor_nb,.@iden,.@ref,.@att,.@c0,.@c1,.@c2,.@c3); + debugmes "retriveitem id="+.@item_id+" restamount="+.@stor_nb+" .@ok="+.@ok; + } + } + } + cutin "",255; + close; +//end rstk + +L_seelist: + callsub S_countlist; + query_sql "select list_name from `"+$restock_tl$+"` where list_id="+restock_lsel,.@lname$; + mes "nliste: "+restock_lsel+", name : "+.@lname$; + set .@slotmenu$,callsub(S_build_slots,1); + next; + goto L_menu; +//end seelist + +L_delslot: + callsub S_countlist; + query_sql "select list_name from `"+$restock_tl$+"` where list_id="+restock_lsel,.@lname$; //name lookup + mes "nliste: "+restock_lsel+", name : "+.@lname$; + set .@slotmenu$,callsub(S_build_slots,0); + mes "Quel slot voulez vous supprimez ?"; + select(.@slotmenu$); + query_sql "delete from `"+$restock_ti$+"` where list_id="+restock_lsel+" and slot="+(@menu-1); + mes "Slot have been correctly deleted"; + next; + goto L_menu; +//end delslot + + +L_mdflist: + callsub S_countlist; + mes "Quel liste voulez vous selectionner parmit celle-ci ?"; + set .@menulist$,callsub(S_build_lists,0); + select(.@menulist$); + explode(.@options$,.@menulist$,":"); + debugmes "mdf .@options$="+.@options$[@menu-1]; + set .@list_select$,.@options$[@menu-1]; + mes "Options selected ="+.@list_select$; + query_sql "select list_id from `"+$restock_tl$+"` where char_id="+@charid+" and list_name='"+escape_sql(.@list_select$)+"'",.@list_id; + set restock_lsel,.@list_id; + next; + goto L_menu; +//end mdflist + +L_dellist: + callsub S_countlist; + mes "Quel liste voulez vous supprimer parmit celle-ci ?"; + set .@menulist$,callsub(S_build_lists,0); + select(.@menulist$); + explode(.@options$,.@menulist$,":"); + debugmes "del .@options$="+.@options$[@menu-1]; + set .@list_select$,.@options$[@menu-1]; + mes "Etes vous sur que vous voulez supprimer cette liste ?"; + mes "Options selected ="+.@list_select$; + if(select("Yes:Non")==1){ + query_sql "select list_id from `"+$restock_tl$+"` where char_id="+@charid+" and list_name='"+escape_sql(.@list_select$)+"'",.@list_id; + query_sql "delete from `"+$restock_tl$+"` where list_id="+.@list_id; + query_sql "delete from `"+$restock_ti$+"` where list_id="+.@list_id; + } + next; + goto L_menu; +//end L_dellist + + + +//sub function for easy call +S_new_list: + mes "Entrez le nom de votre liste !"; + input @newlist$; + if(@newlist$ == "") { + mes "Votre nom de liste n'est pas valide !"; + next; + return 0; + } + query_sql "select list_id from `"+$restock_tl$+"` where char_id="+@charid+" and list_name='"+escape_sql(@newlist$)+"'",.@list_id; + if(.@list_id != 0) { + mes "Vous avez deja entrer ce nom de liste !"; + next; + return 0; + } + return 1; +//end newlist + +S_memo_list: + set .@list_id,getarg(0); + debugmes "S_memo_list id="+.@list_id; + select("Créer ma liste manuellement:Scanner mon inventaire"); + switch(@menu){ + case 1: //manuel + /* + set .@end,1; + do{ + switch(select("Avancer:Reculer:Finir:Annuler")){ + case 1 : + if (.@slot<126) set .@slot,.@slot+1; + else mes "Maximum de slot atteint"; + break; + case 2 : if (.@index>1) set .@slot,.@slot-1; + else mes "Le slot ne peut être negatif"; + break; + case 3 : set .@end,0; + break; + case 4 : + return 0; + } + if(@menu!=3){ + mes "Slot ["+.@slot+"] = "+getitemname(.@itemslot_id[.@slot])+":"+.@itemslot_id[.@slot]+" / "+.@itemslot_nb[.@slot]; + mes "Entrez l'item id :"; + input .@item_id; + setarray .@itemslot_id[.@slot],.@item_id; + mes "Entrez la quantité :"; + input .@item_nb; + setarray .@itemslot_nb[.@slot],.@item_nb; + mes "MAJ Slot ["+.@slot+"] = "+getitemname(.@item_id)+":"+.@item_id+" / "+.@item_nb; + } + } while(.@end); + */ + mes "Currently rewriting this, disable"; return 0; + break; + case 2: //scan inventaire + getinventorylist(); + if(@inventorylist_count > 127){ //not possible normally but eh + mes "Les listes doivent être inférieur a 128 items"; + return 0; + } + //copy to merge both methode + //copyarray .@itemslot_id[0],@inventorylist_id[0],@inventorylist_count; + //copyarray .@itemslot_nb[0],@inventorylist_amount[0],@inventorylist_count; + for (set .@slot,0; .@slot<@inventorylist_count; set .@slot,.@slot+1) { + set .@item_id,@inventorylist_id[.@slot]; + set .@item_nb,@inventorylist_amount[.@slot]; + set .@ref,@inventorylist_refine[.@slot]; + set .@iden,@inventorylist_identify[.@slot]; + set .@att,@inventorylist_attribute[.@slot]; + set .@c0,@inventorylist_card1[.@slot]; + set .@c1,@inventorylist_card2[.@slot]; + set .@c2,@inventorylist_card3[.@slot]; + set .@c3,@inventorylist_card4[.@slot]; + set .@query$,"insert into `"+$restock_ti$+"`(list_id,slot,item_id,item_nb,refine,identify,attribute,card0,card1,card2,card3) values("+.@list_id+","+.@slot+","+.@item_id+","+.@item_nb+","+.@ref+","+.@iden+","+.@att+","+.@c0+","+.@c1+","+.@c2+","+.@c3+");"; + debugmes .@query$; + query_sql .@query$; + } + break; + } //end switch + /* + set .@listsize,getarraysize(.@itemslot_id); + for (set .@slot,0; .@slot<.@listsize; set .@slot,.@slot+1) { + set .@item_ib,.@itemslot_id[.@slot]; + set .@item_nb,.@itemslot_nb[.@slot]; + query_sql "insert into `"+$restock_ti$+"`(list_id,slot,item_id,item_nb) values("+.@list_id+","+.@slot+","+.@item_id+","+.@item_nb+");"; + } + */ + return 1; +//end memo list + +S_build_slots: + set .@display,getarg(0); + set .@query$,"select item_id,item_nb from `"+$restock_ti$+"` where list_id="+restock_lsel; + debugmes .@query$; + query_sql "select item_id,item_nb from `"+$restock_ti$+"` where list_id="+restock_lsel,.@item_id[0],.@item_nb[0]; + set .@slot_nb,getarraysize(.@item_id); + debugmes ".@slot_nb="+.@slot_nb; + for(set .@slot,0; .@slot<.@slot_nb; set .@slot, .@slot+1) { + set .@slotmenu$,.@slotmenu$+"Slot ["+.@slot+"] = "+getitemname(.@item_id[.@slot])+" / "+.@item_nb[.@slot]+":"; + if (.@display==1) mes "Slot ["+.@slot+"] = "+getitemname(.@item_id[.@slot])+" / "+.@item_nb[.@slot]; + debugmes ".@slot["+.@slot+"]="+getitemname(.@item_id[.@slot])+" / "+.@item_nb[.@slot]; + } + debugmes ".@slotmenu$="+.@slotmenu$; + return .@slotmenu$; +//end build_slots + +S_build_lists: + set .@display,getarg(0); + query_sql "select distinct list_name from `"+$restock_tl$+"` where char_id="+@charid,.@listname$[0]; + set .@lcount,getarraysize(.@listname$); + for(set .@numlist,0; .@numlist<.@lcount; set .@numlist, .@numlist+1) { + if (.@display==1) mes .@listname$[.@numlist]; + set .@menulist$, .@menulist$+.@listname$[.@numlist]+":"; + debugmes "numl["+.@numlist+"]="+.@listname$[.@numlist]; + } + debugmes ".@menulist$="+.@menulist$; + return .@menulist$; +//end build_lists + +S_countlist: + query_sql "select count(list_id) from `"+$restock_tl$+"` where char_id="+@charid+"",@listcount; + if (@listcount<=0){ + mes "[Restockeur]"; + mes "Bonjour "+@charname$+""; + mes "Vous n'avez fait aucun enregistrement !"; + next; + goto L_menu; + } + return @listcount; +//end countlist + +end; //extra end for security +OnInit: //config part + set $restock_tl$,"restock_lists"; + set $restock_ti$,"restock_items"; + end; +} + + + +aldebaran,137,106,0 duplicate(Restock#00) Restock#01 80 +amatsu,102,143,4 duplicate(Restock#00) Restock#02 80 +ayothaya,203,171,4 duplicate(Restock#00) Restock#03 80 +brasilis,240,318,4 duplicate(Restock#00) Restock#04 80 +mid_camp,223,243,4 duplicate(Restock#00) Restock#05 80 +cave,107,42,4 duplicate(Restock#00) Restock#06 80 +comodo,190,141,4 duplicate(Restock#00) Restock#07 80 +dicastes01,197,196,4 duplicate(Restock#00) Restock#08 80 +einbroch,60,195,4 duplicate(Restock#00) Restock#09 80 +einbech,166,132,4 duplicate(Restock#00) Restock#10 80 +geffen,124,62,4 duplicate(Restock#00) Restock#11 80 +gonryun,156,122,4 duplicate(Restock#00) Restock#12 80 +hugel,91,157,4 duplicate(Restock#00) Restock#13 80 +izlude,134,85,4 duplicate(Restock#00) Restock#14 80 +lighthalzen,151,100,4 duplicate(Restock#00) Restock#15 80 +louyang,207,97,4 duplicate(Restock#00) Restock#16 80 +xmas,144,127,4 duplicate(Restock#00) Restock#17 80 +manuk,288,188,4 duplicate(Restock#00) Restock#18 80 +morocc,159,101,4 duplicate(Restock#00) Restock#19 80 +moscovia,218,194,4 duplicate(Restock#00) Restock#20 80 +payon,182,107,4 duplicate(Restock#00) Restock#21 80 +prontera,153,189,4 duplicate(Restock#00) Restock#22 80 +rachel,106,129,4 duplicate(Restock#00) Restock#23 80 +splendide,179,148,4 duplicate(Restock#00) Restock#24 80 +umbala,125,125,4 duplicate(Restock#00) Restock#25 80 +veins,215,135,4 duplicate(Restock#00) Restock#26 80 +yuno,154,187,4 duplicate(Restock#00) Restock#27 80 +bat_room,148,150,4 duplicate(Restock#00) Restock#28 80 +amatsu,273,212,4 duplicate(Restock#00) Restock#39 80 +alberta,33,240,4 duplicate(Restock#00) Restock#40 80 + +//BG + + + + Index: npc/scripts_custom.conf =================================================================== --- npc/scripts_custom.conf (revision 104) +++ npc/scripts_custom.conf (working copy) @@ -197,10 +197,10 @@ npc: npc/gro_custom/kafra.txt npc: npc/gro_custom/tooldealer.txt npc: npc/gro_custom/tower.txt +npc: npc/gro_custom/restock.txt - // WoE // Guild WoE time settings. @@ -254,4 +254,4 @@ npc: npc/gro_custom/guild2/schg_cas04.txt npc: npc/gro_custom/guild2/schg_cas05.txt // Guild Dungeon Entrances -npc: npc/gro_custom/guild2/guild_dungeon.txt \ No newline at end of file +npc: npc/gro_custom/guild2/guild_dungeon.txt Index: src/map/script.c =================================================================== --- src/map/script.c (revision 104) +++ src/map/script.c (working copy) @@ -4217,6 +4217,7 @@ sd->npc_menu -= menu_countoptions(text, sd->npc_menu, &menu); if( sd->npc_menu <= 0 ) break;// entry found + pc_setregstr(sd, add_str("@options$"),text); //text option selected } pc_setreg(sd, add_str("@menu"), menu); script_pushint(st, menu); @@ -5945,7 +5946,7 @@ if( itemdb_isstackable2(id) ) { - ARR_FIND(0,MAX_STORAGE,i,compare_item(&sd->status.storage.items[i],&it)); + ARR_FIND(0,MAX_STORAGE,i,compare_item(&sd->status.storage.items[i],&it,0)); if( i < MAX_STORAGE ) { // Item on Storage script_pushint(st,amount + sd->status.storage.items[i].amount > MAX_AMOUNT ? 0 : 1); +/*========================================== + * Countstorageitem,type,item{,charid} [Lighta] + * type : 0 inventory, 1 guildinventory + * item : itemid or itemname + *------------------------------------------*/ +BUILDIN_FUNC(countstorageitem) +{ + TBL_PC * sd = ((script_hasdata(st,11)) ? map_id2sd(script_getnum(st,11)) : script_rid2sd(st)); + int i, type, count = 0; + struct item_data* item_data; + struct guild_storage *gstor; + struct storage_data *stor; + struct item tmp_it; + type = script_getnum(st,2); + + if(sd != NULL && (item_data = itemdb_exists(script_getnum(st,3))) != NULL ){ + tmp_it.nameid = item_data->nameid; + tmp_it.identify = script_getnum(st,4); + tmp_it.refine = script_getnum(st,5); + tmp_it.attribute = script_getnum(st,6); + tmp_it.card[0] = script_getnum(st,7); + tmp_it.card[1] = script_getnum(st,8); + tmp_it.card[2] = script_getnum(st,9); + tmp_it.card[3] = script_getnum(st,10); + + switch(type){ + case 0 : + stor=&sd->status.storage; + for(i = 0; i < MAX_STORAGE; i++) { + if( (&stor->items[i] != NULL) + && stor->items[i].amount > 0 + && compare_item(&stor->items[i],&tmp_it,1) + ) + count += stor->items[i].amount; + } + script_pushint(st,count); + break; + case 1: + if (sd->status.guild_id && (gstor=guild2storage2(sd->status.guild_id))) { + for(i = 0; i < MAX_GUILD_STORAGE; i++) { + if( (&gstor->items[i] != NULL) + && gstor->items[i].amount > 0 + && compare_item(&gstor->items[i],&tmp_it,1) + ) + count += gstor->items[i].amount; + } + script_pushint(st,count); + } + break; + default : + ShowError("Invalid type specified in countstorageitem"); + script_pushint(st,-1); + break; + } + } + + return 0; +} + +/*========================================== + * inv2stor,item_id,item_nb,attribute,refine,identify,c0,c1,c2,c3{,charid} [Lighta] + * interface pour pour la fonction de storage storage_storageadd + * transferant un item de l'inventaire au storage + *------------------------------------------*/ +BUILDIN_FUNC(inv2stor) +{ + TBL_PC * sd = ((script_hasdata(st,11)) ? map_id2sd(script_getnum(st,11)) : script_rid2sd(st)); + int i,ok; + struct item_data* item_data; + struct item tmp_it; + int item_id = script_getnum(st,2); + int item_nb = script_getnum(st,3); + + nullpo_ret(sd); + + if( (item_data = itemdb_exists(item_id)) != NULL ){ + tmp_it.nameid = item_data->nameid; + tmp_it.identify = script_getnum(st,4); + tmp_it.refine = script_getnum(st,5); + tmp_it.attribute = script_getnum(st,6); + tmp_it.card[0] = script_getnum(st,7); + tmp_it.card[1] = script_getnum(st,8); + tmp_it.card[2] = script_getnum(st,9); + tmp_it.card[3] = script_getnum(st,10); + + ARR_FIND( 0, MAX_INVENTORY, i, ((&sd->status.inventory[i] != NULL) + && compare_item(&sd->status.inventory[i],&tmp_it,1) )); + if( i < MAX_INVENTORY ){ + ok=storage_storageadd(sd,i,item_nb); + script_pushint(st,ok); + storage_storageclose(sd); + return ok; + } + } + script_pushint(st,-1); + return 0; +} + +/*========================================== + * inv2stor,item_id,item_nb,attribute,refine,identify,c0,c1,c2,c3{,charid} [Lighta] + * interface pour pour la fonction de storage_storageget + * transferant un item du storage a l'inventaire + *------------------------------------------*/ +BUILDIN_FUNC(stor2inv) +{ + TBL_PC * sd = ((script_hasdata(st,11)) ? map_id2sd(script_getnum(st,11)) : script_rid2sd(st)); + int i,ok; + struct item_data* item_data; + struct item tmp_it; + int item_id = script_getnum(st,2); + int item_nb = script_getnum(st,3); + + nullpo_ret(sd); + + if( (item_data = itemdb_exists(item_id)) != NULL){ + tmp_it.nameid = item_data->nameid; + tmp_it.identify = script_getnum(st,4); + tmp_it.refine = script_getnum(st,5); + tmp_it.attribute = script_getnum(st,6); + tmp_it.card[0] = script_getnum(st,7); + tmp_it.card[1] = script_getnum(st,8); + tmp_it.card[2] = script_getnum(st,9); + tmp_it.card[3] = script_getnum(st,10); + ARR_FIND( 0, MAX_STORAGE, i, ((&sd->status.storage.items[i] != NULL) + && compare_item(&sd->status.storage.items[i],&tmp_it,1) ) + ); + if( i < MAX_STORAGE ){ + ok=storage_storageget(sd,i,item_nb); + script_pushint(st,ok); + return ok; + } + } + script_pushint(st,-1); + return 0; +} + + + // declarations that were supposed to be exported from npc_chat.c #ifdef PCRE_SUPPORT BUILDIN_FUNC(defpattern); @@ -18519,7 +18658,10 @@ BUILDIN_DEF(checkweight2, "*"), // [Lighta] :) BUILDIN_DEF(checkweights, "rr"), - + BUILDIN_DEF(countstorageitem,"iiiiiiiii?"), + BUILDIN_DEF(stor2inv,"iiiiiiiii?"), + BUILDIN_DEF(inv2stor,"iiiiiiiii?"), + BUILDIN_DEF(vending_add, "ii*"), //epoque then mrj BUILDIN_DEF(vending_remove, "i*"), BUILDIN_DEF(vending_open, "*"), Index: src/map/storage.c =================================================================== --- src/map/storage.c (revision 104) +++ src/map/storage.c (working copy) @@ -121,14 +121,19 @@ clif_updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE); return 0; } -// helper function -int compare_item(struct item *a, struct item *b) + +/* helper function + * checking if 2 item structure are identique + * flag : + * 1 = not checking expire_time + */ +int compare_item(struct item *a, struct item *b, short flag) { if( a->nameid == b->nameid && a->identify == b->identify && a->refine == b->refine && a->attribute == b->attribute && - a->expire_time == b->expire_time && + (flag&1 || (a->expire_time == b->expire_time) ) ) { int i; @@ -439,7 +444,7 @@ { for(i=0; i< MAX_MEMBER_STORAGE; ++i) { - if(compare_item(&mstor->items[i], item_data)) + if(compare_item(&mstor->items[i], item_data,0)) { if(mstor->items[i].amount+amount > MAX_AMOUNT) return 1; @@ -513,7 +518,7 @@ if(itemdb_isstackable2(data)){ //Stackable for(i=0;iitems[i], item_data)) { + if(compare_item(&stor->items[i], item_data,0)) { if(stor->items[i].amount+amount > MAX_AMOUNT) return 1; stor->items[i].amount+=amount; @@ -640,7 +645,7 @@ {//Stackable for( i = 0; i < MAX_STORAGE; i++ ) { - if( compare_item(&stor->items[i], item_data) ) + if( compare_item(&stor->items[i], item_data,0) ) {// existing items found, stack them if( amount > MAX_AMOUNT - stor->items[i].amount ) return 1; Index: src/map/storage.h =================================================================== --- src/map/storage.h (revision 104) +++ src/map/storage.h (working copy) @@ -27,6 +27,7 @@ void storage_storage_quit(struct map_session_data *sd, int flag); struct member_storage_data* member2storage(int member_id); struct guild_storage* guild2storage(int guild_id); +struct guild_storage *guild2storage2(int guild_id); int member_storage_delete(int member_id); int guild_storage_delete(int guild_id); int storage_member_storageopen(struct map_session_data *sd); @@ -54,7 +55,7 @@ int storage_guild_storagesaved(int guild_id); //Ack from char server that guild store was saved. -int compare_item(struct item *a, struct item *b); +int compare_item(struct item *a, struct item *b, short flag); int storage_additem2(struct map_session_data *sd, struct item* item_data, int amount); #endif /* _STORAGE_H_ */