예제 #1
0
ALERROR CObjectImageArray::InitFromXML (CXMLElement *pDesc)

//	InitFromXML

	{
	SDesignLoadCtx Ctx;

	return InitFromXML(Ctx, pDesc, true);
	}
예제 #2
0
ALERROR CUniverse::Init (const CString &sFilespec, CString *retsError, DWORD dwFlags)

//	Init
//
//	Initializes either from an XML file or from a TDB

	{
	ALERROR error;

	CResourceDb Resources(sFilespec);
	if (error = Resources.Open(DFOPEN_FLAG_READ_ONLY))
		{
		*retsError = CONSTLIT("Unable to initialize Transcendence");
		return error;
		}

	if (Resources.IsUsingExternalGameFile())
		kernelDebugLogMessage("Using external Transcendence.xml");

	if (Resources.IsUsingExternalResources())
		kernelDebugLogMessage("Using external resource files");

	CXMLElement *pGameFile;
	if (error = Resources.LoadGameFile(&pGameFile, retsError))
		return error;

	SDesignLoadCtx Ctx;
	Ctx.sResDb = sFilespec;
	Ctx.pResDb = &Resources;
	Ctx.bNoResources = ((dwFlags & flagNoResources) ? true : false);
	Ctx.bNoVersionCheck = ((dwFlags & flagNoVersionCheck) ? true : false);

	//	Remember the resource Db for deferred loads

	m_sResourceDb = sFilespec;

	//	Initialize the universe

	if (error = InitFromXML(Ctx, pGameFile, Resources))
		goto Fail;

	//	Load extensions

	if (error = InitExtensions(Ctx, sFilespec))
		goto Fail;

	//	Done loading design elements

	if (error = BindDesign(Ctx))
		goto Fail;

	//	Done

	delete pGameFile;
	return NOERROR;

Fail:

	*retsError = Ctx.sError;
	return error;
	}