void send_netgame_packet(ubyte *server, ubyte *node) { int i, j; int loc = 0; if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { send_d1x_netgame_packet(server, node); return; } memset(out_buffer, 0, MAX_DATA_SIZE); out_buffer[loc] = Netgame.type; loc++; memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1); memcpy(&(out_buffer[loc]), Netgame.team_name, 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1); out_buffer[loc] = Netgame.gamemode; loc++; out_buffer[loc] = Netgame.difficulty; loc++; out_buffer[loc] = Netgame.game_status; loc++; out_buffer[loc] = Netgame.numplayers; loc++; out_buffer[loc] = Netgame.max_numplayers; loc++; out_buffer[loc] = Netgame.game_flags; loc++; for (i = 0; i < MAX_PLAYERS; i++) { put_netplayer_info(&(out_buffer[loc]), &Netgame.players[i], 0); loc += sizeof(netplayer_info); } if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { for (i = 0; i < MAX_PLAYERS; i++) { out_buffer[loc] = Netgame.locations[i]; loc++; } } else { for (i = 0; i < MAX_PLAYERS; i++) { PUT_INTEL_INT(out_buffer + loc, Netgame.locations[i]); loc += 4; // SWAP HERE!!! } } for (i = 0; i < MAX_PLAYERS; i++) { for (j = 0; j < MAX_PLAYERS; j++) { PUT_INTEL_SHORT(out_buffer + loc, Netgame.kills[i][j]); loc += 2; // SWAP HERE!!! } } PUT_INTEL_INT(out_buffer + loc, Netgame.levelnum); loc += 4; // SWAP_HERE out_buffer[loc] = Netgame.protocol_version; loc++; out_buffer[loc] = Netgame.team_vector; loc++; PUT_INTEL_SHORT(out_buffer + loc, Netgame.segments_checksum); loc += 2; // SWAP_HERE PUT_INTEL_SHORT(out_buffer + loc, Netgame.team_kills[0]); loc += 2; // SWAP_HERE PUT_INTEL_SHORT(out_buffer + loc, Netgame.team_kills[1]); loc += 2; // SWAP_HERE for (i = 0; i < MAX_PLAYERS; i++) { PUT_INTEL_SHORT(out_buffer + loc, Netgame.killed[i]); loc += 2; // SWAP HERE!!! } for (i = 0; i < MAX_PLAYERS; i++) { PUT_INTEL_SHORT(out_buffer + loc, Netgame.player_kills[i]); loc += 2; // SWAP HERE!!! } PUT_INTEL_INT(out_buffer + loc, Netgame.level_time); loc += 4; // SWAP_HERE PUT_INTEL_INT(out_buffer + loc, Netgame.control_invul_time); loc += 4; // SWAP_HERE PUT_INTEL_INT(out_buffer + loc, Netgame.monitor_vector); loc += 4; // SWAP_HERE for (i = 0; i < 8; i++) { PUT_INTEL_INT(out_buffer + loc, Netgame.player_score[i]); loc += 4; // SWAP_HERE } for (i = 0; i < 8; i++) { out_buffer[loc] = Netgame.player_flags[i]; loc++; } memcpy(&(out_buffer[loc]), Netgame.mission_name, 9); loc += 9; memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1); if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { out_buffer[loc] = Netgame.packets_per_sec; loc++; PUT_INTEL_INT(out_buffer + loc, Netgame.flags); loc += 4; } if (server == NULL) NetDrvSendBroadcastPacketData(out_buffer, loc); else NetDrvSendInternetworkPacketData( out_buffer, loc, server, node ); }
void send_netgame_packet(ubyte *server, ubyte *node) { uint tmpi; ushort tmps; int i, j; int loc = 0; #ifndef SHAREWARE if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { send_d1x_netgame_packet(server, node); return; } #endif memset(out_buffer, 0, IPX_MAX_DATA_SIZE); out_buffer[loc] = Netgame.type; loc++; memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1); memcpy(&(out_buffer[loc]), Netgame.team_name, 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1); out_buffer[loc] = Netgame.gamemode; loc++; out_buffer[loc] = Netgame.difficulty; loc++; out_buffer[loc] = Netgame.game_status; loc++; out_buffer[loc] = Netgame.numplayers; loc++; out_buffer[loc] = Netgame.max_numplayers; loc++; out_buffer[loc] = Netgame.game_flags; loc++; for (i = 0; i < MAX_PLAYERS; i++) { memcpy(&(out_buffer[loc]), Netgame.players[i].callsign, CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1; memcpy(&(out_buffer[loc]), Netgame.players[i].server, 4); loc += 4; memcpy(&(out_buffer[loc]), Netgame.players[i].node, 6); loc += 6; memcpy(&(out_buffer[loc]), &(Netgame.players[i].socket), 2); loc += 2; memcpy(&(out_buffer[loc]), &(Netgame.players[i].connected), 1); loc++; } if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { for (i = 0; i < MAX_PLAYERS; i++) { out_buffer[loc] = Netgame.locations[i]; loc++; } } else { for (i = 0; i < MAX_PLAYERS; i++) { tmpi = swapint(Netgame.locations[i]); memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP HERE!!! } } for (i = 0; i < MAX_PLAYERS; i++) { for (j = 0; j < MAX_PLAYERS; j++) { tmps = swapshort(Netgame.kills[i][j]); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!! } } tmpi = swapint(Netgame.levelnum); memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE out_buffer[loc] = Netgame.protocol_version; loc++; out_buffer[loc] = Netgame.team_vector; loc++; tmps = swapshort(Netgame.segments_checksum); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE tmps = swapshort(Netgame.team_kills[0]); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE tmps = swapshort(Netgame.team_kills[1]); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE for (i = 0; i < MAX_PLAYERS; i++) { tmps = swapshort(Netgame.killed[i]); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!! } for (i = 0; i < MAX_PLAYERS; i++) { tmps = swapshort(Netgame.player_kills[i]); memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!! } #ifndef SHAREWARE tmpi = swapint(Netgame.level_time); memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE tmpi = swapint(Netgame.control_invul_time); memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE tmpi = swapint(Netgame.monitor_vector); memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE for (i = 0; i < 8; i++) { tmpi = swapint(Netgame.player_score[i]); memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE } for (i = 0; i < 8; i++) { memcpy(&(out_buffer[loc]), &(Netgame.player_flags[i]), 1); loc++; } memcpy(&(out_buffer[loc]), Netgame.mission_name, 9); loc += 9; memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1); if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { out_buffer[loc] = Netgame.packets_per_sec; loc++; tmpi = swapint(Netgame.flags); memcpy(&out_buffer[loc], &tmpi, 4); loc += 4; } #endif if (server == NULL) ipx_send_broadcast_packet_data(out_buffer, loc); else ipx_send_internetwork_packet_data( out_buffer, loc, server, node ); }