ALERROR CExplorerModel::Init (void) // Init // // Initialize the model { fileGetVersionInfo(NULL_STR, &m_Version); m_Universe.SetSoundMgr(&m_HI.GetSoundMgr()); m_Universe.SetDebugMode(false); m_Universe.SetSound(false); return NOERROR; }
ALERROR CTransSaverModel::Init (void) // Init // // Initialize { fileGetVersionInfo(NULL_STR, &m_Version); m_Universe.SetSoundMgr(&m_HI.GetSoundMgr()); m_Universe.SetDebugMode(false); m_Universe.SetHost(NULL); m_Universe.SetSound(false); return NOERROR; }
void CTransWorkshop::PrintLogo (CXMLElement *pCmdLine) const // PrintLogo // // Prints the logo and version { SFileVersionInfo VersionInfo; if (fileGetVersionInfo(NULL_STR, &VersionInfo) != NOERROR) { printf("ERROR: Unable to get version info.\n"); return; } printf("TransWorkshop %s\n", (LPSTR)VersionInfo.sProductVersion); printf("%s\n\n", (LPSTR)VersionInfo.sCopyright); }
LONG CTranscendenceWnd::WMCreate (CString *retsError) // WMCreate // // Handle WM_CREATE { ALERROR error; int i; // Get the version information { SFileVersionInfo VerInfo; fileGetVersionInfo(NULL_STR, &VerInfo); m_sVersion = strPatternSubst(CONSTLIT("%s %s"), VerInfo.sProductName, VerInfo.sProductVersion); m_sCopyright = VerInfo.sCopyright; kernelDebugLogMessage(m_sVersion); } // Load preferences //LoadPreferences(); //g_pHI->GetSoundMgr().SetWaveVolume(m_Prefs.iSoundVolume); // Compute screen size ComputeScreenSize(); // Initialize frame rate information m_iStartAnimation = 0; m_iFrameCount = 0; for (i = 0; i < FRAME_RATE_COUNT; i++) { m_iFrameTime[i] = 0; m_iPaintTime[i] = 0; m_iUpdateTime[i] = 0; m_iBltTime[i] = 0; } // Initialize m_rcScreen.left = 0; m_rcScreen.top = 0; m_rcScreen.right = g_cxScreen; m_rcScreen.bottom = g_cyScreen; int cxMainScreen = Min(MAIN_SCREEN_WIDTH, g_cxScreen); int cyMainScreen = Min(MAIN_SCREEN_HEIGHT, g_cyScreen); m_rcMainScreen.left = (g_cxScreen - cxMainScreen) / 2; m_rcMainScreen.top = (g_cyScreen - cyMainScreen) / 2; m_rcMainScreen.right = m_rcMainScreen.left + cxMainScreen; m_rcMainScreen.bottom = m_rcMainScreen.top + cyMainScreen; // Initialize the font table m_Fonts.Small.Create(STR_SMALL_TYPEFACE, -10); m_Fonts.Medium.Create(STR_SMALL_TYPEFACE, -13); m_Fonts.MediumBold.Create(STR_SMALL_TYPEFACE, -13, true); m_Fonts.MediumHeavyBold.Create(STR_MEDIUM_TYPEFACE, -14, true); m_Fonts.Large.Create(STR_MEDIUM_TYPEFACE, -16); m_Fonts.LargeBold.Create(STR_MEDIUM_TYPEFACE, -16, true); m_Fonts.Header.CreateFromResource(g_hInst, "DXFN_HEADER"); m_Fonts.HeaderBold.CreateFromResource(g_hInst, "DXFN_HEADER_BOLD"); m_Fonts.SubTitle.CreateFromResource(g_hInst, "DXFN_SUBTITLE"); m_Fonts.SubTitleBold.CreateFromResource(g_hInst, "DXFN_SUBTITLE_BOLD"); m_Fonts.SubTitleHeavyBold.CreateFromResource(g_hInst, "DXFN_SUBTITLE_HEAVY_BOLD"); m_Fonts.Title.CreateFromResource(g_hInst, "DXFN_TITLE"); m_Fonts.LogoTitle.CreateFromResource(g_hInst, "DXFN_LOGO_TITLE"); m_Fonts.Console.Create(STR_FIXED_TYPEFACE, -14); // Output the typeface that we got if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo)) { kernelDebugLogMessage("Small typeface: %s", m_Fonts.Small.GetTypeface()); kernelDebugLogMessage("Medium typeface: %s", m_Fonts.Large.GetTypeface()); kernelDebugLogMessage("Large typeface: %s", m_Fonts.Header.GetTypeface()); kernelDebugLogMessage("Console typeface: %s", m_Fonts.Console.GetTypeface()); } // Set colors m_Fonts.wTextColor = CG16bitImage::RGBValue(191,196,201); m_Fonts.wTitleColor = CG16bitImage::RGBValue(218,235,255); m_Fonts.wLightTitleColor = CG16bitImage::RGBValue(120,129,140); m_Fonts.wHelpColor = CG16bitImage::RGBValue(103,114,128); m_Fonts.wBackground = CG16bitImage::RGBValue(15,17,18); m_Fonts.wSectionBackground = CG16bitImage::RGBValue(86,82,73); m_Fonts.wSelectBackground = CG16bitImage::RGBValue(115,230,115); //m_Fonts.wSelectBackground = CG16bitImage::RGBValue(255,225,103); m_Fonts.wAltGreenColor = CG16bitImage::RGBValue(5,211,5); m_Fonts.wAltGreenBackground = CG16bitImage::RGBValue(23,77,23); m_Fonts.wAltYellowColor = CG16bitImage::RGBValue(255,225,103); m_Fonts.wAltYellowBackground = CG16bitImage::RGBValue(65,57,24); m_Fonts.wAltRedColor = CG16bitImage::RGBValue(4,179,4); m_Fonts.wAltRedBackground = CG16bitImage::RGBValue(76,0,0); m_Fonts.wAltBlueColor = CG16bitImage::RGBValue(87,111,205); m_Fonts.wAltBlueBackground = CG16bitImage::RGBValue(52,57,64); m_Fonts.wItemTitle = CG16bitImage::RGBValue(255,255,255); m_Fonts.wItemRef = CG16bitImage::RGBValue(255,255,255); m_Fonts.wItemDesc = CG16bitImage::RGBValue(128,128,128); m_Fonts.wItemDescSelected = CG16bitImage::RGBValue(200,200,200); // Initialize UI resources if (error = m_UIRes.Init(&m_Fonts)) { *retsError = CONSTLIT("Unable to initialize UI resources."); goto Fail; } // Play Intro Music if (!m_pTC->GetOptionBoolean(CGameSettings::noMusic)) g_pHI->GetSoundMgr().PlayMusic(CONSTLIT("TranscendenceMarch.mp3")); // Initialize debug console RECT rcRect; rcRect.left = m_rcScreen.right - (DEBUG_CONSOLE_WIDTH + 4); rcRect.top = (RectHeight(m_rcScreen) - DEBUG_CONSOLE_HEIGHT) / 2; rcRect.right = rcRect.left + DEBUG_CONSOLE_WIDTH; rcRect.bottom = rcRect.top + DEBUG_CONSOLE_HEIGHT; m_DebugConsole.SetFontTable(&m_Fonts); m_DebugConsole.Init(this, rcRect); m_DebugConsole.Output(CONSTLIT("Transcendence Debug Console")); m_DebugConsole.Output(m_sVersion); m_DebugConsole.Output(m_sCopyright); m_DebugConsole.Output(NULL_STR); return 0; Fail: return -1; }
bool CArchonProcess::Boot (const SProcessDesc &Config) // Boot // // Boots the process. We take ownership of all engines. { try { int i; // Get our current process location CString sExecutableFilespec = fileGetExecutableFilespec(); CString sExecutablePath = fileGetPath(sExecutableFilespec); // LATER: Hard-coded for now m_sArcology = STR_DEFAULT_ARCOLOGY; // Set some options m_bArcologyPrime = ((Config.dwFlags & PROCESS_FLAG_ARCOLOGY_PRIME) != 0); m_bCentralModule = ((Config.dwFlags & PROCESS_FLAG_CENTRAL_MODULE) != 0); m_bConsoleMode = ((Config.dwFlags & PROCESS_FLAG_CONSOLE_MODE) != 0); m_bDebugger = ((Config.dwFlags & PROCESS_FLAG_DEBUG) != 0); m_sMachineName = Config.sMachineName; // Set the name if (m_bCentralModule) m_sName = STR_CENTRAL_MODULE; else { // Get a module name by taking just the filename (without extension) fileGetExtension(fileGetFilename(sExecutableFilespec), &m_sName); } m_iState = stateNone; // Initialize the black box so that we can record boot errors. // (But only if we're the central module on arcology prime). if (m_bCentralModule && m_bArcologyPrime) { m_BlackBox.Boot(sExecutablePath); if (Config.dwFlags & PROCESS_FLAG_CONSOLE_OUTPUT) m_BlackBox.SetConsoleOutput(true); LogBlackBox(STR_ARCHON_BOOT); } else if (m_bConsoleMode) { m_BlackBox.SetConsoleOutput(true); } // Validate options if (m_sMachineName.IsEmpty() && !m_bConsoleMode) { LogBlackBox(ERR_NO_MACHINE_NAME); m_iState = stateBootError; return false; } // Get version information if (!fileGetVersionInfo(NULL_STR, &m_Version)) { LogBlackBox(ERR_UNABLE_TO_GET_VERSION); m_iState = stateBootError; return false; } // Log version information if (m_bCentralModule || m_bConsoleMode) { LogBlackBox(strPattern("%s %s", m_Version.sProductName, m_Version.sProductVersion)); LogBlackBox(m_Version.sCopyright); } // Boot Foundation, including Winsock CString sError; if (!CFoundation::Boot(0, &sError)) { LogBlackBox(sError); m_iState = stateBootError; return false; } // Init some stuff m_dwLastGarbageCollect = sysGetTickCount(); m_QuitEvent.Create(); m_RunEvent.Create(); m_PauseEvent.Create(); m_QuitSignalEvent.Create(); // If we're the Central Module, then claim a mutex so that no one // else tries it. if (m_bCentralModule) { if (m_bArcologyPrime) m_CentralModuleSem.Create(STR_ARCOLOGY_PRIME_SEMAPHORE, 1); else m_CentralModuleSem.Create(STR_CENTRAL_MODULE_SEMAPHORE, 1); if (!m_CentralModuleSem.TryIncrement()) { LogBlackBox(ERR_NOT_CENTRAL_MODULE); m_iState = stateBootError; return false; } } // Boot some stuff m_MnemosynthDb.Boot(this); m_Transporter.Boot(this); // Boot some threads m_ImportThread.Boot(this, m_sName, m_RunEvent, m_PauseEvent, m_QuitEvent); // Remember the Exarch engine, if we have it. m_pExarch = Config.pExarch; // Add the list of engines DWORD dwEngineID = 0; // Add the mnemosynth engine (if not in console mode) if (!m_bConsoleMode) { SEngine *pEngine = m_Engines.Insert(); pEngine->pEngine = new CMnemosynthEngine(&m_MnemosynthDb); pEngine->pEngine->Boot(this, dwEngineID++); } // Add user provided engines for (i = 0; i < Config.Engines.GetCount(); i++) { SEngine *pEngine = m_Engines.Insert(); pEngine->pEngine = Config.Engines[i].pEngine; // Allow the engine to add its ports pEngine->pEngine->Boot(this, dwEngineID++); } // After this point we cannot create or destroy any engines. // // Get all engine's command port (in case we need it). // It is OK if an engine does not have a command port; that just means // that it doesn't want any messages from us. for (i = 0; i < m_Engines.GetCount(); i++) m_Engines[i].pCommand = Bind(GenerateAddress(strPattern("%s.command", m_Engines[i].pEngine->GetName()))); // Publish this module's virtual ports to Mnemosynth m_Transporter.PublishToMnemosynth(); // Done return true; } catch (...) { LogBlackBox(ERR_CRASH_WHILE_BOOTING); m_iState = stateBootError; return false; } }
CString ExecuteUpgrade (CSocket &theSocket, const CString &sCmd) { int i; CString sRoot = fileGetPath(fileGetExecutableFilespec()); // Make a list of all executable files to upgrade TArray<CString> FileList; if (!fileGetFileList(sRoot, NULL_STR, CString("*.exe"), FFL_FLAG_RELATIVE_FILESPEC, &FileList)) return CString("ERROR: Unable to obtain a list of executable files to upgrade."); // Prepare a request upgrade command CStringBuffer Output; Output.Write("requestUpgrade (", 16); for (i = 0; i < FileList.GetCount(); i++) { CString sFilespec = fileAppend(sRoot, FileList[i]); // Version SFileVersionInfo Info; if (!fileGetVersionInfo(sFilespec, &Info)) { printf("ERROR: Unable to get file version: %s\n", (LPSTR)sFilespec); continue; } CIPInteger Version(Info.dwProductVersion); CString sVersion = Version.AsString(); // Checksum DWORD dwChecksum = fileChecksumAdler32(sFilespec); if (dwChecksum == 0) { printf("ERROR: Unable to get file checksum: %s\n", (LPSTR)sFilespec); continue; } CString sOutput = strPattern("{filename:\"%s\" version:%s checksum:%d} ", FileList[i], sVersion, dwChecksum); Output.Write(sOutput); } Output.Write(")", 1); // Send the command CString sSend = CString::CreateFromHandoff(Output); CString sResult; CDatum dResult; ExecuteArcologyCommand(theSocket, sSend, &sResult, &dResult); if (strEquals(sResult, CString("ERROR"))) return dResult.AsString(); // Show all the files to upgrade CDatum dUpgradeDesc = dResult.GetElement(0).GetElement(FIELD_UPGRADE_DESC); for (i = 0; i < dUpgradeDesc.GetCount(); i++) { CDatum dFileDesc = dUpgradeDesc.GetElement(i); printf("Upgrading %s\n", (LPSTR)dFileDesc.GetElement(FIELD_FILENAME).AsString()); } // Confirm CString sConfirm = GetInputLine(CString("\nAre you sure you want to upgrade the arcology? [y/n] : ")); if (*sConfirm.GetParsePointer() != 'y' && *sConfirm.GetParsePointer() != 'Y') return NULL_STR; // Upload the new files. for (i = 0; i < dUpgradeDesc.GetCount(); i++) { CDatum dFileDesc = dUpgradeDesc.GetElement(i); const CString &sFilename = dFileDesc.GetElement(FIELD_FILENAME); CString sFilespec = fileAppend(sRoot, sFilename); CString sResult = UploadFile(theSocket, CMD_UPLOAD_UPGRADE, sFilename, sFilespec); printf("%s\n", (LPSTR)sResult); } // Complete the upgrade return ExecuteArcologyCommand(theSocket, CMD_COMPLETE_UPGRADE); }