コード例 #1
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
int64 MDFN_GetSettingI(const char *name)
{
 const MDFNCS *setting = FindSetting(name);
 const char *value = GetSetting(FindSetting(name));


 if(setting->desc->type == MDFNST_ENUM)
  return(GetEnum(setting, value));
 else
 {
  long long ret;
  TranslateSettingValueI(value, ret);
  return(ret);
 }
}
コード例 #2
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
static MDFNCS *FindSetting(const char *name, bool dref_alias, bool dont_freak_out_on_fail)
{
 MDFNCS *ret = NULL;
 uint32 name_hash;

 //printf("Find: %s\n", name);

 name_hash = MakeNameHash(name);

 std::pair<std::multimap <uint32, MDFNCS>::iterator, std::multimap <uint32, MDFNCS>::iterator> sit_pair;
 std::multimap <uint32, MDFNCS>::iterator sit;

 sit_pair = CurrentSettings.equal_range(name_hash);

 for(sit = sit_pair.first; sit != sit_pair.second; sit++)
 {
  //printf("Found: %s\n", sit->second.name);
  if(!strcmp(sit->second.name, name))
  {
   if(dref_alias && sit->second.desc->type == MDFNST_ALIAS)
    return(FindSetting(sit->second.value, dref_alias, dont_freak_out_on_fail));

   ret = &sit->second;
  }
 }

 if(!ret && !dont_freak_out_on_fail)
 {
  printf("\n\nINCONCEIVABLE!  Setting not found: %s\n\n", name);
  exit(1);
 }
 return(ret);
}
コード例 #3
0
TInt CDPOFPrintingDevice::GetNumPrintPages()
	{
	LOG1("CDPOFPrintingDevice::GetNumPrintPages begin with job state: %d", iPrintJob->iState);
	if( iPrintJob->iState == PJSNone )
		{
		LOG("CDPOFPrintingDevice::GetNumPrintPages job state == PJSNone, ending with 0");
		return 0;
		}


	TInt ImagesPerPage = 1;
	TInt NumPrintPages;
	TInt NumImages = iPrintJob->iImages.Count();

	// Get Num images per page from the mapping table.
	TSetting Setting;
	FindSetting(EPrintCapabLayout, Setting);

	for (TInt j = 0; j < iMappingArray.Count(); j++)
		{
		if (iMappingArray[j].iCode == Setting.iValue)
			{
			ImagesPerPage = iMappingArray[j].iImagesPerPage;
			break;
			}
		}

	if( ImagesPerPage == 0 ) // Stickers, Uses only one image, and populates a single page
		NumPrintPages = 1;
	else
		NumPrintPages = (NumImages + ImagesPerPage - 1) / ImagesPerPage;

	LOG1("CDPOFPrintingDevice::GetNumPrintPages returns: %d", NumPrintPages);
	return NumPrintPages;
	}
コード例 #4
0
ファイル: GdlFeatures.cpp プロジェクト: bbriggs/FieldWorks
DEFINE_THIS_FILE

/***********************************************************************************************
	Forward declarations
***********************************************************************************************/

/***********************************************************************************************
	Local Constants and static variables
***********************************************************************************************/

/***********************************************************************************************
	Methods: Post-parser
***********************************************************************************************/

