diff options
author | Eugene Sandulenko | 2016-07-22 15:38:24 +0300 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | d57fca4665e65bca1cf487fb109d020d1233e800 (patch) | |
tree | c5a8b0e88f4c55e0f2e2afb2f78a4cd1f89d66f3 /backends/networking/sdl_net/client.cpp | |
parent | cccfe7c247fed9b00c100e64433439386d6ef077 (diff) | |
download | scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.tar.gz scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.tar.bz2 scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.zip |
CLOUD: JANITORIAL: Fix code formatting
Diffstat (limited to 'backends/networking/sdl_net/client.cpp')
-rw-r--r-- | backends/networking/sdl_net/client.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/backends/networking/sdl_net/client.cpp b/backends/networking/sdl_net/client.cpp index 6cef5ffc93..0026d0e346 100644 --- a/backends/networking/sdl_net/client.cpp +++ b/backends/networking/sdl_net/client.cpp @@ -45,15 +45,18 @@ Client::~Client() { } void Client::open(SDLNet_SocketSet set, TCPsocket socket) { - if (_state != INVALID) close(); + if (_state != INVALID) + close(); _state = READING_HEADERS; _socket = socket; _set = set; Reader cleanReader; _reader = cleanReader; - if (_handler) delete _handler; + if (_handler) + delete _handler; _handler = nullptr; - if (_previousHandler) delete _previousHandler; + if (_previousHandler) + delete _previousHandler; _previousHandler = nullptr; _stream = new Common::MemoryReadWriteStream(DisposeAfterUse::YES); if (set) { @@ -65,10 +68,14 @@ void Client::open(SDLNet_SocketSet set, TCPsocket socket) { } bool Client::readMoreIfNeeded() { - if (_stream == nullptr) return false; //nothing to read into - if (_stream->size() - _stream->pos() > 0) return true; //not needed, some data left in the stream - if (!_socket) return false; - if (!SDLNet_SocketReady(_socket)) return false; + if (_stream == nullptr) + return false; //nothing to read into + if (_stream->size() - _stream->pos() > 0) + return true; //not needed, some data left in the stream + if (!_socket) + return false; + if (!SDLNet_SocketReady(_socket)) + return false; int bytes = SDLNet_TCP_Recv(_socket, _buffer, CLIENT_BUFFER_SIZE); if (bytes <= 0) { @@ -87,33 +94,38 @@ bool Client::readMoreIfNeeded() { } void Client::readHeaders() { - if (!readMoreIfNeeded()) return; + if (!readMoreIfNeeded()) + return; _reader.setContent(_stream); if (_reader.readFirstHeaders()) _state = (_reader.badRequest() ? BAD_REQUEST : READ_HEADERS); } bool Client::readContent(Common::WriteStream *stream) { - if (!readMoreIfNeeded()) return false; + if (!readMoreIfNeeded()) + return false; _reader.setContent(_stream); return _reader.readFirstContent(stream); } bool Client::readBlockHeaders(Common::WriteStream *stream) { - if (!readMoreIfNeeded()) return false; + if (!readMoreIfNeeded()) + return false; _reader.setContent(_stream); return _reader.readBlockHeaders(stream); } bool Client::readBlockContent(Common::WriteStream *stream) { - if (!readMoreIfNeeded()) return false; + if (!readMoreIfNeeded()) + return false; _reader.setContent(_stream); return _reader.readBlockContent(stream); } void Client::setHandler(ClientHandler *handler) { if (_handler) { - if (_previousHandler) delete _previousHandler; + if (_previousHandler) + delete _previousHandler; _previousHandler = _handler; //can't just delete it, as setHandler() could've been called by handler itself } _state = BEING_HANDLED; @@ -121,9 +133,12 @@ void Client::setHandler(ClientHandler *handler) { } void Client::handle() { - if (_state != BEING_HANDLED) warning("handle() called in a wrong Client's state"); - if (!_handler) warning("Client doesn't have handler to be handled by"); - if (_handler) _handler->handle(this); + if (_state != BEING_HANDLED) + warning("handle() called in a wrong Client's state"); + if (!_handler) + warning("Client doesn't have handler to be handled by"); + if (_handler) + _handler->handle(this); } void Client::close() { |