Excessive struct size? - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Design (/forum-5.html)
+--- Thread: Excessive struct size? (/thread-7402.html)
Excessive struct size? - sealfin - Jan 13, 2003 10:02 AM
I'm just pondering whether the size of a struct is a tad excessive (~100bytes); typically, how many bytes would people use for a backbone struct like this?
The struct in discussion is the backbone of my game; the struct takes care of all events between entities (i.e. the results of collisions et al, which can result in spawning, destroying or changing in some way an entity et al).
Excessive struct size? - DoG - Jan 13, 2003 10:44 AM
I don't know what you do with so much data to thrown around in events (I would rather pass a pointer to custom data stored somewhere), but it's not too big. My struct for storing a single triangle is over 300 bytes, so I don't think yours is too big, even though my event class is 40 bytes only.
Excessive struct size? - w_reade - Jan 13, 2003 11:12 AM
As long as you don't go around passing it by value, I don't think there's any very compelling reason (other than aesthetic) to change it. The GlobalStuff struct in MAFFia is more than 100 lines, and each of those lines will account for at least 4 bytes, and it didn't cause any problems. I don't see why yours should do anything untoward, even if you have a few hundred of them.
After all, 500 objects at 100 bytes is only 50k, and plenty of games juggle a hundred times more graphical data alone.
How many bytes people would use depends on what the struct needs to hold. Simple as that. Once you've decided what information needs to be in the struct, you choose how that information is represented.
You could keep a wodge of XML in memory and read/write the values textually, or you could compress the data to the tightest possible binary and decompress whenever you needed to read a value (and probably decompress/recompress whenever you wanted to write). Both of those solutions would probably be bad in a game situation, but they represent the extremes, and would have their uses. I'm being obvious, I know, but....
anyway. A list of coded numbers, of whatever length seems to encapsulate all the relevant information without requiring too much redundant storage and processing time, seems to be the norm. Computers deal with it with ease, and frail human programmers can still understand what's going on. In the end, only you can judge - I suspect you're the only person who knows what the data needs to do well enough to have an idea of the tradeoffs in your own situation.