Example #1
0
void read_guilds_dat()
{
    string guildsfile = config.world_data_path + "guilds.txt";

	if (!FileExists( guildsfile ))
        return;

    ConfigFile cf( guildsfile );
    ConfigSection sect_general( cf, "GENERAL", CST_UNIQUE );
    ConfigSection sect_guild( cf, "GUILD", CST_NORMAL );
    ConfigElem elem;
    while (cf.read( elem ))
    {
        if (sect_general.matches( elem ))
        {
            nextguildid = elem.remove_ulong( "NEXTGUILDID", 1 );
        }
        else if (sect_guild.matches( elem ))
        {
            Guild* guild = new Guild(elem);
            guilds[ guild->guildid() ].set( guild );
        }
    }

    register_guilds();
}
Example #2
0
void read_bannedips_config( bool initial_load)
{
	if (!initial_load)
	{
		banned_ips.clear();
	}
    if (!FileExists( "config/bannedips.cfg" ))
        return;

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

	while (cf.read( elem ))
    {
		IPRule CurrentEntry;
		string iptext = elem.remove_string( "IPMatch" );
		string::size_type delim = iptext.find_first_of( "/" );
		if (delim != string::npos)
		{
			string ipaddr_str = iptext.substr( 0, delim );
			string ipmask_str = iptext.substr( delim+1 );
			CurrentEntry.ipMatch = inet_addr( ipaddr_str.c_str() );
			CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() );
			banned_ips.push_back(CurrentEntry);
		}
		else
		{
			string ipmask_str = "255.255.255.255";
			CurrentEntry.ipMatch = inet_addr( iptext.c_str() );
			CurrentEntry.ipMask = inet_addr( ipmask_str.c_str() );
			banned_ips.push_back(CurrentEntry);
		}
	}
}
Example #3
0
void Storage::read( ConfigFile& cf )
{
    static int num_until_dot = 1000;
    unsigned long nobjects = 0;

    StorageArea *area = NULL;
    ConfigElem elem;

    clock_t start = clock();

    while (cf.read( elem ))
    {
        if (--num_until_dot == 0)
        {
            cout << ".";
            num_until_dot = 1000;
        }
        if (elem.type_is( "StorageArea" ))
        {
            area = create_area( elem );
        }
        else if (elem.type_is("Item"))
        {
            if (area != NULL)
            {
                try 
                {
                    area->load_item( elem );
                }
                catch( std::exception& )
                {
                    if (!config.ignore_load_errors)
                        throw;
                }
            }
            else
            {
                cerr << "Storage: Got an ITEM element, but don't have a StorageArea to put it." << endl;
                throw runtime_error( "Data file integrity error" );
            }
        }
        else
        {
            cerr << "Unexpected element type " << elem.type() << " in storage file." << endl;
            throw runtime_error( "Data file integrity error" );
        }
		++nobjects;
    }

	clock_t end = clock();
	long ms = static_cast<long>((end-start) * 1000.0 / CLOCKS_PER_SEC);

	cout << " " << nobjects << " elements in " << ms << " ms." << std::endl;
}
Example #4
0
void read_stacking_cfg(ConfigFile& cf)
{
	ConfigElem elem;
	if( cf.read( elem ) )
	{
		if (elem.type_is( "Stacking" ))
		{
			string temp = elem.remove_string( "IgnoreCprops" );
			ISTRINGSTREAM is( temp );
			string cprop_name;
			while (is >> cprop_name)
				Global_Ignore_CProps.insert(cprop_name);
		}
	}
Example #5
0
bool ConfigSection::matches( const ConfigElem& elem )
{
  if( elem.type_is( _sectname.c_str() ) )
  {
    if( _found && ( _flags & CST_UNIQUE ) )
    {
      elem.throw_error( "Section type " + _sectname + " found more than once" );
    }
    _found = true;
    return true;
  }
  else
  {
    return false;
  }
}
Example #6
0
SerialSet::SerialSet( ConfigElem& elem, const char* tag )
{
    unsigned long tmp;
    while (elem.remove_prop( tag, &tmp ))
    {
        insert( tmp );
    }
}
Example #7
0
int xmain( int argc, char* argv[] )
{
    StoreCmdArgs( argc, argv );
    if (FindArg2( "uodata=" ) != NULL)
    {
        config.uo_datafile_root = FindArg2( "uodata=" );
        config.uo_datafile_root = normalized_dir_form( config.uo_datafile_root );
    }
    else
    {
        cout << "Reading pol.cfg." << endl;
        ConfigFile cf( "pol.cfg" );
        ConfigElem elem;

        cf.readraw( elem );
        config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" );
        config.uo_datafile_root = normalized_dir_form( config.uo_datafile_root );
        
        unsigned short max_tile = elem.remove_ushort( "MaxTileID", 0x3FFF );

		if (max_tile != 0x3FFF && max_tile != 0x7FFF)
			config.max_tile_id = 0x3FFF;
		else
			config.max_tile_id = max_tile;
    }


    string main_cfg = "uoconvert.cfg";
	if (FileExists( main_cfg.c_str() ) )
	{
        string temp;
        ConfigElem elem;
        cout << "Reading uoconvert.cfg." << endl;
		ConfigFile cf_main( main_cfg.c_str() );
	    while( cf_main.read( elem ) )
	    {
		    if (elem.type_is( "MultiTypes" ))
		    {
			    temp = elem.remove_string( "Boats" );
			    ISTRINGSTREAM is_boats( temp );
			    string graphicnum;
			    while (is_boats >> graphicnum)
				    BoatTypes.insert(strtoul(graphicnum.c_str(),NULL,0));

			    temp = elem.remove_string( "Houses" );
			    ISTRINGSTREAM is_houses( temp );
			    while (is_houses >> graphicnum)
				    HouseTypes.insert(strtoul(graphicnum.c_str(),NULL,0));

			    temp = elem.remove_string( "Stairs" );
			    ISTRINGSTREAM is_stairs( temp );
			    while (is_stairs >> graphicnum)
				    StairTypes.insert(strtoul(graphicnum.c_str(),NULL,0));
		    }
            else if (elem.type_is( "LOSOptions" ))
Example #8
0
FileAccess::FileAccess( ConfigElem& elem ) :
	AllowWrite( elem.remove_bool( "AllowWrite", false ) ),
	AllowAppend( elem.remove_bool( "AllowAppend", false ) ),
	AllowRead( elem.remove_bool( "AllowRead", false ) ),
	AllowRemote( elem.remove_bool( "AllowRemote", false ) ),
	AllPackages( false ),
	AllDirectories( false ),
	AllExtensions( false )
{
	string tmp;
	while (elem.remove_prop( "Package", &tmp ))
	{
		if (tmp == "*")
			AllPackages = true;
		else
			Packages.insert( tmp );
	}
	while (elem.remove_prop( "Directory", &tmp ))
	{
		if (tmp == "*")
			AllDirectories = true;
		else
			Directories.push_back( tmp );
	}
	while (elem.remove_prop( "Extension", &tmp ))
	{
		if (tmp == "*")
			AllExtensions = true;
		else
			Extensions.push_back( tmp );
	}
}
Example #9
0
Guild::Guild( ConfigElem& elem ) :
    _guildid( elem.remove_ushort( "GUILDID" ) ),
    _member_serials( elem, "MEMBER" ),
    _allyguild_serials( elem, "ALLYGUILD" ),
    _enemyguild_serials( elem, "ENEMYGUILD" ),
    _proplist(),
    _disbanded(false)
{
    _proplist.readProperties( elem );
}
Example #10
0
void StorageArea::load_item( ConfigElem& elem )
{
    // if this object is modified in a subsequent incremental save,
    // don't load it yet. 
    pol_serial_t serial = 0;
    elem.get_prop( "SERIAL", &serial );
    if (get_save_index( serial ) > current_incremental_save)
        return;

	u32 container_serial = 0;
	elem.remove_prop( "CONTAINER", &container_serial );

    Item *item = read_item( elem );
	//Austin added 8/10/2006, protect against further crash if item is null. Should throw instead?
	if (item == NULL)
	{
		elem.warn_with_line("Error reading item SERIAL or OBJTYPE.");
		return;
	}
	if (container_serial == 0)
    {
        insert_root_item( item );
    }
	else
	{
        Item *cont_item = ::system_find_item( container_serial );

		if (cont_item)
		{
            add_loaded_item( cont_item, item );
		}
        else
        {
            defer_item_insertion( item, container_serial );
        }
	}
}
Example #11
0
UOSkill::UOSkill( const Package* pkg, ConfigElem& elem ) :
    inited(true),
        skillid( strtoul( elem.rest(), NULL, 10 ) ),
    attributename(elem.remove_string( "Attribute", "" )),
    pAttr(NULL),
    pkg(pkg)
{
    if (skillid < 0 || 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 = FindAttribute( attributename );
        if (!pAttr)
        {
            if (required)
            {
                elem.throw_error( "Attribute " 
                                    + tostring(attributename)
                                    + " not found." );
            }
            else
            {
                elem.warn( "Attribute " 
                                    + tostring(attributename)
                                    + " not found." );
            }
        }
    }
}
Example #12
0
void load_skill_entry( const Package* pkg, ConfigElem& elem )
{
    UOSkill uoskill( pkg, elem );

    if ( uoskill.skillid >= uo_skills.size() )
        uo_skills.resize( uoskill.skillid+1 );
    
    if ( uo_skills[uoskill.skillid].inited )
    {
        elem.throw_error( "UOSkill "
                            + tostring(uoskill.skillid) 
                            + " already defined by " 
                            + uo_skills[uoskill.skillid].pkg->desc() );
    }
    
    uo_skills[ uoskill.skillid ] = uoskill;
}
Example #13
0
void CompilerConfig::Read( const string& path )
{
    ConfigFile cf( path.c_str() );
    ConfigElem elem;
    cf.readraw( elem );

    PackageRoot.clear();
    IncludeDirectory.clear();

    string tmp;
    while (elem.remove_prop( "PackageRoot", &tmp ))
    {
        PackageRoot.push_back( normalized_dir_form(tmp) );
    }
    if (elem.remove_prop( "IncludeDirectory", &tmp ))
    {
        IncludeDirectory = normalized_dir_form(tmp);
    }
    ModuleDirectory = normalized_dir_form(elem.remove_string( "ModuleDirectory" ));
    PolScriptRoot = normalized_dir_form(elem.remove_string( "PolScriptRoot" ));
	GenerateListing = elem.remove_bool( "GenerateListing", false );
	GenerateDebugInfo = elem.remove_bool( "GenerateDebugInfo", false );
	GenerateDebugTextInfo = elem.remove_bool( "GenerateDebugTextInfo", false );
    DisplayWarnings = elem.remove_bool( "DisplayWarnings", false );
    CompileAspPages = elem.remove_bool( "CompileAspPages", false );
    AutoCompileByDefault = elem.remove_bool( "AutoCompileByDefault", false );
    UpdateOnlyOnAutoCompile = elem.remove_bool( "UpdateOnlyOnAutoCompile", false );
    OnlyCompileUpdatedScripts = elem.remove_bool( "OnlyCompileUpdatedScripts", false );
    DisplaySummary = elem.remove_bool( "DisplaySummary", false );
    OptimizeObjectMembers = elem.remove_bool( "OptimizeObjectMembers", true);
    GenerateDependencyInfo = elem.remove_bool( "GenerateDependencyInfo", OnlyCompileUpdatedScripts );

	ThreadedCompilation = elem.remove_bool( "ThreadedCompilation", false );
    DisplayUpToDateScripts = elem.remove_bool( "DisplayUpToDateScripts", true );    

	// This is where we TRY to validate full paths from what was provided in the
	// ecompile.cfg. Maybe Turley or Shini can find the best way to do this in *nix.
#ifdef WIN32
	string MyPath = path.c_str();
	// If it's just "ecompile.cfg", let's change it to the exe's path which it SHOULD be
	// with. 
	if (stricmp(MyPath.c_str(), "ecompile.cfg") == 0)
	{
		// Let's find the NEXT-TO-LAST / in the path, and remove from there on. Oh yay!
		// To bad we can't just force everyone to use ABSOLUTE PATHS NANDO. :o
		MyPath = xmain_exedir.substr(0, xmain_exedir.length()-1);
		MyPath = MyPath.substr(0, MyPath.find_last_of( '/')+1);
	}
	if (IncludeDirectory.find(':') == string::npos)
	{
		if (IncludeDirectory.substr(0, 1) != ".") // Let's make sure they didn't try using this method
		{
			IncludeDirectory = MyPath + IncludeDirectory;
		}
	}
	if (ModuleDirectory.find(':') == string::npos)
	{
		if (ModuleDirectory.substr(0, 1) != ".") // Let's make sure they didn't try using this method
		{
			ModuleDirectory = MyPath + ModuleDirectory;
		}
	}
	if (PolScriptRoot.find(':') == string::npos)
	{
		if (PolScriptRoot.substr(0, 1) != ".") // Let's make sure they didn't try using this method
		{
			PolScriptRoot = MyPath + PolScriptRoot;
		}
	}
	for( unsigned pr = 0; pr < PackageRoot.size(); ++pr )
    {
		if (PackageRoot[pr].find(':') == string::npos)
		{
			if (PackageRoot[pr].substr(0, 1) != ".") // Let's make sure they didn't try using this method
			{
				PackageRoot[pr] = MyPath + PackageRoot[pr];
			}
		}
    }

#endif
}
Example #14
0
int xmain( int argc, char* argv[] )
{
    StoreCmdArgs( argc, argv );
    ConfigFile cf( "pol.cfg" );
    ConfigElem elem;

    cf.readraw( elem );

    config.uo_datafile_root = elem.remove_string( "UoDataFileRoot" );
    config.uo_datafile_root = normalized_dir_form( config.uo_datafile_root );

	unsigned short max_tile = elem.remove_ushort( "MaxTileID", 0x3FFF );

	if (max_tile != 0x3FFF && max_tile != 0x7FFF)
		config.max_tile_id = 0x3FFF;
	else
		config.max_tile_id = max_tile;

	if (argc <= 1)
		return Usage(1);

    if (argv[1][0] == '/' || argv[1][1] == ':')
    {
        config.uo_datafile_root = argv[1];
        --argc;
        ++argv;
    }

	if (stricmp( argv[1], "tiledump" ) == 0)
	{
		return tiledump( argc, argv );
	}
	else if (stricmp( argv[1], "vertile" ) == 0)
	{
		return vertile( argc, argv );
	}
    else if (stricmp( argv[1], "verlandtile" ) == 0)
    {
        return verlandtile( argc, argv );
    }
    else if (stricmp( argv[1], "landtilehist" ) == 0)
    {
        return landtilehist( argc, argv );
    }
	else if (stricmp( argv[1], "flagsearch" ) == 0)
	{
		return flagsearch( argc, argv );
	}
	else if (stricmp( argv[1], "landtileflagsearch" ) == 0)
	{
		return landtileflagsearch( argc, argv );
	}
    else if (stricmp( argv[1], "loschange" ) == 0)
    {
        return loschange( argc, argv );
    }
	else if (stricmp( argv[1], "rawdump" ) == 0)
	{
		return rawdump( argc, argv );
	}
    else if (stricmp( argv[1], "ctable" ) == 0)
    {
        return print_ctable();
    }
    else if (stricmp( argv[1], "sndlist" ) == 0)
    {
        return print_sndlist(argc, argv);
    }
    else if (stricmp( argv[1], "statics" ) == 0)
    {
        return print_statics();
    }
    else if (stricmp( argv[1], "verdata" ) == 0)
    {
        return print_verdata_info();
    }
    else if (stricmp( argv[1], "multis" ) == 0)
    {
        return print_multis();
    }
    else if (stricmp( argv[1], "water" ) == 0)
    {
        return print_water_data();
    }
    else if (stricmp( argv[1], "newstatics" ) == 0)
    {
        return write_pol_static_files( "main" );
    }
    else if (stricmp( argv[1], "staticsmax" ) == 0)
    {
        void staticsmax();
        open_uo_data_files();
        staticsmax();
        return 0;
    }
    else if (stricmp( argv[1], "watersearch" ) == 0)
    {
        return water_search(argc,argv);
    }
    else if (stricmp( argv[1], "zhist" ) == 0)
    {
        return z_histogram();
    }
    else if (stricmp( argv[1], "staticshist" ) == 0)
    {
        return statics_histogram();
    }
    else if (stricmp( argv[1], "writedungmap" ) == 0)
    {
        return write_polmap();
    }
    else if (stricmp( argv[1], "writekeys" ) == 0)
    {
        printf( "Keys written to current.key" );
        return 0;
    }
    else if (stricmp( argv[1], "mapdump" ) == 0)
    {
        return mapdump( argc, argv );
    }
    else if (stricmp( argv[1], "contour" ) == 0)
    {
        return contour( argc, argv );
    }
    else if (stricmp( argv[1], "findlandtile" ) == 0)
    {
        return findlandtile( argc-1, argv+1 );
    }
	else if (stricmp( argv[1], "findlandtileflags" ) == 0)
	{
		return findlandtileflags( argc-1, argv+1 );
	}
    else if (stricmp( argv[1], "findgraphic" ) == 0)
    {
        return findgraphic( argc-1, argv+1 );
    }
    else if (stricmp( argv[1], "defragstatics" ) == 0)
    {
        return defragstatics( argc-1, argv+1 );
    }
    
	return 0;
}
Example #15
0
void read_combat_config()
{
	ConfigFile cf;
	ConfigElem elem;

    if (FileExists( "config/combat.cfg" ))
    {
		if ( config.loglevel > 1 ) {
			cout << "Loading combat.cfg options\n";
		}
        cf.open( "config/combat.cfg" );
        cf.readraw( elem );
    } else if ( config.loglevel > 1 ) {
		cout << "File config/combat.cfg not found, skipping.\n";
	}

	combat_config.display_parry_success_messages = elem.remove_bool("DisplayParrySuccessMessages", false);
	combat_config.warmode_inhibits_regen = elem.remove_bool("WarmodeInhibitsRegen", false);
	combat_config.attack_self = elem.remove_bool("SingleCombat", false);
	combat_config.warmode_delay = elem.remove_ulong("WarModeDelay", 1);
	combat_config.core_hit_sounds = elem.remove_bool("CoreHitSounds", false);
	combat_config.scripted_attack_checks = elem.remove_bool("ScriptedAttackChecks", false);
	combat_config.reset_swing_onturn = elem.remove_bool("ResetSwingOnTurn", false);
	combat_config.send_swing_packet = elem.remove_bool("SendSwingPacket", true);
    combat_config.send_damage_packet = elem.remove_bool("SendDamagePacket", false);		
	combat_config.core_attack_effects = elem.remove_bool("CoreAttackEffects", true);
}