fixed so that the server reports gametype, progression and password protection correctly

This commit is contained in:
Magnus Auvinen 2007-11-27 19:51:48 +00:00
parent 8fa8485a3a
commit 59f0a07555
3 changed files with 54 additions and 6 deletions

View file

@ -761,7 +761,8 @@ const char *mods_net_version();
int server_getclientinfo(int client_id, CLIENT_INFO *info); int server_getclientinfo(int client_id, CLIENT_INFO *info);
const char *server_clientname(int client_id); const char *server_clientname(int client_id);
void server_setclientname(int client_id, const char *name); void server_setclientname(int client_id, const char *name);
void server_setprogression(int v);
void server_setbrowseinfo(int game_type, int progression);
int server_tick(); int server_tick();
int server_tickspeed(); int server_tickspeed();

View file

@ -25,6 +25,9 @@ static SNAPBUILD builder;
static int64 game_start_time; static int64 game_start_time;
static int current_tick = 0; static int current_tick = 0;
static int browseinfo_gametype = -1;
static int browseinfo_progression = -1;
static int64 lastheartbeat; static int64 lastheartbeat;
static NETADDR4 master_server; static NETADDR4 master_server;
@ -176,6 +179,12 @@ void server_setclientname(int client_id, const char *name)
strncpy(clients[client_id].name, name, MAX_NAME_LENGTH); strncpy(clients[client_id].name, name, MAX_NAME_LENGTH);
} }
void server_setbrowseinfo(int game_type, int progression)
{
browseinfo_gametype = game_type;
browseinfo_progression = progression;
}
int server_tick() int server_tick()
{ {
return current_tick; return current_tick;
@ -534,9 +543,21 @@ static void server_send_serverinfo(NETADDR4 *addr)
packer_add_string(&p, mods_net_version(), 32); packer_add_string(&p, mods_net_version(), 32);
packer_add_string(&p, config.sv_name, 64); packer_add_string(&p, config.sv_name, 64);
packer_add_string(&p, config.sv_map, 32); packer_add_string(&p, config.sv_map, 32);
packer_add_string(&p, "0", 2); /* gametype */
packer_add_string(&p, "0", 2); /* flags */ /* gametype */
packer_add_string(&p, "0", 4); /* progression */ sprintf(buf, "%d", browseinfo_gametype);
packer_add_string(&p, buf, 2);
/* flags */
i = 0;
if(strlen(config.password))
i |= 1;
sprintf(buf, "%d", i);
packer_add_string(&p, buf, 2);
/* progression */
sprintf(buf, "%d", browseinfo_progression);
packer_add_string(&p, buf, 4);
sprintf(buf, "%d", c); packer_add_string(&p, buf, 3); /* num players */ sprintf(buf, "%d", c); packer_add_string(&p, buf, 3); /* num players */
sprintf(buf, "%d", netserver_max_clients(net)); packer_add_string(&p, buf, 3); /* max players */ sprintf(buf, "%d", netserver_max_clients(net)); packer_add_string(&p, buf, 3); /* max players */

View file

@ -110,8 +110,6 @@ void gameobject::post_reset()
players[i].respawn(); players[i].respawn();
} }
} }
void gameobject::on_player_info_change(class player *p) void gameobject::on_player_info_change(class player *p)
{ {
@ -165,6 +163,34 @@ void gameobject::tick()
startround(); startround();
} }
} }
// update browse info
int prog = -1;
if(config.timelimit > 0)
prog = max(prog, (server_tick()-round_start_tick) * 100 / (config.timelimit*server_tickspeed()*60));
if(config.scorelimit)
{
if(is_teamplay)
{
prog = max(prog, (teamscore[0]*100)/config.scorelimit);
prog = max(prog, (teamscore[1]*100)/config.scorelimit);
}
else
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(players[i].client_id != -1)
prog = max(prog, (players[i].score*100)/config.scorelimit);
}
}
}
if(warmup)
prog = -1;
server_setbrowseinfo(gametype, prog);
} }
void gameobject::snap(int snapping_client) void gameobject::snap(int snapping_client)