Author Topic: Feature: Player Search Function in Serverbrowser  (Read 19185 times)

FlaMe

  • Autococker
  • Posts: 601
Feature: Player Search Function in Serverbrowser
« on: January 06, 2008, 04:47:22 PM »
Customizable skins.? I swear i open serverbrowser more times than i open up DP.

Search function - search for partial names somehow connected to the GLS so you can search your clan tag or player names to see if someones on

Remove the annoying beep when you refresh?

Changeable fonts?

And the one in-game is quite bad tbh
...you cant see the port numbers on the diff servers.
maybe a smaller font/bigger window
« Last Edit: January 06, 2008, 10:58:14 PM by y00tz »

KiLo

  • Autococker
  • Posts: 2086
Re: Feature: Enhanced Server Browser
« Reply #1 on: January 06, 2008, 04:52:32 PM »
Are you talking something like the All-Seeing Eye?

I don't get a beep.

Menu widgets will help fix seeing the server port and what not.

FlaMe

  • Autococker
  • Posts: 601
Re: Feature: Enhanced Server Browser
« Reply #2 on: January 06, 2008, 04:54:28 PM »
well I hate when someone says GT match 3, and i cant see which one that is without opening up serverbrowser.exe

maybe the server admins could just shorten the names of their servers orrrr

we get a smaller in-game font with the ability to ignore servers or cancel their pings so i dont have to see the n00by jump servers on my list.

KiLo

  • Autococker
  • Posts: 2086
Re: Feature: Enhanced Server Browser
« Reply #3 on: January 06, 2008, 04:56:31 PM »
What you don't like the high piniging leezerz.com jump server?

FlaMe

  • Autococker
  • Posts: 601
Re: Feature: Enhanced Server Browser
« Reply #4 on: January 06, 2008, 04:59:15 PM »
i meant more like the aussie servers

i have login to the Leezerz servers... so i dont mind them...

i mean the home run n00b servers run off a german lan 56k

Garrett

  • Autococker
  • Posts: 1372
Re: Feature: Enhanced Server Browser
« Reply #5 on: January 06, 2008, 05:08:16 PM »
Could this also include the in-game server browser.  The search feature would be nice along with Zorch's menus.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18801
Re: Feature: Enhanced Server Browser
« Reply #6 on: January 06, 2008, 10:51:31 PM »
You're going to need to make more specific feature requests so people can vote for/against the ones they like/don't like.  I'm not keen on skins, for example.  They just add bloat.  If you want it to look different, change your windows theme.

FlaMe

  • Autococker
  • Posts: 601
Re: Feature: Enhanced Server Browser
« Reply #7 on: January 06, 2008, 10:52:28 PM »
i just want a search player function as well as an ignore function.

Garrett

  • Autococker
  • Posts: 1372
Re: Feature: Enhanced Server Browser
« Reply #8 on: January 06, 2008, 10:53:57 PM »
A player search button and Zorch's password fill in window seems to be the only wanted feature.

y00tz

  • Autococker
  • Posts: 2742
Re: Feature: Enhanced Server Browser
« Reply #9 on: January 06, 2008, 10:54:26 PM »
An ignore function does not seem worth the effort at all, just don't join it.

FlaMe

  • Autococker
  • Posts: 601
Re: Feature: Enhanced Server Browser
« Reply #10 on: January 06, 2008, 10:55:49 PM »
ok fine... ignore my original post and rename this thread "Feature: Player Search Function in Serverbrowser"

Garrett

  • Autococker
  • Posts: 1372
Re: Feature: Enhanced Server Browser
« Reply #11 on: January 06, 2008, 10:57:15 PM »
and in game because some people don't use the server browser. 

jitspoe

  • Administrator
  • Autococker
  • Posts: 18801

Eiii

  • Autococker
  • Posts: 4595
Re: Feature: Player Search Function in Serverbrowser
« Reply #13 on: January 07, 2008, 01:34:49 AM »
I just updated my old serverbrowser code to search for players as well. Of course, it doesn't have a GUI, and needs a tiny bit more tweaking, but hey. I'll put it out tomorrow.

f3l1x

  • Committee Member
  • VM-68
  • Posts: 213
Re: Feature: Player Search Function in Serverbrowser
« Reply #14 on: April 12, 2011, 04:32:44 PM »
How different is implement it to new version of server browser.. i think SB works now pretty good and some search function could be helpful.

xrichardx

  • 68 Carbine
  • Posts: 295
Re: Feature: Player Search Function in Serverbrowser
« Reply #15 on: February 05, 2014, 07:47:17 PM »
This is my try for a player search function. I will append my serverbrowser.exe, to see the dialog press CTRL + F. It's at least working on my machine.
The file size has increased drastically, probably because my compiler likes to link statically while microsofts does it dynamically for common libraries. I did not link any more libraries nor include any other files, i just used all the things that were used in the program before so when compiling with the MS compiler the file should again be as small as it used to be.

Screenshot:


