|
@@ -186,24 +186,16 @@ public class Fort
|
|
if (getOwnerClan().getWarehouse().getAdena() >= _fee || !_cwh)
|
|
if (getOwnerClan().getWarehouse().getAdena() >= _fee || !_cwh)
|
|
{
|
|
{
|
|
int fee = _fee;
|
|
int fee = _fee;
|
|
- boolean newfc = true;
|
|
|
|
- if (getEndTime() == 0 || getEndTime() == -1)
|
|
|
|
- {
|
|
|
|
- if (getEndTime() == -1)
|
|
|
|
- {
|
|
|
|
- newfc = false;
|
|
|
|
- fee = _tempFee;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- newfc = false;
|
|
|
|
|
|
+ if (getEndTime() == -1)
|
|
|
|
+ fee = _tempFee;
|
|
|
|
+
|
|
setEndTime(System.currentTimeMillis() + getRate());
|
|
setEndTime(System.currentTimeMillis() + getRate());
|
|
- dbSave(newfc);
|
|
|
|
|
|
+ dbSave();
|
|
if (_cwh)
|
|
if (_cwh)
|
|
{
|
|
{
|
|
getOwnerClan().getWarehouse().destroyItemByItemId("CS_function_fee", 57, fee, null, null);
|
|
getOwnerClan().getWarehouse().destroyItemByItemId("CS_function_fee", 57, fee, null, null);
|
|
if (Config.DEBUG)
|
|
if (Config.DEBUG)
|
|
- _log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
|
|
|
|
|
|
+ _log.warning("Deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
|
|
}
|
|
}
|
|
ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
|
|
ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
|
|
}
|
|
}
|
|
@@ -216,7 +208,7 @@ public class Fort
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public void dbSave(boolean newFunction)
|
|
|
|
|
|
+ public void dbSave()
|
|
{
|
|
{
|
|
Connection con = null;
|
|
Connection con = null;
|
|
try
|
|
try
|
|
@@ -224,32 +216,19 @@ public class Fort
|
|
PreparedStatement statement;
|
|
PreparedStatement statement;
|
|
|
|
|
|
con = L2DatabaseFactory.getInstance().getConnection();
|
|
con = L2DatabaseFactory.getInstance().getConnection();
|
|
- if (newFunction)
|
|
|
|
- {
|
|
|
|
- statement = con.prepareStatement("INSERT INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)");
|
|
|
|
- statement.setInt(1, getFortId());
|
|
|
|
- statement.setInt(2, getType());
|
|
|
|
- statement.setInt(3, getLvl());
|
|
|
|
- statement.setInt(4, getLease());
|
|
|
|
- statement.setLong(5, getRate());
|
|
|
|
- statement.setLong(6, getEndTime());
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- statement = con.prepareStatement("UPDATE fort_functions SET lvl=?, lease=?, endTime=? WHERE fort_id=? AND type=?");
|
|
|
|
- statement.setInt(1, getLvl());
|
|
|
|
- statement.setInt(2, getLease());
|
|
|
|
- statement.setLong(3, getEndTime());
|
|
|
|
- statement.setInt(4, getFortId());
|
|
|
|
- statement.setInt(5, getType());
|
|
|
|
- }
|
|
|
|
|
|
+ statement = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)");
|
|
|
|
+ statement.setInt(1, getFortId());
|
|
|
|
+ statement.setInt(2, getType());
|
|
|
|
+ statement.setInt(3, getLvl());
|
|
|
|
+ statement.setInt(4, getLease());
|
|
|
|
+ statement.setLong(5, getRate());
|
|
|
|
+ statement.setLong(6, getEndTime());
|
|
statement.execute();
|
|
statement.execute();
|
|
statement.close();
|
|
statement.close();
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- _log.log(Level.SEVERE, "Exception: Fort.updateFunctions(int type, int lvl, int lease, long rate, long time, boolean addNew): "
|
|
|
|
- + e.getMessage(), e);
|
|
|
|
|
|
+ _log.log(Level.SEVERE, "Exception: Fort.updateFunctions(int type, int lvl, int lease, long rate, long time, boolean addNew): " + e.getMessage(), e);
|
|
}
|
|
}
|
|
finally
|
|
finally
|
|
{
|
|
{
|
|
@@ -745,7 +724,7 @@ public class Fort
|
|
{
|
|
{
|
|
_function.get(type).setLease(lease);
|
|
_function.get(type).setLease(lease);
|
|
_function.get(type).setLvl(lvl);
|
|
_function.get(type).setLvl(lvl);
|
|
- _function.get(type).dbSave(false);
|
|
|
|
|
|
+ _function.get(type).dbSave();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|