

bool YOU_ARE_NOT_ALONE = false;
	// 0: Player has no opponents (Stock PotC)
	// 1: One opponent from each nation will be added (They will have skills, perks and experience, like main character. They will increase skills and gain experience automatically. They can capture ships and some colonies too. You must be quick in this world, or you will be last in heroes list.)

bool SAILING_MESSENGER = true;
	// 0: Interface (boal_map)
	// 1: Dialog window

// Inez/NK BuildSettings backend
// 05-07-25
object BuildSettingsCats[256];
object BSDirectory;
int BUILDSETTINGS_CATS_QUANTITY = 0;

// ******* lookup and handling functions

// returns the setting in the specified category
string GetBuildSetting(string cat, string setting)
{
	ref bsc = GetBuildSettingCat(cat);
	// NB we're not doing a CheckAttribute() call for speed reasons (though with few settings and split into multiple cats we should be OK)
	// but we should never be in a situation where a needed setting doesn't exist--because we will init with default values at start of game and then overwrite with custom.
	// but if we were doing a check, it'd be:
	//if(!CheckAttribute(bsc, setting)) return "";
	return bsc.(setting);
}

// gets index for category 'id'
int GetBuildSettingCatIndex(string id)
{
	return NativeFindCharacter(&BuildSettingsCats, id);
}

// gets reference to category 'id'
ref GetBuildSettingCat(string id)
{
	int idx = GetBuildSettingCatIndex(id);
	if(idx == -1) return NullCharacter;
	return &BuildSettingsCats[idx];
}

// gets reference to category 'id' if it exists, or creates it and returns the reference if not.
ref GetOrCreateBuildSettingCat(string id)
{
	int idx = NativeFindCharacter(&BuildSettingsCats, id);
	if(idx == -1)
	{
		idx = BUILDSETTINGS_CATS_QUANTITY;
		BUILDSETTINGS_CATS_QUANTITY++;
		BuildSettingsCats[idx].id = id;
	}
	return &BuildSettingsCats[idx];
}

// clears BuildSettings slot n directly, irrespective of where in the array it is
// please don't use this function directly; either use ClearBuildSettingSlot() to delete a BuildSetting, or InitBuildSettings() to start from scratch.
void ClearBuildSettingCatSlotDirect(int n, bool indexonly)
{
	ref BuildSettingCat; makeref(BuildSettingCat, BuildSettingsCats[n]);
	if(!indexonly)
	{
		DeleteAttribute(&BuildSettingCat, "");
		//DeleteAttribute(&BuildSettingCat, "types");
		BuildSettingCat.id = "blank";
	}
	BuildSettingCat.index = n;
}

// use this to clear a slot instead. This will refill that slot, if it's not at the end of the array, with another nonblank slot, keeping all blank slots at the end of the array.
void ClearBuildSettingCatSlot(int n)
{
	bool bdirect = BUILDSETTINGS_CATS_QUANTITY <= 1;
	if(!bdirect)
	{
		if(n >= BUILDSETTINGS_CATS_QUANTITY-1)
		{
			bdirect = true;
			BUILDSETTINGS_CATS_QUANTITY = n; // assume there's nothing after this, even though we use >= above.
		}
	}
			
	if(bdirect)
	{
		ClearBuildSettingCatSlotDirect(n, false);
		return;
	}
	DeleteAttribute(&BuildSettingsCats[n], "");
	BUILDSETTINGS_CATS_QUANTITY--;
	CopyAttributes(&BuildSettingsCats[n], &BuildSettingsCats[BUILDSETTINGS_CATS_QUANTITY]);
	BuildSettingsCats[n].index = n;
	ClearBuildSettingCatSlotDirect(BUILDSETTINGS_CATS_QUANTITY, false);
}

void SaveBuildSettings()
{
	object temp;
	ref curBS;
	string tmpstr;
	ref rtmp;
	for(int i = 0; i < BUILDSETTINGS_CATS_QUANTITY; i++)
	{
		DeleteAttribute(&temp, "");
		curBS = &BuildSettingsCats[i];
		CopyAttributes(&temp, &curBS);
        //Inez: Attribute kept to gather the junk that gets appended in writing. 
		//DeleteAttribute(&temp, "index");
		makeref(rtmp, temp);
		tmpstr = "BuildSettings\\BS_"+rtmp.id+".cfg";
		SendMessage(&GameInterface, "lsa", MSG_INTERFACE_SAVEOPTIONS, tmpstr, rtmp);
	}
}

void LoadBuildSettings()
{
	DeleteAttribute(&BSDirectory, "");
	InitBuildSettings(false);
	
	BSDirectory.dir = "BuildSettings\\";
	BSDirectory.mask = "*.cfg";
	CreateEntity(&BSDirectory,"FINDFILESINTODIRECTORY");
	DeleteClass(&BSDirectory);
	aref arList;
	//trace("dumping directory");
	//dumpattributes(&BSDirectory);
	makearef(arList, BSDirectory.filelist);
	object otmp;
	ref rtmp;
	makeref(rtmp, otmp);
	for(int i = 0; i < GetAttributesNum(arList); i++)
	{
		DeleteAttribute(&rtmp, "");
		aref arCur = GetAttributeN(arList, i);
		string fname = GetAttributeValue(arCur);
		//trace("found filename " + fname);
		string catname = fname;

        //if(HasSubStr(fname, "BS_")) catname = strcut(fname, 3, strlen(fname)-1);
        //Inez: strip file extension
        if(HasSubStr(fname, "BS_")) catname = strcut(fname, 3, strlen(fname)-5);

		//trace("new catname " + catname);
		ref BSCat = GetOrCreateBuildSettingCat(catname);
        //trace("New Category: " + BSCat.id); 
		int idx = sti(BSCat.index);
		//trace("created BSCat " + catname + ", dump:");
		//DumpAttributes(BSCat);
		SendMessage(&GameInterface, "lsa", MSG_INTERFACE_LOADOPTIONS, "BuildSettings\\"+fname, rtmp);
		//trace("Attribs of tempobj are:");
		//DumpAttributes(rtmp);
		CopyAttributes(&BSCat, &rtmp);

        //Inez: replace 
        BSCat.id = catname; 
	    BSCat.index = idx;
	}
	//InitBuildSettings(true);
}

