コード例 #1
0
void briefing_editor_dlg::delete_icon(int num)
{
	int i, z;

	if (num < 0)
		num = m_cur_icon;

	if (num < 0)
		return;

	Assert(m_cur_stage >= 0);
	Assert(Briefing->stages[m_cur_stage].num_icons);
	z = m_cur_icon;
	if (z == num)
		z = -1;
	if (z > num)
		z--;

	m_cur_icon = -1;
	update_data(1);
	obj_delete(icon_obj[num]);
	for (i=num+1; i<Briefing->stages[m_cur_stage].num_icons; i++) {
		Briefing->stages[m_cur_stage].icons[i-1] = Briefing->stages[m_cur_stage].icons[i];
		icon_obj[i-1] = icon_obj[i];
		Objects[icon_obj[i-1]].instance = i - 1;
	}

	Briefing->stages[m_cur_stage].num_icons--;
	if (z >= 0) {
		m_cur_icon = z;
		update_data(0);
	}
}
コード例 #2
0
ファイル: gameseq.c プロジェクト: Mako88/DXX-Retro
void gameseq_remove_unused_players()
{
	int i;

	// 'Remove' the unused players

#ifdef NETWORK
	if (Game_mode & GM_MULTI)
	{
		for (i=0; i < NumNetPlayerPositions; i++)
		{
			if ((!Players[i].connected) || (i >= N_players))
			{
				multi_make_player_ghost(i);
			}
		}
	}
	else
#endif
	{		// Note link to above if!!!
		for (i=1; i < NumNetPlayerPositions; i++)
		{
			obj_delete(Players[i].objnum);
		}
	}
}
コード例 #3
0
ファイル: obj.c プロジェクト: Clodial/GummyShips2
void obj_free(Obj *obj)
{
    if (!obj)return;
    obj->used--;
    if (obj->used > 0)return;
    obj_delete(obj);
}
コード例 #4
0
ファイル: multi_respawn.cpp プロジェクト: lubomyr/freespace2
// respawn myself as an observer
void multi_respawn_as_observer()
{
	// configure the hud to be in "observer" mode
	hud_config_as_observer(Player_ship,Player_ai);	

	// blow away my old player object
	Player_obj->flags |= OF_SHOULD_BE_DEAD;
	obj_delete(OBJ_INDEX(Player_obj));

	// create a new shiny observer object for me
	multi_obs_create_observer(Net_player);
	
	// set my object to be the observer object
	Player_obj = &Objects[Net_player->player->objnum];
	Player_ship = &Hud_obs_ship;	
	Player_ai = &Hud_obs_ai;	
	
	// set some flags for myself
	Net_player->flags |= NETINFO_FLAG_OBSERVER;
	Net_player->flags |= NETINFO_FLAG_OBS_PLAYER;
	Net_player->flags &= ~(NETINFO_FLAG_LIMBO);

	// clear my auto-match speed flag
	Net_player->player->flags &= ~(PLAYER_FLAGS_AUTO_MATCH_SPEED | PLAYER_FLAGS_MATCH_TARGET);
	
	// reset the control info structure
	memset(&Player->ci,0,sizeof(control_info));	
}
コード例 #5
0
/**
 * Destructor for CJumpNode class
 */
