}
else
{
_ownerId = 0;
} // Remove owner
ThreadConnection con = null;
FiltredPreparedStatement statement;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("UPDATE clanhall SET ownerId=?, lease=?, inDebt=0 WHERE id=?");
statement.setInt(1, getOwnerId());
statement.setLong(2, getLease());
statement.setInt(3, getId());
statement.execute();
DatabaseUtils.closeStatement(statement);
statement = con.prepareStatement("UPDATE clan_data SET hasHideout=0 WHERE hasHideout=?");
statement.setInt(1, getId());
statement.execute();
DatabaseUtils.closeStatement(statement);
statement = con.prepareStatement("UPDATE clan_data SET hasHideout=? WHERE clan_id=?");
statement.setInt(1, getId());
statement.setInt(2, getOwnerId());
statement.execute();
DatabaseUtils.closeStatement(statement);
statement = con.prepareStatement("DELETE FROM residence_functions WHERE id=?");
statement.setInt(1, getId());
statement.execute();
DatabaseUtils.closeStatement(statement);
// Announce to clan memebers
if(clan != null)
{
clan.setHasHideout(getId()); // Set has hideout flag for new owner
clan.broadcastClanStatus(false, true, true);
}
else if(getPrice() > 0)
{
Calendar endDate = Calendar.getInstance();
endDate.add(Calendar.DAY_OF_MONTH, 7); // Schedule to happen in 7 days
statement = con.prepareStatement("REPLACE INTO auction (id, sellerId, sellerName, sellerClanName, itemName, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?)");
statement.setInt(1, getId());
statement.setInt(2, 0);
statement.setString(3, "NPC");
statement.setString(4, "NPC Clan");
statement.setString(5, getName());