diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-07 21:13:24 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-07 21:13:24 +0000 |
| commit | 3b086d616a9090f714c90c7985f10c5dc4bd5733 (patch) | |
| tree | 8137021d446260adfc5eacd753f9e42ab5281e7d /src/engine/client | |
| parent | 6a4e17ea8520e9eb3a88ce15a9e337679d631775 (diff) | |
| download | zcatch-3b086d616a9090f714c90c7985f10c5dc4bd5733.tar.gz zcatch-3b086d616a9090f714c90c7985f10c5dc4bd5733.zip | |
fixed threaded jobs
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/ec_client.c | 57 | ||||
| -rw-r--r-- | src/engine/client/ec_srvbrowse.c | 73 |
2 files changed, 76 insertions, 54 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c index a99f901d..3acd2723 100644 --- a/src/engine/client/ec_client.c +++ b/src/engine/client/ec_client.c @@ -1289,31 +1289,37 @@ static void client_update() client_serverbrowse_update(); } -static int client_getversion() + +static void client_versionupdate() { - NETADDR addr; - NETCHUNK packet; + static int state = 0; + static HOSTLOOKUP version_serveraddr; - mem_zero(&addr, sizeof(NETADDR)); - mem_zero(&packet, sizeof(NETCHUNK)); - - if(net_host_lookup(config.cl_version_server, &addr, NETTYPE_IPV4)) + if(state == 0) { - dbg_msg("client/version", "could not find the address of %s, skipping version fetch", config.cl_version_server); - return -1; + engine_hostlookup(&version_serveraddr, config.cl_version_server); + state++; + } + else if(state == 1) + { + if(jobs_status(&version_serveraddr.job) == JOBSTATUS_DONE) + { + NETCHUNK packet; + + mem_zero(&packet, sizeof(NETCHUNK)); + + version_serveraddr.addr.port = VERSIONSRV_PORT; + + packet.client_id = -1; + packet.address = version_serveraddr.addr; + packet.data = VERSIONSRV_GETVERSION; + packet.data_size = sizeof(VERSIONSRV_GETVERSION); + packet.flags = NETSENDFLAG_CONNLESS; + + netclient_send(net, &packet); + state++; + } } - - addr.port = VERSIONSRV_PORT; - - packet.client_id = -1; - packet.address = addr; - packet.data = VERSIONSRV_GETVERSION; - packet.data_size = sizeof(VERSIONSRV_GETVERSION); - packet.flags = NETSENDFLAG_CONNLESS; - - netclient_send(net, &packet); - - return 0; } extern int editor_update_and_render(); @@ -1336,7 +1342,7 @@ static void client_run() return; /* start refreshing addresses while we load */ - mastersrv_refresh_addresses(); + /* mastersrv_refresh_addresses(); */ /* init the editor */ editor_init(); @@ -1363,9 +1369,6 @@ static void client_run() config.cl_connect[0] = 0; */ - /* fetch latest client-version from versionsrv */ - client_getversion(); - /* never start with the editor */ config.cl_editor = 0; @@ -1377,7 +1380,11 @@ static void client_run() int64 frame_start_time = time_get(); frames++; + perf_start(&rootscope); + + /* */ + client_versionupdate(); /* update input */ { diff --git a/src/engine/client/ec_srvbrowse.c b/src/engine/client/ec_srvbrowse.c index 98f60643..20a80e97 100644 --- a/src/engine/client/ec_srvbrowse.c +++ b/src/engine/client/ec_srvbrowse.c @@ -49,6 +49,8 @@ static SERVERENTRY *first_req_server = 0; /* request list */ static SERVERENTRY *last_req_server = 0; static int num_requests = 0; +static int need_refresh = 0; + static int num_sorted_servers = 0; static int num_sorted_servers_capacity = 0; static int num_servers = 0; @@ -489,30 +491,8 @@ void client_serverbrowse_refresh(int type) } else if(type == BROWSETYPE_INTERNET) { - NETADDR addr; - NETCHUNK p; - int i; - - /*net_host_lookup(config.masterserver, MASTERSERVER_PORT, &master_server);*/ - - mem_zero(&p, sizeof(p)); - p.client_id = -1; - p.flags = NETSENDFLAG_CONNLESS; - p.data_size = sizeof(SERVERBROWSE_GETLIST); - p.data = SERVERBROWSE_GETLIST; - - for(i = 0; i < MAX_MASTERSERVERS; i++) - { - addr = mastersrv_get(i); - if(!addr.ip[0] && !addr.ip[1] && !addr.ip[2] && !addr.ip[3]) - continue; - - p.address = addr; - netclient_send(net, &p); - } - - if(config.debug) - dbg_msg("client", "requesting server list"); + need_refresh = 1; + mastersrv_refresh_addresses(); } else if(type == BROWSETYPE_FAVORITES) { @@ -524,7 +504,7 @@ void client_serverbrowse_refresh(int type) static void client_serverbrowse_request(SERVERENTRY *entry) { - unsigned char buffer[sizeof(SERVERBROWSE_GETINFO)+1]; + /*unsigned char buffer[sizeof(SERVERBROWSE_GETINFO)+1];*/ NETCHUNK p; if(config.debug) @@ -534,15 +514,15 @@ static void client_serverbrowse_request(SERVERENTRY *entry) entry->addr.ip[3], entry->addr.port); } - mem_copy(buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO)); - buffer[sizeof(SERVERBROWSE_GETINFO)] = current_token; + /*mem_copy(buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO)); + buffer[sizeof(SERVERBROWSE_GETINFO)] = current_token;*/ p.client_id = -1; p.address = entry->addr; p.flags = NETSENDFLAG_CONNLESS; - p.data_size = sizeof(buffer); + /*p.data_size = sizeof(buffer); p.data = buffer; - netclient_send(net, &p); + netclient_send(net, &p);*/ /* send old requtest style aswell */ p.data_size = sizeof(SERVERBROWSE_OLD_GETINFO); @@ -559,6 +539,35 @@ void client_serverbrowse_update() int count; SERVERENTRY *entry, *next; + /* do server list requests */ + if(need_refresh && !mastersrv_refreshing()) + { + NETADDR addr; + NETCHUNK p; + int i; + + need_refresh = 0; + + mem_zero(&p, sizeof(p)); + p.client_id = -1; + p.flags = NETSENDFLAG_CONNLESS; + p.data_size = sizeof(SERVERBROWSE_GETLIST); + p.data = SERVERBROWSE_GETLIST; + + for(i = 0; i < MAX_MASTERSERVERS; i++) + { + addr = mastersrv_get(i); + if(!addr.ip[0] && !addr.ip[1] && !addr.ip[2] && !addr.ip[3]) + continue; + + p.address = addr; + netclient_send(net, &p); + } + + if(config.debug) + dbg_msg("client", "requesting server list"); + } + /* do timeouts */ entry = first_req_server; while(1) @@ -660,3 +669,9 @@ void client_serverbrowse_save() engine_config_write_line(buffer); } } + + +int client_serverbrowse_refreshingmasters() +{ + return mastersrv_refreshing(); +} |