CJumpNode::~CJumpNode()
{
	model_unload(m_modelnum);

	if (Objects[m_objnum].type != OBJ_NONE)
		obj_delete(m_objnum);
}
コード例 #6
0
ファイル: GAMESEQ.C プロジェクト: devint1/descent-win
void gameseq_remove_unused_players()
{
	int i;

	// 'Remove' the unused players

#ifdef NETWORK
	if (Game_mode & GM_MULTI)
	{
		for (i=0; i < NumNetPlayerPositions; i++)
		{
			if ((!Players[i].connected) || (i >= N_players))
			{
				#ifndef NDEBUG
//				mprintf((0, "Ghosting player ship %d.\n", i+1));
				#endif
				multi_make_player_ghost(i);
			}
		}
	}
	else
#endif
	{		// Note link to above if!!!
		#ifndef NDEBUG
		mprintf((0, "Removing player objects numbered %d-%d.\n", 1, NumNetPlayerPositions));
		#endif
		for (i=1; i < NumNetPlayerPositions; i++)
		{
			obj_delete(Players[i].objnum);
		}
	}
}
コード例 #7
0
static int do_work(struct kid_t *kid)
{
        int rc = 0, err, iter = 0;

        if (!(kid->k_cmd.c_flags & C_CREATE_EVERY))
                rc = obj_create(kid);

        for (iter = 0; iter < kid->k_cmd.c_rpt; iter++) {
                if (rc || sig_received)
                        break;

                if (kid->k_cmd.c_flags & C_CREATE_EVERY) {
                        rc = obj_create(kid);
                        if (rc)
                                break;
                }

                if (kid->k_cmd.c_flags & C_WRITE) {
                        rc = obj_write(kid);
                        grant_estimate(kid->k_id);
                }

                if (kid->k_cmd.c_flags & C_CREATE_EVERY) {
                        err = obj_delete(kid);
                        if (!rc) rc = err;
                }

                if ((o_verbose > 3) && (iter % 10 == 0))
                        printf("%d: i%d\n", kid->k_id, iter);
                if (!rc)
                        sleep(kid->k_cmd.c_delay);
        }

        if (!(kid->k_cmd.c_flags & C_CREATE_EVERY)) {
                err = obj_delete(kid);
                if (!rc) rc = err;
        }

        if (o_verbose > 2)
                printf("%d: done (%d)\n", kid->k_id, rc);

        return rc;
}
コード例 #8
0
ファイル: obj.c プロジェクト: Clodial/GummyShips2
static void obj_close()
{
    int i;
    for (i = 0; i < __obj_max; i++)
    {
        if (ObjList[i].used)
        {
            obj_delete(&ObjList[i]);
        }
    }
}
コード例 #9
0
ファイル: object.c プロジェクト: Alexis211/Grapes
void obj_closeP(struct process* p, int id) {
	struct object* obj = objdesc_read(p, id);
	if (obj == 0) return;
	objdesc_rm(p, id);
	if (obj->owner == p) {
		if (obj->descriptors > 0) {	//TODO !!!
			obj->owner = 0; // set object to be invalid
			//if a request was being handled, set it to interrupted (acknowledged = 3) and wake up receiver thread or if nonblocking delete it
			//unlock objects busymutex
		} else {
			obj_delete(obj);
		}
	} else {
		if (obj->descriptors == 0 && obj->owner == 0) {
			obj_delete(obj);
		} else if (obj->descriptors == 1 && obj->owner != 0) {
			//future : send message becuz object closed for everyone
		}
	}
}
コード例 #10
0
ファイル: GAMESEQ.C プロジェクト: devint1/descent-win
void
gameseq_init_network_players()
{
	int i,k,j;

	// Initialize network player start locations and object numbers

	ConsoleObject = &Objects[0];
	k = 0;
	j = 0;
	for (i=0;i<=Highest_object_index;i++) {

		if (( Objects[i].type==OBJ_PLAYER )	|| (Objects[i].type == OBJ_GHOST) || (Objects[i].type == OBJ_COOP))
		{
#ifndef SHAREWARE
			if ( (!(Game_mode & GM_MULTI_COOP) && ((Objects[i].type == OBJ_PLAYER)||(Objects[i].type==OBJ_GHOST))) ||
	           ((Game_mode & GM_MULTI_COOP) && ((j == 0) || ( Objects[i].type==OBJ_COOP ))) )
			{
				mprintf((0, "Created Cooperative multiplayer object\n"));
				Objects[i].type=OBJ_PLAYER;
#endif
				mprintf((0, "Player init %d is ship %d.\n", k, j));
				Player_init[k].pos = Objects[i].pos;
				Player_init[k].orient = Objects[i].orient;
				Player_init[k].segnum = Objects[i].segnum;
				Players[k].objnum = i;
				Objects[i].id = k;
				k++;
#ifndef SHAREWARE
			}
			else
				obj_delete(i);
			j++;
#endif
		}
	}
	NumNetPlayerPositions = k;

#ifndef NDEBUG
	if ( ((Game_mode & GM_MULTI_COOP) && (NumNetPlayerPositions != 4)) ||
		  (!(Game_mode & GM_MULTI_COOP) && (NumNetPlayerPositions != 8)) )
	{
		mprintf((1, "--NOT ENOUGH MULTIPLAYER POSITIONS IN THIS MINE!--\n"));
		//Int3(); // Not enough positions!!
	}
#endif
}
コード例 #11
0
//	------------------------------------------------------------------------------------------------------
//	Delete current object, if it exists.
//	If it doesn't exist, reformat Matt's hard disk, even if he is in Boston.
int ObjectDelete(void)
{

	if (Cur_object_index != object_none) {
		auto delete_objnum = Cur_object_index;
		ObjectSelectNextinSegment();

		obj_delete(vobjptridx(delete_objnum));

		if (delete_objnum == Cur_object_index)
			Cur_object_index = object_none;

		Update_flags |= UF_WORLD_CHANGED;
	}

	return 1;
}
コード例 #12
0
// Delete a ship in a red alert mission (since it must have died/departed in the previous mission)
void red_alert_delete_ship(ship *shipp, int ship_state)
{
	if ( (shipp->wing_status_wing_index >= 0) && (shipp->wing_status_wing_pos >= 0) ) {
		if (ship_state == RED_ALERT_DESTROYED_SHIP_CLASS) {
			hud_set_wingman_status_dead(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
		} else if (ship_state == RED_ALERT_PLAYER_DEL_SHIP_CLASS) {
			hud_set_wingman_status_none(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
		} else {
			Error(LOCATION, "Red Alert: asked to delete ship (%s) with invalid ship state (%d)", shipp->ship_name, ship_state);
		}
	}

	ship_add_exited_ship( shipp, SEF_PLAYER_DELETED );
	obj_delete(shipp->objnum);
	if ( shipp->wingnum >= 0 ) {
		ship_wing_cleanup( shipp-Ships, &Wings[shipp->wingnum] );
	}
}
コード例 #13
0
ファイル: automap.c プロジェクト: CDarrow/DXX-Retro
void DropMarker (int player_marker_num)
{
	int marker_num = (Player_num*2)+player_marker_num;
	object *playerp = &Objects[Players[Player_num].objnum];

	MarkerPoint[marker_num] = playerp->pos;

	if (MarkerObject[marker_num] != -1)
		obj_delete(MarkerObject[marker_num]);

	MarkerObject[marker_num] = drop_marker_object(&playerp->pos,playerp->segnum,&playerp->orient,marker_num);

#ifdef NETWORK
	if (Game_mode & GM_MULTI)
		multi_send_drop_marker (Player_num,playerp->pos,player_marker_num,MarkerMessage[marker_num]);
#endif

}
コード例 #14
0
ファイル: automap.c プロジェクト: CDarrow/DXX-Retro
void DropBuddyMarker(object *objp)
{
	int marker_num;

	// Find spare marker slot.  "if" code below should be an assert, but what if someone changes NUM_MARKERS or MAX_CROP_SINGLE and it never gets hit?
	marker_num = MAX_DROP_SINGLE+1;
	if (marker_num > NUM_MARKERS-1)
		marker_num = NUM_MARKERS-1;

	sprintf(MarkerMessage[marker_num], "RIP: %s",PlayerCfg.GuidebotName);

	MarkerPoint[marker_num] = objp->pos;

	if (MarkerObject[marker_num] != -1 && MarkerObject[marker_num] !=0)
		obj_delete(MarkerObject[marker_num]);

	MarkerObject[marker_num] = drop_marker_object(&objp->pos, objp->segnum, &objp->orient, marker_num);

}
コード例 #15
0
ファイル: EOBJECT.C プロジェクト: devint1/descent-win
//	------------------------------------------------------------------------------------------------------
//	Delete current object, if it exists.
//	If it doesn't exist, reformat Matt's hard disk, even if he is in Boston.
int ObjectDelete(void)
{

	if (Cur_object_index != -1) {
		int delete_objnum;

		delete_objnum = Cur_object_index;

		ObjectSelectNextinSegment();

		obj_delete(delete_objnum);

		if (delete_objnum == Cur_object_index)
			Cur_object_index = -1;

		Update_flags |= UF_WORLD_CHANGED;
	}

	return 1;
}
コード例 #16
0
ファイル: gameseq.c プロジェクト: Mako88/DXX-Retro
void
gameseq_init_network_players()
{
	int i,k,j;

	// Initialize network player start locations and object numbers

	ConsoleObject = &Objects[0];
	k = 0;
	j = 0;
	for (i=0;i<=Highest_object_index;i++) {

		if (( Objects[i].type==OBJ_PLAYER )	|| (Objects[i].type == OBJ_GHOST) || (Objects[i].type == OBJ_COOP))
		{
#ifndef SHAREWARE
			if ( (!(Game_mode & GM_MULTI_COOP) && ((Objects[i].type == OBJ_PLAYER)||(Objects[i].type==OBJ_GHOST))) ||
	           ((Game_mode & GM_MULTI_COOP) && ((j == 0) || ( Objects[i].type==OBJ_COOP ))) )
			{
				Objects[i].type=OBJ_PLAYER;
#endif
				Player_init[k].pos = Objects[i].pos;
				Player_init[k].orient = Objects[i].orient;
				Player_init[k].segnum = Objects[i].segnum;
				Players[k].objnum = i;
				Objects[i].id = k;
				k++;
#ifndef SHAREWARE
			}
			else
				obj_delete(i);
			j++;
#endif
		}
	}
	NumNetPlayerPositions = k;
}
コード例 #17
0
ファイル: multi_respawn.cpp プロジェクト: lubomyr/freespace2
// 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);
	}
}
コード例 #18
0
void waypoint_remove(waypoint *wpt)
{
	int objnum = wpt->get_objnum();
	waypoint_list *wp_list = wpt->get_parent_list();

	int this_list = calc_waypoint_list_index(Objects[objnum].instance);
	int this_index = calc_waypoint_index(Objects[objnum].instance);

	// special case... this is the only waypoint on its list
	if (wp_list->get_waypoints().size() == 1)
	{
		wp_list->get_waypoints().clear();

		// special special case... this is the only waypoint list!
		if (Waypoint_lists.size() == 1)
		{
			Waypoint_lists.clear();
		}
		// shift the other waypoint lists down
		else
		{
			// remove this particular waypoint list
			SCP_list<waypoint_list>::iterator ii;
			int i;
			for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii)
			{
				if (i == this_list)
				{
					Waypoint_lists.erase(ii);
					break;
				}
			}
			Assert(ii != Waypoint_lists.end());

			// iterate through all waypoints that are in lists later than this one,
			// and edit their instances so that they point to a list one place lower
			for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp))
			{
				if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) > this_list))
					objp->instance -= 0x10000;
			}
		}
	}
	// shift the other waypoints down
	else
	{
		// remove this particular waypoint
		SCP_vector<waypoint>::iterator ii;
		int i;
		for (i = 0, ii = wp_list->get_waypoints().begin(); ii != wp_list->get_waypoints().end(); ++i, ++ii)
		{
			if (i == this_index)
			{
				wp_list->get_waypoints().erase(ii);
				break;
			}
		}
		Assert(ii != wp_list->get_waypoints().end());

		// iterate through all waypoints that are later than this one,
		// and edit their instances so that they point to a waypoint one place lower
		for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp))
		{
			if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) == this_list) && (calc_waypoint_index(objp->instance) > this_index))
				objp->instance--;
		}
	}

	// FRED has its own object removal logic
	if (!Fred_running)
		obj_delete(objnum);
}
コード例 #19
0
int collide_remove_weapons( )
{
	obj_pair *opp;
	int i, num_deleted, oldest_index, j, loop_count;
	float oldest_time;

	// setup remove_weapon array.  assume we can remove it.
	for (i = 0; i < MAX_WEAPONS; i++ ) {
		if ( Weapons[i].objnum == -1 )
			crw_status[i] = CRW_NO_OBJECT;
		else
			crw_status[i] = CRW_NO_PAIR;
	}

	// first pass is to see if any of the weapons don't have collision pairs.

	if ( Cmdline_old_collision_sys ) {
		opp = &pair_used_list;
		opp = opp->next;
		while( opp != NULL )	{
			// for each collide pair, if the two objects can still collide, then set the remove_weapon
			// parameter for the weapon to 0.  need to check both parameters
			if ( opp->a->type == OBJ_WEAPON )
				crw_check_weapon( opp->a->instance, opp->next_check_time );

			if ( opp->b->type == OBJ_WEAPON )
				crw_check_weapon( opp->b->instance, opp->next_check_time );

			opp = opp->next;
		}
	} else {
		SCP_hash_map<uint, collider_pair>::iterator it;
		collider_pair *pair_obj;

		for ( it = Collision_cached_pairs.begin(); it != Collision_cached_pairs.end(); ++it ) {
			pair_obj = &it->second;
			
			if ( !pair_obj->initialized ) {
				continue;
			}

			if ( pair_obj->a->type == OBJ_WEAPON && pair_obj->signature_a == pair_obj->a->signature ) {
				crw_check_weapon(pair_obj->a->instance, pair_obj->next_check_time);

				if ( crw_status[pair_obj->a->instance] == CRW_CAN_DELETE ) {
					pair_obj->initialized = false;
				}
			}

			if ( pair_obj->b->type == OBJ_WEAPON && pair_obj->signature_b == pair_obj->b->signature ) {
				crw_check_weapon(pair_obj->b->instance, pair_obj->next_check_time);

				if ( crw_status[pair_obj->b->instance] == CRW_CAN_DELETE ) {
					pair_obj->initialized = false;
				}
			}
		}
	}

	// for each weapon which could be removed, delete the object
	num_deleted = 0;
	for ( i = 0; i < MAX_WEAPONS; i++ ) {
		if ( crw_status[i] == CRW_CAN_DELETE ) {
			Assert( Weapons[i].objnum != -1 );
			obj_delete( Weapons[i].objnum );
			num_deleted++;
		}
	}

	if ( num_deleted )
		return num_deleted;

	// if we didn't remove any weapons, try to the N oldest weapons.  first checking for pairs, then
	// checking for oldest weapons in general.  We will go through the loop a max of 2 times.  first time
	// through, we check oldest weapons with pairs, next time through, for oldest weapons.
	loop_count = 0;
	do {
		for ( j = 0; j < CRW_MAX_TO_DELETE; j++ ) {
			oldest_time = 1000.0f;
			oldest_index = -1;
			for (i = 0; i < MAX_WEAPONS; i++ ) {
				if ( Weapons[i].objnum == -1 )			// shouldn't happen, but this is the safe thing to do.
					continue;
				if ( ((loop_count || crw_status[i] == CRW_NO_PAIR)) && (Weapons[i].lifeleft < oldest_time) ) {
					oldest_time = Weapons[i].lifeleft;
					oldest_index = i;
				}
			}
			if ( oldest_index != -1 ) {
				obj_delete(Weapons[oldest_index].objnum);
				num_deleted++;
			}
		}

		// if we deleted some weapons, then we can break
		if ( num_deleted )
			break;

		loop_count++;
	} while ( loop_count < 2);

	return num_deleted;

}
コード例 #20
0
void briefing_editor_dlg::update_data(int update)
{
	char buf[MAX_LABEL_LEN], buf2[MAX_ICON_TEXT_LEN], buf3[MAX_BRIEF_LEN];
	int i, j, l, lines, count, enable = TRUE, valid = 0, invalid = 0;
	object *objp;
	brief_stage *ptr = NULL;

	if (update)
		UpdateData(TRUE);

	// save off current data before we update over it with new briefing stage/team stuff
	Briefing = save_briefing;

	Mission_music[SCORE_BRIEFING] = m_briefing_music - 1;
	strcpy(The_mission.substitute_briefing_music_name, m_substitute_briefing_music);
	if (m_last_stage >= 0) {
		ptr = &Briefing->stages[m_last_stage];
		deconvert_multiline_string(buf3, m_text, MAX_BRIEF_LEN);
		if (stricmp(ptr->new_text, buf3))
			set_modified();

		strcpy(ptr->new_text, buf3);
		MODIFY(ptr->camera_time, atoi(m_time));
		string_copy(ptr->voice, m_voice, MAX_FILENAME_LEN, 1);
		i = ptr->flags;
		if (m_cut_prev)
			i |= BS_BACKWARD_CUT;
		else
			i &= ~BS_BACKWARD_CUT;

		if (m_cut_next)
			i |= BS_FORWARD_CUT;
		else
			i &= ~BS_FORWARD_CUT;

		MODIFY(ptr->flags, i);
		ptr->formula = m_tree.save_tree();
		switch (m_lines.GetCheck()) {
			case 1:
				// add lines between every pair of 2 marked icons if there isn't one already.
				for (i=0; i<ptr->num_icons - 1; i++)
					for (j=i+1; j<ptr->num_icons; j++) {
						if ( icon_marked[i] && icon_marked[j] ) {
							for (l=0; l<ptr->num_lines; l++)
								if ( ((ptr->lines[l].start_icon == i) && (ptr->lines[l].end_icon == j)) || ((ptr->lines[l].start_icon == j) && (ptr->lines[l].end_icon == i)) )
									break;

							if ((l == ptr->num_lines) && (l < MAX_BRIEF_STAGE_LINES)) {
								ptr->lines[l].start_icon = i;
								ptr->lines[l].end_icon = j;
								ptr->num_lines++;
							}
						}
					}

				break;

			case 0:
				// remove all existing lines between any 2 marked icons
				i = ptr->num_lines;
				while (i--)
					if ( icon_marked[ptr->lines[i].start_icon] && icon_marked[ptr->lines[i].end_icon] ) {
						ptr->num_lines--;
						for (l=i; l<ptr->num_lines; l++)
							ptr->lines[l] = ptr->lines[l + 1];
					}

				break;
		}

		if (m_last_icon >= 0) {
			valid = (m_id != ptr->icons[m_last_icon].id);
			if (m_id >= 0) {
				if (valid && !m_change_local) {
					for (i=m_last_stage+1; i<Briefing->num_stages; i++) {
						if (find_icon(m_id, i) >= 0) {
							char msg[1024];

							valid = 0;
							sprintf(msg, "Icon ID #%d is already used in a later stage.  You can only\n"
								"change to that ID locally.  Icon ID has been reset back to %d", m_id, ptr->icons[m_last_icon].id);

							m_id = ptr->icons[m_last_icon].id;
							MessageBox(msg);
							break;
						}
					}
				}

				for (i=0; i<ptr->num_icons; i++)
					if ((i != m_last_icon) && (ptr->icons[i].id == m_id)) {
						char msg[1024];

						sprintf(msg, "Icon ID #%d is already used in this stage.  Icon ID has been reset back to %d",
							m_id, ptr->icons[m_last_icon].id);

						m_id = ptr->icons[m_last_icon].id;
						MessageBox(msg);
						break;
					}

				if (valid && !m_change_local) {
					set_modified();
					reset_icon_loop(m_last_stage);
					while (get_next_icon(ptr->icons[m_last_icon].id))
						iconp->id = m_id;
				}
			}

			ptr->icons[m_last_icon].id = m_id;
			string_copy(buf, m_icon_label, MAX_LABEL_LEN);
			if (stricmp(ptr->icons[m_last_icon].label, buf) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					strcpy(iconp->label, buf);
			}

			strcpy(ptr->icons[m_last_icon].label, buf);
			if ( m_hilight )
				ptr->icons[m_last_icon].flags |= BI_HIGHLIGHT;
			else
				ptr->icons[m_last_icon].flags &= ~BI_HIGHLIGHT;

			if (m_flipicon)
				ptr->icons[m_last_icon].flags |= BI_MIRROR_ICON;
			else
				ptr->icons[m_last_icon].flags &= ~BI_MIRROR_ICON;

			if ((ptr->icons[m_last_icon].type != m_icon_image) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					iconp->type = m_icon_image;
			}

			ptr->icons[m_last_icon].type = m_icon_image;
			if ((ptr->icons[m_last_icon].team != m_icon_team) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					iconp->team = m_icon_team;
			}

			ptr->icons[m_last_icon].team = m_icon_team;
			if ((ptr->icons[m_last_icon].ship_class != m_ship_type) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					iconp->ship_class = m_ship_type;
			}

			MODIFY(ptr->icons[m_last_icon].ship_class, m_ship_type);
			deconvert_multiline_string(buf2, m_icon_text, MAX_ICON_TEXT_LEN);
/*
			if (stricmp(ptr->icons[m_last_icon].text, buf2) && !m_change_local) {
				set_modified();
				reset_icon_loop(m_last_stage);
				while (get_next_icon(m_id))
					strcpy(iconp->text, buf2);
			}

			strcpy(ptr->icons[m_last_icon].text, buf2);
*/
		}
	}

	if (!::IsWindow(m_hWnd))
		return;

	// set briefing pointer to correct team
	Briefing = &Briefings[m_current_briefing];

	if ((m_cur_stage >= 0) && (m_cur_stage < Briefing->num_stages)) {
		ptr = &Briefing->stages[m_cur_stage];
		m_stage_title.Format("Stage %d of %d", m_cur_stage + 1, Briefing->num_stages);
		m_text = convert_multiline_string(ptr->new_text);
		m_time.Format("%d", ptr->camera_time);
		m_voice = ptr->voice;
		m_cut_prev = (ptr->flags & BS_BACKWARD_CUT) ? 1 : 0;
		m_cut_next = (ptr->flags & BS_FORWARD_CUT) ? 1 : 0;
		m_tree.load_tree(ptr->formula);

	} else {
		m_stage_title = _T("No stages");
		m_text = _T("");
		m_time = _T("");
		m_voice = _T("");
		m_cut_prev = m_cut_next = 0;
		m_tree.clear_tree();
		enable = FALSE;
		m_cur_stage = -1;
	}

	if (m_cur_stage == Briefing->num_stages - 1)
		GetDlgItem(IDC_NEXT) -> EnableWindow(FALSE);
	else
		GetDlgItem(IDC_NEXT) -> EnableWindow(enable);

	if (m_cur_stage)
		GetDlgItem(IDC_PREV) -> EnableWindow(enable);
	else
		GetDlgItem(IDC_PREV) -> EnableWindow(FALSE);

	if (Briefing->num_stages >= MAX_BRIEF_STAGES)
		GetDlgItem(IDC_ADD_STAGE) -> EnableWindow(FALSE);
	else
		GetDlgItem(IDC_ADD_STAGE) -> EnableWindow(TRUE);

	if (Briefing->num_stages) {
		GetDlgItem(IDC_DELETE_STAGE) -> EnableWindow(enable);
		GetDlgItem(IDC_INSERT_STAGE) -> EnableWindow(enable);
	} else {
		GetDlgItem(IDC_DELETE_STAGE) -> EnableWindow(FALSE);
		GetDlgItem(IDC_INSERT_STAGE) -> EnableWindow(FALSE);
	}

	GetDlgItem(IDC_TIME) -> EnableWindow(enable);
	GetDlgItem(IDC_VOICE) -> EnableWindow(enable);
	GetDlgItem(IDC_BROWSE) -> EnableWindow(enable);
	GetDlgItem(IDC_TEXT) -> EnableWindow(enable);
	GetDlgItem(IDC_SAVE_VIEW) -> EnableWindow(enable);
	GetDlgItem(IDC_GOTO_VIEW) -> EnableWindow(enable);
	GetDlgItem(IDC_CUT_PREV) -> EnableWindow(enable);
	GetDlgItem(IDC_CUT_NEXT) -> EnableWindow(enable);
	GetDlgItem(IDC_TREE) -> EnableWindow(enable);
	GetDlgItem(IDC_PLAY) -> EnableWindow(enable);

	if ((m_cur_stage >= 0) && (m_cur_icon >= 0) && (m_cur_icon < ptr->num_icons)) {
		m_hilight = (ptr->icons[m_cur_icon].flags & BI_HIGHLIGHT)?1:0;
		m_flipicon = (ptr->icons[m_cur_icon].flags & BI_MIRROR_ICON)?1:0;
		m_icon_image = ptr->icons[m_cur_icon].type;
		m_icon_team = ptr->icons[m_cur_icon].team;
		m_icon_label = ptr->icons[m_cur_icon].label;
		m_ship_type = ptr->icons[m_cur_icon].ship_class;
//		m_icon_text = convert_multiline_string(ptr->icons[m_cur_icon].text);
		m_id = ptr->icons[m_cur_icon].id;
		enable = TRUE;

	} else {
		m_flipicon = FALSE;
		m_hilight = FALSE;
		m_icon_image = -1;
		m_icon_team = -1;
		m_ship_type = -1;
		m_icon_label = _T("");
		m_cur_icon = -1;
		m_id = 0;
		enable = FALSE;
	}

	GetDlgItem(IDC_ICON_TEXT) -> EnableWindow(enable);
	GetDlgItem(IDC_ICON_LABEL) -> EnableWindow(enable);
	GetDlgItem(IDC_ICON_IMAGE) -> EnableWindow(enable);
	GetDlgItem(IDC_SHIP_TYPE) -> EnableWindow(enable);
	GetDlgItem(IDC_HILIGHT) -> EnableWindow(enable);
	GetDlgItem(IDC_FLIP_ICON) -> EnableWindow(enable);
	GetDlgItem(IDC_LOCAL) -> EnableWindow(enable);
	GetDlgItem(IDC_TEAM) -> EnableWindow(enable);
	GetDlgItem(IDC_ID) -> EnableWindow(enable);
	GetDlgItem(IDC_DELETE_ICON) -> EnableWindow(enable);

	valid = invalid = 0;
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags & OF_MARKED) {
			if ((objp->type == OBJ_SHIP) || (objp->type == OBJ_START) || (objp->type == OBJ_WAYPOINT) || (objp->type == OBJ_JUMP_NODE))
				valid = 1;
			else
				invalid = 1;
		}

		objp = GET_NEXT(objp);
	}

	if (m_cur_stage >= 0)
		ptr = &Briefing->stages[m_cur_stage];

	if (valid && !invalid && (m_cur_stage >= 0) && (ptr->num_icons < MAX_STAGE_ICONS))
		GetDlgItem(IDC_MAKE_ICON) -> EnableWindow(TRUE);
	else
		GetDlgItem(IDC_MAKE_ICON) -> EnableWindow(FALSE);

	if (m_cur_stage >= 0)
		for (i=0; i<ptr->num_icons; i++)
			icon_marked[i] = 0;

	valid = invalid = 0;
	objp = GET_FIRST(&obj_used_list);
	while (objp != END_OF_LIST(&obj_used_list)) {
		if (objp->flags & OF_MARKED) {
			if (objp->type == OBJ_POINT) {
				valid++;
				icon_marked[objp->instance] = 1;

			} else
				invalid++;
		}

		objp = GET_NEXT(objp);
	}

	if (valid && !invalid && (m_cur_stage >= 0))
		GetDlgItem(IDC_PROPAGATE_ICONS) -> EnableWindow(TRUE);
	else
		GetDlgItem(IDC_PROPAGATE_ICONS) -> EnableWindow(FALSE);

	count = 0;
	lines = 1;  // default lines checkbox to checked
	
	if (m_cur_stage >= 0) {
		for (i=0; i<ptr->num_lines; i++)
			line_marked[i] = 0;

		// go through and locate all lines between marked icons
		for (i=0; i<ptr->num_icons - 1; i++)
			for (j=i+1; j<ptr->num_icons; j++) {
				if ( icon_marked[i] && icon_marked[j] ) {
					for (l=0; l<ptr->num_lines; l++)
						if ( ((ptr->lines[l].start_icon == i) && (ptr->lines[l].end_icon == j)) || ((ptr->lines[l].start_icon == j) && (ptr->lines[l].end_icon == i)) ) {
							line_marked[l] = 1;
							count++;  // track number of marked lines (lines between 2 icons that are both marked)
							break;
						}

					// at least 1 line missing between 2 marked icons, so use mixed state
					if (l == ptr->num_lines)
						lines = 2;
				}
			}
	}

	// not even 1 line between any 2 marked icons?  Set checkbox to unchecked.
	if (!count)
		lines = 0;

	i = 0;
	if (m_cur_stage >= 0){
		i = calc_num_lines_for_icons(valid) + ptr->num_lines - count;
	}

	if ((valid > 1) && !invalid && (m_cur_stage >= 0) && (i <= MAX_BRIEF_STAGE_LINES))
		GetDlgItem(IDC_LINES) -> EnableWindow(TRUE);
	else
		GetDlgItem(IDC_LINES) -> EnableWindow(FALSE);

	m_lines.SetCheck(lines);

	UpdateData(FALSE);
	if ((m_last_stage != m_cur_stage) || (Briefing != save_briefing)) {
		if (m_last_stage >= 0) {
			for (i=0; i<save_briefing->stages[m_last_stage].num_icons; i++) {
				// save positions of all icons, in case they have moved
				save_briefing->stages[m_last_stage].icons[i].pos = Objects[icon_obj[i]].pos;
				// release objects being used by last stage
				obj_delete(icon_obj[i]);
			}
		}

		if (m_cur_stage >= 0) {
			for (i=0; i<ptr->num_icons; i++) {
				// create an object for each icon for display/manipulation purposes
				icon_obj[i] = obj_create(OBJ_POINT, -1, i, NULL, &ptr->icons[i].pos, 0.0f, OF_RENDERS);
			}

			obj_merge_created_list();
		}

		m_last_stage = m_cur_stage;
	}

	m_last_icon = m_cur_icon;
	Update_window = 1;
	save_briefing = Briefing;
}
コード例 #21
0
/*
 * test == 1: get next pid
 * test == 2: get next oid
 * test == 3: check existing obj
 * test == 4: check non existing obj
 * test == 5: check if pid empty
 * test == 6: get type
 */
