Removed quest_global_data SQL table.

This commit is contained in:
MobiusDev
2017-08-15 16:26:18 +00:00
parent e8a760de9c
commit c06f5fb5db
77 changed files with 208 additions and 576 deletions

View File

@@ -264,7 +264,6 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM heroes_diary WHERE heroes_diary.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_offline_trade WHERE character_offline_trade.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_offline_trade_items WHERE character_offline_trade_items.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_quest_global_data WHERE character_quest_global_data.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_tpbookmark WHERE character_tpbookmark.charId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM character_variables WHERE character_variables.charId NOT IN (SELECT charId FROM characters);");

View File

@@ -1536,97 +1536,6 @@ public class Quest extends AbstractScript implements IIdentifiable
}
}
/**
* Insert (or update) in the database variables that need to stay persistent for this quest after a reboot.<br>
* This function is for storage of values that do not related to a specific player but are global for all characters.<br>
* For example, if we need to disable a quest-gatekeeper until a certain time (as is done with some grand-boss gatekeepers), we can save that time in the DB.
* @param var the name of the variable to save
* @param value the value of the variable
*/
public final void saveGlobalQuestVar(String var, String value)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO quest_global_data (quest_name,var,value) VALUES (?,?,?)"))
{
ps.setString(1, getName());
ps.setString(2, var);
ps.setString(3, value);
ps.executeUpdate();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not insert global quest variable:", e);
}
}
/**
* Read from the database a previously saved variable for this quest.<br>
* Due to performance considerations, this function should best be used only when the quest is first loaded.<br>
* Subclasses of this class can define structures into which these loaded values can be saved.<br>
* However, on-demand usage of this function throughout the script is not prohibited, only not recommended.<br>
* Values read from this function were entered by calls to "saveGlobalQuestVar".
* @param var the name of the variable to load
* @return the current value of the specified variable, or an empty string if the variable does not exist
*/
public final String getGlobalQuestVar(String var)
{
String result = "";
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT value FROM quest_global_data WHERE quest_name = ? AND var = ?"))
{
ps.setString(1, getName());
ps.setString(2, var);
try (ResultSet rs = ps.executeQuery())
{
if (rs.first())
{
result = rs.getString(1);
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not load global quest variable:", e);
}
return result;
}
/**
* Permanently delete from the database a global quest variable that was previously saved for this quest.
* @param var the name of the variable to delete
*/
public final void deleteGlobalQuestVar(String var)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ? AND var = ?"))
{
ps.setString(1, getName());
ps.setString(2, var);
ps.executeUpdate();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not delete global quest variable:", e);
}
}
/**
* Permanently delete from the database all global quest variables that were previously saved for this quest.
*/
public final void deleteAllGlobalQuestVars()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ?"))
{
ps.setString(1, getName());
ps.executeUpdate();
}
catch (Exception e)
{
_log.log(Level.WARNING, "could not delete global quest variables:", e);
}
}
/**
* Insert in the database the quest for the player.
* @param qs the {@link QuestState} object whose variable to insert

View File

@@ -457,12 +457,6 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
ps.execute();
}
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_quest_global_data WHERE charId=?"))
{
ps.setInt(1, objid);
ps.executeUpdate();
}
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=?"))
{
ps.setInt(1, objid);

View File

@@ -328,7 +328,7 @@ public final class RequestAcquireSkill extends L2GameClientPacket
{
for (int i = 1; i <= Config.MAX_SUBCLASS; i++)
{
final String itemOID = st.getQuest().getGlobalQuestVar(varName + i);
final String itemOID = activeChar.getVariables().getString(varName + i);
if (!itemOID.isEmpty() && !itemOID.endsWith(";") && !itemOID.equals("0"))
{
if (Util.isDigit(itemOID))
@@ -345,7 +345,7 @@ public final class RequestAcquireSkill extends L2GameClientPacket
{
giveSkill(activeChar, trainer, skill);
// Logging the given skill.
st.getQuest().saveGlobalQuestVar(varName + i, skill.getId() + ";");
activeChar.getVariables().set(varName + i, skill.getId() + ";");
}
return;
}