11import { 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 " ;
44import { Players } from "@rbxts/services" ;
55import { t } from "@rbxts/t" ;
66import {
@@ -20,7 +20,6 @@ import {
2020import { ServerEvents , ServerFunctions } from "./networking" ;
2121import {
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