This is an automated email from the git hooks/post-receive script.

apo-guest pushed a commit to branch master
in repository springlobby.

commit 2921fb630676515c5f1651eaf0d4a62b34c2bd6f
Author: Markus Koschany <[email protected]>
Date:   Tue Jun 2 20:47:21 2015 +0200

    Imported Upstream version 0.224
---
 ChangeLog                         |  10 +++
 VERSION                           |   2 +-
 springlobby_config.h              |   2 +-
 src/CMakeLists.txt                |   1 +
 src/autohost.h                    |   3 +-
 src/autohostmanager.cpp           |  18 ++++++
 src/autohostmanager.h             |   5 +-
 src/battle.cpp                    |  13 ----
 src/gui/infodialog.cpp            |   1 -
 src/gui/infodialog.h              |   1 +
 src/gui/mapselectdialog.cpp       |   1 -
 src/gui/selectusersdialog.cpp     |   1 -
 src/gui/singleplayertab.cpp       |  83 +++++++++++++-----------
 src/gui/singleplayertab.h         |   5 ++
 src/gui/sltipwin.cpp              |  36 +++++------
 src/gui/sltipwin.h                |   8 +--
 src/gui/textentrydialog.cpp       |  40 ++++++++++++
 src/gui/textentrydialog.h         |  40 ++----------
 src/ibattle.cpp                   |  34 ++++++----
 src/log.cpp                       |  14 +---
 src/lsl/lib/cimg/CImg.h           |   5 +-
 src/lsl/src/lslutils/conversion.h |   2 +-
 src/serverevents.cpp              | 132 +++++++++++++++++++++++---------------
 src/tasserver.cpp                 |  23 ++++---
 src/tasserver.h                   |   2 +-
 src/tests/lslconversion.cpp       |  21 ++++++
 26 files changed, 295 insertions(+), 208 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e846182..2b83e7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 ChangeLog of Springlobby
 
+## 0.224
+ - fix startposition type ignored
+
+## 0.223
+ - fix invalid sync check (makes relayhost/hosting work again)
+ - set focus to text input when prompting
+ - allow to select engine version for singleplayer games (thanks 
OursDesCavernes!)
+ - fix detection of autohosts
+ - fix crash when selecting map / clicking start on autohosts
+
 ## 0.222
  - fix crash when going to tools/download archives
  - (try to) fix bug: tipwindow consumes first mouse events
diff --git a/VERSION b/VERSION
index 10d2e8d..4a3543f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.222
+0.224
diff --git a/springlobby_config.h b/springlobby_config.h
index ae5ea4f..07ad7c6 100644
--- a/springlobby_config.h
+++ b/springlobby_config.h
@@ -6,6 +6,6 @@
 #undef VERSION
 
 /* the git tag / commit we build from */
-#define VERSION "0.222"
+#define VERSION "0.224"
 
 #endif /* SPRINGLOBBY_HEADERGUARD_CONFIG_H */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bc0a419..8701a30 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -194,6 +194,7 @@ set(springlobbySrc
        gui/singleplayertab.cpp
        gui/selectusersdialog.cpp
        gui/taskbar.cpp
+       gui/textentrydialog.cpp
        gui/ui.cpp
        gui/wxtextctrlhist.cpp
 
diff --git a/src/autohost.h b/src/autohost.h
index d8ce465..73bd076 100644
--- a/src/autohost.h
+++ b/src/autohost.h
@@ -3,8 +3,7 @@
 #ifndef SPRINGLOBBY_HEADERGUARD_AUTOHOST_H
 #define SPRINGLOBBY_HEADERGUARD_AUTOHOST_H
 
-//including this header is only really needed for time_t ..
-#include <wx/string.h>
+#include <time.h>
 #include <wx/arrstr.h>
 
 class IBattle;
diff --git a/src/autohostmanager.cpp b/src/autohostmanager.cpp
index a638c86..f2de69f 100644
--- a/src/autohostmanager.cpp
+++ b/src/autohostmanager.cpp
@@ -20,14 +20,25 @@ AutohostHandler::~AutohostHandler()
 
 void AutohostHandler::Send(const std::string& cmd)
 {
+       if (m_battle == nullptr) {
+               return;
+       }
        m_battle->Say(cmd);
 }
 
 void AutohostHandler::SayFounder(const std::string& cmd)
 {
+       if (m_battle == nullptr) {
+               return;
+       }
        m_battle->GetFounder().Say(cmd);
 }
 
+void AutohostHandler::SetBattle(IBattle* battle)
+{
+       m_battle = battle;
+}
+
 //========================
 //-------- Springie ------
 //========================
@@ -160,10 +171,12 @@ bool AutohostManager::RecognizeAutohost(const 
std::string& type)
 {
        if (type == "SPRINGIE") {
                m_type = AutohostManager::AUTOHOSTTYPE_SPRINGIE;
+               Configure();
                return true;
        }
        if (type == "SPADS") {
                m_type = AutohostManager::AUTOHOSTTYPE_SPADS;
+               Configure();
                return true;
        }
 
@@ -172,6 +185,11 @@ bool AutohostManager::RecognizeAutohost(const std::string& 
type)
        return false;
 }
 
