Excessive struct size?

Posts: 691
Joined: 2002.04
Post: #1
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).

Mark Bishop
Quote this message in a reply
Posts: 869
Joined: 2003.01
Post: #2
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.

- D.G
Quote this message in a reply
Post: #3
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Free game concept: Excessive Force Jishiro 4 5,454 May 14, 2006 05:35 PM
Last Post: David Drew