Skip to content

Commit

Permalink
fix issue with empty world loading
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGruber committed Aug 19, 2024
1 parent ed1331e commit 12c253d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/servers/ZoneServer2016/managers/worlddatamanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,20 @@ export class WorldDataManager {
let serverData: ServerSaveData;
if (this._soloMode) {
serverData = require(`${this._appDataFolder}/worlddata/world.json`);
if (!serverData) {
if (!serverData.serverId) {
debug("World data not found in file, aborting.");
return null;
}
} else {
serverData = await this._db
?.collection(DB_COLLECTIONS.WORLDS)
.findOne({ worldId: serverId });
if (!serverData) {
if (!serverData.serverId) {
debug("World data not found in mongo, aborting.");
return null;
}
}
return serverData;
return serverData ?? null;
}

private async saveServerData(lastItemGuid: bigint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ expose({
return worldDataManager.initialize(worldId, mongoAddress);
},
getServerData(serverId: number) {
return worldDataManager.getServerData(
serverId
) as Promise<ServerSaveData | null>;
return worldDataManager.getServerData(serverId);
},
fetchWorldData() {
return worldDataManager.fetchWorldData();
Expand Down

0 comments on commit 12c253d

Please sign in to comment.