diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp index 9eac380b6..350921502 100644 --- a/src/client/inputhandler.cpp +++ b/src/client/inputhandler.cpp @@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inputhandler.h" #include "mainmenumanager.h" +#ifdef __IOS__ +extern void external_exit_game(); +#endif + bool MyEventReceiver::OnEvent(const SEvent &event) { /* @@ -58,6 +62,15 @@ bool MyEventReceiver::OnEvent(const SEvent &event) } #endif +#ifdef __IOS__ + if (event.EventType == irr::EET_APPLICATION_EVENT) { + if (event.ApplicationEvent.EventType == irr::EAET_WILL_PAUSE) + external_exit_game(); + + return true; + } +#endif + if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) { /* TODO add a check like: if (event.JoystickEvent != joystick_we_listen_for) diff --git a/src/game.cpp b/src/game.cpp index 1b142abba..86727fac8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4884,6 +4884,13 @@ void external_pause_game() g_game->pauseGame(); } +void external_exit_game() +{ + if (!g_game) + return; + g_gamecallback->disconnect(); +} + void external_statustext(const char *text, float duration) { if (!g_game) diff --git a/src/network/connection.cpp b/src/network/connection.cpp index 34ca9c1ff..c7499a989 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -2166,6 +2166,9 @@ void ConnectionReceiveThread::receive() Address sender; s32 received_size = m_connection->m_udpSocket.Receive(sender, *packetdata, packet_maxsize); + if (received_size == -1) + break; + if ((received_size < BASE_HEADER_SIZE) || (readU32(&packetdata[0]) != m_connection->GetProtocolID())) { diff --git a/src/socket.cpp b/src/socket.cpp index 64c961b17..08746fbeb 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -348,6 +348,11 @@ bool UDPSocket::init(bool ipv6, bool noExceptions) setTimeoutMs(0); +#ifdef __IOS__ + int val = 1; + setsockopt(m_handle, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val)); +#endif + return true; }