From 81ff15fe6b972d3cc721fac36ab8d8a690c7298b Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Tue, 26 Jul 2011 20:55:39 -0300 Subject: [PATCH] fix bug --- data/modules/mainmenu/entergame.lua | 9 +++------ src/protocollogin.cpp | 2 +- src/protocollogin.h | 3 +++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/modules/mainmenu/entergame.lua b/data/modules/mainmenu/entergame.lua index f1a4da23..7bfa8bda 100644 --- a/data/modules/mainmenu/entergame.lua +++ b/data/modules/mainmenu/entergame.lua @@ -1,9 +1,6 @@ function EnterGame_connectToLoginServer() -- create login protocol local protocolLogin = ProtocolLogin.create() - print(ProtocolLogin_mt) - print(Protocol_mt) - print(getmetatable(protocolLogin)) -- used to recreate enter game window local recreateEnterGame = function() @@ -14,9 +11,9 @@ function EnterGame_connectToLoginServer() local loadBox = displayCancelBox("Please wait", "Connecting..") -- cancel loading callback - loadBox.onCancel = function(protocol) + loadBox.onCancel = function(msgbox) -- cancel protocol and reacreate enter game window - protocol:cancel() + protocolLogin:cancel() recreateEnterGame() end @@ -29,7 +26,7 @@ function EnterGame_connectToLoginServer() local errorBox = displayErrorBox("Login Error", error) -- cancel protocol and reacreate enter game window - protocol.cancel() + protocol:cancel() errorBox.onOk = recreateEnterGame end diff --git a/src/protocollogin.cpp b/src/protocollogin.cpp index 2788ef40..42a06abe 100644 --- a/src/protocollogin.cpp +++ b/src/protocollogin.cpp @@ -41,7 +41,7 @@ void ProtocolLogin::login(const std::string& accountName, const std::string& acc //std::string host = "tecserver.zapto.org"; uint16 port = 7171; - connect(host, port, std::bind(&ProtocolLogin::onConnect, this)); + connect(host, port, std::bind(&ProtocolLogin::onConnect, asProtocolLogin())); } void ProtocolLogin::onConnect() diff --git a/src/protocollogin.h b/src/protocollogin.h index 69ce98f9..cf74b36a 100644 --- a/src/protocollogin.h +++ b/src/protocollogin.h @@ -22,6 +22,9 @@ public: void onRecv(InputMessage *inputMessage); void cancel() { /* TODO: this func */ } + + ProtocolLoginPtr asProtocolLogin() { return std::static_pointer_cast(shared_from_this()); } + virtual const char* getLuaTypeName() const { return "ProtocolLogin"; } private: