Ejemplo n.º 1
0
bool SMOnlineRoom::AddClient(SMOnlineClient *client, const MString& pw, bool ignorePass)
{
    //IN_GAME is the only state that we are not allowed to add clients
    if (m_state == RS_INGAME)
        return false;

    //Check for self
    for (unsigned int i = 0; i < m_clients.size(); ++i)
        if (m_clients[i] == client)
            return false;

    if ( CheckForBan(client) || CheckForKick(client) )
        return false;

    //ignorePass must be false and m_password must not be empty
    if ( !ignorePass && !m_passwd.empty())
        if (pw != m_passwd)
            return false;

    int cnum = m_clients.size();
    m_clients.push_back(client);
    client->SetInRoom(true);
    SendRoomTitle(cnum);
    SendRoomList(cnum);
    PopulatePlayersList();
    SendPlayersList();
    return true;
}
Ejemplo n.º 2
0
void SMOnlineRoom::RemoveClient(const unsigned int index)
{
    if (index >= m_clients.size())
        return;

    if (m_clients[index])
    {
        m_clients[index]->SetInRoom(false);
        m_clients[index] = NULL;
    }
    m_clients.erase(m_clients.begin()+index);
//	LOG->Write("Removed client from room");

    PopulatePlayersList();
    SendPlayersList();
}
BOOL CPagePlayers::OnInitDialog() 
{
  // Register for events of interest
  GetSheet()->GetSession()->ActivateEvents(EventID_GameCreated, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_GameDestroyed, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_LoginGame, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_LogoutGame, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_ShipChangesSectors, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_LeaveTeam, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_JoinTeam, -1);
  GetSheet()->GetSession()->ActivateEvents(EventID_TeamInfoChange, -1);

  // Perform default processing
  CPropertyPage::OnInitDialog();

  // Initialize the AutoSize object
  m_AutoSizer.SetWindowAndRules(*this, _AutoSizerMap);

  // Set the list view control extended styles
  DWORD dwExStyle = LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP;
  m_listPlayers.SetExtendedStyle(dwExStyle);

  // Add columns to the list view control
  m_listPlayers.InsertColumn(c_iColumnName  , CString((LPCSTR)IDS_COLUMN_PLAYER));
  m_listPlayers.InsertColumn(c_iColumnTeam  , CString((LPCSTR)IDS_COLUMN_TEAM  ));
  m_listPlayers.InsertColumn(c_iColumnSector, CString((LPCSTR)IDS_COLUMN_SECTOR));

  // Load previous values from registry
  LoadFromRegistry();

  // Update fields from data members
  UpdateData(false);

  // Update the UI
  UpdateUI();

  // Populate the list of players
  PopulatePlayersList();

  // Set the focus to the first tabstop control
  return true;
}