From f1b8a3740be39c6ef0a50a98e5976404db694240 Mon Sep 17 00:00:00 2001 From: f0Re3t Date: Tue, 3 Sep 2024 11:14:29 +0300 Subject: [PATCH 1/3] A more improved check for the selected item in the "list" type dialog --- Server/Components/Dialogs/dialog.cpp | 40 +++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Server/Components/Dialogs/dialog.cpp b/Server/Components/Dialogs/dialog.cpp index da3fc9b10..4637c4e51 100644 --- a/Server/Components/Dialogs/dialog.cpp +++ b/Server/Components/Dialogs/dialog.cpp @@ -155,7 +155,7 @@ class DialogsComponent final : public IDialogsComponent, public PlayerConnectEve return false; } - if (sendDialogResponse.Response < 0 || sendDialogResponse.Response > 1) + if (sendDialogResponse.Response < DialogResponse_Right || sendDialogResponse.Response > DialogResponse_Left) { return false; } @@ -167,22 +167,42 @@ class DialogsComponent final : public IDialogsComponent, public PlayerConnectEve if ((data->style_ == DialogStyle_LIST || data->style_ == DialogStyle_TABLIST || data->style_ == DialogStyle_TABLIST_HEADERS) && data->body_.length() > 0) { - unsigned int lines = 0; + int count = -1; + std::string temp; - for (unsigned int i = 0; i < data->body_.length() - 1; i++) + std::remove_copy(data->body_.begin(), data->body_.end(), std::back_inserter(temp), '\n'); + + if (!temp.empty()) { - if (data->body_[i] == '\n') + struct duplicateEndLine + { + bool operator()(char first, char second) const + { + return first == second && first == '\n'; + } + }; + + data->body_.erase(std::unique(data->body_.begin(), data->body_.end(), duplicateEndLine()), data->body_.end()); + + if (data->body_[0] == '\n') { - lines++; + data->body_.erase(0, 1); } - } - if (data->style_ == DialogStyle_TABLIST_HEADERS && lines > 0) - { - lines--; + if (data->body_[data->body_.length() - 1] == '\n') + { + data->body_.erase(std::prev(data->body_.end())); + } + + count = std::count(data->body_.begin(), data->body_.end(), '\n'); + + if (data->style_ == DialogStyle_TABLIST_HEADERS) + { + count--; + } } - if (sendDialogResponse.ListItem < 0 || sendDialogResponse.ListItem > lines) + if (listItem < 0 || listItem > count) { return false; } From 8297236bacf151a047b822ae8475a1a7d281099e Mon Sep 17 00:00:00 2001 From: f0Re3t Date: Tue, 3 Sep 2024 11:20:11 +0300 Subject: [PATCH 2/3] Fix sendDialogResponse.ListItem --- Server/Components/Dialogs/dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/Components/Dialogs/dialog.cpp b/Server/Components/Dialogs/dialog.cpp index 4637c4e51..20009aaee 100644 --- a/Server/Components/Dialogs/dialog.cpp +++ b/Server/Components/Dialogs/dialog.cpp @@ -202,7 +202,7 @@ class DialogsComponent final : public IDialogsComponent, public PlayerConnectEve } } - if (listItem < 0 || listItem > count) + if (sendDialogResponse.ListItem < 0 || sendDialogResponse.ListItem > count) { return false; } From 9472a7166f608998fbf125f967b5f832d1950b5d Mon Sep 17 00:00:00 2001 From: f0Re3t Date: Sun, 8 Sep 2024 13:40:18 +0300 Subject: [PATCH 3/3] fix setplayerskin for mobile clients --- Shared/NetCode/core.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Shared/NetCode/core.hpp b/Shared/NetCode/core.hpp index c571f967a..1849777d7 100644 --- a/Shared/NetCode/core.hpp +++ b/Shared/NetCode/core.hpp @@ -748,7 +748,9 @@ namespace RPC bs.writeUINT16(PlayerID); bs.writeUINT32(Skin); - bs.writeUINT32(CustomSkin); + + if (isDL) + bs.writeUINT32(CustomSkin); } };