//----------------------------------------------------------------------------
void CBuildingPhysicalGuild::dumpBuilding(NLMISC::CLog & log) const
{
	log.displayNL("<BUILDING_DUMP> CBuildingPhysicalGuild");
	log.displayNL("Name: %s, alias: %s", _Name.c_str(), CPrimitivesParser::aliasToString( _Alias ).c_str());

	for (uint i = 0; i < _UsersInside.size(); i++)
	{
		const TDataSetRow rowId = _UsersInside[i];
		CCharacter * c = PlayerManager.getChar( rowId );
		if ( !c )
		{
			log.displayNL("\tError: cannot find character with row id: %s", rowId.toString().c_str());
			continue;
		}

		const string charName = c->getName().toUtf8();
		const string charEId = c->getId().toString();

		CMirrorPropValueRO<TYPE_CELL> mirrorCell(TheDataset, rowId, DSPropertyCELL);
		const sint32 cell = mirrorCell;

		IRoomInstance * room = CBuildingManager::getInstance()->getRoomInstanceFromCell( cell );
		if ( !room )
		{
			log.displayNL("\tError: character %s %s is in cell %d but no room was found", charName.c_str(), charEId.c_str(), cell);
			continue;
		}

		CRoomInstanceGuild * guildRoom = dynamic_cast<CRoomInstanceGuild *>(room);
		if ( !guildRoom )
		{
			log.displayNL("\tError: character %s %s is in cell %d but room is not a guild room but a %s",
				charName.c_str(), charEId.c_str(), cell, room->getRoomDescription().c_str()
				);
			continue;
		}

		const uint32 guildId = c->getGuildId();
		string guildName;
		CGuild * guild = CGuildManager::getInstance()->getGuildFromId( guildId );
		if (guild)
			guildName = guild->getName().toUtf8();

		log.displayNL("\tCharacter %s %s [guild name='%s' id=%u] is in cell %d, room desc: %s",
			charName.c_str(), charEId.c_str(), guildName.c_str(), guildId, cell, room->getRoomDescription().c_str()
			);
	}

	for (uint i = 0; i < _Guilds.size(); i++)
	{
		const uint32 guildId = _Guilds[i];
		string guildName;
		CGuild * guild = CGuildManager::getInstance()->getGuildFromId( guildId );
		if (guild)
			guildName = guild->getName().toUtf8();

		log.displayNL("\t> Guild registered in building at index %u: %s", i, guildName.c_str());
	}
}
//----------------------------------------------------------------------------
void COutpostGuildDBUpdater::updateOutpostGuildDBOUTPOST_PROPERTIES()
{
	CGuild* owner = CGuildManager::getInstance()->getGuildFromId(_Outpost->_OwnerGuildId);
	CGuild* attacker = CGuildManager::getInstance()->getGuildFromId(_Outpost->_AttackerGuildId);
//	uint32 const OWNED					= (_Side == OUTPOSTENUMS::OutpostOwner)?1:0;
//	uint32 const SHEET					= _Outpost->_Sheet.asInt();
//	uint32 const LEVEL					= _Outpost->getStaticForm()?_Outpost->getStaticForm()->Level:0;
	ucstring const GUILD_NAME				= owner?owner->getName():ucstring();
	uint64 const GUILD_ICON				= owner?owner->getIcon():0;
//	uint32 const TRIBE					= _Outpost->isBelongingToAGuild()?0:1;
	ucstring const GUILD_NAME_ATT			= attacker?attacker->getName():ucstring();
//	uint32 const STATUS					= _Outpost->computeStatusForClient();
//	uint32 const DISPLAY_CRASH			= _Outpost->_CrashHappened?1:0;
	uint32 const WARCOST				= _Outpost->_Form->ChallengeCost;
	uint32 const ROUND_LVL_THRESHOLD	= _Outpost->_CurrentOutpostLevel;
	uint32 const ROUND_LVL_MAX_ATT		= _Outpost->_FightData._MaxAttackLevel;
	uint32 const ROUND_LVL_MAX_DEF		= _Outpost->_FightData._MaxDefenseLevel;
	uint32 const ROUND_LVL_CUR			= _Outpost->_FightData._CurrentCombatLevel;
	uint32 const ROUND_ID_CUR			= _Outpost->_FightData._CurrentCombatRound;
	uint32 const ROUND_ID_MAX			= _Outpost->computeRoundCount();
	uint32 const TIME_RANGE_DEF_WANTED	= _Outpost->_DefenseHour;
	uint32 const TIME_RANGE_DEF			= _Outpost->computeTimeRangeDefForClient();
	uint32 const TIME_RANGE_ATT			= _Outpost->computeTimeRangeAttForClient();
	uint32 const TIME_RANGE_LENGTH		= _Outpost->computeTimeRangeLengthForClient();
	uint32 const SQUAD_CAPITAL			= (_Side == OUTPOSTENUMS::OutpostOwner) ? _Outpost->_OwnerExpenseLimit : _Outpost->_AttackerExpenseLimit;
	
	setOWNED(_Side == OUTPOSTENUMS::OutpostOwner);
	
	setSHEET(_Outpost->_Sheet);
	setLEVEL(_Outpost->getStaticForm()?_Outpost->getStaticForm()->Level:0);
	setGUILD__NAME(GUILD_NAME);
	setGUILD__ICON(GUILD_ICON);
	setGUILD__TRIBE(!_Outpost->isBelongingToAGuild());
	setGUILD__NAME_ATT(GUILD_NAME_ATT);
	setSTATUS(_Outpost->computeStatusForClient());
	setDISPLAY_CRASH(_Outpost->_CrashHappened);
	setWARCOST(WARCOST);
	
	setROUND_LVL_THRESHOLD(uint8(ROUND_LVL_THRESHOLD));
	setROUND_LVL_MAX_ATT(uint8(ROUND_LVL_MAX_ATT));
	setROUND_LVL_MAX_DEF(uint8(ROUND_LVL_MAX_DEF));
	setROUND_LVL_CUR(uint8(ROUND_LVL_CUR));
	setROUND_ID_CUR(uint8(ROUND_ID_CUR));
	setROUND_ID_MAX(uint8(ROUND_ID_MAX));
	
	setTIME_RANGE_DEF_WANTED(uint8(TIME_RANGE_DEF_WANTED));
	setTIME_RANGE_DEF(TIME_RANGE_DEF);
	setTIME_RANGE_ATT(TIME_RANGE_ATT);
	setTIME_RANGE_LENGTH(TIME_RANGE_LENGTH);

	setSQUAD_CAPITAL(SQUAD_CAPITAL);
}