/*----------------------------------------------------------------------------------------------
	Return the feature setting with the given name; create it if necessary.
----------------------------------------------------------------------------------------------*/
GdlFeatureSetting * GdlFeatureDefn::FindOrAddSetting(StrAnsi sta, GrpLineAndFile & lnf)
{
	GdlFeatureSetting * pfset = FindSetting(sta);
	if (pfset)
		return pfset;

	pfset = new GdlFeatureSetting();
	pfset->SetName(sta);
	pfset->SetLineAndFile(lnf);
	m_vpfset.Push(pfset);
	return pfset;
}
コード例 #5
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
static INLINE void MergeSettingSub(const MDFNSetting *setting)
{
  MDFNCS TempSetting;
  uint32 name_hash;

  assert(setting->name);
  assert(setting->default_value);

  if(FindSetting(setting->name, false, true) != NULL)
  {
   printf("Duplicate setting name %s\n", setting->name);
   abort();
  }

  name_hash = MakeNameHash(setting->name);

  TempSetting.name = strdup(setting->name);
  TempSetting.value = strdup(setting->default_value);
  TempSetting.name_hash = name_hash;
  TempSetting.desc = setting;
  TempSetting.ChangeNotification = setting->ChangeNotification;
  TempSetting.netplay_override = NULL;

  CurrentSettings.insert(std::pair<uint32, MDFNCS>(name_hash, TempSetting)); //[name_hash] = TempSetting;
}
コード例 #6
0
ファイル: tactical.cpp プロジェクト: ZhouWeikuan/darkreign2
  //
  // Load the modifier settings
  //
  void ModifierSettings::LoadState(FScope *fScope)
  {
    // Load the settings
    FScope *sScope;
    while ((sScope = fScope->NextFunction()) != NULL)
    {
      switch (sScope->NameCrc())
      {
        case 0x1F2EDF02: // "Set"
        {
          const char *modifier = sScope->NextArgString();
          const char *setting = sScope->NextArgString();

          U8 modifierIndex;
          U8 settingIndex;

          if (
            FindModifier(Crc::CalcStr(modifier), &modifierIndex) &&
            FindSetting(modifierIndex, Crc::CalcStr(setting), &settingIndex))
          {
            Set(modifierIndex, settingIndex);
          }
          else
          {
            LOG_WARN(("Invalid modifier setting combination %s:%s", modifier, setting))
          }
          break;
        }
      }
    }
  }
コード例 #7
0
ファイル: settings.cpp プロジェクト: FabioPinheiro/Mednafen
static void ParseSettingLine(std::string &linebuf, bool IsOverrideSetting = false)
{
 MDFNCS *zesetting;
 size_t spacepos = linebuf.find(' ');

 // EOF or bad line
 if(spacepos == std::string::npos)
  return;	

 // No name(key)
 if(spacepos == 0)
  return;

 // No value
 if((spacepos + 1) == linebuf.size())
  return;

 // Comment
 if(linebuf[0] == ';')
  return;

 linebuf[spacepos] = 0;
 zesetting = FindSetting(linebuf.c_str(), true, true);

 if(zesetting)
 {
  char *nv = strdup(linebuf.c_str() + spacepos + 1);

  if(IsOverrideSetting)
  {
   if(zesetting->game_override)
    free(zesetting->game_override);

   zesetting->game_override = nv;
  }
  else
  {
   if(zesetting->value)
    free(zesetting->value);

   zesetting->value = nv;
  }

  ValidateSetting(nv, zesetting->desc);	// TODO: Validate later(so command line options can override invalid setting file data correctly)
 }
 else if(!IsOverrideSetting)
 {
  UnknownSetting_t unks;

  unks.name = strdup(linebuf.c_str());
  unks.value = strdup(linebuf.c_str() + spacepos + 1);

  UnknownSettings.push_back(unks);
 }
}
コード例 #8
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
std::string MDFN_GetSettingS(const char *name)
{
 const MDFNCS *setting = FindSetting(name);
 const char *value = GetSetting(setting);

 // Even if we're getting the string value of an enum instead of the associated numeric value, we still need
 // to make sure it's a valid enum
 // (actually, not really, since it's handled in other places where the setting is actually set)
 //if(setting->desc->type == MDFNST_ENUM)
 // GetEnum(setting, value);

 return(std::string(value));
}
コード例 #9
0
ファイル: difficulty.cpp プロジェクト: ZhouWeikuan/darkreign2
  //
  // LoadConfig
  //
  // Load the configured difficulty settings
  //
  static void LoadConfig()
  {
    PTree pTree;
    GameIdent defaultName;

    // Clear any current settings
    ClearSettings();

    // Open the configuration file
    if (pTree.AddFile(configName))
    {
      FScope *gScope = pTree.GetGlobalScope();
      FScope *sScope;

      // Parse each function
      while ((sScope = gScope->NextFunction()) != NULL)
      {
        switch (sScope->NameCrc())
        {
          case 0x12AFF0D8: // "CreateSetting"
            ProcessCreateSetting(sScope);
            break;

          case 0x733C1EB5: // "DefaultSetting"
            defaultName = StdLoad::TypeString(sScope);
            break;
        }
      }

      // Ensure at least one setting is configured
      if (settings.GetCount())
      {
        // Setup the default setting
        if ((defaultSetting = FindSetting(defaultName)) == NULL)
        {
          defaultSetting = settings.GetHead();
        }

        // Set the current from the default
        currentSetting = defaultSetting;
      }
      else
      {
        ERR_CONFIG(("At least one difficulty setting must be supplied in [%s]", configName));
      }
    }
    else
    {
      ERR_CONFIG(("Unable to load difficulty settings configuration [%s]", configName));
    }
  }
