(suggestion) Filter Search in server list

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
Post Reply
User avatar
Titanoboa
Reverse Outside Corner Grinder
Posts: 1791
Joined: Sun Feb 22, 2009 8:07 pm

(suggestion) Filter Search in server list

Post by Titanoboa »

Maybe you've thought of this and it's difficult or (currently) impossible to implement, and therefore haven't done it. That seems likely.

Maybe you just haven't thought of it and it turns out it's super easy to implement. Wouldn't that be neat.


The suggestion: with the server list open, you'd be able to type in "Crazy" into some text field, and filter out any servers without that letter combination in its name. Or "sumo" if you're looking for a server containing that word. Or fortress, or dogfight, or ladle. You get the gist.

I think that would be useful and wildly popular among users. However, I can't dream of doing it myself and I understand if nobody else can or wants to either. Just thought I'd bring it up.

Thanks for reading!

User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: (suggestion) Filter Search in server list

Post by Jip »

I got some time today and tried to implement it. The only thing I didn't get to work is the correct filtering. I tried it like this:

Code: Select all

        if(filter_string.Len() > 1)
        {
            tString name;
            name << tColoredString::RemoveColors( run->GetName(), false );
            run->show = false;
            oneFound = true;
            
            if(name.ToLower().StrPos(filter_string) >= 0)
            {
                run->show = true;
            }
        }
filter_string is already the search term to lower case.

But somehow it doesn't work correctly (see screenshot). Any ideas?
Attachments
Bildschirmfoto6.png

User avatar
Light
Reverse Outside Corner Grinder
Posts: 1664
Joined: Thu Oct 20, 2011 2:11 pm

Re: (suggestion) Filter Search in server list

Post by Light »

This worked for me, Jip. I don't know how to make your filter input though, so maybe it'll help?

Code: Select all

tString filter_string;
filter_string = "light";

if (filter_string.Len() > 0)
{
	run = gServerInfo::GetFirstServer();
	{
		while (run)
		{
			tString name;
			name << tColoredString::RemoveColors(run -> GetName(), false);
			boost::algorithm::to_lower(name);
			
			run -> show = false;
			oneFound = true;
			
			if (name.find(filter_string) != std::string::npos)
			{
				run -> show = true;
			}
			
			run = run -> Next();
		}
	}
}
Of course, we have to include the boost algorithm to that file for the to_lower() function I used.

Code: Select all

#include <boost/algorithm/string.hpp>
When I don't use to_lower() on the server name I get HFT as my only result, which seems weird, but whatever ... Using to_lower() gives expected results.

User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: (suggestion) Filter Search in server list

Post by Jip »

Thanks, the line

Code: Select all

if (name.find(filter_string) != std::string::npos)
made it work.

I got it working but I have the feeling, that it is quite a hack. Could someone have a look over it and tell me what can be done better? I will make a pull request (doh! no github) bug report with attached patch.

Patch to look over is attached.
Attachments
browser_filter.patch.not.zip
(6.03 KiB) Downloaded 87 times

User avatar
Light
Reverse Outside Corner Grinder
Posts: 1664
Joined: Thu Oct 20, 2011 2:11 pm

Re: (suggestion) Filter Search in server list

Post by Light »

It works. :)

I did get this ..

Code: Select all

[email protected]:~/armagetronad/src$ patch language/english_base.txt < browser_filter.patch 
patching file language/english_base.txt
patching file language/english_base.txt
Hunk #1 FAILED at 114.
Hunk #2 FAILED at 128.
Hunk #3 FAILED at 154.
Hunk #4 FAILED at 315.
Hunk #5 FAILED at 332.
Hunk #6 FAILED at 342.
Hunk #7 FAILED at 432.
Hunk #8 FAILED at 446.
Hunk #9 FAILED at 521.
Hunk #10 FAILED at 564.
Hunk #11 FAILED at 799.
Hunk #12 FAILED at 996.
Hunk #13 succeeded at 967 with fuzz 2 (offset -43 lines).
Hunk #14 FAILED at 1076.
13 out of 14 hunks FAILED -- saving rejects to file language/english_base.txt.rej
Not sure what may have gone wrong, but it was written.

Code: Select all

network_master_filter Filter:
Maybe this wasn't for the 0.4 client? The other file was written with all success though, so the more important part is fine. Should I send a patch to launchpad? I feel like we're going to have a much better chance of seeing this come up in 0.4 than 0.2.

User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: (suggestion) Filter Search in server list

Post by Jip »

Are you patching against current trunk?
I will post the patch on launchpad when we have some feedback from the devs.

User avatar
Light
Reverse Outside Corner Grinder
Posts: 1664
Joined: Thu Oct 20, 2011 2:11 pm

Re: (suggestion) Filter Search in server list

Post by Light »

Jip wrote:Are you patching against current trunk?
I will post the patch on launchpad when we have some feedback from the devs.
Oh yeah .. The copy I have built atm is from the weekly builds and not the latest launchpad. That could be it.

User avatar
Light
Reverse Outside Corner Grinder
Posts: 1664
Joined: Thu Oct 20, 2011 2:11 pm

Re: (suggestion) Filter Search in server list

Post by Light »

Would just like to bump this and maybe get a comment from a dev? It would be nice to see this added, and the patch is there ready to go, unless you wanted to clean it up some. I think this is a very good feature to add to the client.

User avatar
Z-Man
God & Project Admin
Posts: 11424
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: (suggestion) Filter Search in server list

Post by Z-Man »

Comment: Wonderful! I especially like the escape handling bit. Action: Merged.

To Jip: Any special wishes on how you want to be credited in AUTHORS?

(This was open in my yet-to-properly-read tab collection, but thanks for the bump anyway; that collection all too often turns into the pit of oblivion.)


User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: (suggestion) Filter Search in server list

Post by Jip »

Z-Man wrote:Comment: Wonderful! I especially like the escape handling bit. Action: Merged.

To Jip: Any special wishes on how you want to be credited in AUTHORS?

(This was open in my yet-to-properly-read tab collection, but thanks for the bump anyway; that collection all too often turns into the pit of oblivion.)
Nice to see it merged :)
Would be wonderful to be mentioned as brandesign. That correspond with my github account :)

Post Reply