Skip to content

Commit

Permalink
Warn the server owner if RogueMapGen isnt found in the data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Melledy committed May 21, 2024
1 parent fa93084 commit 64f013d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/main/java/emu/lunarcore/data/ResourceLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, int[]> rogue = gson.fromJson(reader, TypeToken.getParameterized(Map.class, Integer.class, int[].class).getType());
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/emu/lunarcore/game/rogue/RogueManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 64f013d

Please sign in to comment.