Navigation

 Internal Server Browser Filter Feature Type: Coding Tutorials     Added: 24/01  
  Author: Corven 

Alter the internal server browser to filter only your mod.

Code to be Deleted or Commented out
Code to be Added or Changed

ui_servers2.c

That's the internal server browser file that will do most of the work, sorting the servers, showing their lists, collating server details etc. We will change it to only filter your mod, for this example I'm using my Eternal Arena mod.

Starting at the top with the defines, you'll see:

#define GAMES_ALL 5
#define GAMES_FFA 1
#define GAMES_TEAMPLAY 2
#define GAMES_TOURNEY 3
#define GAMES_CTF 4

Now add to the end of those:
#define GAMES_ETERNAL 0

Then further down you'll see the servertype items, which are the options you can toggle through to filter out different games:

static const char *servertype_items[] = {
"All",
"Free For All",
"Team Deathmatch",
"Tournament",
"Capture the Flag",
0
};

Remove or comment out all those gametypes and just put your mod in as an option like this:

static const char *servertype_items[] = {
//"All",
//"Free For All",
//"Team Deathmatch",
//"Tournament",
//"Capture the Flag",

"Eternal Arena",
0
};

Then we jump down to the ArenaServers_UpdateMenu function, where we have the gametype switch:

switch( g_gametype ) {
case GAMES_ALL:
break;

case GAMES_FFA:
if( servernodeptr->gametype != GT_FFA ) {
continue;
}
break;

case GAMES_TEAMPLAY:
if( servernodeptr->gametype != GT_TEAM ) {
continue;
}
break;

case GAMES_TOURNEY:
if( servernodeptr->gametype != GT_TOURNAMENT ) {
continue;
}
break;

case GAMES_CTF:
if( servernodeptr->gametype != GT_CTF ) {
continue;
}
break;
}

We don't need any of those, but we do need to add one of our own, so replace that part of the code like the following:

switch( g_gametype ) {
/*case GAMES_ALL:
break;

case GAMES_FFA:
if( servernodeptr->gametype != GT_FFA ) {
continue;
}
break;

case GAMES_TEAMPLAY:
if( servernodeptr->gametype != GT_TEAM ) {
continue;
}
break;

case GAMES_TOURNEY:
if( servernodeptr->gametype != GT_TOURNAMENT ) {
continue;
}
break;

case GAMES_CTF:
if( servernodeptr->gametype != GT_CTF ) {
continue;
}
break;
/*

case GAMES_ETERNAL:
if( strcmp(servernodeptr->gamename,"eternal") != 0 ) {
continue;
}
break;

}

Compile and build your qvms, fire up a game and go check it is being filtered in the internal server browser.

Comments »



  Page 1

  Comments ( 0 )


  Features Index

  Home

Copyright © 2001 MGON International AB - Privacy statement