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 { ygoProPacket, ygoProtobuf } from "../packet";
import { utf8ArrayToStr } from "../util";
export default class StocChatPB implements ygoProtobuf {
packet: ygoProPacket;
......@@ -11,7 +10,9 @@ export default class StocChatPB implements ygoProtobuf {
adapt(): ygopro.YgoStocMsg {
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({
stoc_chat: new ygopro.StocChat({
......
......@@ -20,6 +20,7 @@ export function strEncodeUTF16(str: string) {
return new Uint8Array(buf);
}
// currently not used, but remain.
export function utf8ArrayToStr(array: Uint8Array) {
let out, i, len, c;
let char2, char3;
......
......@@ -3,8 +3,6 @@ import { store } from "../../store";
import { setJoined } from "../../reducers/joinSlice";
export default function handleJoinGame(pb: ygopro.YgoStocMsg) {
console.log("Game joined!");
const dispatch = store.dispatch;
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