// MAXIMUS -->
void InitBuildOptions(bool bDefault)
{
	if(!CheckAttribute(PlayerProfile,"BuildSettings") || bDefault)
	{
		PlayerProfile.BuildSettings.START_LEVEL = 1;
		PlayerProfile.BuildSettings.START_MONEY = 1000;
		PlayerProfile.BuildSettings.START_WEALTH = 500;
		PlayerProfile.BuildSettings.CHOOSABLE_NEWGAMESKILLS = true;
		PlayerProfile.BuildSettings.RANDOM_RELATIONS = false;
		PlayerProfile.BuildSettings.CHANGING_RELATIONS = false;
		PlayerProfile.BuildSettings.AUTO_SKILL_SYSTEM = true;
		PlayerProfile.BuildSettings.SKILLS_UP_BONUS = 35;
		PlayerProfile.BuildSettings.SKIP_LOGOVIDEO = false;
		PlayerProfile.BuildSettings.DEATHRATE = 1;
		PlayerProfile.BuildSettings.ENABLE_WEAPONSMOD = true;
		PlayerProfile.BuildSettings.START_DIFF_SHIPCAP = 0;
		PlayerProfile.BuildSettings.WDMAP_SHIP_SHOW_MODE = 0;
		PlayerProfile.BuildSettings.SAILHO_INFOLEVEL = 2;
		PlayerProfile.BuildSettings.COASTRAIDER_CHANCE = 0.2;
		PlayerProfile.BuildSettings.REDUCE_CR = 0;
		PlayerProfile.BuildSettings.WEATHER_UPDATE_AT_SEA = true;
		PlayerProfile.BuildSettings.ENABLE_FLAGS = true;
		PlayerProfile.BuildSettings.USE_MINSAILCREW = true;
		PlayerProfile.BuildSettings.SAIL_DAMAGE_TURNRATE = true;
		PlayerProfile.BuildSettings.SURR_GLOBAL_SCL = 0.1;
		PlayerProfile.BuildSettings.LDH_TURN_RATE_FACTOR = 1.5;
		PlayerProfile.BuildSettings.ARCADE_MULT_SPEED = 2;
		PlayerProfile.BuildSettings.ENABLE_FIREDRILL = true;
		PlayerProfile.BuildSettings.VISIT_DECK = true;
		PlayerProfile.BuildSettings.AUTO_AIMED_FIRE = true;
		PlayerProfile.BuildSettings.USE_REAL_CANNONS = true;
		PlayerProfile.BuildSettings.ALLOW_CRIT_FROM_BALLS = true;
		PlayerProfile.BuildSettings.ALLOW_FIRE_FROM_BALLS = true;		
		PlayerProfile.BuildSettings.EXTRA_HIT_CHECK = true;
		PlayerProfile.BuildSettings.CANNON_RANGE_SCALAR = 1.0;
		PlayerProfile.BuildSettings.CANNON_DAMAGE_SCALAR = 0.5;
		PlayerProfile.BuildSettings.CANNONPOWDER_MOD = true;
		PlayerProfile.BuildSettings.ARCADE_MULT_CANNONS = 0.5;
		PlayerProfile.BuildSettings.BOARDERMODEL = "standard";
		PlayerProfile.BuildSettings.RANSOM_PRISONERS = true;
		PlayerProfile.BuildSettings.CAPTURE_COLONIES = true;
		PlayerProfile.BuildSettings.KBSPG = 2;
		PlayerProfile.BuildSettings.FOOD_ON = true;
		PlayerProfile.BuildSettings.AUTOHIRECREW_ONCHANGESHIP = true;		
		PlayerProfile.BuildSettings.REALREPAIR = true;
		PlayerProfile.BuildSettings.SY_RPG_STYLE = true;
		PlayerProfile.BuildSettings.REALISTIC_SHIP_PURCHASE = true;
		PlayerProfile.BuildSettings.IT_RPG_STYLE = true;
		PlayerProfile.BuildSettings.SALARY_MULTIPLIER = 3;
		PlayerProfile.BuildSettings.CANNOT_RELOAD_WHILE_FIGHTING = true;
		PlayerProfile.BuildSettings.ENABLE_AMMOMOD = true;
		PlayerProfile.BuildSettings.BLADEDAMAGE_ENABLED = true;
		PlayerProfile.BuildSettings.BLOCKDAMAGE = 1;
		PlayerProfile.BuildSettings.CORPSEMODE = 3;//MAXIMUS: by this way CORPSEMODE 3 will hidden from options-interface
		PlayerProfile.BuildSettings.AUTOLOOT_ON = false;
		PlayerProfile.BuildSettings.REALISTIC_HEALTH_ITEMS = true;
		PlayerProfile.BuildSettings.DIALOG_CAMERA = 0.0;
		PlayerProfile.BuildSettings.GREATER_OXBAY = true;
		PlayerProfile.BuildSettings.ENABLE_BROTHEL = true;
		PlayerProfile.BuildSettings.PORT_FASTTRAVEL_MOD = true;
		PlayerProfile.BuildSettings.ENABLE_BUILDINGSET = true;
		PlayerProfile.BuildSettings.PATROL_ADRESSING = true;
		PlayerProfile.BuildSettings.NO_THEFT = 0;
		PlayerProfile.BuildSettings.LOCK_OPEN = 0;
		PlayerProfile.BuildSettings.SKELETON_CHANCE = 0.15;
		PlayerProfile.BuildSettings.MUMMY_CHANCE = 0.15;
		PlayerProfile.BuildSettings.NAPOLEONIC_ERA = true;
		PlayerProfile.BuildSettings.REAL_CARIBBEAN = true;
		PlayerProfile.BuildSettings.ENABLE_SMALLLOG = true;
		PlayerProfile.BuildSettings.LOC_CAMERA = false;
		PlayerProfile.BuildSettings.ONSEA_COMPASS = 1;
		PlayerProfile.BuildSettings.DISPLAY_SEA_TIME = false;
		PlayerProfile.BuildSettings.DISPLAY_BATTLEINTERFACE = false;
		PlayerProfile.BuildSettings.DISPLAY_MAP_POSITION = false;
		PlayerProfile.BuildSettings.DEFAULT_SAILS = 3;
		PlayerProfile.BuildSettings.PIRATES_BLACK_SAILS = false;
		PlayerProfile.BuildSettings.SHIPHIT_PARTICLES = 2;
		PlayerProfile.BuildSettings.USE_PARTICLES = 2;
		PlayerProfile.BuildSettings.AERO_SKIES = true;
		PlayerProfile.BuildSettings.KB_TUNESHIPS = true;
		trace("==> BuildSettings: Sets to default");
	}
	else
	{
		START_LEVEL = PlayerProfile.BuildSettings.START_LEVEL;
		START_MONEY = PlayerProfile.BuildSettings.START_MONEY;
		START_WEALTH = PlayerProfile.BuildSettings.START_WEALTH;
		if(!AUTO_SKILL_SYSTEM) { CHOOSABLE_NEWGAMESKILLS = PlayerProfile.BuildSettings.CHOOSABLE_NEWGAMESKILLS; }
		else { CHOOSABLE_NEWGAMESKILLS = false; }
		RANDOM_RELATIONS = PlayerProfile.BuildSettings.RANDOM_RELATIONS;
		CHANGING_RELATIONS = PlayerProfile.BuildSettings.CHANGING_RELATIONS;
		AUTO_SKILL_SYSTEM = PlayerProfile.BuildSettings.AUTO_SKILL_SYSTEM;
		SKILLS_UP_BONUS = PlayerProfile.BuildSettings.SKILLS_UP_BONUS;
		SKIP_LOGOVIDEO = PlayerProfile.BuildSettings.SKIP_LOGOVIDEO;
		DEATHRATE = PlayerProfile.BuildSettings.DEATHRATE;
		ENABLE_WEAPONSMOD = PlayerProfile.BuildSettings.ENABLE_WEAPONSMOD;
		START_DIFF_SHIPCAP = PlayerProfile.BuildSettings.START_DIFF_SHIPCAP;
		WDMAP_SHIP_SHOW_MODE = PlayerProfile.BuildSettings.WDMAP_SHIP_SHOW_MODE;
		SAILHO_INFOLEVEL = PlayerProfile.BuildSettings.SAILHO_INFOLEVEL;
		COASTRAIDER_CHANCE = PlayerProfile.BuildSettings.COASTRAIDER_CHANCE;
		REDUCE_CR = PlayerProfile.BuildSettings.REDUCE_CR;
		WEATHER_UPDATE_AT_SEA = PlayerProfile.BuildSettings.WEATHER_UPDATE_AT_SEA;
		ENABLE_FLAGS = PlayerProfile.BuildSettings.ENABLE_FLAGS;
		USE_MINSAILCREW = PlayerProfile.BuildSettings.USE_MINSAILCREW;
		SAIL_DAMAGE_TURNRATE = PlayerProfile.BuildSettings.SAIL_DAMAGE_TURNRATE;
		SURR_GLOBAL_SCL = PlayerProfile.BuildSettings.SURR_GLOBAL_SCL;
		LDH_TURN_RATE_FACTOR = PlayerProfile.BuildSettings.LDH_TURN_RATE_FACTOR;
		ARCADE_MULT_SPEED = PlayerProfile.BuildSettings.ARCADE_MULT_SPEED;
		VISIT_DECK = PlayerProfile.BuildSettings.VISIT_DECK;
		AUTO_AIMED_FIRE = PlayerProfile.BuildSettings.AUTO_AIMED_FIRE;
		USE_REAL_CANNONS = PlayerProfile.BuildSettings.USE_REAL_CANNONS;
		ALLOW_CRIT_FROM_BALLS = PlayerProfile.BuildSettings.ALLOW_CRIT_FROM_BALLS;
		ALLOW_FIRE_FROM_BALLS = PlayerProfile.BuildSettings.ALLOW_FIRE_FROM_BALLS;		
		EXTRA_HIT_CHECK = PlayerProfile.BuildSettings.EXTRA_HIT_CHECK;
		CANNON_RANGE_SCALAR = PlayerProfile.BuildSettings.CANNON_RANGE_SCALAR;
		CANNON_DAMAGE_SCALAR = PlayerProfile.BuildSettings.CANNON_DAMAGE_SCALAR;
		CANNONPOWDER_MOD = PlayerProfile.BuildSettings.CANNONPOWDER_MOD;
		ARCADE_MULT_CANNONS = PlayerProfile.BuildSettings.ARCADE_MULT_CANNONS;
		BOARDERMODEL = PlayerProfile.BuildSettings.BOARDERMODEL;
		RANSOM_PRISONERS = PlayerProfile.BuildSettings.RANSOM_PRISONERS;
		CAPTURE_COLONIES = PlayerProfile.BuildSettings.CAPTURE_COLONIES;
		KBSPG = PlayerProfile.BuildSettings.KBSPG;
		FOOD_ON = PlayerProfile.BuildSettings.FOOD_ON;
		AUTOHIRECREW_ONCHANGESHIP = PlayerProfile.BuildSettings.AUTOHIRECREW_ONCHANGESHIP;		
		REALREPAIR = PlayerProfile.BuildSettings.REALREPAIR;
		SY_RPG_STYLE = PlayerProfile.BuildSettings.SY_RPG_STYLE;
		REALISTIC_SHIP_PURCHASE = PlayerProfile.BuildSettings.REALISTIC_SHIP_PURCHASE;
		IT_RPG_STYLE = PlayerProfile.BuildSettings.IT_RPG_STYLE;
		SALARY_MULTIPLIER = PlayerProfile.BuildSettings.SALARY_MULTIPLIER;
		CANNOT_RELOAD_WHILE_FIGHTING = PlayerProfile.BuildSettings.CANNOT_RELOAD_WHILE_FIGHTING;
		ENABLE_AMMOMOD = PlayerProfile.BuildSettings.ENABLE_AMMOMOD;
		BLADEDAMAGE_ENABLED = PlayerProfile.BuildSettings.BLADEDAMAGE_ENABLED;
		BLOCKDAMAGE = PlayerProfile.BuildSettings.BLOCKDAMAGE;
		//MAXIMUS: by this way CORPSEMODE 3 is hidden from options-interface -->
		CORPSEMODE = sti(PlayerProfile.BuildSettings.CORPSEMODE);
		switch(CORPSEMODE)
		{
			case 3: CORPSEMODE = 4; break;
			case 4: CORPSEMODE = 3; break;
		}
		//MAXIMUS: by this way CORPSEMODE 3 is hidden from options-interface <--
		//=======================| ON/OFF SHOW IN CONTROLS-INTERFACE |=======================//
		objControlsState.keygroups.General.NK_DialogStart.invisible = CORPSEMODE!=2;
		objControlsState.keygroups.PrimaryLand.NK_DialogStart.invisible = CORPSEMODE!=2;
		objControlsState.keygroups.FightModeControls.NK_DialogStart.invisible = CORPSEMODE!=2;
		//=======================| ON/OFF SHOW IN CONTROLS-INTERFACE |=======================//
		AUTOLOOT_ON = PlayerProfile.BuildSettings.AUTOLOOT_ON;
		REALISTIC_HEALTH_ITEMS = PlayerProfile.BuildSettings.REALISTIC_HEALTH_ITEMS;
		DIALOG_CAMERA = PlayerProfile.BuildSettings.DIALOG_CAMERA;
		GREATER_OXBAY = PlayerProfile.BuildSettings.GREATER_OXBAY;
		ENABLE_BROTHEL = PlayerProfile.BuildSettings.ENABLE_BROTHEL;
		PORT_FASTTRAVEL_MOD = PlayerProfile.BuildSettings.PORT_FASTTRAVEL_MOD;
		ENABLE_BUILDINGSET = PlayerProfile.BuildSettings.ENABLE_BUILDINGSET;
		PATROL_ADRESSING = PlayerProfile.BuildSettings.PATROL_ADRESSING;
		NO_THEFT = PlayerProfile.BuildSettings.NO_THEFT;
		LOCK_OPEN = PlayerProfile.BuildSettings.LOCK_OPEN;
		SKELETON_CHANCE = PlayerProfile.BuildSettings.SKELETON_CHANCE;
		MUMMY_CHANCE = PlayerProfile.BuildSettings.MUMMY_CHANCE;
		NAPOLEONIC_ERA = PlayerProfile.BuildSettings.NAPOLEONIC_ERA;
		REAL_CARIBBEAN = PlayerProfile.BuildSettings.REAL_CARIBBEAN;
		ENABLE_SMALLLOG = PlayerProfile.BuildSettings.ENABLE_SMALLLOG;
		LOC_CAMERA = PlayerProfile.BuildSettings.LOC_CAMERA;
		ONSEA_COMPASS = PlayerProfile.BuildSettings.ONSEA_COMPASS;
		DISPLAY_SEA_TIME = PlayerProfile.BuildSettings.DISPLAY_SEA_TIME;
		DISPLAY_BATTLEINTERFACE = PlayerProfile.BuildSettings.DISPLAY_BATTLEINTERFACE;
		DISPLAY_MAP_POSITION = PlayerProfile.BuildSettings.DISPLAY_MAP_POSITION;
		DEFAULT_SAILS = PlayerProfile.BuildSettings.DEFAULT_SAILS;
		PIRATES_BLACK_SAILS = PlayerProfile.BuildSettings.PIRATES_BLACK_SAILS;
		SHIPHIT_PARTICLES = PlayerProfile.BuildSettings.SHIPHIT_PARTICLES;
		USE_PARTICLES = PlayerProfile.BuildSettings.USE_PARTICLES;
		AERO_SKIES = PlayerProfile.BuildSettings.AERO_SKIES;
		KB_TUNESHIPS = PlayerProfile.BuildSettings.KB_TUNESHIPS;
		trace("==> BuildSettings: New settings applied");
	}
}

void GetBuildSettings()
{
	object bopt;
	string optionsPath = "options";
	if(CheckAttribute(&PlayerProfile,"name") && PlayerProfile.name!=DEFAULT_NAME)
	{
		if(FindFile(DEFAULT_PATH,"*",PlayerProfile.name+"_options")!="") optionsPath = DEFAULT_PATH+"\"+PlayerProfile.name+"_options";
	}

	GetBuildSettingsData(&bopt);
	SendMessage(&GameInterface, "lsa", MSG_INTERFACE_LOADOPTIONS, optionsPath, &bopt);
	UpdateBuildSettingsData(&bopt);
}

void GetBuildSettingsData(ref optref)
{
	InitBuildOptions(false);
	aref bSet; makearef(bSet, PlayerProfile.BuildSettings);
	if(CheckAttribute(optref,"Buildsettings")) DeleteAttribute(optref,"Buildsettings");
	if(CheckAttribute(optref,"PlayerProfile.profiles")) DeleteAttribute(optref,"PlayerProfile.profiles");

	for(int i=0; i<GetAttributesNum(bSet); i++)
	{
		aref curItem = GetAttributeN(bSet, i);
		string attrName = GetAttributeName(curItem);
		optref.Buildsettings.(attrName) = PlayerProfile.Buildsettings.(attrName);
	}

	if(CheckAttribute(PlayerProfile,"name")) optref.PlayerProfile.name = PlayerProfile.name;
	else optref.PlayerProfile.name = DEFAULT_NAME;
	if(CheckAttribute(PlayerProfile,"SavePath")) optref.PlayerProfile.SavePath = PlayerProfile.SavePath;
	else optref.PlayerProfile.SavePath = DEFAULT_PATH;
	if(CheckAttribute(PlayerProfile,"profiles"))
	{
		makearef(bSet, PlayerProfile.profiles);
		for(i=0; i<GetAttributesNum(bSet); i++)
		{
			curItem = GetAttributeN(bSet, i);
			attrName = GetAttributeName(curItem);
			optref.PlayerProfile.profiles.(attrName) = PlayerProfile.profiles.(attrName);
		}
	}
}

