Commit 775d5ee9 authored by Chunchi Che's avatar Chunchi Che Committed by WANG HE

fix chat display

parent 4c8cb83f
import { ygopro } from "../../idl/ocgcore"; import { ygopro } from "../../idl/ocgcore";
import { ygoProPacket, ygoProtobuf } from "../packet"; import { ygoProPacket, ygoProtobuf } from "../packet";
import { utf8ArrayToStr } from "../util";
export default class StocChatPB implements ygoProtobuf { export default class StocChatPB implements ygoProtobuf {
packet: ygoProPacket; packet: ygoProPacket;
...@@ -11,7 +10,9 @@ export default class StocChatPB implements ygoProtobuf { ...@@ -11,7 +10,9 @@ export default class StocChatPB implements ygoProtobuf {
adapt(): ygopro.YgoStocMsg { adapt(): ygopro.YgoStocMsg {
const player = new DataView(this.packet.exData.buffer).getInt16(0, true); const player = new DataView(this.packet.exData.buffer).getInt16(0, true);
const msg = utf8ArrayToStr(this.packet.exData.slice(2));
const decoder = new TextDecoder("utf-16");
const msg = decoder.decode(this.packet.exData.slice(2));
return new ygopro.YgoStocMsg({ return new ygopro.YgoStocMsg({
stoc_chat: new ygopro.StocChat({ stoc_chat: new ygopro.StocChat({
......
...@@ -20,6 +20,7 @@ export function strEncodeUTF16(str: string) { ...@@ -20,6 +20,7 @@ export function strEncodeUTF16(str: string) {
return new Uint8Array(buf); return new Uint8Array(buf);
} }
// currently not used, but remain.
export function utf8ArrayToStr(array: Uint8Array) { export function utf8ArrayToStr(array: Uint8Array) {
let out, i, len, c; let out, i, len, c;
let char2, char3; let char2, char3;
......
...@@ -3,8 +3,6 @@ import { store } from "../../store"; ...@@ -3,8 +3,6 @@ import { store } from "../../store";
import { setJoined } from "../../reducers/joinSlice"; import { setJoined } from "../../reducers/joinSlice";
export default function handleJoinGame(pb: ygopro.YgoStocMsg) { export default function handleJoinGame(pb: ygopro.YgoStocMsg) {
console.log("Game joined!");
const dispatch = store.dispatch; const dispatch = store.dispatch;
const msg = pb.stoc_join_game; const msg = pb.stoc_join_game;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment