Permalink
Browse files

Receive client lobby ID

  • Loading branch information...
MasterBel2
MasterBel2 committed Sep 6, 2018
1 parent 60bd46e commit 7da4a2ff762012a341cfe1449bb7c029ffe17422
@@ -32,6 +32,7 @@ NickDataViewCtrl::NickDataViewCtrl(const wxString& dataViewName, wxWindow* paren
AppendBitmapColumn(_("c"), COUNTRY, wxDATAVIEW_CELL_INERT, wxDVC_DEFAULT_MINWIDTH, wxALIGN_CENTER, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
AppendBitmapColumn(_("r"), RANK, wxDATAVIEW_CELL_INERT, wxDVC_DEFAULT_MINWIDTH, wxALIGN_CENTER, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
AppendTextColumn(_("Nickname"), NICKNAME, wxDATAVIEW_CELL_INERT, wxDVC_DEFAULT_WIDTH + 10 /*add 10 px to let some nicks to fit better*/, wxALIGN_NOT, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
AppendTextColumn(_("Lobby client"), LOBBYAGENT, wxDATAVIEW_CELL_INERT, wxDVC_DEFAULT_WIDTH + 10 /*add 10 px to let some nicks to fit better*/, wxALIGN_NOT, wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);

if (!show_header) {
//TODO: implement "no header" style somehow
@@ -59,7 +59,8 @@ class NickDataViewCtrl : public BaseDataViewCtrl<User>
STATUS = 0,
COUNTRY,
RANK,
NICKNAME
NICKNAME,
LOBBYAGENT
};

DECLARE_EVENT_TABLE()
@@ -36,6 +36,7 @@ void NickDataViewModel::GetValue(wxVariant& variant, const wxDataViewItem& item,
break;

case NICKNAME:
case LOBBYAGENT:
case DEFAULT_COLUMN:
default:
variant = wxVariant(wxEmptyString);
@@ -84,6 +85,10 @@ void NickDataViewModel::GetValue(wxVariant& variant, const wxDataViewItem& item,
}
break;

case LOBBYAGENT:
variant = wxString(user->GetClientAgent());
break;

case DEFAULT_COLUMN:
//Do nothing
break;
@@ -158,6 +163,10 @@ int NickDataViewModel::Compare(const wxDataViewItem& itemA,
sortingResult = 0;
break;

case LOBBYAGENT:
sortingResult = BaseDataViewModel::Compare(itemA, itemB, column, true);
break;

default:
wxASSERT(false);
sortingResult = 0;
@@ -201,6 +210,7 @@ wxString NickDataViewModel::GetColumnType(unsigned int column) const
break;

case NICKNAME:
case LOBBYAGENT:
case DEFAULT_COLUMN:
colTypeString = COL_TYPE_TEXT;
break;
@@ -23,6 +23,7 @@ class NickDataViewModel : public BaseDataViewModel<User>
COUNTRY,
RANK,
NICKNAME,
LOBBYAGENT,
COLUMN_COUNT
};
};
@@ -125,7 +125,7 @@ void ServerEvents::OnPong(wxLongLong ping_time)
}


void ServerEvents::OnNewUser(const std::string& nick, const std::string& country, int cpu, int id)
void ServerEvents::OnNewUser(const std::string& nick, const std::string& country, int cpu, int id, const std::string& clientAgent)
{
slLogDebugFunc("");
if (m_serv.UserExists(nick)) {
@@ -136,6 +136,7 @@ void ServerEvents::OnNewUser(const std::string& nick, const std::string& country
user.SetCountry(country);
user.SetCpu(cpu);
user.SetID(id);
user.SetClientAgent(clientAgent);
if (!m_serv.IsOnline()) { //login info isn't complete yet
return;
}
@@ -44,7 +44,7 @@ class ServerEvents
void OnMotd(const std::string& msg);
void OnPong(wxLongLong ping_time);

void OnNewUser(const std::string& nick, const std::string& conutry, int cpu, int id);
void OnNewUser(const std::string& nick, const std::string& conutry, int cpu, int id, const std::string& clientAgent);
void OnUserStatus(const std::string& nick, UserStatus status);
void OnUserQuit(const std::string& nick);

@@ -573,7 +573,8 @@ void TASServer::ExecuteCommand(const std::string& cmd, const std::string& inpara
} else {
id = GetIntParam(params);
}
m_se->OnNewUser(nick, contry, cpu, id);
// params contains user's lobby client and version.
m_se->OnNewUser(nick, contry, cpu, id, params);
if (nick == m_relay_host_bot) {
RelayCmd("OPENBATTLE", m_delayed_open_command); // relay bot is deployed, send host command
m_delayed_open_command = "";
@@ -212,10 +212,12 @@ class CommonUser
m_nick = nick;
}

const std::string& GetClientAgent() const { return m_client_agent; }
const std::string& GetCountry() const
{
return m_country;
}
void SetClientAgent(const std::string& ca) { m_client_agent = ca; }
virtual void SetCountry(const std::string& country)
{
m_country = country;
@@ -292,6 +294,7 @@ class CommonUser

private:
std::string m_nick;
std::string m_client_agent;
std::string m_country;
int m_id;
int m_cpu;

0 comments on commit 7da4a2f

Please sign in to comment.