Edit: Added a patch for the csv repository 2 posts below.
About the code: I marked everything I edited with "//Edit by Richard" and I will also write down all changes here so it should be easy to apply my changes to other files. One problem is that I use another IDE and another compiler and therefore also needed to do some adaptions to other parts of the code (mostly replace snprintf_s with snprintf), so if anyone wanted to use this he or she probably has to copy the parts I changed manually. The other problem is that I don't know how other people like to organize their source code, so I can't tell for sure where to put declarations and implementations. But I will append my project folder as a zip file so everyone who wants can download the complete source. (Used IDE: CodeBlocks; Compiler: TDM-GCC-64 V4.8 ). Also, I will write down all my changes in this post hoping it will be easy to apply / copy this.

The basic function is (I put this in serverbrowser.cpp, to the end of the file):
Code: [Select]
//Edit by Richard
//__IN_ sName is the name to search for
//_OUT_ vFound is a vector of a pair containing 1. the key value of the server in g_mServers
// where the player is playing
// and 2. his index in the vPlayers vector
void SearchPlayer(std::string sName, std::vector < std::pair<std::string, int> > * vFound)
{
vFound->clear(); //clear the vector we'll write in
for(int i = 0; sName[i]; i++){
sName[i] = tolower(sName[i]);
}
//make the name we search for lowercase so the search is case insensitive
std::string sPlayerNameCopy;

for (g_mServers_iterator_t iServer = g_mServers.begin(); iServer != g_mServers.end(); iServer++) //loop through all servers
{
for (int iPlayer = 0; iPlayer < iServer->second.vPlayers.size(); iPlayer++) //loop through all players
{
sPlayerNameCopy.assign(iServer->second.vPlayers[iPlayer].sName);
for(int i = 0; sPlayerNameCopy[i]; i++){
sPlayerNameCopy[i] = tolower(sPlayerNameCopy[i]);
}
//also transform the players name to lowercase

if ((sName.length() == 0) or (sPlayerNameCopy.find(sName) != std::string::npos))
//if playername contains the name we're searching for or sName is empty
{
vFound->push_back(std::pair<std::string, int>(iServer->first, iPlayer));
}
}
}
}
this function needs one typedef, I put it in the header of serverbrowser.cpp:
Code: [Select]
//Edit by Richard
typedef std::map<std::string, serverinfo_t>::iterator g_mServers_iterator_t;

I also declared this function in serverbrowser.h so I can use it in the GUI.cpp:
Code: [Select]
//Edit by Richard
void SearchPlayer(std::string, std::vector < std::pair<std::string, int> > *);

To implement the GUI I used a simple dialog resource. Therefore, some things need to be defined in resource.h:
Code: [Select]
//Edit by Richard
#define IDM_SEARCHPLAYER 32778

#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDD_SEARCHPLAYER 32779
#define IDC_SP_EDIT 32780
#define IDC_SP_LIST 32781
The numbers should be exchangeable as long as they are not used somewhere else in the program.

The dialog itself (I only created it in english until now, so I made it language neutral):
Code: [Select]
//Edit by Richard
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_SEARCHPLAYER DIALOG 0, 0, 180, 249
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Player Search"
FONT 8, "Ms Shell Dlg"
{
    DEFPUSHBUTTON   "OK", IDOK, 123, 228, 50, 14
    LTEXT           "Please enter the player's name:", IDC_STATIC, 7, 7, 132, 8, SS_LEFT
    EDITTEXT        IDC_SP_EDIT, 7, 20, 166, 14, ES_AUTOHSCROLL
    LISTBOX         IDC_SP_LIST, 7, 62, 166, 161, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_SORT | LBS_NOTIFY
    LTEXT           "Results: ", IDC_STATIC, 7, 49, 132, 8, SS_LEFT
}

And, of course, the keyboard shortcut needs to be added to the accelerators, I also did this at the top of the file in a languagye unspecific location just for testing:
Code: [Select]
//Edit by Richard
IDC_SERVERBROWSER ACCELERATORS
BEGIN
    "F", IDM_SEARCHPLAYER, VIRTKEY, CONTROL, NOINVERT
END


And, finally, changes to the serverbrowserGUI.cpp:
First, i forward declared a callback function:
EDIT: The mFound_iterator_t typedef is not needed. I used to give back results drom SearchPlayer() in a map but then changed it to a vector where an iterator is not needed anymore!
Code: [Select]
//Edit by Richard
//typedef std::map<std::string, int>::iterator mFound_iterator_t; //not necessary!
static LRESULT CALLBACK SearchPlayerDlg (HWND, UINT, WPARAM, LPARAM);

Then, the message by the accelerator needs to be handeled, so this is put into the "OnCommand" function into the switch:
Code: [Select]
//Edit by Richard
case IDM_SEARCHPLAYER:
DialogBox(g_hInst, (LPCTSTR)IDD_SEARCHPLAYER, hWnd, (DLGPROC)SearchPlayerDlg);
return TRUE;


