Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Bryan on Sat 17/04/2004 09:44:25

Title: #define performance and naming suggestion
Post by: Bryan on Sat 17/04/2004 09:44:25
Two related things here, one a question:
I shudder at referring to things by number in my scripts for several reasons (which I won't go into), and so I have a whole slew of #define to name all my sprites and objects in the appropriate scopes.  I've assumed that those are all replaced when compiling the game exe and so there is no run time performance hit no matter how many #define's I use.  

Is that true?

And my suggestion: everything should be nameable.  Currently, we can do this for characters and gui's, and then use the names in place of the int's.  I'm accomplishing the same with all my #define's, but it could be cleaner if I could name them directly in AGS.
Title: Re:#define performance and naming suggestion
Post by: Kweepa on Sat 17/04/2004 10:09:41
That must be true. And even in the impossible offchance that it's not true (which it is) it's still worth the performance hit (although there isn't one because it's true).

As for the naming, I can foresee cases when AGS naming could be duplicating work. I'm thinking about room objects, regions etc, where objects are out of scope, but you still want to refer to them. With #defines that's easy and natural (move from room script to global header).
Title: Re:#define performance and naming suggestion
Post by: Bryan on Sat 17/04/2004 10:15:12
I see your point.  I'll still argue for sprites though, since they are global scope.

edit:  re: #define performance, I was pretty sure it was true, because otherwise would be silly.  But silly things happen so I wanted to be sure.  No offense intended.
Title: Re:#define performance and naming suggestion
Post by: Kweepa on Sat 17/04/2004 10:20:07
Yeah, being able to name sprites, dialogs and fonts would be good.
Title: Re:#define performance and naming suggestion
Post by: Pumaman on Sat 17/04/2004 14:44:26
Yes, #define is replaced with its definition at compile-time, so it has no in-game performance hit.

As for naming, the problem is with naming things that are deletable. (this is one reason you can't delete views, for instance).

Suppose you named view 56 as JIBBLE, but then you deleted view 50. All the higher numbered ones get re-numbered down one (and the #defines would be updated); but any rooms which are already compiled would be referring to the wrong view.

This is why GUI names actually #define to a special hidden function FindGUIByName, so that even if the numbers have changed, it will still find the right one.

Still, naming dialogs and fonts, which are not currently deletable, sounds like a good idea.
Title: Re:#define performance and naming suggestion
Post by: Gilbert on Mon 19/04/2004 04:52:42
Quote from: Pumaman on Sat 17/04/2004 14:44:26
Suppose you named view 56 as JIBBLE, but then you deleted view 50. All the higher numbered ones get re-numbered down one (and the #defines would be updated); but any rooms which are already compiled would be referring to the wrong view.


But hey, isn't that what the rebuild all rooms function of teh editor is for? ;)