jbarcz1 wrote:
Each empire needs to have a list of "buildable" designs, so we can populate their list of shipbuilding options in the UI. That, in itself, is a reason to have a set of designs in the empire object, and to have a "ship-stats" class which is distinct from the ship itself.
As to the memory problem, It depends on how big we want our fleets to get. We're trying to plan for the future when designs get much more elaborate. I figure a ship design class could probably take up at least 50 bytes, and maybe close to 100 in the worst case (with lots of weapons and special gear)
100 bytes is roughly 1 MB per 10,000 ships. If our fleets are MOO2 sized (say, no more than 500 ships per empire), then this is no problem, since 500 ships * 10 empires = 5K ships = a measly 512KB. If they're MOO1 sized, however (tens of thousands of ships per empire), then that will create memory problems if we represent the ships individually, and store copies of the designs. 40K ships per empire * 10 empires = 40 MB, worst case. If we're planning on huge fleets, we probably aught to ditch the idea of a ship as a distinct object, and just do it the way MOO1 did (but with an infinite number of designs per side)
Now that I've done the math, If we intend to keep the fleet sizes small, I'd actually like to duplicate this data, since it would allow captures, custom refits, etc etc to be supported with little effort (you just change the individual ships, no need to tweak the design "schema").
If we're planning on huge fleets though we'll need to have designs seperate and put references in ships, to avoid hogging too much ram.
We probably need the design team's input to decide the question of fleet size.
The designs are separate from the ships in my design, but when each ship is created, it is given a design object that keeps a local copy of, that defines its size, shape, weapons, whatever. That design can be changed on a ship-by-ship basis, captured with the ship, etc. This flexibility is why I set things up the way I did.
The original designs should indeed be placed in the Empire that creates that kind of ship; I only put copies into each ship.
And for the worst-case scenario you outlined above, 40MB is not a huge deal (though it is significant). I have 512MB on my machine, and by the time this project is ready to have huge fleets an multiple players, 40MB will be even smaller in proportion to contemporary memory sizes.