コード例 #10
0
// Parses a tree structure of items. The rootName setting must be a list of item names.
void CSettingsParser::ParseTree( const wchar_t *rootName, std::vector<TreeItem> &items )
{
	const wchar_t *str=FindSetting(rootName);
	if (str)
	{
		CString names[MAX_TREE_LEVEL];
		ParseTreeRec(str,items,names,0);
	}
	else
	{
		TreeItem last={L"",-1};
		items.push_back(last);
	}
}
コード例 #11
0
int CSettingsParser::ParseTreeRec( const wchar_t *str, std::vector<TreeItem> &items, CString *names, int level )
{
	size_t start=items.size();
	while (*str)
	{
		wchar_t token[256];
		str=GetToken(str,token,_countof(token),L", \t");
		if (token[0])
		{
			// 
			bool bFound=false;
			for (int i=0;i<level;i++)
				if (_wcsicmp(token,names[i])==0)
				{
					bFound=true;
					break;
				}
				if (!bFound)
				{
					TreeItem item={token,-1};
					items.push_back(item);
				}
		}
	}
	size_t end=items.size();
	if (start==end) return -1;

	TreeItem item={L"",-1};
	items.push_back(item);

	if (level<MAX_TREE_LEVEL-1)
	{
		for (size_t i=start;i<end;i++)
		{
			wchar_t buf[266];
			Sprintf(buf,_countof(buf),L"%s.Items",items[i].name);
			const wchar_t *str2=FindSetting(buf);
			if (str2)
			{
				names[level]=items[i].name;
				// these two statements must be on separate lines. otherwise items[i] is evaluated before ParseTreeRec, but
				// the items vector can be reallocated inside ParseTreeRec, causing the address to be invalidated -> crash!
				int idx=ParseTreeRec(str2,items,names,level+1);
				items[i].children=idx;
			}
		}
	}
	return (int)start;
}
コード例 #12
0
TDBTSettingHandle CSettings::WriteSetting(TDBTSetting & Setting)
{
	CBlockManager * file = &m_BlockManagerPri;
	if (Setting.Descriptor->Entity == 0)
		file = &m_BlockManagerSet;
	
	CBlockManager::WriteTransaction trans(*file);

	TDBTSettingHandle hset = FindSetting(*Setting.Descriptor);
	if (hset == DBT_INVALIDPARAM)
		return hset;

	hset = WriteSetting(Setting, hset);

	return hset;
}
コード例 #13
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
bool MDFNI_SetSetting(const char *name, const char *value, bool NetplayOverride)
{
 MDFNCS *zesetting = FindSetting(name, true, true);

 if(zesetting)
 {
  if(!ValidateSetting(value, zesetting->desc))
  {
   return(0);
  }

  // TODO:  When NetplayOverride is set, make sure the setting is an emulation-related setting, 
  // and that it is safe to change it(changing paths to BIOSes and such is not safe :b).
  if(NetplayOverride)
  {
   if(zesetting->netplay_override)
    free(zesetting->netplay_override);
   zesetting->netplay_override = strdup(value);
  }
  else
  {
   if(zesetting->value)
    free(zesetting->value);
   zesetting->value = strdup(value);
  }

  // TODO, always call driver notification function, regardless of whether a game is loaded.
  if(zesetting->ChangeNotification)
  {
   if(MDFNGameInfo)
    zesetting->ChangeNotification(name);
  }
  return(true);
 }
 else
 {
  MDFN_PrintError(_("Unknown setting \"%s\""), name);
  return(false);
 }
}
コード例 #14
0
unsigned int CSettings::DeleteSetting(TDBTSettingDescriptor & Descriptor)
{
	TDBTSettingHandle hset = FindSetting(Descriptor);
	if ((hset == 0) || (hset == DBT_INVALIDPARAM))
	{
		return DBT_INVALIDPARAM;
	}

	unsigned int res = 0;
	if ((Descriptor.Flags & DBT_SDF_FoundValid) && (Descriptor.Flags & DBT_SDF_HashValid))
	{
		CBlockManager * file = &m_BlockManagerPri;

		if (Descriptor.FoundInEntity == 0)
		{
			file = &m_BlockManagerSet;
			hset = hset & ~cSettingsFileFlag;
		}

		CBlockManager::WriteTransaction trans(*file);

		uint32_t sig = cSettingSignature;
		uint32_t size = 0;
		TSetting * setting = file->ReadBlock<TSetting>(hset, size, sig);
		if (setting && (setting->Entity == Descriptor.FoundInEntity))
		{
			CSettingsTree * tree = getSettingsTree(setting->Entity);
			if (tree)
			{
				tree->_DeleteSetting(Descriptor.Hash, hset);
				file->DeleteBlock(hset);
			}
		}

	} else {
		res = DeleteSetting(hset);
	}

	return res;
}
コード例 #15
0
unsigned int CSettings::ReadSetting(TDBTSetting & Setting)
{
	CBlockManager * file = &m_BlockManagerPri;
	if (Setting.Descriptor->Entity == 0)
		file = &m_BlockManagerSet;
	
	CBlockManager::ReadTransaction trans(*file);

	TDBTSettingHandle hset = FindSetting(*Setting.Descriptor);
	if ((hset == 0) || (hset == DBT_INVALIDPARAM))
		return DBT_INVALIDPARAM;
	
	PDBTSettingDescriptor back = Setting.Descriptor;
	Setting.Descriptor = NULL;

	if (ReadSetting(Setting, hset) == DBT_INVALIDPARAM)
		hset = DBT_INVALIDPARAM;

	Setting.Descriptor = back;

	return hset;
}
コード例 #16
0
TInt CDPOFPrintingDevice::GetJobSetting(TInt aCapabilityID, TInt& aValue)
	{
	LOG1("CDPOFPrintingDevice::GetJobSetting begins with aCapabilityID: %d", aCapabilityID);
	TInt err(KErrNone);
	if( iPrintJob->iState == PJSNone )
		{
		err = KErrInvalidSequence;
		}
	else
		{
		TSetting Setting;
		if( FindSetting(aCapabilityID, Setting) )
			{
			aValue = Setting.iValue;
			}
		else
			{
			err = KErrInvalidData;
			}
		}
	LOG1("CDPOFPrintingDevice::GetJobSetting ends with err: %d", err);
	return err;
	}
