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

Function GetChannelList

netcon/mtclient/chat_api.cpp:1074–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1072 Firstchannel = nullptr;
1073}
1074char *GetChannelList() {
1075 int ichan_list_length = 0;
1076 char sznumusers[10];
1077
1078 if (GettingChannelList != 2)
1079 return nullptr;
1080 if (!Socket_connected)
1081 return nullptr;
1082
1083 if (Chan_list) {
1084 DLLmem_free(Chan_list);
1085 Chan_list = nullptr;
1086 }
1087
1088 Currchannel = Firstchannel;
1089 while (Currchannel) {
1090 ichan_list_length += strlen(Currchannel->topic) + 1 + strlen(Currchannel->channel_name) + 1 +
1091 5; // 1 for the space, and 4 for the number of users 0000-9999 + space
1092 Currchannel = Currchannel->next;
1093 }
1094 Currchannel = Firstchannel;
1095 Chan_list = (char *)DLLmem_malloc(ichan_list_length + 1);
1096 Chan_list[0] = '\0';
1097 while (Currchannel) {
1098 strcat(Chan_list, "$");
1099 strcat(Chan_list, Currchannel->channel_name);
1100 strcat(Chan_list, " ");
1101 snprintf(sznumusers, sizeof(sznumusers), "%d ", Currchannel->users);
1102 strcat(Chan_list, sznumusers);
1103 strcat(Chan_list, Currchannel->topic); // fgets
1104 strcat(Chan_list, " ");
1105 Currchannel = Currchannel->next;
1106 }
1107 FlushChannelList();
1108 GettingChannelList = 0;
1109 return Chan_list;
1110}
1111
1112void AddChannel(char *channel, uint16_t numusers, char *topic) {
1113 Currchannel = Firstchannel;

Callers 1

MainMultiplayerMenuFunction · 0.85

Calls 1

FlushChannelListFunction · 0.85

Tested by

no test coverage detected