--- a/sources/interface.cpp Thu Jul 23 00:16:47 2015 +0300 +++ b/sources/interface.cpp Thu Jul 23 01:52:04 2015 +0300 @@ -28,12 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <curses.h> #include <string.h> #include <time.h> #include "interface.h" #include "network/rconsession.h" #include "network/ipaddress.h" #include "coloredline.h" +BEGIN_ZFC_NAMESPACE static const int g_pageSize = 10; @@ -127,7 +129,7 @@ { case INPUTSTATE_ADDRESS: if (CurrentAddress.host != 0) - mutable_current_input() = CurrentAddress.to_string (IP_WITH_PORT); + mutable_current_input() = CurrentAddress.to_string (IPAddress::WITH_PORT); break; default: @@ -141,7 +143,18 @@ // ------------------------------------------------------------------------------------------------- // Interface::Interface() : - Session (this) + Session (this), + InputCursor (0), + CursorPosition (0), + InputPanning (0), + NeedRefresh (false), + NeedStatusBarRender (false), + NeedInputRender (false), + NeedOutputRender (false), + NeedNicklistRender (false), + OutputScroll (0), + CurrentInputState (INPUTSTATE_NORMAL), + DisconnectConfirmFunction (NULL) { #ifdef XCURSES ::Xinitscr(argc, argv); @@ -219,7 +232,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::safe_disconnect (Function<void()> afterwards) +void Interface::safe_disconnect (std::function<void()> afterwards) { if (Session.is_active()) { @@ -252,8 +265,10 @@ { int x = x0; - for (int byte : line.data()) + for (int i = 0; i < line.length(); ++i) { + int byte = line.data()[i]; + if (x == x0 + width) { if (not allowWrap) @@ -443,8 +458,8 @@ // If we're inputting a password, replace it with asterisks if (CurrentInputState == INPUTSTATE_PASSWORD) { - for (char& ch : displayString) - ch = '*'; + for (int i = 0; i < displayString.length(); ++i) + displayString[i] = '*'; } // Ensure the cursor is within bounds @@ -506,7 +521,7 @@ case RCON_CONNECTING: case RCON_AUTHENTICATING: - text = "Connecting to " + Session.address().to_string (IP_WITH_PORT) + "..."; + text = "Connecting to " + Session.address().to_string (IPAddress::WITH_PORT) + "..."; break; case RCON_CONNECTED: @@ -523,8 +538,10 @@ Session.num_admins() != 1 ? "s" : ""); } - text.sprintf ("%s | %s | %s", Session.address().to_string (IP_WITH_PORT).chars(), - Session.level().chars(), adminText.chars()); + text.sprintf ("%s | %s | %s", + Session.address().to_string (IPAddress::WITH_PORT).chars(), + Session.level().chars(), + adminText.chars()); } break; } @@ -950,14 +967,16 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::print_to_console (String a) +void Interface::print_to_console (String message) { // Zandronum sometimes sends color codes as "\\c" and sometimes as "\x1C". // Let's correct that on our end and hope this won't cause conflicts. - a.replace ("\\c", "\x1C"); + message.replace ("\\c", "\x1C"); - for (char ch : a) + for (int i = 0; i < message.length(); ++i) { + char ch = message[i]; + if (ch == '\n') { OutputLines.last().finalize(); @@ -1028,3 +1047,5 @@ NeedInputRender = true; } } + +END_ZFC_NAMESPACE \ No newline at end of file