コード例 #17
0
ファイル: settings.cpp プロジェクト: gameblabla/mednafen-gcw
static void ParseSettingLine(std::string &linebuf, size_t* valid_count, size_t* unknown_count, bool IsOverrideSetting = false)
{
 MDFNCS *zesetting;
 size_t spacepos;

 //
 // Comment
 //
 if(linebuf[0] == ';' || linebuf[0] == '#')
  return;

 spacepos = linebuf.find(' ');

 // No name(key)
 if(spacepos == 0)
  return;

 // No space present?!
 if(spacepos == std::string::npos)
 {
  //if(linebuf.size() != 0)
  // spacepos = linebuf.size() - 1;
  //else
   return;
 }
 else
  linebuf[spacepos] = 0;

 zesetting = FindSetting(linebuf.c_str(), true, true);

 if(zesetting)
 {
  char *nv = strdup(linebuf.c_str() + spacepos + 1);

  if(IsOverrideSetting)
  {
   if(zesetting->game_override)
    free(zesetting->game_override);

   zesetting->game_override = nv;
  }
  else
  {
   if(zesetting->value)
    free(zesetting->value);

   zesetting->value = nv;
  }

  ValidateSetting(nv, zesetting->desc);	// TODO: Validate later(so command line options can override invalid setting file data correctly)
  (*valid_count)++;
 }
 else
 {
  if(!IsOverrideSetting)
  {
   UnknownSetting_t unks;

   unks.name = strdup(linebuf.c_str());
   unks.value = strdup(linebuf.c_str() + spacepos + 1);

   UnknownSettings.push_back(unks);
  }
  (*unknown_count)++;
 }
}
コード例 #18
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
bool MDFN_GetSettingB(const char *name)
{
 return(strtoull(GetSetting(FindSetting(name)), NULL, 10));
}
コード例 #19
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
double MDFN_GetSettingF(const char *name)
{ 
 return(world_strtod(GetSetting(FindSetting(name)), (char **)NULL));
}
コード例 #20
0
TInt CDPOFPrintingDevice::SetJobSettingL(TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability)
	{
	LOG1("CDPOFPrintingDevice::SetJobSettingL begins with aCapabilityID: %d", aCapabilityID);
	LOG1("CDPOFPrintingDevice::SetJobSettingL begins with aValue: %d", aValue);
	LOG1("CDPOFPrintingDevice::SetJobSettingL begins with aAffectedCapability: %d", aAffectedCapability);

	if( iPrintJob->iState == PJSNone )
		{
		LOG("CDPOFPrintingDevice::SetJobSettingL job state == PJSNone");
		LOG1("CDPOFPrintingDevice::SetJobSettingL ends with: %d", KErrInvalidSequence);
		return KErrInvalidSequence;
		}

	aAffectedCapability = 0;
	TSetting Setting;
	if( FindSetting(aCapabilityID, Setting) == EFalse )
		{
		LOG("CDPOFPrintingDevice::SetJobSettingL FindSetting == EFalse");
		LOG1("CDPOFPrintingDevice::SetJobSettingL ends with: %d", KErrInvalidData);
		return KErrInvalidData;
		}

	// Get the Target printer and capability
	TPrintCapability TargetCapability;
	CPrinterElement* TargetPrinter = FindDeviceL( iPrintJob->iPrinterID );
	if( TargetPrinter == NULL )
		{
		LOG("CDPOFPrintingDevice::SetJobSettingL TargetPrinter == NULL");
		LOG1("CDPOFPrintingDevice::SetJobSettingL ends with: %d", KErrInvalidData);
		return KErrInvalidData;
		}

	TargetPrinter->iPrinterCapabilities->GetCapability(aCapabilityID, TargetCapability);

	// Check Validity against the target capability ranges
	if ((TargetCapability.iType == TPrintCapability::Int) ||
		(TargetCapability.iType == TPrintCapability::Float))
		{
		if (((aValue < TargetCapability.iLow) && (TargetCapability.iLow != -1)) ||
			((aValue > TargetCapability.iHigh) && (TargetCapability.iHigh != -1)))
			{
			LOG("CDPOFPrintingDevice::SetJobSettingL capability ranges error");
			LOG1("CDPOFPrintingDevice::SetJobSettingL ends with: %d", KErrInvalidData);
			return KErrInvalidData;
			}

		}
	else // enum
		{
		TBool Valid = EFalse;
		for (TInt i = 0; i < TargetCapability.iEnumCount; i++)
			{
			if (aValue == TargetCapability.iEnumCodes[i])
				{
					Valid = ETrue;
					break;
				}
			}
		if (!Valid)
			{
			LOG("CDPOFPrintingDevice::SetJobSettingL !Valid");
			LOG1("CDPOFPrintingDevice::SetJobSettingL ends with: %d", KErrInvalidData);
			return KErrInvalidData;
			}
		}

	for (TInt i = 0; i < iPrintJob->iSettings.Count(); i++)
		{
		if (aCapabilityID == iPrintJob->iSettings[i].iCapabilityID)
			{
			iPrintJob->iSettings[i].iValue = aValue;
			break;
			}
		}

	aAffectedCapability = TargetPrinter->iPrinterCapabilities->SetCurrentValueL(aCapabilityID, aValue);
	LOG1("CDPOFPrintingDevice::SetJobSettingL ends with aAffectedCapability: %d", aAffectedCapability);
	LOG1("CDPOFPrintingDevice::SetJobSettingL ends with code: %d", KErrNone);
	return KErrNone;
	}
