mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 20:14:54 +02:00
Add error code to onError protocol event
This commit is contained in:
@@ -34,9 +34,9 @@ SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
|
||||
|
||||
IF(USE_STATIC_LIBS)
|
||||
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
MESSAGE("Link to static libraries: ON")
|
||||
MESSAGE(STATUS "Link to static libraries: ON")
|
||||
ELSE()
|
||||
MESSAGE("Link to static libraries: OFF")
|
||||
MESSAGE(STATUS "Link to static libraries: OFF")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
||||
|
@@ -242,6 +242,6 @@ void Protocol::onRecv(const InputMessagePtr& inputMessage)
|
||||
|
||||
void Protocol::onError(const boost::system::error_code& err)
|
||||
{
|
||||
callLuaField("onError", err.message(), true);
|
||||
callLuaField("onError", err.message(), err.value());
|
||||
disconnect();
|
||||
}
|
||||
|
@@ -64,13 +64,13 @@ void Game::resetGameStates()
|
||||
m_gmActions.clear();
|
||||
}
|
||||
|
||||
void Game::processConnectionError(const boost::system::error_code& error)
|
||||
void Game::processConnectionError(const boost::system::error_code& ec)
|
||||
{
|
||||
// connection errors only have meaning if we still have a protocol
|
||||
if(m_protocolGame) {
|
||||
// eof = end of file, a clean disconnect
|
||||
if(error != asio::error::eof)
|
||||
g_lua.callGlobalField("g_game", "onConnectionError", error.message());
|
||||
if(ec != asio::error::eof)
|
||||
g_lua.callGlobalField("g_game", "onConnectionError", ec.message(), ec.value());
|
||||
|
||||
processDisconnect();
|
||||
}
|
||||
|
@@ -42,6 +42,8 @@ void ProtocolGame::login(const std::string& accountName, const std::string& acco
|
||||
|
||||
void ProtocolGame::onConnect()
|
||||
{
|
||||
Protocol::onConnect();
|
||||
|
||||
// must create local player before parsing anything
|
||||
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
|
||||
|
||||
@@ -56,12 +58,16 @@ void ProtocolGame::onConnect()
|
||||
|
||||
void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
|
||||
{
|
||||
//Protocol::onConnect(inputMessage);
|
||||
|
||||
parseMessage(inputMessage);
|
||||
recv();
|
||||
}
|
||||
|
||||
void ProtocolGame::onError(const boost::system::error_code& error)
|
||||
{
|
||||
Protocol::onError(error);
|
||||
|
||||
g_game.processConnectionError(error);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user