Sync with L2jServer HighFive Jul 25th 2015.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
|
||||
@ -795,11 +795,11 @@ public class L2PetInstance extends L2Summon
|
||||
}
|
||||
|
||||
// pet control item no longer exists, delete the pet from the db
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
|
||||
{
|
||||
statement.setInt(1, getControlObjectId());
|
||||
statement.execute();
|
||||
ps.setInt(1, getControlObjectId());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -851,14 +851,14 @@ public class L2PetInstance extends L2Summon
|
||||
|
||||
private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
|
||||
{
|
||||
L2PetInstance pet;
|
||||
statement.setInt(1, control.getObjectId());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
ps.setInt(1, control.getObjectId());
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
if (!rset.next())
|
||||
if (!rs.next())
|
||||
{
|
||||
if (template.isType("L2BabyPet"))
|
||||
{
|
||||
@ -873,17 +873,17 @@ public class L2PetInstance extends L2Summon
|
||||
|
||||
if (template.isType("L2BabyPet"))
|
||||
{
|
||||
pet = new L2BabyPetInstance(template, owner, control, rset.getByte("level"));
|
||||
pet = new L2BabyPetInstance(template, owner, control, rs.getByte("level"));
|
||||
}
|
||||
else
|
||||
{
|
||||
pet = new L2PetInstance(template, owner, control, rset.getByte("level"));
|
||||
pet = new L2PetInstance(template, owner, control, rs.getByte("level"));
|
||||
}
|
||||
|
||||
pet._respawned = true;
|
||||
pet.setName(rset.getString("name"));
|
||||
pet.setName(rs.getString("name"));
|
||||
|
||||
long exp = rset.getLong("exp");
|
||||
long exp = rs.getLong("exp");
|
||||
L2PetLevelData info = PetDataTable.getInstance().getPetLevelData(pet.getId(), pet.getLevel());
|
||||
// DS: update experience based by level
|
||||
// Avoiding pet delevels due to exp per level values changed.
|
||||
@ -893,18 +893,18 @@ public class L2PetInstance extends L2Summon
|
||||
}
|
||||
|
||||
pet.getStat().setExp(exp);
|
||||
pet.getStat().setSp(rset.getInt("sp"));
|
||||
pet.getStat().setSp(rs.getInt("sp"));
|
||||
|
||||
pet.getStatus().setCurrentHp(rset.getInt("curHp"));
|
||||
pet.getStatus().setCurrentMp(rset.getInt("curMp"));
|
||||
pet.getStatus().setCurrentHp(rs.getInt("curHp"));
|
||||
pet.getStatus().setCurrentMp(rs.getInt("curMp"));
|
||||
pet.getStatus().setCurrentCp(pet.getMaxCp());
|
||||
if (rset.getDouble("curHp") < 1)
|
||||
if (rs.getDouble("curHp") < 1)
|
||||
{
|
||||
pet.setIsDead(true);
|
||||
pet.stopHpMpRegeneration();
|
||||
}
|
||||
|
||||
pet.setCurrentFed(rset.getInt("fed"));
|
||||
pet.setCurrentFed(rs.getInt("fed"));
|
||||
}
|
||||
return pet;
|
||||
}
|
||||
@ -952,20 +952,20 @@ public class L2PetInstance extends L2Summon
|
||||
req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? " + "WHERE item_obj_id = ?";
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(req))
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(req))
|
||||
{
|
||||
statement.setString(1, getName());
|
||||
statement.setInt(2, getStat().getLevel());
|
||||
statement.setDouble(3, getStatus().getCurrentHp());
|
||||
statement.setDouble(4, getStatus().getCurrentMp());
|
||||
statement.setLong(5, getStat().getExp());
|
||||
statement.setLong(6, getStat().getSp());
|
||||
statement.setInt(7, getCurrentFed());
|
||||
statement.setInt(8, getOwner().getObjectId());
|
||||
statement.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
|
||||
statement.setInt(10, getControlObjectId());
|
||||
statement.executeUpdate();
|
||||
ps.setString(1, getName());
|
||||
ps.setInt(2, getStat().getLevel());
|
||||
ps.setDouble(3, getStatus().getCurrentHp());
|
||||
ps.setDouble(4, getStatus().getCurrentMp());
|
||||
ps.setLong(5, getStat().getExp());
|
||||
ps.setLong(6, getStat().getSp());
|
||||
ps.setInt(7, getCurrentFed());
|
||||
ps.setInt(8, getOwner().getObjectId());
|
||||
ps.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
|
||||
ps.setInt(10, getControlObjectId());
|
||||
ps.executeUpdate();
|
||||
|
||||
_respawned = true;
|
||||
|
||||
@ -1002,7 +1002,7 @@ public class L2PetInstance extends L2Summon
|
||||
// Clear list for overwrite
|
||||
SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
|
||||
PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
|
||||
{
|
||||
@ -1069,20 +1069,20 @@ public class L2PetInstance extends L2Summon
|
||||
@Override
|
||||
public void restoreEffects()
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
|
||||
PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
|
||||
{
|
||||
if (!SummonEffectsTable.getInstance().containsPetId(getControlObjectId()))
|
||||
{
|
||||
ps1.setInt(1, getControlObjectId());
|
||||
try (ResultSet rset = ps1.executeQuery())
|
||||
try (ResultSet rs = ps1.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
while (rs.next())
|
||||
{
|
||||
int effectCurTime = rset.getInt("remaining_time");
|
||||
int effectCurTime = rs.getInt("remaining_time");
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(rset.getInt("skill_id"), rset.getInt("skill_level"));
|
||||
final Skill skill = SkillData.getInstance().getSkill(rs.getInt("skill_id"), rs.getInt("skill_level"));
|
||||
if (skill == null)
|
||||
{
|
||||
continue;
|
||||
|
@ -28,7 +28,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
|
||||
@ -260,14 +260,14 @@ public class L2ServitorInstance extends L2Summon implements Runnable
|
||||
// Clear list for overwrite
|
||||
SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE))
|
||||
{
|
||||
// Delete all current stored effects for summon to avoid dupe
|
||||
statement.setInt(1, getOwner().getObjectId());
|
||||
statement.setInt(2, getOwner().getClassIndex());
|
||||
statement.setInt(3, getReferenceSkill());
|
||||
statement.execute();
|
||||
ps.setInt(1, getOwner().getObjectId());
|
||||
ps.setInt(2, getOwner().getClassIndex());
|
||||
ps.setInt(3, getReferenceSkill());
|
||||
ps.execute();
|
||||
|
||||
int buff_index = 0;
|
||||
|
||||
@ -338,22 +338,22 @@ public class L2ServitorInstance extends L2Summon implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
{
|
||||
if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
|
||||
try (PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
|
||||
{
|
||||
statement.setInt(1, getOwner().getObjectId());
|
||||
statement.setInt(2, getOwner().getClassIndex());
|
||||
statement.setInt(3, getReferenceSkill());
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
ps.setInt(1, getOwner().getObjectId());
|
||||
ps.setInt(2, getOwner().getClassIndex());
|
||||
ps.setInt(3, getReferenceSkill());
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
while (rs.next())
|
||||
{
|
||||
int effectCurTime = rset.getInt("remaining_time");
|
||||
int effectCurTime = rs.getInt("remaining_time");
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(rset.getInt("skill_id"), rset.getInt("skill_level"));
|
||||
final Skill skill = SkillData.getInstance().getSkill(rs.getInt("skill_id"), rs.getInt("skill_level"));
|
||||
if (skill == null)
|
||||
{
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user