static void time_obj_generic(struct osd_device *osd, int numobj, int numiter,
			     int test)
{
	int ret = 0;
	int i = 0, j = 0;
	uint64_t start, end;
	uint64_t oid = 0, pid = 0;
	int present = 0;
	int isempty = 0;
	uint8_t obj_type = ILLEGAL_OBJ;
	double *t = 0;
	double mu, sd;
	const char *func = NULL;

	if (test < 1 || test > 6)
		return;

	t = Malloc(sizeof(*t) * numiter);
	if (!t)
		return;

	/* run a pilot */
	switch (test) {
	case 1: {
		ret = obj_insert(osd->dbc, 20, 0, 2);
		assert(ret == 0);
		pid = 0;
		ret = obj_get_nextpid(osd->dbc, &pid);
		assert(ret == 0);
		assert(pid == 21);
		ret = obj_delete(osd->dbc, 20, 0);
		assert(ret == 0);
		func = "get_next_pid";
		break;
	}
	case 2: {
		ret = obj_insert(osd->dbc, 1, 2, 128);
		assert(ret == 0);
		oid = 0;
		ret = obj_get_nextoid(osd->dbc, 1, &oid);
		assert(ret == 0);
		assert(oid == 3);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		func = "get_next_oid";
		break;
	}
	case 3: 
	case 4: {
		ret = obj_insert(osd->dbc, 1, 2, 128);
		assert(ret == 0);
		ret = obj_ispresent(osd->dbc, 1, 2, &present);
		assert(ret == 0 && present == 1);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		ret = obj_ispresent(osd->dbc, 1, 2, &present);
		assert(ret == 0 && present == 0);
		if (test == 3)
			func = "objpresent";
		else
			func = "objnotpresent";
		break;
	}
	case 5: {
		ret = obj_insert(osd->dbc, 1, 2, 128);
		assert(ret == 0);
		ret = obj_isempty_pid(osd->dbc, 1, &isempty);
		assert(ret == 0 && isempty == 0);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		ret = obj_isempty_pid(osd->dbc, 1, &isempty);
		assert(ret == 0 && isempty == 1);
		func = "objemptypid";
		break;
	}
	case 6: {
		ret = obj_insert(osd->dbc, 1, 2, USEROBJECT);
		assert(ret == 0);
		ret = obj_get_type(osd->dbc, 1, 2, &obj_type);
		assert(ret == 0 && obj_type == USEROBJECT);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		func = "objgettype";
		break;
	}
	default:
		fprintf(stderr, "1 <= test <= 6\n");
		exit(1);
	}

	for (i = 0; i < numiter; i++) {
		for (j = 1; j < numobj+1; j++) {
			if (test == 1) {
				ret = obj_insert(osd->dbc, j, 0, PARTITION);
			} else {
				ret = obj_insert(osd->dbc, 1, j, USEROBJECT);
			}
			assert(ret == 0);
		}

		switch (test) {
		case 1: {
			pid = 0;
			rdtsc(start);
			ret = obj_get_nextpid(osd->dbc, &pid);
			rdtsc(end);
			assert(ret == 0);
			assert(pid == (uint64_t)(numobj+1));
			break;
		}
		case 2: {
			oid = 0;
			rdtsc(start);
			ret = obj_get_nextoid(osd->dbc, 1, &oid);
			rdtsc(end);
			assert(ret == 0);
			assert(oid == (uint64_t)(numobj+1));
			break;
		}
		case 3: {
			oid = numobj;
			rdtsc(start);
			ret = obj_ispresent(osd->dbc, 1, oid, &present);
			rdtsc(end);
			assert(ret == 0 && present == 1);
			break;
		}
		case 4: {
			oid = numobj+2;
			rdtsc(start);
			ret = obj_ispresent(osd->dbc, 1, oid, &present);
			rdtsc(end);
			assert(ret == 0 && present == 0);
			break;
		}
		case 5: {
			rdtsc(start);
			ret = obj_isempty_pid(osd->dbc, 1, &isempty);
			rdtsc(end);
			assert(ret == 0 && isempty == 0);
			break;
		}
		case 6: {
			oid = numobj;
			rdtsc(start);
			ret = obj_get_type(osd->dbc, 1, oid, &obj_type);
			rdtsc(end);
			assert(ret == 0 && obj_type == USEROBJECT);
			break;
		}
		default:
			fprintf(stderr, "1 <= test <= 6\n");
			exit(1);
		}

		t[i] = (double) (end - start) / mhz;
		start = end = 0;

		switch (test) {
		case 1: {
			for (j = 1; j < numobj+1; j++) {
				ret = obj_delete(osd->dbc, j, 0);
				assert(ret == 0);
			}
			break;
		}
		case 2:
		case 3:
		case 4:
		case 5:
		case 6: {
			ret = obj_delete_pid(osd->dbc, 1);
			assert(ret == 0);
			break;
		}
		default:
			fprintf(stderr, "1 <= test <= 6\n");
			exit(1);
		}
	}

	mu = mean(t, numiter);
	sd = stddev(t, mu, numiter);
	printf("%s numiter %d numobj %d test, %d avg %lf +- %lf us\n", func,
	       numiter, numobj, test, mu, sd); 
	free(t);
}
コード例 #22
0
static void time_obj_delete(struct osd_device *osd, int numobj, int numiter, 
			    int testone)
{
	int ret = 0;
	int i = 0, j = 0;
	uint64_t start, end;
	double *t = 0;
	double mu, sd;

	t = Malloc(sizeof(*t) * numiter);
	if (!t)
		return;

	ret = obj_insert(osd->dbc, 1, 2, 128);
	assert(ret == 0);
	ret = obj_delete(osd->dbc, 1, 2);
	assert(ret == 0);

	if (testone == 0) {
		for (i = 0; i < numiter; i++) {
			for (j = 0; j < numobj; j++) {
				ret = obj_insert(osd->dbc, 1, j, 128);
				assert(ret == 0);
			}

			t[i] = 0;
			for (j = 0; j < numobj; j++) {
				rdtsc(start);
				ret = obj_delete(osd->dbc, 1, j);
				rdtsc(end);
				assert(ret == 0);

				t[i] += (double)(end - start) / mhz;
			}

		}
	} else if (testone == 1) {
		for (i = 0; i < numobj; i++) {
			ret = obj_insert(osd->dbc, 1, i, 128);
			assert (ret == 0);
		}
		
		for (i = 0; i < numiter; i++) {
			ret = obj_insert(osd->dbc, 1, numobj, 128);
			assert(ret == 0);

			rdtsc(start);
			ret = obj_delete(osd->dbc, 1, numobj);
			rdtsc(end);
			assert(ret == 0);

			t[i] = (double)(end - start) / mhz;
		}

		ret = obj_delete_pid(osd->dbc, 1);
		assert (ret == 0);
	}

	mu = mean(t, numiter);
	sd = stddev(t, mu, numiter);
	printf("%s numiter %d numobj %d testone %d avg %lf +- %lf us\n", 
	       __func__, numiter, numobj, testone, mu, sd);
	free(t);
}
コード例 #23
0
ファイル: automap.c プロジェクト: CDarrow/DXX-Retro
int automap_key_command(window *wind, d_event *event, automap *am)
{
	int c = event_key_get(event);
	int marker_num;
	char maxdrop;

	switch (c)
	{
		case KEY_PRINT_SCREEN: {
			gr_set_current_canvas(NULL);
			save_screen_shot(1);
			return 1;
		}
			
		case KEY_ESC:
			if (am->leave_mode==0)
			{
				window_close(wind);
				return 1;
			}
			return 1;
			
#ifndef NDEBUG
		case KEY_DEBUGGED+KEY_F: 	{
				int i;
				
				for (i=0; i<=Highest_segment_index; i++ )
					Automap_visited[i] = 1;
				automap_build_edge_list(am);
				am->max_segments_away = set_segment_depths(Objects[Players[Player_num].objnum].segnum, Automap_visited);
				am->segment_limit = am->max_segments_away;
				adjust_segment_limit(am, am->segment_limit);
			}
			return 1;
#endif
			
		case KEY_F9:
			if (am->segment_limit > 1) 		{
				am->segment_limit--;
				adjust_segment_limit(am, am->segment_limit);
			}
			return 1;
		case KEY_F10:
			if (am->segment_limit < am->max_segments_away) 	{
				am->segment_limit++;
				adjust_segment_limit(am, am->segment_limit);
			}
			return 1;
		case KEY_1:
		case KEY_2:
		case KEY_3:
		case KEY_4:
		case KEY_5:
		case KEY_6:
		case KEY_7:
		case KEY_8:
		case KEY_9:
		case KEY_0:
			if (Game_mode & GM_MULTI)
				maxdrop=2;
			else
				maxdrop=9;
			
			marker_num = c-KEY_1;
			if (marker_num<=maxdrop)
			{
				if (MarkerObject[marker_num] != -1)
					HighlightMarker=marker_num;
			}
			return 1;
			
		case KEY_D+KEY_CTRLED:
			if (HighlightMarker > -1 && MarkerObject[HighlightMarker] != -1) {
				gr_set_current_canvas(NULL);
				if (nm_messagebox( NULL, 2, TXT_YES, TXT_NO, "Delete Marker?" ) == 0) {
					obj_delete(MarkerObject[HighlightMarker]);
					MarkerObject[HighlightMarker]=-1;
					MarkerMessage[HighlightMarker][0]=0;
					HighlightMarker = -1;
				}
				set_screen_mode(SCREEN_GAME);
			}
			return 1;
			
#ifndef RELEASE
		case KEY_F11:	//KEY_COMMA:
			if (MarkerScale>.5)
				MarkerScale-=.5;
			return 1;
		case KEY_F12:	//KEY_PERIOD:
			if (MarkerScale<30.0)
				MarkerScale+=.5;
			return 1;
#endif
	}
	
	return 0;
}
コード例 #24
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, 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);
	}
}