Commit 28b505e1 authored by line-bear's avatar line-bear Committed by GitHub
Browse files

Fix stuck when talking to npc seller (#1128)

* Fix zero length array check method

* Import grasscutter logger
parent 6f5a290a
...@@ -2,6 +2,7 @@ package emu.grasscutter.game.quest; ...@@ -2,6 +2,7 @@ package emu.grasscutter.game.quest;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Transient; import dev.morphia.annotations.Transient;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.binout.MainQuestData; import emu.grasscutter.data.binout.MainQuestData;
import emu.grasscutter.data.binout.MainQuestData.SubQuestData; import emu.grasscutter.data.binout.MainQuestData.SubQuestData;
...@@ -44,11 +45,11 @@ public class GameQuest { ...@@ -44,11 +45,11 @@ public class GameQuest {
this.startTime = this.acceptTime; this.startTime = this.acceptTime;
this.state = QuestState.QUEST_STATE_UNFINISHED; this.state = QuestState.QUEST_STATE_UNFINISHED;
if (questData.getFinishCond()!= null) { if (questData.getFinishCond() != null && questData.getAcceptCond().length != 0) {
this.finishProgressList = new int[questData.getFinishCond().length]; this.finishProgressList = new int[questData.getFinishCond().length];
} }
if (questData.getFailCond() != null) { if (questData.getFailCond() != null && questData.getFailCond().length != 0) {
this.failProgressList = new int[questData.getFailCond().length]; this.failProgressList = new int[questData.getFailCond().length];
} }
...@@ -165,7 +166,8 @@ public class GameQuest { ...@@ -165,7 +166,8 @@ public class GameQuest {
if (quest == null) { if (quest == null) {
QuestData questData = GameData.getQuestDataMap().get(subQuest.getSubId()); QuestData questData = GameData.getQuestDataMap().get(subQuest.getSubId());
if (questData == null || questData.getAcceptCond() == null) { if (questData == null || questData.getAcceptCond() == null
|| questData.getAcceptCond().length == 0) {
continue; continue;
} }
...@@ -174,7 +176,8 @@ public class GameQuest { ...@@ -174,7 +176,8 @@ public class GameQuest {
// TODO // TODO
for (int i = 0; i < questData.getAcceptCond().length; i++) { for (int i = 0; i < questData.getAcceptCond().length; i++) {
QuestCondition condition = questData.getAcceptCond()[i]; QuestCondition condition = questData.getAcceptCond()[i];
boolean result = getOwner().getServer().getQuestHandler().triggerCondition(this, condition, condition.getParam()); boolean result = getOwner().getServer().getQuestHandler().triggerCondition(this, condition,
condition.getParam());
accept[i] = result ? 1 : 0; accept[i] = result ? 1 : 0;
} }
...@@ -187,7 +190,7 @@ public class GameQuest { ...@@ -187,7 +190,7 @@ public class GameQuest {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().error("An error occurred while trying to accept quest.", e);
} }
return false; return false;
......
package emu.grasscutter.game.quest; package emu.grasscutter.game.quest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.QuestData; import emu.grasscutter.data.excels.QuestData;
...@@ -133,7 +130,9 @@ public class QuestManager { ...@@ -133,7 +130,9 @@ public class QuestManager {
QuestData data = quest.getData(); QuestData data = quest.getData();
for (int i = 0; i < data.getFinishCond().length; i++) { for (int i = 0; i < data.getFinishCond().length; i++) {
if (quest.getFinishProgressList() == null || quest.getFinishProgressList()[i] == 1) { if (quest.getFinishProgressList() == null
|| quest.getFinishProgressList().length == 0
|| quest.getFinishProgressList()[i] == 1) {
continue; continue;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment