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(); } } } } }
bool CAeonEngine::OpenTableDefinitions (void) // OpenTableDefinitions // // Opens and reads all tables in all volumes. Note that we have no idea what // could have happened since our last boot--someone could have copied files // all over the place. We make almost no assumptions. { CSmartLock Lock(m_cs); int i, j; CString sError; // Loop over all volumes and end up with a list of tables and volumes TSortMap<CString, TArray<CString>> Tables; for (i = 0; i < m_LocalVolumes.GetCount(); i++) { CString sVolume = m_LocalVolumes.GetVolume(i); TArray<CString> Dirs; fileGetFileList(fileAppend(m_LocalVolumes.GetPath(i), FILESPEC_TABLE_DIR_FILTER), FFL_FLAG_DIRECTORIES_ONLY | FFL_FLAG_RELATIVE_FILESPEC, &Dirs); for (j = 0; j < Dirs.GetCount(); j++) { TArray<CString> *pList = Tables.SetAt(Dirs[j]); pList->Insert(sVolume); } } // Open all tables for (i = 0; i < Tables.GetCount(); i++) { CString sName = Tables.GetKey(i); CAeonTable *pTable = new CAeonTable; if (!pTable->Open(GetProcessCtx(), &m_LocalVolumes, sName, Tables[i], &sError)) { Log(MSG_LOG_ERROR, strPattern("Unable to load %s: %s", sName, sError)); delete pTable; continue; } m_Tables.Insert(sName, pTable); } // Done return true; }
void GenerateEncounterCount (CUniverse &Universe, CXMLElement *pCmdLine) { int i, j, k, l; // Options int iSystemSample = pCmdLine->GetAttributeIntegerBounded(CONSTLIT("count"), 1, -1, 1); bool bLogo = !pCmdLine->GetAttributeBool(CONSTLIT("noLogo")); bool bAll = pCmdLine->GetAttributeBool(CONSTLIT("all")); // Additional columns TArray<CString> Cols; for (i = 0; i < pCmdLine->GetAttributeCount(); i++) { CString sAttrib = pCmdLine->GetAttributeName(i); if (!IsMainCommandParam(sAttrib) && !strEquals(sAttrib, CONSTLIT("count")) && !strEquals(sAttrib, CONSTLIT("encountercount"))) { CString sValue = pCmdLine->GetAttribute(i); if (!strEquals(sValue, CONSTLIT("true"))) Cols.Insert(strPatternSubst(CONSTLIT("%s:%s"), sAttrib, sValue)); else Cols.Insert(sAttrib); } } // Generate systems for multiple games TSortMap<CString, SNodeDesc> NodeTable; for (i = 0; i < iSystemSample; i++) { if (bLogo) printf("pass %d...\n", i+1); // Initialize the game CString sError; if (Universe.InitGame(0, &sError) != NOERROR) { printf("%s\n", sError.GetASCIIZPointer()); return; } for (j = 0; j < Universe.GetTopologyNodeCount(); j++) { CTopologyNode *pNode = Universe.GetTopologyNode(j); if (pNode->IsEndGame()) continue; // Create the system CSystem *pSystem; if (Universe.CreateStarSystem(pNode, &pSystem) != NOERROR) { printf("ERROR: Unable to create star system.\n"); return; } // Create a sort string for this system CString sSort = strPatternSubst(CONSTLIT("%02d-%s"), pSystem->GetLevel(), pNode->GetID()); // Get the table bool bNew; SNodeDesc *pResult = NodeTable.SetAt(sSort, &bNew); if (bNew) { pResult->iLevel = pNode->GetLevel(); pResult->sNodeID = pNode->GetID(); } // Accumulate data AddSystemData(pSystem, bAll, pResult); // Done with old system Universe.DestroySystem(pSystem); } Universe.Reinit(); } // Header printf("Level\tNode\tSystemType\tCategory\tSovereign\tEncounter\tCount"); for (i = 0; i < Cols.GetCount(); i++) printf("\t%s", Cols[i].GetASCIIZPointer()); printf("\n"); // Output all rows for (i = 0; i < NodeTable.GetCount(); i++) { for (j = 0; j < NodeTable[i].Table.GetCount(); j++) { CCountTable &Encounters = NodeTable[i].Table[j]; for (k = 0; k < Encounters.GetCount(); k++) { int iCount = Encounters[k] / iSystemSample; int iCountFrac = 1000 * (Encounters[k] % iSystemSample) / iSystemSample; CStationType *pEncounterType = Universe.FindStationType(Encounters.GetKey(k)); if (pEncounterType == NULL) continue; CSovereign *pSovereign = pEncounterType->GetControllingSovereign(); CString sSovereign = (pSovereign ? pSovereign->GetTypeName() : CONSTLIT("(Unknown)")); printf("%d\t%s\t0x%08x\t%s\t%s\t%s\t%d.%03d", NodeTable[i].iLevel, NodeTable[i].sNodeID.GetASCIIZPointer(), NodeTable[i].Table.GetKey(j), pEncounterType->GetDataField(CONSTLIT("category")).GetASCIIZPointer(), sSovereign.GetASCIIZPointer(), pEncounterType->GetName().GetASCIIZPointer(), iCount, iCountFrac); for (l = 0; l < Cols.GetCount(); l++) { CString sValue = pEncounterType->GetDataField(Cols[l]); printf("\t%s", sValue.GetASCIIZPointer()); } printf("\n"); } } } }
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]; printf("%s\n\n", Entry.sShipClassName.GetASCIIZPointer()); OutputHeader(Ctx); OutputTable(Ctx, Entry.ItemTable); printf("\n"); } } }
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)); } } } }
void CPlayerGameStats::GenerateGameStats (CGameStats &Stats, CSpaceObject *pPlayerShip, bool bGameOver) const // GenerateGameStats // // Generates a stats for everything we track { int j; CShip *pShip = (pPlayerShip ? pPlayerShip->AsShip() : NULL); if (pShip == NULL) return; CPlayerShipController *pPlayer = (CPlayerShipController *)pShip->GetController(); if (pPlayer == NULL) return; CSovereign *pPlayerSovereign = g_pUniverse->FindSovereign(g_PlayerSovereignUNID); if (pPlayerSovereign == NULL) return; // Base stats Stats.Insert(CONSTLIT("Genome"), strCapitalize(GetGenomeName(pPlayer->GetPlayerGenome()))); Stats.Insert(CONSTLIT("Score"), strFormatInteger(CalcEndGameScore(), -1, FORMAT_THOUSAND_SEPARATOR | FORMAT_UNSIGNED)); Stats.Insert(CONSTLIT("Ship class"), pShip->GetNounPhrase(0)); CTimeSpan Time = GetPlayTime(); if (!Time.IsBlank()) Stats.Insert(CONSTLIT("Time played"), Time.Format(NULL_STR)); #ifdef REAL_TIME Time = GetGameTime(); if (!Time.IsBlank()) Stats.Insert(CONSTLIT("Time elapsed in game"), Time.Format(NULL_STR)); #endif // Some combat stats CString sDestroyed = GetStat(ENEMY_SHIPS_DESTROYED_STAT); if (!sDestroyed.IsBlank()) Stats.Insert(CONSTLIT("Enemy ships destroyed"), sDestroyed, CONSTLIT("combat")); sDestroyed = GetStat(FRIENDLY_SHIPS_DESTROYED_STAT); if (!sDestroyed.IsBlank()) Stats.Insert(CONSTLIT("Friendly ships destroyed"), sDestroyed, CONSTLIT("combat")); sDestroyed = GetStat(ENEMY_STATIONS_DESTROYED_STAT); if (!sDestroyed.IsBlank()) Stats.Insert(CONSTLIT("Enemy stations destroyed"), sDestroyed, CONSTLIT("combat")); sDestroyed = GetStat(FRIENDLY_STATIONS_DESTROYED_STAT); if (!sDestroyed.IsBlank()) Stats.Insert(CONSTLIT("Friendly stations destroyed"), sDestroyed, CONSTLIT("combat")); // Add stat for every station destroyed CStatCounterArray CounterArray; CMapIterator i; m_StationStats.Reset(i); while (m_StationStats.HasMore(i)) { SStationTypeStats *pStats; DWORD dwUNID = m_StationStats.GetNext(i, &pStats); CStationType *pType = g_pUniverse->FindStationType(dwUNID); if (pType == NULL) continue; CString sName = pType->GetNounPhrase(0); CString sSort = strPatternSubst(CONSTLIT("%03d%s"), 100 - pType->GetLevel(), sName); if (pType->GetSovereign()->IsEnemy(pPlayerSovereign)) CounterArray.Insert(sName, pStats->iDestroyed, CONSTLIT("Enemy stations destroyed"), sSort); else CounterArray.Insert(sName, pStats->iDestroyed, CONSTLIT("Friendly stations destroyed"), sSort); } CounterArray.GenerateGameStats(Stats); // Add stat for every ship class destroyed CounterArray.DeleteAll(); m_ShipStats.Reset(i); while (m_ShipStats.HasMore(i)) { SShipClassStats *pStats; DWORD dwUNID = m_ShipStats.GetNext(i, &pStats); CShipClass *pClass = g_pUniverse->FindShipClass(dwUNID); if (pClass == NULL) continue; CString sName = pClass->GetNounPhrase(0); CString sSort = strPatternSubst(CONSTLIT("%09d%s"), 100000000 - pClass->GetScore(), sName); if (pStats->iEnemyDestroyed > 0) CounterArray.Insert(sName, pStats->iEnemyDestroyed, CONSTLIT("Enemy ships destroyed"), sSort); if (pStats->iFriendDestroyed > 0) CounterArray.Insert(sName, pStats->iFriendDestroyed, CONSTLIT("Friendly ships destroyed"), sSort); } CounterArray.GenerateGameStats(Stats); // Add stat for every weapon fired m_ItemStats.Reset(i); while (m_ItemStats.HasMore(i)) { SItemTypeStats *pStats; DWORD dwUNID = m_ItemStats.GetNext(i, &pStats); CItemType *pItemType = g_pUniverse->FindItemType(dwUNID); if (pItemType == NULL) continue; CString sName = pItemType->GetNounPhrase(nounShort); CString sSort = strPatternSubst(CONSTLIT("%03d%s"), 100 - pItemType->GetLevel(), sName); // Installed items if (pStats->dwFirstInstalled != INVALID_TIME) Stats.Insert(sName, NULL_STR, CONSTLIT("Items installed"), sSort); if (pStats->iCountFired > 0) Stats.Insert(sName, strFormatInteger(pStats->iCountFired, -1, FORMAT_THOUSAND_SEPARATOR | FORMAT_UNSIGNED), CONSTLIT("Weapons fired"), sSort); } // Stats for player equipment (but only if the game is done) if (bGameOver) { TSortMap<CString, CItem> InstalledItems; // First we generate a sorted list of installed items // (We do this in case there are multiple of the same device/armor so that // we can coalesce them together into a single line). CItemListManipulator ItemList(pShip->GetItemList()); ItemList.ResetCursor(); while (ItemList.MoveCursorForward()) { const CItem &Item(ItemList.GetItemAtCursor()); if (Item.IsInstalled()) { CString sEnhancement = Item.GetEnhancedDesc(pShip); CString sItemName = Item.GetNounPhrase(nounActual | nounCountOnly | nounShort); CString sLine = (sEnhancement.IsBlank() ? sItemName : strPatternSubst(CONSTLIT("%s [%s]"), sItemName, sEnhancement)); bool bInserted; CItem *pEntry = InstalledItems.SetAt(sLine, &bInserted); if (bInserted) { *pEntry = Item; pEntry->SetCount(1); } else pEntry->SetCount(pEntry->GetCount() + 1); } } // Now add all the installed items to the stats for (j = 0; j < InstalledItems.GetCount(); j++) { // Redo the line now that we know the proper count CString sEnhancement = InstalledItems[j].GetEnhancedDesc(pShip); CString sItemName = InstalledItems[j].GetNounPhrase(nounActual | nounCountOnly); CString sLine = (sEnhancement.IsBlank() ? sItemName : strPatternSubst(CONSTLIT("%s [%s]"), sItemName, sEnhancement)); // Compute the sort order int iOrder; switch (InstalledItems[j].GetType()->GetCategory()) { case itemcatWeapon: iOrder = 0; break; case itemcatLauncher: iOrder = 1; break; case itemcatShields: iOrder = 2; break; case itemcatArmor: iOrder = 3; break; case itemcatReactor: iOrder = 4; break; case itemcatDrive: iOrder = 5; break; default: iOrder = 6; break; } CString sSort = strPatternSubst(CONSTLIT("%d%03d%s"), iOrder, 100 - InstalledItems[j].GetType()->GetLevel(), sLine); Stats.Insert(sLine, NULL_STR, CONSTLIT("Final equipment"), sSort); } // Add the remaining items ItemList.ResetCursor(); while (ItemList.MoveCursorForward()) { const CItem &Item(ItemList.GetItemAtCursor()); if (!Item.IsInstalled()) { CString sEnhancement = Item.GetEnhancedDesc(pShip); CString sItemName = Item.GetNounPhrase(nounActual | nounCountOnly); CString sLine = (sEnhancement.IsBlank() ? sItemName : strPatternSubst(CONSTLIT("%s [%s]"), sItemName, sEnhancement)); CString sSort = strPatternSubst(CONSTLIT("%03d%s"), 100 - Item.GetType()->GetLevel(), sLine); Stats.Insert(sLine, NULL_STR, CONSTLIT("Final items"), sSort); } } } }
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"); }
void GenerateEncounterFrequency (CUniverse &Universe, CXMLElement *pCmdLine) { enum ETypes { outputFreq, outputFillLocations, }; int i, j; // Options int iSystemSample = pCmdLine->GetAttributeIntegerBounded(CONSTLIT("count"), 1, -1, 1); bool bLogo = !pCmdLine->GetAttributeBool(CONSTLIT("noLogo")); bool bAll = pCmdLine->GetAttributeBool(CONSTLIT("all")); bool bRawData = pCmdLine->GetAttributeBool(CONSTLIT("rawData")); ETypes iType; if (pCmdLine->GetAttributeBool(CONSTLIT("fillLocations"))) iType = outputFillLocations; else iType = outputFreq; // Additional columns TArray<CString> Cols; for (i = 0; i < pCmdLine->GetAttributeCount(); i++) { CString sAttrib = pCmdLine->GetAttributeName(i); if (!IsMainCommandParam(sAttrib) && !strEquals(sAttrib, CONSTLIT("count")) && !strEquals(sAttrib, CONSTLIT("fillLocations")) && !strEquals(sAttrib, CONSTLIT("rawData")) && !strEquals(sAttrib, CONSTLIT("encounterfreq"))) { CString sValue = pCmdLine->GetAttribute(i); if (!strEquals(sValue, CONSTLIT("true"))) Cols.Insert(strPatternSubst(CONSTLIT("%s:%s"), sAttrib, sValue)); else Cols.Insert(sAttrib); } } // Generate systems for multiple games CSystemCreateStats Stats; for (i = 0; i < iSystemSample; i++) { if (bLogo) printf("pass %d...\n", i+1); // Initialize the game CString sError; if (Universe.InitGame(0, &sError) != NOERROR) { printf("%s\n", sError.GetASCIIZPointer()); return; } for (j = 0; j < Universe.GetTopologyNodeCount(); j++) { CTopologyNode *pNode = Universe.GetTopologyNode(j); if (pNode->IsEndGame()) continue; // Create the system CSystem *pSystem; if (Universe.CreateStarSystem(pNode, &pSystem, NULL, &Stats) != NOERROR) { printf("ERROR: Unable to create star system.\n"); return; } // Done with old system Universe.DestroySystem(pSystem); } Universe.Reinit(); } // Output based on type if (iType == outputFreq) { // Generate a table for each encounter TSortMap<CStationType *, SEncounterFreqEntry> EncounterFreq; for (i = 0; i < Stats.GetEncounterTableCount(); i++) { const CSystemCreateStats::SEncounterTable &Table = Stats.GetEncounterTable(i); // Skip if only planets and asteroids if (!Table.bHasStation && !bAll) continue; // For each entry in the table, add to the frequency table for (j = 0; j < Table.Table.GetCount(); j++) { CStationType *pEncounterType = Table.Table.GetAt(j); int iChance = Table.Table.GetChance(j); SEncounterFreqEntry *pEntry = EncounterFreq.SetAt(pEncounterType); pEntry->iCount += Table.iCount; pEntry->iTotalChance += Table.iCount * iChance; if (pEntry->pMaxTable == NULL || iChance > pEntry->iMaxChance) { pEntry->pMaxTable = &Table; pEntry->iMaxChance = iChance; } if (pEntry->pMinTable == NULL || iChance < pEntry->iMinChance) { pEntry->pMinTable = &Table; pEntry->iMinChance = iChance; } } } // Output encounter frequency distribution printf("Level\tCategory\tEncounter\tTotal Chances\tAverage Chance\tMin Chance\tMax Chance"); for (i = 0; i < Cols.GetCount(); i++) printf("\t%s", Cols[i].GetASCIIZPointer()); printf("\n"); for (i = 0; i < EncounterFreq.GetCount(); i++) { CStationType *pEncounterType = EncounterFreq.GetKey(i); int iAveWhole = EncounterFreq[i].iTotalChance / EncounterFreq[i].iCount; int iAveFrac = 1000 * (EncounterFreq[i].iTotalChance % EncounterFreq[i].iCount) / EncounterFreq[i].iCount; printf("%d\t%s\t%s\t%d\t%d.%03d\t%d\t%d", pEncounterType->GetLevel(), pEncounterType->GetDataField(CONSTLIT("category")).GetASCIIZPointer(), pEncounterType->GetName().GetASCIIZPointer(), EncounterFreq[i].iCount, iAveWhole, iAveFrac, EncounterFreq[i].iMinChance, EncounterFreq[i].iMaxChance); for (j = 0; j < Cols.GetCount(); j++) { CString sValue = pEncounterType->GetDataField(Cols[j]); printf("\t%s", sValue.GetASCIIZPointer()); } printf("\n"); } // Output raw data if (bRawData) { // Loop over stats and output tables for (i = 0; i < Stats.GetEncounterTableCount(); i++) { const CSystemCreateStats::SEncounterTable &Table = Stats.GetEncounterTable(i); // Skip if only planets and asteroids if (!Table.bHasStation && !bAll) continue; // Header printf("LEVEL %d (%d location%s)\nSystem Type: %08x\nStations: %s\n", Table.iLevel, Table.iCount, (Table.iCount == 1 ? "" : "s"), Table.pSystemType->GetUNID(), Table.sStationCriteria.GetASCIIZPointer()); // Location attributes printf("Location: "); for (j = 0; j < Table.LabelAttribs.GetCount(); j++) { if (j != 0) printf(", "); printf(Table.LabelAttribs[j].GetASCIIZPointer()); } printf("\n"); // Entries for (j = 0; j < Table.Table.GetCount(); j++) printf("%s\t%d\n", Table.Table.GetAt(j)->GetName().GetASCIIZPointer(), Table.Table.GetChance(j)); printf("\n"); } } } else if (iType == outputFillLocations) { printf("Level\tSystem\tEncounter\tChance\n"); for (i = 0; i < Stats.GetFillLocationsTableCount(); i++) { const CSystemCreateStats::SFillLocationsTable &Entry = Stats.GetFillLocationsTable(i); for (j = 0; j < Entry.Table.GetCount(); j++) { int iPercent = (int)(1000.0 * Entry.Table.GetChance(j) / (Metric)Entry.Table.GetTotalChance()); printf("%d\t%s\t%s\t%d.%d\n", Entry.iLevel, Entry.sSystemName.GetASCIIZPointer(), Entry.Table[j]->GetName().GetASCIIZPointer(), iPercent / 10, iPercent % 10); } } } }