diff --git a/src/commands/target.ts b/src/commands/target.ts index cb4812b..09e1e61 100644 --- a/src/commands/target.ts +++ b/src/commands/target.ts @@ -32,7 +32,7 @@ export default async function handle(command: Command) { return; } - const autoTarget = findBestMatch(target, possibleTargets.map(x => x.id)).bestMatch.target; + const autoTarget = findBestMatch(target, possibleTargets.map(x => x.id))?.bestMatch.target; Interface.target = possibleTargets.find(x => x.id === autoTarget)!.session; diff --git a/src/game/Scene.ts b/src/game/Scene.ts index 857d9f4..2162b90 100644 --- a/src/game/Scene.ts +++ b/src/game/Scene.ts @@ -13,7 +13,7 @@ export class Scene { public spawnEntity(entity: Entity, silent: boolean = false) { this.entities.set(entity.entityId, entity); if (!silent) { - this.player.session.send("SceneEntityUpdateScNotify", { + this.player.session.send(SceneEntityUpdateScNotify, { entityList: [entity.getSceneEntityInfo()] } as SceneEntityUpdateScNotify); } @@ -22,7 +22,7 @@ export class Scene { public despawnEntity(entityId: number, silent: boolean = false) { this.entities.delete(entityId); if (!silent) { - this.player.session.send("SceneEntityDisappearScNotify", { + this.player.session.send(SceneEntityDisappearScNotify, { entityIdList: [entityId] } as SceneEntityDisappearScNotify); } diff --git a/src/index.ts b/src/index.ts index 2033a23..b22d6d5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,8 +12,9 @@ import ProtoFactory from "./util/ProtoFactory" const c = new Logger("CrepeSR"); c.log(`Starting CrepeSR...`); + Banners.init(); ProtoFactory.init(); -Interface.start(); +Interface.start(); HttpServer.getInstance().start(); SRServer.getInstance().start(); \ No newline at end of file diff --git a/src/server/kcp/Packet.ts b/src/server/kcp/Packet.ts index db73c45..45ecb72 100644 --- a/src/server/kcp/Packet.ts +++ b/src/server/kcp/Packet.ts @@ -68,6 +68,20 @@ export default class Packet { process.exit(1); } } + + public static fromEncodedBuffer(data: Buffer, name: PacketName): Buffer { + const cmdid = CmdID[name]; + const packet = Buffer.allocUnsafe(16 + data.length); + packet.writeUInt32BE(0x1234567); + packet.writeUint16BE(cmdid, 4); + packet.writeUint16BE(0, 6); + packet.writeUint32BE(data.length, 8); + data.copy(packet, 12); + packet.writeUint32BE(0x89abcdef, 12 + data.length); + return packet; + } + + } export type PacketName = keyof typeof CmdID; diff --git a/src/server/kcp/Session.ts b/src/server/kcp/Session.ts index 21d65fb..5a348fe 100644 --- a/src/server/kcp/Session.ts +++ b/src/server/kcp/Session.ts @@ -80,32 +80,33 @@ export default class Session { public async sync() { const avatars = await Avatar.fromUID(this.player.db._id); - this.sendT(PlayerSyncScNotify, PlayerSyncScNotify.fromPartial({ + this.send(PlayerSyncScNotify, PlayerSyncScNotify.fromPartial({ avatarSync: { avatarList: avatars.map(x => x.data), }, basicInfo: this.player.db.basicInfo })); - this.player.save(); + //this.player.save(); } - public async sendT, >(type: Class, data: UnWrapMessageType) { - const encodedBuffer = type.encode(data).finish(); + public async send, >(type: Class, data: UnWrapMessageType) { const typeName = ProtoFactory.getName(type); + const encodedBuffer = type.encode(type.fromPartial(data)).finish(); + const packet = Packet.fromEncodedBuffer(Buffer.from(encodedBuffer), typeName); this.c.verbL(data); this.c.verbH(encodedBuffer); + if(!encodedBuffer) console.log("sad!") if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName); - //todo: might want to regen the ts-proto types with env = node - this.kcpobj.send(Buffer.from(encodedBuffer)); + this.kcpobj.send(packet); } public kick(hard: boolean = true) { SRServer.getInstance().sessions.delete(this.id); this.kicked = true; - if (hard) this.sendT(PlayerKickOutScNotify, { + if (hard) this.send(PlayerKickOutScNotify, { kickType: PlayerKickOutScNotify_KickType.KICK_BLACK, blackInfo: { limitLevel: BlackLimitLevel.BLACK_LIMIT_LEVEL_ALL, @@ -119,21 +120,6 @@ export default class Session { } - /** - * @deprecated The method should not be used - * use sendT instead - */ - public send(name: PacketName, body: {}) { - this.c.verbL(body); - const packet = Packet.encode(name, body); - if (!packet) return; - this.c.verbH(packet.rawData); - if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(packet.protoName); - this.kcpobj.send(packet.rawData); - //i'll rename sendT to send once all instances are updated - this.c.warn("Session.send deprecated! migrate to Session.sendT"); - } - public sendRaw(data: Buffer) { if (this.kicked) return; this.kcpobj.send(data); diff --git a/src/server/packets/ChangeLineupLeaderCsReq.ts b/src/server/packets/ChangeLineupLeaderCsReq.ts index 5c1a485..8c2ad1c 100644 --- a/src/server/packets/ChangeLineupLeaderCsReq.ts +++ b/src/server/packets/ChangeLineupLeaderCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as ChangeLineupLeaderCsReq; - session.send("ChangeLineupLeaderScRsp", { + session.send(ChangeLineupLeaderScRsp, { retcode: 0, slot: body.slot } as ChangeLineupLeaderScRsp); diff --git a/src/server/packets/DoGachaCsReq.ts b/src/server/packets/DoGachaCsReq.ts index 3dff2bf..05174e7 100644 --- a/src/server/packets/DoGachaCsReq.ts +++ b/src/server/packets/DoGachaCsReq.ts @@ -22,7 +22,7 @@ export default async function handle(session: Session, packet: Packet) { isNew: true //TODO: avatar checking } as GachaItem); } - session.send("DoGachaScRsp", { + session.send(DoGachaScRsp, { retcode: 0, gachaId: body.gachaId!, gachaNum: body.gachaNum!, diff --git a/src/server/packets/EnterMazeCsReq.ts b/src/server/packets/EnterMazeCsReq.ts index 5109714..fba4ff6 100644 --- a/src/server/packets/EnterMazeCsReq.ts +++ b/src/server/packets/EnterMazeCsReq.ts @@ -15,7 +15,7 @@ export default async function handle(session: Session, packet: Packet) { session.player.db.posData.planeID = mazeEntry.PlaneID; session.player.save(); - session.send("EnterMazeScRsp", { + session.send(EnterMazeScRsp, { retcode: 0, maze: { floor: { diff --git a/src/server/packets/EnterSectionCsReq.ts b/src/server/packets/EnterSectionCsReq.ts index b98a883..79ddead 100644 --- a/src/server/packets/EnterSectionCsReq.ts +++ b/src/server/packets/EnterSectionCsReq.ts @@ -1,6 +1,7 @@ +import { EnterSectionScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("EnterSectionScRsp", { retcode: 0 }); + session.send(EnterSectionScRsp, { retcode: 0 }); } \ No newline at end of file diff --git a/src/server/packets/EntityBindPropCsReq.ts b/src/server/packets/EntityBindPropCsReq.ts index 2e9a8e2..0ae3716 100644 --- a/src/server/packets/EntityBindPropCsReq.ts +++ b/src/server/packets/EntityBindPropCsReq.ts @@ -1,6 +1,7 @@ +import { EntityBindPropScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("EntityBindPropScRsp", { retcode: 0 }); + session.send(EntityBindPropScRsp, { retcode: 0 }); } \ No newline at end of file diff --git a/src/server/packets/FinishTalkMissionCsReq.ts b/src/server/packets/FinishTalkMissionCsReq.ts index 157924b..edced0f 100644 --- a/src/server/packets/FinishTalkMissionCsReq.ts +++ b/src/server/packets/FinishTalkMissionCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as FinishTalkMissionCsReq; - session.send("FinishTalkMissionScRsp", { + session.send(FinishTalkMissionScRsp, { retcode: 0, talkStr: body.talkStr } as FinishTalkMissionScRsp); diff --git a/src/server/packets/FinishTutorialGuideCsReq.ts b/src/server/packets/FinishTutorialGuideCsReq.ts index 17cc88a..cdad127 100644 --- a/src/server/packets/FinishTutorialGuideCsReq.ts +++ b/src/server/packets/FinishTutorialGuideCsReq.ts @@ -14,5 +14,5 @@ export default async function handle(session: Session, packet: Packet) { reward: { itemList: [] } } - session.send("FinishTutorialGuideScRsp", dataObj); + session.send(FinishTutorialGuideScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetAllLineupDataCsReq.ts b/src/server/packets/GetAllLineupDataCsReq.ts index e3d9f1c..2788fcd 100644 --- a/src/server/packets/GetAllLineupDataCsReq.ts +++ b/src/server/packets/GetAllLineupDataCsReq.ts @@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) { lineupList } as GetAllLineupDataScRsp; - session.send("GetAllLineupDataScRsp", dataObj); + session.send(GetAllLineupDataScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetAvatarDataCsReq.ts b/src/server/packets/GetAvatarDataCsReq.ts index 137516e..1453dfb 100644 --- a/src/server/packets/GetAvatarDataCsReq.ts +++ b/src/server/packets/GetAvatarDataCsReq.ts @@ -2,22 +2,25 @@ import { GetAvatarDataCsReq, GetAvatarDataScRsp } from "../../data/proto/StarRai import AvatarExcelTable from "../../data/excel/AvatarExcelTable.json"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; -import Avatar from "../../db/Avatar"; +import AvatarDb from "../../db/Avatar"; + +import { Avatar } from "../../data/proto/StarRail"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as GetAvatarDataCsReq; - const avatar = await Avatar.fromUID(session.player.db._id); + const avatar = await AvatarDb.fromUID(session.player.db._id); + console.log(avatar.length) const dataObj = { retcode: 0, - avatarList: avatar.map(av => av.data), + avatarList: avatar.map(av => Avatar.fromPartial(av.data)), isAll: body.isGetAll - } as GetAvatarDataScRsp; + }; Object.values(AvatarExcelTable).forEach(avatar => { // dataObj.avatarList.push() }); - session.send("GetAvatarDataScRsp", dataObj); + session.send(GetAvatarDataScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetBagCsReq.ts b/src/server/packets/GetBagCsReq.ts index 08c1914..8af4f24 100644 --- a/src/server/packets/GetBagCsReq.ts +++ b/src/server/packets/GetBagCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetBagScRsp", { + session.send(GetBagScRsp, { equipmentList: [], materialList: [], relicList: [], diff --git a/src/server/packets/GetBasicInfoCsReq.ts b/src/server/packets/GetBasicInfoCsReq.ts index 471f0f6..e07860a 100644 --- a/src/server/packets/GetBasicInfoCsReq.ts +++ b/src/server/packets/GetBasicInfoCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetBasicInfoScRsp", { + session.send(GetBasicInfoScRsp, { curDay: 1, exchangeTimes: 0, retcode: 0, diff --git a/src/server/packets/GetChallengeCsReq.ts b/src/server/packets/GetChallengeCsReq.ts index 9acba58..52d61f3 100644 --- a/src/server/packets/GetChallengeCsReq.ts +++ b/src/server/packets/GetChallengeCsReq.ts @@ -19,5 +19,5 @@ export default async function handle(session: Session, packet: Packet) { }); }); - session.send("GetChallengeScRsp", dataObj); + session.send(GetChallengeScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetChallengeRaidInfoCsReq.ts b/src/server/packets/GetChallengeRaidInfoCsReq.ts index 9cf1be9..8192e61 100644 --- a/src/server/packets/GetChallengeRaidInfoCsReq.ts +++ b/src/server/packets/GetChallengeRaidInfoCsReq.ts @@ -19,5 +19,5 @@ export default async function handle(session: Session, packet: Packet) { }); }) - session.send("GetChallengeRaidInfoScRsp", dataObj); + session.send(GetChallengeRaidInfoScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetCurBattleInfoCsReq.ts b/src/server/packets/GetCurBattleInfoCsReq.ts index 5fb9716..0ae14a5 100644 --- a/src/server/packets/GetCurBattleInfoCsReq.ts +++ b/src/server/packets/GetCurBattleInfoCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const lineup = await session.player.getLineup(); - session.send("GetCurBattleInfoScRsp", { + session.send(GetCurBattleInfoScRsp, { retcode: 0, avatarList: lineup.avatarList.map(list => { return { diff --git a/src/server/packets/GetCurLineupDataCsReq.ts b/src/server/packets/GetCurLineupDataCsReq.ts index a05c50b..0968fce 100644 --- a/src/server/packets/GetCurLineupDataCsReq.ts +++ b/src/server/packets/GetCurLineupDataCsReq.ts @@ -30,7 +30,7 @@ export default async function handle(session: Session, packet: Packet) { session.player.save(); } - session.send("GetCurLineupDataScRsp", { + session.send(GetCurLineupDataScRsp, { retcode: 0, lineup: { ...lineup, diff --git a/src/server/packets/GetCurSceneInfoCsReq.ts b/src/server/packets/GetCurSceneInfoCsReq.ts index 175f3fe..87cf150 100644 --- a/src/server/packets/GetCurSceneInfoCsReq.ts +++ b/src/server/packets/GetCurSceneInfoCsReq.ts @@ -8,7 +8,7 @@ export default async function handle(session: Session, packet: Packet) { const _lineup = session.player.db.lineup; const lineup = _lineup.lineups[_lineup.curIndex]; const curAvatarEntity = new ActorEntity(session.player.scene, lineup.avatarList[0], posData.pos); - session.send("GetCurSceneInfoScRsp", { + session.send(GetCurSceneInfoScRsp, { retcode: 0, scene: { planeId: posData.planeID, diff --git a/src/server/packets/GetDialogueEventDataCsReq.ts b/src/server/packets/GetDialogueEventDataCsReq.ts index 0af2e98..2ab54c7 100644 --- a/src/server/packets/GetDialogueEventDataCsReq.ts +++ b/src/server/packets/GetDialogueEventDataCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetDialogueEventDataScRsp", { + session.send(GetDialogueEventDataScRsp, { dialogueEventList: [], retcode: 0 } as GetDialogueEventDataScRsp); diff --git a/src/server/packets/GetExpeditionDataCsReq.ts b/src/server/packets/GetExpeditionDataCsReq.ts index a2b23ca..72c48b9 100644 --- a/src/server/packets/GetExpeditionDataCsReq.ts +++ b/src/server/packets/GetExpeditionDataCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetExpeditionDataScRsp", { + session.send(GetExpeditionDataScRsp, { retcode: 0, expedtionList: [], unlockedExpeditionIdList: [], diff --git a/src/server/packets/GetFirstTalkNpcCsReq.ts b/src/server/packets/GetFirstTalkNpcCsReq.ts index 488e638..0b2a00d 100644 --- a/src/server/packets/GetFirstTalkNpcCsReq.ts +++ b/src/server/packets/GetFirstTalkNpcCsReq.ts @@ -19,5 +19,5 @@ export default async function handle(session: Session, packet: Packet) { dataObj.npcMeetStatusList.push(meetStatusObj); }); - session.send("GetFirstTalkNpcScRsp", dataObj); + session.send(GetFirstTalkNpcScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetGachaInfoCsReq.ts b/src/server/packets/GetGachaInfoCsReq.ts index 382b094..c2e3c70 100644 --- a/src/server/packets/GetGachaInfoCsReq.ts +++ b/src/server/packets/GetGachaInfoCsReq.ts @@ -4,7 +4,7 @@ import Session from "../kcp/Session"; import Banner from './../../util/Banner'; export default async function handle(session: Session, packet: Packet) { - session.send("GetGachaInfoScRsp", { + session.send(GetGachaInfoScRsp, { gachaRandom: 0, retcode: 0, gachaInfoList: Banner.config.map(banner => { diff --git a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts index 121fe4f..2355920 100644 --- a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts +++ b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { let gender: Gender = (session.player.db.heroBasicType % 2 === 0) ? Gender.GenderWoman : Gender.GenderMan; - session.send("GetHeroBasicTypeInfoScRsp", { + session.send(GetHeroBasicTypeInfoScRsp, { retcode: 0, gender: gender, basicTypeInfoList: [{ diff --git a/src/server/packets/GetHeroPathCsReq.ts b/src/server/packets/GetHeroPathCsReq.ts index 950fa71..ee00aa0 100644 --- a/src/server/packets/GetHeroPathCsReq.ts +++ b/src/server/packets/GetHeroPathCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetHeroPathScRsp", { + session.send(GetHeroPathScRsp, { retcode: 0, heroPathList: [] } as GetHeroPathScRsp); diff --git a/src/server/packets/GetLevelRewardTakenListCsReq.ts b/src/server/packets/GetLevelRewardTakenListCsReq.ts index 766e8b5..f90f94a 100644 --- a/src/server/packets/GetLevelRewardTakenListCsReq.ts +++ b/src/server/packets/GetLevelRewardTakenListCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetLevelRewardTakenListScRsp", { + session.send(GetLevelRewardTakenListScRsp, { retcode: 0, takenLevelList: [] } as GetLevelRewardTakenListScRsp); diff --git a/src/server/packets/GetLineupAvatarDataCsReq.ts b/src/server/packets/GetLineupAvatarDataCsReq.ts index 1131059..1fd81a0 100644 --- a/src/server/packets/GetLineupAvatarDataCsReq.ts +++ b/src/server/packets/GetLineupAvatarDataCsReq.ts @@ -42,5 +42,5 @@ export default async function handle(session: Session, packet: Packet) { }); } - session.send("GetLineupAvatarDataScRsp", dataObj); + session.send(GetLineupAvatarDataScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetLoginActivityCsReq.ts b/src/server/packets/GetLoginActivityCsReq.ts index f184f4d..40ba548 100644 --- a/src/server/packets/GetLoginActivityCsReq.ts +++ b/src/server/packets/GetLoginActivityCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetLoginActivityScRsp", { + session.send(GetLoginActivityScRsp, { retcode: 0, loginActivityList: [{ id: 1001, diff --git a/src/server/packets/GetMailCsReq.ts b/src/server/packets/GetMailCsReq.ts index 13f4a7d..767da68 100644 --- a/src/server/packets/GetMailCsReq.ts +++ b/src/server/packets/GetMailCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetMailScRsp", { + session.send(GetMailScRsp, { retcode: 0, mailList: [], noticeMailList: [], diff --git a/src/server/packets/GetMazeMapInfoCsReq.ts b/src/server/packets/GetMazeMapInfoCsReq.ts index e6a8935..c81b883 100644 --- a/src/server/packets/GetMazeMapInfoCsReq.ts +++ b/src/server/packets/GetMazeMapInfoCsReq.ts @@ -26,5 +26,5 @@ export default async function handle(session: Session, packet: Packet) { dataObj.unlockTeleportList = MazePlaneExcel.getAllEntries().map(x => x.ID); - session.send("GetMazeMapInfoScRsp", dataObj); + session.send(GetMazeMapInfoScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetMazeTimeOfDayCsReq.ts b/src/server/packets/GetMazeTimeOfDayCsReq.ts index c76c2da..ca9e8d6 100644 --- a/src/server/packets/GetMazeTimeOfDayCsReq.ts +++ b/src/server/packets/GetMazeTimeOfDayCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetMazeTimeOfDayScRsp", { + session.send(GetMazeTimeOfDayScRsp, { retcode: 0, mazeTimeOfDayMap: {} } as GetMazeTimeOfDayScRsp); diff --git a/src/server/packets/GetMissionDataCsReq.ts b/src/server/packets/GetMissionDataCsReq.ts index 982eb01..c2451ec 100644 --- a/src/server/packets/GetMissionDataCsReq.ts +++ b/src/server/packets/GetMissionDataCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetMissionDataScRsp", { + session.send(GetMissionDataScRsp, { retcode: 0, missionList: [] } as GetMissionDataScRsp); diff --git a/src/server/packets/GetMissionEventDataCsReq.ts b/src/server/packets/GetMissionEventDataCsReq.ts index cf37c30..ff0aff5 100644 --- a/src/server/packets/GetMissionEventDataCsReq.ts +++ b/src/server/packets/GetMissionEventDataCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetMissionEventDataScRsp", { + session.send(GetMissionEventDataScRsp, { retcode: 0, missionEventList: [] } as unknown as GetMissionEventDataScRsp); diff --git a/src/server/packets/GetMissionStatusCsReq.ts b/src/server/packets/GetMissionStatusCsReq.ts index 6bf1c29..7270ce3 100644 --- a/src/server/packets/GetMissionStatusCsReq.ts +++ b/src/server/packets/GetMissionStatusCsReq.ts @@ -54,5 +54,5 @@ export default async function handle(session: Session, packet: Packet) { }); }); - session.send("GetMissionStatusScRsp", dataObj); + session.send(GetMissionStatusScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetNpcMessageGroupCsReq.ts b/src/server/packets/GetNpcMessageGroupCsReq.ts index a643698..b9c200e 100644 --- a/src/server/packets/GetNpcMessageGroupCsReq.ts +++ b/src/server/packets/GetNpcMessageGroupCsReq.ts @@ -10,5 +10,5 @@ export default async function handle(session: Session, packet: Packet) { messageGroupList: [], }; - session.send("GetNpcMessageGroupScRsp", dataObj); + session.send(GetNpcMessageGroupScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetNpcStatusCsReq.ts b/src/server/packets/GetNpcStatusCsReq.ts index 040538a..b7c9a28 100644 --- a/src/server/packets/GetNpcStatusCsReq.ts +++ b/src/server/packets/GetNpcStatusCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetNpcStatusScRsp", { + session.send(GetNpcStatusScRsp, { retcode: 0, messageStatusList: [] } as GetNpcStatusScRsp); diff --git a/src/server/packets/GetNpcTakenRewardCsReq.ts b/src/server/packets/GetNpcTakenRewardCsReq.ts index 55bf8ac..644816f 100644 --- a/src/server/packets/GetNpcTakenRewardCsReq.ts +++ b/src/server/packets/GetNpcTakenRewardCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as GetNpcTakenRewardCsReq; - session.send("GetNpcTakenRewardScRsp", { + session.send(GetNpcTakenRewardScRsp, { retcode: 0, npcId: body.npcId, talkEventList: [] diff --git a/src/server/packets/GetPrestigeInfoCsReq.ts b/src/server/packets/GetPrestigeInfoCsReq.ts index 5a18c39..ba5901e 100644 --- a/src/server/packets/GetPrestigeInfoCsReq.ts +++ b/src/server/packets/GetPrestigeInfoCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetPrestigeInfoScRsp", { + session.send(GetPrestigeInfoScRsp, { retcode: 0, prestigeInfo: { exp: 0, diff --git a/src/server/packets/GetQuestDataCsReq.ts b/src/server/packets/GetQuestDataCsReq.ts index 599a783..02c1101 100644 --- a/src/server/packets/GetQuestDataCsReq.ts +++ b/src/server/packets/GetQuestDataCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetQuestDataScRsp", { + session.send(GetQuestDataScRsp, { questList: [], retcode: 0, takenAchievementLevelList: [], diff --git a/src/server/packets/GetRogueInfoCsReq.ts b/src/server/packets/GetRogueInfoCsReq.ts index 64eb9bb..67b3ec6 100644 --- a/src/server/packets/GetRogueInfoCsReq.ts +++ b/src/server/packets/GetRogueInfoCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetRogueInfoScRsp", { + session.send(GetRogueInfoScRsp, { retcode: 0, rogueInfo: { status: RogueStatus.ROGUE_STATUS_NONE, diff --git a/src/server/packets/GetShopListCsReq.ts b/src/server/packets/GetShopListCsReq.ts index ee78be2..3d1c68d 100644 --- a/src/server/packets/GetShopListCsReq.ts +++ b/src/server/packets/GetShopListCsReq.ts @@ -37,5 +37,5 @@ export default async function handle(session: Session, packet: Packet) { dataObj.shopList.push(shopObj); }); - session.send("GetShopListScRsp", dataObj); + session.send(GetShopListScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetSpringRecoverDataCsReq.ts b/src/server/packets/GetSpringRecoverDataCsReq.ts index 75dd1c6..7b28981 100644 --- a/src/server/packets/GetSpringRecoverDataCsReq.ts +++ b/src/server/packets/GetSpringRecoverDataCsReq.ts @@ -3,7 +3,7 @@ import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { - session.send("GetSpringRecoverDataScRsp", { + session.send(GetSpringRecoverDataScRsp, { retcode: 0, healPoolInfo: { healPool: 0, diff --git a/src/server/packets/GetTutorialCsReq.ts b/src/server/packets/GetTutorialCsReq.ts index cfd40a4..5285561 100644 --- a/src/server/packets/GetTutorialCsReq.ts +++ b/src/server/packets/GetTutorialCsReq.ts @@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) { }); }); - session.send("GetTutorialScRsp", dataObj); + session.send(GetTutorialScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/GetTutorialGuideCsReq.ts b/src/server/packets/GetTutorialGuideCsReq.ts index fec08fc..471d915 100644 --- a/src/server/packets/GetTutorialGuideCsReq.ts +++ b/src/server/packets/GetTutorialGuideCsReq.ts @@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) { }); }); - session.send("GetTutorialGuideScRsp", dataObj); + session.send(GetTutorialGuideScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/JoinLineupCsReq.ts b/src/server/packets/JoinLineupCsReq.ts index dee8d04..50c5b87 100644 --- a/src/server/packets/JoinLineupCsReq.ts +++ b/src/server/packets/JoinLineupCsReq.ts @@ -1,4 +1,4 @@ -import { AvatarType, JoinLineupCsReq, SyncLineupNotify, SyncLineupReason } from "../../data/proto/StarRail"; +import { AvatarType, JoinLineupCsReq, JoinLineupScRsp, SyncLineupNotify, SyncLineupReason } from "../../data/proto/StarRail"; import Avatar from "../../db/Avatar"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; @@ -6,7 +6,7 @@ import Session from "../kcp/Session"; // JoinLineupCsReq { baseAvatarId: 1002, slot: 1 } export default async function handle(session: Session, packet: Packet) { const body = packet.body as JoinLineupCsReq; - session.send("JoinLineupScRsp", { retcode: 0 }); + session.send(JoinLineupScRsp, { retcode: 0 }); let lineup = await session.player.getLineup(); const slot = body.slot || 0; @@ -29,7 +29,7 @@ export default async function handle(session: Session, packet: Packet) { session.player.setLineup(lineup); session.player.save(); - session.send("SyncLineupNotify", { + session.send(SyncLineupNotify, { lineup: lineup, reasonList: [SyncLineupReason.SYNC_REASON_NONE] } as SyncLineupNotify); diff --git a/src/server/packets/PlayerGetTokenCsReq.ts b/src/server/packets/PlayerGetTokenCsReq.ts index 0c32f5a..4b294e0 100644 --- a/src/server/packets/PlayerGetTokenCsReq.ts +++ b/src/server/packets/PlayerGetTokenCsReq.ts @@ -21,7 +21,7 @@ export default async function handle(session: Session, packet: Packet) { const dataObj = { retcode: 0, - secretKeySeed: 0 + secretKeySeed: 0, } as PlayerGetTokenScRsp; const account = await Account.fromToken(body.token || ""); @@ -46,5 +46,5 @@ export default async function handle(session: Session, packet: Packet) { } dataObj.uid = player.db._id; - session.send("PlayerGetTokenScRsp", dataObj); + session.send(PlayerGetTokenScRsp, dataObj); } \ No newline at end of file diff --git a/src/server/packets/PlayerLoginCsReq.ts b/src/server/packets/PlayerLoginCsReq.ts index a1d2c9c..616b528 100644 --- a/src/server/packets/PlayerLoginCsReq.ts +++ b/src/server/packets/PlayerLoginCsReq.ts @@ -82,7 +82,7 @@ export default async function handle(session: Session, packet: Packet) { plr.save(); } - session.send("PlayerLoginScRsp", { + session.send(PlayerLoginScRsp, { basicInfo: plr!.db.basicInfo as PlayerBasicInfo, isNewPlayer: false, stamina: 100, diff --git a/src/server/packets/SceneEntityMoveCsReq.ts b/src/server/packets/SceneEntityMoveCsReq.ts index 2370c65..dfbe65e 100644 --- a/src/server/packets/SceneEntityMoveCsReq.ts +++ b/src/server/packets/SceneEntityMoveCsReq.ts @@ -34,7 +34,7 @@ export default async function handle(session: Session, packet: Packet) { } } - session.send("SceneEntityMoveScRsp", { + session.send(SceneEntityMoveScRsp, { retcode: 0, downloadData: undefined, } as SceneEntityMoveScRsp); diff --git a/src/server/packets/SetClientPausedCsReq.ts b/src/server/packets/SetClientPausedCsReq.ts index e31ad47..ee7354e 100644 --- a/src/server/packets/SetClientPausedCsReq.ts +++ b/src/server/packets/SetClientPausedCsReq.ts @@ -1,8 +1,8 @@ -import { SetClientPausedCsReq } from "../../data/proto/StarRail"; +import { SetClientPausedCsReq, SetClientPausedScRsp } from "../../data/proto/StarRail"; import Packet from "../kcp/Packet"; import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as SetClientPausedCsReq; - session.send("SetClientPausedScRsp", { retcode: 0, paused: body.paused }); + session.send(SetClientPausedScRsp, { retcode: 0, paused: body.paused }); } \ No newline at end of file diff --git a/src/server/packets/SetLineupNameCsReq.ts b/src/server/packets/SetLineupNameCsReq.ts index 6fe94d6..271c9f0 100644 --- a/src/server/packets/SetLineupNameCsReq.ts +++ b/src/server/packets/SetLineupNameCsReq.ts @@ -14,7 +14,7 @@ export default async function handle(session: Session, packet: Packet) { session.c.error("Failed to set lineup name", false); } - session.send("SetLineupNameScRsp", { + session.send(SetLineupNameScRsp, { retcode: 0, index: session.player.db.lineup.curIndex, name: body.name diff --git a/src/server/packets/StartChallengeCsReq.ts b/src/server/packets/StartChallengeCsReq.ts index 80e6085..7c8c5d7 100644 --- a/src/server/packets/StartChallengeCsReq.ts +++ b/src/server/packets/StartChallengeCsReq.ts @@ -8,7 +8,7 @@ export default async function handle(session: Session, packet: Packet) { // TODO: This packet is just a base - session.send("StartChallengeScRsp", { + session.send(StartChallengeScRsp, { retcode: 0, curChallenge: { challengeId: body.challengeId, diff --git a/src/server/packets/SwapLineupCsReq.ts b/src/server/packets/SwapLineupCsReq.ts index f22c944..bf2dc9d 100644 --- a/src/server/packets/SwapLineupCsReq.ts +++ b/src/server/packets/SwapLineupCsReq.ts @@ -4,7 +4,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as SwapLineupCsReq; - session.send("SwapLineupScRsp", { retcode: 0 } as SwapLineupScRsp); + session.send(SwapLineupScRsp, { retcode: 0 } as SwapLineupScRsp); let lineup = await session.player.getLineup(); const _copy = lineup.avatarList[body.dstSlot]; @@ -14,7 +14,7 @@ export default async function handle(session: Session, packet: Packet) { session.player.setLineup(lineup); session.player.save(); - session.send("SyncLineupNotify", { + session.send(SyncLineupNotify, { lineup: lineup, reasonList: [SyncLineupReason.SYNC_REASON_NONE] } as SyncLineupNotify); diff --git a/src/server/packets/SyncTimeCsReq.ts b/src/server/packets/SyncTimeCsReq.ts index 7f90072..a0d2f77 100644 --- a/src/server/packets/SyncTimeCsReq.ts +++ b/src/server/packets/SyncTimeCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as SyncTimeCsReq; - session.send("SyncTimeScRsp", { + session.send(SyncTimeScRsp, { retcode: 0, clientTimeMs: body.clientTimeMs, serverTimeMs: Math.round(new Date().getTime() / 1000) diff --git a/src/server/packets/UnlockTutorialGuideCsReq.ts b/src/server/packets/UnlockTutorialGuideCsReq.ts index 6268c08..6351f33 100644 --- a/src/server/packets/UnlockTutorialGuideCsReq.ts +++ b/src/server/packets/UnlockTutorialGuideCsReq.ts @@ -5,7 +5,7 @@ import Session from "../kcp/Session"; export default async function handle(session: Session, packet: Packet) { const body = packet.body as UnlockTutorialGuideCsReq; - session.send("UnlockTutorialGuideScRsp", { + session.send(UnlockTutorialGuideScRsp, { retcode: 0, tutorialGuide: { id: body.groupId,