Dropped addToQuestStateArray method.

This commit is contained in:
MobiusDevelopment
2020-01-24 15:51:52 +00:00
parent 7307d8d53d
commit 58fe3bdd8f
2 changed files with 21 additions and 73 deletions

View File

@@ -1877,7 +1877,7 @@ public class NpcInstance extends Creature
// collect awaiting quests and start points // collect awaiting quests and start points
final List<Quest> options = new ArrayList<>(); final List<Quest> options = new ArrayList<>();
final QuestState[] awaits = player.getQuestsForTalk(getTemplate().npcId); final List<QuestState> awaits = player.getQuestsForTalk(getTemplate().npcId);
final Quest[] starts = getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START); final Quest[] starts = getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START);
// Quests are limited between 1 and 999 because those are the quests that are supported by the client. // Quests are limited between 1 and 999 because those are the quests that are supported by the client.

View File

@@ -1579,24 +1579,6 @@ public class PlayerInstance extends Playable
_quests.remove(quest); _quests.remove(quest);
} }
/**
* Adds the to quest state array.
* @param questStateArray the quest state array
* @param state the state
* @return the quest state[]
*/
private QuestState[] addToQuestStateArray(QuestState[] questStateArray, QuestState state)
{
final int len = questStateArray.length;
final QuestState[] tmp = new QuestState[len + 1];
for (int i = 0; i < len; i++)
{
tmp[i] = questStateArray[i];
}
tmp[len] = state;
return tmp;
}
/** /**
* Return a list containing all Quest in progress from the table _quests. * Return a list containing all Quest in progress from the table _quests.
* @return the all active quests * @return the all active quests
@@ -1632,15 +1614,14 @@ public class PlayerInstance extends Playable
} }
/** /**
* Return a table containing all QuestState to modify after a Attackable killing.<BR> * Return a table containing all QuestState to modify after a Attackable killing.
* <BR>
* @param npc the npc * @param npc the npc
* @return the quests for attacks * @return the quests for attacks
*/ */
public QuestState[] getQuestsForAttacks(NpcInstance npc) public List<QuestState> getQuestsForAttacks(NpcInstance npc)
{ {
// Create a QuestState table that will contain all QuestState to modify // Create a QuestState lisy that will contain all QuestState to modify
QuestState[] states = null; List<QuestState> states = new ArrayList<>();
// Go through the QuestState of the PlayerInstance quests // Go through the QuestState of the PlayerInstance quests
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ATTACK)) for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ATTACK))
@@ -1649,34 +1630,23 @@ public class PlayerInstance extends Playable
if (getQuestState(quest.getName()) != null) if (getQuestState(quest.getName()) != null)
{ {
// Copy the current PlayerInstance QuestState in the QuestState table // Copy the current PlayerInstance QuestState in the QuestState table
if (states == null) states.add(getQuestState(quest.getName()));
{
states = new QuestState[]
{
getQuestState(quest.getName())
};
}
else
{
states = addToQuestStateArray(states, getQuestState(quest.getName()));
}
} }
} }
// Return a table containing all QuestState to modify // Return a list containing all QuestState to modify
return states; return states;
} }
/** /**
* Return a table containing all QuestState to modify after a Attackable killing.<BR> * Return a table containing all QuestState to modify after a Attackable killing.
* <BR>
* @param npc the npc * @param npc the npc
* @return the quests for kills * @return the quests for kills
*/ */
public QuestState[] getQuestsForKills(NpcInstance npc) public List<QuestState> getQuestsForKills(NpcInstance npc)
{ {
// Create a QuestState table that will contain all QuestState to modify // Create a QuestState lisy that will contain all QuestState to modify
QuestState[] states = null; List<QuestState> states = new ArrayList<>();
// Go through the QuestState of the PlayerInstance quests // Go through the QuestState of the PlayerInstance quests
for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL)) for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL))
@@ -1685,34 +1655,23 @@ public class PlayerInstance extends Playable
if (getQuestState(quest.getName()) != null) if (getQuestState(quest.getName()) != null)
{ {
// Copy the current PlayerInstance QuestState in the QuestState table // Copy the current PlayerInstance QuestState in the QuestState table
if (states == null) states.add(getQuestState(quest.getName()));
{
states = new QuestState[]
{
getQuestState(quest.getName())
};
}
else
{
states = addToQuestStateArray(states, getQuestState(quest.getName()));
}
} }
} }
// Return a table containing all QuestState to modify // Return a list containing all QuestState to modify
return states; return states;
} }
/** /**
* Return a table containing all QuestState from the table _quests in which the PlayerInstance must talk to the NPC.<BR> * Return a table containing all QuestState from the table _quests in which the PlayerInstance must talk to the NPC.
* <BR>
* @param npcId The Identifier of the NPC * @param npcId The Identifier of the NPC
* @return the quests for talk * @return the quests for talk
*/ */
public QuestState[] getQuestsForTalk(int npcId) public List<QuestState> getQuestsForTalk(int npcId)
{ {
// Create a QuestState table that will contain all QuestState to modify // Create a QuestState list that will contain all QuestState to modify
QuestState[] states = null; List<QuestState> states = new ArrayList<>();
// Go through the QuestState of the PlayerInstance quests // Go through the QuestState of the PlayerInstance quests
final Quest[] quests = NpcTable.getInstance().getTemplate(npcId).getEventQuests(Quest.QuestEventType.QUEST_TALK); final Quest[] quests = NpcTable.getInstance().getTemplate(npcId).getEventQuests(Quest.QuestEventType.QUEST_TALK);
@@ -1723,22 +1682,12 @@ public class PlayerInstance extends Playable
// Copy the current PlayerInstance QuestState in the QuestState table // Copy the current PlayerInstance QuestState in the QuestState table
if ((quest != null) && (getQuestState(quest.getName()) != null)) if ((quest != null) && (getQuestState(quest.getName()) != null))
{ {
if (states == null) states.add(getQuestState(quest.getName()));
{
states = new QuestState[]
{
getQuestState(quest.getName())
};
}
else
{
states = addToQuestStateArray(states, getQuestState(quest.getName()));
}
} }
} }
} }
// Return a table containing all QuestState to modify // Return a list containing all QuestState to modify
return states; return states;
} }
@@ -1787,9 +1736,8 @@ public class PlayerInstance extends Playable
if ((object instanceof NpcInstance) && isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false)) if ((object instanceof NpcInstance) && isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false))
{ {
final NpcInstance npc = (NpcInstance) object; final NpcInstance npc = (NpcInstance) object;
final QuestState[] states = getQuestsForTalk(npc.getNpcId()); final List<QuestState> states = getQuestsForTalk(npc.getNpcId());
if (!states.isEmpty())
if (states != null)
{ {
for (QuestState state : states) for (QuestState state : states)
{ {