pxt-arcade 1.13.2 → 1.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2554,11 +2554,13 @@ var pxsim;
2554
2554
  }
2555
2555
  multiplayer.postImage = postImage;
2556
2556
  function postIcon(iconType, slot, im) {
2557
- if (im._width * im._height > 64 * 64) {
2557
+ if (im && (im._width * im._height > 64 * 64)) {
2558
2558
  // setting 64x64 as max size for icon for now
2559
2559
  return;
2560
2560
  }
2561
- const asBuf = pxsim.image.toBuffer(im);
2561
+ // treat empty icon as undefined
2562
+ const asBuf = (im && im.data.some(pixel => pixel != 0))
2563
+ ? pxsim.image.toBuffer(im) : undefined;
2562
2564
  const sb = pxsim.board();
2563
2565
  const screenState = sb && sb.screenState;
2564
2566
  pxsim.getMultiplayerState().send({
@@ -2667,9 +2669,7 @@ var pxsim;
2667
2669
  }
2668
2670
  }
2669
2671
  else if (isConnectionMessage(msg)) {
2670
- if (this.origin === "server") {
2671
- this.registerConnectionState(msg.slot, msg.connected);
2672
- }
2672
+ this.registerConnectionState(msg.slot, msg.connected);
2673
2673
  }
2674
2674
  }
2675
2675
  }
package/built/sim.js CHANGED
@@ -2876,11 +2876,13 @@ var pxsim;
2876
2876
  }
2877
2877
  multiplayer.postImage = postImage;
2878
2878
  function postIcon(iconType, slot, im) {
2879
- if (im._width * im._height > 64 * 64) {
2879
+ if (im && (im._width * im._height > 64 * 64)) {
2880
2880
  // setting 64x64 as max size for icon for now
2881
2881
  return;
2882
2882
  }
2883
- const asBuf = pxsim.image.toBuffer(im);
2883
+ // treat empty icon as undefined
2884
+ const asBuf = (im && im.data.some(pixel => pixel != 0))
2885
+ ? pxsim.image.toBuffer(im) : undefined;
2884
2886
  const sb = pxsim.board();
2885
2887
  const screenState = sb && sb.screenState;
2886
2888
  pxsim.getMultiplayerState().send({
@@ -2989,9 +2991,7 @@ var pxsim;
2989
2991
  }
2990
2992
  }
2991
2993
  else if (isConnectionMessage(msg)) {
2992
- if (this.origin === "server") {
2993
- this.registerConnectionState(msg.slot, msg.connected);
2994
- }
2994
+ this.registerConnectionState(msg.slot, msg.connected);
2995
2995
  }
2996
2996
  }
2997
2997
  }