// do all sync related data stuff (server-side only) void multi_data_do() { int idx, p_idx; // only do this once a second if ((time(NULL) - Multi_data_time) < 1) { return; } // maybe try and reload player squad logo bitmaps multi_data_maybe_reload(); // reset the time Multi_data_time = time(NULL); // if I'm the server if (Net_player && (Net_player->flags & NETINFO_FLAG_AM_MASTER)) { // for all valid files for (idx = 0; idx < MAX_MULTI_DATA; idx++) { // a valid file that isn't currently xferring (ie, anything we've got completely on our hard drive) if (Multi_data[idx].used && (multi_xfer_lookup(Multi_data[idx].filename) < 0)) { // send it to all players who need it for (p_idx = 0; p_idx < MAX_PLAYERS; p_idx++) { // if he doesn't have it if ((Net_player != &Net_players[p_idx]) && MULTI_CONNECTED(Net_players[p_idx]) && (Net_players[p_idx].reliable_socket != INVALID_SOCKET) && (Multi_data[idx].status[p_idx] == 0)) { // queue up the file to send to him, or at least try to if (multi_xfer_send_file(Net_players[p_idx].reliable_socket, Multi_data[idx].filename, CF_TYPE_ANY, MULTI_XFER_FLAG_AUTODESTROY | MULTI_XFER_FLAG_QUEUE) < 0) { nprintf(("Network", "Failed to send data file! Trying again later...\n")); } else { // mark his status Multi_data[idx].status[p_idx] = 1; } } } } } } }
// send all my files as necessary void multi_data_send_my_junk() { char *with_ext; int bmap, w, h; int ok_to_send = 1; // pilot pic -------------------------------------------------------------- // verify that my pilot pic is valid if(strlen(Net_player->m_player->image_filename)){ bmap = bm_load(Net_player->m_player->image_filename); if(bmap == -1){ ok_to_send = 0; } // verify image dimensions if(ok_to_send){ w = -1; h = -1; bm_get_info(bmap,&w,&h); // release the bitmap bm_release(bmap); bmap = -1; // if the dimensions are invalid, kill the filename if((w != PLAYER_PILOT_PIC_W) || (h != PLAYER_PILOT_PIC_H)){ ok_to_send = 0; } } } else { ok_to_send = 0; } if(ok_to_send){ with_ext = cf_add_ext(Net_player->m_player->image_filename, NOX(".pcx")); if(with_ext != NULL){ strcpy_s(Net_player->m_player->image_filename, with_ext); } // host should put his own pic file in the list now if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (Net_player->m_player->image_filename[0] != '\0')){ multi_data_add_new(Net_player->m_player->image_filename, MY_NET_PLAYER_NUM); } // otherwise clients should just queue up a send else { // add a file extension if necessary multi_xfer_send_file(Net_player->reliable_socket, Net_player->m_player->image_filename, CF_TYPE_ANY, MULTI_XFER_FLAG_AUTODESTROY | MULTI_XFER_FLAG_QUEUE); } } // squad logo -------------------------------------------------------------- // verify that my pilot pic is valid ok_to_send = 1; if(strlen(Net_player->m_player->m_squad_filename)){ bmap = bm_load(Net_player->m_player->m_squad_filename); if(bmap == -1){ ok_to_send = 0; } if(ok_to_send){ // verify image dimensions w = -1; h = -1; bm_get_info(bmap,&w,&h); // release the bitmap bm_release(bmap); bmap = -1; // if the dimensions are invalid, kill the filename if((w != PLAYER_SQUAD_PIC_W) || (h != PLAYER_SQUAD_PIC_H)){ ok_to_send = 0; } } } else { ok_to_send = 0; } if(ok_to_send){ with_ext = cf_add_ext(Net_player->m_player->m_squad_filename, NOX(".pcx")); if(with_ext != NULL){ strcpy_s(Net_player->m_player->m_squad_filename,with_ext); } // host should put his own pic file in the list now if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (Net_player->m_player->m_squad_filename[0] != '\0')){ multi_data_add_new(Net_player->m_player->m_squad_filename, MY_NET_PLAYER_NUM); } // otherwise clients should just queue up a send else { // add a file extension if necessary multi_xfer_send_file(Net_player->reliable_socket, Net_player->m_player->m_squad_filename, CF_TYPE_ANY, MULTI_XFER_FLAG_AUTODESTROY | MULTI_XFER_FLAG_QUEUE); } } }