MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ChatGetString

Function ChatGetString

netcon/mtclient/chat_api.cpp:449–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449const char *ChatGetString() {
450 char ch[2];
451 char *p;
452 int bytesread = 1;
453 static char return_string[MAXCHATBUFFER];
454
455 while ((bytesread != 0) && (bytesread != SOCKET_ERROR)) {
456 bytesread = recv(Chatsock, ch, 1, 0);
457 if (bytesread == SOCKET_ERROR) {
458 uint32_t lerror = WSAGetLastError();
459#if !defined(POSIX)
460 if (WSAEWOULDBLOCK != lerror)
461#else
462 if (WSAEWOULDBLOCK != lerror && 0 != lerror)
463#endif
464 {
465 DLLmprintf(0, "recv caused an error: %d\n", lerror);
466 }
467 return nullptr;
468 }
469 if (bytesread) {
470 ch[1] = '\0';
471 // DLLmprintf(0,ch);
472 if ((ch[0] == 0x0a) || (ch[0] == 0x0d)) {
473 if (Input_chat_buffer[0] == '\0') {
474 // Blank line, ignore it
475 return nullptr;
476 }
477 strcpy(return_string, Input_chat_buffer);
478 Input_chat_buffer[0] = '\0';
479 // DLLmprintf(0,"->|%s\n",return_string);
480 p = ParseIRCMessage(return_string, MSG_REMOTE);
481
482 return p;
483 }
484 strcat(Input_chat_buffer, ch);
485 } else {
486 // Select said we had read data, but 0 bytes read means disconnected
487 DLLmprintf(0, "Disconnected! Doh!");
488 AddChatCommandToQueue(CC_DISCONNECTED, nullptr, 0);
489 return nullptr;
490 }
491 }
492 return nullptr;
493}
494
495const char *GetWordNum(int num, const char *l_String) {
496 static char strreturn[600];

Callers 1

GetChatTextFunction · 0.85

Calls 2

ParseIRCMessageFunction · 0.85
AddChatCommandToQueueFunction · 0.85

Tested by

no test coverage detected