ID:1461609
 
BYOND Version:501
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 32.0.1700.41
Applies to:Dream Seeker
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:
When using icon.Insert in the same iteration inside of a loop, it would seem that it creates a runtime error. It doesn't matter whether using a .rsc, external, or cached (soft-coded) file, nor does it matter if using any icon procs beforehand.

Numbered Steps to Reproduce Problem:
1. Create a new .dm file
2. Create a while loop.
3. Use more than one icon.Insert proc for the same icon inside the loop.

Code Snippet (if applicable) to Reproduce Problem:
var/icon/Ichild = new('_flat_Blank.dmi')
while(realframe <= maxoframe)
//body
var/icon/bodyI = new('_flat_Blank.dmi')
var/icon/bodyadd = icon(body.overlay_obj.icon || src.icon
, body.overlay_obj.icon_state || (body.overlay_obj.icon && (src.icon_state in icon_states(body.overlay_obj.icon)) && src.icon_state)
, (dir)
, 1
, 0)

bodyadd.Scale(48*abs(body.scale_x),48*abs(body.scale_y))
if(body.scale_x < 0)
bodyadd.Flip(WEST)
if(body.scale_y < 0)
bodyadd.Flip(SOUTH)

bodyadd.Turn(body.angle)


bodyI.Blend(bodyadd,ICON_OVERLAY,body.PixelX()+1,body.PixelY()+1)

if(loopoverlay == 0 && currentoframe >= 1+((maxoframe-1)*currentdelay))
Ichild.Insert(bodyI,"[age]-[currentanimation]-[chargender]_body[body_type]",src.dir,realframe,0,999)
else
Ichild.Insert(bodyI,"[age]-[currentanimation]-[chargender]_body[body_type]",src.dir,realframe,0,currentdelay)
//larm1
var/icon/larm1I = new('_flat_Blank.dmi')
var/icon/larm1add = icon(larm1.overlay_obj.icon || src.icon
, larm1.overlay_obj.icon_state || (larm1.overlay_obj.icon && (src.icon_state in icon_states(larm1.overlay_obj.icon)) && src.icon_state)
, (dir)
, 1
, 0)

larm1add.Scale(48*abs(larm1.scale_x),48*abs(larm1.scale_y))
if(larm1.scale_x < 0)
larm1add.Flip(WEST)
if(larm1.scale_y < 0)
larm1add.Flip(SOUTH)
larm1add.Turn(larm1.angle)


larm1I.Blend(larm1add,ICON_OVERLAY,larm1.PixelX()+1,larm1.PixelY()+1)

if(loopoverlay == 0 && currentoframe >= 1+((maxoframe-1)*currentdelay))
Ichild.Insert(larm1I,"[age]-[currentanimation]-[chargender]_larm1[body_type]",src.dir,realframe,0,999)
else
Ichild.Insert(larm1I,"[age]-[currentanimation]-[chargender]_larm1[body_type]",src.dir,realframe,0,currentdelay)
//larm2
var/icon/larm2I = new('_flat_Blank.dmi')
var/icon/larm2add = icon(larm2.overlay_obj.icon || src.icon
, larm2.overlay_obj.icon_state || (larm2.overlay_obj.icon && (src.icon_state in icon_states(larm2.overlay_obj.icon)) && src.icon_state)
, (dir)
, 1
, 0)

larm2add.Scale(48*abs(larm2.scale_x),48*abs(larm2.scale_y))
if(larm2.scale_x < 0)
larm2add.Flip(WEST)
if(larm2.scale_y < 0)
larm2add.Flip(SOUTH)
larm2add.Turn(larm2.angle)


larm2I.Blend(larm2add,ICON_OVERLAY,larm2.PixelX()+1,larm2.PixelY()+1)

if(loopoverlay == 0 && currentoframe >= 1+((maxoframe-1)*currentdelay))
Ichild.Insert(larm2I,"[age]-[currentanimation]-[chargender]_larm2[body_type]",src.dir,realframe,0,999)
else
Ichild.Insert(larm2I,"[age]-[currentanimation]-[chargender]_larm2[body_type]",src.dir,realframe,0,currentdelay)

realframe += 1

(A minimized example. Not everything I have is included, however I have tested it with a simpler example as well.)
Expected Results:
The icon would be inserted without errors into the icon file.
Actual Results:
Dream Seeker returns a runtime error.
runtime error: bad icon operation
proc name: Insert (/icon/proc/Insert)
usr: Kamuna (/mob)
src: /icon (/icon)
call stack:
/icon (/icon): Insert(/icon (/icon), "10-0-male_body1", 2, 1, 0, 999)
Kamuna (/mob): CreateAnimations()

Does the problem occur:
Every time? Or how often? Every time.
In other games? Not tested.
In other user accounts? Not tested.
On other computers? Not tested.

When does the problem NOT occur?
When I use seperate icons for the Insert procedures. (Aka Ichildp1, Ichildp2, etc) OR use the same icon in different iterations.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? Not tested.

Workarounds:
Use seperate icons for the Insert procedures, then merge the icons together into one icon.

Other notes: This is just a quick problem that happened to me whilst coding an animation system. I thought I might as well report it, but it's not a huge problem. Took me a while to find the cause of the problem, however, once I did, it was easy to work around.

Edit: Thanks for editing the code in my post, I didn't have time to edit and properly indent it.