+void AutohostManager::Configure()
+{
+       GetAutohostHandler().SetBattle(m_battle);
+}
+
 AutohostManager::AutohostType AutohostManager::GetAutohostType()
 {
        return m_type;
diff --git a/src/autohostmanager.h b/src/autohostmanager.h
index ea4315f..4fdf35a 100644
--- a/src/autohostmanager.h
+++ b/src/autohostmanager.h
@@ -20,12 +20,13 @@ public:
        virtual void AddStartBox(int /*posx*/, int /*posy*/, int /*w*/, int 
/*h*/){};
        virtual void Notify(){};
        virtual void Start(){};
+       void SetBattle(IBattle* battle);
 
 protected:
        virtual void Send(const std::string& /*cmd*/);
        virtual void SayFounder(const std::string& /*cmd*/);
+
 private:
-       void SetBattle(IBattle* battle);
        IBattle* m_battle;
 
 
@@ -76,7 +77,6 @@ public:
        ~AutohostManager();
 
        void SetBattle(IBattle* bt);
-
        bool RecognizeAutohost(const std::string& type);
 
        AutohostType GetAutohostType();
@@ -84,6 +84,7 @@ public:
        AutohostHandler& GetAutohostHandler();
 
 private:
+       void Configure();
 
        SpringieHandler m_springie;
        SpadsHandler m_spads;
diff --git a/src/battle.cpp b/src/battle.cpp
index 06576d9..68ccb5f 100644
--- a/src/battle.cpp
+++ b/src/battle.cpp
@@ -20,7 +20,6 @@
 #include "utils/conversion.h"
 #include "utils/uievents.h"
 #include "utils/battleevents.h"
-#include "utils/slpaths.h"
 #include "gui/uiutils.h"
 #include "settings.h"
 #include "useractions.h"
@@ -593,18 +592,6 @@ void Battle::StartHostedBattle()
                                if (UserExists(GetProxy()) && 
!GetUser(GetProxy()).Status().in_game) {
                                        // DON'T set m_generating_script here, 
it will trick the script generating code to think we're the host
                                        wxString hostscript = 
spring().WriteScriptTxt(*this);
-                                       try {
-                                               wxString path = 
TowxString(SlPaths::GetDataDir()) + _T("relayhost_script.txt");
-                                               if (!wxFile::Access(path, 
wxFile::write)) {
-                                                       wxLogError(_T("Access 
denied to script.txt."));
-                                               }
-
-                                               wxFile f(path, wxFile::write);
-                                               f.Write(hostscript);
-                                               f.Close();
-
-                                       } catch (...) {
-                                       }
                                        
m_serv.SendScriptToProxy(STD_STRING(hostscript));
                                }
                        }
diff --git a/src/gui/infodialog.cpp b/src/gui/infodialog.cpp
index 41ccbd7..c742a30 100644
--- a/src/gui/infodialog.cpp
+++ b/src/gui/infodialog.cpp
@@ -95,4 +95,3 @@ InfoDialog::InfoDialog(wxWindow* parent)
 InfoDialog::~InfoDialog()
 {
 }
-
diff --git a/src/gui/infodialog.h b/src/gui/infodialog.h
index ee25670..727a9d4 100644
--- a/src/gui/infodialog.h
+++ b/src/gui/infodialog.h
@@ -12,6 +12,7 @@ class InfoDialog : public wxDialog
 public:
        InfoDialog(wxWindow* parent);
        virtual ~InfoDialog();
+
 private:
        wxBoxSizer* m_main_sizer;
 };
diff --git a/src/gui/mapselectdialog.cpp b/src/gui/mapselectdialog.cpp
index 159b601..2e460ac 100644
--- a/src/gui/mapselectdialog.cpp
+++ b/src/gui/mapselectdialog.cpp
@@ -156,7 +156,6 @@ MapSelectDialog::~MapSelectDialog()
 
        if (IsShown())
                EndModal(0);
-
 }
 
 
diff --git a/src/gui/selectusersdialog.cpp b/src/gui/selectusersdialog.cpp
index 92d16ea..8aaad46 100644
--- a/src/gui/selectusersdialog.cpp
+++ b/src/gui/selectusersdialog.cpp
@@ -101,7 +101,6 @@ SelectUsersDialog::SelectUsersDialog(wxWindow* parent, 
wxWindowID id, const wxSt
 SelectUsersDialog::~SelectUsersDialog()
 {
        ClearList();
-
 }
 
 void SelectUsersDialog::Initialize()
diff --git a/src/gui/singleplayertab.cpp b/src/gui/singleplayertab.cpp
index e0b1902..f027bcc 100644
--- a/src/gui/singleplayertab.cpp
+++ b/src/gui/singleplayertab.cpp
@@ -38,6 +38,7 @@ BEGIN_EVENT_TABLE(SinglePlayerTab, wxPanel)
 
 EVT_CHOICE(SP_MAP_PICK, SinglePlayerTab::OnMapSelect)
 EVT_CHOICE(SP_MOD_PICK, SinglePlayerTab::OnModSelect)
+EVT_CHOICE(SP_ENGINE_PICK, SinglePlayerTab::OnEngineSelect)
 EVT_BUTTON(SP_BROWSE_MAP, SinglePlayerTab::OnMapBrowse)
 EVT_BUTTON(SP_ADD_BOT, SinglePlayerTab::OnAddBot)
 EVT_BUTTON(SP_RESET, SinglePlayerTab::OnReset)
@@ -117,6 +118,15 @@ SinglePlayerTab::SinglePlayerTab(wxWindow* parent, 
MainSinglePlayerTab& msptab)
        m_mod_pick = new wxChoice(this, SP_MOD_PICK);
        m_ctrl_sizer->Add(m_mod_pick, 1, wxALL, 5);
 
+       m_mod_lbl = new wxStaticText(this, -1, _("Engine:"));
+       m_ctrl_sizer->Add(m_mod_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+
+       wxArrayString m_engine_picChoices;
+       wxBoxSizer* mod_choice_button_sizer2 = new wxBoxSizer(wxHORIZONTAL);
+       m_engine_pic = new wxChoice(this, SP_ENGINE_PICK, wxDefaultPosition, 
wxDefaultSize, m_engine_picChoices, 0);
+       m_engine_pic->SetToolTip(_("Select the engine version to play."));
+       mod_choice_button_sizer2->Add(m_engine_pic, 0, wxALL, 5);
+       m_ctrl_sizer->Add(mod_choice_button_sizer2, 0, wxEXPAND | wxALL, 1);
 
        //  m_ctrl_sizer->Add( 0, 0, 1, wxEXPAND, 0 );
 
@@ -146,12 +156,17 @@ SinglePlayerTab::SinglePlayerTab(wxWindow* parent, 
MainSinglePlayerTab& msptab)
 
        m_main_sizer->Add(m_buttons_sizer, 0, wxEXPAND, 5);
 
-       this->SetSizer(m_main_sizer);
-       this->Layout();
+       m_battle.SetEngineName("spring");
+       m_battle.SetEngineVersion(SlPaths::GetCurrentUsedSpringIndex());
 
        ReloadMaplist();
        ReloadModlist();
+       ReloadEngineList();
        ConnectGlobalEvent(this, GlobalEvent::OnUnitsyncReloaded, 
wxObjectEventFunction(&SinglePlayerTab::OnUnitsyncReloaded));
+
+       this->SetSizer(m_main_sizer);
+       this->Layout();
+
 }
 
 
@@ -198,6 +213,26 @@ void SinglePlayerTab::ReloadModlist()
        }
 }
 
