wip clean up profile locks
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
import { RequestCode } from "../defs";
|
||||
import { AccountLockRequest } from "../request/accountLock";
|
||||
|
||||
accountLock.msgCode = 0x0069 as RequestCode;
|
||||
accountLock.msgLen = 0x0020;
|
||||
|
||||
export function accountLock(buf: Buffer): AccountLockRequest {
|
||||
return {
|
||||
type: "account_lock_req",
|
||||
aimeId: buf.readUInt32LE(0x0004),
|
||||
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
|
||||
field_0018: buf.readUInt16LE(0x0018),
|
||||
};
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { RequestCode } from "../defs";
|
||||
import { AccountUnlockRequest } from "../request/accountUnlock";
|
||||
|
||||
accountUnlock.msgCode = 0x006f as RequestCode;
|
||||
accountUnlock.msgLen = 0x0020;
|
||||
|
||||
export function accountUnlock(buf: Buffer): AccountUnlockRequest {
|
||||
return {
|
||||
type: "account_unlock_req",
|
||||
aimeId: buf.readUInt32LE(0x0004),
|
||||
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Transform } from "stream";
|
||||
|
||||
import { accountLock } from "./accountLock";
|
||||
import { accountUnlock } from "./accountUnlock";
|
||||
import { createProfile } from "./createProfile";
|
||||
import { createTeam } from "./createTeam";
|
||||
import { discoverProfile } from "./discoverProfile";
|
||||
@@ -14,10 +12,12 @@ import { loadRewardTable } from "./loadRewardTable";
|
||||
import { loadServerList } from "./loadServerList";
|
||||
import { loadStocker } from "./loadStocker";
|
||||
import { loadTeam } from "./loadTeam";
|
||||
import { lockProfile } from "./lockProfile";
|
||||
import { saveExpedition } from "./saveExpedition";
|
||||
import { saveProfile } from "./saveProfile";
|
||||
import { saveSettings } from "./saveSettings";
|
||||
import { saveTopic } from "./saveTopic";
|
||||
import { unlockProfile } from "./unlockProfile";
|
||||
import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank";
|
||||
import { updateStoryClearNum } from "./updateStoryClearNum";
|
||||
import { RequestCode } from "../defs";
|
||||
@@ -29,8 +29,7 @@ export type ReaderFn = ((buf: Buffer) => Request) & {
|
||||
};
|
||||
|
||||
const funcList: ReaderFn[] = [
|
||||
accountLock,
|
||||
accountUnlock,
|
||||
unlockProfile,
|
||||
createProfile,
|
||||
createTeam,
|
||||
discoverProfile,
|
||||
@@ -43,6 +42,7 @@ const funcList: ReaderFn[] = [
|
||||
loadServerList,
|
||||
loadStocker,
|
||||
loadTeam,
|
||||
lockProfile,
|
||||
saveExpedition,
|
||||
saveProfile,
|
||||
saveSettings,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { RequestCode } from "../defs";
|
||||
import { LockAccountRequest } from "../request/lockProfile";
|
||||
|
||||
lockProfile.msgCode = 0x0069 as RequestCode;
|
||||
lockProfile.msgLen = 0x0020;
|
||||
|
||||
export function lockProfile(buf: Buffer): LockAccountRequest {
|
||||
return {
|
||||
type: "lock_profile_req",
|
||||
aimeId: buf.readUInt32LE(0x0004),
|
||||
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
|
||||
field_0018: buf.readUInt16LE(0x0018),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { RequestCode } from "../defs";
|
||||
import { UnlockProfileRequest } from "../request/unlockProfile";
|
||||
|
||||
unlockProfile.msgCode = 0x006f as RequestCode;
|
||||
unlockProfile.msgLen = 0x0020;
|
||||
|
||||
export function unlockProfile(buf: Buffer): UnlockProfileRequest {
|
||||
return {
|
||||
type: "unlock_profile_req",
|
||||
aimeId: buf.readUInt32LE(0x0004),
|
||||
pcbId: buf.slice(0x0008, buf.indexOf("\0", 0x0008)).toString("ascii"),
|
||||
};
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { AccountLockResponse } from "../response/accountLock";
|
||||
|
||||
export function accountLock(res: AccountLockResponse) {
|
||||
const buf = Buffer.alloc(0x0020);
|
||||
|
||||
buf.writeInt16LE(0x006a, 0x0000);
|
||||
buf.writeInt8(res.field_0018, 0x0018);
|
||||
buf.writeInt16LE(res.field_001A, 0x001a);
|
||||
buf.writeInt32LE(res.field_001C.getTime() / 1000, 0x001c);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Transform } from "stream";
|
||||
|
||||
import { _team } from "./_team";
|
||||
import { accountLock } from "./accountLock";
|
||||
import { accountUnlock } from "./accountUnlock";
|
||||
import { lockProfile } from "./lockProfile";
|
||||
import { unlockProfile } from "./unlockProfile";
|
||||
import { discoverProfile } from "./discoverProfile";
|
||||
import { generic } from "./generic";
|
||||
import { load2on2 } from "./load2on2";
|
||||
@@ -22,12 +22,6 @@ import { Response } from "../response";
|
||||
|
||||
function encode(res: Response): Buffer {
|
||||
switch (res.type) {
|
||||
case "account_lock_res":
|
||||
return accountLock(res);
|
||||
|
||||
case "account_unlock_res":
|
||||
return accountUnlock(res);
|
||||
|
||||
case "create_team_res":
|
||||
return _team(res);
|
||||
|
||||
@@ -67,9 +61,15 @@ function encode(res: Response): Buffer {
|
||||
case "load_team_res":
|
||||
return _team(res);
|
||||
|
||||
case "lock_profile_res":
|
||||
return lockProfile(res);
|
||||
|
||||
case "save_expedition_res":
|
||||
return saveExpedition(res);
|
||||
|
||||
case "unlock_profile_res":
|
||||
return unlockProfile(res);
|
||||
|
||||
case "update_provisional_store_rank_res":
|
||||
return updateProvisionalStoreRank(res);
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { LockProfileResponse } from "../response/lockProfile";
|
||||
|
||||
const statusCodes = {
|
||||
locked: 0x0000,
|
||||
unlocked: 0x0001,
|
||||
obsolete: 0x0002,
|
||||
};
|
||||
|
||||
export function lockProfile(res: LockProfileResponse) {
|
||||
const buf = Buffer.alloc(0x0020);
|
||||
|
||||
buf.writeInt16LE(0x006a, 0x0000);
|
||||
buf.writeInt8(statusCodes[res.status], 0x0018);
|
||||
buf.writeInt16LE(res.field_001A, 0x001a);
|
||||
buf.writeInt32LE(res.lockExpiry.getTime() / 1000, 0x001c);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AccountUnlockResponse } from "../response/accountUnlock";
|
||||
import { UnlockProfileResponse } from "../response/unlockProfile";
|
||||
|
||||
export function accountUnlock(res: AccountUnlockResponse) {
|
||||
export function unlockProfile(res: UnlockProfileResponse) {
|
||||
const buf = Buffer.alloc(0x0010);
|
||||
|
||||
buf.writeInt16LE(0x0070, 0x0000);
|
||||
@@ -1,15 +0,0 @@
|
||||
import { AccountLockRequest } from "../request/accountLock";
|
||||
import { AccountLockResponse } from "../response/accountLock";
|
||||
import { World } from "../world";
|
||||
|
||||
export function accountLock(
|
||||
w: World,
|
||||
req: AccountLockRequest
|
||||
): AccountLockResponse {
|
||||
return {
|
||||
type: "account_lock_res",
|
||||
field_0018: 1,
|
||||
field_001A: -1,
|
||||
field_001C: new Date(Date.now() + 3600000),
|
||||
};
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { AccountUnlockRequest } from "../request/accountUnlock";
|
||||
import { AccountUnlockResponse } from "../response/accountUnlock";
|
||||
import { World } from "../world";
|
||||
|
||||
export function accountUnlock(
|
||||
w: World,
|
||||
req: AccountUnlockRequest
|
||||
): AccountUnlockResponse {
|
||||
return {
|
||||
type: "account_unlock_res",
|
||||
status: 1,
|
||||
};
|
||||
}
|
||||
+15
-15
@@ -1,34 +1,28 @@
|
||||
import { Request } from "../request";
|
||||
import { Response } from "../response";
|
||||
import { World } from "../world";
|
||||
import { accountLock } from "./accountLock";
|
||||
import { accountUnlock } from "./accountUnlock";
|
||||
import { createProfile } from "./createProfile";
|
||||
import { _team } from "./_team";
|
||||
import { createProfile } from "./createProfile";
|
||||
import { discoverProfile } from "./discoverProfile";
|
||||
import { load2on2 } from "./load2on2";
|
||||
import { loadConfig } from "./loadConfig";
|
||||
import { loadConfig2 } from "./loadConfig2";
|
||||
import { discoverProfile } from "./discoverProfile";
|
||||
import { loadGeneralReward } from "./loadGeneralReward";
|
||||
import { loadProfile } from "./loadProfile";
|
||||
import { loadReward as loadRewardTable } from "./loadRewardTable";
|
||||
import { loadServerList } from "./loadServerList";
|
||||
import { loadStocker } from "./loadStocker";
|
||||
import { lockProfile } from "./lockProfile";
|
||||
import { saveExpedition } from "./saveExpedition";
|
||||
import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank";
|
||||
import { saveProfile } from "./saveProfile";
|
||||
import { saveSettings } from "./saveSettings";
|
||||
import { updateStoryClearNum } from "./updateStoryClearNum";
|
||||
import { saveTopic } from "./saveTopic";
|
||||
import { unlockProfile } from "./unlockProfile";
|
||||
import { updateProvisionalStoreRank } from "./updateProvisionalStoreRank";
|
||||
import { updateStoryClearNum } from "./updateStoryClearNum";
|
||||
import { Request } from "../request";
|
||||
import { Response } from "../response";
|
||||
import { World } from "../world";
|
||||
|
||||
export function dispatch(w: World, req: Request): Response {
|
||||
switch (req.type) {
|
||||
case "account_lock_req":
|
||||
return accountLock(w, req);
|
||||
|
||||
case "account_unlock_req":
|
||||
return accountUnlock(w, req);
|
||||
|
||||
case "create_profile_req":
|
||||
return createProfile(w, req);
|
||||
|
||||
@@ -65,6 +59,9 @@ export function dispatch(w: World, req: Request): Response {
|
||||
case "load_team_req":
|
||||
return _team(w, req);
|
||||
|
||||
case "lock_profile_req":
|
||||
return lockProfile(w, req);
|
||||
|
||||
case "save_expedition_req":
|
||||
return saveExpedition(w, req);
|
||||
|
||||
@@ -83,6 +80,9 @@ export function dispatch(w: World, req: Request): Response {
|
||||
case "save_topic_req":
|
||||
return saveTopic(w, req);
|
||||
|
||||
case "unlock_profile_req":
|
||||
return unlockProfile(w, req);
|
||||
|
||||
default:
|
||||
const exhaustCheck: never = req;
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { LockAccountRequest } from "../request/lockProfile";
|
||||
import { LockProfileResponse } from "../response/lockProfile";
|
||||
import { World } from "../world";
|
||||
|
||||
export function lockProfile(
|
||||
w: World,
|
||||
req: LockAccountRequest
|
||||
): LockProfileResponse {
|
||||
return {
|
||||
type: "lock_profile_res",
|
||||
status: "unlocked",
|
||||
field_001A: -1,
|
||||
lockExpiry: new Date(Date.now() + 3600000),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { UnlockProfileRequest } from "../request/unlockProfile";
|
||||
import { UnlockProfileResponse } from "../response/unlockProfile";
|
||||
import { World } from "../world";
|
||||
|
||||
export function unlockProfile(
|
||||
w: World,
|
||||
req: UnlockProfileRequest
|
||||
): UnlockProfileResponse {
|
||||
return {
|
||||
type: "unlock_profile_res",
|
||||
status: 1,
|
||||
};
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface AccountLockRequest {
|
||||
type: "account_lock_req";
|
||||
aimeId: number;
|
||||
pcbId: string;
|
||||
field_0018: number;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export interface AccountUnlockRequest {
|
||||
type: "account_unlock_req";
|
||||
aimeId: number;
|
||||
pcbId: string;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { AccountLockRequest } from "./accountLock";
|
||||
import { AccountUnlockRequest } from "./accountUnlock";
|
||||
import { UnlockProfileRequest } from "./unlockProfile";
|
||||
import { CreateProfileRequest } from "./createProfile";
|
||||
import { CreateTeamRequest } from "./createTeam";
|
||||
import { Load2on2Request } from "./load2on2";
|
||||
@@ -12,6 +11,7 @@ import { LoadRewardTableRequest } from "./loadRewardTable";
|
||||
import { LoadServerListRequest } from "./loadServerList";
|
||||
import { LoadStockerRequest } from "./loadStocker";
|
||||
import { LoadTeamRequest } from "./loadTeam";
|
||||
import { LockAccountRequest } from "./lockProfile";
|
||||
import { SaveExpeditionRequest } from "./saveExpedition";
|
||||
import { UpdateProvisionalStoreRankRequest } from "./updateProvisionalStoreRank";
|
||||
import { UpdateStoryClearNumRequest } from "./updateStoryClearNum";
|
||||
@@ -20,8 +20,6 @@ import { SaveSettingsRequest } from "./saveSettings";
|
||||
import { SaveTopicRequest } from "./saveTopic";
|
||||
|
||||
export type Request =
|
||||
| AccountLockRequest
|
||||
| AccountUnlockRequest
|
||||
| CreateProfileRequest
|
||||
| CreateTeamRequest
|
||||
| DiscoverProfileRequest
|
||||
@@ -34,9 +32,11 @@ export type Request =
|
||||
| LoadServerListRequest
|
||||
| LoadStockerRequest
|
||||
| LoadTeamRequest
|
||||
| LockAccountRequest
|
||||
| SaveExpeditionRequest
|
||||
| SaveProfileRequest
|
||||
| SaveSettingsRequest
|
||||
| SaveTopicRequest
|
||||
| UnlockProfileRequest
|
||||
| UpdateProvisionalStoreRankRequest
|
||||
| UpdateStoryClearNumRequest;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface LockAccountRequest {
|
||||
type: "lock_profile_req";
|
||||
aimeId: number;
|
||||
pcbId: string;
|
||||
field_0018: number;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface UnlockProfileRequest {
|
||||
type: "unlock_profile_req";
|
||||
aimeId: number;
|
||||
pcbId: string;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface AccountLockResponse {
|
||||
type: "account_lock_res";
|
||||
field_0018: number;
|
||||
field_001A: number;
|
||||
field_001C: Date;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface AccountUnlockResponse {
|
||||
type: "account_unlock_res";
|
||||
status: number;
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { AccountLockResponse } from "./accountLock";
|
||||
import { AccountUnlockResponse } from "./accountUnlock";
|
||||
import { CreateTeamResponse } from "./createTeam";
|
||||
import { DiscoverProfileResponse } from "./discoverProfile";
|
||||
import { GenericResponse } from "./generic";
|
||||
@@ -13,14 +11,15 @@ import { LoadRewardTableResponse } from "./loadRewardTable";
|
||||
import { LoadServerListResponse } from "./loadServerList";
|
||||
import { LoadStockerResponse } from "./loadStocker";
|
||||
import { LoadTeamResponse } from "./loadTeam";
|
||||
import { LockProfileResponse } from "./lockProfile";
|
||||
import { UpdateProvisionalStoreRankResponse } from "./updateProvisionalStoreRank";
|
||||
import { UpdateStoryClearNumResponse } from "./updateStoryClearNum";
|
||||
import { UnlockProfileResponse } from "./unlockProfile";
|
||||
import { SaveExpeditionResponse } from "./saveExpedition";
|
||||
import { SaveTopicResponse } from "./saveTopic";
|
||||
|
||||
export type Response =
|
||||
| AccountLockResponse
|
||||
| AccountUnlockResponse
|
||||
| UnlockProfileResponse
|
||||
| CreateTeamResponse
|
||||
| DiscoverProfileResponse
|
||||
| GenericResponse
|
||||
@@ -34,6 +33,7 @@ export type Response =
|
||||
| LoadServerListResponse
|
||||
| LoadStockerResponse
|
||||
| LoadTeamResponse
|
||||
| LockProfileResponse
|
||||
| UpdateProvisionalStoreRankResponse
|
||||
| UpdateStoryClearNumResponse
|
||||
| SaveExpeditionResponse
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export type LockAccountStatus = "locked" | "unlocked" | "obsolete";
|
||||
|
||||
export interface LockProfileResponse {
|
||||
type: "lock_profile_res";
|
||||
status: LockAccountStatus;
|
||||
field_001A: number;
|
||||
lockExpiry: Date;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface UnlockProfileResponse {
|
||||
type: "unlock_profile_res";
|
||||
status: number;
|
||||
}
|
||||
Reference in New Issue
Block a user