mirror of
https://github.com/djhackersdev/minime.git
synced 2026-04-24 23:47:21 -05:00
idz: Deal with multiple load2on2 formats
This commit is contained in:
parent
dfdd775370
commit
2392aaa205
|
|
@ -5,7 +5,7 @@ import { createProfile } from "./createProfile";
|
|||
import { createTeam } from "./createTeam";
|
||||
import { joinAutoTeam } from "./joinAutoTeam";
|
||||
import { discoverProfile } from "./discoverProfile";
|
||||
import { load2on2 } from "./load2on2";
|
||||
import { load2on2_v1, load2on2_v2 } from "./load2on2";
|
||||
import { loadConfig } from "./loadConfig";
|
||||
import { loadConfig2 } from "./loadConfig2";
|
||||
import { loadEventInfo } from "./loadEventInfo";
|
||||
|
|
@ -52,7 +52,8 @@ const funcList: ReaderFn[] = [
|
|||
createTeam,
|
||||
joinAutoTeam,
|
||||
discoverProfile,
|
||||
load2on2,
|
||||
load2on2_v1,
|
||||
load2on2_v2,
|
||||
loadConfig,
|
||||
loadConfig2,
|
||||
loadEventInfo,
|
||||
|
|
|
|||
|
|
@ -2,14 +2,28 @@ import { RequestCode } from "./_defs";
|
|||
import { ExtId } from "../model/base";
|
||||
import { Profile } from "../model/profile";
|
||||
import { Team } from "../model/team";
|
||||
import { Load2on2Request } from "../request/load2on2";
|
||||
import { Load2on2Request1, Load2on2Request2 } from "../request/load2on2";
|
||||
|
||||
load2on2.msgCode = 0x00b0 as RequestCode;
|
||||
load2on2.msgLen = 0x0010;
|
||||
load2on2_v1.msgCode = 0x00b0 as RequestCode;
|
||||
load2on2_v1.msgLen = 0x0010;
|
||||
|
||||
export function load2on2(buf: Buffer): Load2on2Request {
|
||||
export function load2on2_v1(buf: Buffer): Load2on2Request1 {
|
||||
return {
|
||||
type: "load_2on2_req",
|
||||
format: 1,
|
||||
field_0002: buf.readUInt16LE(0x0002),
|
||||
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
|
||||
teamId: buf.readUInt32LE(0x0008) as ExtId<Team>,
|
||||
};
|
||||
}
|
||||
|
||||
load2on2_v2.msgCode = 0x0132 as RequestCode;
|
||||
load2on2_v2.msgLen = 0x0010;
|
||||
|
||||
export function load2on2_v2(buf: Buffer): Load2on2Request2 {
|
||||
return {
|
||||
type: "load_2on2_req",
|
||||
format: 2,
|
||||
field_0002: buf.readUInt16LE(0x0002),
|
||||
profileId: buf.readUInt32LE(0x0004) as ExtId<Profile>,
|
||||
teamId: buf.readUInt32LE(0x0008) as ExtId<Team>,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,37 @@
|
|||
import { Load2on2Response } from "../response/load2on2";
|
||||
import {
|
||||
Load2on2Response,
|
||||
Load2on2Response1,
|
||||
Load2on2Response2,
|
||||
} from "../response/load2on2";
|
||||
|
||||
export function load2on2(res: Load2on2Response) {
|
||||
export function load2on2(res: Load2on2Response): Buffer {
|
||||
switch (res.format) {
|
||||
case 1:
|
||||
return load2on2_v1(res);
|
||||
|
||||
case 2:
|
||||
return load2on2_v2(res);
|
||||
|
||||
default:
|
||||
const exhaust: never = res;
|
||||
|
||||
throw new Error(`Unsupported 2on2 response format ${res["format"]}`);
|
||||
}
|
||||
}
|
||||
|
||||
function load2on2_v1(res: Load2on2Response1): Buffer {
|
||||
const buf = Buffer.alloc(0x04c0);
|
||||
|
||||
buf.writeInt16LE(0x00b1, 0x0000);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
// Same size but presumably incompatible somehow
|
||||
function load2on2_v2(res: Load2on2Response2): Buffer {
|
||||
const buf = Buffer.alloc(0x04c0);
|
||||
|
||||
buf.writeInt16LE(0x0133, 0x0000);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@ export function load2on2(
|
|||
): Load2on2Response {
|
||||
return {
|
||||
type: "load_2on2_res",
|
||||
format: req.format as any,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,19 @@ import { ExtId } from "../model/base";
|
|||
import { Profile } from "../model/profile";
|
||||
import { Team } from "../model/team";
|
||||
|
||||
export interface Load2on2Request {
|
||||
interface Load2on2RequestBase {
|
||||
type: "load_2on2_req";
|
||||
field_0002: number;
|
||||
profileId: ExtId<Profile>;
|
||||
teamId: ExtId<Team>;
|
||||
}
|
||||
|
||||
export interface Load2on2Request1 extends Load2on2RequestBase {
|
||||
format: 1;
|
||||
}
|
||||
|
||||
export interface Load2on2Request2 extends Load2on2RequestBase {
|
||||
format: 2;
|
||||
}
|
||||
|
||||
export type Load2on2Request = Load2on2Request1 | Load2on2Request2;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,14 @@
|
|||
export interface Load2on2Response {
|
||||
interface Load2on2ResponseBase {
|
||||
type: "load_2on2_res";
|
||||
// TODO?
|
||||
}
|
||||
|
||||
export interface Load2on2Response1 extends Load2on2ResponseBase {
|
||||
format: 1;
|
||||
}
|
||||
|
||||
export interface Load2on2Response2 extends Load2on2ResponseBase {
|
||||
format: 2;
|
||||
}
|
||||
|
||||
export type Load2on2Response = Load2on2Response1 | Load2on2Response2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user