1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/* eslint indent: ["error", 2, { "SwitchCase": 1 }] */
import { client, extrafeatures, UPDATE_INTERVAL } from "../../client";
import { handleCharacterInfo } from "../../client/handleCharacterInfo";
import { resetICParams } from "../../client/resetICParams";
import { prepChat, safeTags } from "../../encoding";
import { handle_ic_speaking } from '../../viewport/utils/handleICSpeaking'
/**
* Handles an in-character chat message.
* @param {*} args packet arguments
*/
export const handleMS = (args: string[]) => {
// TODO: this if-statement might be a bug.
if (args[4] !== client.viewport.getChatmsg().content) {
document.getElementById("client_inner_chat")!.innerHTML = "";
const char_id = Number(args[9]);
const char_name = safeTags(args[3]);
let msg_nameplate = args[3];
let msg_blips = "male";
let char_chatbox = "default";
let char_muted = false;
if (char_id < client.char_list_length && char_id >= 0) {
if (client.chars[char_id].name !== char_name) {
console.info(
`${client.chars[char_id].name} is iniediting to ${char_name}`
);
const chargs = (`${char_name}&` + "iniediter").split("&");
handleCharacterInfo(chargs, char_id);
}
}
try {
msg_nameplate = client.chars[char_id].showname;
} catch (e) {
msg_nameplate = args[3];
}
try {
msg_blips = client.chars[char_id].blips;
} catch (e) { }
try {
char_chatbox = client.chars[char_id].chat;
} catch (e) {
char_chatbox = "default";
}
try {
char_muted = client.chars[char_id].muted;
} catch (e) {
char_muted = false;
console.error("we're still missing some character data");
}
if (char_muted === false) {
let chatmsg = {
deskmod: Number(safeTags(args[1]).toLowerCase()),
preanim: safeTags(args[2]).toLowerCase(), // get preanim
nameplate: msg_nameplate,
chatbox: char_chatbox,
name: char_name,
sprite: safeTags(args[4]).toLowerCase(),
content: prepChat(args[5]), // Escape HTML tags
side: args[6].toLowerCase(),
sound: safeTags(args[7]).toLowerCase(),
blips: safeTags(msg_blips),
type: Number(args[8]),
charid: char_id,
snddelay: Number(args[10]),
objection: Number(args[11]),
evidence: Number(safeTags(args[12])),
flip: Number(args[13]),
flash: Number(args[14]),
color: Number(args[15]),
speed: UPDATE_INTERVAL,
};
if (args.length > 16) {
const extra_cccc = {
showname: prepChat(args[16]),
other_charid: Number(args[17]),
other_name: safeTags(args[18]),
other_emote: safeTags(args[19]),
self_offset: args[20].split("<and>"), // HACK: here as well, client is fucked and uses this instead of &
other_offset: args[21].split("<and>"),
other_flip: Number(args[22]),
noninterrupting_preanim: Number(args[23]),
};
chatmsg = Object.assign(extra_cccc, chatmsg);
if (args.length > 24) {
const extra_27 = {
looping_sfx: Number(args[24]),
screenshake: Number(args[25]),
frame_screenshake: safeTags(args[26]),
frame_realization: safeTags(args[27]),
frame_sfx: safeTags(args[28]),
};
chatmsg = Object.assign(extra_27, chatmsg);
if (args.length > 29) {
const extra_28 = {
additive: Number(args[29]),
effects: args[30].split("|"),
};
chatmsg = Object.assign(extra_28, chatmsg);
} else {
const extra_28 = {
additive: 0,
effects: ["", "", ""],
};
chatmsg = Object.assign(extra_28, chatmsg);
}
} else {
const extra_27 = {
looping_sfx: 0,
screenshake: 0,
frame_screenshake: "",
frame_realization: "",
frame_sfx: "",
};
chatmsg = Object.assign(extra_27, chatmsg);
const extra_28 = {
additive: 0,
effects: ["", "", ""],
};
chatmsg = Object.assign(extra_28, chatmsg);
}
} else {
const extra_cccc = {
showname: "",
other_charid: 0,
other_name: "",
other_emote: "",
self_offset: [0, 0],
other_offset: [0, 0],
other_flip: 0,
noninterrupting_preanim: 0,
};
chatmsg = Object.assign(extra_cccc, chatmsg);
const extra_27 = {
looping_sfx: 0,
screenshake: 0,
frame_screenshake: "",
frame_realization: "",
frame_sfx: "",
};
chatmsg = Object.assign(extra_27, chatmsg);
const extra_28 = {
additive: 0,
effects: ["", "", ""],
};
chatmsg = Object.assign(extra_28, chatmsg);
}
if (chatmsg.content.trim() === "") {
//blankpost
chatmsg.content = "";
}
// our own message appeared, reset the buttons
if (chatmsg.charid === client.charID) {
resetICParams();
}
handle_ic_speaking(chatmsg); // no await
}
}
}
|