Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: two small fixes #402

Merged
merged 2 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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