Sun, 17 May 2015 22:07:48 +0300
Added support for SVRC_YOUREDISCONNECTED
--- a/sources/interface.cpp Sun May 17 17:22:20 2015 +0300 +++ b/sources/interface.cpp Sun May 17 22:07:48 2015 +0300 @@ -155,7 +155,6 @@ InputHistory << ""; OutputLines.clear(); OutputLines << ColoredLine(); - Title = format (APPNAME " %1 (%2)", full_version_string(), changeset_date_string()); for (int i = 0; i < NUM_COLORS; ++i) for (int j = 0; j < NUM_COLORS; ++j) @@ -174,13 +173,18 @@ // void Interface::render_titlebar() { - if (Title.length() <= COLS) + String message = Title; + + if (Title.is_empty()) + message = format (APPNAME " %1 (%2)", full_version_string(), changeset_date_string()); + + if (message.length() <= COLS) { int pair = color_pair (WHITE, BLUE); - int startx = (COLS - Title.length()) / 2; - int endx = startx + Title.length(); + int startx = (COLS - message.length()) / 2; + int endx = startx + message.length(); attron (pair); - mvprintw (0, startx, "%s", Title.chars()); + mvprintw (0, startx, "%s", message.chars()); mvhline (0, 0, ' ', startx); mvhline (0, endx, ' ', COLS - endx); attroff (pair); @@ -955,3 +959,12 @@ NeedInputRender = true; } } + +// ------------------------------------------------------------------------------------------------- +// +void Interface::disconnected() +{ + Title = ""; + update_statusbar(); + render_titlebar(); +}
--- a/sources/interface.h Sun May 17 17:22:20 2015 +0300 +++ b/sources/interface.h Sun May 17 22:07:48 2015 +0300 @@ -56,6 +56,7 @@ void need_refresh(); void tab_complete (const String& part, String complete); RCONSession* get_session() { return &Session; } + void disconnected(); template<typename... argtypes> void print (const String& fmtstr, const argtypes&... args) @@ -117,4 +118,4 @@ void yank (int a, int b); int find_previous_word(); int find_next_word(); -}; +}; \ No newline at end of file
--- a/sources/network/rconsession.cpp Sun May 17 17:22:20 2015 +0300 +++ b/sources/network/rconsession.cpp Sun May 17 22:07:48 2015 +0300 @@ -136,11 +136,13 @@ case SVRC_OLDPROTOCOL: m_interface->print_error ("Your RCON client is using outdated protocol.\n"); m_state = RCON_DISCONNECTED; + m_interface->disconnected(); break; case SVRC_BANNED: m_interface->print_error ("You have been banned from the server.\n"); m_state = RCON_DISCONNECTED; + m_interface->disconnected(); break; case SVRC_SALT: @@ -152,6 +154,7 @@ case SVRC_INVALIDPASSWORD: m_interface->print_error ("Login failed.\n"); m_state = RCON_DISCONNECTED; + m_interface->disconnected(); break; case SVRC_MESSAGE: @@ -241,6 +244,15 @@ m_interface->print ("New value of %1: %2\n", name, value); } break; + + case SVRC_YOUREDISCONNECTED: + { + String message = packet.read_string(); + m_interface->print_error ("Connection error: %1\n", message); + m_state = RCON_DISCONNECTED; + m_interface->disconnected(); + } + break; } } }
--- a/sources/network/rconsession.h Sun May 17 17:22:20 2015 +0300 +++ b/sources/network/rconsession.h Sun May 17 22:07:48 2015 +0300 @@ -57,6 +57,7 @@ SVRC_ALREADYWATCHINGCVAR, SVRC_WATCHCVARNOTFOUND, SVRC_CVARCHANGED, + SVRC_YOUREDISCONNECTED, }; // -------------------------------------------------------------------------------------------------