Bläddra i källkod

Does not create new QuestState in database for "Created" quests. Database record created only in "Started" state.
Potentially dangerous, but can help reduce database usage.

_DS_ 15 år sedan
förälder
incheckning
0dfa360002

+ 0 - 1
L2_GameServer/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -181,7 +181,6 @@ public class Quest extends ManagedScript
 	public QuestState newQuestState(L2PcInstance player)
 	public QuestState newQuestState(L2PcInstance player)
 	{
 	{
 		QuestState qs = new QuestState(this, player, getInitialState());
 		QuestState qs = new QuestState(this, player, getInitialState());
-		Quest.createQuestInDb(qs);
 		return qs;
 		return qs;
 	}
 	}
 	
 	

+ 18 - 6
L2_GameServer/java/com/l2jserver/gameserver/model/quest/QuestState.java

@@ -129,6 +129,15 @@ public final class QuestState
 		return _state;
 		return _state;
 	}
 	}
 
 
+	/**
+	 * Return true if quest just created, false otherwise
+	 * @return
+	 */
+	public boolean isCreated()
+	{
+		return (getState() == State.CREATED);
+	}
+
 	/**
 	/**
 	 * Return true if quest completed, false otherwise
 	 * Return true if quest completed, false otherwise
 	 * @return boolean
 	 * @return boolean
@@ -163,12 +172,15 @@ public final class QuestState
 		// set new state if it is not already in that state
 		// set new state if it is not already in that state
 		if (_state != state)
 		if (_state != state)
 		{
 		{
+			final boolean newQuest = isCreated();
 			_state = state;
 			_state = state;
-			
-			Quest.updateQuestInDb(this);
-			QuestList ql = new QuestList();
-			
-			getPlayer().sendPacket(ql);
+
+			if (newQuest)
+				Quest.createQuestInDb(this);
+			else
+				Quest.updateQuestInDb(this);
+
+			getPlayer().sendPacket(new QuestList());
 		}
 		}
 		return state;
 		return state;
 	}
 	}
@@ -1064,7 +1076,7 @@ public final class QuestState
 		// remove this quest from the notifyDeath list of this character if its on this list
 		// remove this quest from the notifyDeath list of this character if its on this list
 		_player.removeNotifyQuestOfDeath(this);
 		_player.removeNotifyQuestOfDeath(this);
 
 
-		if (isCompleted())
+		if (isCompleted() || isCreated())
 			return this;
 			return this;
 
 
 		// Say quest is completed
 		// Say quest is completed