diff --git a/Server/Components/Dialogs/dialog.cpp b/Server/Components/Dialogs/dialog.cpp index da3fc9b10..3cb00e02b 100644 --- a/Server/Components/Dialogs/dialog.cpp +++ b/Server/Components/Dialogs/dialog.cpp @@ -168,21 +168,30 @@ 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; - - for (unsigned int i = 0; i < data->body_.length() - 1; i++) + + for (unsigned int i = 0; i < data->body_.length(); i++) { - if (data->body_[i] == '\n') + if (data->body_[i] != '\n' && i > 0 && data->body_[i - 1] == '\n') { lines++; } } - if (data->style_ == DialogStyle_TABLIST_HEADERS && lines > 0) + if (data->style_ == DialogStyle_TABLIST_HEADERS) + { + if (lines <= 1) + { + sendDialogResponse.ListItem = 0; + lines = 1; + } + } + else { - lines--; + if (lines == 0) sendDialogResponse.ListItem = 0; + lines++; } - if (sendDialogResponse.ListItem < 0 || sendDialogResponse.ListItem > lines) + if (sendDialogResponse.ListItem < 0 || sendDialogResponse.ListItem >= lines) { return false; }