| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include <cstdint> |
| 20 | |
| 21 | // Commands |
| 22 | #define CC_USER_JOINING 1 // A user had joined this channel (add him/her from the user listbox if any) |
| 23 | #define CC_USER_LEAVING 2 // A user has left the channel (remove him/her from the user listbox if any) |
| 24 | #define CC_DISCONNECTED 3 // We have been disconnected from the server (close the chat screen down) |
| 25 | #define CC_KICKED 4 // We were kicked out of the channel! (close the chat screen down?) |
| 26 | #define CC_NICKCHANGED 5 // Informing that your nickname has changed (data = "oldnick newnick") |
| 27 | #define CC_YOURCHANNEL 6 // data = name of the channel you are in. Only generated when you are joining #autoselect |
| 28 | |
| 29 | #define MAXLOCALSTRING 600 |
| 30 | #define MSG_REMOTE 0 |
| 31 | #define MSG_LOCAL 1 |
| 32 | |
| 33 | typedef struct Chat_user { |
| 34 | char nick_name[33]; |
| 35 | Chat_user *next; |
| 36 | } Chat_user; |
| 37 | |
| 38 | typedef struct Chat_channel { |
| 39 | char channel_name[33]; |
| 40 | uint16_t users; |
| 41 | char topic[100]; |
| 42 | Chat_channel *next; |
| 43 | } Chat_channel; |
| 44 | |
| 45 | typedef struct Chat_command { |
| 46 | int16_t command; |
| 47 | char data[100]; |
| 48 | Chat_command *next; |
| 49 | } Chat_command; |
| 50 | |
| 51 | // Prototypes |
| 52 | int ConnectToChatServer(const char *serveraddr, int16_t chat_port, char *nickname, char *trackerid); |
| 53 | void DisconnectFromChatServer(); |
| 54 | const char *GetChatText(); |
| 55 | const char *SendChatString(const char *line, int raw = 0); |
| 56 | Chat_command *GetChatCommand(); |
| 57 | char *GetChatUserList(); |
| 58 | int SetNewChatChannel(const char *channel); |
| 59 | char *GetChannelList(); |
| 60 | char *GetTrackerIdByUser(const char *nickname); |
| 61 | char *GetChannelByUser(const char *nickname); |
| 62 | |
| 63 | const char *ChatGetString(); |
| 64 | const char *GetWordNum(int num, const char *l_String); |
| 65 | char *ParseIRCMessage(char *Line, int iMode); |
| 66 | int AddChatUser(const char *nickname); |
| 67 | int RemoveChatUser(char *nickname); |
| 68 | void RemoveAllChatUsers(); |
| 69 | void AddChatCommandToQueue(int command, const void *data, int len); |
| 70 | Chat_command *GetChatCommandFromQueue(); |
| 71 | void FlushChatCommandQueue(); |
| 72 | void AddChannel(char *channel, uint16_t numusers, char *topic); |
| 73 | void FlushChannelList(); |