]> icculus.org git repositories - taylor/freespace2.git/blob - include/multi_xfer.h
proper padding of PXO stats struct for FS2 demo
[taylor/freespace2.git] / include / multi_xfer.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Network/multi_xfer.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * $Log$
16  * Revision 1.3  2002/06/09 04:41:14  relnev
17  * added copyright header
18  *
19  * Revision 1.2  2002/05/26 20:22:48  theoddone33
20  * Most of network/ works
21  *
22  * Revision 1.1.1.1  2002/05/03 03:28:12  root
23  * Initial import.
24  *
25  * 
26  * 5     12/14/98 4:01p Dave
27  * Got multi_data stuff working well with new xfer stuff. 
28  * 
29  * 4     12/14/98 12:13p Dave
30  * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
31  * Need to test now.
32  * 
33  * 3     11/05/98 5:55p Dave
34  * Big pass at reducing #includes
35  * 
36  * 2     10/07/98 10:53a Dave
37  * Initial checkin.
38  * 
39  * 1     10/07/98 10:50a Dave
40  * 
41  * 21    5/21/98 3:45a Sandeep
42  * Make sure file xfer sender side uses correct directory type.
43  * 
44  * 20    4/23/98 6:18p Dave
45  * Store ETS values between respawns. Put kick feature in the text
46  * messaging system. Fixed text messaging system so that it doesn't
47  * process or trigger ship controls. Other UI fixes.
48  * 
49  * 19    4/01/98 11:19p Dave
50  * Put in auto-loading of xferred pilot pic files. Grey out background
51  * behind pinfo popup. Put a chatbox message in when players are kicked.
52  * Moved mission title down in briefing. Other ui fixes.
53  * 
54  * 18    3/23/98 5:42p Dave
55  * Put in automatic xfer of pilot pic files. Changed multi_xfer system so
56  * that it can support multiplayer sends/received between client and
57  * server simultaneously.
58  * 
59  * 17    3/21/98 7:14p Dave
60  * Fixed up standalone player slot switching. Made training missions not
61  * count towards player stats.
62  * 
63  * 16    2/22/98 2:53p Dave
64  * Put in groundwork for advanced multiplayer campaign  options.
65  * 
66  * 15    2/20/98 4:43p Dave
67  * Finished support for multiplayer player data files. Split off
68  * multiplayer campaign functionality.
69  * 
70  * 14    2/19/98 6:26p Dave
71  * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
72  * initial support for player data uploading.
73  * 
74  * 13    2/18/98 10:21p Dave
75  * Ripped out old file xfer system. Put in brand new xfer system.
76  * 
77  * $NoKeywords: $
78  */
79
80 #ifndef _FREESPACE_FILE_TRANSFER_HEADER
81 #define _FREESPACE_FILE_TRANSFER_HEADER
82
83 #include "pstypes.h"
84
85 // ------------------------------------------------------------------------------------------
86 // MULTI XFER DEFINES/VARS
87 //
88
89 typedef uint PSNET_SOCKET_RELIABLE;
90
91 // status codes for transfers
92 #define MULTI_XFER_NONE                                         -1                                                      // nothing is happening - this is an invalid handle
93 #define MULTI_XFER_SUCCESS                                      0                                                       // the xfer has successfully transferred
94 #define MULTI_XFER_FAIL                                         1                                                       // the xfer has failed for one reason or another
95 #define MULTI_XFER_UNKNOWN                                      2                                                       // the xfer has finished but its unknown if it was successful - wait a while longer
96 #define MULTI_XFER_TIMEDOUT                             3                                                       // the xfer has timed-out during some stage of the process
97 #define MULTI_XFER_IN_PROGRESS                  4                                                       // the xfer is in progress
98 #define MULTI_XFER_QUEUED                                       5                                                       // queued up - hasn't started yet
99
100 #define MULTI_XFER_FLAG_AUTODESTROY             (1<<15)                                 // automatically clear and free an xfer handle that is done
101 #define MULTI_XFER_FLAG_REJECT                  (1<<16)                                 // set by the receive callback function if we want to disallow xfer of this file
102 // if this flag is set, the system will only xfer one file at a time to a given destination. 
103 // so, suppose you start sending 3 files to one target, all which have this flag set. Only the first file will send.
104 // Once it is complete, the second one will go. Then the third. This is extremely useful for files where you don't 
105 // _really_ care if it arrives or not (eg - sending multiple pilot pics or sounds or squad logos, etc). If you _do_
106 // care about the file (eg - mission files), you probably shouldn't be using this flag
107 #define MULTI_XFER_FLAG_QUEUE                           (1<<17)                                 
108
109 // the xfer system is guaranteed never to spew data larger than this
110 #define MULTI_XFER_MAX_SIZE                             500
111
112 // ------------------------------------------------------------------------------------------
113 // MULTI XFER FUNCTIONS
114 //
115
116 // initialize all file xfer transaction stuff, call in multi_level_init()
117 void multi_xfer_init(void (*multi_xfer_recv_callback)(int handle));
118
119 // do frame for all file xfers, call in multi_do_frame()
120 void multi_xfer_do();
121
122 // close down the file xfer system
123 void multi_xfer_close();
124
125 // reset the xfer system, including shutting down/killing all active xfers
126 void multi_xfer_reset();
127
128 // send a file to the specified player, return a handle
129 int multi_xfer_send_file(PSNET_SOCKET_RELIABLE who, char *filename, int cfile_flags, int flags = 0);
130
131 // get the status of the current file xfer
132 int multi_xfer_get_status(int handle);
133
134 // abort a transferring file
135 void multi_xfer_abort(int handle);
136
137 // release an xfer handle
138 void multi_xfer_release_handle(int handle);
139
140 // get the filename of the xfer for the given handle
141 char *multi_xfer_get_filename(int handle);
142
143 // lock the xfer system (don't accept incoming files, don't allow outgoing files)
144 void multi_xfer_lock();
145
146 // unlock the xfer system
147 void multi_xfer_unlock();
148
149 // force all receives to go into the specified directory by cfile type
150 void multi_xfer_force_dir(int cf_type);
151
152 // forces the given xfer entry to the specified directory type (only valid when called from the recv_callback function)
153 void multi_xfer_handle_force_dir(int handle,int cf_type);
154
155 // xor the flag on a given entry
156 void multi_xfer_xor_flags(int handle,int flags);
157
158 // get the flags for a given entry
159 int multi_xfer_get_flags(int handle);
160
161 // if the passed filename is being xferred, return the xfer handle, otherwise return -1
162 int multi_xfer_lookup(char *filename);
163
164 // get the % of completion of the passed file handle, return < 0 if invalid
165 float multi_xfer_pct_complete(int handle);
166
167 // get the socket of the file xfer (useful for identifying players)
168 uint multi_xfer_get_sock(int handle);
169
170 // get the CF_TYPE of the directory this file is going to
171 int multi_xfer_get_force_dir(int handle);
172
173 // ------------------------------------------------------------------------------------------
174 // MULTI XFER PACKET HANDLERS
175 //
176
177 // process an incoming file xfer data packet, return bytes processed, guaranteed to process the entire
178 // packet regardless of error conditions
179 int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who);
180
181 #endif
182