Skip to content

Commit bd2699a

Browse files
authored
feat(ini): Implement optional INI lookup folders for all common game systems (#1476)
For example the game will now not only load Data\INI\Armor.ini but also all *.ini files in Data\INI\Armor
1 parent 85fdc80 commit bd2699a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+355
-239
lines changed

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,22 @@ AudioManager::~AudioManager()
213213
void AudioManager::init()
214214
{
215215
INI ini;
216-
ini.load( AsciiString( "Data\\INI\\AudioSettings.ini" ), INI_LOAD_OVERWRITE, NULL);
216+
ini.loadFileDirectory( AsciiString( "Data\\INI\\AudioSettings" ), INI_LOAD_OVERWRITE, NULL);
217217

218-
ini.load( AsciiString( "Data\\INI\\Default\\Music.ini" ), INI_LOAD_OVERWRITE, NULL );
219-
ini.load( AsciiString( "Data\\INI\\Music.ini" ), INI_LOAD_OVERWRITE, NULL );
218+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Default\\Music" ), INI_LOAD_OVERWRITE, NULL );
219+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Music" ), INI_LOAD_OVERWRITE, NULL );
220220

221-
ini.load( AsciiString( "Data\\INI\\Default\\SoundEffects.ini" ), INI_LOAD_OVERWRITE, NULL );
222-
ini.load( AsciiString( "Data\\INI\\SoundEffects.ini" ), INI_LOAD_OVERWRITE, NULL );
221+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Default\\SoundEffects" ), INI_LOAD_OVERWRITE, NULL );
222+
ini.loadFileDirectory( AsciiString( "Data\\INI\\SoundEffects" ), INI_LOAD_OVERWRITE, NULL );
223223

224-
ini.load( AsciiString( "Data\\INI\\Default\\Speech.ini" ), INI_LOAD_OVERWRITE, NULL );
225-
ini.load( AsciiString( "Data\\INI\\Speech.ini" ), INI_LOAD_OVERWRITE, NULL );
224+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Default\\Speech" ), INI_LOAD_OVERWRITE, NULL );
225+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Speech" ), INI_LOAD_OVERWRITE, NULL );
226226

227-
ini.load( AsciiString( "Data\\INI\\Default\\Voice.ini" ), INI_LOAD_OVERWRITE, NULL );
228-
ini.load( AsciiString( "Data\\INI\\Voice.ini" ), INI_LOAD_OVERWRITE, NULL );
227+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Default\\Voice" ), INI_LOAD_OVERWRITE, NULL );
228+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Voice" ), INI_LOAD_OVERWRITE, NULL );
229229

230-
// do the miscellaneous sound files last so that we find the audioeventrts associated with the events.
231-
ini.load( AsciiString( "Data\\INI\\MiscAudio.ini" ), INI_LOAD_OVERWRITE, NULL);
230+
// do the miscellaneous sound files last so that we find the AudioEventRTS associated with the events.
231+
ini.loadFileDirectory( AsciiString( "Data\\INI\\MiscAudio" ), INI_LOAD_OVERWRITE, NULL);
232232

233233
// determine if one of the music tracks exists. Since their now BIGd, one implies all.
234234
// If they don't exist, then attempt to load them from the CD.

Core/GameEngine/Source/GameClient/VideoPlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ void VideoPlayer::init( void )
182182
// Load this here so that WB doesn't have to link to BinkLib, costing us (potentially)
183183
// an extra license.
184184
INI ini;
185-
ini.load( AsciiString( "Data\\INI\\Default\\Video.ini" ), INI_LOAD_OVERWRITE, NULL );
186-
ini.load( AsciiString( "Data\\INI\\Video.ini" ), INI_LOAD_OVERWRITE, NULL );
185+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Default\\Video" ), INI_LOAD_OVERWRITE, NULL );
186+
ini.loadFileDirectory( AsciiString( "Data\\INI\\Video" ), INI_LOAD_OVERWRITE, NULL );
187187
}
188188

189189
//============================================================================

Core/Tools/MapCacheBuilder/Source/WinMain.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@
116116
static SubsystemInterfaceList _TheSubsystemList;
117117

118118
template<class SUBSYSTEM>
119-
void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = NULL, const char* path2 = NULL, const char* dirpath = NULL)
119+
void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = NULL, const char* path2 = NULL)
120120
{
121121
sysref = sys;
122-
_TheSubsystemList.initSubsystem(sys, path1, path2, dirpath, NULL);
122+
_TheSubsystemList.initSubsystem(sys, path1, path2, NULL);
123123
}
124124

