generic send :D
This commit is contained in:
parent
4de62431db
commit
e24ff7d25d
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
@ -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;
|
||||
|
@ -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<Class extends MessageType<any>, >(type: Class, data: UnWrapMessageType<Class>) {
|
||||
const encodedBuffer = type.encode(data).finish();
|
||||
public async send<Class extends MessageType<any>, >(type: Class, data: UnWrapMessageType<Class>) {
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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!,
|
||||
|
@ -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: {
|
||||
|
@ -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 });
|
||||
}
|
@ -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 });
|
||||
}
|
@ -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);
|
||||
|
@ -14,5 +14,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
reward: { itemList: [] }
|
||||
}
|
||||
|
||||
session.send("FinishTutorialGuideScRsp", dataObj);
|
||||
session.send(FinishTutorialGuideScRsp, dataObj);
|
||||
}
|
@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
lineupList
|
||||
} as GetAllLineupDataScRsp;
|
||||
|
||||
session.send("GetAllLineupDataScRsp", dataObj);
|
||||
session.send(GetAllLineupDataScRsp, dataObj);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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: [],
|
||||
|
@ -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,
|
||||
|
@ -19,5 +19,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
});
|
||||
});
|
||||
|
||||
session.send("GetChallengeScRsp", dataObj);
|
||||
session.send(GetChallengeScRsp, dataObj);
|
||||
}
|
@ -19,5 +19,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
});
|
||||
})
|
||||
|
||||
session.send("GetChallengeRaidInfoScRsp", dataObj);
|
||||
session.send(GetChallengeRaidInfoScRsp, dataObj);
|
||||
}
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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: [],
|
||||
|
@ -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);
|
||||
}
|
@ -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 => {
|
||||
|
@ -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: [{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -42,5 +42,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
});
|
||||
}
|
||||
|
||||
session.send("GetLineupAvatarDataScRsp", dataObj);
|
||||
session.send(GetLineupAvatarDataScRsp, dataObj);
|
||||
}
|
@ -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,
|
||||
|
@ -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: [],
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -54,5 +54,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
});
|
||||
});
|
||||
|
||||
session.send("GetMissionStatusScRsp", dataObj);
|
||||
session.send(GetMissionStatusScRsp, dataObj);
|
||||
}
|
@ -10,5 +10,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
messageGroupList: [],
|
||||
};
|
||||
|
||||
session.send("GetNpcMessageGroupScRsp", dataObj);
|
||||
session.send(GetNpcMessageGroupScRsp, dataObj);
|
||||
}
|
@ -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);
|
||||
|
@ -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: []
|
||||
|
@ -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,
|
||||
|
@ -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: [],
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
@ -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,
|
||||
|
@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
});
|
||||
});
|
||||
|
||||
session.send("GetTutorialScRsp", dataObj);
|
||||
session.send(GetTutorialScRsp, dataObj);
|
||||
}
|
@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) {
|
||||
});
|
||||
});
|
||||
|
||||
session.send("GetTutorialGuideScRsp", dataObj);
|
||||
session.send(GetTutorialGuideScRsp, dataObj);
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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 });
|
||||
}
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user