Official eMule-Board: Serverlistctrl And Ip Filters. - Official eMule-Board

Jump to content


Page 1 of 1

Serverlistctrl And Ip Filters. Show a Server is blocked by IP Filtlers!

#1 User is offline   BlueSonicBoy 

  • Magnificent Member
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 396
  • Joined: 26-September 04

Posted 20 December 2005 - 09:26 PM

I have been looking at the IP Filter code and I noticed that although the IP Filter code blocks servers whose IPs are in the IP Filter list, ( :+1: ); the server will still appear in the servers list like any other good available server!!

The fix is simple. In eMule 46c, in ServerListCtrl.cpp

ServerListCtrl.cpp said:

#include "IPFilter.h" 

and in the vanilla eMule 46c, in void CServerListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *plResult)

void CServerListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, on LRESULT *plResult), said:

if (pnmlvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
  const CServer* pServer = (const CServer*)pnmlvcd->nmcd.lItemlParam;
  const CServer* pConnectedServer = theApp.serverconnect->GetCurrentServer();
  // the server which we are connected to always has a valid numerical IP member assigned,
  // therefor we do not need to call CServer::IsEqual (which is little expensive)
  //if (pConnectedServer && pConnectedServer->IsEqual(pServer))

  if (pConnectedServer && pConnectedServer->GetIP() == pServer->GetIP() && pConnectedServer->GetPort() == pServer->GetPort())
  pnmlvcd->clrText = RGB(32,32,255);
  else if (pServer->GetFailedCount() >= thePrefs.GetDeadServerRetries() || theApp.ipfilter->IsFiltered(pServer->GetIP()))
  pnmlvcd->clrText = RGB(192,192,192);
  else if (pServer->GetFailedCount() >= 2)
  pnmlvcd->clrText = RGB(128,128,128);
}

However, I had recently added IP to Country to my TK4 Mod, copying the code from the eXtreme Mod ,(via Tombstone!). When implementing the above fix I found it would not work as above in the altered ServerListCtrl.cpp code! I believe the additional DrawItem() overrides the reflected message handler OnNMCustomdraw()

If this is the case then the indication of dead servers will be lost in mods using this code? Morph??, eXtreme etc? :flowers:

To fix this in void CServerListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) (below is based on the eXtreme Mod variant.)

void CServerListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) said:

//RECT cur_rec = lpDrawItemStruct->rcItem; //MORPH - Moved by SiRoB, Don't draw hidden Rect
COLORREF crOldTextColor = dc.SetTextColor(m_crWindowText);
   
//TK4 Mod
LOGFONT lfFont;
CFont fontCustom;

//Xman our server in blubold
  if(theApp.serverconnect->IsConnected()
  && (cur_srv = theApp.serverconnect->GetCurrentServer()) != NULL
  && cur_srv->GetPort() == server->GetPort()
  //&& cur_srv->GetConnPort() == server->GetConnPort()//Morph - added by AndCycle, aux Ports, by lugdunummaster
  && _tcsicmp(cur_srv->GetAddress(), server->GetAddress()) == 0)
    {  //it's our server
      GetFont()->GetLogFont(&lfFont);
      lfFont.lfWeight = FW_BOLD;
      fontCustom.CreateFontIndirect(&lfFont);
      dc.SelectObject(&fontCustom);
      dc->SetTextColor(RGB(0,0,192));
      }//Xman end
        else //TK4 Mod grey out Filtered servers or Dead servers
              if(server->GetFailedCount() >= thePrefs.GetDeadServerRetries() || theApp.ipfilter->IsFiltered(server->GetIP()))
                {
                    GetFont()->GetLogFont(&lfFont);
                    fontCustom.CreateFontIndirect(&lfFont);
                    dc.SelectObject(&fontCustom);
                    dc->SetTextColor(RGB(192,192,192));
                  } else if(server->GetFailedCount() >= 2)
                              {
//unreliable servers
                                GetFont()->GetLogFont(&lfFont);
                                fontCustom.CreateFontIndirect(&lfFont);
                                dc.SelectObject(&fontCustom);
                                dc->SetTextColor(RGB(128,128,128));
                                }

   

int iOldBkMode;


[EDIT] BTW in the above case I think OnNMCustomdraw() is redundant and can safely be removed! :)

Thanks for reading! :thumbup:

This post has been edited by BlueSonicBoy: 20 December 2005 - 10:09 PM

0

#2 User is offline   Xman1 

  • Xtreme Modder
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1955
  • Joined: 21-June 03

Posted 30 December 2005 - 08:42 PM

Quote

I believe the additional DrawItem() overrides the reflected message handler OnNMCustomdraw()

you are right! big thanks for the code .. never noticed that we used a code-part which is useless.
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users