From 00791f6801fbd0e8eb80e5c7d35706de0e1cca94 Mon Sep 17 00:00:00 2001 From: bgk Date: Sun, 2 Sep 2012 14:26:22 +0000 Subject: [PATCH] WX: Somewhat fix lan link. Advance wars won't link properly whereas it is working with mem link. --- src/wx/guiinit.cpp | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index fdb2ab93..b61594fe 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -121,19 +121,25 @@ public: sig->Signal(); lock->Unlock(); } - } sid(&lock, &sig, &connmsg, &pmsg, &done); - if(!ls.Init(&sid)) { - wxLogError(_("Error occurred.\nPlease try again.")); - lock.Unlock(); - return; + }; + + sid_t* sid = new sid_t(&lock, &sig, &connmsg, &pmsg, &done); + + if (!ls.Init(sid)) { + wxLogError(_("Error occurred.\nPlease try again.")); + lock.Unlock(); + delete sid; + return; } + wxProgressDialog pdlg(_("Waiting for clients..."), connmsg, 100, dlg, wxPD_APP_MODAL|wxPD_CAN_ABORT|wxPD_ELAPSED_TIME); + while(!done) { - if(!pdlg.Pulse(connmsg + pmsg)) - done = true; - sig.Wait(); + if(!pdlg.Pulse(connmsg + pmsg)) + done = true; + sig.Wait(); } } else { class cid_t : public ClientInfoDisplay @@ -175,21 +181,25 @@ public: sig->Signal(); lock->Unlock(); } - } cid(&lock, &sig, &connmsg, &pmsg, &done); - int err; - if((err = lc.Init(sf::IPAddress(std::string(gopts.link_host.mb_str())), - &cid))) { - wxLogError(_("Error %d occurred.\nPlease try again."), err); - lock.Unlock(); - return; + }; + + cid_t* cid = new cid_t(&lock, &sig, &connmsg, &pmsg, &done); + + if (!lc.Init(sf::IPAddress(std::string(gopts.link_host.mb_str())), cid)) { + wxLogError(_("Error occurred.\nPlease try again.")); + lock.Unlock(); + delete cid; + return; } + wxProgressDialog pdlg(_("Waiting for connection..."), connmsg, 100, dlg, wxPD_APP_MODAL|wxPD_CAN_ABORT|wxPD_ELAPSED_TIME); + while(!done) { - if(!pdlg.Pulse(connmsg + pmsg)) - done = true; - sig.Wait(); + if(!pdlg.Pulse(connmsg + pmsg)) + done = true; + sig.Wait(); } } lock.Unlock();