DWORD WINAPI GetServerPingsAndInfosProc(void * lpParameter) { unsigned int SB_Sources_Marked_Count(void); extern cvar_t sb_listcache; extern void SB_Serverlist_Serialize_f(); int full = (int) lpParameter; abort_ping = 0; if (full || serversn_passed == 0) { if (SB_Sources_Marked_Count() == 0) { // ensure some sources are marked, otherwise the refresh makes no sense MarkDefaultSources(); } SB_Sources_Update(true); if (useNewPing) { // New Ping = UPD QW Packet ping using 2 threads (sender and receiver) PingHosts(servers, serversn, sb_pings.integer); } else { // Old Ping = ICMP PING Packet using single thread oldPingHosts(servers, serversn, sb_pings.integer ); } } if (!abort_ping) { ping_phase = 2; GetServerInfosProc(NULL); } /* if (abort_ping) Sys_MSleep(500); // let the packets end the road */ resort_servers = 1; rebuild_all_players = 1; ping_phase = 0; TP_ExecTrigger("f_sbrefreshdone"); if (sb_listcache.integer) { SB_Serverlist_Serialize_f(); } if (sb_findroutes.integer && (full || !SB_PingTree_Built())) { SB_PingTree_Build(); } serverinfo_lock = 0; return 0; }
void Host_Quit (void) { // execute user's trigger TP_ExecTrigger ("f_exit"); Cbuf_Execute(); // save config (conditional) Config_QuitSave(); // turn off Host_Shutdown (); Sys_Quit (); }
//When you run over an item, the server sends this command void V_BonusFlash_f (void) { static double last_bonusflashtrigger = 0; if (cls.realtime != last_bonusflashtrigger) { // do not trigger twice a frame TP_ExecTrigger ("f_bonusflash"); last_bonusflashtrigger = cls.realtime; } if (!v_bonusflash.value && cbuf_current == &cbuf_svc) return; cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215; cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186; cl.cshifts[CSHIFT_BONUS].destcolor[2] = 69; cl.cshifts[CSHIFT_BONUS].percent = 50; }
/* ===================== CL_Spawn ===================== */ void CL_Spawn (void) { // first update is the final signon stage cls.state = ca_active; if (cls.demoplayback) host_skipframe = true; if (!cls.demoplayback) VID_SetCaption (va(PROGRAM ": %s", cls.servername)); Con_ClearNotify (); SCR_EndLoadingPlaque (); TP_ExecTrigger ("f_spawn"); }
void V_TF_FlashStuff (void) { static float last_own_flash_time; static float last_other_flash_time; float blocktime; // 240 = Normal TF || 255 = Angel TF if (cshift_empty.percent == 240 || cshift_empty.percent == 255 ) { TP_ExecTrigger ("f_flash"); if (!flashed && (!strncasecmp(Rulesets_Ruleset(), "MTFL", 4))) V_TF_FlashSettings (true); flashed = true; last_other_flash_time = cls.realtime; } if (cshift_empty.percent == 160) { // flashed by your own flash if (!flashed && (!strncasecmp(Rulesets_Ruleset(), "MTFL", 4))) V_TF_FlashSettings (true); flashed = true; last_own_flash_time = cls.realtime; } blocktime = (last_other_flash_time > last_own_flash_time) ? 20.0 : 10.0; // turn gamma and contrast back if if ((!(cls.realtime - max (last_own_flash_time, last_other_flash_time) < blocktime)) || // flashed for last 10 seconds or (cshift_empty.percent == 0 && (cbuf_current = &cbuf_svc))) { // death while flashed if (flashed && (!strncasecmp(Rulesets_Ruleset(), "MTFL", 4))) { V_TF_FlashSettings (false); flashed = false; } } if (cls.demoplayback && cshift_empty.destcolor[0] == cshift_empty.destcolor[1]) cshift_empty.percent *= cl_demoplay_flash.value/1.0f; }
DWORD WINAPI Update_Multiple_Sources_Proc(void * lpParameter) { // get servers from master server SYSTEMTIME lt; char request[] = {'c', '\n', '\0'}; socket_t newsocket; struct sockaddr_storage server; int ret = 0, i, sourcenum; unsigned char answer[10000]; fd_set fd; struct timeval tv; int total_masters = 0; int updated = 0; int d1, d2; GetLocalTime(<); d1 = lt.wSecond + 60*(lt.wMinute + 60*(lt.wHour + 24*(lt.wDay))); // update file sources - this should be a flash for (sourcenum = 0; sourcenum < psourcesn; sourcenum++) if (psources[sourcenum]->checked) { if (psources[sourcenum]->type == type_file) Update_Source(psources[sourcenum]); if (psources[sourcenum]->type == type_url) Update_Source(psources[sourcenum]); // todo cache this too else if (psources[sourcenum]->type == type_master) { source_data *s = psources[sourcenum]; if (s->last_update.wYear != 0 && !source_full_update) { d2 = s->last_update.wSecond + 60*(s->last_update.wMinute + 60*(s->last_update.wHour + 24*(s->last_update.wDay))); if (d1 > d2 && d1 < d2 + sb_sourcevalidity.value*60) continue; } total_masters++; } } // update master sources newsocket = UDP_OpenSocket(PORT_ANY); for (sourcenum = 0; sourcenum < psourcesn && !abort_ping; sourcenum++) { server_data *servers[MAX_SERVERS]; int serversn = 0; int trynum = 0; source_data *s = psources[sourcenum]; double timeout; if (psources[sourcenum]->type != type_master || !psources[sourcenum]->checked) continue; if (s->last_update.wYear != 0 && !source_full_update) { d2 = s->last_update.wSecond + 60*(s->last_update.wMinute + 60*(s->last_update.wHour + 24*(s->last_update.wDay))); if (d1 > d2 && d1 < d2 + sb_sourcevalidity.value*60) continue; } // send trynum queries to master server for (trynum=0; trynum < sb_masterretries.value; trynum++) { NetadrToSockadr (&(s->address.address), &server); ret = sendto (newsocket, request, sizeof(request), 0, (struct sockaddr *)&server, sizeof(server) ); } if (ret <= 0) continue; timeout = Sys_DoubleTime() + (sb_mastertimeout.value / 1000.0); while (Sys_DoubleTime() < timeout) { struct sockaddr_storage hostaddr; netadr_t from; //fd.fd_count = 1; //fd.fd_array[0] = newsocket; FD_ZERO(&fd); FD_SET(newsocket, &fd); tv.tv_sec = 0; tv.tv_usec = 1000 * sb_mastertimeout.value; ret = select(newsocket+1, &fd, NULL, NULL, &tv); // get answer i = sizeof(hostaddr); if (ret > 0) ret = recvfrom (newsocket, (char *) answer, 10000, 0, (struct sockaddr *)&hostaddr, (socklen_t *)&i); if (ret > 0 && ret < 10000) { SockadrToNetadr (&hostaddr, &from); if (from.ip[0] == s->address.address.ip[0] && from.ip[1] == s->address.address.ip[1] && from.ip[2] == s->address.address.ip[2] && from.ip[3] == s->address.address.ip[3] && from.port == s->address.address.port) { answer[ret] = 0; if (memcmp(answer, "\xff\xff\xff\xff\x64\x0a", 6)) { continue; } // create servers avoiding duplicates for (i=6; i+5 < ret; i+=6) { char buf[32]; server_data* server; qbool exists = false; int j; snprintf(buf, sizeof (buf), "%u.%u.%u.%u:%u", (int)answer[i+0], (int)answer[i+1], (int)answer[i+2], (int)answer[i+3], 256 * (int)answer[i+4] + (int)answer[i+5]); server = Create_Server(buf); for (j=0; j<serversn; j++) { if (NET_CompareAdr(servers[j]->address, server->address)) { exists = true; break; } } if (!exists) servers[serversn++] = server; else Delete_Server(server); } } } } // copy all servers to source list if (serversn > 0) { updated++; Reset_Source(s); s->servers = (server_data **) Q_malloc(serversn * sizeof(server_data *)); for (i=0; i < serversn; i++) s->servers[i] = servers[i]; s->serversn = serversn; if (s->checked) rebuild_servers_list = 1; GetLocalTime(&(s->last_update)); if (sb_mastercache.value) DumpSource(s); } ping_pos = updated / (double)total_masters; } closesocket(newsocket); // Not having this here leads to crash almost always when some // other action with servers list happens right after this function. // Even 1 ms delay was enough during the tests, previously 500 ms was used. //Sys_MSleep(100); updating_sources = 0; TP_ExecTrigger("f_sbupdatesourcesdone"); return 0; }