void UpdateBuildSettingsData(ref optref)
{
	aref bSet; makearef(bSet, PlayerProfile.BuildSettings);

	for(int i=0; i<GetAttributesNum(bSet); i++)
	{
		aref curItem = GetAttributeN(bSet, i);
		string attrName = GetAttributeName(curItem);
		if(CheckAttribute(optref,"Buildsettings."+attrName)) PlayerProfile.Buildsettings.(attrName) = optref.Buildsettings.(attrName);
	}

	InitBuildOptions(false);
	if(!CheckAttribute(PlayerProfile,"name")) PlayerProfile.name = optref.PlayerProfile.name;
	if(!CheckAttribute(PlayerProfile,"SavePath")) PlayerProfile.SavePath = optref.PlayerProfile.SavePath;
	if(CheckAttribute(optref,"PlayerProfile.profiles"))
	{
		makearef(bSet, optref.PlayerProfile.profiles);
		for(i=0; i<GetAttributesNum(bSet); i++)
		{
			curItem = GetAttributeN(bSet, i);
			attrName = GetAttributeName(curItem);
			if(CheckAttribute(bSet,attrName)) { PlayerProfile.profiles.(attrName) = bSet.(attrName); }
		}
	}
}
// <-- MAXIMUS

void InitBuildSettings(bool indexonly)
{
	ClearBuildSettingCatSlotDirect(0, indexonly);
	ClearBuildSettingCatSlotDirect(1, indexonly);
	ClearBuildSettingCatSlotDirect(2, indexonly);
	ClearBuildSettingCatSlotDirect(3, indexonly);
	ClearBuildSettingCatSlotDirect(4, indexonly);
	ClearBuildSettingCatSlotDirect(5, indexonly);
	ClearBuildSettingCatSlotDirect(6, indexonly);
	ClearBuildSettingCatSlotDirect(7, indexonly);
	ClearBuildSettingCatSlotDirect(8, indexonly);
	ClearBuildSettingCatSlotDirect(9, indexonly);
	ClearBuildSettingCatSlotDirect(10, indexonly);
	ClearBuildSettingCatSlotDirect(11, indexonly);
	ClearBuildSettingCatSlotDirect(12, indexonly);
	ClearBuildSettingCatSlotDirect(13, indexonly);
	ClearBuildSettingCatSlotDirect(14, indexonly);
	ClearBuildSettingCatSlotDirect(15, indexonly);
	ClearBuildSettingCatSlotDirect(16, indexonly);
	ClearBuildSettingCatSlotDirect(17, indexonly);
	ClearBuildSettingCatSlotDirect(18, indexonly);
	ClearBuildSettingCatSlotDirect(19, indexonly);
	ClearBuildSettingCatSlotDirect(20, indexonly);
	ClearBuildSettingCatSlotDirect(21, indexonly);
	ClearBuildSettingCatSlotDirect(22, indexonly);
	ClearBuildSettingCatSlotDirect(23, indexonly);
	ClearBuildSettingCatSlotDirect(24, indexonly);
	ClearBuildSettingCatSlotDirect(25, indexonly);
	ClearBuildSettingCatSlotDirect(26, indexonly);
	ClearBuildSettingCatSlotDirect(27, indexonly);
	ClearBuildSettingCatSlotDirect(28, indexonly);
	ClearBuildSettingCatSlotDirect(29, indexonly);
	ClearBuildSettingCatSlotDirect(30, indexonly);
	ClearBuildSettingCatSlotDirect(31, indexonly);
	ClearBuildSettingCatSlotDirect(32, indexonly);
	ClearBuildSettingCatSlotDirect(33, indexonly);
	ClearBuildSettingCatSlotDirect(34, indexonly);
	ClearBuildSettingCatSlotDirect(35, indexonly);
	ClearBuildSettingCatSlotDirect(36, indexonly);
	ClearBuildSettingCatSlotDirect(37, indexonly);
	ClearBuildSettingCatSlotDirect(38, indexonly);
	ClearBuildSettingCatSlotDirect(39, indexonly);
	ClearBuildSettingCatSlotDirect(40, indexonly);
	ClearBuildSettingCatSlotDirect(41, indexonly);
	ClearBuildSettingCatSlotDirect(42, indexonly);
	ClearBuildSettingCatSlotDirect(43, indexonly);
	ClearBuildSettingCatSlotDirect(44, indexonly);
	ClearBuildSettingCatSlotDirect(45, indexonly);
	ClearBuildSettingCatSlotDirect(46, indexonly);
	ClearBuildSettingCatSlotDirect(47, indexonly);
	ClearBuildSettingCatSlotDirect(48, indexonly);
	ClearBuildSettingCatSlotDirect(49, indexonly);
	ClearBuildSettingCatSlotDirect(50, indexonly);
	ClearBuildSettingCatSlotDirect(51, indexonly);
	ClearBuildSettingCatSlotDirect(52, indexonly);
	ClearBuildSettingCatSlotDirect(53, indexonly);
	ClearBuildSettingCatSlotDirect(54, indexonly);
	ClearBuildSettingCatSlotDirect(55, indexonly);
	ClearBuildSettingCatSlotDirect(56, indexonly);
	ClearBuildSettingCatSlotDirect(57, indexonly);
	ClearBuildSettingCatSlotDirect(58, indexonly);
	ClearBuildSettingCatSlotDirect(59, indexonly);
	ClearBuildSettingCatSlotDirect(60, indexonly);
	ClearBuildSettingCatSlotDirect(61, indexonly);
	ClearBuildSettingCatSlotDirect(62, indexonly);
	ClearBuildSettingCatSlotDirect(63, indexonly);
	ClearBuildSettingCatSlotDirect(64, indexonly);
	ClearBuildSettingCatSlotDirect(65, indexonly);
	ClearBuildSettingCatSlotDirect(66, indexonly);
	ClearBuildSettingCatSlotDirect(67, indexonly);
	ClearBuildSettingCatSlotDirect(68, indexonly);
	ClearBuildSettingCatSlotDirect(69, indexonly);
	ClearBuildSettingCatSlotDirect(70, indexonly);
	ClearBuildSettingCatSlotDirect(71, indexonly);
	ClearBuildSettingCatSlotDirect(72, indexonly);
	ClearBuildSettingCatSlotDirect(73, indexonly);
	ClearBuildSettingCatSlotDirect(74, indexonly);
	ClearBuildSettingCatSlotDirect(75, indexonly);
	ClearBuildSettingCatSlotDirect(76, indexonly);
	ClearBuildSettingCatSlotDirect(77, indexonly);
	ClearBuildSettingCatSlotDirect(78, indexonly);
	ClearBuildSettingCatSlotDirect(79, indexonly);
	ClearBuildSettingCatSlotDirect(80, indexonly);
	ClearBuildSettingCatSlotDirect(81, indexonly);
	ClearBuildSettingCatSlotDirect(82, indexonly);
	ClearBuildSettingCatSlotDirect(83, indexonly);
	ClearBuildSettingCatSlotDirect(84, indexonly);
	ClearBuildSettingCatSlotDirect(85, indexonly);
	ClearBuildSettingCatSlotDirect(86, indexonly);
	ClearBuildSettingCatSlotDirect(87, indexonly);
	ClearBuildSettingCatSlotDirect(88, indexonly);
	ClearBuildSettingCatSlotDirect(89, indexonly);
	ClearBuildSettingCatSlotDirect(90, indexonly);
	ClearBuildSettingCatSlotDirect(91, indexonly);
	ClearBuildSettingCatSlotDirect(92, indexonly);
	ClearBuildSettingCatSlotDirect(93, indexonly);
	ClearBuildSettingCatSlotDirect(94, indexonly);
	ClearBuildSettingCatSlotDirect(95, indexonly);
	ClearBuildSettingCatSlotDirect(96, indexonly);
	ClearBuildSettingCatSlotDirect(97, indexonly);
	ClearBuildSettingCatSlotDirect(98, indexonly);
	ClearBuildSettingCatSlotDirect(99, indexonly);
	ClearBuildSettingCatSlotDirect(100, indexonly);
	ClearBuildSettingCatSlotDirect(101, indexonly);
	ClearBuildSettingCatSlotDirect(102, indexonly);
	ClearBuildSettingCatSlotDirect(103, indexonly);
	ClearBuildSettingCatSlotDirect(104, indexonly);
	ClearBuildSettingCatSlotDirect(105, indexonly);
	ClearBuildSettingCatSlotDirect(106, indexonly);
	ClearBuildSettingCatSlotDirect(107, indexonly);
	ClearBuildSettingCatSlotDirect(108, indexonly);
	ClearBuildSettingCatSlotDirect(109, indexonly);
	ClearBuildSettingCatSlotDirect(110, indexonly);
	ClearBuildSettingCatSlotDirect(111, indexonly);
	ClearBuildSettingCatSlotDirect(112, indexonly);
	ClearBuildSettingCatSlotDirect(113, indexonly);
	ClearBuildSettingCatSlotDirect(114, indexonly);
	ClearBuildSettingCatSlotDirect(115, indexonly);
	ClearBuildSettingCatSlotDirect(116, indexonly);
	ClearBuildSettingCatSlotDirect(117, indexonly);
	ClearBuildSettingCatSlotDirect(118, indexonly);
	ClearBuildSettingCatSlotDirect(119, indexonly);
	ClearBuildSettingCatSlotDirect(120, indexonly);
	ClearBuildSettingCatSlotDirect(121, indexonly);
	ClearBuildSettingCatSlotDirect(122, indexonly);
	ClearBuildSettingCatSlotDirect(123, indexonly);
	ClearBuildSettingCatSlotDirect(124, indexonly);
	ClearBuildSettingCatSlotDirect(125, indexonly);
	ClearBuildSettingCatSlotDirect(126, indexonly);
	ClearBuildSettingCatSlotDirect(127, indexonly);
	ClearBuildSettingCatSlotDirect(128, indexonly);
	ClearBuildSettingCatSlotDirect(129, indexonly);
	ClearBuildSettingCatSlotDirect(130, indexonly);
	ClearBuildSettingCatSlotDirect(131, indexonly);
	ClearBuildSettingCatSlotDirect(132, indexonly);
	ClearBuildSettingCatSlotDirect(133, indexonly);
	ClearBuildSettingCatSlotDirect(134, indexonly);
	ClearBuildSettingCatSlotDirect(135, indexonly);
	ClearBuildSettingCatSlotDirect(136, indexonly);
	ClearBuildSettingCatSlotDirect(137, indexonly);
	ClearBuildSettingCatSlotDirect(138, indexonly);
	ClearBuildSettingCatSlotDirect(139, indexonly);
	ClearBuildSettingCatSlotDirect(140, indexonly);
	ClearBuildSettingCatSlotDirect(141, indexonly);
	ClearBuildSettingCatSlotDirect(142, indexonly);
	ClearBuildSettingCatSlotDirect(143, indexonly);
	ClearBuildSettingCatSlotDirect(144, indexonly);
	ClearBuildSettingCatSlotDirect(145, indexonly);
	ClearBuildSettingCatSlotDirect(146, indexonly);
	ClearBuildSettingCatSlotDirect(147, indexonly);
	ClearBuildSettingCatSlotDirect(148, indexonly);
	ClearBuildSettingCatSlotDirect(149, indexonly);
	ClearBuildSettingCatSlotDirect(150, indexonly);
	ClearBuildSettingCatSlotDirect(151, indexonly);
	ClearBuildSettingCatSlotDirect(152, indexonly);
	ClearBuildSettingCatSlotDirect(153, indexonly);
	ClearBuildSettingCatSlotDirect(154, indexonly);
	ClearBuildSettingCatSlotDirect(155, indexonly);
	ClearBuildSettingCatSlotDirect(156, indexonly);
	ClearBuildSettingCatSlotDirect(157, indexonly);
	ClearBuildSettingCatSlotDirect(158, indexonly);
	ClearBuildSettingCatSlotDirect(159, indexonly);
	ClearBuildSettingCatSlotDirect(160, indexonly);
	ClearBuildSettingCatSlotDirect(161, indexonly);
	ClearBuildSettingCatSlotDirect(162, indexonly);
	ClearBuildSettingCatSlotDirect(163, indexonly);
	ClearBuildSettingCatSlotDirect(164, indexonly);
	ClearBuildSettingCatSlotDirect(165, indexonly);
	ClearBuildSettingCatSlotDirect(166, indexonly);
	ClearBuildSettingCatSlotDirect(167, indexonly);
	ClearBuildSettingCatSlotDirect(168, indexonly);
	ClearBuildSettingCatSlotDirect(169, indexonly);
	ClearBuildSettingCatSlotDirect(170, indexonly);
	ClearBuildSettingCatSlotDirect(171, indexonly);
	ClearBuildSettingCatSlotDirect(172, indexonly);
	ClearBuildSettingCatSlotDirect(173, indexonly);
	ClearBuildSettingCatSlotDirect(174, indexonly);
	ClearBuildSettingCatSlotDirect(175, indexonly);
	ClearBuildSettingCatSlotDirect(176, indexonly);
	ClearBuildSettingCatSlotDirect(177, indexonly);
	ClearBuildSettingCatSlotDirect(178, indexonly);
	ClearBuildSettingCatSlotDirect(179, indexonly);
	ClearBuildSettingCatSlotDirect(180, indexonly);
	ClearBuildSettingCatSlotDirect(181, indexonly);
	ClearBuildSettingCatSlotDirect(182, indexonly);
	ClearBuildSettingCatSlotDirect(183, indexonly);
	ClearBuildSettingCatSlotDirect(184, indexonly);
	ClearBuildSettingCatSlotDirect(185, indexonly);
	ClearBuildSettingCatSlotDirect(186, indexonly);
	ClearBuildSettingCatSlotDirect(187, indexonly);
	ClearBuildSettingCatSlotDirect(188, indexonly);
	ClearBuildSettingCatSlotDirect(189, indexonly);
	ClearBuildSettingCatSlotDirect(190, indexonly);
	ClearBuildSettingCatSlotDirect(191, indexonly);
	ClearBuildSettingCatSlotDirect(192, indexonly);
	ClearBuildSettingCatSlotDirect(193, indexonly);
	ClearBuildSettingCatSlotDirect(194, indexonly);
	ClearBuildSettingCatSlotDirect(195, indexonly);
	ClearBuildSettingCatSlotDirect(196, indexonly);
	ClearBuildSettingCatSlotDirect(197, indexonly);
	ClearBuildSettingCatSlotDirect(198, indexonly);
	ClearBuildSettingCatSlotDirect(199, indexonly);
	ClearBuildSettingCatSlotDirect(200, indexonly);
	ClearBuildSettingCatSlotDirect(201, indexonly);
	ClearBuildSettingCatSlotDirect(202, indexonly);
	ClearBuildSettingCatSlotDirect(203, indexonly);
	ClearBuildSettingCatSlotDirect(204, indexonly);
	ClearBuildSettingCatSlotDirect(205, indexonly);
	ClearBuildSettingCatSlotDirect(206, indexonly);
	ClearBuildSettingCatSlotDirect(207, indexonly);
	ClearBuildSettingCatSlotDirect(208, indexonly);
	ClearBuildSettingCatSlotDirect(209, indexonly);
	ClearBuildSettingCatSlotDirect(210, indexonly);
	ClearBuildSettingCatSlotDirect(211, indexonly);
	ClearBuildSettingCatSlotDirect(212, indexonly);
	ClearBuildSettingCatSlotDirect(213, indexonly);
	ClearBuildSettingCatSlotDirect(214, indexonly);
	ClearBuildSettingCatSlotDirect(215, indexonly);
	ClearBuildSettingCatSlotDirect(216, indexonly);
	ClearBuildSettingCatSlotDirect(217, indexonly);
	ClearBuildSettingCatSlotDirect(218, indexonly);
	ClearBuildSettingCatSlotDirect(219, indexonly);
	ClearBuildSettingCatSlotDirect(220, indexonly);
	ClearBuildSettingCatSlotDirect(221, indexonly);
	ClearBuildSettingCatSlotDirect(222, indexonly);
	ClearBuildSettingCatSlotDirect(223, indexonly);
	ClearBuildSettingCatSlotDirect(224, indexonly);
	ClearBuildSettingCatSlotDirect(225, indexonly);
	ClearBuildSettingCatSlotDirect(226, indexonly);
	ClearBuildSettingCatSlotDirect(227, indexonly);
	ClearBuildSettingCatSlotDirect(228, indexonly);
	ClearBuildSettingCatSlotDirect(229, indexonly);
	ClearBuildSettingCatSlotDirect(230, indexonly);
	ClearBuildSettingCatSlotDirect(231, indexonly);
	ClearBuildSettingCatSlotDirect(232, indexonly);
	ClearBuildSettingCatSlotDirect(233, indexonly);
	ClearBuildSettingCatSlotDirect(234, indexonly);
	ClearBuildSettingCatSlotDirect(235, indexonly);
	ClearBuildSettingCatSlotDirect(236, indexonly);
	ClearBuildSettingCatSlotDirect(237, indexonly);
	ClearBuildSettingCatSlotDirect(238, indexonly);
	ClearBuildSettingCatSlotDirect(239, indexonly);
	ClearBuildSettingCatSlotDirect(240, indexonly);
	ClearBuildSettingCatSlotDirect(241, indexonly);
	ClearBuildSettingCatSlotDirect(242, indexonly);
	ClearBuildSettingCatSlotDirect(243, indexonly);
	ClearBuildSettingCatSlotDirect(244, indexonly);
	ClearBuildSettingCatSlotDirect(245, indexonly);
	ClearBuildSettingCatSlotDirect(246, indexonly);
	ClearBuildSettingCatSlotDirect(247, indexonly);
	ClearBuildSettingCatSlotDirect(248, indexonly);
	ClearBuildSettingCatSlotDirect(249, indexonly);
	ClearBuildSettingCatSlotDirect(250, indexonly);
	ClearBuildSettingCatSlotDirect(251, indexonly);
	ClearBuildSettingCatSlotDirect(252, indexonly);
	ClearBuildSettingCatSlotDirect(253, indexonly);
	ClearBuildSettingCatSlotDirect(254, indexonly);
	ClearBuildSettingCatSlotDirect(255, indexonly);
	if(!indexonly) BUILDSETTINGS_CATS_QUANTITY = 0;
}
