// respawns an AI ship. void multi_respawn_ai( p_object *pobjp ) { int objnum; object *objp; // create the object and change the ship type objnum = multi_respawn_common_stuff( pobjp ); objp = &Objects[objnum]; // be sure the the OF_PLAYER_SHIP flag is unset, and the could be player flag is set obj_set_flags( objp, objp->flags | OF_COULD_BE_PLAYER ); objp->flags &= ~OF_PLAYER_SHIP; }
// respawns an AI ship. void multi_respawn_ai( p_object *pobjp ) { int objnum; object *objp; // create the object and change the ship type objnum = multi_respawn_common_stuff( pobjp ); objp = &Objects[objnum]; // be sure the the OF_PLAYER_SHIP flag is unset, and the could be player flag is set obj_set_flags(objp, objp->flags + Object::Object_Flags::Could_be_player); objp->flags.remove(Object::Object_Flags::Player_ship); }
// respawn the passed player with the passed ship object and weapon link settings void multi_respawn_player(net_player *pl, char cur_primary_bank, char cur_secondary_bank, ubyte cur_link_status, ushort ship_ets, ushort net_sig, char *parse_name, vector *pos) { int objnum; object *objp; ship *shipp; p_object *pobjp; // try and find the parse object pobjp = mission_parse_get_arrival_ship(parse_name); Assert(pobjp != NULL); if(pobjp == NULL){ return; } objnum = multi_respawn_common_stuff(pobjp); Assert( objnum != -1 ); objp = &Objects[objnum]; shipp = &Ships[objp->instance]; // this is a player, so mark him as a player, objp->flags |= OF_PLAYER_SHIP; objp->flags &= ~OF_COULD_BE_PLAYER; // server should mark this player as invulerable for a short time if ( MULTIPLAYER_MASTER ) { objp->flags |= OF_INVULNERABLE; pl->s_info.invul_timestamp = timestamp(RESPAWN_INVUL_TIMESTAMP); multi_respawn_place( objp, shipp->team ); } // reset his datarate timestamp extern int OO_gran; pl->s_info.rate_stamp = timestamp( (int)(1000.0f / (float)OO_gran) ); // set some player information pl->player->objnum = objnum; if ( pl == Net_player ) { // this is a hack to ensure that old (dead) player ships are destroyed, since at this point he's actually an OBJ_GHOST Player_obj->flags |= OF_SHOULD_BE_DEAD; obj_delete(OBJ_INDEX(Player_obj)); Player_obj = objp; Player_ship = shipp; Player_ai = &Ai_info[Player_ship->ai_index]; // get rid of the annoying HUD dead message text. HUD_init_fixed_text(); } // clients bash net signature if(!(Net_player->flags & NETINFO_FLAG_AM_MASTER)){ objp->net_signature = net_sig; } // restore the correct weapon bank selections shipp->weapons.current_primary_bank = (int)cur_primary_bank; shipp->weapons.current_secondary_bank = (int)cur_secondary_bank; if(cur_link_status & (1<<0)){ shipp->flags |= SF_PRIMARY_LINKED; } else { shipp->flags &= ~(SF_PRIMARY_LINKED); } if(cur_link_status & (1<<1)){ shipp->flags |= SF_SECONDARY_DUAL_FIRE; } else { shipp->flags &= ~(SF_SECONDARY_DUAL_FIRE); } Assert( ship_ets != 0 ); // find dave or allender // restore the correct ets settings shipp->shield_recharge_index = ((ship_ets & 0x0f00) >> 8); // weapon ets shipp->weapon_recharge_index = ((ship_ets & 0x00f0) >> 4); // engine ets shipp->engine_recharge_index = (ship_ets & 0x000f); // if this is a dogfight mission, make him TEAM_TRAITOR if(Netgame.type_flags & NG_TYPE_DOGFIGHT){ shipp->team = TEAM_TRAITOR; } // maybe bash ship position if(pos != NULL){ objp->pos = *pos; } // unset his respawning flag pl->flags &= ~(NETINFO_FLAG_RESPAWNING | NETINFO_FLAG_LIMBO); // blast his control and button info clear memset(&pl->player->bi, 0, sizeof(pl->player->bi)); memset(&pl->player->ci, 0, sizeof(pl->player->ci)); // if this is me, clear accum button info if(pl == Net_player){ // clear multiplayer button info extern button_info Multi_ship_status_bi; memset(&Multi_ship_status_bi, 0, sizeof(button_info)); } // notify other players of the respawn if ( MULTIPLAYER_MASTER ){ multi_respawn_broadcast(pl); } }
// respawn the passed player with the passed ship object and weapon link settings void multi_respawn_player(net_player *pl, char cur_primary_bank, char cur_secondary_bank, ubyte cur_link_status, ushort ship_ets, ushort net_sig, char *parse_name, vec3d *pos) { int objnum; object *objp; ship *shipp; p_object *pobjp; // try and find the parse object pobjp = mission_parse_get_arrival_ship(parse_name); Assert(pobjp != NULL); if(pobjp == NULL){ return; } objnum = multi_respawn_common_stuff(pobjp); Assert( objnum != -1 ); objp = &Objects[objnum]; shipp = &Ships[objp->instance]; // this is a player, so mark him as a player, objp->flags.set(Object::Object_Flags::Player_ship); objp->flags.remove(Object::Object_Flags::Could_be_player); // server should mark this player as invulerable for a short time if ( MULTIPLAYER_MASTER ) { objp->flags.set(Object::Object_Flags::Invulnerable); pl->s_info.invul_timestamp = timestamp(RESPAWN_INVUL_TIMESTAMP); multi_respawn_place( objp, shipp->team ); } // reset his datarate timestamp extern int OO_gran; pl->s_info.rate_stamp = timestamp( (int)(1000.0f / (float)OO_gran) ); // set some player information pl->m_player->objnum = objnum; if ( pl == Net_player ) { object *oldplr = Player_obj; Player_obj = objp; Player_ship = shipp; Player_ai = &Ai_info[Player_ship->ai_index]; // this is a hack to ensure that old (dead) player ships are destroyed, since at this point he's actually an OBJ_GHOST oldplr->flags.set(Object::Object_Flags::Should_be_dead); obj_delete(OBJ_INDEX(oldplr)); // get rid of the annoying HUD dead message text. HUD_init_fixed_text(); } // clients bash net signature if(!(Net_player->flags & NETINFO_FLAG_AM_MASTER)){ objp->net_signature = net_sig; } // restore the correct weapon bank selections shipp->weapons.current_primary_bank = (int)cur_primary_bank; shipp->weapons.current_secondary_bank = (int)cur_secondary_bank; if(cur_link_status & (1<<0)){ shipp->flags.set(Ship::Ship_Flags::Primary_linked); } else { shipp->flags.remove(Ship::Ship_Flags::Primary_linked); } if(cur_link_status & (1<<1)){ shipp->flags.set(Ship::Ship_Flags::Secondary_dual_fire); } else { shipp->flags.remove(Ship::Ship_Flags::Secondary_dual_fire); } Assert( ship_ets != 0 ); // find dave or allender // restore the correct ets settings shipp->shield_recharge_index = ((ship_ets & 0x0f00) >> 8); // weapon ets shipp->weapon_recharge_index = ((ship_ets & 0x00f0) >> 4); // engine ets shipp->engine_recharge_index = (ship_ets & 0x000f); // give the current bank a half-second timestamp so that we don't fire immediately unpon respawn shipp->weapons.next_secondary_fire_stamp[shipp->weapons.current_secondary_bank] = timestamp(500); // if this is a dogfight mission, make him TEAM_TRAITOR if(Netgame.type_flags & NG_TYPE_DOGFIGHT){ shipp->team = Iff_traitor; } // maybe bash ship position if(pos != NULL){ objp->pos = *pos; } // unset his respawning flag pl->flags &= ~(NETINFO_FLAG_RESPAWNING | NETINFO_FLAG_LIMBO); // blast his control and button info clear memset(&pl->m_player->bi, 0, sizeof(pl->m_player->bi)); memset(&pl->m_player->ci, 0, sizeof(pl->m_player->ci)); // set throttle based on initial velocity specified in mission (the vel gets calculated // like a percentage of our max speed, so we can just use it as-is for the throttle) pl->m_player->ci.forward_cruise_percent = (float)pobjp->initial_velocity; CLAMP(pl->m_player->ci.forward_cruise_percent, 0.0f, 100.0f); // if this is me, clear accum button info if(pl == Net_player){ // clear multiplayer button info extern button_info Multi_ship_status_bi; memset(&Multi_ship_status_bi, 0, sizeof(button_info)); } // notify other players of the respawn if ( MULTIPLAYER_MASTER ){ multi_respawn_broadcast(pl); } }