示例#1
0
// ----------------------------------------------------------------------
// hud_init_msg_window()
//
// Called from HUD_init(), which is called from game_level_init()
//
void hud_init_msg_window()
{
	int i, h;

	MSG_WINDOW_WIDTH = gr_screen.clip_width - 20;

	Hud_list_start = 0;
	Hud_list_end = 0;

	for (i=0; i<SCROLL_BUFFER_LINES; i++)
		HUD_pending[i].text[0] = HUD_pending[i].text[MAX_HUD_LINE_LEN - 1] = 0;
	
	for ( i=0; i < MAX_ACTIVE_BUFFER_LINES; i++ ) {
		HUD_active_msgs_list[i].total_life = 1;
	}

	Scroll_time_id = 1;

	// determine the height of the msg window, which depends on the font height	
	gr_set_font(FONT1);
	h = gr_get_font_height();

	//ACTIVE_BUFFER_LINES = Players[Player_num].HUD_config.num_msg_window_lines;
//	ACTIVE_BUFFER_LINES = HUD_config.num_msg_window_lines;
	ACTIVE_BUFFER_LINES = 4;

	MSG_WINDOW_FONT_HEIGHT = h;
	MSG_WINDOW_HEIGHT = MSG_WINDOW_FONT_HEIGHT * (ACTIVE_BUFFER_LINES-1);

	// starting a mission, free the scroll-back buffers, but only if we've been
	// through this function once already
	if ( HUD_msg_inited == TRUE ) {
		hud_free_scrollback_list();
	}

	list_init( &Msg_scrollback_free_list );
	list_init( &Msg_scrollback_used_list );

	// first slot is reserved for dummy node
	for (i=1; i < MAX_MSG_SCROLLBACK_LINES; i++)	{
		Msg_scrollback_lines[i].text = NULL;
		list_append(&Msg_scrollback_free_list, &Msg_scrollback_lines[i]);
	}

	Active_index=0;
	Scroll_needed=0;
	Scroll_in_progress=0;

	OLD_ACTIVE_BUFFER_LINES = ACTIVE_BUFFER_LINES;

	HUD_init_fixed_text();
	HUD_msg_inited = TRUE;
}
// ----------------------------------------------------------------------
// hud_init_msg_window()
//
// Called from HUD_init(), which is called from game_level_init()
//
void hud_init_msg_window()
{
    int i;

    // starting a mission, free the scroll-back buffers, but only if we've been
    // through this function once already
    if ( HUD_msg_inited == TRUE ) {
        hud_free_scrollback_list();
    }

    list_init( &Msg_scrollback_free_list );
    list_init( &Msg_scrollback_used_list );

    // first slot is reserved for dummy node
    for (i=1; i < MAX_MSG_SCROLLBACK_LINES; i++)	{
        Msg_scrollback_lines[i].text = NULL;
        list_append(&Msg_scrollback_free_list, &Msg_scrollback_lines[i]);
    }

    HUD_init_fixed_text();
    HUD_msg_inited = TRUE;
}
//	Clear all pending text.
void HUD_fixed_printf_reset()
{
    HUD_init_fixed_text();
}
示例#4
0
// 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);
	}
}