+void SinglePlayerTab::ReloadEngineList()
+{
+       m_engine_pic->Clear();
+       std::map<std::string, LSL::SpringBundle> versions = 
SlPaths::GetSpringVersionList();
+       const std::string last = SlPaths::GetCurrentUsedSpringIndex();
+       int i = 0;
+       for (auto pair : versions) {
+               m_engine_pic->Insert(TowxString(pair.first), i);
+               if (last == pair.first) {
+                       m_engine_pic->SetSelection(i);
+               }
+               i++;
+       }
+
+       if (m_engine_pic->GetSelection() == wxNOT_FOUND) {
+               m_engine_pic->SetSelection(0);
+       }
+       //unitsync change needs a refresh of games as well
+       ReloadModlist();
+}
 
 void SinglePlayerTab::SetMap(unsigned int index)
 {
@@ -295,6 +330,13 @@ void SinglePlayerTab::OnModSelect(wxCommandEvent& 
/*unused*/)
                customMessageBoxNoModal(SL_MAIN_ICON, _("Incompatible bots have 
been removed after game selection changed."), _("Bots removed"));
 }
 
+void SinglePlayerTab::OnEngineSelect(wxCommandEvent& /*event*/)
+{
+       
SlPaths::SetUsedSpringIndex(STD_STRING(m_engine_pic->GetString(m_engine_pic->GetSelection())));
+       LSL::usync().ReloadUnitSyncLib();
+       
m_battle.SetEngineVersion(STD_STRING(m_engine_pic->GetString(m_engine_pic->GetSelection())));
+       ReloadEngineList();
+}
 
 void SinglePlayerTab::OnMapBrowse(wxCommandEvent& /*unused*/)
 {
@@ -351,9 +393,6 @@ void SinglePlayerTab::OnStart(wxCommandEvent& /*unused*/)
                return;
        }
 
-       m_battle.SetEngineName("spring");
-       m_battle.SetEngineVersion(SlPaths::GetCurrentUsedSpringIndex()); 
//FIXME: make engine version selectable
-
        if (ValidSetup())
                m_battle.StartSpring();
 }
@@ -387,40 +426,6 @@ void SinglePlayerTab::OnColorButton(wxCommandEvent& 
/*unused*/)
        m_battle.ForceColour(u, wxColourTolsl(CurrentColour));
        UpdateMinimap();
 }
