You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@gathertown/gather-game-common

Package Overview
Dependencies
Maintainers
3
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gathertown/gather-game-common - npm Package Compare versions

Comparing version

to
15.0.0

2

dist/src/config.js

@@ -5,4 +5,4 @@ "use strict";

exports.config = {
gameServerProtocolVersion: 13
gameServerProtocolVersion: 14
};
//# sourceMappingURL=config.js.map

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -136,8 +134,5 @@ exports.__esModule = true;

else if (update.type === UpdateType.Disconnect) {
if (!worldState[update.id]) {
worldState[update.id] = update;
if (worldState === this._worldState) {
delete worldState[update.id];
}
else if (worldState[update.id].type === UpdateType.FullPosition) {
delete this._worldState[update.id];
}
else {

@@ -176,3 +171,3 @@ worldState[update.id] = update;

var generate = function () {
var len = __spreadArrays([0], offsets).reduce(function (x, y) { return x + y; });
var len = __spreadArray([0], offsets).reduce(function (x, y) { return x + y; });
var buf = new ArrayBuffer(len);

@@ -190,3 +185,3 @@ var dv = new DataView(buf);

}
return buffer_1.Buffer.concat(__spreadArrays([buffer_1.Buffer.from(buf)], strings));
return buffer_1.Buffer.concat(__spreadArray([buffer_1.Buffer.from(buf)], strings));
};

@@ -193,0 +188,0 @@ var setUpdate = function (keys, update) {

@@ -8,2 +8,5 @@ export interface Position {

export declare function serializePositionCoordinates(x: number, y: number): string;
export declare function positionToIndex(pos: Position, width: number): number;
export declare function coordinatesToIndex(x: number, y: number, width: number): number;
export declare function indexToPosition(index: number, width: number): Position;
export declare function deserializePosition(s: string): Position;

@@ -10,0 +13,0 @@ export declare function manhattanDistance(a: Position, b: Position): number;

"use strict";
exports.__esModule = true;
exports.isPosWithinRect = exports.euclideanDistance = exports.manhattanDistance = exports.deserializePosition = exports.serializePositionCoordinates = exports.serializePosition = exports.isPosEqual = void 0;
exports.isPosWithinRect = exports.euclideanDistance = exports.manhattanDistance = exports.deserializePosition = exports.indexToPosition = exports.coordinatesToIndex = exports.positionToIndex = exports.serializePositionCoordinates = exports.serializePosition = exports.isPosEqual = void 0;
var isPosEqual = function (a, b) {

@@ -18,2 +18,22 @@ return a.x === b.x && a.y === b.y;

exports.serializePositionCoordinates = serializePositionCoordinates;
// Utility functions for row-major order: maps an X/Y coordinate to a one-dimensional array,
// given a predefined grid width. (If you're trying to reference world positions, you should use
// the map's width.)
function positionToIndex(pos, width) {
return coordinatesToIndex(pos.x, pos.y, width);
}
exports.positionToIndex = positionToIndex;
function coordinatesToIndex(x, y, width) {
return (y * width) + x;
}
exports.coordinatesToIndex = coordinatesToIndex;
// Utility function for row-major order: maps an array index to an XY coordinate, given a predefined
// grid width. (If you're trying to reference world positions, you should use the map's width.)
var _x, _y;
function indexToPosition(index, width) {
_y = (index / width) | 0;
_x = index - (_y * width);
return { x: _x, y: _y };
}
exports.indexToPosition = indexToPosition;
// This should only be called on strings output from serializePosition()

@@ -20,0 +40,0 @@ function deserializePosition(s) {

{
"name": "@gathertown/gather-game-common",
"version": "14.0.0",
"version": "15.0.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

export const config = {
gameServerProtocolVersion: 13,
gameServerProtocolVersion: 14,
};

@@ -76,3 +76,3 @@ import { Buffer } from "buffer";

*/
serializeDelta = (): ArrayBuffer|null => {
serializeDelta = (): ArrayBuffer | null => {
if (Object.keys(this._deltaWorldState).length === 0) {

@@ -88,3 +88,3 @@ return null;

return delta;
}
};

@@ -96,3 +96,3 @@ /**

this._deltaWorldState = {};
}
};

@@ -102,7 +102,7 @@ /**

*/
flushDelta = (): ArrayBuffer|null => {
flushDelta = (): ArrayBuffer | null => {
const delta = this.serializeDelta();
this.clearDelta();
return delta;
}
};

@@ -174,6 +174,4 @@ serialize(): ArrayBuffer {

} else if (update.type === UpdateType.Disconnect) {
if (!worldState[update.id]) {
worldState[update.id] = update;
} else if (worldState[update.id].type === UpdateType.FullPosition) {
delete this._worldState[update.id];
if (worldState === this._worldState) {
delete worldState[update.id];
} else {

@@ -180,0 +178,0 @@ worldState[update.id] = update;

@@ -20,2 +20,21 @@ export interface Position {

// Utility functions for row-major order: maps an X/Y coordinate to a one-dimensional array,
// given a predefined grid width. (If you're trying to reference world positions, you should use
// the map's width.)
export function positionToIndex(pos: Position, width: number): number {
return coordinatesToIndex(pos.x, pos.y, width);
}
export function coordinatesToIndex(x: number, y: number, width: number): number {
return (y * width) + x;
}
// Utility function for row-major order: maps an array index to an XY coordinate, given a predefined
// grid width. (If you're trying to reference world positions, you should use the map's width.)
let _x: number, _y: number;
export function indexToPosition(index: number, width: number): Position {
_y = (index / width) | 0;
_x = index - (_y * width);
return { x: _x, y: _y };
}
// This should only be called on strings output from serializePosition()

@@ -22,0 +41,0 @@ export function deserializePosition(s: string): Position {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet