aboutsummaryrefslogtreecommitdiff
path: root/src/client/chat.c
diff options
context:
space:
mode:
authorfschildt <florian.schildt@protonmail.com>2025-08-22 15:23:11 +0200
committerfschildt <florian.schildt@protonmail.com>2025-08-22 15:23:11 +0200
commit2050c0e0576f05156f192aa4caf48834d2f28b14 (patch)
treeee58bd35b0df0a1bacfbc9700ed99ce80c99294e /src/client/chat.c
first commitHEADmaster
Diffstat (limited to 'src/client/chat.c')
-rw-r--r--src/client/chat.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/client/chat.c b/src/client/chat.c
new file mode 100644
index 0000000..f32c0b2
--- /dev/null
+++ b/src/client/chat.c
@@ -0,0 +1,31 @@
+#include <client/chat.h>
+#include <basic/mem_arena.h>
+
+void
+chat_add_message(Chat *chat, String32 *sender_name, String32 *content, Time creation_time)
+{
+ // Todo: is the index correct? Think once more.
+ size_t index = (chat->start_index + chat->message_count) % ARRAY_COUNT(chat->messages);
+
+ ChatMessage *message = &chat->messages[index];
+ message->creation_time = creation_time;
+ string32_copy(message->sender_name, sender_name);
+ string32_copy(message->content, content);
+}
+
+void
+chat_reset(Chat *chat)
+{
+ chat->start_index = 0;
+ chat->message_count = 0;
+}
+
+Chat *
+chat_create_and_init(MemArena *arena, i32 message_count_max)
+{
+ Chat *chat = mem_arena_push(arena, Chat);
+ chat->start_index = 0;
+ chat->message_count = 0;
+ return chat;
+}
+