-/*
-void SinglePlayerTab::UpdateTag( const wxString& Tag )
-{
-    long type;
-    Tag.BeforeFirst( '_' ).ToLong( &type );
-    const wxString key = Tag.AfterFirst( '_' );
-    if ( type == LSL::OptionsWrapper::PrivateOptions ) {
-        if ( key == _T("mapname") ) {
-            m_addbot_btn->Enable( false );
-            try
-            {
-                
m_map_pick->SetSelection(LSL::usync().GetMapIndex(m_battle.GetHostMapName()));
-                UpdateMinimap();
-                m_addbot_btn->Enable( true );
-            }
-            catch (...) {}
-        }
-        else if ( key == _T("modname") ) {
-            try
-            {
-//                int pln = m_battle.GetNumUsers();
-//                int botn = m_battle.GetNumBots();
-                UpdateMinimap();
-//                pln -= m_battle.GetNumUsers();
-//                botn -= m_battle.GetNumBots();
-//                assert( pln == 0 );
-//                assert( botn == 0 );
-
-            }
-            catch (...) {}
-        }
-    }
-}
-*/
 
 void SinglePlayerTab::UpdatePresetList()
 {
diff --git a/src/gui/singleplayertab.h b/src/gui/singleplayertab.h
index 861930c..6e1e305 100644
--- a/src/gui/singleplayertab.h
+++ b/src/gui/singleplayertab.h
@@ -32,6 +32,7 @@ public:
        void UpdateMinimap();
        void ReloadMaplist();
        void ReloadModlist();
+       void ReloadEngineList();
        void UpdatePresetList();
 
        IBattle& GetBattle()
@@ -43,6 +44,7 @@ public:
 
        void OnMapSelect(wxCommandEvent& event);
        void OnModSelect(wxCommandEvent& event);
+       void OnEngineSelect(wxCommandEvent& event);
        void OnMapBrowse(wxCommandEvent& event);
        void OnAddBot(wxCommandEvent& event);
        void OnStart(wxCommandEvent& event);
@@ -56,6 +58,7 @@ public:
 
        void SetMap(unsigned int index);
        void SetMod(unsigned int index);
+       void SetEngine(unsigned int index);
 
 private:
        wxBoxSizer* m_main_sizer;
@@ -64,6 +67,7 @@ private:
        MapCtrl* m_minimap;
        wxChoice* m_map_pick;
        wxChoice* m_mod_pick;
+       wxChoice* m_engine_pic;
        wxStaticText* m_map_lbl;
        wxStaticText* m_mod_lbl;
        wxButton* m_select_btn;
@@ -81,6 +85,7 @@ private:
        enum {
                SP_MAP_PICK = wxID_HIGHEST,
                SP_MOD_PICK,
+               SP_ENGINE_PICK,
                SP_BROWSE_MAP,
                SP_ADD_BOT,
                SP_RESET,
diff --git a/src/gui/sltipwin.cpp b/src/gui/sltipwin.cpp
index 7c81965..9261fa5 100644
--- a/src/gui/sltipwin.cpp
+++ b/src/gui/sltipwin.cpp
@@ -7,11 +7,12 @@
 #if wxUSE_TIPWINDOW
 
 SLTipWindow::SLTipWindow(wxWindow* parent, const wxString& text)
-    : wxTipWindow(parent, text), wxEventFilter()
+    : wxTipWindow(parent, text)
+    , wxEventFilter()
 {
        parentWindow = parent;
        creationTime = wxDateTime::GetTimeNow();
-       
+
        //Register event hook
        wxEvtHandler::AddFilter(this);
        isHookInstalled = true;
@@ -19,7 +20,7 @@ SLTipWindow::SLTipWindow(wxWindow* parent, const wxString& 
text)
 
 SLTipWindow::~SLTipWindow()
 {
-       if( isHookInstalled == true ) {
+       if (isHookInstalled == true) {
                wxEvtHandler::RemoveFilter(this);
                isHookInstalled = false;
        }
@@ -29,15 +30,15 @@ SLTipWindow::~SLTipWindow()
 int SLTipWindow::FilterEvent(wxEvent& hookedEvent)
 {
        //Only mouse events are in interest
-       if( isMouseEvent(hookedEvent) == true ) {
+       if (isMouseEvent(hookedEvent) == true) {
                //Remove hook before proceed, prevents deadlock
                wxEvtHandler::RemoveFilter(this);
                isHookInstalled = false;
-               
+
                //Send event to parent control
                wxEvent* clonedEvent = hookedEvent.Clone();
                parentWindow->GetEventHandler()->QueueEvent(clonedEvent);
-               
+
                //Close tip window
                Close();
                return Event_Processed;
@@ -50,22 +51,21 @@ int SLTipWindow::FilterEvent(wxEvent& hookedEvent)
 bool SLTipWindow::isMouseEvent(wxEvent& hookedEvent)
 {
        wxEventType et = hookedEvent.GetEventType();
-       
+
        //Check for almost all possible mouse events
-       if( et == wxEVT_LEFT_DOWN ||
-               et == wxEVT_RIGHT_DOWN ||
-               et == wxEVT_MIDDLE_DOWN ||
-               et == wxEVT_LEFT_DCLICK ||
-               et == wxEVT_RIGHT_DCLICK ||
-               et == wxEVT_MIDDLE_DCLICK ||
-               et == wxEVT_MOUSEWHEEL )
-       {
+       if (et == wxEVT_LEFT_DOWN ||
+           et == wxEVT_RIGHT_DOWN ||
+           et == wxEVT_MIDDLE_DOWN ||
+           et == wxEVT_LEFT_DCLICK ||
+           et == wxEVT_RIGHT_DCLICK ||
+           et == wxEVT_MIDDLE_DCLICK ||
+           et == wxEVT_MOUSEWHEEL) {
                return true;
        }
-       
+
        //Detect mouse motion only after some delay
-       if( wxDateTime::GetTimeNow() - creationTime >= MOTION_DETECTION_DELAY ) 
{
-               if( et == wxEVT_MOTION ) {
+       if (wxDateTime::GetTimeNow() - creationTime >= MOTION_DETECTION_DELAY) {
+               if (et == wxEVT_MOTION) {
                        return true;
                }
        }
diff --git a/src/gui/sltipwin.h b/src/gui/sltipwin.h
index e455fcc..1fab0e4 100644
--- a/src/gui/sltipwin.h
+++ b/src/gui/sltipwin.h
@@ -14,17 +14,17 @@ class SLTipWindow : public wxTipWindow, public wxEventFilter
 public:
        SLTipWindow(wxWindow* parent, const wxString& text);
        virtual ~SLTipWindow();
-        
+
        virtual int FilterEvent(wxEvent&);
-       
+
 private:
        bool isMouseEvent(wxEvent&);
-       
+
 private:
        wxWindow* parentWindow;
        bool isHookInstalled;
        time_t creationTime;
-       
+
 private:
        const int MOTION_DETECTION_DELAY = 1;
 };
diff --git a/src/gui/textentrydialog.cpp b/src/gui/textentrydialog.cpp
new file mode 100644
index 0000000..00dc65c
--- /dev/null
+++ b/src/gui/textentrydialog.cpp
@@ -0,0 +1,40 @@
+/* This file is part of the Springlobby (GPL v2 or later), see COPYING */
+
+#include "textentrydialog.h"
+#include <wx/stattext.h>
+#include <wx/sizer.h>
+#include <wx/textctrl.h>
+
+TextEntryDialog::TextEntryDialog(wxWindow* parent, const wxString& title, 
const wxString& heading, const wxString& answer, bool multiline)
+    : wxDialog(parent, -1, title, wxDefaultPosition, wxDefaultSize, 
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+{
+       wxStaticText* text = new wxStaticText(this, -1, heading);
+       long inputstyle = 0;
+       if (multiline)
+               inputstyle = wxTE_MULTILINE;
+       input = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, 
wxDefaultSize, inputstyle);
+       if (multiline)
+               input->SetInitialSize(wxSize(400, 300));
+       SetValue(answer);
+       wxSizer* buttons = CreateButtonSizer(wxOK | wxCANCEL);
+       wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+       sizer->Add(text, 0, wxALL, 5);
+       sizer->Add(input, 1, wxEXPAND | wxALL, 5);
+       sizer->Add(buttons, 0, wxEXPAND | wxALL, 5);
+       SetSizerAndFit(sizer);
+       input->SetFocus();
+}
+
+TextEntryDialog::~TextEntryDialog()
+{
+}
+
+void TextEntryDialog::SetValue(const wxString& value)
+{
+       input->SetValue(value);
+}
+
+const wxString TextEntryDialog::GetValue()
+{
+       return input->GetValue();
+}
diff --git a/src/gui/textentrydialog.h b/src/gui/textentrydialog.h
index 040eef8..6ef1ef7 100644
--- a/src/gui/textentrydialog.h
+++ b/src/gui/textentrydialog.h
@@ -2,44 +2,16 @@
 
 #include <wx/string.h>
 #include <wx/dialog.h>
-#include <wx/stattext.h>
-#include <wx/sizer.h>
+
+class wxTextCtrl;
 
 class TextEntryDialog : public wxDialog
 {
 public:
-       TextEntryDialog(wxWindow* parent, const wxString& title, const 
wxString& heading, const wxString& answer, bool multiline = false)
-           : wxDialog(parent, -1, title, wxDefaultPosition, wxDefaultSize, 
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
-       {
-               wxStaticText* text = new wxStaticText(this, -1, heading);
-               long inputstyle = 0;
-               if (multiline)
-                       inputstyle = wxTE_MULTILINE;
-               input = new wxTextCtrl(this, -1, wxEmptyString, 
wxDefaultPosition, wxDefaultSize, inputstyle);
-               if (multiline)
-                       input->SetInitialSize(wxSize(400, 300));
-               SetValue(answer);
-               wxSizer* buttons = CreateButtonSizer(wxOK | wxCANCEL);
-               wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
-               sizer->Add(text, 0, wxALL, 5);
-               sizer->Add(input, 1, wxEXPAND | wxALL, 5);
-               sizer->Add(buttons, 0, wxEXPAND | wxALL, 5);
-               SetSizerAndFit(sizer);
-       }
-
-       virtual ~TextEntryDialog()
-       {
-       }
-
-       void SetValue(const wxString& value)
-       {
-               input->SetValue(value);
-       }
-
-       const wxString GetValue()
-       {
-               return input->GetValue();
-       }
+       TextEntryDialog(wxWindow* parent, const wxString& title, const 
wxString& heading, const wxString& answer, bool multiline = false);
+       virtual ~TextEntryDialog();
+       void SetValue(const wxString& value);
+       const wxString GetValue();
 
 private:
        wxTextCtrl* input;
diff --git a/src/ibattle.cpp b/src/ibattle.cpp
index a8ce7d1..1401897 100644
--- a/src/ibattle.cpp
+++ b/src/ibattle.cpp
@@ -65,19 +65,31 @@ bool IBattle::IsSynced()
 {
        LoadMod();
        LoadMap();
-       bool synced = true;
+       if (!m_host_mod.name.empty() && m_local_mod.name != m_host_mod.name) {
+               wxLogWarning("Not synced: game name doesn't match: %s %s", 
m_host_mod.name.c_str(), m_local_mod.name.c_str());
+               return false;
+       }
+       if (!m_host_map.name.empty() && m_local_map.name != m_host_map.name) {
+               wxLogWarning("Not synced: map name doesn't match: %s %s", 
m_host_map.name.c_str(), m_local_map.name.c_str());
+               return false;
+       }
+       if (!m_host_mod.hash.empty() && m_host_mod.hash != "0" && 
m_host_mod.hash != m_local_mod.hash) {
+               wxLogWarning("Not synced: game hash doesn't match: %s %s", 
m_host_mod.hash.c_str(), m_host_mod.hash.c_str());
+               return false;
+       }
        if (!m_host_map.hash.empty() && m_host_map.hash != "0" && 
m_host_map.hash != m_local_map.hash) {
-               synced = false;
-       } else if (!m_host_map.name.empty() && m_local_map.name != 
m_host_map.name) {
-               synced = false;
-       } else if (!m_host_mod.hash.empty() && m_host_mod.hash != "0" && 
m_host_mod.hash != m_local_mod.hash) {
-               synced = false;
-       } else if (!m_host_mod.name.empty() && m_local_mod.name != 
m_host_mod.name) {
-               synced = false;
-       } else if (!MapExists() || !ModExists()) {
-               synced = false;
+               wxLogWarning("Not synced: map hash doesn't match: %s %s", 
m_host_map.hash.c_str(), m_local_map.hash.c_str());
+               return false;
+       }
+       if (!ModExists()) {
+               wxLogWarning("Not synced: game doesn't exist: %s %s", 
m_host_mod.name.c_str());
+               return false;
        }
-       return synced;
+       if (!MapExists()) {
+               wxLogWarning("Not synced: map doesn't exist: %s %s", 
m_host_map.name.c_str());
+               return false;
+       }
+       return true;
 }
 
 std::vector<LSL::lslColor>& IBattle::GetFixColoursPalette(int numteams) const
diff --git a/src/log.cpp b/src/log.cpp
index ce801b4..90c519f 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -35,20 +35,8 @@ public:
                }
        }
 
-       // don't remove this override, it is used & needed!
-       virtual void DoLogText(const wxString& msg)
-       {
-               DoLog(2, msg, 0);
-       }
-
-       // don't remove this override, it is used & needed!
-       virtual void DoLogString(const wxChar* msg, time_t timestamp)
-       {
-               DoLog(2, msg, timestamp);
-       }
-
        // catch and process all log messages
-       virtual void DoLog(wxLogLevel loglevel, const wxChar* msg, time_t 
/*time*/)
+       void DoLog(wxLogLevel loglevel, const wxChar* msg, time_t /*time*/) 
override
        {
 
                if (gui && (loglevel == wxLOG_Error || loglevel == 
wxLOG_FatalError)) // show user only errors
diff --git a/src/lsl/lib/cimg/CImg.h b/src/lsl/lib/cimg/CImg.h
index b6fdaf5..559f82b 100644
--- a/src/lsl/lib/cimg/CImg.h
+++ b/src/lsl/lib/cimg/CImg.h
@@ -4943,7 +4943,6 @@ namespace cimg_library_suffixed {
         if (usage) {
           std::fprintf(cimg::output(),"\n 
%s%s%s",cimg::t_red,cimg::basename(argv[0]),cimg::t_normal);
           std::fprintf(cimg::output(),": %s",usage);
-          std::fprintf(cimg::output()," (%s, %s)\n\n",__DATE__,__TIME__);
         }
         if (defaut) std::fprintf(cimg::output(),"%s\n",defaut);
       }
@@ -5040,9 +5039,9 @@ namespace cimg_library_suffixed {
        \note Output is done on the default output stream.
     **/
     inline void info() {
-      std::fprintf(cimg::output(),"\n %s%sCImg Library %u.%u.%u%s, compiled %s 
( %s ) with the following flags:\n\n",
+      std::fprintf(cimg::output(),"\n %s%sCImg Library %u.%u.%u%s, compiled 
with the following flags:\n\n",
                    
cimg::t_red,cimg::t_bold,cimg_version/100,(cimg_version/10)%10,cimg_version%10,
-                   cimg::t_normal,__DATE__,__TIME__);
+                   cimg::t_normal);
 
       std::fprintf(cimg::output(),"  > Operating System:       %s%-13s%s 
%s('cimg_OS'=%d)%s\n",
                    cimg::t_bold,
diff --git a/src/lsl/src/lslutils/conversion.h 
b/src/lsl/src/lslutils/conversion.h
index 059a148..c041791 100644
--- a/src/lsl/src/lslutils/conversion.h
+++ b/src/lsl/src/lslutils/conversion.h
@@ -32,7 +32,7 @@ static inline std::string MakeHashUnsigned( const 
std::string& hash )
 
 static inline std::string MakeHashSigned( const std::string& hash )
 {
-       return ToString( FromString<int>( hash ) );
+       return ToString((int)FromString<long>( hash ) );
 }
 
 // convert const char* to std::string, as std::string(NULL) crashes
diff --git a/src/serverevents.cpp b/src/serverevents.cpp
index 634eda7..fe2fb1c 100644
--- a/src/serverevents.cpp
+++ b/src/serverevents.cpp
@@ -405,67 +405,99 @@ static bool parseSkill(const std::string& value, double& 
result)
        return false;
 }
 
+static bool parseTeam(const std::string& value, int& result)
+{
+       const int res = sscanf(value.c_str(), "team%d", &result);
+       return res == 1;
+}
+
 void ServerEvents::OnSetBattleInfo(int battleid, const std::string& param, 
const std::string& value)
 {
        slLogDebugFunc("%s, %s", param.c_str(), value.c_str());
-       try {
-               IBattle& battle = m_serv.GetBattle(battleid);
-               battle.m_script_tags[param] = value;
-               wxString key = TowxString(param);
-               if (key.Left(5) == _T("game/")) {
-                       key = key.AfterFirst('/');
-                       if (key.Left(11) == _T( "mapoptions/" )) {
-                               key = key.AfterFirst('/');
-                               
battle.CustomBattleOptions().setSingleOption(STD_STRING(key), value, 
LSL::Enum::MapOption);
-                               battle.Update(stdprintf("%d_%s", 
LSL::Enum::MapOption, STD_STRING(key).c_str()));
-                               //Player's TrueSkill changed
-                       } else if (key.Left(8) == _T( "players/" )) {
-                               wxString nickName = 
key.AfterFirst('/').BeforeFirst('/');
-                               wxString playerParam = 
key.AfterFirst('/').AfterFirst('/');
-                               if (playerParam == _T("skill")) {
+       IBattle& battle = m_serv.GetBattle(battleid);
+       battle.m_script_tags[param] = value;
+       const LSL::StringVector vec = LSL::Util::StringTokenize(param, "/"); 
//split string by slash
+
+       switch (vec.size()) {
+               case 3: { // depth 3
+                       if (param.find("game/mapoptions") == 0) {
+                               
battle.CustomBattleOptions().setSingleOption(vec[2], value, 
LSL::Enum::MapOption);
+                               battle.Update(stdprintf("%d_%s", 
LSL::Enum::MapOption, vec[2].c_str()));
+                               return;
+                       }
+                       if (param.find("game/modoptions/") == 0) {
+                               
battle.CustomBattleOptions().setSingleOption(vec[2], value, 
LSL::Enum::ModOption);
+                               battle.Update(stdprintf("%d_%s", 
LSL::Enum::ModOption, vec[2].c_str()));
+                               return;
+                       }
+                       if (param.find("game/restrict") == 0) {
+                               OnBattleDisableUnit(battleid, vec[2], 
LSL::Util::FromString<int>(value));
+                               return;
+                       }
+                       if (param.find("game/") == 0) { 
//game/team0/startposx=1692.
+                               int team = -1;
+                               if (parseTeam(vec[1], team)) {
+                                       const bool xpos = vec[2] == "startposx";
+                                       const bool ypos = vec[2] == "startposy";
+                                       if (xpos || ypos) {
+                                               int numusers = 
battle.GetNumUsers();
+                                               for (int i = 0; i < numusers; 
i++) {
+                                                       User& usr = 
battle.GetUser(i);
+                                                       UserBattleStatus& 
status = usr.BattleStatus();
+                                                       if (status.team == 
team) {
+                                                               if (xpos) {
+                                                                       
status.pos.x = LSL::Util::FromString<int>(value);
+                                                               }
+                                                               if (ypos) {
+                                                                       
status.pos.y = LSL::Util::FromString<int>(value);
+                                                               }
+                                                               
battle.OnUserBattleStatusUpdated(usr, status);
+                                                       }
+                                               }
+                                               return;
+                                       }
+                               }
+                       }
+                       break;
+               }
+               case 4: { //depth 4
+                       if (param.find("game/players/") == 0) {
+                               if (vec[3] == "skill") {
+                                       const std::string nick = vec[2];
                                        double skill;
                                        if (parseSkill(value, skill)) {
-                                               
battle.OnPlayerTrueskillChanged(STD_STRING(nickName), skill); //(std::string& 
nickname, double trueskill_value)
+                                               
battle.OnPlayerTrueskillChanged(nick, skill); //(std::string& nickname, double 
trueskill_value)
                                        }
+                                       return;
                                }
-                       } else if (key.Left(11) == _T( "modoptions/" )) {
-                               key = key.AfterFirst('/');
-                               
battle.CustomBattleOptions().setSingleOption(STD_STRING(key), value, 
LSL::Enum::ModOption);
-                               battle.Update(stdprintf("%d_%s", 
LSL::Enum::ModOption, STD_STRING(key).c_str()));
-                       } else if (key.Left(8) == _T( "restrict" )) {
-                               OnBattleDisableUnit(battleid, 
STD_STRING(key.AfterFirst(_T('/'))), LSL::Util::FromString<int>(value));
-                       } else if (key.Left(4) == _T( "team" ) && 
key.Find(_T("startpos")) != wxNOT_FOUND) {
-                               int team = 
FromwxString(key.BeforeFirst(_T('/')).Mid(4));
-                               if (key.Find(_T("startposx")) != wxNOT_FOUND) {
-                                       int numusers = battle.GetNumUsers();
-                                       for (int i = 0; i < numusers; i++) {
-                                               User& usr = battle.GetUser(i);
-                                               UserBattleStatus& status = 
usr.BattleStatus();
-                                               if (status.team == team) {
-                                                       status.pos.x = 
LSL::Util::FromString<int>(value);
-                                                       
battle.OnUserBattleStatusUpdated(usr, status);
-                                               }
-                                       }
-                               } else if (key.Find(_T("startposy")) != 
wxNOT_FOUND) {
-                                       int numusers = battle.GetNumUsers();
-                                       for (int i = 0; i < numusers; i++) {
-                                               User& usr = battle.GetUser(i);
-                                               UserBattleStatus& status = 
usr.BattleStatus();
-                                               if (status.team == team) {
-                                                       status.pos.y = 
LSL::Util::FromString<int>(value);
-                                                       
battle.OnUserBattleStatusUpdated(usr, status);
-                                               }
-                                       }
+                               if (vec[3] == "skilluncertainty") { //this is 
ignored
+                                       return;
                                }
-                       } else if (key.Left(8) == _T("hosttype")) {
-                               
battle.m_autohost_manager->RecognizeAutohost(value);
-                       } else {
-                               
battle.CustomBattleOptions().setSingleOption(STD_STRING(key), value, 
LSL::Enum::EngineOption);
-                               battle.Update(stdprintf("%d_%s", 
LSL::Enum::EngineOption, STD_STRING(key).c_str()));
                        }
+                       break;
                }
-       } catch (assert_exception) {
+               case 2: { //depth 2
+                       if (param == "game/hosttype") {
+                               if 
(battle.m_autohost_manager->RecognizeAutohost(value)) {
+                                       OnSaidBattle(battleid, 
battle.GetMe().GetNick(), stdprintf("detected %s autohost", value.c_str())); 
//FIXME: add event for that + add a label?!
+                               }
+                               return;
+                       }
+                       // i.e. game/startpostype
+                       battle.CustomBattleOptions().setSingleOption(vec[1], 
value, LSL::Enum::EngineOption);
+                       battle.Update(stdprintf("%d_%s", 
LSL::Enum::EngineOption, vec[1].c_str()));
+                       return;
+               }
+                       /*
+               //seems unused
+               case 1: { //depth 1
+                       battle.CustomBattleOptions().setSingleOption(vec[0], 
value, LSL::Enum::EngineOption);
+                       battle.Update(stdprintf("%d_%s", 
LSL::Enum::EngineOption, vec[0].c_str()));
+                       return;
+               }
+*/
        }
+       wxLogWarning("Unhandled SETSCRIPTTAGS: %s=%s", param.c_str(), 
value.c_str());
 }
 
 void ServerEvents::OnUnsetBattleInfo(int /*battleid*/, const std::string& 
/*param*/)
diff --git a/src/tasserver.cpp b/src/tasserver.cpp
index 5920e97..31ed681 100644
--- a/src/tasserver.cpp
+++ b/src/tasserver.cpp
@@ -953,7 +953,7 @@ void TASServer::RelayCmd(const std::string& command, const 
std::string& param)
        }
        wxString msg = _T("!") + TowxString(command).Lower(); // prefix 
commands with !
        if (!param.empty()) {
-               msg += + _T(" ") + TowxString(param);
+               msg += _T(" ") + TowxString(param);
        }
        SayPrivate(m_relay_host_bot, STD_STRING(msg));
 }
@@ -1338,11 +1338,10 @@ void TASServer::SendHostInfo(HostInfo update)
 
        if ((update & (IBattle::HI_Map | IBattle::HI_Locked | 
IBattle::HI_Spectators)) > 0) {
                // UPDATEBATTLEINFO Spectatorsize locked maphash {mapname}
-               wxString cmd = wxString::Format(_T("%d %d "), 
battle.GetSpectators(), battle.IsLocked());
-               cmd += 
TowxString(LSL::Util::MakeHashSigned(battle.LoadMap().hash) + " ");
-               cmd += TowxString(battle.LoadMap().name);
+               std::string cmd = stdprintf("%d %d %s %s", 
battle.GetSpectators(), battle.IsLocked(),
+                               
LSL::Util::MakeHashSigned(battle.LoadMap().hash).c_str(), 
battle.LoadMap().name.c_str());
 
-               SendCmd("UPDATEBATTLEINFO", STD_STRING(cmd), battle.IsProxy());
+               SendCmd("UPDATEBATTLEINFO", cmd, battle.IsProxy());
        }
        if ((update & IBattle::HI_Send_All_opts) > 0) {
                std::string cmd;
@@ -1992,19 +1991,19 @@ IBattle::GameType IntToGameType(int gt)
 }
 
 // send script.txt to relayhost
-void TASServer::SendScriptToProxy( const std::string& script )
+void TASServer::SendScriptToProxy(const std::string& script)
 {
        LSL::StringVector strings = LSL::Util::StringTokenize(script, "\n");
        int relaylenghtprefix = 10 + 1 + m_relay_host_bot.length() + 2; // 
SAYPRIVATE + space + botname + space + exclamation mark lenght
        int lenght = script.size();
-       lenght += relaylenghtprefix + 11 + 1; // CLEANSCRIPT command size
-       lenght += strings.size() * ( relaylenghtprefix + 16 + 1 ); // num lines 
* APPENDSCRIPTLINE + space command size ( \n is already counted in script.size)
-       lenght += relaylenghtprefix + 9 + 1; // STARTGAME command size
-       const int time = lenght / m_sock->GetSendRateLimit(); // calculate time 
in seconds to upload script
-       DoActionBattle( m_battle_id, stdprintf("is preparing to start the game, 
game will start in approximately %d seconds",time));
+       lenght += relaylenghtprefix + 11 + 1;                    // CLEANSCRIPT 
command size
+       lenght += strings.size() * (relaylenghtprefix + 16 + 1); // num lines * 
APPENDSCRIPTLINE + space command size ( \n is already counted in script.size)
+       lenght += relaylenghtprefix + 9 + 1;                     // STARTGAME 
command size
+       const int time = lenght / m_sock->GetSendRateLimit();    // calculate 
time in seconds to upload script
+       DoActionBattle(m_battle_id, stdprintf("is preparing to start the game, 
game will start in approximately %d seconds", time));
        RelayCmd("CLEANSCRIPT");
 
-       for (const std::string& line: strings) {
+       for (const std::string& line : strings) {
                RelayCmd("APPENDSCRIPTLINE", line);
        }
        RelayCmd("STARTGAME");
diff --git a/src/tasserver.h b/src/tasserver.h
index a1fd765..9cd21ee 100644
--- a/src/tasserver.h
+++ b/src/tasserver.h
@@ -119,7 +119,7 @@ public:
 
        virtual void ExecuteCommand(const std::string& in);
 
-       void SendScriptToProxy( const std::string& script ) override;
+       void SendScriptToProxy(const std::string& script) override;
 
 private:
        void SendUdpSourcePort(int udpport);
diff --git a/src/tests/lslconversion.cpp b/src/tests/lslconversion.cpp
index d0f2e78..815b5cd 100644
--- a/src/tests/lslconversion.cpp
+++ b/src/tests/lslconversion.cpp
@@ -6,7 +6,9 @@
 #include <stdio.h>
 #include "utils/lslconversion.h"
 #include <lslutils/misc.h>
+#include <lslutils/conversion.h>
 #include "user.h"
+#include "utils/conversion.h"
 #include <wx/colour.h>
 
 
@@ -166,3 +168,22 @@ BOOST_AUTO_TEST_CASE(userstatus)
        us.bot = true;
        BOOST_CHECK(us == UserStatus::FromInt(UserStatus::ToInt(us)));
 }
+
+BOOST_AUTO_TEST_CASE(hashes)
+{
+       const unsigned int overflow = 2232970410; //this
+       const int negative = -2147483648;
+
+       BOOST_CHECK("-2061996886" == 
LSL::Util::MakeHashSigned(LSL::Util::ToString(overflow)));
+       BOOST_CHECK(stdprintf("%d", negative) == 
LSL::Util::MakeHashSigned(LSL::Util::ToString(negative)));
+
+       BOOST_CHECK("2232970410" == 
LSL::Util::MakeHashUnsigned(LSL::Util::ToString(overflow)));
+       BOOST_CHECK(stdprintf("%u", negative) == 
LSL::Util::MakeHashUnsigned(LSL::Util::ToString(negative)));
+
+       BOOST_CHECK("2232970410" == LSL::Util::MakeHashUnsigned(stdprintf("%d", 
overflow)));
+       BOOST_CHECK(stdprintf("%u", negative) == 
LSL::Util::MakeHashUnsigned(stdprintf("%d", negative)));
+
+       BOOST_CHECK("2232970410" == LSL::Util::MakeHashUnsigned(stdprintf("%u", 
overflow)));
+       BOOST_CHECK("2147483648" == LSL::Util::MakeHashUnsigned(stdprintf("%u", 
negative)));
+}
+

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/springlobby.git

_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to