OutpostUniverse / op2ext

Outpost 2 extension module loader
1 stars 0 forks source link

Untie resource loading from module loading #237

Open DanRStevens opened 5 years ago

DanRStevens commented 5 years ago

Currently console module loading has two main features:

  1. Load a DLL into Outpost2.exe's address space, and call certain event handlers
  2. Add the module folder and any VOL files to the resource search path

Some of these features are being added for INI modules to increase compatibility between the two module types. Perhaps instead we should look at untying these two features.

Most modules don't need both features. The ones that do can potentially load extra resources from within module initialization. The extra resource loading seems most useful for "modules" that don't have a DLL component. Perhaps instead we can offer a command line option for extra resource loading that isn't tied to module loading.

The separate features could be handled by two different command line options (/loadDll, /loadResources), or perhaps by different arguments to a single option (/load). For backwards compatibility, we could retain the old name that performs both features, or just require that people use both new options together.

Examples:

# Old style compatibility
outpost2.exe /loadmod cm1
# Split using different option names
# Load a DLL module, and resources from corresponding folder
outpost2.exe /loadDll cm1/op2mod.dll /loadResources cm1/
# Split using single option that detects parameter type
# Load a DLL module, and resources from corresponding folder
outpost2.exe /load cm1/op2mod.dll /load cm1/
# Only load DLL
outpost2.exe /load NetFix/NetFix.dll
# Only load resources
outpost2.exe /load GraphicsMod/GraphicsMod.vol

Essentially this would remove the concept of a module folder. A module would then just be a DLL to load. If there are associated resources to load, it can be handled by the module during initialization. If there is no DLL module to load, and only resources, then load just the resources.


Of course there may be a transition period where we don't yet offer API methods to handle extra resource loading during module initialization. In particular, there is no exported method to add a folder to the resource search path. There are also restrictions on when a VOL file can be loaded. For now, we can potentially work around that by using the old option name for compatibility, or by specifying new options for both module loading and resource loading.


Related: In PR #227 there was a suggestion to allow alternative names for console module DLLs. This would allow that.