dredless 1.5.0 → 1.5.2
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.
|
@@ -147,7 +147,11 @@
|
|
|
147
147
|
];
|
|
148
148
|
COMMAND_DEFAULT_FORMATS = {
|
|
149
149
|
type: "positive-fixint",
|
|
150
|
-
|
|
150
|
+
// The official client counts commands in a u32 and writes the smallest
|
|
151
|
+
// unsigned format (fixint, then uint8, uint16, uint32). A fixed uint16
|
|
152
|
+
// wrapped the 65,536th command to 0, and the server drops a connection
|
|
153
|
+
// whose command number goes backwards (ProtocolError).
|
|
154
|
+
n: "uint",
|
|
151
155
|
x: "float32",
|
|
152
156
|
y: "float32",
|
|
153
157
|
mx: "float32",
|
|
@@ -3863,6 +3867,12 @@
|
|
|
3863
3867
|
if (typeof value === "number") {
|
|
3864
3868
|
const schemaFormat = COMMAND_DEFAULT_FORMATS[key];
|
|
3865
3869
|
let format = schemaFormat && schemaFormat !== "nil" ? schemaFormat : null;
|
|
3870
|
+
if (format === "uint") {
|
|
3871
|
+
if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
|
|
3872
|
+
throw new RangeError(`Command field ${key} must be an integer from 0 to 4294967295, got ${value}`);
|
|
3873
|
+
}
|
|
3874
|
+
format = value <= 127 ? "positive-fixint" : value <= 255 ? "uint8" : value <= 65535 ? "uint16" : "uint32";
|
|
3875
|
+
}
|
|
3866
3876
|
if (!format) {
|
|
3867
3877
|
if (!Number.isInteger(value)) format = "float32";
|
|
3868
3878
|
else if (value >= 0) {
|
|
@@ -11425,6 +11435,7 @@
|
|
|
11425
11435
|
if (!Number.isFinite(limit) || limit < 0) return fallback;
|
|
11426
11436
|
return Math.floor(limit);
|
|
11427
11437
|
}
|
|
11438
|
+
var SAVE_ALLOWED_PARENT_WORLD_IDS = /* @__PURE__ */ new Set([66]);
|
|
11428
11439
|
var DredlessClient = class _DredlessClient extends EventBus {
|
|
11429
11440
|
constructor(connection, {
|
|
11430
11441
|
connect = true,
|
|
@@ -11564,8 +11575,10 @@
|
|
|
11564
11575
|
if (!this.connected || !this.ready) return false;
|
|
11565
11576
|
const ship = this.worlds.shipWorld();
|
|
11566
11577
|
if (!ship || ship.isOverworld !== false || ship.parentWorld == null) return false;
|
|
11567
|
-
const
|
|
11568
|
-
|
|
11578
|
+
const parentId = Number(ship.parentWorld);
|
|
11579
|
+
if (SAVE_ALLOWED_PARENT_WORLD_IDS.has(parentId)) return true;
|
|
11580
|
+
const danger = this.worlds.worlds.get(parentId)?.meta?.danger_level;
|
|
11581
|
+
return danger == null || danger === 0;
|
|
11569
11582
|
}
|
|
11570
11583
|
async saveShip({ timeout = 1e4 } = {}) {
|
|
11571
11584
|
this.#assertWritable();
|
|
@@ -11573,7 +11586,7 @@
|
|
|
11573
11586
|
throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
|
|
11574
11587
|
}
|
|
11575
11588
|
if (this.#savePending) throw new Error("A ship save is already in progress");
|
|
11576
|
-
if (!this.canSaveShip()) throw new Error("Saving requires a connected, ready client with
|
|
11589
|
+
if (!this.canSaveShip()) throw new Error("Saving requires a connected, ready client with a current ship outside a known unsafe zone (Mosaic is allowed)");
|
|
11577
11590
|
this.#savePending = true;
|
|
11578
11591
|
try {
|
|
11579
11592
|
return await new Promise((resolve, reject) => {
|