Skip to content

Commit

Permalink
Merge pull request #120 from rune-js/fix-saved-metadata
Browse files Browse the repository at this point in the history
Fixing new players crashing due to savedMetadata and adding sourcemap…
  • Loading branch information
TheBlackParade authored Mar 5, 2020
2 parents e3aa221 + 5adeb58 commit 8d378fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"js-yaml": "^3.13.1",
"quadtree-lib": "^1.0.9",
"rxjs": "^6.5.4",
"source-map-support": "^0.5.16",
"ts-node": "^8.4.1",
"tslib": "^1.10.0",
"typescript": "^3.7.2",
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { runGameServer } from './game-server';
import { runWebServer } from './web-server';
import 'source-map-support/register';
// import { dumpItems } from '@server/data-dump';

runGameServer();
Expand Down
9 changes: 5 additions & 4 deletions src/world/actor/player/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ export class Player extends Actor {
const firstTimePlayer: boolean = playerSave === null;
this.firstTimePlayer = firstTimePlayer;

if(playerSave.savedMetadata) {
this.savedMetadata = playerSave.savedMetadata;
}

if(!firstTimePlayer) {
if(playerSave.savedMetadata) {
this.savedMetadata = playerSave.savedMetadata;
}

// Existing player logging in
this.position = new Position(playerSave.position.x, playerSave.position.y, playerSave.position.level);
if(playerSave.inventory && playerSave.inventory.length !== 0) {
Expand Down Expand Up @@ -158,6 +158,7 @@ export class Player extends Actor {
this.inventory.add({itemId: 1201, amount: 1});
this._appearance = defaultAppearance();
this._rights = Rights.USER;
this.savedMetadata = {};
}

if(!this._settings) {
Expand Down

0 comments on commit 8d378fd

Please sign in to comment.