Skip to content

Commit 5b71918

Browse files
committed
deps: bump charm & charm-sync
1 parent d9b9f3e commit 5b71918

6 files changed

Lines changed: 55 additions & 56 deletions

File tree

package-lock.json

Lines changed: 12 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@
1111
"test:build": "rbxtsc --type=game -p testing -i testing/include",
1212
"serve": "rojo serve testing/testing.project.json"
1313
},
14-
"keywords": ["WCS", "Combat", "CombatSystem", "CombatHandler"],
15-
"files": ["out", "!**/*.tsbuildinfo", "!out/tests/*"],
14+
"keywords": [
15+
"WCS",
16+
"Combat",
17+
"CombatSystem",
18+
"CombatHandler"
19+
],
20+
"files": [
21+
"out",
22+
"!**/*.tsbuildinfo",
23+
"!out/tests/*"
24+
],
1625
"author": "wad4444",
1726
"license": "MIT",
1827
"devDependencies": {
@@ -36,8 +45,8 @@
3645
"dependencies": {
3746
"@flamework/core": "^1.2.3",
3847
"@flamework/networking": "^1.2.3",
39-
"@rbxts/charm": "^0.6.0",
40-
"@rbxts/charm-payload-converter": "^1.0.1",
48+
"@rbxts/charm": "^0.10.0",
49+
"@rbxts/charm-sync": "^0.3.0",
4150
"@rbxts/flamework-binary-serializer": "^0.6.0",
4251
"@rbxts/immut": "^0.4.4-ts.0",
4352
"@rbxts/janitor": "^1.17.0-ts.1",

src/source/client.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Reflect } from "@flamework/core";
2-
import { subscribe, sync } from "@rbxts/charm";
3-
import { fromSerializeablePayload } from "@rbxts/charm-payload-converter";
2+
import { subscribe } from "@rbxts/charm";
43
import { t } from "@rbxts/t";
54
import {
65
clientAtom,
@@ -21,11 +20,11 @@ import {
2120
import { ClientEvents, ClientFunctions } from "./networking";
2221
import {
2322
type SerializedData,
24-
dispatchSerializer,
2523
messageSerializer,
2624
} from "./serdes";
2725
import type { UnknownSkill } from "./skill";
2826
import type { UnknownStatus } from "./statusEffect";
27+
import CharmSync from "@rbxts/charm-sync";
2928

3029
let currentInstance: Client | undefined = undefined;
3130
export type WCS_Client = Client;
@@ -34,7 +33,7 @@ class Client {
3433
private isActive = false;
3534
private registeredModules: ModuleScript[] = [];
3635

37-
private clientSyncer = sync.client({
36+
private clientSyncer = CharmSync.client({
3837
atoms: { atom: clientAtom },
3938
});
4039

@@ -80,12 +79,8 @@ class Client {
8079
setActiveHandler(this);
8180
this.setupCharacterReplication();
8281

83-
ClientEvents.sync.connect((serialized) => {
84-
const payloads = dispatchSerializer.deserialize(
85-
serialized.buffer,
86-
serialized.blobs,
87-
);
88-
this.clientSyncer.sync(...payloads.map(fromSerializeablePayload));
82+
ClientEvents.sync.connect((...payloads) => {
83+
this.clientSyncer.sync(...payloads);
8984
});
9085
ClientEvents.start();
9186

src/source/networking.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Networking } from "@flamework/networking";
2+
import type { SyncPayload } from "@rbxts/charm-sync";
3+
import type { CharacterData } from "exports";
24
import type { SerializedData } from "./serdes";
35

46
interface ClientToServerEvents {
@@ -11,7 +13,11 @@ interface ClientToServerEvents {
1113
}
1214

1315
interface ServerToClientEvents {
14-
sync(serialized: SerializedData): void;
16+
sync(
17+
...payloads: SyncPayload<{
18+
atom: Charm.Atom<CharacterData | undefined>;
19+
}>[]
20+
): void;
1521
messageToClient(serialized: SerializedData): void;
1622
messageToClient_urel: Networking.Unreliable<
1723
(serialized: SerializedData) => void

src/source/serdes.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import type Charm from "@rbxts/charm";
2-
import type { SerializeablePayload } from "@rbxts/charm-payload-converter";
31
import { createBinarySerializer } from "@rbxts/flamework-binary-serializer";
4-
import type { CharacterData } from "exports";
52

6-
export const dispatchSerializer =
7-
createBinarySerializer<
8-
SerializeablePayload<{ atom: Charm.Atom<CharacterData | undefined> }>[]
9-
>();
103
export const skillRequestSerializer =
114
createBinarySerializer<
125
[Name: string, Action: "End" | "Start", StarterParams: unknown[]]

src/source/server.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Reflect } from "@flamework/core";
2-
import { atom, sync } from "@rbxts/charm";
3-
import { toSerializeablePayload } from "@rbxts/charm-payload-converter";
2+
import { atom } from "@rbxts/charm";
3+
import CharmSync from "@rbxts/charm-sync";
44
import { Players } from "@rbxts/services";
55
import { t } from "@rbxts/t";
66
import {
@@ -20,7 +20,6 @@ import {
2020
import { ServerEvents, ServerFunctions } from "./networking";
2121
import {
2222
type SerializedData,
23-
dispatchSerializer,
2423
messageSerializer,
2524
skillRequestSerializer,
2625
} from "./serdes";
@@ -35,7 +34,7 @@ class Server {
3534

3635
/** @internal */
3736
public atom = atom<Map<string, CharacterData>>(new Map());
38-
private syncer = sync.server({
37+
private syncer = CharmSync.server({
3938
atoms: { atom: this.atom },
4039
preserveHistory: true,
4140
});
@@ -92,7 +91,7 @@ class Server {
9291
if (!correspondingId) return;
9392
assignedIdentifiers.set(player, correspondingId);
9493

95-
type ModifiedPayload = Charm.SyncPayload<{
94+
type ModifiedPayload = CharmSync.SyncPayload<{
9695
atom: Charm.Atom<CharacterData | undefined>;
9796
}>;
9897
const modified: ModifiedPayload[] = [];
@@ -107,23 +106,24 @@ class Server {
107106
data: { atom: characterData },
108107
});
109108
}
110-
} else {
111-
const data = payload.data.atom;
112-
if (data === undefined) continue;
109+
continue;
110+
}
113111

114-
const characterData = data.get(correspondingId);
115-
if (characterData === undefined) continue;
112+
print(payload.data);
116113

117-
modified.push({
118-
type: "patch",
119-
data: { atom: characterData },
120-
});
121-
}
114+
const data = payload.data.atom;
115+
if (data === undefined) continue;
116+
117+
const characterData = data.get(correspondingId);
118+
if (characterData === undefined) continue;
119+
120+
modified.push({
121+
type: "patch",
122+
data: { atom: characterData as never },
123+
});
122124
}
123125

124-
const serializeable = modified.map(toSerializeablePayload);
125-
const serialized = dispatchSerializer.serialize(serializeable);
126-
ServerEvents.sync.fire(player, serialized);
126+
ServerEvents.sync.fire(player, ...modified);
127127
});
128128
ServerEvents.start.connect((player) => this.syncer.hydrate(player));
129129

0 commit comments

Comments
 (0)