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

Function SetNewChatChannel

netcon/mtclient/chat_api.cpp:419–447  ·  view source on GitHub ↗

Call this to set/join a channel. Since we can't be sure that we will be able to join that channel, check it for completion You can't be in more than one channel at a time with this API, so you leave the current channel before trying to join a new one. Because of this if the join fails, make sure you try to join another channel, or the user wont be able to chat -1 Failed to join 0 joining 1 success

Source from the content-addressed store, hash-verified

417// 0 joining
418// 1 successfully joined
419int SetNewChatChannel(const char *channel) {
420 char partstr[100];
421 if (!Socket_connected)
422 return -1;
423 if (Joining_channel == 1) {
424 if (Joined_channel == 1) {
425 // We made it in!
426 Joining_channel = 0;
427 return 1;
428 } else if (Joined_channel == -1) {
429 // Error -- we got a message that the channel was invite only, or we were banned or something
430 Joining_channel = 0;
431 strcpy(szChat_channel, "");
432 return -1;
433 }
434 } else {
435 if (szChat_channel[0]) {
436 snprintf(partstr, sizeof(partstr), "/PART %s", szChat_channel);
437 SendChatString(partstr, 1);
438 }
439 strcpy(szChat_channel, channel);
440 snprintf(partstr, sizeof(partstr), "/JOIN %s", szChat_channel);
441 SendChatString(partstr, 1);
442 Joining_channel = 1;
443 Joined_channel = 0;
444 }
445
446 return 0;
447}
448
449const char *ChatGetString() {
450 char ch[2];

Callers 1

JoinNewLobbyFunction · 0.85

Calls 1

SendChatStringFunction · 0.85

Tested by

no test coverage detected