Issue information

Issue ID
#2735
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Feb 2, 2009 19:36
Last Post
Hercules Elf Bot
Nov 23, 2012 16:25
Confirmation
N/A

Hercules Elf Bot - Feb 2, 2009 19:36

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2735

In r10573 there was a fix to countitem2.
Today I got a report that delitem2 is also affected by the same problem. It is likely that getitem2 has this too, but its code structure hides the problem.

Here's something I coded, but then thought... why not just use proper variable types for c1..c4 - short instead of int? That should probably be more proper...

CODE
=== src/map/script.c
==================================================================
--- src/map/script.c    (revision 13505)
+++ src/map/script.c    (local)
@@ -5208,10 +5208,10 @@
    iden=script_getnum(st,4);
    ref=script_getnum(st,5);
    attr=script_getnum(st,6);
-    c1=script_getnum(st,7);
-    c2=script_getnum(st,8);
-    c3=script_getnum(st,9);
-    c4=script_getnum(st,10);
+    c1=(short)script_getnum(st,7);
+    c2=(short)script_getnum(st,8);
+    c3=(short)script_getnum(st,9);
+    c4=(short)script_getnum(st,10);

    if(nameid<0) { // ƒ‰ƒ“ƒ_ƒ€
        nameid=itemdb_searchrandomid(-nameid);
@@ -5242,10 +5242,10 @@
            item_tmp.identify=0;
        item_tmp.refine=ref;
        item_tmp.attribute=attr;
-        item_tmp.card[0]=c1;
-        item_tmp.card[1]=c2;
-        item_tmp.card[2]=c3;
-        item_tmp.card[3]=c4;
+        item_tmp.card[0]=(short)c1;
+        item_tmp.card[1]=(short)c2;
+        item_tmp.card[2]=(short)c3;
+        item_tmp.card[3]=(short)c4;

        //Check if it's stackable.
        if (!itemdb_isstackable(nameid))
@@ -5666,10 +5666,10 @@
    iden=script_getnum(st,4);
    ref=script_getnum(st,5);
    attr=script_getnum(st,6);
-    c1=script_getnum(st,7);
-    c2=script_getnum(st,8);
-    c3=script_getnum(st,9);
-    c4=script_getnum(st,10);
+    c1=(short)script_getnum(st,7);
+    c2=(short)script_getnum(st,8);
+    c3=(short)script_getnum(st,9);
+    c4=(short)script_getnum(st,10);

    if( amount <= 0 )
        return 0;// nothing to do

Hercules Elf Bot - Nov 23, 2012 16:25

Originally posted by [b]mkbu95[/b]
Fixed in [rev=13523].