@hytopia.com/server-protocol 1.4.16 → 1.4.19
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.
- package/package.json +1 -1
- package/packets/PacketCore.ts +2 -6
package/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -86,22 +86,18 @@ export function createPacket<TId extends PacketId, TSchema>(
|
|
|
86
86
|
packetDef: IPacketDefinition<TId, TSchema>,
|
|
87
87
|
data: TSchema,
|
|
88
88
|
worldTick?: WorldTick,
|
|
89
|
-
reusablePacket?: unknown[],
|
|
90
89
|
): IPacket<TId, TSchema> {
|
|
91
90
|
if (!packetDef.validate(data)) {
|
|
92
91
|
throw new Error(`Invalid payload for packet with id ${packetDef.id}. Error: ${Ajv.instance.errorsText(packetDef.validate.errors)}`);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
const packet
|
|
96
|
-
|
|
97
|
-
packet[0] = packetDef.id;
|
|
98
|
-
packet[1] = data;
|
|
94
|
+
const packet: IPacket<TId, TSchema> = [packetDef.id, data];
|
|
99
95
|
|
|
100
96
|
if (typeof worldTick === 'number') {
|
|
101
97
|
packet.push(worldTick);
|
|
102
98
|
}
|
|
103
99
|
|
|
104
|
-
return packet
|
|
100
|
+
return packet;
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
export function definePacket<TId extends PacketId, TSchema>(
|