Example #1
0
	void load_circle_data()
	{
	  if ( !Clib::FileExists( "config/circles.cfg" ) )
	  {
		if ( config.loglevel > 1 )
		  INFO_PRINT << "File config/circles not found, skipping.\n";
		return;
	  }

      Clib::ConfigFile cf( "config/circles.cfg", "Circle" );
      Clib::ConfigElem elem;

	  while ( cf.read( elem ) )
	  {
		int index = strtoul( elem.rest(), NULL, 0 ) - 1;
		if ( index < 0 || index >= 100 )
		{
          ERROR_PRINT << "Error in CIRCLES.CFG: Circle must fall between 1 and 100\n";
		  throw std::runtime_error( "Config file error" );
		}

		spellcircles.resize( index + 1, NULL );

		if ( spellcircles[index] != NULL )
		{
          ERROR_PRINT << "Error in CIRCLES.CFG: Circle " << index + 1 << " is multiply defined.\n";
		  throw std::runtime_error( "Config file error" );
		}

		spellcircles[index] = new SpellCircle( elem );
	  }
	}
Example #2
0
/// Creates a new intrinic shield for an NPC template and returns it
/// @param elem: The conig element defining the NPC
/// @param pkg: The package
/// @returns The created shield or NULL if none is defined in the template
UArmor* create_intrinsic_shield_from_npctemplate( Clib::ConfigElem& elem, const Plib::Package* pkg )
{
  std::string tmp;
  if ( elem.remove_prop( "Shield", &tmp ) )
  {
    // Construct an ArmorTemplate for this NPC template.
    Clib::ConfigElem shieldelem;
    shieldelem.set_rest( elem.rest() );
    shieldelem.set_source( elem );
    shieldelem.add_prop( "Objtype", "0xFFFF" );
    shieldelem.add_prop( "Graphic", "1" );
    shieldelem.add_prop( "SaveOnExit", "0" );
    shieldelem.add_prop( "AR", tmp.c_str() );

    if ( elem.remove_prop( "ShieldMaxHp", &tmp ) )
      shieldelem.add_prop( "MaxHP", tmp.c_str() );
    else
      shieldelem.add_prop( "MaxHP", "1" );

    if ( elem.remove_prop( "ShieldOnHitScript", &tmp ) )
      shieldelem.add_prop( "OnHitScript", tmp.c_str() );

    while ( elem.remove_prop("ShieldCProp", &tmp) )
      shieldelem.add_prop( "CProp", tmp.c_str() );

    return create_intrinsic_shield( elem.rest(), shieldelem, pkg );
  }
  else
  {
    return NULL;
  }
}
Example #3
0
// Strength
// Dexterity
void load_general_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  checka( elem,
          networkManager.uoclient_general.strength,
          "Strength" );
  checka( elem,
          networkManager.uoclient_general.intelligence,
          "Intelligence" );
  checka( elem,
          networkManager.uoclient_general.dexterity,
          "Dexterity" );
  checkv( elem,
          networkManager.uoclient_general.hits,
          "Hits" );
  checkv( elem,
          networkManager.uoclient_general.stamina,
          "Stamina" );
  checkv( elem,
          networkManager.uoclient_general.mana,
          "Mana" );
  //dave changed 3/15/03, support configurable max skillid
  networkManager.uoclient_general.maxskills = elem.remove_ushort( "MaxSkillID", SKILLID__HIGHEST );
  std::string temp;
  if ( elem.remove_prop( "MethodScript", &temp ) )
  {
    if ( !temp.empty() )
    {
      ExportScript* shs = new ExportScript( pkg, temp );
      if ( shs->Initialize() )
        networkManager.uoclient_general.method_script = shs;
      else
        delete shs;
    }
  }
}
Example #4
0
	void read_bannedips_config( bool initial_load )
	{
	  if ( !initial_load )
	  {
		Core::networkManager.banned_ips.clear();
	  }
	  if ( !Clib::FileExists( "config/bannedips.cfg" ) )
		return;

	  Clib::ConfigFile cf( "config/bannedips.cfg" );
	  Clib::ConfigElem elem;

	  while ( cf.read( elem ) )
	  {
		IPRule CurrentEntry;
		std::string iptext = elem.remove_string( "IPMatch" );
		std::string::size_type delim = iptext.find_first_of( "/" );
		if ( delim != std::string::npos )
		{
          std::string ipaddr_str = iptext.substr(0, delim);
          std::string ipmask_str = iptext.substr(delim + 1);
		  CurrentEntry.ipMatch = inet_addr( ipaddr_str.c_str() );
		  CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() );
		  Core::networkManager.banned_ips.push_back( CurrentEntry );
		}
		else
		{
          std::string ipmask_str = "255.255.255.255";
		  CurrentEntry.ipMatch = inet_addr( iptext.c_str() );
		  CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() );
		  Core::networkManager.banned_ips.push_back( CurrentEntry );
		}
	  }
	}
Example #5
0
AuxService::AuxService( const Plib::Package* pkg, Clib::ConfigElem& elem ) :
  _pkg( pkg ),
  _scriptdef( elem.remove_string( "SCRIPT" ), _pkg ),
  _port( elem.remove_ushort( "PORT" ) )
{
  std::string iptext;
  while ( elem.remove_prop( "IPMATCH", &iptext ) )
  {
    auto delim = iptext.find_first_of("/");
    if (delim != std::string::npos)
    {
      std::string ipaddr_str = iptext.substr(0, delim);
      std::string ipmask_str = iptext.substr(delim + 1);
      unsigned int ipaddr = inet_addr( ipaddr_str.c_str() );
      unsigned int ipmask = inet_addr( ipmask_str.c_str() );
      _aux_ip_match.push_back( ipaddr );
      _aux_ip_match_mask.push_back( ipmask );
    }
    else
    {
      unsigned int ipaddr = inet_addr( iptext.c_str() );
      _aux_ip_match.push_back( ipaddr );
      _aux_ip_match_mask.push_back( 0xFFffFFffLu );
    }
  }
}
Example #6
0
UOSkill::UOSkill( const Plib::Package* pkg, Clib::ConfigElem& elem )
    : inited( true ),
      skillid( strtoul( elem.rest(), nullptr, 10 ) ),
      attributename( elem.remove_string( "Attribute", "" ) ),
      pAttr( nullptr ),
      pkg( pkg )
{
  if ( skillid >= 500 )
    elem.throw_error( "SkillID must be < 500" );

  if ( !attributename.empty() )
  {
    bool required = false;
    if ( attributename[0] == '+' )
    {
      required = true;
      attributename = attributename.substr( 1, std::string::npos );
    }
    pAttr = Mobile::Attribute::FindAttribute( attributename );
    if ( !pAttr )
    {
      if ( required )
      {
        elem.throw_error( "Attribute " + attributename + " not found." );
      }
      else
      {
        elem.warn( "Attribute " + attributename + " not found." );
      }
    }
  }
}
Example #7
0
UoClientListener::UoClientListener( Clib::ConfigElem& elem ) :
  port( elem.remove_ushort( "PORT" ) ),
  aosresist( elem.remove_bool( "AOSRESISTANCES", false ) ),
  sticky( elem.remove_bool( "KeepClients", false ) )

{
  CalculateCryptKeys( elem.remove_string( "ENCRYPTION", "none" ), encryption );
}
Example #8
0
void load_uoclient_entry( const Plib::Package* pkg, Clib::ConfigElem& elem )
{
  if ( elem.type_is( "general" ) )
    load_general_entry( pkg, elem );
  else if ( elem.type_is( "protocol" ) )
    load_protocol_entry( pkg, elem );
  else if ( elem.type_is( "listener" ) )
    load_listener_entry( pkg, elem );
}
Example #9
0
	JusticeRegion::JusticeRegion( Clib::ConfigElem& elem, RegionId id ) :
	  Region( elem, id ),
	  guarded_( elem.remove_bool( "Guarded", false ) ),
	  nocombat_( elem.remove_bool( "NoCombat", false ) ),
	  region_name_( elem.rest() ),
	  entertext_( elem.remove_string( "EnterText", "" ) ),
	  leavetext_( elem.remove_string( "LeaveText", "" ) ),
	  enter_script_( elem.remove_string( "EnterScript", "" ) ),
	  leave_script_( elem.remove_string( "LeaveScript", "" ) )
	{}
