generic send :D
This commit is contained in:
parent
4de62431db
commit
e24ff7d25d
@ -32,7 +32,7 @@ export default async function handle(command: Command) {
|
|||||||
return;
|
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;
|
Interface.target = possibleTargets.find(x => x.id === autoTarget)!.session;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export class Scene {
|
|||||||
public spawnEntity(entity: Entity, silent: boolean = false) {
|
public spawnEntity(entity: Entity, silent: boolean = false) {
|
||||||
this.entities.set(entity.entityId, entity);
|
this.entities.set(entity.entityId, entity);
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
this.player.session.send("SceneEntityUpdateScNotify", {
|
this.player.session.send(SceneEntityUpdateScNotify, {
|
||||||
entityList: [entity.getSceneEntityInfo()]
|
entityList: [entity.getSceneEntityInfo()]
|
||||||
} as SceneEntityUpdateScNotify);
|
} as SceneEntityUpdateScNotify);
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ export class Scene {
|
|||||||
public despawnEntity(entityId: number, silent: boolean = false) {
|
public despawnEntity(entityId: number, silent: boolean = false) {
|
||||||
this.entities.delete(entityId);
|
this.entities.delete(entityId);
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
this.player.session.send("SceneEntityDisappearScNotify", {
|
this.player.session.send(SceneEntityDisappearScNotify, {
|
||||||
entityIdList: [entityId]
|
entityIdList: [entityId]
|
||||||
} as SceneEntityDisappearScNotify);
|
} as SceneEntityDisappearScNotify);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import ProtoFactory from "./util/ProtoFactory"
|
|||||||
|
|
||||||
const c = new Logger("CrepeSR");
|
const c = new Logger("CrepeSR");
|
||||||
c.log(`Starting CrepeSR...`);
|
c.log(`Starting CrepeSR...`);
|
||||||
|
|
||||||
Banners.init();
|
Banners.init();
|
||||||
ProtoFactory.init();
|
ProtoFactory.init();
|
||||||
Interface.start();
|
Interface.start();
|
||||||
|
@ -68,6 +68,20 @@ export default class Packet {
|
|||||||
process.exit(1);
|
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;
|
export type PacketName = keyof typeof CmdID;
|
||||||
|
@ -80,32 +80,33 @@ export default class Session {
|
|||||||
|
|
||||||
public async sync() {
|
public async sync() {
|
||||||
const avatars = await Avatar.fromUID(this.player.db._id);
|
const avatars = await Avatar.fromUID(this.player.db._id);
|
||||||
this.sendT(PlayerSyncScNotify, PlayerSyncScNotify.fromPartial({
|
this.send(PlayerSyncScNotify, PlayerSyncScNotify.fromPartial({
|
||||||
avatarSync: {
|
avatarSync: {
|
||||||
avatarList: avatars.map(x => x.data),
|
avatarList: avatars.map(x => x.data),
|
||||||
},
|
},
|
||||||
basicInfo: this.player.db.basicInfo
|
basicInfo: this.player.db.basicInfo
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.player.save();
|
//this.player.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendT<Class extends MessageType<any>, >(type: Class, data: UnWrapMessageType<Class>) {
|
public async send<Class extends MessageType<any>, >(type: Class, data: UnWrapMessageType<Class>) {
|
||||||
const encodedBuffer = type.encode(data).finish();
|
|
||||||
const typeName = ProtoFactory.getName(type);
|
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.verbL(data);
|
||||||
this.c.verbH(encodedBuffer);
|
this.c.verbH(encodedBuffer);
|
||||||
|
if(!encodedBuffer) console.log("sad!")
|
||||||
if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName);
|
if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName);
|
||||||
|
|
||||||
//todo: might want to regen the ts-proto types with env = node
|
//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) {
|
public kick(hard: boolean = true) {
|
||||||
SRServer.getInstance().sessions.delete(this.id);
|
SRServer.getInstance().sessions.delete(this.id);
|
||||||
this.kicked = true;
|
this.kicked = true;
|
||||||
if (hard) this.sendT(PlayerKickOutScNotify, {
|
if (hard) this.send(PlayerKickOutScNotify, {
|
||||||
kickType: PlayerKickOutScNotify_KickType.KICK_BLACK,
|
kickType: PlayerKickOutScNotify_KickType.KICK_BLACK,
|
||||||
blackInfo: {
|
blackInfo: {
|
||||||
limitLevel: BlackLimitLevel.BLACK_LIMIT_LEVEL_ALL,
|
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) {
|
public sendRaw(data: Buffer) {
|
||||||
if (this.kicked) return;
|
if (this.kicked) return;
|
||||||
this.kcpobj.send(data);
|
this.kcpobj.send(data);
|
||||||
|
@ -5,7 +5,7 @@ import Session from "../kcp/Session";
|
|||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as ChangeLineupLeaderCsReq;
|
const body = packet.body as ChangeLineupLeaderCsReq;
|
||||||
|
|
||||||
session.send("ChangeLineupLeaderScRsp", {
|
session.send(ChangeLineupLeaderScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
slot: body.slot
|
slot: body.slot
|
||||||
} as ChangeLineupLeaderScRsp);
|
} as ChangeLineupLeaderScRsp);
|
||||||
|
@ -22,7 +22,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
isNew: true //TODO: avatar checking
|
isNew: true //TODO: avatar checking
|
||||||
} as GachaItem);
|
} as GachaItem);
|
||||||
}
|
}
|
||||||
session.send("DoGachaScRsp", {
|
session.send(DoGachaScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
gachaId: body.gachaId!,
|
gachaId: body.gachaId!,
|
||||||
gachaNum: body.gachaNum!,
|
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.db.posData.planeID = mazeEntry.PlaneID;
|
||||||
session.player.save();
|
session.player.save();
|
||||||
|
|
||||||
session.send("EnterMazeScRsp", {
|
session.send(EnterMazeScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
maze: {
|
maze: {
|
||||||
floor: {
|
floor: {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import { EnterSectionScRsp } from "../../data/proto/StarRail";
|
||||||
import Packet from "../kcp/Packet";
|
import Packet from "../kcp/Packet";
|
||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
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 Packet from "../kcp/Packet";
|
||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
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) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as FinishTalkMissionCsReq;
|
const body = packet.body as FinishTalkMissionCsReq;
|
||||||
|
|
||||||
session.send("FinishTalkMissionScRsp", {
|
session.send(FinishTalkMissionScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
talkStr: body.talkStr
|
talkStr: body.talkStr
|
||||||
} as FinishTalkMissionScRsp);
|
} as FinishTalkMissionScRsp);
|
||||||
|
@ -14,5 +14,5 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
reward: { itemList: [] }
|
reward: { itemList: [] }
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send("FinishTutorialGuideScRsp", dataObj);
|
session.send(FinishTutorialGuideScRsp, dataObj);
|
||||||
}
|
}
|
@ -18,5 +18,5 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
lineupList
|
lineupList
|
||||||
} as GetAllLineupDataScRsp;
|
} 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 AvatarExcelTable from "../../data/excel/AvatarExcelTable.json";
|
||||||
import Packet from "../kcp/Packet";
|
import Packet from "../kcp/Packet";
|
||||||
import Session from "../kcp/Session";
|
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) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as GetAvatarDataCsReq;
|
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 = {
|
const dataObj = {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
avatarList: avatar.map(av => av.data),
|
avatarList: avatar.map(av => Avatar.fromPartial(av.data)),
|
||||||
isAll: body.isGetAll
|
isAll: body.isGetAll
|
||||||
} as GetAvatarDataScRsp;
|
};
|
||||||
|
|
||||||
Object.values(AvatarExcelTable).forEach(avatar => {
|
Object.values(AvatarExcelTable).forEach(avatar => {
|
||||||
// dataObj.avatarList.push()
|
// 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";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetBagScRsp", {
|
session.send(GetBagScRsp, {
|
||||||
equipmentList: [],
|
equipmentList: [],
|
||||||
materialList: [],
|
materialList: [],
|
||||||
relicList: [],
|
relicList: [],
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetBasicInfoScRsp", {
|
session.send(GetBasicInfoScRsp, {
|
||||||
curDay: 1,
|
curDay: 1,
|
||||||
exchangeTimes: 0,
|
exchangeTimes: 0,
|
||||||
retcode: 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) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const lineup = await session.player.getLineup();
|
const lineup = await session.player.getLineup();
|
||||||
|
|
||||||
session.send("GetCurBattleInfoScRsp", {
|
session.send(GetCurBattleInfoScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
avatarList: lineup.avatarList.map(list => {
|
avatarList: lineup.avatarList.map(list => {
|
||||||
return {
|
return {
|
||||||
|
@ -30,7 +30,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
session.player.save();
|
session.player.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send("GetCurLineupDataScRsp", {
|
session.send(GetCurLineupDataScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
lineup: {
|
lineup: {
|
||||||
...lineup,
|
...lineup,
|
||||||
|
@ -8,7 +8,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
const _lineup = session.player.db.lineup;
|
const _lineup = session.player.db.lineup;
|
||||||
const lineup = _lineup.lineups[_lineup.curIndex];
|
const lineup = _lineup.lineups[_lineup.curIndex];
|
||||||
const curAvatarEntity = new ActorEntity(session.player.scene, lineup.avatarList[0], posData.pos);
|
const curAvatarEntity = new ActorEntity(session.player.scene, lineup.avatarList[0], posData.pos);
|
||||||
session.send("GetCurSceneInfoScRsp", {
|
session.send(GetCurSceneInfoScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
scene: {
|
scene: {
|
||||||
planeId: posData.planeID,
|
planeId: posData.planeID,
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetDialogueEventDataScRsp", {
|
session.send(GetDialogueEventDataScRsp, {
|
||||||
dialogueEventList: [],
|
dialogueEventList: [],
|
||||||
retcode: 0
|
retcode: 0
|
||||||
} as GetDialogueEventDataScRsp);
|
} as GetDialogueEventDataScRsp);
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetExpeditionDataScRsp", {
|
session.send(GetExpeditionDataScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
expedtionList: [],
|
expedtionList: [],
|
||||||
unlockedExpeditionIdList: [],
|
unlockedExpeditionIdList: [],
|
||||||
|
@ -19,5 +19,5 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
dataObj.npcMeetStatusList.push(meetStatusObj);
|
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';
|
import Banner from './../../util/Banner';
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetGachaInfoScRsp", {
|
session.send(GetGachaInfoScRsp, {
|
||||||
gachaRandom: 0,
|
gachaRandom: 0,
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
gachaInfoList: Banner.config.map(banner => {
|
gachaInfoList: Banner.config.map(banner => {
|
||||||
|
@ -5,7 +5,7 @@ import Session from "../kcp/Session";
|
|||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
let gender: Gender = (session.player.db.heroBasicType % 2 === 0) ? Gender.GenderWoman : Gender.GenderMan;
|
let gender: Gender = (session.player.db.heroBasicType % 2 === 0) ? Gender.GenderWoman : Gender.GenderMan;
|
||||||
|
|
||||||
session.send("GetHeroBasicTypeInfoScRsp", {
|
session.send(GetHeroBasicTypeInfoScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
gender: gender,
|
gender: gender,
|
||||||
basicTypeInfoList: [{
|
basicTypeInfoList: [{
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetHeroPathScRsp", {
|
session.send(GetHeroPathScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
heroPathList: []
|
heroPathList: []
|
||||||
} as GetHeroPathScRsp);
|
} as GetHeroPathScRsp);
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetLevelRewardTakenListScRsp", {
|
session.send(GetLevelRewardTakenListScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
takenLevelList: []
|
takenLevelList: []
|
||||||
} as GetLevelRewardTakenListScRsp);
|
} 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";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetLoginActivityScRsp", {
|
session.send(GetLoginActivityScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
loginActivityList: [{
|
loginActivityList: [{
|
||||||
id: 1001,
|
id: 1001,
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetMailScRsp", {
|
session.send(GetMailScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
mailList: [],
|
mailList: [],
|
||||||
noticeMailList: [],
|
noticeMailList: [],
|
||||||
|
@ -26,5 +26,5 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
|
|
||||||
dataObj.unlockTeleportList = MazePlaneExcel.getAllEntries().map(x => x.ID);
|
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";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetMazeTimeOfDayScRsp", {
|
session.send(GetMazeTimeOfDayScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
mazeTimeOfDayMap: {}
|
mazeTimeOfDayMap: {}
|
||||||
} as GetMazeTimeOfDayScRsp);
|
} as GetMazeTimeOfDayScRsp);
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetMissionDataScRsp", {
|
session.send(GetMissionDataScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
missionList: []
|
missionList: []
|
||||||
} as GetMissionDataScRsp);
|
} as GetMissionDataScRsp);
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetMissionEventDataScRsp", {
|
session.send(GetMissionEventDataScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
missionEventList: []
|
missionEventList: []
|
||||||
} as unknown as GetMissionEventDataScRsp);
|
} 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: [],
|
messageGroupList: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
session.send("GetNpcMessageGroupScRsp", dataObj);
|
session.send(GetNpcMessageGroupScRsp, dataObj);
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetNpcStatusScRsp", {
|
session.send(GetNpcStatusScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
messageStatusList: []
|
messageStatusList: []
|
||||||
} as GetNpcStatusScRsp);
|
} as GetNpcStatusScRsp);
|
||||||
|
@ -5,7 +5,7 @@ import Session from "../kcp/Session";
|
|||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as GetNpcTakenRewardCsReq;
|
const body = packet.body as GetNpcTakenRewardCsReq;
|
||||||
|
|
||||||
session.send("GetNpcTakenRewardScRsp", {
|
session.send(GetNpcTakenRewardScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
npcId: body.npcId,
|
npcId: body.npcId,
|
||||||
talkEventList: []
|
talkEventList: []
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetPrestigeInfoScRsp", {
|
session.send(GetPrestigeInfoScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
prestigeInfo: {
|
prestigeInfo: {
|
||||||
exp: 0,
|
exp: 0,
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetQuestDataScRsp", {
|
session.send(GetQuestDataScRsp, {
|
||||||
questList: [],
|
questList: [],
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
takenAchievementLevelList: [],
|
takenAchievementLevelList: [],
|
||||||
|
@ -3,7 +3,7 @@ import Packet from "../kcp/Packet";
|
|||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetRogueInfoScRsp", {
|
session.send(GetRogueInfoScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
rogueInfo: {
|
rogueInfo: {
|
||||||
status: RogueStatus.ROGUE_STATUS_NONE,
|
status: RogueStatus.ROGUE_STATUS_NONE,
|
||||||
|
@ -37,5 +37,5 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
dataObj.shopList.push(shopObj);
|
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";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
session.send("GetSpringRecoverDataScRsp", {
|
session.send(GetSpringRecoverDataScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
healPoolInfo: {
|
healPoolInfo: {
|
||||||
healPool: 0,
|
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 Avatar from "../../db/Avatar";
|
||||||
import Packet from "../kcp/Packet";
|
import Packet from "../kcp/Packet";
|
||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
@ -6,7 +6,7 @@ import Session from "../kcp/Session";
|
|||||||
// JoinLineupCsReq { baseAvatarId: 1002, slot: 1 }
|
// JoinLineupCsReq { baseAvatarId: 1002, slot: 1 }
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as JoinLineupCsReq;
|
const body = packet.body as JoinLineupCsReq;
|
||||||
session.send("JoinLineupScRsp", { retcode: 0 });
|
session.send(JoinLineupScRsp, { retcode: 0 });
|
||||||
|
|
||||||
let lineup = await session.player.getLineup();
|
let lineup = await session.player.getLineup();
|
||||||
const slot = body.slot || 0;
|
const slot = body.slot || 0;
|
||||||
@ -29,7 +29,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
session.player.setLineup(lineup);
|
session.player.setLineup(lineup);
|
||||||
session.player.save();
|
session.player.save();
|
||||||
|
|
||||||
session.send("SyncLineupNotify", {
|
session.send(SyncLineupNotify, {
|
||||||
lineup: lineup,
|
lineup: lineup,
|
||||||
reasonList: [SyncLineupReason.SYNC_REASON_NONE]
|
reasonList: [SyncLineupReason.SYNC_REASON_NONE]
|
||||||
} as SyncLineupNotify);
|
} as SyncLineupNotify);
|
||||||
|
@ -21,7 +21,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
|
|
||||||
const dataObj = {
|
const dataObj = {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
secretKeySeed: 0
|
secretKeySeed: 0,
|
||||||
} as PlayerGetTokenScRsp;
|
} as PlayerGetTokenScRsp;
|
||||||
|
|
||||||
const account = await Account.fromToken(body.token || "");
|
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;
|
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();
|
plr.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send("PlayerLoginScRsp", {
|
session.send(PlayerLoginScRsp, {
|
||||||
basicInfo: plr!.db.basicInfo as PlayerBasicInfo,
|
basicInfo: plr!.db.basicInfo as PlayerBasicInfo,
|
||||||
isNewPlayer: false,
|
isNewPlayer: false,
|
||||||
stamina: 100,
|
stamina: 100,
|
||||||
|
@ -34,7 +34,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send("SceneEntityMoveScRsp", {
|
session.send(SceneEntityMoveScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
downloadData: undefined,
|
downloadData: undefined,
|
||||||
} as SceneEntityMoveScRsp);
|
} 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 Packet from "../kcp/Packet";
|
||||||
import Session from "../kcp/Session";
|
import Session from "../kcp/Session";
|
||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as SetClientPausedCsReq;
|
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.c.error("Failed to set lineup name", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.send("SetLineupNameScRsp", {
|
session.send(SetLineupNameScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
index: session.player.db.lineup.curIndex,
|
index: session.player.db.lineup.curIndex,
|
||||||
name: body.name
|
name: body.name
|
||||||
|
@ -8,7 +8,7 @@ export default async function handle(session: Session, packet: Packet) {
|
|||||||
|
|
||||||
// TODO: This packet is just a base
|
// TODO: This packet is just a base
|
||||||
|
|
||||||
session.send("StartChallengeScRsp", {
|
session.send(StartChallengeScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
curChallenge: {
|
curChallenge: {
|
||||||
challengeId: body.challengeId,
|
challengeId: body.challengeId,
|
||||||
|
@ -4,7 +4,7 @@ import Session from "../kcp/Session";
|
|||||||
|
|
||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as SwapLineupCsReq;
|
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();
|
let lineup = await session.player.getLineup();
|
||||||
const _copy = lineup.avatarList[body.dstSlot];
|
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.setLineup(lineup);
|
||||||
session.player.save();
|
session.player.save();
|
||||||
|
|
||||||
session.send("SyncLineupNotify", {
|
session.send(SyncLineupNotify, {
|
||||||
lineup: lineup,
|
lineup: lineup,
|
||||||
reasonList: [SyncLineupReason.SYNC_REASON_NONE]
|
reasonList: [SyncLineupReason.SYNC_REASON_NONE]
|
||||||
} as SyncLineupNotify);
|
} as SyncLineupNotify);
|
||||||
|
@ -5,7 +5,7 @@ import Session from "../kcp/Session";
|
|||||||
export default async function handle(session: Session, packet: Packet) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as SyncTimeCsReq;
|
const body = packet.body as SyncTimeCsReq;
|
||||||
|
|
||||||
session.send("SyncTimeScRsp", {
|
session.send(SyncTimeScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
clientTimeMs: body.clientTimeMs,
|
clientTimeMs: body.clientTimeMs,
|
||||||
serverTimeMs: Math.round(new Date().getTime() / 1000)
|
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) {
|
export default async function handle(session: Session, packet: Packet) {
|
||||||
const body = packet.body as UnlockTutorialGuideCsReq;
|
const body = packet.body as UnlockTutorialGuideCsReq;
|
||||||
|
|
||||||
session.send("UnlockTutorialGuideScRsp", {
|
session.send(UnlockTutorialGuideScRsp, {
|
||||||
retcode: 0,
|
retcode: 0,
|
||||||
tutorialGuide: {
|
tutorialGuide: {
|
||||||
id: body.groupId,
|
id: body.groupId,
|
||||||
|
Loading…
Reference in New Issue
Block a user