コード例 #21
0
void CDPOFPrintingDevice::OverwriteExistingJobL ()
	{
	iPrintError = KErrNone;
	iPrintErrorMsgCode = 0;
	
	CRsDpofEngine::TRsDpofImageLayout layout;
	iDPOF->SetImageFileNamesL(iPrintJob->iImages);
	TSetting layoutSetting;
	FindSetting(EPrintCapabLayout, layoutSetting);
	LOG1("CDPOFPrintingDevice::OverwriteExistingJobL layoutSetting.iValue: %d", layoutSetting.iValue);
	switch(layoutSetting.iValue)
		{
		case EPrintCapabLayout1UpSmall:
			layout = CRsDpofEngine::EOnePerPageSmall;
			break;
		case EPrintCapabLayout1UpMedium:
		case EPrintCapabLayout1UpLarge:
			layout = CRsDpofEngine::EOnePerPageLarge;
			break;
		case EPrintCapabLayout2Up:
			layout = CRsDpofEngine::ETwoPerPage;
			break;
		case EPrintCapabLayout4Up:
			layout = CRsDpofEngine::EFourPerPage;
			break;
		case EPrintCapabLayout6Up:
			layout = CRsDpofEngine::ESixPerPage;
			break;
		case EPrintCapabLayout9Up:
			layout = CRsDpofEngine::ENinePerPage;
			break;
		case EPrintCapabLayout12Up:
			layout = CRsDpofEngine::ETwelvePerPage;
			break;
		case EPrintCapabLayout16Up:
			layout = CRsDpofEngine::ESixteenPerPage;
			break;
		default:
			layout = CRsDpofEngine::EOnePerPageMedium;
			break;
		}
	
	iDPOF->SetImageLayout(layout);
	LOG1("CDPOFPrintingDevice::OverwriteExistingJobL 1 iStatus.Int(): %d", iStatus.Int());
	TInt err = iDPOF->PrintL();
	LOG1("CDPOFPrintingDevice::OverwriteExistingJobL iDPOF->PrintL() error: %d", err);
	LOG1("CDPOFPrintingDevice::OverwriteExistingJobL 2 iStatus.Int(): %d", iStatus.Int());
	
	if( err )
		{
		iPrintError = err;
		iPrintErrorMsgCode = ENoMessage;				
		AddReadyRequestAndSetActive( EPrintError );
		}
	else
		{
		LOG("CDPOFPrintingDevice::OverwriteExistingJobL job submitted");
		iPrintJob->iState = PJSSubmitted;
		if(!IsActive()) SetActive();
		}
	}
