Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Check array length before accessing it. Fixes #377 (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms authored Jul 8, 2019
1 parent 6428a13 commit 39aedff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/sdk/src/adapters/multipeer/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const Rules: { [id in Payloads.PayloadType]: Rule } = {
(value.message.payload as Payloads.ActorUpdate).actor.id === payload.actorId).shift();
if (queuedMessage) {
const existingPayload = queuedMessage.message.payload as Partial<Payloads.ActorUpdate>;
existingPayload.actor = deepmerge(existingPayload.actor, {
existingPayload.actor = deepmerge(existingPayload.actor, {
payload: {
actor: {
transform: {
Expand Down Expand Up @@ -682,7 +682,10 @@ export const Rules: { [id in Payloads.PayloadType]: Rule } = {
message: Message<Payloads.ObjectSpawned>
) => {
// Check that this is the authoritative client
const exclusiveUser = session.actorSet[message.payload.actors[0].id].exclusiveToUser;
const exclusiveUser =
message.payload.actors && message.payload.actors.length ?
session.actorSet[message.payload.actors[0].id].exclusiveToUser :
undefined;
if (client.authoritative || client.userId && client.userId === exclusiveUser) {
// Create no-op creation message. Implicit sync from initialization until they're updated
for (const spawned of message.payload.actors) {
Expand Down

0 comments on commit 39aedff

Please sign in to comment.