I finded bug with element_id Maybe. Can anybody test it?
OS Win 10. latest version GM 2
I testing create layer_sprite
Test project have 1 room, 1 object code is below, 2 sprites
GML:
//create event
var _i = 0
Layer = layer_get_id("Assets")
global.Element = array_create(0)
repeat(1){
global.Element[_i] = layer_sprite_create(Layer,200,100,Sprite2)
_i++
}
//step event
var _test = 0,
repeat(10000000){
_test = layer_sprite_create(Layer,100,100,Sprite1)
layer_sprite_destroy(_test)
}
show_debug_message(string(_test))
starting watch table = 1 element (instance), 1 element (sprite)
watch table after reach element id 1903481007
this element is visible in the room and can't be remove with layer_sprite_destroy
watch table after element id reach overflow
I can remove 3 elements -2147483648-46 with layer_sprite_destroy in watch table, this element was not removed in step code where is layer_sprite_destroy
(I think _test = layer_sprite_create (Layer, 100,100, Sprite1) returns -1 or something else)
Now I can't destroy layer sprite that was create in creation event id 2 is missing in layer_get_all_elements("Assets") and what I stored in global variable
Now I can't select instance element_id 0 that was in "Instances" layer and sprite in "Assets"" layer too. I cant remove sprite from room
I can access to instance with (instance_num).variable, but I can't use layer_instance_get_instance() .
watch table after reach element id -244000641 (it is same bitwise like 103481007 with -)
this element is visible in the room and can't be remove with layer_sprite_destroy
after reach next overflow now I have element id 0 and 1
I can remove element 0 and 1 with layer_sprite_destroy in watch table, this element was not removed in step code where is layer_sprite_destroy
(I think _test = layer_sprite_create (Layer, 100,100, Sprite1) returns -1 or something else)
after reach element id 1903481007 again I see 2 elements with same ID and I cant destroy it.
Question 1. Element_id 1903481007 and -244000641 is bug?
Question 2. How do I fix an overflow? The best thing for me is something like the internal GM2 variable element_id (last used id or next used id for element). I will check this id and I change it to the number I need.