OSDN Git Service

多数のロッドを所持したときにpvalがオーバフローする不具合を修正。
authoriks <iks@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 3 Apr 2003 08:26:33 +0000 (08:26 +0000)
committeriks <iks@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 3 Apr 2003 08:26:33 +0000 (08:26 +0000)
src/object2.c
src/store.c
src/wizard2.c

index 78abf98..994b185 100644 (file)
@@ -1797,8 +1797,12 @@ bool object_similar(object_type *o_ptr, object_type *j_ptr)
  */
 void object_absorb(object_type *o_ptr, object_type *j_ptr)
 {
-       /* Add together the item counts */
-       o_ptr->number = o_ptr->number + j_ptr->number;
+       int max_num = object_similar_part(o_ptr, j_ptr);
+       int total = o_ptr->number + j_ptr->number;
+       int diff = (total > max_num) ? total - max_num : 0;
+
+       /* Combine quantity, lose excess items */
+       o_ptr->number = (total > max_num) ? max_num : total;
 
        /* Hack -- blend "known" status */
        if (object_known_p(j_ptr)) object_known(o_ptr);
@@ -1827,14 +1831,14 @@ void object_absorb(object_type *o_ptr, object_type *j_ptr)
        /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
        if (o_ptr->tval == TV_ROD)
        {
-               o_ptr->pval += j_ptr->pval;
-               o_ptr->timeout += j_ptr->timeout;
+               o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
+               o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
        }
 
        /* Hack -- if wands are stacking, combine the charges. -LM- */
        if (o_ptr->tval == TV_WAND)
        {
-               o_ptr->pval += j_ptr->pval;
+               o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
        }
 }
 
@@ -6067,16 +6071,30 @@ void combine_pack(void)
                                }
                                else
                                {
+                                       int old_num = o_ptr->number;
                                        int remain = j_ptr->number + o_ptr->number - max_num;
-                                       
+#if 0
                                        o_ptr->number -= remain;
-                                       
+#endif
                                        /* Add together the item counts */
                                        object_absorb(j_ptr, o_ptr);
 
                                        o_ptr->number = remain;
-                                       
+
+                                       /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
+                                       if (o_ptr->tval == TV_ROD)
+                                       {
+                                               o_ptr->pval =  o_ptr->pval * remain / old_num;
+                                               o_ptr->timeout = o_ptr->timeout * remain / old_num;
+                                       }
+
+                                       /* Hack -- if wands are stacking, combine the charges. -LM- */
+                                       if (o_ptr->tval == TV_WAND)
+                                       {
+                                               o_ptr->pval = o_ptr->pval * remain / old_num;
+                                       }
                                }
+
                                /* Window stuff */
                                p_ptr->window |= (PW_INVEN);
                                
@@ -6092,7 +6110,6 @@ void combine_pack(void)
 #else
        if (flag) msg_print("You combine some items in your pack.");
 #endif
-
 }
 
 
index 3625dc7..a33cd5e 100644 (file)
@@ -1197,21 +1197,24 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
  */
 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
 {
+       int max_num = (o_ptr->tval == TV_ROD) ?
+               MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
        int total = o_ptr->number + j_ptr->number;
+       int diff = (total > max_num) ? total - max_num : 0;
 
        /* Combine quantity, lose excess items */
-       o_ptr->number = (total > 99) ? 99 : total;
+       o_ptr->number = (total > max_num) ? max_num : total;
 
        /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
        if (o_ptr->tval == TV_ROD)
        {
-               o_ptr->pval += j_ptr->pval;
+               o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
        }
 
        /* Hack -- if wands are stacking, combine the charges. -LM- */
        if (o_ptr->tval == TV_WAND)
        {
-               o_ptr->pval += j_ptr->pval;
+               o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
        }
 }
 
index aa94cfa..c3d627b 100644 (file)
@@ -1178,6 +1178,11 @@ static void wiz_quantity_item(object_type *o_ptr)
                /* Accept modifications */
                o_ptr->number = tmp_int;
        }
+
+       if (o_ptr->tval == TV_ROD)
+       {
+               o_ptr->pval = o_ptr->pval * o_ptr->number / tmp_qnt;
+       }
 }