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-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Misc routines for network.
30 #ifdef WORDS_BIGENDIAN
37 // routine to calculate the checksum of the segments. We add these specialized routines
38 // since the current way is byte order dependent.
40 void mac_do_checksum_calc(ubyte *b, int len, unsigned int *s1, unsigned int *s2)
45 if (*s1 >= 255) *s1 -= 255;
50 ushort mac_calc_segment_checksum()
53 unsigned int sum1,sum2;
58 for (i = 0; i < Highest_segment_index + 1; i++) {
59 for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
60 mac_do_checksum_calc((unsigned char *)&(Segments[i].sides[j].type), 1, &sum1, &sum2);
61 mac_do_checksum_calc(&(Segments[i].sides[j].pad), 1, &sum1, &sum2);
62 s = INTEL_SHORT(Segments[i].sides[j].wall_num);
63 mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
64 s = INTEL_SHORT(Segments[i].sides[j].tmap_num);
65 mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
66 s = INTEL_SHORT(Segments[i].sides[j].tmap_num2);
67 mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
68 for (k = 0; k < 4; k++) {
69 t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].u));
70 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
71 t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].v));
72 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
73 t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].l));
74 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
76 for (k = 0; k < 2; k++) {
77 t = INTEL_INT(((int)Segments[i].sides[j].normals[k].x));
78 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
79 t = INTEL_INT(((int)Segments[i].sides[j].normals[k].y));
80 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
81 t = INTEL_INT(((int)Segments[i].sides[j].normals[k].z));
82 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
85 for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
86 s = INTEL_SHORT(Segments[i].children[j]);
87 mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
89 for (j = 0; j < MAX_VERTICES_PER_SEGMENT; j++) {
90 s = INTEL_SHORT(Segments[i].verts[j]);
91 mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
93 t = INTEL_INT(Segments[i].objects);
94 mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
97 return ((sum1<<8)+ sum2);
100 // this routine totally and completely relies on the fact that the network
101 // checksum must be calculated on the segments!!!!!
103 ushort netmisc_calc_checksum(void * vptr, int len)
107 return mac_calc_segment_checksum();
110 // following are routine for macintosh only that will swap the elements of
111 // structures send through the networking code. The structures and
112 // this code must be kept in total sync
114 sbyte out_buffer[IPX_MAX_DATA_SIZE]; // used for tmp netgame packets as well as sending object data
116 void receive_netplayer_info(ubyte *data, netplayer_info *info)
120 memcpy(info->callsign, &(data[loc]), CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1;
121 memcpy(&(info->network.ipx.server), &(data[loc]), 4); loc += 4;
122 memcpy(&(info->network.ipx.node), &(data[loc]), 6); loc += 6;
123 info->version_major = data[loc]; loc++;
124 info->version_minor = data[loc]; loc++;
125 memcpy(&(info->computer_type), &(data[loc]), 1); loc++; // memcpy to avoid compile time warning about enum
126 info->connected = data[loc]; loc++;
127 memcpy(&(info->socket), &(data[loc]), 2); loc += 2;
128 memcpy (&(info->rank),&(data[loc]),1); loc++;
129 // MWA don't think we need to swap this because we need it in high
130 // order info->socket = INTEL_SHORT(info->socket);
133 void send_netplayers_packet(ubyte *server, ubyte *node)
139 memset(out_buffer, 0, sizeof(out_buffer));
140 out_buffer[0] = NetPlayers.type; loc++;
141 tmpi = INTEL_INT(NetPlayers.Security);
142 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
143 for (i = 0; i < MAX_PLAYERS+4; i++) {
144 memcpy(&(out_buffer[loc]), NetPlayers.players[i].callsign, CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1;
145 memcpy(&(out_buffer[loc]), NetPlayers.players[i].network.ipx.server, 4); loc += 4;
146 memcpy(&(out_buffer[loc]), NetPlayers.players[i].network.ipx.node, 6); loc += 6;
147 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].version_major), 1); loc++;
148 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].version_minor), 1); loc++;
149 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].computer_type), 1); loc++;
150 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].connected), 1); loc++;
151 tmps = INTEL_SHORT(NetPlayers.players[i].socket);
152 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
153 memcpy(&(out_buffer[loc]), &(NetPlayers.players[i].rank), 1); loc++;
156 if ((server == NULL) && (node == NULL))
157 ipx_send_broadcast_packet_data((unsigned char *)out_buffer, loc);
159 ipx_send_internetwork_packet_data((unsigned char *)out_buffer, loc, server, node);
163 void receive_netplayers_packet(ubyte *data, AllNetPlayers_info *pinfo)
167 pinfo->type = data[loc]; loc++;
168 memcpy(&(pinfo->Security), &(data[loc]), 4); loc += 4;
169 pinfo->Security = INTEL_INT(pinfo->Security);
170 for (i = 0; i < MAX_PLAYERS+4; i++) {
171 receive_netplayer_info(&(data[loc]), &(pinfo->players[i]));
172 loc += 26; // sizeof(netplayer_info) on the PC
176 void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address)
182 memset(out_buffer, 0, sizeof(out_buffer));
183 out_buffer[0] = seq.type; loc++;
184 tmpi = INTEL_INT(seq.Security);
185 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; loc += 3;
186 memcpy(&(out_buffer[loc]), seq.player.callsign, CALLSIGN_LEN+1);loc += CALLSIGN_LEN+1;
187 memcpy(&(out_buffer[loc]), seq.player.network.ipx.server, 4); loc += 4;
188 memcpy(&(out_buffer[loc]), seq.player.network.ipx.node, 6); loc += 6;
189 out_buffer[loc] = seq.player.version_major; loc++;
190 out_buffer[loc] = seq.player.version_minor; loc++;
191 out_buffer[loc] = seq.player.computer_type; loc++;
192 out_buffer[loc] = seq.player.connected; loc++;
193 tmps = INTEL_SHORT(seq.player.socket);
194 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
195 out_buffer[loc]=seq.player.rank; loc++; // for pad byte
196 if (net_address != NULL)
197 ipx_send_packet_data((unsigned char *)out_buffer, loc, server, node, net_address);
198 else if ((server == NULL) && (node == NULL))
199 ipx_send_broadcast_packet_data((unsigned char *)out_buffer, loc);
201 ipx_send_internetwork_packet_data((unsigned char *)out_buffer, loc, server, node);
204 void receive_sequence_packet(ubyte *data, sequence_packet *seq)
208 seq->type = data[0]; loc++;
209 memcpy(&(seq->Security), &(data[loc]), 4); loc += 4; loc += 3; // +3 for pad byte
210 seq->Security = INTEL_INT(seq->Security);
211 receive_netplayer_info(&(data[loc]), &(seq->player));
214 void send_netgame_packet(ubyte *server, ubyte *node, ubyte *net_address, int lite_flag) // lite says shorter netgame packets
221 memset(out_buffer, 0, IPX_MAX_DATA_SIZE);
222 memcpy(&(out_buffer[loc]), &(Netgame.type), 1); loc++;
223 tmpi = INTEL_INT(Netgame.Security);
224 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
225 memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1);
226 memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1);
227 memcpy(&(out_buffer[loc]), Netgame.mission_name, 9); loc += 9;
228 tmpi = INTEL_INT(Netgame.levelnum);
229 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4;
230 memcpy(&(out_buffer[loc]), &(Netgame.gamemode), 1); loc++;
231 memcpy(&(out_buffer[loc]), &(Netgame.RefusePlayers), 1); loc++;
232 memcpy(&(out_buffer[loc]), &(Netgame.difficulty), 1); loc++;
233 memcpy(&(out_buffer[loc]), &(Netgame.game_status), 1); loc++;
234 memcpy(&(out_buffer[loc]), &(Netgame.numplayers), 1); loc++;
235 memcpy(&(out_buffer[loc]), &(Netgame.max_numplayers), 1); loc++;
236 memcpy(&(out_buffer[loc]), &(Netgame.numconnected), 1); loc++;
237 memcpy(&(out_buffer[loc]), &(Netgame.game_flags), 1); loc++;
238 memcpy(&(out_buffer[loc]), &(Netgame.protocol_version), 1); loc++;
239 memcpy(&(out_buffer[loc]), &(Netgame.version_major), 1); loc++;
240 memcpy(&(out_buffer[loc]), &(Netgame.version_minor), 1); loc++;
241 memcpy(&(out_buffer[loc]), &(Netgame.team_vector), 1); loc++;
246 // will this work -- damn bitfields -- totally bogus when trying to do
247 // this type of stuff
248 // Watcom makes bitfields from left to right. CW7 on the mac goes
249 // from right to left. then they are endian swapped
251 tmps = *(ushort *)((ubyte *)(&Netgame.team_vector) + 1); // get the values for the first short bitfield
252 tmps = INTEL_SHORT(tmps);
253 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
255 tmps = *(ushort *)((ubyte *)(&Netgame.team_vector) + 3); // get the values for the second short bitfield
256 tmps = INTEL_SHORT(tmps);
257 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
259 #if 0 // removed since I reordered bitfields on mac
260 p = *(ushort *)((ubyte *)(&Netgame.team_vector) + 1); // get the values for the first short bitfield
262 for (i = 15; i >= 0; i--) {
264 tmps |= (1 << (15 - i));
266 tmps = INTEL_SHORT(tmps);
267 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
268 p = *(ushort *)((ubyte *)(&Netgame.team_vector) + 3); // get the values for the second short bitfield
270 for (i = 15; i >= 0; i--) {
272 tmps |= (1 << (15 - i));
274 tmps = INTEL_SHORT(tmps);
275 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
278 memcpy(&(out_buffer[loc]), Netgame.team_name, 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1);
279 for (i = 0; i < MAX_PLAYERS; i++) {
280 tmpi = INTEL_INT(Netgame.locations[i]);
281 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP HERE!!!
284 for (i = 0; i < MAX_PLAYERS; i++) {
285 for (j = 0; j < MAX_PLAYERS; j++) {
286 tmps = INTEL_SHORT(Netgame.kills[i][j]);
287 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
291 tmps = INTEL_SHORT(Netgame.segments_checksum);
292 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
293 tmps = INTEL_SHORT(Netgame.team_kills[0]);
294 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
295 tmps = INTEL_SHORT(Netgame.team_kills[1]);
296 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE
297 for (i = 0; i < MAX_PLAYERS; i++) {
298 tmps = INTEL_SHORT(Netgame.killed[i]);
299 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
301 for (i = 0; i < MAX_PLAYERS; i++) {
302 tmps = INTEL_SHORT(Netgame.player_kills[i]);
303 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!!
306 tmpi = INTEL_INT(Netgame.KillGoal);
307 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
308 tmpi = INTEL_INT(Netgame.PlayTimeAllowed);
309 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
310 tmpi = INTEL_INT(Netgame.level_time);
311 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
312 tmpi = INTEL_INT(Netgame.control_invul_time);
313 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
314 tmpi = INTEL_INT(Netgame.monitor_vector);
315 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
316 for (i = 0; i < MAX_PLAYERS; i++) {
317 tmpi = INTEL_INT(Netgame.player_score[i]);
318 memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE
320 for (i = 0; i < MAX_PLAYERS; i++) {
321 memcpy(&(out_buffer[loc]), &(Netgame.player_flags[i]), 1); loc++;
323 tmps = INTEL_SHORT(Netgame.PacketsPerSec);
324 memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2;
325 memcpy(&(out_buffer[loc]), &(Netgame.ShortPackets), 1); loc ++;
328 if (net_address != NULL)
329 ipx_send_packet_data((unsigned char *)out_buffer, loc, server, node, net_address);
330 else if ((server == NULL) && (node == NULL))
331 ipx_send_broadcast_packet_data((unsigned char *)out_buffer, loc);
333 ipx_send_internetwork_packet_data((unsigned char *)out_buffer, loc, server, node);
336 void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag)
340 short bitfield; // new_field;
342 memcpy(&(netgame->type), &(data[loc]), 1); loc++;
343 memcpy(&(netgame->Security), &(data[loc]), 4); loc += 4;
344 netgame->Security = INTEL_INT(netgame->Security);
345 memcpy(netgame->game_name, &(data[loc]), NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1);
346 memcpy(netgame->mission_title, &(data[loc]), MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1);
347 memcpy(netgame->mission_name, &(data[loc]), 9); loc += 9;
348 memcpy(&(netgame->levelnum), &(data[loc]), 4); loc += 4;
349 netgame->levelnum = INTEL_INT(netgame->levelnum);
350 memcpy(&(netgame->gamemode), &(data[loc]), 1); loc++;
351 memcpy(&(netgame->RefusePlayers), &(data[loc]), 1); loc++;
352 memcpy(&(netgame->difficulty), &(data[loc]), 1); loc++;
353 memcpy(&(netgame->game_status), &(data[loc]), 1); loc++;
354 memcpy(&(netgame->numplayers), &(data[loc]), 1); loc++;
355 memcpy(&(netgame->max_numplayers), &(data[loc]), 1); loc++;
356 memcpy(&(netgame->numconnected), &(data[loc]), 1); loc++;
357 memcpy(&(netgame->game_flags), &(data[loc]), 1); loc++;
358 memcpy(&(netgame->protocol_version), &(data[loc]), 1); loc++;
359 memcpy(&(netgame->version_major), &(data[loc]), 1); loc++;
360 memcpy(&(netgame->version_minor), &(data[loc]), 1); loc++;
361 memcpy(&(netgame->team_vector), &(data[loc]), 1); loc++;
366 memcpy(&bitfield, &(data[loc]), 2); loc += 2;
367 bitfield = INTEL_SHORT(bitfield);
368 memcpy(((ubyte *)(&netgame->team_vector) + 1), &bitfield, 2);
370 memcpy(&bitfield, &(data[loc]), 2); loc += 2;
371 bitfield = INTEL_SHORT(bitfield);
372 memcpy(((ubyte *)(&netgame->team_vector) + 3), &bitfield, 2);
374 #if 0 // not used since reordering mac bitfields
375 memcpy(&bitfield, &(data[loc]), 2); loc += 2;
377 for (i = 15; i >= 0; i--) {
378 if (bitfield & (1 << i))
379 new_field |= (1 << (15 - i));
381 new_field = INTEL_SHORT(new_field);
382 memcpy(((ubyte *)(&netgame->team_vector) + 1), &new_field, 2);
384 memcpy(&bitfield, &(data[loc]), 2); loc += 2;
386 for (i = 15; i >= 0; i--) {
387 if (bitfield & (1 << i))
388 new_field |= (1 << (15 - i));
390 new_field = INTEL_SHORT(new_field);
391 memcpy(((ubyte *)(&netgame->team_vector) + 3), &new_field, 2);
394 memcpy(netgame->team_name, &(data[loc]), 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1);
395 for (i = 0; i < MAX_PLAYERS; i++) {
396 memcpy(&(netgame->locations[i]), &(data[loc]), 4); loc += 4;
397 netgame->locations[i] = INTEL_INT(netgame->locations[i]);
400 for (i = 0; i < MAX_PLAYERS; i++) {
401 for (j = 0; j < MAX_PLAYERS; j++) {
402 memcpy(&(netgame->kills[i][j]), &(data[loc]), 2); loc += 2;
403 netgame->kills[i][j] = INTEL_SHORT(netgame->kills[i][j]);
407 memcpy(&(netgame->segments_checksum), &(data[loc]), 2); loc += 2;
408 netgame->segments_checksum = INTEL_SHORT(netgame->segments_checksum);
409 memcpy(&(netgame->team_kills[0]), &(data[loc]), 2); loc += 2;
410 netgame->team_kills[0] = INTEL_SHORT(netgame->team_kills[0]);
411 memcpy(&(netgame->team_kills[1]), &(data[loc]), 2); loc += 2;
412 netgame->team_kills[1] = INTEL_SHORT(netgame->team_kills[1]);
413 for (i = 0; i < MAX_PLAYERS; i++) {
414 memcpy(&(netgame->killed[i]), &(data[loc]), 2); loc += 2;
415 netgame->killed[i] = INTEL_SHORT(netgame->killed[i]);
417 for (i = 0; i < MAX_PLAYERS; i++) {
418 memcpy(&(netgame->player_kills[i]), &(data[loc]), 2); loc += 2;
419 netgame->player_kills[i] = INTEL_SHORT(netgame->player_kills[i]);
421 memcpy(&(netgame->KillGoal), &(data[loc]), 4); loc += 4;
422 netgame->KillGoal = INTEL_INT(netgame->KillGoal);
423 memcpy(&(netgame->PlayTimeAllowed), &(data[loc]), 4); loc += 4;
424 netgame->PlayTimeAllowed = INTEL_INT(netgame->PlayTimeAllowed);
426 memcpy(&(netgame->level_time), &(data[loc]), 4); loc += 4;
427 netgame->level_time = INTEL_INT(netgame->level_time);
428 memcpy(&(netgame->control_invul_time), &(data[loc]), 4); loc += 4;
429 netgame->control_invul_time = INTEL_INT(netgame->control_invul_time);
430 memcpy(&(netgame->monitor_vector), &(data[loc]), 4); loc += 4;
431 netgame->monitor_vector = INTEL_INT(netgame->monitor_vector);
432 for (i = 0; i < MAX_PLAYERS; i++) {
433 memcpy(&(netgame->player_score[i]), &(data[loc]), 4); loc += 4;
434 netgame->player_score[i] = INTEL_INT(netgame->player_score[i]);
436 for (i = 0; i < MAX_PLAYERS; i++) {
437 memcpy(&(netgame->player_flags[i]), &(data[loc]), 1); loc++;
439 memcpy(&(netgame->PacketsPerSec), &(data[loc]), 2); loc += 2;
440 netgame->PacketsPerSec = INTEL_SHORT(netgame->PacketsPerSec);
441 memcpy(&(netgame->ShortPackets), &(data[loc]), 1); loc ++;
445 void swap_object(object *obj)
447 // swap the short and int entries for this object
448 obj->signature = INTEL_INT(obj->signature);
449 obj->next = INTEL_SHORT(obj->next);
450 obj->prev = INTEL_SHORT(obj->prev);
451 obj->segnum = INTEL_SHORT(obj->segnum);
452 obj->pos.x = INTEL_INT(obj->pos.x);
453 obj->pos.y = INTEL_INT(obj->pos.y);
454 obj->pos.z = INTEL_INT(obj->pos.z);
456 obj->orient.rvec.x = INTEL_INT(obj->orient.rvec.x);
457 obj->orient.rvec.y = INTEL_INT(obj->orient.rvec.y);
458 obj->orient.rvec.z = INTEL_INT(obj->orient.rvec.z);
459 obj->orient.fvec.x = INTEL_INT(obj->orient.fvec.x);
460 obj->orient.fvec.y = INTEL_INT(obj->orient.fvec.y);
461 obj->orient.fvec.z = INTEL_INT(obj->orient.fvec.z);
462 obj->orient.uvec.x = INTEL_INT(obj->orient.uvec.x);
463 obj->orient.uvec.y = INTEL_INT(obj->orient.uvec.y);
464 obj->orient.uvec.z = INTEL_INT(obj->orient.uvec.z);
466 obj->size = INTEL_INT(obj->size);
467 obj->shields = INTEL_INT(obj->shields);
469 obj->last_pos.x = INTEL_INT(obj->last_pos.x);
470 obj->last_pos.y = INTEL_INT(obj->last_pos.y);
471 obj->last_pos.z = INTEL_INT(obj->last_pos.z);
473 obj->lifeleft = INTEL_INT(obj->lifeleft);
475 switch (obj->movement_type) {
479 obj->mtype.phys_info.velocity.x = INTEL_INT(obj->mtype.phys_info.velocity.x);
480 obj->mtype.phys_info.velocity.y = INTEL_INT(obj->mtype.phys_info.velocity.y);
481 obj->mtype.phys_info.velocity.z = INTEL_INT(obj->mtype.phys_info.velocity.z);
483 obj->mtype.phys_info.thrust.x = INTEL_INT(obj->mtype.phys_info.thrust.x);
484 obj->mtype.phys_info.thrust.y = INTEL_INT(obj->mtype.phys_info.thrust.y);
485 obj->mtype.phys_info.thrust.z = INTEL_INT(obj->mtype.phys_info.thrust.z);
487 obj->mtype.phys_info.mass = INTEL_INT(obj->mtype.phys_info.mass);
488 obj->mtype.phys_info.drag = INTEL_INT(obj->mtype.phys_info.drag);
489 obj->mtype.phys_info.brakes = INTEL_INT(obj->mtype.phys_info.brakes);
491 obj->mtype.phys_info.rotvel.x = INTEL_INT(obj->mtype.phys_info.rotvel.x);
492 obj->mtype.phys_info.rotvel.y = INTEL_INT(obj->mtype.phys_info.rotvel.y);
493 obj->mtype.phys_info.rotvel.z = INTEL_INT(obj->mtype.phys_info.rotvel.z);
495 obj->mtype.phys_info.rotthrust.x = INTEL_INT(obj->mtype.phys_info.rotthrust.x);
496 obj->mtype.phys_info.rotthrust.y = INTEL_INT(obj->mtype.phys_info.rotthrust.y);
497 obj->mtype.phys_info.rotthrust.z = INTEL_INT(obj->mtype.phys_info.rotthrust.z);
499 obj->mtype.phys_info.turnroll = INTEL_INT(obj->mtype.phys_info.turnroll);
500 obj->mtype.phys_info.flags = INTEL_SHORT(obj->mtype.phys_info.flags);
506 obj->mtype.spin_rate.x = INTEL_INT(obj->mtype.spin_rate.x);
507 obj->mtype.spin_rate.y = INTEL_INT(obj->mtype.spin_rate.y);
508 obj->mtype.spin_rate.z = INTEL_INT(obj->mtype.spin_rate.z);
512 switch (obj->control_type) {
515 obj->ctype.laser_info.parent_type = INTEL_SHORT(obj->ctype.laser_info.parent_type);
516 obj->ctype.laser_info.parent_num = INTEL_SHORT(obj->ctype.laser_info.parent_num);
517 obj->ctype.laser_info.parent_signature = INTEL_INT(obj->ctype.laser_info.parent_signature);
518 obj->ctype.laser_info.creation_time = INTEL_INT(obj->ctype.laser_info.creation_time);
519 obj->ctype.laser_info.last_hitobj = INTEL_SHORT(obj->ctype.laser_info.last_hitobj);
520 obj->ctype.laser_info.track_goal = INTEL_SHORT(obj->ctype.laser_info.track_goal);
521 obj->ctype.laser_info.multiplier = INTEL_INT(obj->ctype.laser_info.multiplier);
525 obj->ctype.expl_info.spawn_time = INTEL_INT(obj->ctype.expl_info.spawn_time);
526 obj->ctype.expl_info.delete_time = INTEL_INT(obj->ctype.expl_info.delete_time);
527 obj->ctype.expl_info.delete_objnum = INTEL_SHORT(obj->ctype.expl_info.delete_objnum);
528 obj->ctype.expl_info.attach_parent = INTEL_SHORT(obj->ctype.expl_info.attach_parent);
529 obj->ctype.expl_info.prev_attach = INTEL_SHORT(obj->ctype.expl_info.prev_attach);
530 obj->ctype.expl_info.next_attach = INTEL_SHORT(obj->ctype.expl_info.next_attach);
534 obj->ctype.ai_info.hide_segment = INTEL_SHORT(obj->ctype.ai_info.hide_segment);
535 obj->ctype.ai_info.hide_index = INTEL_SHORT(obj->ctype.ai_info.hide_index);
536 obj->ctype.ai_info.path_length = INTEL_SHORT(obj->ctype.ai_info.path_length);
537 obj->ctype.ai_info.danger_laser_num = INTEL_SHORT(obj->ctype.ai_info.danger_laser_num);
538 obj->ctype.ai_info.danger_laser_signature = INTEL_INT(obj->ctype.ai_info.danger_laser_signature);
539 obj->ctype.ai_info.dying_start_time = INTEL_INT(obj->ctype.ai_info.dying_start_time);
543 obj->ctype.light_info.intensity = INTEL_INT(obj->ctype.light_info.intensity);
547 obj->ctype.powerup_info.count = INTEL_INT(obj->ctype.powerup_info.count);
548 obj->ctype.powerup_info.creation_time = INTEL_INT(obj->ctype.powerup_info.creation_time);
549 // Below commented out 5/2/96 by Matt. I asked Allender why it was
550 // here, and he didn't know, and it looks like it doesn't belong.
551 // if (obj->id == POW_VULCAN_WEAPON)
552 // obj->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT;
557 switch (obj->render_type) {
563 obj->rtype.pobj_info.model_num = INTEL_INT(obj->rtype.pobj_info.model_num);
565 for (i=0;i<MAX_SUBMODELS;i++) {
566 obj->rtype.pobj_info.anim_angles[i].p = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].p);
567 obj->rtype.pobj_info.anim_angles[i].b = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].b);
568 obj->rtype.pobj_info.anim_angles[i].h = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].h);
571 obj->rtype.pobj_info.subobj_flags = INTEL_INT(obj->rtype.pobj_info.subobj_flags);
572 obj->rtype.pobj_info.tmap_override = INTEL_INT(obj->rtype.pobj_info.tmap_override);
573 obj->rtype.pobj_info.alt_textures = INTEL_INT(obj->rtype.pobj_info.alt_textures);
577 case RT_WEAPON_VCLIP:
581 obj->rtype.vclip_info.vclip_num = INTEL_INT(obj->rtype.vclip_info.vclip_num);
582 obj->rtype.vclip_info.frametime = INTEL_INT(obj->rtype.vclip_info.frametime);
589 // END OF SWAPPING OBJECT STRUCTURE
593 #else /* !WORDS_BIGENDIAN */
596 // Calculates the checksum of a block of memory.
597 ushort netmisc_calc_checksum(void * vptr, int len)
599 ubyte *ptr = (ubyte *)vptr;
600 unsigned int sum1,sum2;
606 if (sum1 >= 255) sum1 -= 255;
611 return ((sum1<<8)+ sum2);
614 #endif /* WORDS_BIGENDIAN */
616 //--unused-- //Finds the difference between block1 and block2. Fills in diff_buffer and
617 //--unused-- //returns the size of diff_buffer.
618 //--unused-- int netmisc_find_diff(void *block1, void *block2, int block_size, void *diff_buffer)
620 //--unused-- int mode;
621 //--unused-- ushort *c1, *c2, *diff_start, *c3;
622 //--unused-- int i, j, size, diff, n , same;
624 //--unused-- size=(block_size+1)/sizeof(ushort);
625 //--unused-- c1 = (ushort *)block1;
626 //--unused-- c2 = (ushort *)block2;
627 //--unused-- c3 = (ushort *)diff_buffer;
629 //--unused-- mode = same = diff = n = 0;
631 //--unused-- //mprintf(0, "=================================\n");
633 //--unused-- for (i=0; i<size; i++, c1++, c2++) {
634 //--unused-- if (*c1 != *c2) {
635 //--unused-- if (mode==0) {
636 //--unused-- mode = 1;
637 //--unused-- //mprintf(0, "%ds ", same);
638 //--unused-- c3[n++] = same;
639 //--unused-- same=0; diff=0;
640 //--unused-- diff_start = c2;
642 //--unused-- *c1 = *c2;
644 //--unused-- if (diff==65535) {
645 //--unused-- mode = 0;
646 //--unused-- // send how many diff ones.
647 //--unused-- //mprintf(0, "%dd ", diff);
648 //--unused-- c3[n++]=diff;
649 //--unused-- // send all the diff ones.
650 //--unused-- for (j=0; j<diff; j++)
651 //--unused-- c3[n++] = diff_start[j];
652 //--unused-- same=0; diff=0;
653 //--unused-- diff_start = c2;
655 //--unused-- } else {
656 //--unused-- if (mode==1) {
658 //--unused-- // send how many diff ones.
659 //--unused-- //mprintf(0, "%dd ", diff);
660 //--unused-- c3[n++]=diff;
661 //--unused-- // send all the diff ones.
662 //--unused-- for (j=0; j<diff; j++)
663 //--unused-- c3[n++] = diff_start[j];
664 //--unused-- same=0; diff=0;
665 //--unused-- diff_start = c2;
668 //--unused-- if (same==65535) {
670 //--unused-- // send how many the same
671 //--unused-- //mprintf(0, "%ds ", same);
672 //--unused-- c3[n++] = same;
673 //--unused-- same=0; diff=0;
674 //--unused-- diff_start = c2;
679 //--unused-- if (mode==0) {
680 //--unused-- // send how many the same
681 //--unused-- //mprintf(0, "%ds ", same);
682 //--unused-- c3[n++] = same;
683 //--unused-- } else {
684 //--unused-- // send how many diff ones.
685 //--unused-- //mprintf(0, "%dd ", diff);
686 //--unused-- c3[n++]=diff;
687 //--unused-- // send all the diff ones.
688 //--unused-- for (j=0; j<diff; j++)
689 //--unused-- c3[n++] = diff_start[j];
692 //--unused-- //mprintf(0, "=================================\n");
694 //--unused-- return n*2;
697 //--unused-- //Applies diff_buffer to block1 to create a new block1. Returns the final
698 //--unused-- //size of block1.
699 //--unused-- int netmisc_apply_diff(void *block1, void *diff_buffer, int diff_size)
701 //--unused-- unsigned int i, j, n, size;
702 //--unused-- ushort *c1, *c2;
704 //--unused-- //mprintf(0, "=================================\n");
705 //--unused-- c1 = (ushort *)diff_buffer;
706 //--unused-- c2 = (ushort *)block1;
708 //--unused-- size = diff_size/2;
711 //--unused-- while (1) {
712 //--unused-- j += c1[i]; // Same
713 //--unused-- //mprintf(0, "%ds ", c1[i]);
715 //--unused-- if (i>=size) break;
716 //--unused-- n = c1[i]; // ndiff
717 //--unused-- //mprintf(0, "%dd ", c1[i]);
719 //--unused-- if (n>0) {
720 //--unused-- //Assert(n* < 256);
721 //--unused-- memcpy(&c2[j], &c1[i], n*2);
725 //--unused-- if (i>=size) break;
727 //--unused-- //mprintf(0, "=================================\n");
729 //--unused-- return j*2;