bool C4StartupNetListEntry::KeywordMatch(const char *szMatch) { // only finished references if (!pRef) return false; if(SSearchNoCase(pRef->getTitle(),szMatch)) return true; C4Client *pHost = pRef->Parameters.Clients.getHost(); if(pHost && SSearchNoCase(pHost->getName(),szMatch)) return true; if(SSearchNoCase(pRef->getComment(),szMatch)) return true; return false; }
void C4ObjectInfoCore::Default(C4ID n_id, C4DefList *pDefs, const char *cpNames) { // Def C4Def *pDef=NULL; if (pDefs) pDef = pDefs->ID2Def(n_id); // Defaults id=n_id; Participation=1; Rank=0; Experience=0; Rounds=0; DeathCount=0; Birthday=0; TotalPlayingTime=0; SCopy("Clonk",Name,C4MaxName); SCopy("Clonk",TypeName,C4MaxName); sRankName.Copy("Clonk"); sNextRankName.Clear(); NextRankExp=0; DeathMessage[0]='\0'; *PortraitFile=0; Age=0; ExtraData.Reset(); // Type if (pDef) SCopy(pDef->GetName(),TypeName,C4MaxName); // Name if (cpNames) { // Name file reference if (SSearchNoCase(cpNames,C4CFN_Names)) SCopy(GetAName(cpNames),Name,C4MaxName); // Name list else { SCopySegment(cpNames,Random(SCharCount(0x0A,cpNames)),Name,0x0A,C4MaxName+1); SClearFrontBack(Name); SReplaceChar(Name,0x0D,0x00); } if (!Name[0]) SCopy("Clonk",Name,C4MaxName); } #ifdef C4ENGINE if (pDefs) UpdateCustomRanks(pDefs); #endif // Physical Physical.Default(); if (pDef) Physical = pDef->Physical; Physical.PromotionUpdate(Rank); // Old format }
bool C4Application::DoInit() { assert(AppState == C4AS_None); // Config overwrite by parameter StdStrBuf sConfigFilename; char szParameter[_MAX_PATH + 1]; for (int32_t iPar = 0; SGetParameter(GetCommandLine(), iPar, szParameter, _MAX_PATH); iPar++) if (SEqual2NoCase(szParameter, "/config:")) sConfigFilename.Copy(szParameter + 8); // Config check Config.Init(); Config.Load(true, sConfigFilename.getData()); Config.Save(); // sometimes, the configuration can become corrupted due to loading errors or // w/e // check this and reset defaults if necessary if (Config.IsCorrupted()) { if (sConfigFilename) { // custom config corrupted: Fail Log("Warning: Custom configuration corrupted - program abort!\n"); return false; } else { // default config corrupted: Restore default Log("Warning: Configuration corrupted - restoring default!\n"); Config.Default(); Config.Save(); Config.Load(); } } MMTimer = Config.General.MMTimer != 0; // Init C4Group C4Group_SetMaker(Config.General.Name); C4Group_SetProcessCallback(&ProcessCallback); C4Group_SetTempPath(Config.General.TempPath); C4Group_SetSortList(C4CFN_FLS); // Open log if (!OpenLog()) return false; // init system group if (!SystemGroup.Open(C4CFN_System)) { // Error opening system group - no LogFatal, because it needs language // table. // This will *not* use the FatalErrors stack, but this will cause the game // to instantly halt, anyway. Log("Error opening system group file (System.c4g)!"); return false; } // Language override by parameter const char *pLanguage; if (pLanguage = SSearchNoCase(GetCommandLine(), "/Language:")) SCopyUntil(pLanguage, Config.General.LanguageEx, ' ', CFG_MaxString); // Init external language packs Languages.Init(); // Load language string table if (!Languages.LoadLanguage(Config.General.LanguageEx)) // No language table was loaded - bad luck... if (!IsResStrTableLoaded()) Log("WARNING: No language string table loaded!"); // Set unregistered user name C4Group_SetMaker(LoadResStr("IDS_PRC_UNREGUSER")); // Parse command line Game.ParseCommandLine(GetCommandLine()); #ifdef WIN32 // Windows: handle incoming updates directly, even before starting up the gui // because updates will be applied in the console anyway. if (Application.IncomingUpdate) if (C4UpdateDlg::ApplyUpdate(Application.IncomingUpdate.getData(), false, NULL)) return true; #endif // activate Active = TRUE; // Init carrier window if (isFullScreen) { if (!(pWindow = FullScreen.Init(this))) { Clear(); return false; } } else { if (!(pWindow = Console.Init(this))) { Clear(); return false; } } // init timers (needs window) if (!InitTimer()) { LogFatal(LoadResStr("IDS_ERR_TIMER")); Clear(); return false; } // Engine header message Log(C4ENGINEINFOLONG); LogF("Version: %s %s", C4VERSION, C4_OS); #if defined(USE_DIRECTX) && defined(_WIN32) // DDraw emulation warning DWORD DDrawEmulationState; if (GetRegistryDWord(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectDraw", "EmulationOnly", &DDrawEmulationState)) if (DDrawEmulationState) Log("WARNING: DDraw Software emulation is activated!"); #endif // Initialize D3D/OpenGL DDraw = DDrawInit(this, isFullScreen, FALSE, Config.Graphics.BitDepth, Config.Graphics.Engine, Config.Graphics.Monitor); if (!DDraw) { LogFatal(LoadResStr("IDS_ERR_DDRAW")); Clear(); return false; } #if defined(_WIN32) && !defined(USE_CONSOLE) // Register clonk file classes - notice: under Vista this will only work if we // have administrator rights char szModule[_MAX_PATH + 1]; GetModuleFileName(NULL, szModule, _MAX_PATH); SetC4FileClasses(szModule); #endif // Initialize gamepad if (!pGamePadControl && Config.General.GamepadEnabled) pGamePadControl = new C4GamePadControl(); AppState = C4AS_PreInit; return true; }