mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:12:54 +08:00
Fix stuck when talking to npc seller (#1128)
* Fix zero length array check method * Import grasscutter logger
This commit is contained in:
parent
6f5a290a3a
commit
28b505e187
@ -2,6 +2,7 @@ package emu.grasscutter.game.quest;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.MainQuestData;
|
||||
import emu.grasscutter.data.binout.MainQuestData.SubQuestData;
|
||||
@ -44,11 +45,11 @@ public class GameQuest {
|
||||
this.startTime = this.acceptTime;
|
||||
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];
|
||||
}
|
||||
|
||||
if (questData.getFailCond() != null) {
|
||||
|
||||
if (questData.getFailCond() != null && questData.getFailCond().length != 0) {
|
||||
this.failProgressList = new int[questData.getFailCond().length];
|
||||
}
|
||||
|
||||
@ -158,36 +159,38 @@ public class GameQuest {
|
||||
public boolean tryAcceptQuestLine() {
|
||||
try {
|
||||
MainQuestData questConfig = GameData.getMainQuestDataMap().get(this.getMainQuestId());
|
||||
|
||||
|
||||
for (SubQuestData subQuest : questConfig.getSubQuests()) {
|
||||
GameQuest quest = getMainQuest().getChildQuestById(subQuest.getSubId());
|
||||
|
||||
|
||||
if (quest == null) {
|
||||
QuestData questData = GameData.getQuestDataMap().get(subQuest.getSubId());
|
||||
|
||||
if (questData == null || questData.getAcceptCond() == null) {
|
||||
|
||||
if (questData == null || questData.getAcceptCond() == null
|
||||
|| questData.getAcceptCond().length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int[] accept = new int[questData.getAcceptCond().length];
|
||||
|
||||
|
||||
// TODO
|
||||
for (int i = 0; i < questData.getAcceptCond().length; 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;
|
||||
}
|
||||
|
||||
|
||||
boolean shouldAccept = LogicType.calculate(questData.getAcceptCondComb(), accept);
|
||||
|
||||
|
||||
if (shouldAccept) {
|
||||
this.getOwner().getQuestManager().addQuest(questData.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Grasscutter.getLogger().error("An error occurred while trying to accept quest.", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1,12 +1,9 @@
|
||||
package emu.grasscutter.game.quest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.QuestData;
|
||||
@ -133,7 +130,9 @@ public class QuestManager {
|
||||
QuestData data = quest.getData();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user