Inserting an non-null icon into a blank icon (created from a blank .dmi with no states) throws "Bad icon operation" runtimes.
Runtime in detail:
[13:00:00] Runtime in ,: bad icon operation
proc name: Insert (/icon/proc/Insert)
usr: Irrationalist (/mob/new_player) ([0x3000001]) (NULL) (0,0,0) (NULL) (irrationalist)
usr.loc: *null*
src: /icon (/icon)
call stack:
/icon (/icon): Insert(/icon (/icon), null, 8, null, null, null)
/datum/rick/mob_icon_compiler (/datum/rick/mob_icon_compiler): generate(Angel Gibson (mannequin) (/mob/living/carbon/human/dummy/mannequin))
Angel Gibson (mannequin) (/mob/living/carbon/human/dummy/mannequin): update body(0)
Angel Gibson (mannequin) (/mob/living/carbon/human/dummy/mannequin): force update limbs()
/datum/preferences (/datum/preferences): copy to(Angel Gibson (mannequin) (/mob/living/carbon/human/dummy/mannequin), 1)
/datum/preferences (/datum/preferences): dress preview mob(Angel Gibson (mannequin) (/mob/living/carbon/human/dummy/mannequin))
/datum/preferences (/datum/preferences): update preview icon()
Body (/datum/category_item/player_setup_item/physical/body): content(Irrationalist (/mob/new_player))
Physical (/datum/category_group/player_setup_category/physical_preferences): content(Irrationalist (/mob/new_player))
/datum/category_collection/pla... (/datum/category_collection/player_setup_collection): content(Irrationalist (/mob/new_player))
/datum/preferences (/datum/preferences): ShowChoices(Irrationalist (/mob/new_player))
Irrationalist (/mob/new_player): Topic("src=\[0x3000001];show_preferen...", /list (/list))
Irrationalist (/client): Topic("src=\[0x3000001];show_preferen...", /list (/list), Irrationalist (/mob/new_player))
Irrationalist (/client): Topic("src=\[0x3000001];show_preferen...", /list (/list), Irrationalist (/mob/new_player))
Numbered Steps to Reproduce Problem:
1. Create a new icon from a blank .dmi
2. Try to insert an other icon (be it from an other dmi or a procedurally generated one using several icons clobbered together with Blend, etc.), doesn't matter if it is blank or not.
Code Snippet (if applicable) to Reproduce Problem:
// Not included are two strings that turn the blend styles and
// directions into readable strings for debugging output
/datum/rick/mob_icon_compiler/generate(var/mob/living/carbon/human/H)
var/icon/output_icon = new/icon('modules/ric/blanks.dmi')
for(var/direction in list(NORTH,SOUTH,WEST,EAST))
// A procedurally generated (and seemingly valid) icon
var/icon/dir_base_icon = compile_direction(direction, H)
// Trying to insert non-blanks from files also cause runtimes
// dir_base_icon = new/icon('icons/mob/human.dmi',"body_m_s")
src.log_event("Inserting [direction_to_string(direction)] into output")
output_icon.Insert(new/icon(dir_base_icon, dir = direction), dir = direction)
src.log_event("Done!")
return output_icon
/datum/rick/mob_icon_compiler/proc/compile_direction(var/direction, var/mob/living/carbon/human/H)
var/obj/item/organ/external/root = H.get_organ(BP_CHEST)
var/icon/base_icon = new/icon(root.get_icon(), dir = direction)
src.log_event("Collecting body part info.")
for(var/obj/item/organ/external/part in (H.organs-root))
var/datum/arg_object/mob_icon_part/O = part.visit_mob_icon_part(direction, list())
if (O && O.body_icon)
base_icon.Blend(O.body_icon, O.blend_style)
src.log_event("Blended [part.organ_tag] into [direction_to_string(direction)] component with [blend_to_string(O.blend_style)]")
return base_icon
Expected Results:
No runtime.
Actual Results:
Runtime with a very insightful description helpful to solving the problem painlessly with
Does the problem occur:
Every time? Or how often?
Every time when this operation is run
In other games?
N/A
In other user accounts?
N/A
On other computers?
N/A
When does the problem NOT occur?
I've yet to figure out.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Unknown
Workarounds:
By not using Insert()
Besides, on a more serious note, only this seems to work without runtimes.
var/obj/item/organ/external/chest = get_organ(BP_CHEST)
base_icon = chest.get_icon()
for(var/obj/item/organ/external/part in (organs-chest))
var/icon/temp = part.get_icon()
//That part makes left and right legs drawn topmost and lowermost when human looks WEST or EAST
//And no change in rendering for other parts (they icon_position is 0, so goes to 'else' part)
if(part.icon_position & (LEFT | RIGHT))
var/icon/temp2 = new('icons/mob/human.dmi',"blank")
temp2.Insert(new/icon(temp,dir=NORTH),dir=NORTH)
temp2.Insert(new/icon(temp,dir=SOUTH),dir=SOUTH)
if(!(part.icon_position & LEFT))
temp2.Insert(new/icon(temp,dir=EAST),dir=EAST)
if(!(part.icon_position & RIGHT))
temp2.Insert(new/icon(temp,dir=WEST),dir=WEST)
base_icon.Blend(temp2, ICON_OVERLAY)
if(part.icon_position & LEFT)
temp2.Insert(new/icon(temp,dir=EAST),dir=EAST)
if(part.icon_position & RIGHT)
temp2.Insert(new/icon(temp,dir=WEST),dir=WEST)
base_icon.Blend(temp2, ICON_UNDERLAY)
else if(part.icon_position & UNDER)
base_icon.Blend(temp, ICON_UNDERLAY)
else
base_icon.Blend(temp, ICON_OVERLAY)
Where temp are non-blanks, and temp2 is a blank, the very same circumstances as above.