Skip to content

Commit

Permalink
Fix train parlor map UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Melledy committed Jul 31, 2024
1 parent e80b0fd commit a1be806
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/emu/lunarcore/GameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GameConstants {
// Game
public static final String DEFAULT_NAME = "A Nameless";
public static final int[] DEFAULT_HEAD_ICONS = {208001, 208002};
public static final int DEFAULT_WORLD_ID = 101;
public static final int TRAILBLAZER_AVATAR_ID = 8001;
public static final int MAX_TRAILBLAZER_LEVEL = 70;
public static final int[] WORLD_LEVEL_UPGRADES = {0, 20, 30, 40, 50, 60, 65};
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/emu/lunarcore/game/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class Player implements Tickable {
private int planeId;
private int floorId;
private int entryId;
private int worldId;

private long lastActiveTime;

Expand Down Expand Up @@ -800,6 +801,11 @@ public boolean loadScene(int planeId, int floorId, int entryId, Position pos, Po
nextScene = new Scene(this, planeExcel, floorId);
}

// Set world id
if (planeExcel.getPlaneType() == PlaneType.Town || planeExcel.getPlaneType() == PlaneType.Maze) {
this.worldId = planeExcel.getWorldID();
}

// Set player position
this.getPos().set(pos);
this.getRot().set(rot);
Expand Down Expand Up @@ -918,6 +924,11 @@ public void onLogin() {
this.challengeInstance = null;
}

// Set default world id if we don't have it
if (this.worldId == 0) {
this.worldId = GameConstants.DEFAULT_WORLD_ID;
}

// Unstuck check, dont load player into raid scenes
MazePlaneExcel planeExcel = GameData.getMazePlaneExcelMap().get(planeId);
if (planeExcel == null || planeExcel.getPlaneType().getVal() >= PlaneType.Raid.getVal()) {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/emu/lunarcore/game/scene/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Scene implements Tickable {
private final int planeId;
private final int floorId;
private int entryId;
private int worldId;
@Setter private int leaveEntryId;

private int lastEntityId = 0;
Expand Down Expand Up @@ -72,6 +73,13 @@ public Scene(Player player, MazePlaneExcel excel, int floorId) {
this.healingSprings = new ObjectArrayList<>();
this.triggers = new ObjectArrayList<>();

// Set world id
if (this.getExcel().getPlaneType() == PlaneType.Train) {
this.worldId = player.getWorldId();
} else {
this.worldId = this.getExcel().getWorldID();
}

// Use singleton to avoid allocating memory for a new entity loader everytime we create a scene
this.entityLoader = getExcel().getPlaneType().getSceneEntityLoader();

Expand Down Expand Up @@ -391,10 +399,10 @@ public void onBattleStart(Battle battle) {
public synchronized SceneInfo toProto() {
// Set loaded flag
this.loaded = true;

// Proto
var proto = SceneInfo.newInstance()
.setWorldId(this.getExcel().getWorldID())
.setWorldId(this.getWorldId())
.setGameModeType(this.getExcel().getPlaneType().getVal())
.setPlaneId(this.getPlaneId())
.setFloorId(this.getFloorId())
Expand Down

0 comments on commit a1be806

Please sign in to comment.