viewing paste ra_guildboundchk | Diff

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -792,9 +792,29 @@
 /*==========================================
  * Player request leaving a given guild_id
  *----------------------------------------*/
+
+int itemdb_guildbound_chk(TBL_PC *sd,int type,int *idxlist){
+   int i=0, j=0;
+   switch(type){
+   case 1: //cehck in inventory
+       for(i=0;i<MAX_INVENTORY;i++){
+           if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0 && sd->status.inventory[i].bound == 2) {
+               idxlist[j] = i;
+               j++;
+           }
+       }
+       break;
+   case 2: //check in cart
+   case 3: //check in storage
+       break;
+   }
+   return j;
+}
+
 int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes)
 {
    struct guild *g;
+   int idxlist[MAX_INVENTORY]; //or malloc to reduce consumtion
 
    nullpo_ret(sd);
 
@@ -808,10 +828,23 @@
        ((agit_flag || agit2_flag) && map[sd->bl.m].flag.gvg_castle))
        return 0;
 
+   //Guild bound item check
+   j = itemdb_guildbound_chk(sd,1,idxlist);
+   if(j) {
+       struct guild_storage* stor = guild2storage(sd->status.guild_id);
+       for(i=0;i<j;i++) {
+           guild_storage_additem(sd,stor,&sd->status.inventory[list[i]],sd->status.inventory[list[i]].amount);
+           pc_delitem(sd,list[i],sd->status.inventory[list[i]].amount,0,4,LOG_TYPE_GSTORAGE);
+       }
+       storage_guild_storageclose(sd);
+   }
+
    intif_guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes);
    return 0;
 }
Viewed 1155 times, submitted by lighta.