62 #define NETGAME_SEND_TIME 2 // time between sending netgame update packets
63 #define STATE_SEND_TIME 2 // time between sending netplayer state packets
64 #define GAMEINFO_SEND_TIME 3 // time between sending game information packets
65 #define PING_SEND_TIME 2 // time between player pings
66 #define BYTES_SENT_TIME 5 // every five seconds
69 #define MAX_NET_BUFFER (1024 * 16) // define and variable declaration for our local tcp buffer
70 #define NUM_REENTRANT_LEVELS 3
73 #define MULTI_SERVER_MAX_TIMEOUT (F1_0 * 4) // after this number of milliseoncds, stop client simulation
74 #define MULTI_SERVER_MAX_TIMEOUT_LARGE (F1_0 * 40) // done anytime not in mission
75 #define MULTI_SERVER_WAIT_TIME (F1_0 * 60) // wait 60 seconds to reconnect with the server
76 #define MULTI_SERVER_GONE 1
77 #define MULTI_SERVER_ALIVE 2
80 #define MULTI_SERVER_SLOW_PING_TIME 700 // when average ping time to server reaches this -- display hud icon
83 #define MULTI_CLIENT_UPDATE_TIME 333
167 Assert( Net_player == NULL );
177 Net_player = &Net_players[0];
180 Net_player->
flags = 0;
241 Active_game_head = NULL;
242 Game_server_head = NULL;
265 memset(&Net_players[idx],0,
sizeof(
net_player));
362 ml_printf(
NOX(
"Accepted TCP connection from %s"), Net_players[i].m_player == NULL ?
NOX(
"Unknown") : Net_players[i].m_player->callsign);
368 if ( i == MAX_PLAYERS ) {
369 nprintf((
"Network",
"Got accept on my listen socket, but unknown player. Closing socket.\n"));
378 fix this_time, last_time, max;
386 if ( last_time > this_time )
389 this_time -= last_time;
398 if ( this_time > max){
451 if(Netgame.
server == NULL){
602 else if(Net_player != NULL){
922 nprintf((
"Network",
"Received packet with unknown type %d\n", data[0] ));
938 int type, bytes_processed;
954 memcpy(header_info.
addr, from_addr->
addr, 6);
957 header_info.
id = Net_players[player_num].
player_id;
963 while( (bytes_processed >= 0) && (bytes_processed < len) ) {
965 buf = &(data[bytes_processed]);
975 nprintf( (
"Network",
"multi_process_bigdata: Invalid packet type %d!\n", type ));
988 if(Net_player != NULL){
1017 ml_string(
"Shutting down rel socket because of disconnect!");
1022 if(Net_players[idx].s_info.reliable_connect_time != -1){
1029 ml_string(
"Player timed out while connecting on reliable socket!");
1039 if(Serverconn != 0xffffffff){
1042 mprintf((
"CLIENT SOCKET DISCONNECTED\n"));
1069 while( (size =
psnet_get(data, &from_addr))>0 ) {
1072 nprintf((
"Network",
"Tossing UDP like a good little ingame joiner...\n"));
1111 DCF(
eye_tog,
"Toggles setting of the local player eyepoint on every frame (Multiplayer)")
1128 if((Net_player != NULL) &&
eye_tog){
1250 if(Net_player != NULL){
1282 if(
MULTI_CONNECTED(Net_players[idx]) && (Net_player != &Net_players[idx])){
1443 MessageBox((
HWND)
os_get_window(),
XSTR(
"You have selected TCP/IP for multiplayer FreeSpace, but the TCP socket is already in use. Check for another instance and/or use the \"-port <port_num>\" command line option to select an available port.", 1620),
"Error",
MB_OK);
1451 #endif // ifdef _WIN32
1470 memset( &Netgame, 0,
sizeof(Netgame) );
1494 Net_player = &Net_players[0];
1535 nprintf((
"Network",
"STANDALONE USING LOW UPDATES\n"));
1538 nprintf((
"Network",
"STANDALONE USING MEDIUM UPDATES\n"));
1541 nprintf((
"Network",
"STANDALONE USING HIGH UPDATE\n"));
1544 nprintf((
"Network",
"STANDALONE USING LAN UPDATE\n"));
1628 if ( &Net_players[idx] != Net_player ) {
1715 Multi_debrief_server_framecount = 0;
1772 DCF(netd,
"change netgame debug flags (Mulitplayer)")
1816 if(
MULTI_CONNECTED(Net_players[idx]) && (Net_player != &Net_players[idx]) && (Net_players[idx].m_player != NULL)){
1817 if(Net_players[idx].sv_last_pl < 0){
1830 if(Net_player != NULL){
#define MULTI_TRACKER_STRING_LEN
int Multi_client_update_times[MAX_PLAYERS]
#define NETPLAYER_STATE_DEBRIEF
int timestamp(int delta_ms)
void multi_update_valid_missions()
int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who)
#define MULTIPLAYER_CLIENT
#define SUBSYSTEM_DESTROYED
#define MY_NET_PLAYER_NUM
#define NETGAME_STATE_DEBRIEF
char Multi_tracker_squad_name[MULTI_TRACKER_STRING_LEN+1]
void fs2netd_gameserver_start()
#define timestamp_elapsed_safe(_a, _b)
void multi_standalone_wait_init()
#define SUBSYS_CARGO_HIDDEN
void process_ship_create_packet(ubyte *data, header *hinfo)
void process_ai_info_update_packet(ubyte *data, header *hinfo)
void multi_voice_process_packet(ubyte *data, header *hinfo)
void process_ship_kill_packet(ubyte *data, header *hinfo)
void process_packet_normal(ubyte *data, header *header_info)
#define SHIP_STATUS_CHANGE
void process_ping_packet(ubyte *data, header *hinfo)
void multi_options_set_local_defaults(multi_local_options *options)
#define PLAYER_ORDER_PACKET
void process_change_iff_color_packet(ubyte *data, header *hinfo)
#define MULTI_SERVER_WAIT_TIME
#define NETINFO_FLAG_DO_NETWORKING
void standalone_main_init()
CFILE * Multi_chat_stream
int find_player(net_addr *addr)
void process_observer_update_packet(ubyte *data, header *hinfo)
uint PSNET_SOCKET_RELIABLE
int Multi_restr_query_timestamp
void multi_standalone_postgame_do()
void multi_reset_timestamps()
void send_netplayer_update_packet(net_player *pl)
void process_game_chat_packet(ubyte *data, header *hinfo)
void process_ingame_ship_request_packet(ubyte *data, header *hinfo)
int gameseq_get_state(void)
void multi_ping_send_all()
void process_countdown_packet(ubyte *data, header *hinfo)
void process_variable_update_packet(ubyte *data, header *hinfo)
void process_homing_weapon_info(ubyte *data, header *hinfo)
void standalone_main_close()
#define NETINFO_FLAG_OBSERVER
void process_ingame_ships_packet(ubyte *data, header *hinfo)
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
void process_turret_fired_packet(ubyte *data, header *hinfo)
void process_force_end_mission_packet(ubyte *data, header *hinfo)
void process_mission_request_packet(ubyte *data, header *hinfo)
int multi_kill_limit_reached()
int multi_netplayer_state_check(int state, int ignore_standalone)
void process_repair_info_packet(ubyte *data, header *hinfo)
void process_flak_fired_packet(ubyte *data, header *hinfo)
void process_subsystem_cargo_hidden_packet(ubyte *data, header *hinfo)
int Multi_display_netinfo
void process_mission_message_packet(ubyte *data, header *hinfo)
void multi_standalone_reset_all()
void process_debris_update_packet(ubyte *data, header *hinfo)
int find_player_id(short player_id)
void ml_string(const char *string, int add_time)
#define MULTI_END_ERROR_CONTACT_LOST
int multi_get_connection_speed()
void process_countermeasure_success_packet(ubyte *data, header *hinfo)
int multi_client_server_dead()
void process_wing_create_packet(ubyte *data, header *hinfo)
void process_host_captain_change_packet(ubyte *data, header *hinfo)
int psnet_get(void *data, net_addr *from_addr)
int Multi_server_check_count
void gr_set_color_fast(color *dst)
void send_netgame_update_packet(net_player *pl)
void process_sexp_packet(ubyte *data, header *hinfo)
void debrief_multi_server_stuff()
void multi_respawn_handle_invul_players()
void process_store_stats_packet(ubyte *data, header *hinfo)
void multi_oo_send_control_info()
void process_NEW_primary_fired_packet(ubyte *data, header *hinfo)
GLenum GLuint GLenum GLsizei const GLchar * buf
void standalone_main_do()
#define OBJECT_UPDATE_NEW
void process_debrief_info(ubyte *data, header *hinfo)
void multi_xfer_force_dir(int cf_type)
#define WINGS_INGAME_PACKET
#define CF_TYPE_MULTI_CACHE
char callsign[CALLSIGN_LEN+1]
void fs2netd_disconnect()
LOCAL ubyte Multi_read_count
int psnet_same(net_addr *a1, net_addr *a2)
#define SECONDARY_FIRED_PLR
void process_new_player_packet(ubyte *data, header *hinfo)
void get_info(vec3d *position, matrix *orientation)
void multi_create_list_load_missions()
void multi_endgame_process()
ushort Next_asteroid_signature
#define DCF(function_name, help_text)
The potent DCF macro, used to define new debug commands for the console.
void multi_handle_end_mission_request()
void multi_voice_process()
void process_netgame_update_packet(ubyte *data, header *hinfo)
int multi_oo_cirate_can_send()
#define MULTI_SERVER_ALIVE
#define MISSION_GOAL_INFO
void process_host_restr_packet(ubyte *data, header *hinfo)
int multi_endgame_ending()
void process_NEW_countermeasure_fired_packet(ubyte *data, header *hinfo)
player Players[MAX_PLAYERS]
void process_shield_explosion_packet(ubyte *data, header *hinfo)
void multi_process_bigdata(ubyte *data, int len, net_addr *from_addr, int reliable)
void process_beam_fired_packet(ubyte *data, header *hinfo)
void process_secondary_fired_packet(ubyte *data, header *hinfo, int from_player)
process a packet indicating a secondary weapon was fired
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void process_pong_packet(ubyte *data, header *hinfo)
void multi_options_read_config()
void process_game_active_packet(ubyte *data, header *hinfo)
void send_bytes_recvd_packet(net_player *pl)
void chatbox_reset_timestamps()
void process_hud_message(ubyte *data, header *hinfo)
void multi_client_check_server()
void multi_oo_process_update(ubyte *data, header *hinfo)
char Multi_tracker_passwd[MULTI_TRACKER_STRING_LEN+1]
void multi_campaign_process_ingame_start(ubyte *data, header *hinfo)
#define NETINFO_FLAG_AM_MASTER
void multi_options_process_packet(unsigned char *data, header *hinfo)
void ml_printf(const char *format,...)
#define MISSION_SYNC_DATA
void process_pslot_update_packet(ubyte *data, header *hinfo)
int voice_token_timestamp
void process_lightning_packet(ubyte *data, header *hinfo)
void process_netplayer_load_packet(ubyte *data, header *hinfo)
void process_event_update_packet(ubyte *data, header *hinfo)
multi_server_options options
void send_client_update_packet(net_player *pl)
PSNET_SOCKET_RELIABLE reliable_socket
void process_reinforcement_avail(ubyte *data, header *hinfo)
void multi_process_incoming()
#define GAMEINFO_SEND_TIME
#define STORE_MISSION_STATS
#define HOMING_WEAPON_UPDATE
#define ACCEPT_PLAYER_DATA
void multi_team_send_update()
void multi_respawn_init()
void process_endgame_packet(ubyte *data, header *hinfo)
#define COUNTERMEASURE_FIRED
void multi_respawn_check_ai()
#define SUBSYS_CARGO_REVEALED
#define NG_FLAG_STORED_MT_STATS
#define WSS_REQUEST_PACKET
int Multi_num_players_at_start
#define INGAME_SHIP_UPDATE
#define NETINFO_FLAG_MISSION_OK
void process_countermeasure_fired_packet(ubyte *data, header *hinfo)
void process_ship_status_packet(ubyte *data, header *hinfo)
void process_weapon_or_ammo_changed_packet(ubyte *data, header *hinfo)
#define NETGAME_END_ERROR
#define NETINFO_FLAG_INGAME_JOIN
#define FIRE_TURRET_WEAPON
#define PRIMARY_FIRED_NEW
void process_multi_pause_packet(ubyte *data, header *hinfo)
char Multi_tracker_id_string[255]
net_player_server_info s_info
int Multi_connection_speed
void multi_standalone_wait_close()
#define NETINFO_FLAG_HAXOR
#define FORCE_MISSION_END
bool dc_optional_string_either(const char *str1, const char *str2)
Searches for an optional string and it's alias.
void process_game_query(ubyte *data, header *hinfo)
#define NETINFO_FLAG_RELIABLE_CONNECTED
void process_subsystem_destroyed_packet(ubyte *data, header *hinfo)
void process_netplayer_update_packet(ubyte *data, header *hinfo)
void multi_pause_do_frame()
void process_cargo_hidden_packet(ubyte *data, header *hinfo)
int psnet_use_protocol(int protocol)
void process_wss_request_packet(ubyte *data, header *hinfo)
void multi_team_process_packet(unsigned char *data, header *hinfo)
void multi_standalone_postgame_init()
void multi_file_xfer_notify(int handle)
void process_player_settings_packet(ubyte *data, header *hinfo)
int reliable_connect_time
#define MULTI_SERVER_GONE
#define MULTI_SERVER_MAX_TIMEOUT
void process_client_update_packet(ubyte *data, header *hinfo)
void multi_xfer_init(void(*multi_xfer_recv_callback)(int handle))
void send_observer_update_packet()
void process_firing_info_packet(ubyte *data, header *hinfo)
ushort Multi_current_file_checksum
void std_reset_timestamps()
const char * XSTR(const char *str, int index)
#define NETGAME_SEND_TIME
void process_sw_query_packet(ubyte *data, header *hinfo)
void std_debug_set_standalone_state_string(char *str)
void process_self_destruct_packet(ubyte *data, header *hinfo)
void process_ship_weapon_change(ubyte *data, header *hinfo)
#define GM_STANDALONE_SERVER
void multi_create_standalone_object()
#define MULTI_END_NOTIFY_NONE
void process_change_ai_class_packet(ubyte *data, header *hinfo)
#define SECONDARY_FIRED_AI
void process_mission_sync_packet(ubyte *data, header *hinfo)
#define WSS_UPDATE_PACKET
#define NETGAME_STATE_IN_MISSION
void dc_stuff_int(int *i)
Stuffs an int to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats...
#define NETINFO_FLAG_CONNECTED
int Multi_debrief_server_framecount
void process_mission_item_packet(ubyte *data, header *hinfo)
void PSNET_TOP_LAYER_PROCESS()
void mission_goal_fail_incomplete()
#define SHIP_WSTATE_CHANGE
void process_ingame_ship_update_packet(ubyte *data, header *hinfo)
int multi_quit_game(int prompt, int notify_code, int err_code, int wsa_error)
void std_multi_set_standalone_missiontime(float mission_time)
void send_game_info_packet()
void process_netgame_end_error_packet(ubyte *data, header *hinfo)
#define NETPLAYER_STATE_WAITING
void process_subsystem_cargo_revealed_packet(ubyte *data, header *hinfo)
void multi_msg_process_squadmsg_packet(unsigned char *data, header *hinfo)
ushort Next_non_perm_signature
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
join_request Multi_restr_join_request
void process_leave_game_packet(ubyte *data, header *hinfo)
dc_printf("proper eye stuff is %s\n", eye_tog?"ON":"OFF")
void mission_campaign_eval_next_mission()
void process_bytes_recvd_packet(ubyte *data, header *hinfo)
void mission_campaign_store_goals_and_events_and_variables()
#define NETPLAYER_SLOTS_P
int Multi_join_restr_mode
void process_post_sync_data_packet(ubyte *data, header *hinfo)
void process_game_info_packet(ubyte *data, header *hinfo)
void multi_endgame_init()
void multi_handle_ingame_joiners()
void process_wss_update_packet(ubyte *data, header *hinfo)
void process_player_order_packet(ubyte *data, header *hinfo)
#define REINFORCEMENT_AVAIL
void process_ship_depart_packet(ubyte *data, header *hinfo)
void delete_player(int player_num, int kicked_reason)
LOCAL ubyte net_buffer[NUM_REENTRANT_LEVELS][MAX_NET_BUFFER]
#define MULTI_CONNECTED(np)
bool load_player(const char *callsign, player *_p=NULL)
#define OBJ_UPDATE_MEDIUM
fix timer_get_fixed_seconds()
#define NETPLAYER_STATE_DEBRIEF_ACCEPT
void process_asteroid_info(ubyte *data, header *hinfo)
#define INGAME_SHIP_REQUEST
#define MULTI_RELIABLE_CONNECT_WAIT
void process_player_kick_packet(ubyte *data, header *hinfo)
int psnet_rel_get(PSNET_SOCKET socketid, ubyte *buffer, int max_len)
class camera * getCamera()
void process_deny_packet(ubyte *data, header *hinfo)
void process_ingame_nak(ubyte *data, header *hinfo)
LOCAL fix Multi_server_wait_start
void process_netplayer_slot_packet(ubyte *data, header *hinfo)
void hud_setup_escort_list(int level)
void std_connect_set_gamename(char *name)
#define NG_FLAG_SERVER_LOST
#define MULTI_CLIENT_UPDATE_TIME
#define MULTIPLAYER_MASTER
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
int psnet_rel_get_status(PSNET_SOCKET_RELIABLE socketid)
void multi_kick_process()
#define NETPLAYER_STATE_INGAME_SHIP_SELECT
#define MULTI_PAUSE_REQUEST
int MessageBox(HWND h, const char *s1, const char *s2, int i)
GLenum GLsizei GLenum GLenum const GLvoid * data
void multi_check_listen()
void send_accept_player_data(net_player *npp, int is_ingame)
int Multi_current_file_length
#define timestamp_elapsed(stamp)
void process_emp_effect(ubyte *data, header *hinfo)
#define MULTI_SERVER_MAX_TIMEOUT_LARGE
int psnet_rel_check_for_listen(net_addr *from_addr)
int multi_client_wait_on_server()
#define IP_ADDRESS_LENGTH
void process_accept_player_data(ubyte *data, header *hinfo)
void multi_oo_gameplay_init()
void multi_process_reliable_details()
void process_change_iff_packet(ubyte *data, header *hinfo)
#define WEAPON_OR_AMMO_CHANGED
void multi_standalone_postgame_close()
void multi_standalone_wait_do()
active_game * Active_game_head
void process_weapon_detonate_packet(ubyte *data, header *hinfo)
#define MISSION_LOG_ENTRY
server_item * Game_server_head
int multi_is_valid_unknown_packet(ubyte type)
void process_accept_packet(ubyte *data, header *hinfo)
void process_player_pain_packet(ubyte *data, header *hinfo)
void process_jump_into_mission_packet(ubyte *data, header *hinfo)
void multi_load_common_icons()
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
void process_cargo_revealed_packet(ubyte *data, header *hinfo)
void process_wss_slots_data_packet(ubyte *data, header *hinfo)
#define NOTIFY_NEW_PLAYER
void multi_io_send_buffered_packets()
void multi_oo_rate_process()
void psnet_rel_close_socket(PSNET_SOCKET_RELIABLE *sockp)
void multi_debrief_server_process()
net_addr Multi_restr_addr
ushort Next_ship_signature
GLenum const GLvoid * addr
#define NETGAME_STATE_FORMING
void multi_create_list_load_campaigns()
void process_mission_goal_info_packet(ubyte *data, header *hinfo)
void process_player_stats_block_packet(ubyte *data, header *hinfo)
void multi_respawn_process_packet(ubyte *data, header *hinfo)
void process_join_packet(ubyte *data, header *hinfo)
#define MULTI_IS_TRACKER_GAME
net_player Net_players[MAX_PLAYERS]
void std_reset_standalone_gui()
void gameseq_post_event(int event)
void multi_rate_process()
#define PLAYER_FLAGS_MSG_MODE
void process_file_sig_packet(ubyte *data, header *hinfo)
char Multi_tracker_login[MULTI_TRACKER_STRING_LEN+1]
#define COUNTERMEASURE_NEW
#define CLIENT_REPAIR_INFO
multi_global_options Multi_options_g
ushort Next_debris_signature
void multi_display_netinfo()
void process_file_sig_request(ubyte *data, header *hinfo)
void process_ingame_wings_packet(ubyte *data, header *hinfo)
int Ingame_join_net_signature
multi_local_options options
void std_set_standalone_fps(float fps)
void std_multi_add_goals()
#define COUNTERMEASURE_SUCCESS
void process_netgame_descript_packet(ubyte *data, header *hinfo)
void multi_campaign_process_update(ubyte *data, header *hinfo)
#define NUM_REENTRANT_LEVELS
void process_mission_log_packet(ubyte *data, header *hinfo)
void multi_options_set_netgame_defaults(multi_server_options *options)
#define NG_FLAG_INGAME_JOINING
#define SHIPS_INGAME_PACKET
#define CAMPAIGN_UPDATE_INGAME