void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
{
	if (!SetSection(section))
	{
		FString path;
#ifdef __APPLE__
		char cpath[PATH_MAX];
		FSRef folder;
		
		if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			path << cpath << "/" GAME_DIR "/autoexec.cfg";
		}
#elif !defined(unix)
		path = "$PROGDIR/autoexec.cfg";
#else
		path = GetUserFile ("autoexec.cfg");
#endif
		SetSection (section, true);
		SetValueForKey ("Path", path.GetChars());
	}
	if (start)
	{
		MoveSectionToStart(section);
	}
}
Пример #2
0
void FGameConfigFile::DoGameSetup (const char *gamename)
{
	const char *key;
	const char *value;

	sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
	subsection = section + countof(section) - sublen - 1;
	section[countof(section) - 1] = '\0';
	
	strncpy (subsection, "UnknownConsoleVariables", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "ConsoleVariables", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	if (gameinfo.gametype & GAME_Raven)
	{
		SetRavenDefaults (gameinfo.gametype == GAME_Hexen);
	}

	// The NetServerInfo section will be read and override anything loaded
	// here when it's determined that a netgame is being played.
	strncpy (subsection, "LocalServerInfo", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "Player", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "ConsoleAliases", sublen);
	if (SetSection (section))
	{
		const char *name = NULL;
		while (NextInSection (key, value))
		{
			if (stricmp (key, "Name") == 0)
			{
				name = value;
			}
			else if (stricmp (key, "Command") == 0 && name != NULL)
			{
				C_SetAlias (name, value);
				name = NULL;
			}
		}
	}
	OkayToWrite = true;
}
Пример #3
0
void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
{
	if (!SetSection(section))
	{
		FString path = M_GetAutoexecPath();
		SetSection (section, true);
		SetValueForKey ("Path", path.GetChars());
	}
	if (start)
	{
		MoveSectionToStart(section);
	}
}
void FGameConfigFile::ArchiveGlobalData ()
{
	SetSection ("LastRun", true);
	ClearCurrentSection ();
	SetValueForKey ("Version", LASTRUNVERSION);

	SetSection ("GlobalSettings", true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, 1);

	SetSection ("GlobalSettings.Unknown", true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, 3);
}
Пример #5
0
void FGameConfigFile::ArchiveGlobalData ()
{
	SetSection ("LastRun", true);
	ClearCurrentSection ();
	SetValueForKey ("Version", LASTRUNVERSION);

	SetSection ("GlobalSettings", true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);

	SetSection ("GlobalSettings.Unknown", true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_AUTO);
}
Пример #6
0
// Like DoGameSetup(), but for mod-specific cvars.
// Called after CVARINFO has been parsed.
void FGameConfigFile::DoModSetup(const char *gamename)
{
	mysnprintf(section, countof(section), "%s.Player.Mod", gamename);
	if (SetSection(section))
	{
		ReadCVars(CVAR_MOD|CVAR_USERINFO|CVAR_IGNORE);
	}
	mysnprintf(section, countof(section), "%s.LocalServerInfo.Mod", gamename);
	if (SetSection (section))
	{
		ReadCVars (CVAR_MOD|CVAR_SERVERINFO|CVAR_IGNORE);
	}
	// Signal that these sections should be rewritten when saving the config.
	bModSetup = true;
}
Пример #7
0
cMenuSetupSc::cMenuSetupSc(const char *CfgDir)
{
  cfgdir=strdup(CfgDir);
  SetSection(tr("SoftCAM"));

  ScOpts->Backup(); LogOpts->Backup();
  for(cOpts *opts=0; (opts=cSystems::GetSystemOpts(opts==0));) opts->Backup();

  ScOpts->Create(this);
  Add(new cOsdItem(tr("Cryptsystem options..."),osUser5));
  Add(new cOsdItem(tr("Message logging..."),osUser6));
  if(Feature.SmartCard()) {
    char id[IDSTR_LEN];
    for(int i=0; smartcards.ListCard(i,id,sizeof(id)); i++) {
      char buff[32];
      snprintf(buff,sizeof(buff),"%s %d",tr("Smartcard interface"),i);
      cScInfoItem *ii;
      if(id[0]) ii=new cScInfoItem(buff,id,osUser4);
      else      ii=new cScInfoItem(buff,tr("(empty)"));
      ii->Ident(i);
      Add(ii);
      }
    }
  Add(new cOsdItem(tr("Status information..."),osUser8));
  Add(new cOsdItem(tr("Flush ECM cache"),osUser7));
  Add(new cOsdItem(tr("Reload files"),osUser9));
}
Пример #8
0
void FGameConfigFile::ReadNetVars ()
{
	strncpy (subsection, "NetServerInfo", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}
	if (bModSetup)
	{
		mysnprintf(subsection, sublen, "NetServerInfo.Mod");
		if (SetSection(section))
		{
			ReadCVars(CVAR_MOD|CVAR_SERVERINFO|CVAR_IGNORE);
		}
	}
}
Пример #9
0
// Moved from DoGameSetup so that it can happen after wads are loaded
void FGameConfigFile::DoKeySetup(const char *gamename)
{
	static const struct { const char *label; FKeyBindings *bindings; } binders[] =
	{
		{ "Bindings", &Bindings },
		{ "DoubleBindings", &DoubleBindings },
		{ "AutomapBindings", &AutomapBindings },
		{ NULL, NULL }
	};
	const char *key, *value;

	sublen = countof(section) - 1 - mysnprintf(section, countof(section), "%s.", gamename);
	subsection = section + countof(section) - sublen - 1;
	section[countof(section) - 1] = '\0';

	C_SetDefaultBindings ();

	for (int i = 0; binders[i].label != NULL; ++i)
	{
		strncpy(subsection, binders[i].label, sublen);
		if (SetSection(section))
		{
			FKeyBindings *bindings = binders[i].bindings;
			bindings->UnbindAll();
			while (NextInSection(key, value))
			{
				bindings->DoBind(key, value);
			}
		}
	}
}
Пример #10
0
/// Set a section name
///
/// @param id String ID
///
void YCIni::SetSection(u32 id)
{
	TCHAR buffer[256];

	::LoadString(::GetModuleHandle(nullptr), id, buffer, ArrayUtils::ArraySize(buffer));

	SetSection(buffer);
}
void FGameConfigFile::ReadNetVars ()
{
	strncpy (subsection, "NetServerInfo", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}
}
void FGameConfigFile::ArchiveGameData (const char *gamename)
{
	char section[32*3], *subsection;

	sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
	subsection = section + countof(section) - 1 - sublen;

	strncpy (subsection, "Player", sublen);
	SetSection (section, true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, 4);

	strncpy (subsection, "ConsoleVariables", sublen);
	SetSection (section, true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, 0);

	strncpy (subsection, netgame ? "NetServerInfo" : "LocalServerInfo", sublen);
	if (!netgame || consoleplayer == 0)
	{ // Do not overwrite this section if playing a netgame, and
	  // this machine was not the initial host.
		SetSection (section, true);
		ClearCurrentSection ();
		C_ArchiveCVars (this, 5);
	}

	strncpy (subsection, "UnknownConsoleVariables", sublen);
	SetSection (section, true);
	ClearCurrentSection ();
	C_ArchiveCVars (this, 2);

	strncpy (subsection, "ConsoleAliases", sublen);
	SetSection (section, true);
	ClearCurrentSection ();
	C_ArchiveAliases (this);

	M_SaveCustomKeys (this, section, subsection, sublen);

	strcpy (subsection, "Bindings");
	SetSection (section, true);
	Bindings.ArchiveBindings (this);

	strncpy (subsection, "DoubleBindings", sublen);
	SetSection (section, true);
	DoubleBindings.ArchiveBindings (this);

	strncpy (subsection, "AutomapBindings", sublen);
	SetSection (section, true);
	AutomapBindings.ArchiveBindings (this);
}
Пример #13
0
ClientEnAttente::ClientEnAttente(string nom, int nbDePersonnes, int sectionsChoisie)
{
	if (sectionsChoisie > 0 && sectionsChoisie < 8) // Le choix est valide
	{
		SetNom(nom);
		SetSection(sectionsChoisie);
		SetNombreDePersonnes(nbDePersonnes);
		SetPrecedent(nullptr);   // nullptr indique qu'on ne connait pas l'adresse; equivaut à null
		SetSuivant(nullptr);
	}
	else // Le choix est invalide, on lance une exception
		cout << "La section choisie est invalide. Choix: salle(0), terrasse(1), terrasseFumeur(2)" << endl;
}
void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
{
	char section[64];
	const char *key;
	const char *value;

	mysnprintf (section, countof(section), "%s.AutoExec", game);

	if (bMigrating)
	{
		FBaseCVar *autoexec = FindCVar ("autoexec", NULL);

		if (autoexec != NULL)
		{
			UCVarValue val;
			char *path;

			val = autoexec->GetGenericRep (CVAR_String);
			path = copystring (val.String);
			delete autoexec;
			SetSection (section, true);
			SetValueForKey ("Path", path);
			list->AppendArg (path);
			delete[] path;
		}
	}
	else
	{
		// If <game>.AutoExec section does not exist, create it
		// with a default autoexec.cfg file present.
		CreateStandardAutoExec(section, false);
		// Run any files listed in the <game>.AutoExec section
		if (!SectionIsEmpty())
		{
			while (NextInSection (key, value))
			{
				if (stricmp (key, "Path") == 0 && *value != '\0')
				{
					FString expanded_path = ExpandEnvVars(value);
					if (FileExists(expanded_path))
					{
						list->AppendArg (ExpandEnvVars(value));
					}
				}
			}
		}
	}
}
void FGameConfigFile::DoGameSetup (const char *gamename)
{
	const char *key;
	const char *value;
	enum { Doom, Heretic, Hexen, Strife, Chex } game;

	if (strcmp (gamename, "Heretic") == 0)
		game = Heretic;
	else if (strcmp (gamename, "Hexen") == 0)
		game = Hexen;
	else if (strcmp (gamename, "Strife") == 0)
		game = Strife;
	else if (strcmp (gamename, "Chex") == 0)
		game = Chex;
	else
		game = Doom;

	if (bMigrating)
	{
		MigrateOldConfig ();
	}
	sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
	subsection = section + countof(section) - sublen - 1;
	section[countof(section) - 1] = '\0';
	
	strncpy (subsection, "UnknownConsoleVariables", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "ConsoleVariables", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	if (game != Doom && game != Strife && game != Chex)
	{
		SetRavenDefaults (game == Hexen);
	}

	// The NetServerInfo section will be read when it's determined that
	// a netgame is being played.
	strncpy (subsection, "LocalServerInfo", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "Player", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "Bindings", sublen);
	if (!SetSection (section))
	{ // Config has no bindings for the given game
		if (!bMigrating)
		{
			C_SetDefaultBindings ();
		}
	}
	else
	{
		C_UnbindAll ();
		while (NextInSection (key, value))
		{
			C_DoBind (key, value, false);
		}
	}

	strncpy (subsection, "DoubleBindings", sublen);
	if (SetSection (section))
	{
		while (NextInSection (key, value))
		{
			C_DoBind (key, value, true);
		}
	}

	strncpy (subsection, "ConsoleAliases", sublen);
	if (SetSection (section))
	{
		const char *name = NULL;
		while (NextInSection (key, value))
		{
			if (stricmp (key, "Name") == 0)
			{
				name = value;
			}
			else if (stricmp (key, "Command") == 0 && name != NULL)
			{
				C_SetAlias (name, value);
				name = NULL;
			}
		}
	}
}
void FGameConfigFile::DoGlobalSetup ()
{
	if (SetSection ("GlobalSettings.Unknown"))
	{
		ReadCVars (CVAR_GLOBALCONFIG);
	}
	if (SetSection ("GlobalSettings"))
	{
		ReadCVars (CVAR_GLOBALCONFIG);
	}
	if (SetSection ("LastRun"))
	{
		const char *lastver = GetValueForKey ("Version");
		if (lastver != NULL)
		{
			double last = atof (lastver);
			if (last < 123.1)
			{
				FBaseCVar *noblitter = FindCVar ("vid_noblitter", NULL);
				if (noblitter != NULL)
				{
					noblitter->ResetToDefault ();
				}
			}
			if (last < 202)
			{
				// Make sure the Hexen hotkeys are accessible by default.
				if (SetSection ("Hexen.Bindings"))
				{
					SetValueForKey ("\\", "use ArtiHealth");
					SetValueForKey ("scroll", "+showscores");
					SetValueForKey ("0", "useflechette");
					SetValueForKey ("9", "use ArtiBlastRadius");
					SetValueForKey ("8", "use ArtiTeleport");
					SetValueForKey ("7", "use ArtiTeleportOther");
					SetValueForKey ("6", "use ArtiEgg");
					SetValueForKey ("5", "use ArtiInvulnerability");
				}
			}
			if (last < 204)
			{ // The old default for vsync was true, but with an unlimited framerate
			  // now, false is a better default.
				FBaseCVar *vsync = FindCVar ("vid_vsync", NULL);
				if (vsync != NULL)
				{
					vsync->ResetToDefault ();
				}
			}
			if (last < 206)
			{ // spc_amp is now a float, not an int.
				if (spc_amp > 16)
				{
					spc_amp = spc_amp / 16.f;
				}
			}
			if (last < 207)
			{ // Now that snd_midiprecache works again, you probably don't want it on.
				FBaseCVar *precache = FindCVar ("snd_midiprecache", NULL);
				if (precache != NULL)
				{
					precache->ResetToDefault();
				}
			}
			if (last < 208)
			{ // Weapon sections are no longer used, so tidy up the config by deleting them.
				const char *name;
				size_t namelen;
				bool more;

				more = SetFirstSection();
				while (more)
				{
					name = GetCurrentSection();
					if (name != NULL && 
						(namelen = strlen(name)) > 12 &&
						strcmp(name + namelen - 12, ".WeaponSlots") == 0)
					{
						more = DeleteCurrentSection();
					}
					else
					{
						more = SetNextSection();
					}
				}
			}
			if (last < 209)
			{
				// menu dimming is now a gameinfo option so switch user override off
				FBaseCVar *dim = FindCVar ("dimamount", NULL);
				if (dim != NULL)
				{
					dim->ResetToDefault ();
				}
			}
		}
	}
}
Пример #17
0
bool CCodeBlock::CreateBlockLinkage(CCodeSection * EnterSection)
{
    CCodeSection * CurrentSection = EnterSection;

    CPU_Message("Section %d", CurrentSection->m_SectionID);
    for (uint32_t TestPC = EnterSection->m_EnterPC, EndPC = ((EnterSection->m_EnterPC + 0x1000) & 0xFFFFF000); TestPC <= EndPC; TestPC += 4)
    {
        if (TestPC != EndPC)
        {
            SectionMap::const_iterator itr = m_SectionMap.find(TestPC);
            if (itr != m_SectionMap.end() && CurrentSection != itr->second)
            {
                if (CurrentSection->m_ContinueSection != NULL &&
                    CurrentSection->m_ContinueSection != itr->second)
                {
                    g_Notify->BreakPoint(__FILE__, __LINE__);
                }
                if (CurrentSection->m_ContinueSection == NULL)
                {
                    SetSection(CurrentSection->m_ContinueSection, CurrentSection, TestPC, true, TestPC);
                    CurrentSection->SetContinueAddress(TestPC - 4, TestPC);
                }
                CurrentSection->m_EndPC = TestPC - 4;
                CurrentSection = itr->second;

                CPU_Message("Section %d", CurrentSection->m_SectionID);
                if (EnterSection != m_EnterSection)
                {
                    if (CurrentSection->m_JumpSection != NULL ||
                        CurrentSection->m_ContinueSection != NULL ||
                        CurrentSection->m_EndSection)
                    {
                        break;
                    }
                }
            }
        }
        else
        {
            CurrentSection->m_EndSection = true;
            break;
        }

        bool LikelyBranch, EndBlock, IncludeDelaySlot, PermLoop;
        uint32_t TargetPC, ContinuePC;

        CurrentSection->m_EndPC = TestPC;
        if (!AnalyzeInstruction(TestPC, TargetPC, ContinuePC, LikelyBranch, IncludeDelaySlot, EndBlock, PermLoop))
        {
            g_Notify->BreakPoint(__FILE__, __LINE__);
            return false;
        }

        if (TestPC + 4 == EndPC && IncludeDelaySlot)
        {
            TargetPC = (uint32_t)-1;
            ContinuePC = (uint32_t)-1;
            EndBlock = true;
        }
        if (TargetPC == (uint32_t)-1 && !EndBlock)
        {
            if (ContinuePC != (uint32_t)-1)
            {
                g_Notify->BreakPoint(__FILE__, __LINE__);
            }
            continue;
        }

        if (EndBlock)
        {
            CPU_Message("%s: End Block", __FUNCTION__);
            CurrentSection->m_EndSection = true;
            // find other sections that need compiling
            break;
        }

        if (ContinuePC != (uint32_t)-1)
        {
            CPU_Message("%s: SetContinueAddress TestPC = %X ContinuePC = %X", __FUNCTION__, TestPC, ContinuePC);
            CurrentSection->SetContinueAddress(TestPC, ContinuePC);
            if (!SetSection(CurrentSection->m_ContinueSection, CurrentSection, ContinuePC, true, TestPC))
            {
                ContinuePC = (uint32_t)-1;
            }
        }

        if (LikelyBranch)
        {
            CPU_Message("%s: SetJumpAddress TestPC = %X Target = %X", __FUNCTION__, TestPC, TestPC + 4);
            CurrentSection->SetJumpAddress(TestPC, TestPC + 4, false);
            if (SetSection(CurrentSection->m_JumpSection, CurrentSection, TestPC + 4, false, TestPC))
            {
                bool BranchLikelyBranch, BranchEndBlock, BranchIncludeDelaySlot, BranchPermLoop;
                uint32_t BranchTargetPC, BranchContinuePC;

                CCodeSection * JumpSection = CurrentSection->m_JumpSection;
                if (!AnalyzeInstruction(JumpSection->m_EnterPC, BranchTargetPC, BranchContinuePC, BranchLikelyBranch, BranchIncludeDelaySlot, BranchEndBlock, BranchPermLoop))
                {
                    g_Notify->BreakPoint(__FILE__, __LINE__);
                    return false;
                }

                if (BranchLikelyBranch || BranchIncludeDelaySlot || BranchPermLoop)
                {
                    g_Notify->BreakPoint(__FILE__, __LINE__);
                    return false;
                }

                JumpSection->m_EndPC = TestPC + 4;
                if (BranchEndBlock)
                {
                    CPU_Message("%s: Jump End Block", __FUNCTION__);
                    JumpSection->m_EndSection = true;
                    TargetPC = (uint32_t)-1;
                }
                else
                {
                    JumpSection->SetJumpAddress(TestPC, TargetPC, false);
                }
                JumpSection->SetDelaySlot();
                SetSection(JumpSection->m_JumpSection, JumpSection, TargetPC, true, TestPC);
            }
            else
            {
                g_Notify->BreakPoint(__FILE__, __LINE__);
            }
        }
        else if (TargetPC != ((uint32_t)-1))
        {
            CPU_Message("%s: SetJumpAddress TestPC = %X Target = %X", __FUNCTION__, TestPC, TargetPC);
            CurrentSection->SetJumpAddress(TestPC, TargetPC, PermLoop);
            if (PermLoop || !SetSection(CurrentSection->m_JumpSection, CurrentSection, TargetPC, true, TestPC))
            {
                if (ContinuePC == (uint32_t)-1)
                {
                    CurrentSection->m_EndSection = true;
                }
            }
        }

        TestPC += IncludeDelaySlot ? 8 : 4;

        //Find the next section
        CCodeSection * NewSection = NULL;
        for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++)
        {
            if (CurrentSection->m_JumpSection != NULL ||
                CurrentSection->m_ContinueSection != NULL ||
                CurrentSection->m_EndSection)
            {
                continue;
            }
            NewSection = itr->second;
            break;
        }
        if (NewSection == NULL)
        {
            break;
        }
        if (CurrentSection == NewSection)
        {
            g_Notify->BreakPoint(__FILE__, __LINE__);
        }
        CurrentSection = NewSection;
        if (CurrentSection->m_JumpSection != NULL ||
            CurrentSection->m_ContinueSection != NULL ||
            CurrentSection->m_EndSection)
        {
            break;
        }
        TestPC = CurrentSection->m_EnterPC;
        CPU_Message("a. Section %d", CurrentSection->m_SectionID);
        TestPC -= 4;
    }

    for (SectionMap::iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++)
    {
        CCodeSection * Section = itr->second;
        if (Section->m_JumpSection != NULL ||
            Section->m_ContinueSection != NULL ||
            Section->m_EndSection)
        {
            continue;
        }
        if (!CreateBlockLinkage(Section))
        {
            return false;
        }
        break;
    }
    if (CurrentSection->m_EndPC == (uint32_t)-1)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }
    return true;
}
Пример #18
0
//--------------------------------------------------------------------
double CIniFile::ReadFloat(const std::wstring& szSection, const std::wstring& szKey, double lfDefault)
{
    SetSection(szSection);
    return ReadFloat(szKey, lfDefault);
}
Пример #19
0
/*
	Init()
*/
void CConfig::CONFIG::Init(LPCSTR lpcszSectionName/*=NULL*/,LPCSTR lpcszKeyName/*=NULL*/,DWORD dwKeyValue/*=(DWORD)-1L*/)
{
	SetSection(lpcszSectionName);
	SetName(lpcszKeyName);
	SetValue(dwKeyValue);
}
Пример #20
0
//--------------------------------------------------------------------
bool CIniFile::SafeReadBoolean(const std::wstring& szSection,
                               const std::wstring& szKey) throw(CIniException)
{
    SetSection(szSection);
    return SafeReadBoolean(szKey);
}
Пример #21
0
void BaseSearchMgr::SetSection(BaseSearcher* pBaseSearcher,U16 pid,U8 table_id,const U8* pBuffer,U32 iSize)
{
	DVBSection *pSection = new DVBSection(pBaseSearcher,pid,table_id,pBuffer,iSize);
	SetSection(pSection);
}
void FGameConfigFile::DoGameSetup (const char *gamename)
{
	const char *key;
	const char *value;

	if (bMigrating)
	{
		MigrateOldConfig ();
	}
	sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
	subsection = section + countof(section) - sublen - 1;
	section[countof(section) - 1] = '\0';
	
	strncpy (subsection, "UnknownConsoleVariables", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "ConsoleVariables", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	if (gameinfo.gametype & GAME_Raven)
	{
		SetRavenDefaults (gameinfo.gametype == GAME_Hexen);
	}

	// The NetServerInfo section will be read when it's determined that
	// a netgame is being played.
	strncpy (subsection, "LocalServerInfo", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	strncpy (subsection, "Player", sublen);
	if (SetSection (section))
	{
		ReadCVars (0);
	}

	if (!bMigrating)
	{
		C_SetDefaultBindings ();
	}

	strncpy (subsection, "Bindings", sublen);
	if (SetSection (section))
	{
		Bindings.UnbindAll();
		while (NextInSection (key, value))
		{
			Bindings.DoBind (key, value);
		}
	}

	strncpy (subsection, "DoubleBindings", sublen);
	if (SetSection (section))
	{
		DoubleBindings.UnbindAll();
		while (NextInSection (key, value))
		{
			DoubleBindings.DoBind (key, value);
		}
	}

	strncpy (subsection, "AutomapBindings", sublen);
	if (SetSection (section))
	{
		AutomapBindings.UnbindAll();
		while (NextInSection (key, value))
		{
			AutomapBindings.DoBind (key, value);
		}
	}

	strncpy (subsection, "ConsoleAliases", sublen);
	if (SetSection (section))
	{
		const char *name = NULL;
		while (NextInSection (key, value))
		{
			if (stricmp (key, "Name") == 0)
			{
				name = value;
			}
			else if (stricmp (key, "Command") == 0 && name != NULL)
			{
				C_SetAlias (name, value);
				name = NULL;
			}
		}
	}
	OkayToWrite = true;
}
Пример #23
0
//--------------------------------------------------------------------
double CIniFile::SafeReadFloat(const std::wstring& szSection,
                               const std::wstring& szKey) throw(CIniException)
{
    SetSection(szSection);
    return SafeReadFloat(szKey);
}
Пример #24
0
//--------------------------------------------------------------------
void CIniFile::WriteInteger(const std::wstring& szSection, const std::wstring& szKey, int nValue)
{
    SetSection(szSection);
    WriteInteger(szKey, nValue);
}
Пример #25
0
//--------------------------------------------------------------------
void CIniFile::WriteString(const std::wstring& szSection,
                           const std::wstring& szKey, const std::wstring& szValue)
{
    SetSection(szSection);
    WriteString(szKey, szValue);
}
Пример #26
0
//--------------------------------------------------------------------
int CIniFile::SafeReadInteger(const std::wstring& szSection,
                              const std::wstring& szKey) throw( CIniException )
{
    SetSection( szSection );
    return SafeReadInteger( szKey );
}
Пример #27
0
//--------------------------------------------------------------------
void CIniFile::WriteFloat(const std::wstring& szSection, const std::wstring& szKey, double lfValue)
{
    SetSection( szSection );
    WriteFloat( szKey, lfValue );
}
Пример #28
0
//--------------------------------------------------------------------
bool CIniFile::ReadBoolean(const std::wstring& szSection, const std::wstring& szKey, bool bDefault)
{
    SetSection(szSection);
    return ReadBoolean(szKey, bDefault);
}
FGameConfigFile::FGameConfigFile ()
{
#ifdef __APPLE__
	FString user_docs, user_app_support, local_app_support;
#endif
	FString pathname;
	
	bMigrating = false;
	pathname = GetConfigPath (true);
	ChangePathName (pathname);
	LoadConfigFile (MigrateStub, NULL);

	if (!HaveSections ())
	{ // Config file not found; try the old one
		MigrateOldConfig ();
	}

	// If zdoom.ini was read from the program directory, switch
	// to the user directory now. If it was read from the user
	// directory, this effectively does nothing.
	pathname = GetConfigPath (false);
	ChangePathName (pathname);

	// Set default IWAD search paths if none present
	if (!SetSection ("IWADSearch.Directories"))
	{
		SetSection ("IWADSearch.Directories", true);
		SetValueForKey ("Path", ".", true);
		SetValueForKey ("Path", "$DOOMWADDIR", true);
#ifdef __APPLE__
		char cpath[PATH_MAX];
		FSRef folder;
		
		if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			user_docs << cpath << "/" GAME_DIR;
			SetValueForKey("Path", user_docs, true);
		}
		else
		{
			SetValueForKey("Path", "~/" GAME_DIR, true);
		}
		if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			user_app_support << cpath << "/" GAME_DIR;
			SetValueForKey("Path", user_app_support, true);
		}
		SetValueForKey ("Path", "$PROGDIR", true);
		if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			local_app_support << cpath << "/" GAME_DIR;
			SetValueForKey("Path", local_app_support, true);
		}
#elif !defined(unix)
		SetValueForKey ("Path", "$HOME", true);
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", "~/" GAME_DIR, true);
		SetValueForKey ("Path", SHARE_DIR, true);
#endif
	}

	// Set default search paths if none present
	if (!SetSection ("FileSearch.Directories"))
	{
		SetSection ("FileSearch.Directories", true);
#ifdef __APPLE__
		SetValueForKey ("Path", user_docs, true);
		SetValueForKey ("Path", user_app_support, true);
		SetValueForKey ("Path", "$PROGDIR", true);
		SetValueForKey ("Path", local_app_support, true);
#elif !defined(unix)
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", SHARE_DIR, true);
#endif
		SetValueForKey ("Path", "$DOOMWADDIR", true);
	}

	// Create auto-load sections, so users know what's available.
	// Note that this totem pole is the reverse of the order that
	// they will appear in the file.
	CreateSectionAtStart("Chex3.Autoload");
	CreateSectionAtStart("Chex.Autoload");
	CreateSectionAtStart("Strife.Autoload");
	CreateSectionAtStart("HexenDemo.Autoload");
	CreateSectionAtStart("HexenDK.Autoload");
	CreateSectionAtStart("Hexen.Autoload");
	CreateSectionAtStart("Heretic.Autoload");
	CreateSectionAtStart("FreeDM.Autoload");
	CreateSectionAtStart("Freedoom1.Autoload");
	CreateSectionAtStart("Freedoom.Autoload");
	CreateSectionAtStart("Plutonia.Autoload");
	CreateSectionAtStart("TNT.Autoload");
	CreateSectionAtStart("Doom2.Autoload");
	CreateSectionAtStart("Doom1.Autoload");
	CreateSectionAtStart("Doom.Autoload");
	CreateSectionAtStart("Global.Autoload");

	// The same goes for auto-exec files.
	CreateStandardAutoExec("Chex.AutoExec", true);
	CreateStandardAutoExec("Strife.AutoExec", true);
	CreateStandardAutoExec("Hexen.AutoExec", true);
	CreateStandardAutoExec("Heretic.AutoExec", true);
	CreateStandardAutoExec("Doom.AutoExec", true);

	// Move search paths back to the top.
	MoveSectionToStart("FileSearch.Directories");
	MoveSectionToStart("IWADSearch.Directories");

	// Add some self-documentation.
	SetSectionNote("IWADSearch.Directories",
		"# These are the directories to automatically search for IWADs.\n"
		"# Each directory should be on a separate line, preceded by Path=\n");
	SetSectionNote("FileSearch.Directories",
		"# These are the directories to search for wads added with the -file\n"
		"# command line parameter, if they cannot be found with the path\n"
		"# as-is. Layout is the same as for IWADSearch.Directories\n");
	SetSectionNote("Doom.AutoExec",
		"# Files to automatically execute when running the corresponding game.\n"
		"# Each file should be on its own line, preceded by Path=\n\n");
	SetSectionNote("Global.Autoload",
		"# WAD files to always load. These are loaded after the IWAD but before\n"
		"# any files added with -file. Place each file on its own line, preceded\n"
		"# by Path=\n");
	SetSectionNote("Doom.Autoload",
		"# Wad files to automatically load depending on the game and IWAD you are\n"
		"# playing.  You may have have files that are loaded for all similar IWADs\n"
		"# (the game) and files that are only loaded for particular IWADs. For example,\n"
		"# any files listed under Doom.Autoload will be loaded for any version of Doom,\n"
		"# but files listed under Doom2.Autoload will only load when you are\n"
		"# playing Doom 2.\n\n");
}
Пример #30
0
//--------------------------------------------------------------------
void CIniFile::WriteBoolean(const std::wstring& szSection, const std::wstring& szKey, bool bValue)
{
    SetSection( szSection );
    WriteFloat( szKey, bValue );
}