Merge branch 'main' into gacha

This commit is contained in:
timing1337 2022-08-03 12:15:41 +07:00 committed by GitHub
commit 705813039e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,10 +15,12 @@ class MessageType<T> {
//fromjson etc... //fromjson etc...
} }
type UnWrapMessageType<T> = T extends MessageType<infer U> ? U : T;
const messageTypeMap = new Map<PacketName, MessageType<any>>(); const messageTypeMap = new Map<PacketName, MessageType<any>>();
const messageTypeMapReversed = new Map<MessageType<any>, PacketName>(); const messageTypeMapReversed = new Map<MessageType<any>, PacketName>();
function send<Class extends MessageType<T>, T>(type: Class, data: T) { function send<Class extends MessageType<any>, >(type: Class, data: UnWrapMessageType<Class>) {
console.log(type.encode(data).finish()) 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`); if (Logger.VERBOSE_LEVEL > VerboseLevel.ALL) c.log(`Initialized with ${messageTypeMap.size} types`);
//c.log(this.getName(types.PlayerLoginScRsp)) //c.log(this.getName(types.PlayerLoginScRsp))
return; // return;
//if you want a partial type //if you want a partial type
send(types.PlayerLoginScRsp, types.PlayerLoginScRsp.fromPartial({ send(types.PlayerLoginScRsp, {
basicInfo: { basicInfo: {
exp: 0, exp: 0,
level: 1, level: 1,
@ -77,7 +79,11 @@ export default class ProtoFactory {
stamina: 100, stamina: 100,
curTimezone: 1, curTimezone: 1,
serverTimestampMs: Math.round(new Date().getTime() / 1000), serverTimestampMs: Math.round(new Date().getTime() / 1000),
})) bsBinVersion: "1.0.0",
retcode: 0,
isRelay: false,
loginRandom: 0,
});
} }
} }