void lobby_info::process_userlist() { SCOPE_LB; users_.clear(); FOREACH(const AUTO & c, gamelist_.child_range("user")) { users_.push_back(user_info(c)); } FOREACH(AUTO & ui, users_) { if(ui.game_id != 0) { game_info* g = get_game_by_id(ui.game_id); if(g == NULL) { WRN_NG << "User " << ui.name << " has unknown game_id: " << ui.game_id << "\n"; } else { switch(ui.relation) { case user_info::FRIEND: g->has_friends = true; break; case user_info::IGNORED: g->has_ignored = true; break; default: break; } } } } }
/** * Updates array of connected spectators when new spectator is connected. */ void update_connected_spectators(void) { int i; pthread_t tid; games_list_s *list = *tdata.games_list; game_s *game = NULL; tid = pthread_self(); if (list == NULL) { fprintf(stderr, "(Thread %d) Error while updating data\n", (int) tid); return; } get_game_by_id(list, &game, tdata.game->id); if (game == NULL) { fprintf(stderr, "(Thread %d) Error game list is null\n", (int) tid); return; } memcpy(tdata.spectators_fd, game->spectators, SPECTATORS_NO * sizeof(int)); for (i = 0; i < SPECTATORS_NO; i++) { if (tdata.spectators_fd[i] != -1) { if (!FD_ISSET(tdata.spectators_fd[i], global_thread_rdfs)) { FD_SET(tdata.spectators_fd[i], global_thread_rdfs); *global_thrad_fdmax = max(*global_thrad_fdmax, tdata.spectators_fd[i]); } } } }