From 0c62eff9d64115245e7312728fd37327343d1a65 Mon Sep 17 00:00:00 2001 From: TheLostTree <65834918+TheLostTree@users.noreply.github.com> Date: Tue, 2 Aug 2022 21:34:55 -0700 Subject: [PATCH] better generic send in protofactory PLS UPDATE TO USING THIS SOON --- src/util/ProtoFactory.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/util/ProtoFactory.ts b/src/util/ProtoFactory.ts index ae56ae7..ebc3b82 100644 --- a/src/util/ProtoFactory.ts +++ b/src/util/ProtoFactory.ts @@ -15,10 +15,12 @@ class MessageType { //fromjson etc... } +type UnWrapMessageType = T extends MessageType ? U : T; + const messageTypeMap = new Map>(); const messageTypeMapReversed = new Map, PacketName>(); -function send, T>(type: Class, data: T) { +function send, >(type: Class, data: UnWrapMessageType) { console.log(type.encode(data).finish()) } @@ -59,10 +61,10 @@ export default class ProtoFactory { if (Logger.VERBOSE_LEVEL > VerboseLevel.ALL) c.log(`Initialized with ${messageTypeMap.size} types`); //c.log(this.getName(types.PlayerLoginScRsp)) - return; + // return; //if you want a partial type - send(types.PlayerLoginScRsp, types.PlayerLoginScRsp.fromPartial({ + send(types.PlayerLoginScRsp, { basicInfo: { exp: 0, level: 1, @@ -77,7 +79,11 @@ export default class ProtoFactory { stamina: 100, curTimezone: 1, serverTimestampMs: Math.round(new Date().getTime() / 1000), - })) + bsBinVersion: "1.0.0", + retcode: 0, + isRelay: false, + loginRandom: 0, + }); } }