Example #10
0
/// Since the constructor is doing some wrong guessing to tell when an armor is a shield,
/// forceShield will force to consider it a shield
ArmorDesc::ArmorDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package* pkg,
                      bool forceShield )
    : EquipDesc( objtype, elem, ARMORDESC, pkg ),
      ar( elem.remove_ushort( "AR", 0 ) ),
      zones(),
      on_hit_script( elem.remove_string( "ONHITSCRIPT", "" ), pkg, "scripts/items/" )
{
  std::string coverage;
  while ( elem.remove_prop( "COVERAGE", &coverage ) )
  {
    try
    {
      zones.insert( Mobile::zone_name_to_zone( coverage.c_str() ) );
    }
    catch ( std::runtime_error& )
    {
      fmt::Writer tmp;
      tmp.Format( "Error in Objtype 0x{:X}" ) << objtype;
      if ( pkg == NULL )
        tmp << "config/itemdesc.cfg\n";
      else
        tmp << pkg->dir() << "itemdesc.cfg\n";

      ERROR_PRINT << tmp.str();
      throw;
    }
  }

  if ( zones.empty() )
  {
    // No 'COVERAGE' entries existed.
    // default coverage based on object type/layer
    unsigned short layer = Plib::systemstate.tile[graphic].layer;
    // special case for shields - they effectively have no coverage.
    if ( !forceShield && layer != Core::LAYER_HAND1 && layer != Core::LAYER_HAND2 )
    {
      try
      {
        zones.insert( Mobile::layer_to_zone( layer ) );
      }
      catch ( std::runtime_error& )
      {
        fmt::Writer tmp;
        tmp.Format( "Error in Objtype 0x{:X}" ) << objtype;
        if ( pkg == NULL )
          tmp << "config/itemdesc.cfg\n";
        else
          tmp << pkg->dir() << "itemdesc.cfg\n";

        ERROR_PRINT << tmp.str();
        throw;
      }
    }
  }
}
Example #11
0
void read_global_data( Clib::ConfigElem& elem )
{
  ResourceDef* rd = find_resource_def( elem.rest() );
  if ( rd == nullptr )
  {
    ERROR_PRINT << "Error reading RESOURCE.DAT: Unable to find resource type " << elem.rest()
                << "\n";
    throw std::runtime_error( "Data file error" );
  }

  rd->read_data( elem );
}
Example #12
0
/// Resource Management
ResourceRegion::ResourceRegion( Clib::ConfigElem& elem, RegionId id )
    : Region( elem, id ),
      tilecount_( 0 ),

      units_per_area_( elem.remove_ulong( "UnitsPerArea" ) ),
      seconds_per_regrow_( elem.remove_ulong( "SecondsPerRegrow" ) ),
      last_regen_( poltime() ),

      capacity_( elem.remove_ulong( "Capacity" ) ),
      units_( 0 )

{
}
Example #13
0
	void UCorpse::readProperties( Clib::ConfigElem& elem )
	{
	  // corpses can be the same color as mobiles
	  u16 savecolor = elem.remove_ushort( "COLOR", 0 );

	  base::readProperties( elem );

	  color = savecolor;

	  elem.remove_prop( "CorpseType", &corpsetype );
	  elem.remove_prop( "OwnerSerial", &ownerserial );
	  take_contents_to_grave = elem.remove_bool( "TakeContentsToGrave", false );
	  movable_ = false;
	}
Example #14
0
	void read_multidefs()
	{
      Clib::ConfigFile cf( "config/multis.cfg", "BOAT HOUSE STAIRS" );
      Clib::ConfigElem elem;
	  while ( cf.read( elem ) )
	  {
		u16 multiid = static_cast<u16>( strtoul( elem.rest(), NULL, 0 ) );

		MultiDef* mdef = new MultiDef( elem, multiid );
		mdef->init();

		multidef_buffer.multidefs_by_multiid[mdef->multiid] = mdef;
	  }
	}
Example #15
0
	void Account::writeto( Clib::ConfigElem& elem ) const
	{
	  elem.add_prop( "Name", name_.c_str() );

	  //dave 6/5/3 don't write cleartext unless configured to
	  if ( Plib::systemstate.config.retain_cleartext_passwords && !password_.empty( ) )
		elem.add_prop( "Password", password_.c_str() );

	  elem.add_prop( "PasswordHash", passwordhash_.c_str() );

	  elem.add_prop( "Enabled", ( (unsigned int)( enabled_ ? 1 : 0 ) ) );
	  elem.add_prop( "Banned", ( (unsigned int)( banned_ ? 1 : 0 ) ) );

	  if ( !default_privs_.empty() )
	  {
		elem.add_prop( "DefaultPrivs", default_privs_.extract().c_str() );
	  }
	  if ( default_cmdlevel_ )
	  {
		elem.add_prop( "DefaultCmdLevel", Core::gamestate.cmdlevels[default_cmdlevel_].name.c_str( ) );
	  }
	  if ( uo_expansion_ )
	  {
		elem.add_prop( "UOExpansion", uo_expansion().c_str() );
	  }
	  props_.printProperties( elem );
	}
