SSTU - Shadow Space Technologies Unlimited

SSTU - Shadow Space Technologies Unlimited

98.5k Downloads

Code Cleanup -- Resource Handling (VolumeContainer and defs)

shadowmage45 opened this issue ยท 3 comments

commented

Code regarding loading of resource defs needs to be improved at all levels.

Currently if duplicate defs are detected/attempted to load, it will either error out (nullref), or end up with duplicate entries.

The spots that need improvement are:

  • Loading of volume defs. Log (loudly) when duplicates are detected. Keep whatever was loaded first.
  • Missing resource defs in for resources listed in CONTAINER nodes. Validate on attempt-to-load/parse. Log when the resource is not found, but skip it otherwise.
  • Loading of fuel type data -- Log the error, but keep the first definition loaded for a fuel type.
  • ?? Probably lots more once I look at the code a bit closer.
commented

You could check if they are in CRP instead of the individual mods, as most well-known mods use CRP resources.

Maybe make some kind of matrix that can be set by a patch to enable the CRP resource. That way you can make an function on each mod trying to activate a resource, and define the actual tank resource from the plugin (preventing double definitions from multiple patches).

example:

Have the plugin look in a table for CRP resources and a Custom table that can be added to via patches
CRP/CommonResources.cfg
SSTU/CustomResources.cfg

DSEV.cfg

SSTUCustomResource:NEEDS[...]
{
name = PeanutButterCups
volume = 0.1
}

@SSTUResources:NEEDS[...]
{
resourceEnable = Water
resourceEnable = Oxygen
}

TAC.cfg

// no custom definitions, all are present in CRP

@SSTUResources:NEEDS[...]
{
resourceEnable = Water
resourceEnable = Oxygen
resourceEnable = Food
}

commented

Orrrrrr

Define all resources in crp and have patches activate them...

@SSTUresources:needs[tac...]
{
Enable_Water = true
Enable_Food = true
}

That way multiple cal from mods will not interfere.

Plus a custom file as described above for custom resources.

commented

Seems like this should be done at the same time as #525