And this is the callback function for the dialog:
Code: [Select]
//Edit by Richard
//Message handler for Player Search Dialog
static LRESULT CALLBACK SearchPlayerDlg (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_SP_EDIT, EN_CHANGE), (LPARAM) GetDlgItem(hDlg, IDC_SP_EDIT));
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if ((LOWORD(wParam) == IDC_SP_EDIT) and (HIWORD(wParam) == EN_CHANGE))
{
std::string sContentBuffer;
char szNameBuffer[GetWindowTextLength(GetDlgItem(hDlg, IDC_SP_EDIT)) + 1];
std::vector <std::pair<std::string, int> > vFound;

SendMessage(GetDlgItem(hDlg, IDC_SP_LIST), LB_RESETCONTENT, 0, 0);

GetWindowText(GetDlgItem(hDlg, IDC_SP_EDIT), szNameBuffer,
sizeof(szNameBuffer) / sizeof (szNameBuffer[0]));
SearchPlayer(szNameBuffer, &vFound);
for (int i = 0; i < vFound.size(); i++)
{
sContentBuffer.assign(g_mServers[vFound[i].first].vPlayers[vFound[i].second].sName);
sContentBuffer.append (" on ");
sContentBuffer.append (g_mServers[vFound[i].first].sHostName);
int index = SendMessage(GetDlgItem(hDlg, IDC_SP_LIST), LB_ADDSTRING,
0, (LPARAM) sContentBuffer.c_str());
//maybe needed to determine the selected list box item later:
//SendMessage(GetDlgItem(hDlg, IDC_SP_LIST), LB_SETITEMDATA, index, i);
}
return TRUE;
}
break;
}

    return FALSE;
}

Hoping that this helps,
Richard
« Last Edit: February 06, 2014, 11:20:14 AM by xrichardx »

not_payl_obviously

  • 68 Carbine
  • Posts: 415
Re: Feature: Player Search Function in Serverbrowser
« Reply #16 on: February 06, 2014, 05:13:24 AM »
Not bad richard, but I'm hater here so let me hate a bit:
1.Your comments are bit awful, example: vFound->clear(); //clear the vector we'll write in//ORLY?
If you want to comment your code, don't repeat what instruction does, it's beginner mistake.
2.In current state, it's not really useful: I would like if it had asterix and question mark support to make searching easier. Also if you click on listbox, you should be moved on server list to that server and player.

Still, I approve of your job, but this serverbrowser is missing functionality like friend status me and rocklitude have with ours serverbrowsers.
Also, if you modified source, and this project is on SVN, you should generate patch rather than send whole source.

xrichardx

  • 68 Carbine
  • Posts: 295
Re: Feature: Player Search Function in Serverbrowser
« Reply #17 on: February 06, 2014, 05:35:14 AM »
2.In current state, it's not really useful: I would like if it had asterix and question mark support to make searching easier. Also if you click on listbox, you should be moved on server list to that server and player.
For things like asterisk support: nice idea, I also thought about it, but to accomplish it you would require a regex function, which is only included in C++11 or other libraries (e.g. boost) and i don't know wheter jitspoe would like to use these...
About the OnClick events: Yes, that's a good idea and should also be doable, but first I wanted to check what other people think about this. If the only response I get is: "We already got serverbrowsers which are much better that the default one" then I'm not going to spend time on improving the default one..

not_payl_obviously

  • 68 Carbine
  • Posts: 415
Re: Feature: Player Search Function in Serverbrowser
« Reply #18 on: February 06, 2014, 05:43:36 AM »
For things like asterisk support: nice idea, I also thought about it, but to accomplish it you would require a regex function, which is only included in C++11 or other libraries (e.g. boost)
Or you can just write your version, if there isn't mass of such code on internet. It's simple... Yet it will be harder to extend.
but first I wanted to check what other people think about this. If the only response I get is: "We already got serverbrowsers which are much better that the default one" then I'm not going to spend time on improving the default one..
Well, I haven't got any request for my serverbrowser, so I guess people are mostly used and happy with default serverbrowser in it current state or use built-in serverbrowser. At least thats what I suppose.

xrichardx

  • 68 Carbine
  • Posts: 295
Re: Feature: Player Search Function in Serverbrowser
« Reply #19 on: February 06, 2014, 09:12:46 AM »
Also, if you modified source, and this project is on SVN, you should generate patch rather than send whole source.
I can not find a SVN repository... Do you mean CSV? http://paintball2.cvs.sourceforge.net/viewvc/paintball2/serverbrowser/
Well, here's the patch, created with TortoiseCSV. It also contains some changes where i didn't change anything because my IDE trims spaces at the end of a line.

Or you can just write your version, if there isn't mass of such code on internet. It's simple... Yet it will be harder to extend.
Well, I haven't got any request for my serverbrowser, so I guess people are mostly used and happy with default serverbrowser in it current state or use built-in serverbrowser. At least thats what I suppose.
My question is: do you really need something like an asterisk that matches every string? I mean, when i open up the dialog right now and want to check if a player with the name "payl" is playing,
just entering "p"      gives 9 results
just entering "pa"   gives 1 result
and entering "pay"   gives 0 results
So who would use such a feature?
« Last Edit: February 06, 2014, 11:20:27 AM by xrichardx »