Пример #1
0
wxString MD5SUM(const wxString& Input)
{
	std::string str = MD5SUM(Input.char_str(), Input.Len());

	return stdstr_towxstr(str);
}
Пример #2
0
/*
    Takes a server structure and adds it to the list control
    if insert is 1, then add an item to the list, otherwise it will
    update the current item with new data
*/
void LstOdaServerList::AddServerToList(const Server &s, 
                                        wxInt32 index, 
                                        bool insert)
{
    wxFileConfig ConfigInfo;
    wxInt32 PQGood, PQPlayable, PQLaggy;
    
    wxInt32 i = 0;
    wxListItem li;
    
    wxUint64 Ping = 0;
    wxString GameType = wxT("");
    size_t WadCount = 0;
    
    li.m_mask = wxLIST_MASK_TEXT;

    if (insert)
    {
        li.m_itemId = ALCInsertItem();
    }
    else
    {
        // All cells must be cleared on a "replace" operation, otherwise if the 
        // server failed to respond a second time 'round, we would end up with 
        // some stale data (which is highly dependent on the response check 
        // below)
        ClearItemCells(index);
        
        li.m_itemId = index;
    }
       
    // Address column
    li.m_col = serverlist_field_address;    
    li.m_text = stdstr_towxstr(s.GetAddress());

    SetItem(li);

    // break here so atleast we have an ip address to go by
    if (s.GotResponse() == false)
        return;

    // Server name column
    li.m_col = serverlist_field_name;
    li.m_text = stdstr_towxstr(s.Info.Name);
       
    SetItem(li);
      
    // Ping column
    Ping = s.GetPing();

    li.m_col = serverlist_field_ping;
    li.m_text = wxString::Format(_T("%llu"), Ping);

    SetItem(li);

    // Number of players, Maximum players column
    // TODO: acquire max players, max clients and spectators from these 2 and
    // create some kind of graphical column maybe
    li.m_col = serverlist_field_players;
    li.m_text = wxString::Format(_T("%d/%d"),s.Info.Players.size(),s.Info.MaxClients);
    
    // Colour the entire text column (wx/windows bug - exploited) if there are
    // players
    // TODO: Allow the user to select prefered colours
    if (s.Info.Players.size())
        li.SetTextColour(wxColor(0,192,0));

    SetItem(li); 
    
    // WAD files column
    WadCount = s.Info.Wads.size();
    
    // build a list of pwads
    if (WadCount)
    {
        // pwad list
        std::string wadlist;
        std::string pwad;
            
        for (i = 2; i < WadCount; ++i)
        {
            pwad = s.Info.Wads[i].Name.substr(0, s.Info.Wads[i].Name.find('.'));
            
            wadlist.append(pwad);
            wadlist.append(" ");
        }
            
        li.m_col = serverlist_field_wads;
        li.m_text = stdstr_towxstr(wadlist);
    
        SetItem(li);
    }

    // Map name column
    li.m_col = serverlist_field_map;
    li.m_text = stdstr_towxstr(s.Info.CurrentMap).Upper();
    
    SetItem(li);
       
    // Game type column
    switch (s.Info.GameType)
    {
        case GT_Cooperative:
        {
            // Detect a single player server
            if (s.Info.MaxPlayers > 1)
                GameType = wxT("Cooperative");
            else
                GameType = wxT("Single Player");
        }
        break;
        
        case GT_Deathmatch:
        {
            GameType = wxT("Deathmatch");
        }
        break;
        
        case GT_TeamDeathmatch:
        {
            GameType = wxT("Team Deathmatch");
        }
        break;
        
        case GT_CaptureTheFlag:
        {
            GameType = wxT("Capture The Flag");
        }
        break;
        
        default:
        {
            GameType = wxT("Unknown");
        }
        break;
    }
    
    li.m_col = serverlist_field_type;
    li.m_text = GameType;
    
    SetItem(li);

    // IWAD column
    if (WadCount)
    {
        std::string iwad;
        iwad = s.Info.Wads[1].Name.substr(0, s.Info.Wads[1].Name.find('.'));
        
        li.m_col = serverlist_field_iwad;
        li.m_text = stdstr_towxstr(iwad);
    }
    
    SetItem(li);
    
    // Icons
    // -----
    
    // Padlock icon for passworded servers
    SetItemColumnImage(li.m_itemId, serverlist_field_name, 
        (s.Info.PasswordHash.length() ? ImageList_Padlock : -1));
    
    ConfigInfo.Read(wxT("IconPingQualityGood"), &PQGood, 150);
    ConfigInfo.Read(wxT("IconPingQualityPlayable"), &PQPlayable, 300);
    ConfigInfo.Read(wxT("IconPingQualityLaggy"), &PQLaggy, 350);
    
    // Coloured bullets for ping quality
    if (Ping < PQGood)
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingGreen);
    }
    else if (Ping < PQPlayable)
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingOrange);
    }
    else if (Ping < PQLaggy)
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingRed);
    }
    else
    {
        SetItemColumnImage(li.m_itemId, serverlist_field_ping, 
            ImageList_PingGray);
    }
}
Пример #3
0
void LstOdaSrvDetails::LoadDetailsFromServer(Server &In)
{   
    DeleteAllItems();
    DeleteAllColumns();
    
    if (In.GotResponse() == false)
        return;
    
    // Begin adding data to the control   
    
    // Set the initial background colour
    BGItemAlternator = *wxWHITE;
    
    InsertColumn(srvdetails_field_name, wxT(""), wxLIST_FORMAT_LEFT, 150);
    InsertColumn(srvdetails_field_value, wxT(""), wxLIST_FORMAT_LEFT, 150);
    
    // Version
    InsertLine(wxT("Version"), wxString::Format(wxT("%u.%u.%u-r%u"), 
                                In.Info.VersionMajor, 
                                In.Info.VersionMinor, 
                                In.Info.VersionPatch,
                                In.Info.VersionRevision));
    
    InsertLine(wxT("QP Version"), wxString::Format(wxT("%u"), 
        In.Info.VersionProtocol));

    // Status of the game 
    InsertLine(wxT(""), wxT(""));                            
    InsertHeader(wxT("Game Status"), wxRED, wxWHITE);
    
    InsertLine(wxT("Time left"), wxString::Format(wxT("%u"), In.Info.TimeLeft));
    
    if (In.Info.GameType == GT_TeamDeathmatch || 
        In.Info.GameType == GT_CaptureTheFlag)
    {
        InsertLine(wxT("Score Limit"), wxString::Format(wxT("%u"), 
            In.Info.ScoreLimit));
    }
    
    // Patch (BEX/DEH) files
    InsertLine(wxT(""), wxT(""));                            
    InsertHeader(wxT("BEX/DEH Files"), wxRED, wxWHITE);
    
    if (In.Info.Patches.size() == 0)
    {
        InsertLine(wxT("None"), wxT(""));
    }
    else
    {
        size_t i = 0;
        size_t PatchesCount = In.Info.Patches.size();
        
        wxString Current, Next;
                
        // A while loop is used to format this correctly
        while (i < PatchesCount)
        {           
            Current = stdstr_towxstr(In.Info.Patches[i]);
            
            ++i;
            
            if (i < PatchesCount)
                Next = stdstr_towxstr(In.Info.Patches[i]);
            
            ++i;
            
            InsertLine(Current, Next);
            
            Current = wxT("");
            Next = wxT("");
        }
    }
    
    // Gameplay variables (Cvars, others)
    InsertLine(wxT(""), wxT(""));                            
    InsertHeader(wxT("Game Settings"), wxRED, wxWHITE);

    // Sort cvars ascending
    sort(In.Info.Cvars.begin(), In.Info.Cvars.end(), CvarCompare);
    
    for (size_t i = 0; i < In.Info.Cvars.size(); ++i)
        InsertLine(stdstr_towxstr(In.Info.Cvars[i].Name), stdstr_towxstr(In.Info.Cvars[i].Value));

    // Resize the columns
    ResizeNameValueColumns();
}