Jibble

Author Topic: #define performance and naming suggestion  (Read 1994 times)

#define performance and naming suggestion
« on: 17 Apr 2004, 09:44 »
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

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    • Kweepa worked on one or more games that won an AGS Award!
    •  
    • Kweepa worked on one or more games that was nominated for an AGS Award!
Re:#define performance and naming suggestion
« Reply #1 on: 17 Apr 2004, 10:09 »
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

Re:#define performance and naming suggestion
« Reply #2 on: 17 Apr 2004, 10:15 »
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.
« Last Edit: 17 Apr 2004, 10:22 by Bryan »
this space intentionally left blank

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    • Kweepa worked on one or more games that won an AGS Award!
    •  
    • Kweepa worked on one or more games that was nominated for an AGS Award!
Re:#define performance and naming suggestion
« Reply #3 on: 17 Apr 2004, 10:20 »
Yeah, being able to name sprites, dialogs and fonts would be good.
Still waiting for Purity of the Surf II

Pumaman

  • Creator of AGS
  • Administrator
  • Mittens King
  • I sense danger.
    • Lifetime Achievement Award Winner
    • Pumaman worked on one or more games that won an AGS Award!
    •  
    • Pumaman worked on one or more games that was nominated for an AGS Award!
Re:#define performance and naming suggestion
« Reply #4 on: 17 Apr 2004, 14:44 »
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

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
Re:#define performance and naming suggestion
« Reply #5 on: 19 Apr 2004, 04:52 »
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? ;)