125125
///////////////////////////////////////////////////////////////////////////////
@@ -257,31 +257,31 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
257257
initSubsystem(TheLocalFileSystem, (LocalFileSystem*)new Win32LocalFileSystem);
258258
initSubsystem(TheArchiveFileSystem, (ArchiveFileSystem*)new Win32BIGFileSystem);
259259
INI ini;
260-
initSubsystem(TheWritableGlobalData, new GlobalData(), "Data\\INI\\Default\\GameData.ini", "Data\\INI\\GameData.ini");
260+
initSubsystem(TheWritableGlobalData, new GlobalData(), "Data\\INI\\Default\\GameData", "Data\\INI\\GameData");
261261
initSubsystem(TheGameText, CreateGameTextInterface());
262-
initSubsystem(TheScienceStore, new ScienceStore(), "Data\\INI\\Default\\Science.ini", "Data\\INI\\Science.ini");
263-
initSubsystem(TheMultiplayerSettings, new MultiplayerSettings(), "Data\\INI\\Default\\Multiplayer.ini", "Data\\INI\\Multiplayer.ini");
264-
initSubsystem(TheTerrainTypes, new TerrainTypeCollection(), "Data\\INI\\Default\\Terrain.ini", "Data\\INI\\Terrain.ini");
265-
initSubsystem(TheTerrainRoads, new TerrainRoadCollection(), "Data\\INI\\Default\\Roads.ini", "Data\\INI\\Roads.ini");
262+
initSubsystem(TheScienceStore, new ScienceStore(), "Data\\INI\\Default\\Science", "Data\\INI\\Science");
263+
initSubsystem(TheMultiplayerSettings, new MultiplayerSettings(), "Data\\INI\\Default\\Multiplayer", "Data\\INI\\Multiplayer");
264+
initSubsystem(TheTerrainTypes, new TerrainTypeCollection(), "Data\\INI\\Default\\Terrain", "Data\\INI\\Terrain");
265+
initSubsystem(TheTerrainRoads, new TerrainRoadCollection(), "Data\\INI\\Default\\Roads", "Data\\INI\\Roads");
266266
initSubsystem(TheScriptEngine, (ScriptEngine*)(new ScriptEngine()));
267267
initSubsystem(TheAudio, (AudioManager*)new MilesAudioManager());
268268
initSubsystem(TheVideoPlayer, (VideoPlayerInterface*)(new VideoPlayer()));
269269
initSubsystem(TheModuleFactory, (ModuleFactory*)(new W3DModuleFactory()));
270270
initSubsystem(TheSidesList, new SidesList());
271271
initSubsystem(TheCaveSystem, new CaveSystem());
272-
initSubsystem(TheRankInfoStore, new RankInfoStore(), NULL, "Data\\INI\\Rank.ini");
273-
initSubsystem(ThePlayerTemplateStore, new PlayerTemplateStore(), "Data\\INI\\Default\\PlayerTemplate.ini", "Data\\INI\\PlayerTemplate.ini");
274-
initSubsystem(TheSpecialPowerStore, new SpecialPowerStore(), "Data\\INI\\Default\\SpecialPower.ini", "Data\\INI\\SpecialPower.ini" );
272+
initSubsystem(TheRankInfoStore, new RankInfoStore(), NULL, "Data\\INI\\Rank");
273+
initSubsystem(ThePlayerTemplateStore, new PlayerTemplateStore(), "Data\\INI\\Default\\PlayerTemplate", "Data\\INI\\PlayerTemplate");
274+
initSubsystem(TheSpecialPowerStore, new SpecialPowerStore(), "Data\\INI\\Default\\SpecialPower", "Data\\INI\\SpecialPower" );
275275
initSubsystem(TheParticleSystemManager, (ParticleSystemManager*)(new W3DParticleSystemManager()));
276-
initSubsystem(TheFXListStore, new FXListStore(), "Data\\INI\\Default\\FXList.ini", "Data\\INI\\FXList.ini");
277-
initSubsystem(TheWeaponStore, new WeaponStore(), NULL, "Data\\INI\\Weapon.ini");
278-
initSubsystem(TheObjectCreationListStore, new ObjectCreationListStore(), "Data\\INI\\Default\\ObjectCreationList.ini", "Data\\INI\\ObjectCreationList.ini");
279-
initSubsystem(TheLocomotorStore, new LocomotorStore(), NULL, "Data\\INI\\Locomotor.ini");
280-
initSubsystem(TheDamageFXStore, new DamageFXStore(), NULL, "Data\\INI\\DamageFX.ini");
281-
initSubsystem(TheArmorStore, new ArmorStore(), NULL, "Data\\INI\\Armor.ini");
282-
initSubsystem(TheThingFactory, new ThingFactory(), "Data\\INI\\Default\\Object.ini", NULL, "Data\\INI\\Object");
283-
initSubsystem(TheCrateSystem, new CrateSystem(), "Data\\INI\\Default\\Crate.ini", "Data\\INI\\Crate.ini");
284-
initSubsystem(TheUpgradeCenter, new UpgradeCenter, "Data\\INI\\Default\\Upgrade.ini", "Data\\INI\\Upgrade.ini");
276+
initSubsystem(TheFXListStore, new FXListStore(), "Data\\INI\\Default\\FXList", "Data\\INI\\FXList");
277+
initSubsystem(TheWeaponStore, new WeaponStore(), NULL, "Data\\INI\\Weapon");
278+
initSubsystem(TheObjectCreationListStore, new ObjectCreationListStore(), "Data\\INI\\Default\\ObjectCreationList", "Data\\INI\\ObjectCreationList");
279+
initSubsystem(TheLocomotorStore, new LocomotorStore(), NULL, "Data\\INI\\Locomotor");
280+
initSubsystem(TheDamageFXStore, new DamageFXStore(), NULL, "Data\\INI\\DamageFX");
281+
initSubsystem(TheArmorStore, new ArmorStore(), NULL, "Data\\INI\\Armor");
282+
initSubsystem(TheThingFactory, new ThingFactory(), "Data\\INI\\Default\\Object", "Data\\INI\\Object");
283+
initSubsystem(TheCrateSystem, new CrateSystem(), "Data\\INI\\Default\\Crate", "Data\\INI\\Crate");
284+
initSubsystem(TheUpgradeCenter, new UpgradeCenter, "Data\\INI\\Default\\Upgrade", "Data\\INI\\Upgrade");
285285
initSubsystem(TheAnim2DCollection, new Anim2DCollection ); //Init's itself.
286286

