#define performance and naming suggestion

Started by Bryan, Sat 17/04/2004 09:44:25

Previous topic - Next topic

Bryan

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.
this space intentionally left blank

Kweepa

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).
Still waiting for Purity of the Surf II

Bryan

#2
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.
this space intentionally left blank

Kweepa

Yeah, being able to name sprites, dialogs and fonts would be good.
Still waiting for Purity of the Surf II

Pumaman

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.

Gilbert

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? ;)

SMF spam blocked by CleanTalk