2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
15 * $Source: /cvs/cvsroot/d2x/main/netpkt.c,v $
18 * $Date: 2002-02-14 09:24:19 $
20 * Network packet conversions
21 * Based on macnet.c from MAC version of Descent 1
23 * $Log: not supported by cvs2svn $
24 * Revision 1.1 2002/02/14 09:05:33 bradleyb
25 * Lotsa networking stuff from d1x
44 void receive_netplayer_info(ubyte *data, netplayer_info *info, int d2x)
48 memcpy(info->callsign, &(data[loc]), CALLSIGN_LEN); loc += CALLSIGN_LEN;
49 info->callsign[CALLSIGN_LEN] = 0;
51 memcpy(&(info->network.ipx.server), &(data[loc]), 4); loc += 4;
52 memcpy(&(info->network.ipx.node), &(data[loc]), 6); loc += 6;
53 memcpy(&(info->socket), &(data[loc]), 2); loc += 2;
54 //MWA don't think we need to swap this because we need it in high order info->socket = swapshort(info->socket);
55 info->connected = data[loc]; loc++;
57 //edited 03/04/99 Matt Mueller - sub_protocol was being set wrong in non-d2x games.. I still think its screwed somewhere else too though
59 info->sub_protocol = data[loc]; loc++;
60 // printf ("%i "__FUNCTION__ " name=%s sub_protocol=%i\n",Player_num,info->callsign,info->sub_protocol);
62 info->sub_protocol = 0;
67 void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address)
73 memset(out_buffer, 0, sizeof(out_buffer));
74 out_buffer[0] = seq.type; loc++;
75 memcpy(&(out_buffer[loc]), seq.player.callsign, CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1;
76 memcpy(&(out_buffer[loc]), seq.player.network.ipx.server, 4); loc += 4;
77 memcpy(&(out_buffer[loc]), seq.player.network.ipx.node, 6); loc += 6;
78 tmps = swapshort(seq.player.socket);
79 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
80 out_buffer[loc] = seq.player.connected; loc++;
81 out_buffer[loc] = MULTI_PROTO_D2X_MINOR; loc++;
83 if (net_address != NULL)
84 ipx_send_packet_data( out_buffer, loc, server, node, net_address);
85 else if ((server == NULL) && (node == NULL))
86 ipx_send_broadcast_packet_data( out_buffer, loc );
88 ipx_send_internetwork_packet_data( out_buffer, loc, server, node);
91 void receive_sequence_packet(ubyte *data, sequence_packet *seq)
95 seq->type = data[0]; loc++;
96 receive_netplayer_info(&(data[loc]), &(seq->player), 0);
100 void send_netgame_packet(ubyte *server, ubyte *node)
108 if (Netgame.protocol_version == MULTI_PROTO_D2X_VER) {
109 send_d2x_netgame_packet(server, node);
113 memset(out_buffer, 0, IPX_MAX_DATA_SIZE);
114 out_buffer[loc] = Netgame.type; loc++;
115 memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1);
116 memcpy(&(out_buffer[loc]), Netgame.team_name, 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1);
117 out_buffer[loc] = Netgame.gamemode; loc++;
118 out_buffer[loc] = Netgame.difficulty; loc++;
119 out_buffer[loc] = Netgame.game_status; loc++;
120 out_buffer[loc] = Netgame.numplayers; loc++;
121 out_buffer[loc] = Netgame.max_numplayers; loc++;
122 out_buffer[loc] = Netgame.game_flags; loc++;
123 for (i = 0; i < MAX_PLAYERS; i++) {
124 memcpy(&(out_buffer[loc]), NetPlayers.players[i].callsign, CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1;
125 memcpy(&(out_buffer[loc]), NetPlayers.players[i].network.ipx.server, 4); loc += 4;
126 memcpy(&(out_buffer[loc]), NetPlayers.players[i].network.ipx.node, 6); loc += 6;
127 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].socket), 2); loc += 2;
128 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].connected), 1); loc++;
130 if (Netgame.protocol_version == MULTI_PROTO_D2X_VER) {
131 for (i = 0; i < MAX_PLAYERS; i++) {
132 out_buffer[loc] = Netgame.locations[i]; loc++;
135 for (i = 0; i < MAX_PLAYERS; i++) {
136 tmpi = swapint(Netgame.locations[i]);
137 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP HERE!!!
141 for (i = 0; i < MAX_PLAYERS; i++) {
142 for (j = 0; j < MAX_PLAYERS; j++) {
143 tmps = swapshort(Netgame.kills[i][j]);
144 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
148 tmpi = swapint(Netgame.levelnum);
149 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
150 out_buffer[loc] = Netgame.protocol_version; loc++;
151 out_buffer[loc] = Netgame.team_vector; loc++;
152 tmps = swapshort(Netgame.segments_checksum);
153 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
154 tmps = swapshort(Netgame.team_kills[0]);
155 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
156 tmps = swapshort(Netgame.team_kills[1]);
157 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
158 for (i = 0; i < MAX_PLAYERS; i++) {
159 tmps = swapshort(Netgame.killed[i]);
160 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
162 for (i = 0; i < MAX_PLAYERS; i++) {
163 tmps = swapshort(Netgame.player_kills[i]);
164 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
168 tmpi = swapint(Netgame.level_time);
169 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
170 tmpi = swapint(Netgame.control_invul_time);
171 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
172 tmpi = swapint(Netgame.monitor_vector);
173 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
174 for (i = 0; i < 8; i++) {
175 tmpi = swapint(Netgame.player_score[i]);
176 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
178 for (i = 0; i < 8; i++) {
179 memcpy(&(out_buffer[loc]), &(Netgame.player_flags[i]), 1); loc++;
181 memcpy(&(out_buffer[loc]), Netgame.mission_name, 9); loc += 9;
182 memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1);
183 if (Netgame.protocol_version == MULTI_PROTO_D2X_VER) {
184 out_buffer[loc] = Netgame.PacketsPerSec; loc++;
185 tmpi = swapint(Netgame.flags);
186 memcpy(&out_buffer[loc], &tmpi, 4); loc += 4;
191 ipx_send_broadcast_packet_data(out_buffer, loc);
193 ipx_send_internetwork_packet_data( out_buffer, loc, server, node );
196 void receive_netgame_packet(ubyte *data, netgame_info *netgame, AllNetPlayers_info *netplayers, int d2x)
202 receive_d2x_netgame_packet(data, netgame, netplayers);
207 netgame->type = data[loc]; loc++;
208 memcpy(netgame->game_name, &(data[loc]), NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1);
209 memcpy(netgame->team_name, &(data[loc]), 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1);
210 netgame->gamemode = data[loc]; loc++;
211 netgame->difficulty = data[loc]; loc++;
212 netgame->game_status = data[loc]; loc++;
213 netgame->numplayers = data[loc]; loc++;
214 netgame->max_numplayers = data[loc]; loc++;
215 netgame->game_flags = data[loc]; loc++;
216 for (i = 0; i < MAX_PLAYERS; i++) {
217 receive_netplayer_info(&(data[loc]), &(netplayers->players[i]), 0);
218 loc += sizeof(netplayer_info);//NETPLAYER_ORIG_SIZE;
222 for (i = 0; i < MAX_PLAYERS; i++) {
223 netgame->locations[i] = data[loc]; loc++;
228 for (i = 0; i < MAX_PLAYERS; i++) {
229 memcpy(&(netgame->locations[i]), &(data[loc]), 4); loc += 4; // SWAP HERE!!!
230 netgame->locations[i] = swapint(netgame->locations[i]);
234 for (i = 0; i < MAX_PLAYERS; i++) {
235 for (j = 0; j < MAX_PLAYERS; j++) {
236 memcpy(&(netgame->kills[i][j]), &(data[loc]), 2); loc += 2; // SWAP HERE!!!
237 netgame->kills[i][j] = swapshort(netgame->kills[i][j]);
241 memcpy(&(netgame->levelnum), &(data[loc]), 4); loc += 4; // SWAP_HERE
242 netgame->levelnum = swapint(netgame->levelnum);
243 netgame->protocol_version = data[loc]; loc++;
244 netgame->team_vector = data[loc]; loc++;
245 memcpy(&(netgame->segments_checksum), &(data[loc]), 2); loc += 2; // SWAP_HERE
246 netgame->segments_checksum = swapshort(netgame->segments_checksum);
247 memcpy(&(netgame->team_kills[0]), &(data[loc]), 2); loc += 2; // SWAP_HERE
248 netgame->team_kills[0] = swapshort(netgame->team_kills[0]);
249 memcpy(&(netgame->team_kills[1]), &(data[loc]), 2); loc += 2; // SWAP_HERE
250 netgame->team_kills[1] = swapshort(netgame->team_kills[1]);
251 for (i = 0; i < MAX_PLAYERS; i++) {
252 memcpy(&(netgame->killed[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!!
253 netgame->killed[i] = swapshort(netgame->killed[i]);
255 for (i = 0; i < MAX_PLAYERS; i++) {
256 memcpy(&(netgame->player_kills[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!!
257 netgame->player_kills[i] = swapshort(netgame->player_kills[i]);
261 memcpy(&(netgame->level_time), &(data[loc]), 4); loc += 4; // SWAP_HERE
262 netgame->level_time = swapint(netgame->level_time);
263 memcpy(&(netgame->control_invul_time), &(data[loc]), 4); loc += 4; // SWAP_HERE
264 netgame->control_invul_time = swapint(netgame->control_invul_time);
265 memcpy(&(netgame->monitor_vector), &(data[loc]), 4); loc += 4; // SWAP_HERE
266 netgame->monitor_vector = swapint(netgame->monitor_vector);
267 for (i = 0; i < 8; i++) {
268 memcpy(&(netgame->player_score[i]), &(data[loc]), 4); loc += 4; // SWAP_HERE
269 netgame->player_score[i] = swapint(netgame->player_score[i]);
271 memcpy(netgame->player_flags, &(data[loc]), 8); loc += 8;
273 for (i = 0; i < 8; i++) {
274 memcpy(&(netgame->player_flags[i]), &(data[loc]), 1); loc++;
278 memcpy(netgame->mission_name, &(data[loc]), 9); loc += 9;
279 memcpy(netgame->mission_title, &(data[loc]), MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1);
281 if (d2x && netgame->protocol_version == MULTI_PROTO_D2X_VER) {
282 netgame->packets_per_sec = data[loc]; loc++;
283 memcpy(&netgame->flags, &data[loc], 4); loc += 4;
284 netgame->flags = swapint(netgame->flags);
291 void store_netplayer_info(ubyte *data, netplayer_info *player, int d2x)
293 memcpy(data, player->callsign, CALLSIGN_LEN); data += CALLSIGN_LEN;
294 if (!d2x) *(data++) = 0;
295 memcpy(data, player->network.ipx.server, 4); data += 4;
296 memcpy(data, player->network.ipx.node, 6); data += 6;
297 memcpy(data, &player->socket, 2); data += 2;
298 *data = player->connected; data++;
300 *data = player->sub_protocol; data++;
301 // printf ("%i "__FUNCTION__ " name=%s sub_protocol=%i\n",Player_num,player->callsign,player->sub_protocol);
305 void send_d2x_netgame_packet(ubyte *server, ubyte *node)
312 memset(out_buffer, 0, IPX_MAX_DATA_SIZE);
313 out_buffer[loc] = Netgame.type; loc++;
314 out_buffer[loc] = MULTI_PROTO_D2X_VER; loc++;
315 out_buffer[loc] = Netgame.subprotocol; loc++;
316 out_buffer[loc] = Netgame.required_subprotocol; loc++;
317 memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN); loc += NETGAME_NAME_LEN;
318 memcpy(&(out_buffer[loc]), Netgame.mission_name, 8); loc += 8;
319 memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN); loc += MISSION_NAME_LEN;
320 out_buffer[loc] = Netgame.levelnum; loc++;
321 out_buffer[loc] = Netgame.gamemode; loc++;
322 out_buffer[loc] = Netgame.difficulty; loc++;
323 out_buffer[loc] = Netgame.game_status; loc++;
324 out_buffer[loc] = Netgame.game_flags; loc++;
325 out_buffer[loc] = Netgame.max_numplayers; loc++;
326 out_buffer[loc] = Netgame.team_vector; loc++;
327 if (Netgame.type == PID_D2X_GAME_LITE) {
330 for (i = 0; i < Netgame.numplayers; i++)
331 if (Players[i].connected) {
336 out_buffer[loc] = j; loc++; /* numconnected */
337 if (master == -1) /* should not happen, but... */
339 store_netplayer_info(&(out_buffer[loc]), &NetPlayers.players[master], 1); loc += sizeof(netplayer_info); //NETPLAYER_D2X_SIZE;
340 //added 4/18/99 Matt Mueller - send .flags as well, so 'I' can show them
341 tmpi = swapint(Netgame.flags);
342 memcpy(&out_buffer[loc], &tmpi, 4); loc += 4;
345 out_buffer[loc] = Netgame.numplayers; loc++;
346 out_buffer[loc] = sizeof(netplayer_info); //NETPLAYER_D2X_SIZE; // sizeof netplayer struct
348 for (i = 0; i < MAX_PLAYERS; i++) {
349 store_netplayer_info(&(out_buffer[loc]), &NetPlayers.players[i], 1);
350 loc += sizeof(netplayer_info); //NETPLAYER_D2X_SIZE;
352 memcpy(&(out_buffer[loc]), Netgame.team_name[0], CALLSIGN_LEN); loc += CALLSIGN_LEN;
353 memcpy(&(out_buffer[loc]), Netgame.team_name[1], CALLSIGN_LEN); loc += CALLSIGN_LEN;
354 for (i = 0; i < MAX_PLAYERS; i++) {
355 out_buffer[loc] = Netgame.locations[i]; loc++;
357 for (i = 0; i < MAX_PLAYERS; i++) {
358 for (j = 0; j < MAX_PLAYERS; j++) {
359 tmps = swapshort(Netgame.kills[i][j]);
360 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
363 tmps = swapshort(Netgame.segments_checksum);
364 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
365 tmps = swapshort(Netgame.team_kills[0]);
366 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
367 tmps = swapshort(Netgame.team_kills[1]);
368 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
369 for (i = 0; i < MAX_PLAYERS; i++) {
370 tmps = swapshort(Netgame.killed[i]);
371 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
373 for (i = 0; i < MAX_PLAYERS; i++) {
374 tmps = swapshort(Netgame.player_kills[i]);
375 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
377 tmpi = swapint(Netgame.level_time);
378 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
379 tmpi = swapint(Netgame.control_invul_time);
380 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
381 tmpi = swapint(Netgame.monitor_vector);
382 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
383 for (i = 0; i < 8; i++) {
384 tmpi = swapint(Netgame.player_score[i]);
385 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
387 memcpy(&(out_buffer[loc]), Netgame.player_flags, MAX_PLAYERS); loc += MAX_PLAYERS;
388 out_buffer[loc] = Netgame.PacketsPerSec; loc++;
389 tmpi = swapint(Netgame.flags);
390 memcpy(&out_buffer[loc], &tmpi, 4); loc += 4;
394 ipx_send_broadcast_packet_data(out_buffer, loc);
396 ipx_send_internetwork_packet_data(out_buffer, loc, server, node);
399 void receive_d2x_netgame_packet(ubyte *data, netgame_info *netgame, AllNetPlayers_info *netplayers) {
403 netgame->type = data[loc]; loc++;
404 if (netgame->type == PID_D2X_GAME_LITE) {
405 memset(netgame, 0, sizeof(netgame_info));
406 netgame->type = PID_D2X_GAME_LITE;
408 netgame->protocol_version = data[loc]; loc++;
409 netgame->subprotocol = data[loc]; loc++;
410 netgame->required_subprotocol = data[loc]; loc++;
411 memcpy(netgame->game_name, &(data[loc]), NETGAME_NAME_LEN); loc += NETGAME_NAME_LEN;
412 netgame->game_name[NETGAME_NAME_LEN] = 0;
413 memcpy(netgame->mission_name, &(data[loc]), 8); loc += 8;
414 netgame->mission_name[8] = 0;
415 memcpy(netgame->mission_title, &(data[loc]), MISSION_NAME_LEN); loc += MISSION_NAME_LEN;
416 netgame->mission_title[MISSION_NAME_LEN] = 0;
417 netgame->levelnum = ((signed char *)data)[loc]; loc++;
418 netgame->gamemode = data[loc]; loc++;
419 netgame->difficulty = data[loc]; loc++;
420 netgame->game_status = data[loc]; loc++;
421 netgame->game_flags = data[loc]; loc++;
422 netgame->max_numplayers = data[loc]; loc++;
423 netgame->team_vector = data[loc]; loc++;
424 if (netgame->type == PID_D2X_GAME_LITE) {
425 j = netgame->numplayers = data[loc]; loc++;
426 for (i = 0; i < j; i++)
427 netplayers->players[i].connected = 1;
428 receive_netplayer_info(&(data[loc]), &(netplayers->players[0]), 1);loc += sizeof(netplayer_info); //NETPLAYER_D2X_SIZE;
429 //added 4/18/99 Matt Mueller - send .flags as well, so 'I' can show them
430 if (netgame->subprotocol>=1){
431 memcpy(&netgame->flags, &data[loc], 4); loc += 4;
432 netgame->flags = swapint(netgame->flags);
436 netgame->numplayers = data[loc]; loc++;
437 j = data[loc]; loc++; // sizeof netplayer struct
438 if (j > 29) { /* sanity: 304+29*8=536, just below IPX_MAX=542 */
439 netgame->protocol_version = 0; return;
441 for (i = 0; i < MAX_PLAYERS; i++) {
442 receive_netplayer_info(&(data[loc]), &(netplayers->players[i]), 1);
445 memcpy(netgame->team_name[0], &(data[loc]), CALLSIGN_LEN); loc += CALLSIGN_LEN;
446 netgame->team_name[0][CALLSIGN_LEN] = 0;
447 memcpy(netgame->team_name[1], &(data[loc]), CALLSIGN_LEN); loc += CALLSIGN_LEN;
448 netgame->team_name[1][CALLSIGN_LEN] = 0;
449 for (i = 0; i < MAX_PLAYERS; i++) {
450 netgame->locations[i] = data[loc]; loc++;
452 for (i = 0; i < MAX_PLAYERS; i++) {
453 for (j = 0; j < MAX_PLAYERS; j++) {
454 memcpy(&(netgame->kills[i][j]), &(data[loc]), 2); loc += 2; // SWAP HERE!!!
455 netgame->kills[i][j] = swapshort(netgame->kills[i][j]);
458 memcpy(&(netgame->segments_checksum), &(data[loc]), 2); loc += 2; // SWAP_HERE
459 netgame->segments_checksum = swapshort(netgame->segments_checksum);
460 memcpy(&(netgame->team_kills[0]), &(data[loc]), 2); loc += 2; // SWAP_HERE
461 netgame->team_kills[0] = swapshort(netgame->team_kills[0]);
462 memcpy(&(netgame->team_kills[1]), &(data[loc]), 2); loc += 2; // SWAP_HERE
463 netgame->team_kills[1] = swapshort(netgame->team_kills[1]);
464 for (i = 0; i < MAX_PLAYERS; i++) {
465 memcpy(&(netgame->killed[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!!
466 netgame->killed[i] = swapshort(netgame->killed[i]);
468 for (i = 0; i < MAX_PLAYERS; i++) {
469 memcpy(&(netgame->player_kills[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!!
470 netgame->player_kills[i] = swapshort(netgame->player_kills[i]);
472 memcpy(&(netgame->level_time), &(data[loc]), 4); loc += 4; // SWAP_HERE
473 netgame->level_time = swapint(netgame->level_time);
474 memcpy(&(netgame->control_invul_time), &(data[loc]), 4); loc += 4; // SWAP_HERE
475 netgame->control_invul_time = swapint(netgame->control_invul_time);
476 memcpy(&(netgame->monitor_vector), &(data[loc]), 4); loc += 4; // SWAP_HERE
477 netgame->monitor_vector = swapint(netgame->monitor_vector);
478 for (i = 0; i < 8; i++) {
479 memcpy(&(netgame->player_score[i]), &(data[loc]), 4); loc += 4; // SWAP_HERE
480 netgame->player_score[i] = swapint(netgame->player_score[i]);
482 memcpy(netgame->player_flags, &(data[loc]), 8); loc += 8;
483 netgame->PacketsPerSec = data[loc]; loc++;
484 memcpy(&netgame->flags, &data[loc], 4); loc += 4;
485 netgame->flags = swapint(netgame->flags);
490 void send_frameinfo_packet(ubyte *server, ubyte *node, ubyte *address, int short_packet)
497 object *pl_obj = &Objects[Players[Player_num].objnum];
500 memset(out_buffer, 0, IPX_MAX_DATA_SIZE);
502 out_buffer[0] = PID_PDATA; loc++;
503 tmpi = swapint(MySyncPack.numpackets);
504 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
505 tmps = swapshort(Players[Player_num].objnum);
506 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
507 out_buffer[loc] = Player_num; loc++;
508 tmps = swapshort(pl_obj->segnum);
509 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
511 tmpi = swapint((int)pl_obj->pos.x);
512 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
513 tmpi = swapint((int)pl_obj->pos.y);
514 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
515 tmpi = swapint((int)pl_obj->pos.z);
516 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
518 tmpi = swapint((int)pl_obj->orient.rvec.x);
519 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
520 tmpi = swapint((int)pl_obj->orient.rvec.y);
521 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
522 tmpi = swapint((int)pl_obj->orient.rvec.z);
523 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
524 tmpi = swapint((int)pl_obj->orient.uvec.x);
525 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
526 tmpi = swapint((int)pl_obj->orient.uvec.y);
527 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
528 tmpi = swapint((int)pl_obj->orient.uvec.z);
529 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
530 tmpi = swapint((int)pl_obj->orient.fvec.x);
531 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
532 tmpi = swapint((int)pl_obj->orient.fvec.y);
533 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
534 tmpi = swapint((int)pl_obj->orient.fvec.z);
535 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
537 tmpi = swapint((int)pl_obj->mtype.phys_info.velocity.x);
538 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
539 tmpi = swapint((int)pl_obj->mtype.phys_info.velocity.y);
540 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
541 tmpi = swapint((int)pl_obj->mtype.phys_info.velocity.z);
542 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
543 tmpi = swapint((int)pl_obj->mtype.phys_info.thrust.x);
544 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
545 tmpi = swapint((int)pl_obj->mtype.phys_info.thrust.y);
546 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
547 tmpi = swapint((int)pl_obj->mtype.phys_info.thrust.z);
548 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
549 tmpi = swapint((int)pl_obj->mtype.phys_info.mass);
550 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
551 tmpi = swapint((int)pl_obj->mtype.phys_info.drag);
552 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
553 tmpi = swapint((int)pl_obj->mtype.phys_info.brakes);
554 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
555 tmpi = swapint((int)pl_obj->mtype.phys_info.rotvel.x);
556 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
557 tmpi = swapint((int)pl_obj->mtype.phys_info.rotvel.y);
558 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
559 tmpi = swapint((int)pl_obj->mtype.phys_info.rotvel.z);
560 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
561 tmpi = swapint((int)pl_obj->mtype.phys_info.rotthrust.x);
562 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
563 tmpi = swapint((int)pl_obj->mtype.phys_info.rotthrust.y);
564 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
565 tmpi = swapint((int)pl_obj->mtype.phys_info.rotthrust.z);
566 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
567 tmps = swapshort((short)pl_obj->mtype.phys_info.turnroll);
568 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
569 tmps = swapshort(pl_obj->mtype.phys_info.flags);
570 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
572 out_buffer[loc] = pl_obj->render_type; loc++;
573 out_buffer[loc] = Current_level_num; loc++;
574 tmps = swapshort(MySyncPack.data_size);
575 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
576 memcpy(&(out_buffer[loc]), MySyncPack.data, MySyncPack.data_size);
577 loc += MySyncPack.data_size;
579 if (short_packet == 1) {
581 out_buffer[loc] = PID_SHORTPDATA; loc++;
582 out_buffer[loc] = Player_num; loc++;
583 out_buffer[loc] = pl_obj->render_type; loc++;
584 out_buffer[loc] = Current_level_num; loc++;
585 create_shortpos((shortpos *)(out_buffer + loc), pl_obj, 0);
586 loc += 9+2*3+2+2*3; // go past shortpos structure
587 *(ushort *)(out_buffer + loc) = MySyncPack.data_size; loc += 2;
588 memcpy(out_buffer + loc, MySyncPack.data, MySyncPack.data_size);
589 loc += MySyncPack.data_size;
590 } else if (short_packet == 2) {
592 out_buffer[loc] = PID_PDATA_SHORT2; loc++;
593 out_buffer[loc] = MySyncPack.numpackets & 255; loc++;
594 create_shortpos((shortpos *)(out_buffer + loc), pl_obj, 0);
595 loc += 9+2*3+2+2*3; // go past shortpos structure
596 tmpus = MySyncPack.data_size | (Player_num << 12) | (pl_obj->render_type << 15);
597 *(ushort *)(out_buffer + loc) = tmpus; loc += 2;
598 out_buffer[loc] = Current_level_num; loc++;
599 memcpy(out_buffer + loc, MySyncPack.data, MySyncPack.data_size);
600 loc += MySyncPack.data_size;
602 out_buffer[0] = PID_PDATA; loc++; loc += 3; // skip three for pad byte
603 tmpi = swapint(MySyncPack.numpackets);
604 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
606 tmpi = swapint((int)pl_obj->pos.x);
607 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
608 tmpi = swapint((int)pl_obj->pos.y);
609 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
610 tmpi = swapint((int)pl_obj->pos.z);
611 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
613 tmpi = swapint((int)pl_obj->orient.rvec.x);
614 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
615 tmpi = swapint((int)pl_obj->orient.rvec.y);
616 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
617 tmpi = swapint((int)pl_obj->orient.rvec.z);
618 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
619 tmpi = swapint((int)pl_obj->orient.uvec.x);
620 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
621 tmpi = swapint((int)pl_obj->orient.uvec.y);
622 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
623 tmpi = swapint((int)pl_obj->orient.uvec.z);
624 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
625 tmpi = swapint((int)pl_obj->orient.fvec.x);
626 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
627 tmpi = swapint((int)pl_obj->orient.fvec.y);
628 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
629 tmpi = swapint((int)pl_obj->orient.fvec.z);
630 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
632 tmpi = swapint((int)pl_obj->mtype.phys_info.velocity.x);
633 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
634 tmpi = swapint((int)pl_obj->mtype.phys_info.velocity.y);
635 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
636 tmpi = swapint((int)pl_obj->mtype.phys_info.velocity.z);
637 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
639 tmpi = swapint((int)pl_obj->mtype.phys_info.rotvel.x);
640 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
641 tmpi = swapint((int)pl_obj->mtype.phys_info.rotvel.y);
642 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
643 tmpi = swapint((int)pl_obj->mtype.phys_info.rotvel.z);
644 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
646 tmps = swapshort(pl_obj->segnum);
647 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
648 tmps = swapshort(MySyncPack.data_size);
649 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
651 out_buffer[loc] = Player_num; loc++;
652 out_buffer[loc] = pl_obj->render_type; loc++;
653 out_buffer[loc] = Current_level_num; loc++;
654 memcpy(&(out_buffer[loc]), MySyncPack.data, MySyncPack.data_size);
655 loc += MySyncPack.data_size;
658 #if 0 // adb: not possible (always array passed)
660 ipx_send_internetwork_packet_data( out_buffer, loc, server, node );
663 ipx_send_packet_data( out_buffer, loc, server, node, address);
666 void receive_frameinfo_packet(ubyte *data, frame_info *info, int short_packet)
673 info->type = data[0]; loc++;
674 memcpy(&(info->numpackets), &(data[loc]), 4); loc += 4;
675 info->numpackets = swapint(info->numpackets);
676 memcpy(&(info->objnum), &(data[loc]), 2); loc += 2;
677 info->objnum = swapshort(info->objnum);
678 info->playernum = data[loc]; loc++;
680 memcpy(&(info->obj_segnum), &(data[loc]), 2); loc += 2;
681 info->obj_segnum = swapshort(info->obj_segnum);
683 memcpy(&(info->obj_pos.x), &(data[loc]), 4); loc += 4;
684 info->obj_pos.x = (fix)swapint((int)info->obj_pos.x);
685 memcpy(&(info->obj_pos.y), &(data[loc]), 4); loc += 4;
686 info->obj_pos.y = (fix)swapint((int)info->obj_pos.y);
687 memcpy(&(info->obj_pos.z), &(data[loc]), 4); loc += 4;
688 info->obj_pos.z = (fix)swapint((int)info->obj_pos.z);
690 memcpy(&(info->obj_orient.rvec.x), &(data[loc]), 4); loc += 4;
691 info->obj_orient.rvec.x = (fix)swapint((int)info->obj_orient.rvec.x);
692 memcpy(&(info->obj_orient.rvec.y), &(data[loc]), 4); loc += 4;
693 info->obj_orient.rvec.y = (fix)swapint((int)info->obj_orient.rvec.y);
694 memcpy(&(info->obj_orient.rvec.z), &(data[loc]), 4); loc += 4;
695 info->obj_orient.rvec.z = (fix)swapint((int)info->obj_orient.rvec.z);
696 memcpy(&(info->obj_orient.uvec.x), &(data[loc]), 4); loc += 4;
697 info->obj_orient.uvec.x = (fix)swapint((int)info->obj_orient.uvec.x);
698 memcpy(&(info->obj_orient.uvec.y), &(data[loc]), 4); loc += 4;
699 info->obj_orient.uvec.y = (fix)swapint((int)info->obj_orient.uvec.y);
700 memcpy(&(info->obj_orient.uvec.z), &(data[loc]), 4); loc += 4;
701 info->obj_orient.uvec.z = (fix)swapint((int)info->obj_orient.uvec.z);
702 memcpy(&(info->obj_orient.fvec.x), &(data[loc]), 4); loc += 4;
703 info->obj_orient.fvec.x = (fix)swapint((int)info->obj_orient.fvec.x);
704 memcpy(&(info->obj_orient.fvec.y), &(data[loc]), 4); loc += 4;
705 info->obj_orient.fvec.y = (fix)swapint((int)info->obj_orient.fvec.y);
706 memcpy(&(info->obj_orient.fvec.z), &(data[loc]), 4); loc += 4;
707 info->obj_orient.fvec.z = (fix)swapint((int)info->obj_orient.fvec.z);
709 memcpy(&(info->obj_phys_info.velocity.x), &(data[loc]), 4); loc += 4;
710 info->obj_phys_info.velocity.x = (fix)swapint((int)info->obj_phys_info.velocity.x);
711 memcpy(&(info->obj_phys_info.velocity.y), &(data[loc]), 4); loc += 4;
712 info->obj_phys_info.velocity.y = (fix)swapint((int)info->obj_phys_info.velocity.y);
713 memcpy(&(info->obj_phys_info.velocity.z), &(data[loc]), 4); loc += 4;
714 info->obj_phys_info.velocity.z = (fix)swapint((int)info->obj_phys_info.velocity.z);
716 memcpy(&(info->obj_phys_info.thrust.x), &(data[loc]), 4); loc += 4;
717 info->obj_phys_info.thrust.x = (fix)swapint((int)info->obj_phys_info.thrust.x);
718 memcpy(&(info->obj_phys_info.thrust.y), &(data[loc]), 4); loc += 4;
719 info->obj_phys_info.thrust.y = (fix)swapint((int)info->obj_phys_info.thrust.y);
720 memcpy(&(info->obj_phys_info.thrust.z), &(data[loc]), 4); loc += 4;
721 info->obj_phys_info.thrust.z = (fix)swapint((int)info->obj_phys_info.thrust.z);
723 memcpy(&(info->obj_phys_info.mass), &(data[loc]), 4); loc += 4;
724 info->obj_phys_info.mass = (fix)swapint((int)info->obj_phys_info.mass);
725 memcpy(&(info->obj_phys_info.drag), &(data[loc]), 4); loc += 4;
726 info->obj_phys_info.drag = (fix)swapint((int)info->obj_phys_info.drag);
727 memcpy(&(info->obj_phys_info.brakes), &(data[loc]), 4); loc += 4;
728 info->obj_phys_info.brakes = (fix)swapint((int)info->obj_phys_info.brakes);
730 memcpy(&(info->obj_phys_info.rotvel.x), &(data[loc]), 4); loc += 4;
731 info->obj_phys_info.rotvel.x = (fix)swapint((int)info->obj_phys_info.rotvel.x);
732 memcpy(&(info->obj_phys_info.rotvel.y), &(data[loc]), 4); loc += 4;
733 info->obj_phys_info.rotvel.y = (fix)swapint((int)info->obj_phys_info.rotvel.y);
734 memcpy(&(info->obj_phys_info.rotvel.z), &(data[loc]), 4); loc += 4;
735 info->obj_phys_info.rotvel.z = (fix)swapint((int)info->obj_phys_info.rotvel.z);
737 memcpy(&(info->obj_phys_info.rotthrust.x), &(data[loc]), 4); loc += 4;
738 info->obj_phys_info.rotthrust.x = (fix)swapint((int)info->obj_phys_info.rotthrust.x);
739 memcpy(&(info->obj_phys_info.rotthrust.y), &(data[loc]), 4); loc += 4;
740 info->obj_phys_info.rotthrust.y = (fix)swapint((int)info->obj_phys_info.rotthrust.y);
741 memcpy(&(info->obj_phys_info.rotthrust.z), &(data[loc]), 4); loc += 4;
742 info->obj_phys_info.rotthrust.z = (fix)swapint((int)info->obj_phys_info.rotthrust.z);
744 memcpy(&(info->obj_phys_info.turnroll), &(data[loc]), 2); loc += 2;
745 info->obj_phys_info.turnroll = (fixang)swapshort((short)info->obj_phys_info.turnroll);
747 memcpy(&(info->obj_phys_info.flags), &(data[loc]), 2); loc += 2;
748 info->obj_phys_info.flags = (ushort)swapshort(info->obj_phys_info.flags);
750 info->obj_render_type = data[loc]; loc++;
751 info->level_num = data[loc]; loc++;
752 memcpy( &(info->data_size), &(data[loc]), 2); loc += 2;
753 info->data_size = swapshort(info->data_size);
754 memcpy(info->data, &(data[loc]), info->data_size);
756 if (short_packet == 1) {
758 info->type = data[loc]; loc++;
759 info->playernum = data[loc]; loc++;
760 info->obj_render_type = data[loc]; loc++;
761 info->level_num = data[loc]; loc++;
762 loc += 9+2*3+2+2*3; // skip shortpos structure
763 info->data_size = *(ushort *)(data + loc); loc+=2;
764 memcpy(info->data, &(data[loc]), info->data_size);
765 } else if (short_packet == 2) {
769 info->type = data[loc]; loc++;
770 info->numpackets = data[loc]; loc++;
771 loc += 9+2*3+2+2*3; // skip shortpos structure
772 tmpus = *(ushort *)(data + loc); loc+=2;
773 info->data_size = tmpus & 0xfff;
774 info->playernum = (tmpus >> 12) & 7;
775 info->obj_render_type = tmpus >> 15;
776 info->numpackets |= Players[info->playernum].n_packets_got & (~255);
777 if (info->numpackets - Players[info->playernum].n_packets_got > 224)
778 info->numpackets -= 256;
779 else if (Players[info->playernum].n_packets_got - info->numpackets > 128)
780 info->numpackets += 256;
781 info->level_num = data[loc]; loc++;
782 memcpy(info->data, &(data[loc]), info->data_size);
785 info->type = data[loc]; loc++; loc += 3; // skip three for pad byte
786 memcpy(&(info->numpackets), &(data[loc]), 4); loc += 4;
787 info->numpackets = swapint(info->numpackets);
789 memcpy(&(info->obj_pos.x), &(data[loc]), 4); loc += 4;
790 info->obj_pos.x = swapint((int)info->obj_pos.x);
791 memcpy(&(info->obj_pos.y), &(data[loc]), 4); loc += 4;
792 info->obj_pos.y = swapint((int)info->obj_pos.y);
793 memcpy(&(info->obj_pos.z), &(data[loc]), 4); loc += 4;
794 info->obj_pos.z = swapint((int)info->obj_pos.z);
796 memcpy(&(info->obj_orient.rvec.x), &(data[loc]), 4); loc += 4;
797 info->obj_orient.rvec.x = swapint((int)info->obj_orient.rvec.x);
798 memcpy(&(info->obj_orient.rvec.y), &(data[loc]), 4); loc += 4;
799 info->obj_orient.rvec.y = swapint((int)info->obj_orient.rvec.y);
800 memcpy(&(info->obj_orient.rvec.z), &(data[loc]), 4); loc += 4;
801 info->obj_orient.rvec.z = swapint((int)info->obj_orient.rvec.z);
802 memcpy(&(info->obj_orient.uvec.x), &(data[loc]), 4); loc += 4;
803 info->obj_orient.uvec.x = swapint((int)info->obj_orient.uvec.x);
804 memcpy(&(info->obj_orient.uvec.y), &(data[loc]), 4); loc += 4;
805 info->obj_orient.uvec.y = swapint((int)info->obj_orient.uvec.y);
806 memcpy(&(info->obj_orient.uvec.z), &(data[loc]), 4); loc += 4;
807 info->obj_orient.uvec.z = swapint((int)info->obj_orient.uvec.z);
808 memcpy(&(info->obj_orient.fvec.x), &(data[loc]), 4); loc += 4;
809 info->obj_orient.fvec.x = swapint((int)info->obj_orient.fvec.x);
810 memcpy(&(info->obj_orient.fvec.y), &(data[loc]), 4); loc += 4;
811 info->obj_orient.fvec.y = swapint((int)info->obj_orient.fvec.y);
812 memcpy(&(info->obj_orient.fvec.z), &(data[loc]), 4); loc += 4;
813 info->obj_orient.fvec.z = swapint((int)info->obj_orient.fvec.z);
815 memcpy(&(info->phys_velocity.x), &(data[loc]), 4); loc += 4;
816 info->phys_velocity.x = swapint((int)info->phys_velocity.x);
817 memcpy(&(info->phys_velocity.y), &(data[loc]), 4); loc += 4;
818 info->phys_velocity.y = swapint((int)info->phys_velocity.y);
819 memcpy(&(info->phys_velocity.z), &(data[loc]), 4); loc += 4;
820 info->phys_velocity.z = swapint((int)info->phys_velocity.z);
822 memcpy(&(info->phys_rotvel.x), &(data[loc]), 4); loc += 4;
823 info->phys_rotvel.x = swapint((int)info->phys_rotvel.x);
824 memcpy(&(info->phys_rotvel.y), &(data[loc]), 4); loc += 4;
825 info->phys_rotvel.y = swapint((int)info->phys_rotvel.y);
826 memcpy(&(info->phys_rotvel.z), &(data[loc]), 4); loc += 4;
827 info->phys_rotvel.z = swapint((int)info->phys_rotvel.z);
829 memcpy(&(info->obj_segnum), &(data[loc]), 2); loc += 2;
830 info->obj_segnum = swapshort(info->obj_segnum);
831 memcpy(&(info->data_size), &(data[loc]), 2); loc += 2;
832 info->data_size = swapshort(info->data_size);
834 info->playernum = data[loc]; loc++;
835 info->obj_render_type = data[loc]; loc++;
836 info->level_num = data[loc]; loc++;
837 memcpy(info->data, &(data[loc]), info->data_size);
842 void send_endlevel_packet(endlevel_info *info, ubyte *server, ubyte *node, ubyte *address)
848 memset(out_buffer, 0, IPX_MAX_DATA_SIZE);
849 out_buffer[loc] = info->type; loc++;
850 out_buffer[loc] = info->player_num; loc++;
851 out_buffer[loc] = info->connected; loc++;
852 for (i = 0; i < MAX_PLAYERS; i++) {
853 for (j = 0; j < MAX_PLAYERS; j++) {
854 tmps = swapshort(info->kill_matrix[i][j]);
855 memcpy(&(out_buffer[loc]), &tmps, 2);
859 tmps = swapshort(info->kills);
860 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
861 tmps = swapshort(info->killed);
862 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
863 out_buffer[loc] = info->seconds_left; loc++;
865 ipx_send_packet_data( out_buffer, loc, server, node, address);
868 void receive_endlevel_packet(ubyte *data, endlevel_info *info)
873 info->type = data[loc]; loc++;
874 info->player_num = data[loc]; loc++;
875 info->connected = data[loc]; loc++;
877 for (i = 0; i < MAX_PLAYERS; i++) {
878 for (j = 0; j < MAX_PLAYERS; j++) {
879 memcpy(&(info->kill_matrix[i][j]), &(data[loc]), 2); loc += 2;
880 info->kill_matrix[i][j] = swapshort(info->kill_matrix[i][j]);
883 memcpy(&(info->kills), &(data[loc]), 2); loc += 2;
884 info->kills = swapshort(info->kills);
885 memcpy(&(info->killed), &(data[loc]), 2); loc += 2;
886 info->killed = swapshort(info->killed);
887 info->seconds_left = data[loc];
890 void swap_object(object *obj)
892 // swap the short and int entries for this object
893 obj->signature = swapint(obj->signature);
894 obj->next = swapshort(obj->next);
895 obj->prev = swapshort(obj->prev);
896 obj->segnum = swapshort(obj->segnum);
897 obj->attached_obj = swapshort(obj->attached_obj);
898 obj->pos.x = swapint(obj->pos.x);
899 obj->pos.y = swapint(obj->pos.y);
900 obj->pos.z = swapint(obj->pos.z);
902 obj->orient.rvec.x = swapint(obj->orient.rvec.x);
903 obj->orient.rvec.y = swapint(obj->orient.rvec.y);
904 obj->orient.rvec.z = swapint(obj->orient.rvec.z);
905 obj->orient.fvec.x = swapint(obj->orient.fvec.x);
906 obj->orient.fvec.y = swapint(obj->orient.fvec.y);
907 obj->orient.fvec.z = swapint(obj->orient.fvec.z);
908 obj->orient.uvec.x = swapint(obj->orient.uvec.x);
909 obj->orient.uvec.y = swapint(obj->orient.uvec.y);
910 obj->orient.uvec.z = swapint(obj->orient.uvec.z);
912 obj->size = swapint(obj->size);
913 obj->shields = swapint(obj->shields);
915 obj->last_pos.x = swapint(obj->last_pos.x);
916 obj->last_pos.y = swapint(obj->last_pos.y);
917 obj->last_pos.z = swapint(obj->last_pos.z);
919 obj->lifeleft = swapint(obj->lifeleft);
921 switch (obj->movement_type) {
925 obj->mtype.phys_info.velocity.x = swapint(obj->mtype.phys_info.velocity.x);
926 obj->mtype.phys_info.velocity.y = swapint(obj->mtype.phys_info.velocity.y);
927 obj->mtype.phys_info.velocity.z = swapint(obj->mtype.phys_info.velocity.z);
929 obj->mtype.phys_info.thrust.x = swapint(obj->mtype.phys_info.thrust.x);
930 obj->mtype.phys_info.thrust.y = swapint(obj->mtype.phys_info.thrust.y);
931 obj->mtype.phys_info.thrust.z = swapint(obj->mtype.phys_info.thrust.z);
933 obj->mtype.phys_info.mass = swapint(obj->mtype.phys_info.mass);
934 obj->mtype.phys_info.drag = swapint(obj->mtype.phys_info.drag);
935 obj->mtype.phys_info.brakes = swapint(obj->mtype.phys_info.brakes);
937 obj->mtype.phys_info.rotvel.x = swapint(obj->mtype.phys_info.rotvel.x);
938 obj->mtype.phys_info.rotvel.y = swapint(obj->mtype.phys_info.rotvel.y);
939 obj->mtype.phys_info.rotvel.z = swapint(obj->mtype.phys_info.rotvel.z);
941 obj->mtype.phys_info.rotthrust.x = swapint(obj->mtype.phys_info.rotthrust.x);
942 obj->mtype.phys_info.rotthrust.y = swapint(obj->mtype.phys_info.rotthrust.y);
943 obj->mtype.phys_info.rotthrust.z = swapint(obj->mtype.phys_info.rotthrust.z);
945 obj->mtype.phys_info.turnroll = swapint(obj->mtype.phys_info.turnroll);
946 obj->mtype.phys_info.flags = swapshort(obj->mtype.phys_info.flags);
952 obj->mtype.spin_rate.x = swapint(obj->mtype.spin_rate.x);
953 obj->mtype.spin_rate.y = swapint(obj->mtype.spin_rate.y);
954 obj->mtype.spin_rate.z = swapint(obj->mtype.spin_rate.z);
958 switch (obj->control_type) {
961 obj->ctype.laser_info.parent_type = swapshort(obj->ctype.laser_info.parent_type);
962 obj->ctype.laser_info.parent_num = swapshort(obj->ctype.laser_info.parent_num);
963 obj->ctype.laser_info.parent_signature = swapshort(obj->ctype.laser_info.parent_signature);
964 obj->ctype.laser_info.creation_time = swapint(obj->ctype.laser_info.creation_time);
965 obj->ctype.laser_info.last_hitobj = swapint(obj->ctype.laser_info.last_hitobj);
966 obj->ctype.laser_info.multiplier = swapint(obj->ctype.laser_info.multiplier);
970 obj->ctype.expl_info.spawn_time = swapint(obj->ctype.expl_info.spawn_time);
971 obj->ctype.expl_info.delete_time = swapint(obj->ctype.expl_info.delete_time);
972 obj->ctype.expl_info.delete_objnum = swapshort(obj->ctype.expl_info.delete_objnum);
973 obj->ctype.expl_info.attach_parent = swapshort(obj->ctype.expl_info.attach_parent);
974 obj->ctype.expl_info.prev_attach = swapshort(obj->ctype.expl_info.prev_attach);
975 obj->ctype.expl_info.next_attach = swapshort(obj->ctype.expl_info.next_attach);
979 obj->ctype.ai_info.hide_segment = swapshort(obj->ctype.ai_info.hide_segment);
980 obj->ctype.ai_info.hide_index = swapshort(obj->ctype.ai_info.hide_index);
981 obj->ctype.ai_info.path_length = swapshort(obj->ctype.ai_info.path_length);
982 obj->ctype.ai_info.cur_path_index = swapshort(obj->ctype.ai_info.cur_path_index);
983 // obj->ctype.ai_info.follow_path_start_seg = swapshort(obj->ctype.ai_info.follow_path_start_seg);
984 // obj->ctype.ai_info.follow_path_end_seg = swapshort(obj->ctype.ai_info.follow_path_end_seg);
985 obj->ctype.ai_info.danger_laser_signature = swapint(obj->ctype.ai_info.danger_laser_signature);
986 obj->ctype.ai_info.danger_laser_num = swapshort(obj->ctype.ai_info.danger_laser_num);
990 obj->ctype.light_info.intensity = swapint(obj->ctype.light_info.intensity);
994 obj->ctype.powerup_info.count = swapint(obj->ctype.powerup_info.count);
995 if (obj->id == POW_VULCAN_WEAPON)
996 obj->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT;
1001 switch (obj->render_type) {
1007 obj->rtype.pobj_info.model_num = swapint(obj->rtype.pobj_info.model_num);
1009 for (i=0;i<MAX_SUBMODELS;i++) {
1010 obj->rtype.pobj_info.anim_angles[i].p = swapint(obj->rtype.pobj_info.anim_angles[i].p);
1011 obj->rtype.pobj_info.anim_angles[i].b = swapint(obj->rtype.pobj_info.anim_angles[i].b);
1012 obj->rtype.pobj_info.anim_angles[i].h = swapint(obj->rtype.pobj_info.anim_angles[i].h);
1015 obj->rtype.pobj_info.subobj_flags = swapint(obj->rtype.pobj_info.subobj_flags);
1016 obj->rtype.pobj_info.tmap_override = swapint(obj->rtype.pobj_info.tmap_override);
1017 obj->rtype.pobj_info.alt_textures = swapint(obj->rtype.pobj_info.alt_textures);
1021 case RT_WEAPON_VCLIP:
1025 obj->rtype.vclip_info.vclip_num = swapint(obj->rtype.vclip_info.vclip_num);
1026 obj->rtype.vclip_info.frametime = swapint(obj->rtype.vclip_info.frametime);
1033 // END OF SWAPPING OBJECT STRUCTURE