Skip to content

Commit

Permalink
Merge pull request #402 from Jameskmonger/small-fixes
Browse files Browse the repository at this point in the history
fix: two small fixes
  • Loading branch information
Promises authored Jul 9, 2023
2 parents 0196052 + 06d7d3e commit 7337e02
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/engine/world/actor/player/sync/player-sync-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class PlayerSyncTask extends SyncTask<void> {
if(updateFlags.graphics) {
mask |= 0x200;
}
if(updateFlags.animation !== undefined) {
if(updateFlags.animation !== undefined && updateFlags.animation !== null) {
mask |= 0x1;
}

Expand All @@ -151,7 +151,7 @@ export class PlayerSyncTask extends SyncTask<void> {
updateMaskData.put(position.y * 2 + 1, 'SHORT', 'LITTLE_ENDIAN');
}

if(updateFlags.animation !== undefined) {
if(updateFlags.animation !== undefined && updateFlags.animation !== null) {
const animation = updateFlags.animation;

if(animation === null || animation.id === -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/world/actor/update-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class UpdateFlags {

public get updateBlockRequired(): boolean {
return this._appearanceUpdateRequired || this._chatMessages.length !== 0 || this._facePosition !== null ||
this._graphics !== null || this._animation !== undefined || this._faceActor !== undefined || this._damage !== null;
this._graphics !== null || (this._animation !== undefined && this._animation !== null) || (this._faceActor !== undefined && this._faceActor !== null) || this._damage !== null;
}

public get mapRegionUpdateRequired(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/world/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export class World {
public playerOnline(player: Player | string): boolean {
if(typeof player === 'string') {
player = player.toLowerCase();
return this.playerList.findIndex(p => p !== null && p.username.toLowerCase() === player) !== -1;
return this.playerList.findIndex(p => Boolean(p) && p.username.toLowerCase() === player) !== -1;
} else {
const foundPlayer = this.playerList[player.worldIndex];
if(!foundPlayer) {
Expand Down

0 comments on commit 7337e02

Please sign in to comment.