Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Server/Components/Dialogs/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down