From 64f013d87dab49027863ace5bfc905916d6e4f18 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Tue, 21 May 2024 00:46:45 -0700 Subject: [PATCH] Warn the server owner if RogueMapGen isnt found in the data folder --- src/main/java/emu/lunarcore/data/ResourceLoader.java | 5 ++++- src/main/java/emu/lunarcore/game/rogue/RogueManager.java | 7 +++++++ .../server/packet/send/PacketStartRogueScRsp.java | 8 +++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/lunarcore/data/ResourceLoader.java b/src/main/java/emu/lunarcore/data/ResourceLoader.java index 43655f35a..6f7102f35 100644 --- a/src/main/java/emu/lunarcore/data/ResourceLoader.java +++ b/src/main/java/emu/lunarcore/data/ResourceLoader.java @@ -366,7 +366,10 @@ private static void loadRogueDialogueEvent() { private static void loadRogueMapGen() { File file = new File(LunarCore.getConfig().getDataDir() + "/RogueMapGen.json"); - if (!file.exists()) return; + if (!file.exists()) { + LunarCore.getLogger().warn("RogueMapGen not found in data folder. Simulated universe will not work."); + return; + } try (FileReader reader = new FileReader(file)) { Map rogue = gson.fromJson(reader, TypeToken.getParameterized(Map.class, Integer.class, int[].class).getType()); diff --git a/src/main/java/emu/lunarcore/game/rogue/RogueManager.java b/src/main/java/emu/lunarcore/game/rogue/RogueManager.java index f0c676d52..836407792 100644 --- a/src/main/java/emu/lunarcore/game/rogue/RogueManager.java +++ b/src/main/java/emu/lunarcore/game/rogue/RogueManager.java @@ -23,6 +23,7 @@ import emu.lunarcore.proto.RogueTalentOuterClass.RogueTalent; import emu.lunarcore.proto.RogueTalentStatusOuterClass.RogueTalentStatus; import emu.lunarcore.server.packet.CmdId; +import emu.lunarcore.server.packet.Retcode; import emu.lunarcore.server.packet.send.PacketLeaveRogueScRsp; import emu.lunarcore.server.packet.send.PacketStartRogueScRsp; import emu.lunarcore.server.packet.send.PacketSyncRogueFinishScNotify; @@ -71,6 +72,12 @@ public boolean enableTalent(int talentId) { } public void startRogue(int areaId, int aeonId, RepeatedInt avatarIdList) { + // Check if map gen is loaded + if (GameDepot.getRogueMapGen().size() == 0) { + getPlayer().sendPacket(new PacketStartRogueScRsp(Retcode.ROGUE_AREA_INVALID.getVal())); + return; + } + // Make sure player already isnt in a rogue instance if (getPlayer().getRogueInstance() != null) { getPlayer().sendPacket(new PacketStartRogueScRsp()); diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketStartRogueScRsp.java b/src/main/java/emu/lunarcore/server/packet/send/PacketStartRogueScRsp.java index db75eea69..3c6298142 100644 --- a/src/main/java/emu/lunarcore/server/packet/send/PacketStartRogueScRsp.java +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketStartRogueScRsp.java @@ -4,20 +4,22 @@ import emu.lunarcore.proto.StartRogueScRspOuterClass.StartRogueScRsp; import emu.lunarcore.server.packet.BasePacket; import emu.lunarcore.server.packet.CmdId; -import lombok.SneakyThrows; public class PacketStartRogueScRsp extends BasePacket { public PacketStartRogueScRsp() { + this(1); + } + + public PacketStartRogueScRsp(int retcode) { super(CmdId.StartRogueScRsp); var data = StartRogueScRsp.newInstance() - .setRetcode(1); + .setRetcode(retcode); this.setData(data); } - @SneakyThrows public PacketStartRogueScRsp(Player player) { super(CmdId.StartRogueScRsp);