本文整理汇总了C++中CDesignType::GetUNID方法的典型用法代码示例。如果您正苦于以下问题:C++ CDesignType::GetUNID方法的具体用法?C++ CDesignType::GetUNID怎么用?C++ CDesignType::GetUNID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDesignType
的用法示例。
在下文中一共展示了CDesignType::GetUNID方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateTemplateTypes
ALERROR CDesignCollection::CreateTemplateTypes (SDesignLoadCtx &Ctx)
// CreateTemplateTypes
//
// This is called inside of BindDesign to create all template types
{
ALERROR error;
int i;
// Create an appropriate context for running code
CCodeChainCtx CCCtx;
// Loop over all active types looking for templates.
// NOTE: We cannot use the type-specific arrays because they have not been
// set up yet (remember that we are inside of BindDesign).
for (i = 0; i < m_AllTypes.GetCount(); i++)
{
CDesignType *pTemplate = m_AllTypes.GetEntry(i);
if (pTemplate->GetType() != designTemplateType)
continue;
// Get the function to generate the type source
CString sSource;
SEventHandlerDesc Event;
if (pTemplate->FindEventHandler(GET_TYPE_SOURCE_EVENT, &Event))
{
ICCItem *pResult = CCCtx.Run(Event);
if (pResult->IsError())
{
Ctx.sError = strPatternSubst(CONSTLIT("GetTypeSource (%x): %s"), pTemplate->GetUNID(), pResult->GetStringValue());
return ERR_FAIL;
}
else if (pResult->IsNil())
sSource = NULL_STR;
else
sSource = pResult->GetStringValue();
CCCtx.Discard(pResult);
}
// Define the type
if (!sSource.IsBlank())
{
if (error = AddDynamicType(pTemplate->GetExtension(), pTemplate->GetUNID(), sSource, true, &Ctx.sError))
return error;
}
}
return NOERROR;
}
示例2: GetEconomyUNIDOrDefault
ALERROR GetEconomyUNIDOrDefault (CCodeChain &CC, ICCItem *pItem, DWORD *retdwUNID)
{
if (pItem == NULL || pItem->IsNil())
{
if (retdwUNID)
*retdwUNID = 0;
}
else if (pItem->IsInteger())
{
CDesignType *pType = g_pUniverse->FindDesignType(pItem->GetIntegerValue());
if (pType == NULL)
return ERR_FAIL;
if (retdwUNID)
*retdwUNID = pType->GetUNID();
}
else
{
CEconomyType *pEconomy = g_pUniverse->FindEconomyType(pItem->GetStringValue());
if (pEconomy == NULL)
return ERR_FAIL;
if (retdwUNID)
*retdwUNID = pEconomy->GetUNID();
}
return NOERROR;
}
示例3: ResolveOverrides
ALERROR CDesignCollection::ResolveOverrides (SDesignLoadCtx &Ctx)
// ResolveOverrides
//
// Resolve all overrides
{
int i;
// Apply all overrides
for (i = 0; i < m_OverrideTypes.GetCount(); i++)
{
CDesignType *pOverride = m_OverrideTypes.GetEntry(i);
// Find the type that we are trying to override. If we can't find it
// then just continue without error (it means we're trying to override
// a type that doesn't currently exist).
CDesignType *pType = m_AllTypes.FindByUNID(pOverride->GetUNID());
if (pType == NULL)
continue;
// If this type is not already a clone then we need to clone it first
// (Because we never modify the original loaded type).
if (!pType->IsClone())
{
CDesignType *pClone;
pType->CreateClone(&pClone);
m_CreatedTypes.AddEntry(pClone);
pType = pClone;
}
// Now modify the type with the override
pType->MergeType(pOverride);
// Replace the original
m_AllTypes.AddOrReplaceEntry(pType);
}
// Done
return NOERROR;
}
示例4: FireOnGlobalUpdate
void CDesignCollection::FireOnGlobalUpdate (int iTick)
// FireOnGlobalUpdate
//
// Types get a chance to do whatever they want once every 15 ticks.
{
int i;
CString sError;
for (i = 0; i < m_EventsCache[evtOnGlobalUpdate]->GetCount(); i++)
{
SEventHandlerDesc Event;
CDesignType *pType = m_EventsCache[evtOnGlobalUpdate]->GetEntry(i, &Event);
if ((((DWORD)iTick + pType->GetUNID()) % GLOBAL_ON_UPDATE_CYCLE) == 0)
pType->FireOnGlobalUpdate(Event);
}
}
示例5: AccumulateSystem
void AccumulateSystem (CTopologyNode *pNode, CSystem *pSystem, TSortMap<DWORD, STypeInfo> &AllTypes)
{
int j;
int iSystemLevel = pSystem->GetLevel();
// Add the encounters to the appropriate tables
for (j = 0; j < pSystem->GetObjectCount(); j++)
{
CSpaceObject *pObj = pSystem->GetObject(j);
if (pObj)
{
// Add this encounter to the table
CDesignType *pType;
if ((pType = pObj->GetEncounterInfo()) || (pType = pObj->GetType()))
{
STypeInfo *pInfo = AllTypes.SetAt(pType->GetUNID());
pInfo->iTotalCount++;
pInfo->PerLevel[iSystemLevel]++;
}
// Enumerate the items in this object
CItemListManipulator ItemList(pObj->GetItemList());
ItemList.ResetCursor();
while (ItemList.MoveCursorForward())
{
const CItem &Item(ItemList.GetItemAtCursor());
if (!Item.IsInstalled() && !Item.IsDamaged())
{
STypeInfo *pInfo = AllTypes.SetAt(Item.GetType()->GetUNID());
pInfo->iTotalCount += Item.GetCount();
pInfo->PerLevel[iSystemLevel] += Item.GetCount();
}
}
}
}
}
示例6: OutputByShipClass
void OutputByShipClass (SItemTableCtx &Ctx, const SItemTypeList &ItemList, bool bShowUsage)
{
int i, j;
// Make a map of ship classes for each item
TSortMap<DWORD, TArray<CShipClass *>> ItemToShipClass;
for (i = 0; i < g_pUniverse->GetShipClassCount(); i++)
{
CShipClass *pClass = g_pUniverse->GetShipClass(i);
// Skip non-generic ones
if (!pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
continue;
// Add the list of types used by the ship
TSortMap<DWORD, bool> TypesUsed;
pClass->AddTypesUsed(&TypesUsed);
// For each item type, add it to the map
for (j = 0; j < TypesUsed.GetCount(); j++)
{
CDesignType *pType = g_pUniverse->FindDesignType(TypesUsed.GetKey(j));
if (pType && pType->GetType() == designItemType)
{
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
pList->Insert(pClass);
}
}
}
// If we want to show usage, then we print each item along with the
// ship classes using each item.
if (bShowUsage)
{
for (i = 0; i < ItemList.GetCount(); i++)
{
CItemType *pType = ItemList[i];
printf("%s\n", (LPSTR)pType->GetNounPhrase());
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
printf("\t%s\n", (LPSTR)pList->GetAt(j)->GetName());
if (pList->GetCount() == 0)
printf("\t(none)\n");
printf("\n");
}
}
// Otherwise we categorize by ship class
else
{
// Now make a list of all ship classes that have our items
SByShipClassTypeList ByShipClassTable;
for (i = 0; i < ItemList.GetCount(); i++)
{
const CString &sKey = ItemList.GetKey(i);
CItemType *pType = ItemList[i];
// Loop over all ship classes
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
{
CString sClassName = pList->GetAt(j)->GetName();
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(sClassName, &bNew);
if (bNew)
pEntry->sShipClassName = sClassName;
pEntry->ItemTable.Insert(sKey, pType);
}
// If no ship class
if (pList->GetCount() == 0)
{
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(CONSTLIT("(none)"), &bNew);
if (bNew)
pEntry->sShipClassName = CONSTLIT("(none)");
pEntry->ItemTable.Insert(sKey, pType);
}
}
// Now loop over all attributes
for (i = 0; i < ByShipClassTable.GetCount(); i++)
{
const SShipClassEntry &Entry = ByShipClassTable[i];
//.........这里部分代码省略.........
示例7: GenerateImageChart
//.........这里部分代码省略.........
NewEntry.iRotation = pClass->Angle2Direction(iRotation);
NewEntry.sSovereignName = (pClass->GetDefaultSovereign() ? pClass->GetDefaultSovereign()->GetTypeNounPhrase() : NULL_STR);
break;
}
case designStationType:
{
CStationType *pStationType = CStationType::AsType(pType);
// Skip generic classes
if (!bAll && !pStationType->HasLiteralAttribute(CONSTLIT("generic")))
continue;
NewEntry.pType = pType;
NewEntry.sName = pStationType->GetNounPhrase(0);
NewEntry.iSize = pStationType->GetSize();
NewEntry.sSovereignName = (pStationType->GetSovereign() ? pStationType->GetSovereign()->GetTypeNounPhrase() : NULL_STR);
InitStationTypeImage(NewEntry, pStationType);
break;
}
default:
// Don't know how to handle this type
continue;
break;
}
// Adjust name
if (bFieldUNID)
NewEntry.sName = strPatternSubst(CONSTLIT("%s (%x)"), NewEntry.sName, NewEntry.pType->GetUNID());
// Compute the sort key
char szBuffer[1024];
switch (iOrder)
{
case orderLargest:
wsprintf(szBuffer, "%09d%s%x",
1000000 - NewEntry.iSize,
NewEntry.sName.GetASCIIZPointer(),
pType->GetUNID());
break;
case orderLevel:
wsprintf(szBuffer, "%09d%s%x",
pType->GetLevel(),
NewEntry.sName.GetASCIIZPointer(),
pType->GetUNID());
break;
case orderSmallest:
wsprintf(szBuffer, "%09d%s%x",
NewEntry.iSize,
NewEntry.sName.GetASCIIZPointer(),
pType->GetUNID());
break;
case orderSovereign:
wsprintf(szBuffer, "%s|%s|%x", NewEntry.sSovereignName.GetASCIIZPointer(), NewEntry.sName.GetASCIIZPointer(), pType->GetUNID());
NewEntry.sCategorize = NewEntry.sSovereignName;
break;
示例8: GenerateTypeIslands
void GenerateTypeIslands (CUniverse &Universe, CXMLElement *pCmdLine)
{
int i, j;
bool bExcludeImages = true;
printf("TYPE ISLANDS\n");
printf("------------\n\n");
// Make a list of default types
#if 0
g_DefaultTypes.SetAt(0x00001001, true); // independent sovereign
g_DefaultTypes.SetAt(0x00001002, true); // Commonwealth sovereign
g_DefaultTypes.SetAt(0x00001003, true); // independent sovereign
g_DefaultTypes.SetAt(0x00001007, true); // ares sovereign
g_DefaultTypes.SetAt(0x0000100c, true); // sung slavers sovereign
g_DefaultTypes.SetAt(0x0000100f, true); // auton sovereign
g_DefaultTypes.SetAt(0x00001011, true); // corporate hierarchy
g_DefaultTypes.SetAt(0x00004027, true); // container of frozen supplies
g_DefaultTypes.SetAt(0x0000402c, true); // pteracnium ore
g_DefaultTypes.SetAt(0x000040ae, true); // helium3 reactor assembly
g_DefaultTypes.SetAt(0x000040af, true); // pteracnium fuel
g_DefaultTypes.SetAt(0x000040ca, true); // lancer cannon
g_DefaultTypes.SetAt(0x000040e2, true); // worldship armor
g_DefaultTypes.SetAt(0x00004100, true); // xenotite ore
g_DefaultTypes.SetAt(0x00004109, true); // SN2500 reactor
g_DefaultTypes.SetAt(0x00004167, true); // tetramite ore
g_DefaultTypes.SetAt(0x00005004, true); // wreck ejecta
g_DefaultTypes.SetAt(0x0000500c, true); // blast explosion 2
g_DefaultTypes.SetAt(0x0000500d, true); // blast explosion 3
g_DefaultTypes.SetAt(0x0000500e, true); // blast explosion 4
g_DefaultTypes.SetAt(0x0000500f, true); // thermo explosion 1
g_DefaultTypes.SetAt(0x00005011, true); // thermo explosion 3
g_DefaultTypes.SetAt(0x00005012, true); // thermo explosion 4
g_DefaultTypes.SetAt(0x00009004, true); // shield effect
g_DefaultTypes.SetAt(0x00009007, true); // explosion effect
g_DefaultTypes.SetAt(0x0000900a, true); // fire effect
g_DefaultTypes.SetAt(0x0000A003, true); // dsAbandonedStation
g_DefaultTypes.SetAt(0x0000a017, true); // dock screen?
g_DefaultTypes.SetAt(0x001a200c, true); // wreck of the CSC Europa
g_DefaultTypes.SetAt(0x001a200e, true); // sandstorm wreck
g_DefaultTypes.SetAt(0x001c1002, true); // ares sect in Heretic
g_DefaultTypes.SetAt(0x08020102, true); // huari empire sovereign
g_DefaultTypes.SetAt(0x08040140, true); // gaian processor station
#endif
// Create a reverse index of all type dependencies
ReverseIndexMap ReverseIndex;
for (i = 0; i < Universe.GetDesignTypeCount(); i++)
{
CDesignType *pType = Universe.GetDesignType(i);
// Get the list of UNIDs that this type uses
TSortMap<DWORD, bool> TypesUsed;
pType->AddTypesUsed(&TypesUsed);
for (j = 0; j < TypesUsed.GetCount(); j++)
{
CDesignType *pRequired = Universe.FindDesignType(TypesUsed.GetKey(j));
if (pRequired == NULL)
continue;
// Add to reverse index
TArray<DWORD> *pList = ReverseIndex.SetAt(pRequired->GetUNID());
pList->Insert(pType->GetUNID());
}
}
// We create a list of islands. In each island, all the types refer to
// each other and don't refer to types on any other island.
TArray<IslandMap> AllIslands;
// Loop over all types and add them to an island.
for (i = 0; i < Universe.GetDesignTypeCount(); i++)
{
CDesignType *pType = Universe.GetDesignType(i);
// Exclude images
if (bExcludeImages && pType->GetType() == designImage)
continue;
if (pType->GetType() == designShipTable)
continue;
// Exclude default types
if (g_DefaultTypes.Find(pType->GetUNID()))
continue;
// If this type is already on one of the islands, then we skip it.
#if 0
bool bFound = false;
//.........这里部分代码省略.........
示例9: GenerateTypeDependencies
void GenerateTypeDependencies (CUniverse &Universe, CXMLElement *pCmdLine)
{
int i, j;
bool bRecursive = pCmdLine->GetAttributeBool(CONSTLIT("recursive"));
bool bReverse = pCmdLine->GetAttributeBool(CONSTLIT("reverse"));
// Create a reverse index of all type dependencies
TSortMap<DWORD, TArray<DWORD> > ReverseIndex;
// Types and what they use
if (!bReverse)
{
printf("TYPES AND WHAT THEY USE\n");
printf("-----------------------\n\n");
}
for (i = 0; i < Universe.GetDesignTypeCount(); i++)
{
CDesignType *pType = Universe.GetDesignType(i);
if (!bReverse)
printf("%s\n", (char *)GetTypeDesc(pType));
// Get the list of UNIDs that this type uses
TSortMap<DWORD, bool> TypesUsed;
if (bRecursive)
AddTypesUsedRecursive(Universe, pType->GetUNID(), &TypesUsed);
else
pType->AddTypesUsed(&TypesUsed);
// Output the list
for (j = 0; j < TypesUsed.GetCount(); j++)
{
CDesignType *pRequired = Universe.FindDesignType(TypesUsed.GetKey(j));
if (pRequired == NULL)
continue;
if (!bReverse)
printf("\t%s\n", (char *)GetTypeDesc(pRequired));
// Add to reverse index
TArray<DWORD> *pList = ReverseIndex.SetAt(pRequired->GetUNID());
pList->Insert(pType->GetUNID());
}
}
// Types and what depends on them
if (bReverse)
{
printf("\nTYPES AND WHAT USES THEM\n");
printf( "------------------------\n\n");
for (i = 0; i < ReverseIndex.GetCount(); i++)
{
CDesignType *pType = Universe.FindDesignType(ReverseIndex.GetKey(i));
if (pType == NULL)
continue;
printf("%s\n", (char *)GetTypeDesc(pType));
TArray<DWORD> &List = ReverseIndex.GetValue(i);
for (j = 0; j < List.GetCount(); j++)
{
CDesignType *pRequiredBy = Universe.FindDesignType(List[j]);
if (pRequiredBy)
printf("\t%s\n", (char *)GetTypeDesc(pRequiredBy));
}
}
}
}
示例10: GenerateTypeTable
void GenerateTypeTable (CUniverse &Universe, CXMLElement *pCmdLine)
{
int i, j;
// Get the criteria from the command line.
CString sCriteria = pCmdLine->GetAttribute(CRITERIA_ATTRIB);
// Parse it
CDesignTypeCriteria Criteria;
if (CDesignTypeCriteria::ParseCriteria(sCriteria, &Criteria) != NOERROR)
{
printf("ERROR: Unable to parse criteria.\n");
return;
}
// Generate a table of all matching types
TSortMap<CString, CDesignType *> Table;
// Loop over all items for this level and add them to
// a sorted table.
for (i = 0; i < Universe.GetDesignTypeCount(); i++)
{
CDesignType *pType = Universe.GetDesignType(i);
int iLevel = pType->GetLevel();
if (!pType->MatchesCriteria(Criteria))
continue;
// Get the name
CString sName = pType->GetDataField(FIELD_NAME);
if (*sName.GetASCIIZPointer() == '(')
sName = strSubString(sName, 1, -1);
// Figure out the sort order
char szBuffer[1024];
wsprintf(szBuffer, "%02d%s%08x",
iLevel,
sName.GetASCIIZPointer(),
pType->GetUNID());
Table.Insert(CString(szBuffer), pType);
}
// Generate a list of columns to display
TArray<CString> Cols;
Cols.Insert(FIELD_LEVEL);
Cols.Insert(FIELD_NAME);
for (i = 0; i < pCmdLine->GetAttributeCount(); i++)
{
CString sAttrib = pCmdLine->GetAttributeName(i);
if (!IsMainCommandParam(sAttrib)
&& !strEquals(sAttrib, CONSTLIT("typetable")))
{
CString sValue = pCmdLine->GetAttribute(i);
if (!strEquals(sValue, CONSTLIT("true")))
Cols.Insert(strPatternSubst(CONSTLIT("%s:%s"), sAttrib, sValue));
else
Cols.Insert(sAttrib);
}
}
// If we need to output total count, then load the table
CDesignTypeStats TotalCount;
if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT)
|| pCmdLine->GetAttributeBool(FIELD_COUNT_DISTRIBUTION))
{
if (LoadDesignTypeStats(Universe.GetDesignCollection().GetAdventureUNID(), &TotalCount) != NOERROR)
{
printf("ERROR: Unable to load type count table.\n");
return;
}
}
// If we've got any entries in the table, output now
if (Table.GetCount())
{
// Output the header
for (j = 0; j < Cols.GetCount(); j++)
{
if (j != 0)
printf("\t");
printf(Cols[j].GetASCIIZPointer());
}
printf("\n");
// Output each row
//.........这里部分代码省略.........
示例11: GenerateSimTables
void GenerateSimTables (CUniverse &Universe, CXMLElement *pCmdLine)
{
ALERROR error;
int i, j, k;
int iSystemSample = pCmdLine->GetAttributeInteger(CONSTLIT("count"));
if (iSystemSample == 0)
iSystemSample = DEFAULT_SYSTEM_SAMPLE;
// Keep track of stats for each type
TSortMap<DWORD, STypeStats> AllStats;
for (i = 0; i < iSystemSample; i++)
{
TSortMap<DWORD, STypeInfo> AllTypes;
printf("sample %d...\n", i+1);
// Initialize the game
CString sError;
if (error = Universe.InitGame(0, &sError))
{
printf("%s\n", sError.GetASCIIZPointer());
return;
}
// Loop over all nodes
for (j = 0; j < Universe.GetTopologyNodeCount(); j++)
{
CTopologyNode *pNode = Universe.GetTopologyNode(j);
// Skip end game nodes
if (pNode->IsEndGame())
continue;
// Create the system
CSystem *pSystem;
if (error = Universe.CreateStarSystem(pNode, &pSystem, &sError))
{
printf("ERROR: Unable to create star system: %s\n", sError.GetASCIIZPointer());
return;
}
// Accumulate
AccumulateSystem(pNode, pSystem, AllTypes);
// Done with old system
Universe.DestroySystem(pSystem);
}
// Now accumulate all stats
for (j = 0; j < Universe.GetDesignTypeCount(); j++)
{
CDesignType *pType = Universe.GetDesignType(j);
STypeStats *pStats = AllStats.SetAt(pType->GetUNID());
STypeInfo *pTypeInfo = AllTypes.GetAt(pType->GetUNID());
if (pTypeInfo)
{
pStats->PerGame.Insert(pTypeInfo->iTotalCount);
for (k = 0; k < MAX_TECH_LEVEL; k++)
pStats->PerLevel[k].Insert(pTypeInfo->PerLevel[k]);
}
else
{
pStats->PerGame.Insert(0);
for (k = 0; k < MAX_TECH_LEVEL; k++)
pStats->PerLevel[k].Insert(0);
}
}
Universe.Reinit();
}
// Output
if (error = OutputTypeTable(AllStats, iSystemSample))
return;
// Create a table with the sum of all items for the game
printf("Total count statistic computed.\n");
}
示例12: BindDesign
ALERROR CDesignCollection::BindDesign (SDesignLoadCtx &Ctx)
// BindDesign
//
// Bind the design collection so that design types point the appropriate
// pointers by UNID
{
ALERROR error;
int i, j;
// Unbind everything
for (i = 0; i < m_AllTypes.GetCount(); i++)
m_AllTypes.GetEntry(i)->UnbindDesign();
m_AllTypes.DeleteAll();
// Reset the bind tables
for (i = 0; i < designCount; i++)
m_ByType[i].DeleteAll();
// We start with all the base types
for (i = 0; i < m_Base.GetCount(); i++)
m_AllTypes.AddEntry(m_Base.GetEntry(i));
// Start with base topology
m_pTopology = &m_BaseTopology;
m_pAdventureExtension = NULL;
// Now add all enabled extensions
for (i = 0; i < GetExtensionCount(); i++)
{
SExtensionDesc *pExtension = GetExtension(i);
if (pExtension->bEnabled)
{
// Add design elements in extension
for (j = 0; j < pExtension->Table.GetCount(); j++)
{
CDesignType *pEntry = pExtension->Table.GetEntry(j);
m_AllTypes.AddOrReplaceEntry(pEntry);
}
// Handle adventure extensions
if (pExtension->iType == extAdventure)
{
// Keep track of extension
m_pAdventureExtension = pExtension;
// Add topology
m_pTopology = &pExtension->Topology;
}
}
else
{
if (pExtension->iType == extAdventure)
{
DWORD dwCoverImage = 0;
// Adventure desc elements are added even if not enabled
for (j = 0; j < pExtension->Table.GetCount(); j++)
{
CDesignType *pEntry = pExtension->Table.GetEntry(j);
if (pEntry->GetType() == designAdventureDesc)
{
m_AllTypes.AddOrReplaceEntry(pEntry);
// Get the cover image used by the adventure, because
// we need to load that too.
CAdventureDesc *pDesc = CAdventureDesc::AsType(pEntry);
dwCoverImage = pDesc->GetBackgroundUNID();
}
}
// Make sure we load the cover image
if (dwCoverImage)
{
for (j = 0; j < pExtension->Table.GetCount(); j++)
{
CDesignType *pEntry = pExtension->Table.GetEntry(j);
if (pEntry->GetUNID() == dwCoverImage)
m_AllTypes.AddOrReplaceEntry(pEntry);
}
}
}
}
}
// If this is a new game, then create all the Template types
//.........这里部分代码省略.........
示例13: LoadDesignType
ALERROR CExtension::LoadDesignType (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CDesignType **retpType)
// LoadDesignType
//
// Loads a standard design type
{
ALERROR error;
CDesignType *pType = NULL;
// Load topology
if (strEquals(pDesc->GetTag(), STAR_SYSTEM_TOPOLOGY_TAG)
|| strEquals(pDesc->GetTag(), SYSTEM_TOPOLOGY_TAG))
{
if (error = m_Topology.LoadFromXML(Ctx, pDesc, NULL, NULL_STR))
return error;
}
// <Sound>
else if (strEquals(pDesc->GetTag(), SOUND_TAG))
return LoadSoundElement(Ctx, pDesc);
// <Globals>
else if (strEquals(pDesc->GetTag(), GLOBALS_TAG))
return LoadGlobalsElement(Ctx, pDesc);
// <Library>
else if (strEquals(pDesc->GetTag(), LIBRARY_TAG))
return LoadLibraryElement(Ctx, pDesc);
// <Module>
else if (strEquals(pDesc->GetTag(), MODULE_TAG))
return LoadModuleElement(Ctx, pDesc);
// <Modules>
else if (strEquals(pDesc->GetTag(), MODULES_TAG))
return LoadModulesElement(Ctx, pDesc);
// Load standard design elements
else
{
if (error = CDesignType::CreateFromXML(Ctx, pDesc, &pType))
return error;
DWORD dwUNID = pType->GetUNID();
// Can't use the reserved range
if (IsReservedUNID(dwUNID))
{
Ctx.sError = strPatternSubst(CONSTLIT("Cannot use reserved UNID: %x"), dwUNID);
return ERR_FAIL;
}
// Add to our list
if (error = m_DesignTypes.AddEntry(pType))
{
if (error == ERR_OUTOFROOM)
{
// For backwards compatibility with earlier versions, we
// disable this message.
if (Ctx.GetAPIVersion() >= 12)
{
Ctx.sError = strPatternSubst(CONSTLIT("Duplicate UNID: %x"), dwUNID);
return error;
}
}
else
{
Ctx.sError = strPatternSubst(CONSTLIT("Error adding design entry UNID: %x"), dwUNID);
return error;
}
}
// Let this type add external definitions
pType->AddExternals(&m_Externals);
}
// Done
if (retpType)
*retpType = pType;
return NOERROR;
}