コード例 #22
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
bool MFDN_LoadSettings(const char *basedir)
{
 FILE *fp;

 fname = basedir;
 fname += PSS;
 fname += "mednafen-09x.cfg";

 MDFN_printf(_("Loading settings from \"%s\"..."), fname.c_str());

 //printf("%s\n", fname.c_str());
 if(!(fp = fopen(fname.c_str(), "rb")))
 {
  ErrnoHolder ene(errno);

  MDFN_printf(_("Failed: %s\n"), ene.StrError());

  if(ene.Errno() == ENOENT) // Don't return failure if the file simply doesn't exist.
   return(1);
  else
   return(0);
 }
 MDFN_printf("\n");

 char linebuf[1024];

 while(fgets(linebuf, 1024, fp) > 0)
 {
  MDFNCS *zesetting;
  char *spacepos = strchr(linebuf, ' ');

  if(!spacepos) continue;	// EOF or bad line

  if(spacepos == linebuf) continue;	// No name(key)
  if(spacepos[1] == 0) continue;	// No value
  if(spacepos[0] == ';') continue;	// Comment

  // FIXME
  if(linebuf[0] == ';')
   continue;

  *spacepos = 0;
 
  char *lfpos = strchr(spacepos + 1, '\n');
  if(lfpos) *lfpos = 0;
  lfpos = strchr(spacepos + 1, '\r');
  if(lfpos) *lfpos = 0;

  if(spacepos[1] == 0) continue;        // No value

  zesetting = FindSetting(linebuf, true, true);

  if(zesetting)
  {
   if(zesetting->value)
    free(zesetting->value);

   zesetting->value = strdup(spacepos + 1);

   if(!ValidateSetting(zesetting->value, zesetting->desc))
    return(0);
  }
  else
  {
   UnknownSetting_t unks;

   unks.name = strdup(linebuf);
   unks.value = strdup(spacepos + 1);

   UnknownSettings.push_back(unks);
  }
 }
 fclose(fp);
 return(1);
}
コード例 #23
0
ファイル: settings.cpp プロジェクト: CeRiAl/fragistics
int Settings::ParseSettings(char *filename, int argc_, char **argv_){
	int i;
	char numbuf[50];
	string temp,temp1;
	string cfgfile_name; // ss5
	    
	argc=argc_;
	argv=argv_;

	// Take name of config file from args. If not given then
	// FindSetting() handles "MAIN/cfgfile as special case // ss5
	FindSetting(&cfgfile_name, "MAIN","cfgfile", "fragistics.conf");
	
	//cfgfile = new ConfigFile(filename);
	cfgfile = new ConfigFile(cfgfile_name.c_str()); // ss5

	//settings

	
	//HTML
	FindSetting(&text_color, "HTML","text_color", "#c0c0c0");
	FindSetting(&link_color, "HTML","link_color", "#0000ff");
	FindSetting(&vlink_color, "HTML","vlink_color", "#ff0000");
	FindSetting(&alink_color, "HTML","alink_color", "#00ff00");
	FindSetting(&text_color, "HTML","text_color", "#c0c0c0");
	FindSetting(&bg_color, "HTML","bg_color", "#000000");
	FindSetting(&bg_image, "HTML","bg_image", "");

	FindSetting(&namecolors[0], "HTML","name0", "black");
	FindSetting(&namecolors[1], "HTML","name1", "red");
	FindSetting(&namecolors[2], "HTML","name2", "green");
	FindSetting(&namecolors[3], "HTML","name3", "yellow");
	FindSetting(&namecolors[4], "HTML","name4", "blue");
	FindSetting(&namecolors[5], "HTML","name5", "cyan");
	FindSetting(&namecolors[6], "HTML","name6", "magenta");
	FindSetting(&namecolors[7], "HTML","name7", "white");
	FindSetting(&namecolors[8], "HTML","name8", "white");
	FindSetting(&namecolors[9], "HTML","name9", "white");

	
	//KILL TABLES
	if(FindSetting(&temp, "KILL TABLES","hilite_levels", "4")==false){
		temp="4";
		cfgfile->AddValue("KILL TABLES","hilite_level0", "100");
		cfgfile->AddValue("KILL TABLES","hilite_color0", "#00ff00");

		cfgfile->AddValue("KILL TABLES","hilite_level1", "90");
		cfgfile->AddValue("KILL TABLES","hilite_color1", "#d0d000");

		cfgfile->AddValue("KILL TABLES","hilite_level2", "75");
		cfgfile->AddValue("KILL TABLES","hilite_color2", "#d07000");

		cfgfile->AddValue("KILL TABLES","hilite_level3", "50");
		cfgfile->AddValue("KILL TABLES","hilite_color3", "#804020");
	}
	hilite_levels=atoi(temp.c_str());
	if(hilite_levels>=KILLTABLE_MAXHILITE){
		hilite_levels=KILLTABLE_MAXHILITE-1;
		itoa(hilite_levels,numbuf,10);
		cfgfile->AddValue("KILL TABLES","hilite_levels", numbuf);
	}
	//loop to get colors/percents
	for(i=0;i<hilite_levels;i++){
		itoa(i,numbuf,10);
		temp1="hilite_level";
		temp1+=numbuf;
		FindSetting(&temp, "KILL TABLES",temp1.c_str(), "101");
		hilite_percents[i]=atoi(temp.c_str());
		temp1="hilite_color";
		temp1+=numbuf;
		FindSetting(&hilite_colors[i], "KILL TABLES",temp1.c_str(), "white");
	}
	FindSetting(&temp, "KILL TABLES","hilite_minhilite", "2");
	hilite_minhilite=atoi(temp.c_str());
	//columncolors
	FindSetting(&killtable_column[0], "KILL TABLES","column0", "#202020");
	FindSetting(&killtable_column[1], "KILL TABLES","column1", "#404040");
	FindSetting(&killtable_column[2], "KILL TABLES","column2", "#606060");


	//MAIN settings
	FindSetting(&temp, "MAIN","limit_overall_killtables", "1");
	main_overall_killtable=atoi(temp.c_str());
	FindSetting(&temp, "MAIN","players_min_time", "900");
	players_min_time=atoi(temp.c_str());
	FindSetting(&temp, "MAIN","players_min_games", "2");
	players_min_games=atoi(temp.c_str());
	FindSetting(&temp, "MAIN","players_min_kills", "20");
	players_min_kills=atoi(temp.c_str());
	FindSetting(&time_format, "MAIN","time_format", "%X %x");
	FindSetting(&temp, "MAIN","use_cust_rank", "0");
	use_cust_rank=atoi(temp.c_str());
	FindSetting(&temp, "MAIN","cust_rank_start", "10000");
	cust_rank_start=atoi(temp.c_str());
	FindSetting(&cust_rank_template, "MAIN","cust_rank_template", "custrank.htmlt");
	FindSetting(&srcpath, "MAIN","src_path", ".\\templates");
	FindSetting(&destpath, "MAIN","dest_path", ".\\output");
	FindSetting(&dbpath, "MAIN","db_path", ".\\database");
	FindSetting(&temp, "MAIN","use_db", "1");
	use_db=atoi(temp.c_str());
	


	//GAME settings
	FindSetting(&temp, "GAME","min_players", "2");
	game_minplayers=atoi(temp.c_str());
	FindSetting(&temp, "GAME","min_time", "21");
	game_mintime=atoi(temp.c_str());
	FindSetting(&temp, "GAME","min_kills", "10");
	game_minkills=atoi(temp.c_str());
	FindSetting(&temp, "GAME","game_complete", "2");
	game_complete=atoi(temp.c_str());
	FindSetting(&temp, "GAME","game_last_placed", "3");
	game_placed=atoi(temp.c_str());


	//LOGS settings
	FindSetting(&temp, "LOGS","number_of_logs", "-1");
	logs_number=atoi(temp.c_str());
	if(logs_number<=0 || logs_number>1000){				//yes, I know 1000 is arbitrary, but will anyone ever need more that that?
		cfgfile->AddValue("LOGS","number_of_logs", "1");
		cfgfile->AddValue("LOGS","logpath0", "games.log");
		cfgfile->AddValue("LOGS","logtype0", "0");
		logs_number=1;
	}
	logs_paths = new string[logs_number];
	logs_type = new int[logs_number];
	for(i=0;i<logs_number;i++){
		itoa(i,numbuf,10);
		temp1="logpath";
		temp1+=numbuf;
		FindSetting(&logs_paths[i], "LOGS",temp1.c_str(), "games.log");
		temp1="logtype";
		temp1+=numbuf;
		FindSetting(&temp, "LOGS",temp1.c_str(), "0");
		logs_type[i]=atoi(temp.c_str());
	}

	//TEMPLATES settings
	FindSetting(&temp, "TEMPLATES","main_templates_number", "-1");
	main_number=atoi(temp.c_str());
	if(main_number<0 || main_number>1000){				//yes, I know 1000 is arbitrary, but will anyone ever need more that that?
		cfgfile->AddValue("TEMPLATES","main_templates_number", "1");
		cfgfile->AddValue("TEMPLATES","main_template0", "stats");
		main_number=1;
	}
	main_templates = new string[main_number];
	for(i=0;i<main_number;i++){
		itoa(i,numbuf,10);
		temp1="main_template";
		temp1+=numbuf;
		FindSetting(&main_templates[i], "TEMPLATES",temp1.c_str(), "stats");
	}
	FindSetting(&temp, "TEMPLATES","game_templates_number", "-1");
	game_number=atoi(temp.c_str());
	if(game_number<0 || game_number>1000){				//yes, I know 1000 is arbitrary, but will anyone ever need more that that?
		cfgfile->AddValue("TEMPLATES","game_templates_number", "1");
		cfgfile->AddValue("TEMPLATES","game_template0", "game");
		game_number=1;
	}
	game_templates = new string[game_number];
	for(i=0;i<game_number;i++){
		itoa(i,numbuf,10);
		temp1="game_template";
		temp1+=numbuf;
		FindSetting(&game_templates[i], "TEMPLATES",temp1.c_str(), "game");
	}
	FindSetting(&lastgame_template, "TEMPLATES","lastgame_template", "lastgame");
	FindSetting(&gamelist_template, "TEMPLATES","gamelist_template", "gamelist");
	FindSetting(&gamelistloop_template, "TEMPLATES","gamelist_loop_template", "gamelistloop");
	FindSetting(&player_template, "TEMPLATES","player_template", "player");
	FindSetting(&temp, "TEMPLATES","map_templates_number", "-1");
	map_number=atoi(temp.c_str());
	if(map_number<0 || map_number>1000){				//yes, I know 1000 is arbitrary, but will anyone ever need more that that?
		cfgfile->AddValue("TEMPLATES","map_templates_number", "1");
		cfgfile->AddValue("TEMPLATES","map_template0", "map");
		map_number=1;
	}
	map_templates = new string[map_number];
	for(i=0;i<map_number;i++){
		itoa(i,numbuf,10);
		temp1="map_template";
		temp1+=numbuf;
		FindSetting(&map_templates[i], "TEMPLATES",temp1.c_str(), "map");
	}

	return true;
}
コード例 #24
0
ファイル: difficulty.cpp プロジェクト: ZhouWeikuan/darkreign2
 //
 // Find
 //
 // Find the given setting
 //
 Setting * FindSetting(const GameIdent &name)
 {
   return (FindSetting(name.crc));
 }