Commit 7f898417 authored by Melledy's avatar Melledy
Browse files

Fix a few null pointer issues.

parent 2e85834e
...@@ -5,13 +5,15 @@ import java.util.List; ...@@ -5,13 +5,15 @@ import java.util.List;
import emu.grasscutter.data.GameResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@ResourceType(name = "ReliquaryLevelExcelConfigData.json") @ResourceType(name = "ReliquaryLevelExcelConfigData.json")
public class ReliquaryLevelData extends GameResource { public class ReliquaryLevelData extends GameResource {
private int id; private int id;
private Int2ObjectMap<Float> propMap; private Int2FloatMap propMap;
private int rank; private int rank;
private int level; private int level;
...@@ -40,15 +42,15 @@ public class ReliquaryLevelData extends GameResource { ...@@ -40,15 +42,15 @@ public class ReliquaryLevelData extends GameResource {
} }
public float getPropValue(int id) { public float getPropValue(int id) {
return propMap.get(id); return propMap.getOrDefault(id, 0f);
} }
@Override @Override
public void onLoad() { public void onLoad() {
this.id = (rank << 8) + this.getLevel(); this.id = (rank << 8) + this.getLevel();
this.propMap = new Int2ObjectOpenHashMap<>(); this.propMap = new Int2FloatOpenHashMap();
for (RelicLevelProperty p : addProps) { for (RelicLevelProperty p : addProps) {
this.propMap.put(FightProperty.getPropByName(p.getPropType()).getId(), (Float) p.getValue()); this.propMap.put(FightProperty.getPropByName(p.getPropType()).getId(), p.getValue());
} }
} }
......
...@@ -4,6 +4,7 @@ import emu.grasscutter.net.packet.Opcodes; ...@@ -4,6 +4,7 @@ import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.QueryPathReqOuterClass; import emu.grasscutter.net.proto.QueryPathReqOuterClass;
import emu.grasscutter.net.proto.QueryPathReqOuterClass.QueryPathReq;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketQueryPathRsp; import emu.grasscutter.server.packet.send.PacketQueryPathRsp;
...@@ -12,12 +13,15 @@ public class HandlerQueryPathReq extends PacketHandler { ...@@ -12,12 +13,15 @@ public class HandlerQueryPathReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = QueryPathReqOuterClass.QueryPathReq.parseFrom(payload); var req = QueryPathReq.parseFrom(payload);
/** /**
* It is not the actual work * It is not the actual work
*/ */
session.send(new PacketQueryPathRsp(req));
if (req.getDestinationPosList().size() > 0) {
session.send(new PacketQueryPathRsp(req));
}
} }
} }
...@@ -159,7 +159,9 @@ final class ToolsWithLanguageOption { ...@@ -159,7 +159,9 @@ final class ToolsWithLanguageOption {
for (Integer id : list) { for (Integer id : list) {
QuestData data = GameData.getQuestDataMap().get(id); QuestData data = GameData.getQuestDataMap().get(id);
MainQuestData mainQuest = GameData.getMainQuestDataMap().get(data.getMainId()); MainQuestData mainQuest = GameData.getMainQuestDataMap().get(data.getMainId());
writer.println(data.getId() + " : " + map.get(mainQuest.getTitleTextMapHash()) + " - " + map.get(data.getDescTextMapHash())); if (mainQuest != null) {
writer.println(data.getId() + " : " + map.get(mainQuest.getTitleTextMapHash()) + " - " + map.get(data.getDescTextMapHash()));
}
} }
writer.println(); writer.println();
......
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