static void job_check_func (gpointer data, gpointer user_data) { Job *job = (Job *)data; Gstreamill *gstreamill = (Gstreamill *)user_data; if (gstreamill->stop) { GST_ERROR ("waitting %s stopped", job->name); return; } /* stat report. */ if (gstreamill->daemon && (job->worker_pid != 0)) { job_stat_update (job); GST_INFO ("Job %s's average cpu: %d%%, cpu: %d%%, rss: %lu", job->name, job->cpu_average, job->cpu_current, job->memory); } if (*(job->output->state) != JOB_STATE_PLAYING) { return; } source_check (gstreamill, job); encoders_check (gstreamill, job); if (job->is_live) { sync_check (gstreamill, job); } /* check non live job eos */ if (!job->is_live) { gint i; gboolean eos = TRUE; for (i = 0; i < job->output->encoder_count; i++) { if (!(*(job->output->encoders[i].eos))) { eos = FALSE; break; } else { /* add #EXT-X-ENDLIST to playlist if output is m3u8 */ gchar *location, *property, *playlist1, *playlist2; property = g_strdup_printf ("encoder.%d.elements.hlssink.property.playlist-location", i); location = jobdesc_element_property_value (job->description, property); g_free (property); if (location != NULL) { g_file_get_contents (location, &playlist1, NULL, NULL); playlist2 = g_strdup_printf ("%s#EXT-X-ENDLIST\n", playlist1); g_file_set_contents (location, playlist2, strlen(playlist2), NULL); g_free (playlist1); g_free (playlist2); g_free (location); } } } if (eos) { stop_job (job, SIGTERM); job->eos = TRUE; } } }
void update_players() { register struct player *j, *closest = NULL; register Player *p, *ce = NULL, *cf = NULL, *ct = NULL; register int i; int mce = INT_MAX, mcf = INT_MAX, mct = INT_MAX, d; int pldist; int predictx, predicty, rx,ry; Player *nt; if(_state.closest_e && _state.closest_e->p && _state.closest_e->p->p_status == PEXPLODE){ explode_danger = 5/(int)updates + 1; } if(explode_danger) explode_danger --; _state.total_enemies = 0; _state.total_wenemies = 0; _state.closest_e = NULL; _state.total_friends = 0; _state.closest_f = NULL; _state.num_tbombers = 0; _state.num_ttakers = 0; shmem_updmyloc(me->p_x, me->p_y); for(i=0, j= &players[i]; i< MAXPLAYER; i++,j++){ p = &_state.players[j->p_no]; switch(j->p_status){ case PFREE: if(p->last_init){ /* any field not nulled below */ if(j->p_no == _state.controller-1){ _state.controller = 0; locked = 0; } if(_state.last_defend && _state.last_defend->p && _state.last_defend->p->p_no == j->p_no) _state.last_defend = NULL; bzero(p, sizeof(Player)); } continue; case POUTFIT: p->p = NULL; p->dist = GWIDTH; p->p_x = -GWIDTH; p->p_y = -GWIDTH; case PDEAD: case PEXPLODE: if(WAR(j)){ _state.total_enemies ++; } p->alive = 0; p->plcarry = 0.0; if(j->p_team == _state.warteam) _state.total_wenemies ++; continue; } if(j->p_team == _state.warteam) _state.total_wenemies ++; if(j->p_status == PEXPLODE && j->p_explode == 0){ do_expdamage(j); j->p_explode ++; } /* if(j == me) continue; */ if((j!= me) && WAR(j)){ _state.total_enemies ++; p->enemy = 1; } else { _state.total_friends ++; p->enemy = 0; shmem_rloc(j->p_no, &j->p_x, &j->p_y); } if(!p->alive){ /* reset all attributes */ p->p = j; init_sstats(p); } p->alive ++; p->p = j; if(j->p_x < 0 || j->p_y < 0){ /* very little information available */ if ( ! p->invisible ) { p->invisible = 1; /* p->last_init = _udcounter - 1; p->dist = GWIDTH; continue; */ } } else p->invisible = 0; #ifdef NO_PFTRACT /* if server doesn't give tractor info */ /* tractor_check resets or sets this flag */ if(p->pp_flags & PFTRACT){ p->pp_flags = j->p_flags; p->pp_flags |= PFTRACT; } #endif /* NO_PFTRACT */ p->robot = j->p_flags & PFROBOT; if(p->robot) p->fuel = j->p_ship.s_maxfuel; if(j != me){ orbit_check(p, j); army_check1(p, j); army_check2(p, j); if (hm_cr) army_check3(p, j); } if(p->invisible) { p->closest_pl = p->closest_pl; /* keep stale info JKH */ } else { p->closest_pl = closest_planet(j, &pldist, p->closest_pl); p->closest_pl_dist = pldist; } if(j->p_flags & PFBOMB) p->bombing = _udcounter; /* the old information is in p not j */ if(p->invisible) d = GWIDTH; else d = edist_to_me(j); p->lastdist = p->dist; p->dist = d; p->hispr = PHRANGE(p); if(p->invisible){ p->crs = get_wrapcourse(p->p_x, p->p_y); p->icrs = p->crs; /* xxx */ } else{ p->crs = get_wrapcourse(j->p_x, j->p_y); get_intercept_course(p, j, p->dist, &p->icrs); } if(p->enemy && d < mce){ ce = p; mce = d; if(!ignoring_e(p)){ ct = p; mct = d; } } if(p->enemy && d < mct && !ignoring_e(p)){ ct = p; mct = d; } if(!p->enemy && p->p != me && d < mcf){ cf = p; mcf = d; } if(j != me) cloak_check(p, j); if(_udcounter - p->last_init > 450){ /* roughly 45 seconds */ init_sstats(p); } else if(_udcounter - p->last_init == 1){ /* common case for close enemies */ update_sstats(p, 100); } else /* should be actual time in ms, I think */ update_sstats(p, 100 * (_udcounter - p->last_init)); if(p->enemy && !(j->p_flags & PFCLOAK)){ p->thittime = 0; p->phittime = 0; p->thit = p->phit = 0; } if(!p->enemy){ /* what's he doing */ if(_udcounter - p->bombing < 3*60*10) _state.num_tbombers++; } p->last_init = _udcounter; #ifdef nodef if(DEBUG & DEBUG_ENEMY) print_player(p); #endif /* don't update unless it's a value number */ if ( ! p->invisible ) { p->p_x = j->p_x; /* last x */ p->p_y = j->p_y; /* last y */ } } _state.closest_e = ce; _state.closest_f = cf; if(ce) tractor_check(ce, ce->p); nt = get_target(ct); if(nt != _state.current_target){ if(sync_check(&nt)){ _state.current_target = nt; shmem_updmytarg(nt->p->p_no); sendOggVPacket(); } } #ifdef nodef check_server_response(&predictx, &predicty, nint(_serverdelay), NULL, NULL); rx = ABS(me->p_x - predictx); ry = ABS(me->p_y - predicty); /* printf("(sd: %lg) diff: (%d,%d)\n", _serverdelay, rx,ry); */ printf("server (s %d, d %d), local (s %d, d %d), diff (s %d, d %d)\n", _state.sp_subspeed, _state.sp_subdir, _state.p_subspeed, _state.p_subdir, _state.sp_subspeed - _state.p_subspeed, _state.sp_subdir - _state.p_subspeed); #endif /* update my information */ _state.last_x = me->p_x; _state.last_y = me->p_y; _state.last_speed = me->p_speed; _state.last_desspeed = _state.p_desspeed; _state.last_dir = me->p_dir; _state.last_desdir = _state.p_desdir; _state.last_subspeed = _state.p_subspeed; _state.last_subdir = _state.p_subdir; last_udcounter = _udcounter; update_player_density(); check_active_enemies(); }