Game Development Community

Loading Datablocks

by Bill Koons · in Torque Game Engine · 07/28/2005 (2:28 pm) · 5 replies

Does anyone know if there is a way to load only those datablocks needed in a mission? We have a lot of datablocks, but they aren't all used in every mission. As a matter of fact, only a small subset of our datablocks are used for a given mission. As it currently stands, we end up loading all of the datablocks into memory for each mission, which seems like a waste of memory. Any suggestions would be greatly appreciated.

Thanks!

#1
07/28/2005 (3:10 pm)
The simplest suggestion is to only exec the datablocks you need post the unload datablocks call. Or you could put flags on them and modify the transmission code to skip those with false flags. Either way you'll have to hand annotate, as it's not currently possible for the engine to tell which datablocks you're going to use in a level - you might need one for a projectile or a spawned item. So you have to make the list by hand. You might do something like:

datablock FooData(bar1) { };
datablock FooData(bar2) { };
datablock FooData(bar3) { };

if($Mission::hasMechs)
{
   datablock MechData(mech1) { };
   datablock MechData(mech2) { };
   datablock MechData(mech3) { };
}

if($Mission::hasPony)
{
   datablock PonyData(pony1) { };
   datablock ParticleData(ponyPuff) { };
}

You'd set the globals there (the names are just a convenience, no tie to any existing meaning/semantics) when the mission was loaded based on the assets you'd be using, then the if statements would filter which datablocks would get exec'ed, thus, loaded. Using an un-exec'ed datablock will result in problems, though, so be careful what you switch out!
#2
07/29/2005 (7:36 am)
Ben: Thanks for the information and the quick reply. I kind of figured we'd have to do something like that, but wanted to be sure I wasn't missing something.
#3
05/25/2007 (2:10 pm)
@Ben: Where would be the proper place for those if-statements?
#4
05/25/2007 (2:51 pm)
Wouldn't it be simpler to use Packages?
#5
05/25/2007 (3:21 pm)
For me it worked to just define the datablocks at the top of the mission file...since I have datablocks that are mission-specific. They will get loaded only for that mission.