Example #16
0
	Mobile::NPC* add_npc( const char* npctype, unsigned short x, unsigned short y, short z )
	{
	  Clib::ConfigFile cfile;
	  Clib::ConfigElem elem;
	  if ( !Core::FindNpcTemplate( npctype, cfile, elem ) )
	  {
          throw std::runtime_error(std::string("NPC template '") + npctype + "' not found");
	  }

	  auto  npc = new Mobile::NPC( elem.remove_ushort( "OBJTYPE" ), elem );
	  elem.clear_prop( "Serial" );
	  elem.clear_prop( "X" );
	  elem.clear_prop( "Y" );
	  elem.clear_prop( "Z" );

	  elem.add_prop( "Serial", GetNextSerialNumber() );
	  elem.add_prop( "X", x );
	  elem.add_prop( "Y", y );
	  elem.add_prop( "Z", z );
	  npc->readPropertiesForNewNPC( elem );

	  objStorageManager.objecthash.Insert( npc );

	  SetCharacterWorldPosition( npc, WorldChangeReason::NpcCreate );
	  return npc;
	}
Example #17
0
RealmDescriptor RealmDescriptor::Load(const std::string& realm_name, const std::string& realm_path)
{
  std::string realm_cfg_filename;
  if ( realm_path == "" )
    realm_cfg_filename = "realm/" + realm_name + "/realm.cfg";
  else
    realm_cfg_filename = realm_path + "/realm.cfg";

  Clib::ConfigFile cf( realm_cfg_filename, "REALM" );
  Clib::ConfigElem elem;
  if ( !cf.read( elem ) )
    elem.throw_error( "Unable to read configuration file " + realm_cfg_filename );

  return RealmDescriptor( realm_name, realm_path, elem );
}
Example #18
0
void set_watch_vars()
{
  Clib::ConfigFile cf;
  Clib::ConfigElem elem;
  if ( Clib::FileExists( "config/watch.cfg" ) )
  {
    cf.open( "config/watch.cfg" );
    cf.readraw( elem );
  }
  else if ( Plib::systemstate.config.loglevel > 1 )
    INFO_PRINT << "File config/watch.cfg not found, skipping.\n";

  settingsManager.watch.combat = elem.remove_bool( "COMBAT", false );
  settingsManager.watch.profile_scripts = elem.remove_bool( "ProfileScripts", false );
}
Example #19
0
CmdLevel::CmdLevel( Clib::ConfigElem& elem, int cmdlevelnum )
    : name( elem.rest() ), cmdlevel( static_cast<unsigned char>( cmdlevelnum ) )
{
  Clib::mklower( name );
  std::string tmp;
  while ( elem.remove_prop( "DIR", &tmp ) )
  {
    Clib::mklower( tmp );
    add_searchdir( nullptr, Clib::normalized_dir_form( tmp ) );
  }
  while ( elem.remove_prop( "ALIAS", &tmp ) )
  {
    Clib::mklower( tmp );
    aliases.push_back( tmp );
  }
}
Example #20
0
void checkv( Clib::ConfigElem& elem, UoClientGeneral::Mapping& mapping, const char* tag )
{
  if ( !mapping.any )
  {
    std::string name;
    if ( elem.remove_prop( tag, &name ) )
    {
      mapping.name = name;
      mapping.any = true;
      Vital* pVital = FindVital( name );
      if ( pVital )
        mapping.id = pVital->vitalid;
      else
        elem.throw_error( "Vital " + name + " not found" );
    }
  }
}
Example #21
0
void checka( Clib::ConfigElem& elem, UoClientGeneral::Mapping& mapping, const char* tag )
{
  if ( !mapping.any )
  {
    std::string name;
    if ( elem.remove_prop( tag, &name ) )
    {
      mapping.name = name;
      mapping.any = true;
      Mobile::Attribute* pAttr = Mobile::Attribute::FindAttribute( name );
      if ( pAttr )
        mapping.id = pAttr->attrid;
      else
        elem.throw_error( "Attribute " + name + " not found" );
    }
  }
}
Example #22
0
void ResourceDef::read_config( Clib::ConfigElem& elem )
{
  initial_units_ = elem.remove_ulong( "InitialUnits" );

  // start current_units at initial_units in case there's no entry in
  // RESOURCE.DAT
  current_units_ = initial_units_;

  unsigned short tmp;
  while ( elem.remove_prop( "LandTile", &tmp ) )
  {
    landtiles_.insert( tmp );
  }
  while ( elem.remove_prop( "ObjType", &tmp ) )
  {
    tiles_.insert( tmp );
  }
}
Example #23
0
void read_region_data( Clib::ConfigElem& elem )
{
  ResourceDef* rd = find_resource_def( elem.rest() );
  if ( rd == nullptr )
  {
    ERROR_PRINT << "Error reading RESOURCE.DAT: Unable to find resource type " << elem.rest()
                << "\n";
    throw std::runtime_error( "Data file error" );
  }
  std::string regionname = elem.remove_string( "Name" );
  ResourceRegion* rgn = rd->getregion( regionname );
  if ( rgn == nullptr )
  {
    ERROR_PRINT << "Error reading RESOURCE.DAT: Unable to find region " << regionname
                << " in resource " << elem.rest() << "\n";
    throw std::runtime_error( "Data file error" );
  }
  rgn->read_data( elem );
}
Example #24
0
void load_system_hooks()
{
  /*
    system_hooks.clear();
    while (!export_scripts.empty())
    {
    delete export_scripts.back();
    export_scripts.pop_back();
    }
    */
  for ( Plib::Packages::const_iterator citr = Plib::systemstate.packages.begin( ); citr != Plib::systemstate.packages.end( ); ++citr )
  {
    Plib::Package* pkg = ( *citr );
    //string fname = pkg->dir() + "syshook.cfg";
    std::string fname = Plib::GetPackageCfgPath(pkg, "syshook.cfg");
    if ( Clib::FileExists( fname.c_str() ) )
    {
      Clib::ConfigFile cf( fname.c_str( ), "SystemHookScript" );
      Clib::ConfigElem elem;
      while ( cf.read( elem ) )
      {
        ExportScript* shs = new ExportScript( pkg, elem.rest() );
        if ( shs->Initialize() )
        {
          gamestate.export_scripts.push_back( shs );
          std::string hookname, exfuncname;
          while ( elem.remove_first_prop( &hookname, &exfuncname ) )
          {
            if ( exfuncname.empty() )
              exfuncname = hookname;
            hook( shs, hookname, exfuncname );
          }
        }
        else
        {
          delete shs;
        }
      }
    }
  }
}
Example #25
0
void MapWriter::OpenExistingFiles(const std::string& realm_name)
{
  using std::ios;

  _realm_name = realm_name;

  std::string directory = "realm/" + _realm_name + "/";

  std::string realm_cfg_filename = directory + "realm.cfg";
  Clib::ConfigFile cf( realm_cfg_filename, "REALM" );
  Clib::ConfigElem elem;
  if ( !cf.read( elem ) )
    throw std::runtime_error("Unable to read realm from " + realm_cfg_filename);
  _width = elem.remove_ushort( "width" );
  _height = elem.remove_ushort( "height" );

  std::string filename = directory + "base.dat";
  Clib::open_file( _ofs_base, filename, ios::in | ios::out | ios::binary );


  // First-level Solids index (solidx1)
  filename = directory + "solidx1.dat";
  Clib::open_file( _ofs_solidx1, filename, ios::in | ios::out | ios::binary );

  // Second-level Solids index (solidx2)
  filename = directory + "solidx2.dat";
  Clib::open_file( _ofs_solidx2, filename, ios::in | ios::out | ios::binary );
  _ofs_solidx2.seekp( 0, ios::end );
  solidx2_offset = _ofs_solidx2.tellp();

  // Solids data (solids)
  filename = directory + "solids.dat";
  Clib::open_file( _ofs_solids, filename, ios::in | ios::out | ios::binary );
  _ofs_solids.seekp( 0, ios::end );
  solids_offset = _ofs_solids.tellp();

  // Maptile (maptile.dat)
  filename = directory + "maptile.dat";
  Clib::open_file( _ofs_maptile, filename, ios::in | ios::out | ios::binary );
  _ofs_maptile.seekp( 0, ios::end );
}
Example #26
0
void read_resources_dat()
{
  std::string resourcefile = Plib::systemstate.config.world_data_path + "resource.dat";

  if ( Clib::FileExists( resourcefile ) )
  {
    Clib::ConfigFile cf( resourcefile, "GLOBALRESOURCEPOOL REGIONALRESOURCEPOOL" );
    Clib::ConfigElem elem;
    while ( cf.read( elem ) )
    {
      if ( elem.type_is( "GlobalResourcePool" ) )
      {
        read_global_data( elem );
      }
      else
      {
        read_region_data( elem );
      }
    }
  }
}
Example #27
0
void process_package_cmds_cfg( Plib::Package* pkg )
{
  // ConfigFile cf( (pkg->dir() + "cmds.cfg").c_str(), "Commands" );
  Clib::ConfigFile cf( GetPackageCfgPath( pkg, "cmds.cfg" ).c_str(), "Commands" );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    CmdLevel* cmdlevel = find_cmdlevel( elem.rest() );
    if ( !cmdlevel )
    {
      elem.throw_error( std::string( "Command Level " ) + elem.rest() + " not found." );
    }

    std::string tmp;
    while ( elem.remove_prop( "DIR", &tmp ) )
    {
      Clib::mklower( tmp );
      cmdlevel->add_searchdir_front( pkg, Clib::normalized_dir_form( pkg->dir() + tmp ) );
    }
  }
}
Example #28
0
	USpell::USpell( Clib::ConfigElem& elem, Plib::Package* pkg ) :
	  pkg_( pkg ),
	  spellid_( elem.remove_ushort( "SPELLID" ) ),
	  name_( elem.remove_string( "NAME" ) ),
	  power_words_( elem.remove_string( "POWERWORDS" ) ),
	  scriptdef_( elem.remove_string( "SCRIPT", "" ), pkg, "scripts/" )
	{
	  unsigned short action;
	  if ( elem.remove_prop( "ANIMATION", &action ) )
	  {
		if ( UACTION_IS_VALID( action ) )
		{
		  action_ = static_cast<UACTION>( action );
		}
		else
		{
		  elem.throw_error( "Animation is out of range" );
		}
	  }
	  else
	  {
		action_ = ACTION_CAST_SPELL1;
	  }

	  unsigned short circle;
	  if ( elem.remove_prop( "CIRCLE", &circle ) )
	  {
		if ( circle < 1 || circle > spellcircles.size() ||
			 spellcircles[circle - 1] == NULL )
		{
          ERROR_PRINT << "Error reading spell " << name_
            << ": Circle " << circle << " is not defined.\n";
		  throw std::runtime_error( "Config file error" );
		}

		params_ = spellcircles[circle - 1]->params;
	  }
	  else
	  {
		params_ = USpellParams( elem );
	  }

	  std::string reagent_name;
	  while ( elem.remove_prop( "Reagent", &reagent_name ) )
	  {
        unsigned int reagent = Items::get_objtype_from_string( reagent_name );

		reglist_.push_back( reagent );
	  }
	}
Example #29
0
void load_resource_cfg()
{
  if ( !Clib::FileExists( "regions/resource.cfg" ) )
  {
    if ( Plib::systemstate.config.loglevel > 1 )
      INFO_PRINT << "File regions/resource.cfg not found, skipping.\n";
    return;
  }

  Clib::ConfigFile cf( "regions/resource.cfg", "ResourceSystem" );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    std::string resourcename;
    while ( elem.remove_prop( "ResourceType", &resourcename ) )
    {
      read_resource_cfg( resourcename.c_str() );
    }
  }
  if ( Plib::systemstate.config.count_resource_tiles )
    count_resource_tiles();
}
Example #30
0
void read_resource_cfg( const char* resource )
{
  std::string filename = std::string( "regions/" ) + resource + std::string( ".cfg" );
  Clib::ConfigFile cf( filename.c_str(), "GLOBAL REGION" );
  Clib::ConfigElem elem;

  std::unique_ptr<ResourceDef> rd( new ResourceDef( resource ) );

  while ( cf.read( elem ) )
  {
    if ( elem.type_is( "global" ) )
    {
      rd->read_config( elem );
    }
    else
    {
      rd->read_region( elem );
    }
  }

  gamestate.resourcedefs[resource] = rd.release();
}