Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Are IDs ever reused?

Author
Message
Jambo B
14
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 30th May 2019 15:10
Hello all.

Quick question.

I create a sprite with ID = CreateSprite(whatever), and an ID is returned. Later, I might delete that sprite, and then create others afterwards.

My question is this. Is that ID ever used again by AppGameKit when creating another sprite? The ID numbers keep increasing, but theoretically what happens when we hit ID 2147483647 (the highest 32-bit number)? Does AppGameKit roll back around to the first unused (deleted) ID? And is this behaviour the same for all resources (sprites, memblocks, images, etc.)

I know it's unlikely that I would create 2,147,483,647 of anything, but if, under certain circumstances, AppGameKit reuses an ID, it could mess up the code I'm working on.

I guess what I'm asking is are there any circumstances where AppGameKit would reuse an ID it had used before, if that resource had been deleted.

Thanks,

James
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 31st May 2019 02:21 Edited at: 31st May 2019 02:29
If you delete the sprite and AppGameKit renames another sprite with the same ID, you have nothing to worry about.

let's assume you're not doing that.

Your GPU would run out of memory long before AppGameKit could duplicate a sprite. I have dealt with that bug before(accidentally creating an infinite loop of sprites). My GPU just gives out. I can't remember the exact error, but its something like "Your GPU has run out of memory".

Or you could just test this by creating a bunch of invisible sprites?
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 31st May 2019 07:31
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st May 2019 13:26 Edited at: 31st May 2019 13:27
ID's that are created by AppGameKit start at 100001 and increment up by one for every resource of that type allocated up to a max value then it wraps round to 1 again.

AGK will NOT allocate an ID for an item that is currently being used. So as you have said it takes the first unused ID greater than the last one used. If you did allocate and delete a sprite 3 billion times it would wrap back round to 1 and start counting up again but it will miss out any ID's that are currently being used (ID's that have not been deleted) . If you let AppGameKit allocate the IDs for your resources then you shouldn't have any problems at all even if you did happen to create and then delete 3 billion times over.

Login to post a reply

Server time is: 2024-03-28 13:34:00
Your offset time is: 2024-03-28 13:34:00