示例#1
0
// create objects for all known observers in the game at level start
// call this before entering a mission
// this implies for the local player in the case of a client or for _all_ players in the case of a server
void multi_obs_level_init()
{
	int idx;

	// unset the OBS_PLAYER flag here for all net players
	for (idx = 0; idx < MAX_PLAYERS; idx++)
	{
		Net_players[idx].flags &= ~(NETINFO_FLAG_OBS_PLAYER);
	}

	// if i'm a client and I'm an observer, create an object for myself
	if (!(Net_player->flags & NETINFO_FLAG_AM_MASTER) && (Net_player->flags & NETINFO_FLAG_OBSERVER))
	{
		// create my own observer object and setup other misc. data
		multi_obs_create_observer_client();
	}
		// otherwise create stuff for all (permanent) observers in the game
	else
	{
		for (idx = 0; idx < MAX_PLAYERS; idx++)
		{
			if (MULTI_CONNECTED(Net_players[idx]) && MULTI_OBSERVER(Net_players[idx]))
			{
				// make an observer object for the guy
				multi_obs_create_observer(&Net_players[idx]);
			}
		}
	}
}
示例#2
0
// 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));	
}
示例#3
0
// create observer object locally, and additionally, setup some other information
// ( client-side equivalent of multi_obs_create_observer() )
void multi_obs_create_observer_client()
{
	int pobj_num;

	Assert(!(Net_player->flags & NETINFO_FLAG_OBS_PLAYER));

	// make me an observer object
	multi_obs_create_observer(Net_player);

	// set my object to be the observer object	
	Player_obj = &Objects[Net_player->m_player->objnum];

	// create the default player ship object and use that as my default virtual "ship", and make it "invisible"
	pobj_num = parse_create_object(&Player_start_pobject);
	Assert(pobj_num != -1);
	obj_set_flags(&Objects[pobj_num], OF_PLAYER_SHIP);
	Player_ship = &Ships[Objects[pobj_num].instance];

	// make ship hidden from sensors so that this observer cannot target it.  Observers really have two ships
	// one observer, and one "Player_ship".  Observer needs to ignore the Player_ship.
	Player_ship->flags |= SF_HIDDEN_FROM_SENSORS;
	strcpy_s(Player_ship->ship_name, XSTR("Observer Ship", 688));
	Player_ai = &Ai_info[Ships[Objects[pobj_num].instance].ai_index];

	// configure the hud to be in "observer" mode
	hud_config_as_observer(Player_ship, Player_ai);

	// set some flags for myself
	Net_player->flags |= NETINFO_FLAG_OBSERVER;

	// reset the control info structure
	memset(&Player->ci, 0, sizeof(control_info));
}
示例#4
0
// <server> make the given player an observer
void multi_respawn_make_observer(net_player *pl)
{	
	pl->flags |= (NETINFO_FLAG_OBSERVER | NETINFO_FLAG_OBS_PLAYER);		
	pl->flags &= ~(NETINFO_FLAG_RESPAWNING | NETINFO_FLAG_LIMBO);

	// MWA 6/3/98 -- don't set to high -- let it default to whatever player chose 
	//pl->p_info.options.obj_update_level = OBJ_UPDATE_HIGH;
	pl->last_heard_time = timer_get_fixed_seconds();	

	// reset the ping time for this player
	multi_ping_reset(&pl->s_info.ping);
	
	// timestamp his last_full_update_time
	pl->s_info.last_full_update_time = timestamp(0);

	// create an observer object for him
	multi_obs_create_observer(pl);		
}