This commit was manufactured by cvs2svn to create branch
[btb/d2x.git] / main / netmisc.h
1 /*
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.
12 */
13
14
15
16 #ifndef _NETMISC_H
17 #define _NETMISC_H
18
19 #include "multi.h"
20 #include "network.h"
21
22 //Returns a checksum of a block of memory.
23 extern ushort netmisc_calc_checksum( void * vptr, int len );
24
25 //Finds the difference between block1 and block2.  Fills in diff_buffer and returns the size of diff_buffer.
26 extern int netmisc_find_diff( void *block1, void *block2, int block_size, void *diff_buffer );
27
28 //Applies diff_buffer to block1 to create a new block1.  Returns the final size of block1.
29 extern int netmisc_apply_diff(void *block1, void *diff_buffer, int diff_size );
30
31 #ifdef WORDS_BIGENDIAN
32
33 // some mac only routines to deal with incorrectly aligned network structures
34
35 void receive_netplayer_info(ubyte *data, AllNetPlayers_info *info);
36
37 void receive_netplayers_packet(ubyte *data, AllNetPlayers_info *pinfo);
38 void send_netplayers_packet(ubyte *server, ubyte *node);
39 #define send_broadcast_netplayers_packet() \
40         send_netplayers_packet(NULL, NULL)
41
42 void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address);
43 #define send_internetwork_sequence_packet(seq, server, node) \
44         send_sequence_packet(seq, server, node, NULL)
45 #define send_broadcast_sequence_packet(seq) \
46         send_sequence_packet(seq, NULL, NULL, NULL)
47 void receive_sequence_packet(ubyte *data, sequence_packet *seq);
48
49 void send_netgame_packet(ubyte *server, ubyte *node, ubyte *net_address, int lite_flag);
50 #define send_full_netgame_packet(server, node, net_address) \
51         send_netgame_packet(server, node, net_address, 0)
52 #define send_lite_netgame_packet(server, node, net_address) \
53         send_netgame_packet(server, node, net_address, 1)
54 #define send_internetwork_full_netgame_packet(server, node) \
55         send_netgame_packet(server, node, NULL, 0)
56 #define send_internetwork_lite_netgame_packet(server, node) \
57         send_netgame_packet(server, node, NULL, 1)
58 #define send_broadcast_full_netgame_packet() \
59         send_netgame_packet(NULL, NULL, NULL, 0)
60 #define send_broadcast_lite_netgame_packet() \
61         send_netgame_packet(NULL, NULL, NULL, 1)
62 void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag);
63 #define receive_full_netgame_packet(data, netgame) \
64         receive_netgame_packet(data, netgame, 0)
65 #define receive_lite_netgame_packet(data, netgame) \
66         receive_netgame_packet(data, netgame, 1)
67
68 void swap_object(object *obj);
69
70 #else
71
72 #define receive_netplayers_packet(data, pinfo) \
73         memcpy(pinfo, data, sizeof(AllNetPlayers_info))
74 #define send_netplayers_packet(server, node) \
75         ipx_send_internetwork_packet_data((ubyte *)&NetPlayers, sizeof(AllNetPlayers_info), server, node)
76 #define send_broadcast_netplayers_packet() \
77         ipx_send_broadcast_packet_data((ubyte *)&NetPlayers, sizeof(AllNetPlayers_info))
78
79 #define send_sequence_packet(seq, server, node, net_address) \
80         ipx_send_packet_data((ubyte *)&seq, sizeof(sequence_packet), server, node, net_address)
81 #define send_internetwork_sequence_packet(seq, server, node) \
82         ipx_send_internetwork_packet_data((ubyte *)&seq, sizeof(sequence_packet), server, node)
83 #define send_broadcast_sequence_packet(seq) \
84         ipx_send_broadcast_packet_data((ubyte *)&seq, sizeof(sequence_packet))
85
86 #define send_full_netgame_packet(server, node, net_address) \
87         ipx_send_packet_data((ubyte *)&Netgame, sizeof(netgame_info), server, node, net_address)
88 #define send_lite_netgame_packet(server, node, net_address) \
89         ipx_send_packet_data((ubyte *)&Netgame, sizeof(lite_info), server, node, net_address)
90 #define send_internetwork_full_netgame_packet(server, node) \
91         ipx_send_internetwork_packet_data((ubyte *)&Netgame, sizeof(netgame_info), server, node)
92 #define send_internetwork_lite_netgame_packet(server, node) \
93         ipx_send_internetwork_packet_data((ubyte *)&Netgame, sizeof(lite_info), server, node)
94 #define send_broadcast_full_netgame_packet() \
95         ipx_send_broadcast_packet_data((ubyte *)&Netgame, sizeof(netgame_info))
96 #define send_broadcast_lite_netgame_packet() \
97         ipx_send_broadcast_packet_data((ubyte *)&Netgame, sizeof(lite_info))
98 #define receive_full_netgame_packet(data, netgame) \
99         memcpy((ubyte *)(netgame), data, sizeof(netgame_info))
100 #define receive_lite_netgame_packet(data, netgame) \
101         memcpy((ubyte *)(netgame), data, sizeof(lite_info))
102
103 #define swap_object(obj)
104
105 #endif
106
107 #endif