MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / Chat_AddOf

Function Chat_AddOf

src/Chat.c:208–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206void Chat_Add(const cc_string* text) { Chat_AddOf(text, MSG_TYPE_NORMAL); }
207
208void Chat_AddOf(const cc_string* text, int msgType) {
209 cc_string str;
210 if (msgType == MSG_TYPE_NORMAL) {
211 /* Check for chat overflow (see issue #837) */
212 /* This happens because Offset/Length are packed into a single 32 bit value, */
213 /* with 9 bits used for length. Hence if offset exceeds 2^23 (8388608), it */
214 /* overflows and earlier chat messages start wrongly appearing instead */
215 if (Chat_Log.totalLength > 8388000) {
216 ClearChatLogs();
217 Chat_AddRaw("&cChat log cleared as it hit 8.3 million character limit");
218 }
219
220 /* StringsBuffer_Add will abort game if try to add string > 511 characters */
221 str = *text;
222 str.length = min(str.length, DRAWER2D_MAX_TEXT_LENGTH);
223
224 Chat_GetLogTime(Chat_Log.count) = Game.Time;
225 AppendChatLog(&str);
226 StringsBuffer_Add(&Chat_Log, &str);
227 } else if (msgType >= MSG_TYPE_STATUS_1 && msgType <= MSG_TYPE_STATUS_3) {
228 /* Status[0] is for texture pack downloading message */
229 /* Status[1] is for reduced performance mode message */
230 String_Copy(&Chat_Status[2 + (msgType - MSG_TYPE_STATUS_1)], text);
231 } else if (msgType >= MSG_TYPE_BOTTOMRIGHT_1 && msgType <= MSG_TYPE_BOTTOMRIGHT_3) {
232 String_Copy(&Chat_BottomRight[msgType - MSG_TYPE_BOTTOMRIGHT_1], text);
233 } else if (msgType == MSG_TYPE_ANNOUNCEMENT) {
234 String_Copy(&Chat_Announcement, text);
235 Chat_AnnouncementLeft = 5.0f;
236 } else if (msgType == MSG_TYPE_BIGANNOUNCEMENT) {
237 String_Copy(&Chat_BigAnnouncement, text);
238 Chat_BigAnnouncementLeft = 5.0f;
239 } else if (msgType == MSG_TYPE_SMALLANNOUNCEMENT) {
240 String_Copy(&Chat_SmallAnnouncement, text);
241 Chat_SmallAnnouncementLeft = 5.0f;
242 } else if (msgType >= MSG_TYPE_CLIENTSTATUS_1 && msgType <= MSG_TYPE_CLIENTSTATUS_2) {
243 String_Copy(&Chat_ClientStatus[msgType - MSG_TYPE_CLIENTSTATUS_1], text);
244 } else if (msgType >= MSG_TYPE_EXTRASTATUS_1 && msgType <= MSG_TYPE_EXTRASTATUS_2) {
245 String_Copy(&Chat_Status[msgType - MSG_TYPE_EXTRASTATUS_1], text);
246 }
247
248 Event_RaiseChat(&ChatEvents.ChatReceived, text, msgType);
249}
250
251
252/*########################################################################################################################*

Callers 14

ChatInputWidget_TabKeyFunction · 0.85
Chat_Add4Function · 0.85
Chat_AddRawFunction · 0.85
Chat_AddFunction · 0.85
ClearCPEMessagesFunction · 0.85
HandleInactiveChangedFunction · 0.85
TickReducedPerformanceFunction · 0.85
EndReducedPerformanceFunction · 0.85
DrawOpCommand_BeginFunction · 0.85

Calls 6

ClearChatLogsFunction · 0.85
Chat_AddRawFunction · 0.85
AppendChatLogFunction · 0.85
StringsBuffer_AddFunction · 0.85
String_CopyFunction · 0.85
Event_RaiseChatFunction · 0.85

Tested by

no test coverage detected