From f384704c3feaa1230ae903847ed293fe96153086 Mon Sep 17 00:00:00 2001 From: NiteKat Date: Sat, 31 May 2025 09:42:03 -0400 Subject: [PATCH] Chat Message Changes This will need to be changed again to fix longer chat messages, but as long as a message doesn't trigger wordwrap in the message log this works. --- Source/dapi/Server.cpp | 6 +++--- Source/qol/chatlog.cpp | 2 +- Source/qol/chatlog.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/dapi/Server.cpp b/Source/dapi/Server.cpp index 45855c886..32acc8df8 100644 --- a/Source/dapi/Server.cpp +++ b/Source/dapi/Server.cpp @@ -415,10 +415,10 @@ void Server::updateGameData() update->set_connectedto(1); - for (auto chatLogLine = data->lastLogSize; chatLogLine < devilution::ChatLogLines.size(); chatLogLine++) { + for (auto chatLogLine = devilution::ChatLogLines.size() - (devilution::MessageCounter - data->lastLogSize); chatLogLine < devilution::ChatLogLines.size(); chatLogLine++) { std::stringstream message; for (auto &textLine : devilution::ChatLogLines[chatLogLine].colors) { - if (devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorWhitegold & devilution::UiFlags::ColorBlue)) + if (devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorWhitegold) || devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorBlue)) message << textLine.text << ": "; if (devilution::HasAnyOf(textLine.color, devilution::UiFlags::ColorWhite)) message << textLine.text; @@ -428,7 +428,7 @@ void Server::updateGameData() *chatMessage = message.str(); } } - data->lastLogSize = devilution::ChatLogLines.size(); + data->lastLogSize = devilution::MessageCounter; update->set_player(devilution::MyPlayerId); diff --git a/Source/qol/chatlog.cpp b/Source/qol/chatlog.cpp index fc1065623..999f8ac16 100644 --- a/Source/qol/chatlog.cpp +++ b/Source/qol/chatlog.cpp @@ -28,12 +28,12 @@ namespace devilution { std::vector ChatLogLines; +unsigned int MessageCounter = 0; namespace { bool UnreadFlag = false; size_t SkipLines; -unsigned int MessageCounter = 0; constexpr int PaddingTop = 32; constexpr int PaddingLeft = 32; diff --git a/Source/qol/chatlog.h b/Source/qol/chatlog.h index c13b1cde2..e73990024 100644 --- a/Source/qol/chatlog.h +++ b/Source/qol/chatlog.h @@ -23,6 +23,7 @@ struct MultiColoredText { extern bool ChatLogFlag; extern std::vector ChatLogLines; +extern unsigned int MessageCounter; void ToggleChatLog(); void AddMessageToChatLog(std::string_view message, Player *player = nullptr, UiFlags flags = UiFlags::ColorWhite);