void digi_get_sound_loc( vms_matrix * listener, vms_vector * listener_pos, int listener_seg, vms_vector * sound_pos, int sound_seg, fix max_volume, int *volume, int *pan, fix max_distance ) { vms_vector vector_to_sound; fix angle_from_ear, cosang,sinang; fix distance; fix path_distance; *volume = 0; *pan = 0; max_distance = (max_distance*5)/4; // Make all sounds travel 1.25 times as far. // Warning: Made the vm_vec_normalized_dir be vm_vec_normalized_dir_quick and got illegal values to acos in the fang computation. distance = vm_vec_normalized_dir_quick( &vector_to_sound, sound_pos, listener_pos ); if (distance < max_distance ) { int num_search_segs = f2i(max_distance/20); if ( num_search_segs < 1 ) num_search_segs = 1; path_distance = find_connected_distance(listener_pos, listener_seg, sound_pos, sound_seg, num_search_segs, WID_RENDPAST_FLAG ); if ( path_distance > -1 ) { *volume = max_volume - fixdiv(path_distance,max_distance); //mprintf( (0, "Sound path distance %.2f, volume is %d / %d\n", f2fl(distance), *volume, max_volume )); if (*volume > 0 ) { angle_from_ear = vm_vec_delta_ang_norm(&listener->rvec,&vector_to_sound,&listener->uvec); fix_sincos(angle_from_ear,&sinang,&cosang); //mprintf( (0, "volume is %.2f\n", f2fl(*volume) )); if (Config_channels_reversed) cosang *= -1; *pan = (cosang + F1_0)/2; } else { *volume = 0; } } } }
//initialize the player object position & orientation (at start of game, or new ship) void InitPlayerPosition(int random) { int NewPlayer=0; if (! ((Game_mode & GM_MULTI) && !(Game_mode&GM_MULTI_COOP)) ) // If not deathmatch NewPlayer = Player_num; #ifdef NETWORK else if ((Game_mode & GM_MULTI) && (Netgame.SpawnStyle == SPAWN_STYLE_PREVIEW) && Dead_player_camera != NULL) NewPlayer = previewed_spawn_point; #endif else if (random == 1) { int i, trys=0; fix closest_dist = 0x7ffffff, dist; timer_update(); d_srand((fix)timer_query()); do { trys++; NewPlayer = d_rand() % NumNetPlayerPositions; closest_dist = 0x7fffffff; for (i=0; i<N_players; i++ ) { if ( (i!=Player_num) && (Objects[Players[i].objnum].type == OBJ_PLAYER) ) { dist = find_connected_distance(&Objects[Players[i].objnum].pos, Objects[Players[i].objnum].segnum, &Player_init[NewPlayer].pos, Player_init[NewPlayer].segnum, 15, WID_FLY_FLAG ); // Used to be 5, search up to 15 segments if ( (dist < closest_dist) && (dist >= 0) ) { closest_dist = dist; } } } } while ( (closest_dist<i2f(15*20)) && (trys<MAX_PLAYERS*2) ); } else { // If deathmatch and not random, positions were already determined by sync packet reset_player_object(); reset_cruise(); return; } Assert(NewPlayer >= 0); Assert(NewPlayer < NumNetPlayerPositions); ConsoleObject->pos = Player_init[NewPlayer].pos; ConsoleObject->orient = Player_init[NewPlayer].orient; #ifdef NETWORK if ((Game_mode & GM_MULTI) && (Netgame.SpawnStyle == SPAWN_STYLE_PREVIEW) && Dead_player_camera != NULL) { ConsoleObject->orient = Dead_player_camera->orient; Dead_player_camera = NULL; } #endif obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum); reset_player_object(); reset_cruise(); }
//initialize the player object position & orientation (at start of game, or new ship) void InitPlayerPosition(int random) { int NewPlayer=0; if (! ((Game_mode & GM_MULTI) && !(Game_mode&GM_MULTI_COOP)) ) // If not deathmatch NewPlayer = Player_num; #ifdef NETWORK else if (random == 1) { int i, closest = -1, trys=0; fix closest_dist = 0x7ffffff, dist; d_srand(clock()); do { trys++; NewPlayer = d_rand() % NumNetPlayerPositions; closest = -1; closest_dist = 0x7fffffff; for (i=0; i<N_players; i++ ) { if ( (i!=Player_num) && (Objects[Players[i].objnum].type == OBJ_PLAYER) ) { dist = find_connected_distance(&Objects[Players[i].objnum].pos, Objects[Players[i].objnum].segnum, &Player_init[NewPlayer].pos, Player_init[NewPlayer].segnum, 5, WID_FLY_FLAG ); if ( (dist < closest_dist) && (dist >= 0) ) { closest_dist = dist; closest = i; } } } } while ( (closest_dist<i2f(10*20)) && (trys<MAX_NUM_NET_PLAYERS*2) ); } #endif else { goto done; // If deathmatch and not random, positions were already determined by sync packet } Assert(NewPlayer >= 0); Assert(NewPlayer < NumNetPlayerPositions); ConsoleObject->pos = Player_init[NewPlayer].pos; ConsoleObject->orient = Player_init[NewPlayer].orient; obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum); done: reset_player_object(); reset_cruise(); }
void bng_process_segment(object *objp, fix damage, segment *segp, int depth, byte *visited) { int i, sidenum; if (depth > MAX_BLAST_GLASS_DEPTH) return; depth++; for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) { int tm; fix dist; vms_vector pnt; // Process only walls which have glass. if ((tm=segp->sides[sidenum].tmap_num2) != 0) { int ec, db; tm &= 0x3fff; //tm without flags if ((((ec=TmapInfo[tm].eclip_num)!=-1) && ((db=Effects[ec].dest_bm_num)!=-1 && !(Effects[ec].flags&EF_ONE_SHOT))) || (ec==-1 && (TmapInfo[tm].destroyed!=-1))) { compute_center_point_on_side(&pnt, segp, sidenum); dist = vm_vec_dist_quick(&pnt, &objp->pos); if (dist < damage/2) { dist = find_connected_distance(&pnt, segp-Segments, &objp->pos, objp->segnum, MAX_BLAST_GLASS_DEPTH, WID_RENDPAST_FLAG); if ((dist > 0) && (dist < damage/2)) check_effect_blowup(segp, sidenum, &pnt, &Objects[objp->ctype.laser_info.parent_num], 1); } } } } for (i=0; i<MAX_SIDES_PER_SEGMENT; i++) { int segnum = segp->children[i]; if (segnum != -1) { if (!visited[segnum]) { if (WALL_IS_DOORWAY(segp, i) & WID_FLY_FLAG) { visited[segnum] = 1; bng_process_segment(objp, damage, &Segments[segnum], depth, visited); } } } } }
//initialize the player object position & orientation (at start of game, or new ship) InitPlayerPosition(int random) { int NewPlayer; if (! ((Game_mode & GM_MULTI) && !(Game_mode&GM_MULTI_COOP)) ) // If not deathmatch NewPlayer = Player_num; #ifdef NETWORK else if (random == 1) { int i, closest = -1, trys=0; fix closest_dist = 0x7ffffff, dist; srand(clock()); #ifndef NDEBUG if (NumNetPlayerPositions != MAX_NUM_NET_PLAYERS) { mprintf((1, "WARNING: There are only %d start positions!\n")); //Int3(); } #endif do { if (trys > 0) { mprintf((0, "Can't start in location %d because its too close to player %d\n", NewPlayer, closest )); } trys++; NewPlayer = rand() % NumNetPlayerPositions; closest = -1; closest_dist = 0x7fffffff; for (i=0; i<N_players; i++ ) { if ( (i!=Player_num) && (Objects[Players[i].objnum].type == OBJ_PLAYER) ) { dist = find_connected_distance(&Objects[Players[i].objnum].pos, Objects[Players[i].objnum].segnum, &Player_init[NewPlayer].pos, Player_init[NewPlayer].segnum, 5, WID_FLY_FLAG ); // mprintf((0, "Distance from start location %d to player %d is %f.\n", NewPlayer, i, f2fl(dist))); if ( (dist < closest_dist) && (dist >= 0) ) { closest_dist = dist; closest = i; } } } mprintf((0, "Closest from pos %d is %f to plr %d.\n", NewPlayer, f2fl(closest_dist), closest)); } while ( (closest_dist<i2f(10*20)) && (trys<MAX_NUM_NET_PLAYERS*2) ); } #endif else { mprintf((0, "Starting position is not being changed.\n")); goto done; // If deathmatch and not random, positions were already determined by sync packet } Assert(NewPlayer >= 0); Assert(NewPlayer < NumNetPlayerPositions); ConsoleObject->pos = Player_init[NewPlayer].pos; ConsoleObject->orient = Player_init[NewPlayer].orient; mprintf((0, "Re-starting in location %d of %d.\n", NewPlayer+1, NumNetPlayerPositions)); obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum); done: reset_player_object(); reset_cruise(); }