287287
_TheSubsystemList.postProcessLoadAll();

Generals/Code/GameEngine/Include/Common/INI.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,19 @@ class INI
173173
INI();
174174
~INI();
175175

176-
void loadDirectory( AsciiString dirName, Bool subdirs, INILoadType loadType, Xfer *pXfer ); ///< load directory of INI files
177-
void load( AsciiString filename, INILoadType loadType, Xfer *pXfer ); ///< load INI file
176+
// TheSuperHackers @feature xezon 19/08/2025
177+
// Load a specific INI file by name and/or INI files from a directory (and its subdirectories).
178+
// For example "Data\INI\Armor" loads "Data\INI\Armor.ini" and all *.ini files in "Data\INI\Armor".
179+
// Throws if not a single INI file is found or one is not read correctly.
180+
UnsignedInt loadFileDirectory( AsciiString fileDirName, INILoadType loadType, Xfer *pXfer, Bool subdirs = TRUE );
181+
182+
// Load INI files from a directory (and its subdirectories).
183+
// Throws if one INI file is not read correctly.
184+
UnsignedInt loadDirectory( AsciiString dirName, INILoadType loadType, Xfer *pXfer, Bool subdirs = TRUE );
185+
186+
// Load one specific INI file by name.
187+
// Throws if the INI file is not found or is not read correctly.
188+
UnsignedInt load( AsciiString filename, INILoadType loadType, Xfer *pXfer );
178189

179190
static Bool isDeclarationOfType( AsciiString blockType, AsciiString blockName, char *bufferToCheck );
180191
static Bool isEndOfBlock( char *bufferToCheck );

Generals/Code/GameEngine/Include/Common/SubsystemInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class SubsystemInterfaceList
146146
SubsystemInterfaceList();
147147
~SubsystemInterfaceList();
148148

149-
void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, const char* dirpath, Xfer *pXfer, AsciiString name="");
149+
void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer *pXfer, AsciiString name="");
150150
void addSubsystem(SubsystemInterface* sys);
151151
void removeSubsystem(SubsystemInterface* sys);
152152
void postProcessLoadAll();

0 commit comments

Comments
 (0)