Do not put folder local defs into Game.DefinitionFilenames

Instead, rely on Origin pointing to them in savegames.
Günther Brammer 2011-05-15 19:51:34 +02:00
parent 9271365b18
commit c857c1770b
4 changed files with 36 additions and 41 deletions

View File

@ -242,9 +242,6 @@ bool C4Game::OpenScenario()
}
if (pGrp) delete pGrp;*/
// Scan folder local definitions
SAddModules(DefinitionFilenames,FoldersWithLocalsDefs(ScenarioFilename));
// Check mission access
if (C4S.Head.MissionAccess[0])
if (!SIsModule(Config.General.MissionAccess, C4S.Head.MissionAccess))
@ -3054,40 +3051,6 @@ bool C4Game::CheckObjectEnumeration()
return true;
}
const char* C4Game::FoldersWithLocalsDefs(const char *szPath)
{
static char szDefs[10*_MAX_PATH+1];
szDefs[0]=0;
// Scan path for folder names
int32_t cnt,iBackslash;
char szFoldername[_MAX_PATH+1];
C4Group hGroup;
for (cnt=0; (iBackslash=SCharPos(DirectorySeparator,szPath,cnt)) > -1; cnt++)
{
// Get folder name
SCopy(szPath,szFoldername,iBackslash);
// Open folder
if (SEqualNoCase(GetExtension(szFoldername),"ocf"))
if (hGroup.Open(szFoldername))
{
// Check for contained defs
// do not, however, add them to the group set:
// parent folders are added by OpenScenario already!
int32_t iContents;
if ((iContents = GroupSet.CheckGroupContents(hGroup, C4GSCnt_Definitions)))
{
// Add folder to list
SNewSegment(szDefs); SAppend(szFoldername,szDefs);
}
// Close folder
hGroup.Close();
}
}
return szDefs;
}
void C4Game::InitValueOverloads()
{
C4ID idOvrl; C4Def *pDef;

View File

@ -243,7 +243,6 @@ protected:
void DeleteObjects(bool fDeleteInactive);
void ExecObjects();
void Ticks();
const char *FoldersWithLocalsDefs(const char *szPath);
bool CheckObjectEnumeration();
bool LoadScenarioComponents();
bool LoadScenarioScripts();

View File

@ -219,7 +219,36 @@ void C4GameResList::Clear()
iResCount = iResCapacity = 0;
}
bool C4GameResList::Load(const char *szDefinitionFilenames)
void C4GameResList::LoadFoldersWithLocalDefs(const char *szPath)
{
// Scan path for folder names
int32_t cnt,iBackslash;
char szFoldername[_MAX_PATH+1];
C4Group hGroup;
for (cnt=0; (iBackslash=SCharPos(DirectorySeparator,szPath,cnt)) > -1; cnt++)
{
// Get folder name
SCopy(szPath,szFoldername,iBackslash);
// Open folder
if (SEqualNoCase(GetExtension(szFoldername),"ocf"))
if (hGroup.Open(szFoldername))
{
// Check for contained defs
// do not, however, add them to the group set:
// parent folders are added by OpenScenario already!
int32_t iContents;
if ((iContents = Game.GroupSet.CheckGroupContents(hGroup, C4GSCnt_Definitions)))
{
// Add folder to list
CreateByFile(NRT_Definitions, szFoldername);
}
// Close folder
hGroup.Close();
}
}
}
bool C4GameResList::Load(C4Group &hGroup, C4Scenario *pScenario, const char * szDefinitionFilenames)
{
// clear any prev
Clear();
@ -232,6 +261,9 @@ bool C4GameResList::Load(const char *szDefinitionFilenames)
if (*szSegment)
CreateByFile(NRT_Definitions, szSegment);
}
LoadFoldersWithLocalDefs(pScenario->Head.Origin ? pScenario->Head.Origin.getData() : hGroup.GetFullName().getData());
// add System.ocg
CreateByFile(NRT_System, C4CFN_System);
// add all instances of Material.ocg, except those inside the scenario file
@ -368,7 +400,7 @@ bool C4GameParameters::Load(C4Group &hGroup, C4Scenario *pScenario, const char *
Scenario.SetFile(NRT_Scenario, hGroup.GetFullName().getData());
// Additional game resources
if (!GameRes.Load(DefinitionFilenames))
if (!GameRes.Load(hGroup, pScenario, DefinitionFilenames))
return false;
// Player infos (replays only)

View File

@ -81,7 +81,7 @@ public:
C4GameRes *iterRes(C4GameRes *pLast, C4Network2ResType eType = NRT_Null);
void Clear();
bool Load(const char *szDefinitionFilenames); // host: create res cores by definition filenames
bool Load(C4Group &hGroup, C4Scenario *pScenario, const char * szDefinitionFilenames); // host: create res cores by definition filenames
C4GameRes *CreateByFile(C4Network2ResType eType, const char *szFile);
C4GameRes *CreateByNetRes(C4Network2Res::Ref pNetRes);
@ -95,6 +95,7 @@ public:
protected:
void Add(C4GameRes *pRes);
void LoadFoldersWithLocalDefs(const char *szPath);
};
class C4GameParameters