2 * Copyright (C) Volition, Inc. 2005. All rights reserved.
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 the
10 //Pilot tracker client code
13 #include <arpa/inet.h>
14 #include <netinet/in.h>
26 // check structs for size compatibility
27 //SDL_COMPILE_TIME_ASSERT(udp_packet_header, sizeof(udp_packet_header) == 497);
30 SDL_COMPILE_TIME_ASSERT(vmt_freespace2_struct, sizeof(vmt_freespace2_struct) == 408);
32 SDL_COMPILE_TIME_ASSERT(vmt_freespace2_struct, sizeof(vmt_freespace2_struct) == 440);
35 SDL_COMPILE_TIME_ASSERT(vmt_freespace_struct, sizeof(vmt_freespace_struct) == 468);
37 SDL_COMPILE_TIME_ASSERT(validate_id_request, sizeof(validate_id_request) == 60);
38 SDL_COMPILE_TIME_ASSERT(squad_war_request, sizeof(squad_war_request) == 104);
39 SDL_COMPILE_TIME_ASSERT(squad_war_response, sizeof(squad_war_response) == 256);
40 SDL_COMPILE_TIME_ASSERT(squad_war_result, sizeof(squad_war_result) == 72);
41 SDL_COMPILE_TIME_ASSERT(pilot_request, sizeof(pilot_request) == 32);
48 #define PILOTSOCK pilotsock
50 #define PILOTSOCK Unreliable_socket
53 struct sockaddr_in ptrackaddr;
58 unsigned int FSLastSentWrite;
59 unsigned int FSFirstSentWrite;
60 unsigned int FSLastSent;
61 unsigned int FSFirstSent;
64 unsigned int SWLastSentWrite;
65 unsigned int SWFirstSentWrite;
68 udp_packet_header fs_pilot_req, fs_pilot_write, sw_res_write;
71 vmt_freespace_struct *ReadFSPilot;
73 vmt_freespace2_struct *ReadFSPilot;
77 squad_war_response SquadWarWriteResponse;
80 static int SerializePilotPacket(const udp_packet_header *uph, ubyte *data)
88 PXO_ADD_DATA(uph->type);
92 PXO_ADD_USHORT(uph->len);
93 PXO_ADD_UINT(uph->code);
94 PXO_ADD_USHORT(uph->xcode);
99 PXO_ADD_UINT(uph->sig);
100 PXO_ADD_UINT(uph->security);
103 // no extra data for this
107 case UNT_PILOT_DATA_WRITE_NEW: {
108 vmt_stats_struct *fs2 = (vmt_stats_struct *)&uph->data;
110 PXO_ADD_DATA(fs2->tracker_id);
111 PXO_ADD_DATA(fs2->pilot_name);
113 PXO_ADD_DATA(fs2->pad_a); // junk, for size/alignment
115 PXO_ADD_INT(fs2->score);
116 PXO_ADD_INT(fs2->rank);
119 for (i = 0; i < MAX_FS_MEDALS; i++) {
120 PXO_ADD_INT(fs2->medals[i]);
123 for (i = 0; i < MAX_FS_SHIP_TYPES; i++) {
124 PXO_ADD_INT(fs2->kills[i]);
126 #elif defined(FS2_DEMO)
127 for (i = 0; i < MAX_FS2_MEDALS; i++) {
128 PXO_ADD_INT(fs2->medals[i]);
131 for (i = 0; i < MAX_FS2_SHIP_TYPES; i++) {
132 PXO_ADD_USHORT(fs2->kills[i]);
136 PXO_ADD_INT(fs2->assists);
137 PXO_ADD_INT(fs2->kill_count);
138 PXO_ADD_INT(fs2->kill_count_ok);
139 PXO_ADD_UINT(fs2->p_shots_fired);
140 PXO_ADD_UINT(fs2->s_shots_fired);
142 PXO_ADD_UINT(fs2->p_shots_hit);
143 PXO_ADD_UINT(fs2->s_shots_hit);
145 PXO_ADD_UINT(fs2->p_bonehead_hits);
146 PXO_ADD_UINT(fs2->s_bonehead_hits);
147 PXO_ADD_INT(fs2->bonehead_kills);
149 PXO_ADD_INT(fs2->security);
150 PXO_ADD_DATA(fs2->virgin_pilot);
152 PXO_ADD_DATA(fs2->pad_b); // junk, for size/alignment
154 PXO_ADD_UINT(fs2->checksum);
156 PXO_ADD_UINT(fs2->missions_flown);
157 PXO_ADD_UINT(fs2->flight_time);
158 PXO_ADD_UINT(fs2->last_flown);
160 #if !defined(MAKE_FS1) && !defined(FS2_DEMO)
161 PXO_ADD_USHORT(fs2->num_medals);
162 PXO_ADD_USHORT(fs2->num_ship_types);
164 for (i = 0; i < MAX_FS2_MEDALS; i++) {
165 PXO_ADD_INT(fs2->medals[i]);
168 for (i = 0; i < MAX_FS2_SHIP_TYPES; i++) {
169 PXO_ADD_USHORT(fs2->kills[i]);
176 case UNT_SW_RESULT_WRITE: {
177 squad_war_result *sw_result = (squad_war_result *)&uph->data;
179 PXO_ADD_DATA(sw_result->match_code);
180 PXO_ADD_DATA(sw_result->result);
181 PXO_ADD_DATA(sw_result->squad_count1);
182 PXO_ADD_DATA(sw_result->squad_count2);
183 PXO_ADD_DATA(sw_result->pad); // junk, for size/alignment
185 for (i = 0; i < MAX_SQUAD_PLAYERS; i++) {
186 PXO_ADD_INT(sw_result->squad_winners[i]);
189 for (i = 0; i < MAX_SQUAD_PLAYERS; i++) {
190 PXO_ADD_INT(sw_result->squad_losers[i]);
196 case UNT_PILOT_DATA_READ_NEW:
197 case UNT_PILOT_DATA_READ: {
198 pilot_request *pr = (pilot_request *)&uph->data;
200 PXO_ADD_DATA(pr->pilot_name);
201 PXO_ADD_DATA(pr->tracker_id);
202 PXO_ADD_DATA(pr->pad); // junk, for size/alignment
207 // we shouldn't be sending any other packet types
213 SDL_assert(packet_size >= (int)PACKED_HEADER_ONLY_SIZE);
214 SDL_assert(packet_size == (int)uph->len);
219 static void DeserializePilotPacket(const ubyte *data, const int data_size, udp_packet_header *uph)
227 memset(uph, 0, sizeof(udp_packet_header));
229 // make sure we received a complete base packet
230 if (data_size < (int)PACKED_HEADER_ONLY_SIZE) {
237 PXO_GET_DATA(uph->type);
241 PXO_GET_USHORT(uph->len);
242 PXO_GET_UINT(uph->code);
243 PXO_GET_USHORT(uph->xcode);
248 PXO_GET_UINT(uph->sig);
249 PXO_GET_UINT(uph->security);
251 // sanity check data size to make sure we reveived all of the expected packet
253 // (the -1 is because psnet2 pops off one byte)
254 if ((int)uph->len-1 > data_size) {
256 if ((int)uph->len > data_size) {
265 // no extra data for these
266 case UNT_PILOT_READ_FAILED:
267 case UNT_PILOT_WRITE_SUCCESS:
268 case UNT_PILOT_WRITE_FAILED:
271 case UNT_PILOT_DATA_RESPONSE: {
272 vmt_stats_struct *fs2 = (vmt_stats_struct *)&uph->data;
274 PXO_GET_DATA(fs2->tracker_id);
275 PXO_GET_DATA(fs2->pilot_name);
277 PXO_GET_DATA(fs2->pad_a); // junk, for size/alignment
279 PXO_GET_INT(fs2->score);
280 PXO_GET_INT(fs2->rank);
283 for (i = 0; i < MAX_FS_MEDALS; i++) {
284 PXO_GET_INT(fs2->medals[i]);
287 for (i =0; i < MAX_FS_SHIP_TYPES; i++) {
288 PXO_GET_INT(fs2->kills[i]);
290 #elif defined(FS2_DEMO)
291 for (i = 0; i < MAX_FS2_MEDALS; i++) {
292 PXO_GET_INT(fs2->medals[i]);
295 for (i =0; i < MAX_FS2_SHIP_TYPES; i++) {
296 PXO_GET_USHORT(fs2->kills[i]);
300 PXO_GET_INT(fs2->assists);
301 PXO_GET_INT(fs2->kill_count);
302 PXO_GET_INT(fs2->kill_count_ok);
303 PXO_GET_UINT(fs2->p_shots_fired);
304 PXO_GET_UINT(fs2->s_shots_fired);
306 PXO_GET_UINT(fs2->p_shots_hit);
307 PXO_GET_UINT(fs2->s_shots_hit);
309 PXO_GET_UINT(fs2->p_bonehead_hits);
310 PXO_GET_UINT(fs2->s_bonehead_hits);
311 PXO_GET_INT(fs2->bonehead_kills);
313 PXO_GET_INT(fs2->security);
314 PXO_GET_DATA(fs2->virgin_pilot);
316 PXO_GET_DATA(fs2->pad_b); // junk, for size/alignment
318 PXO_GET_UINT(fs2->checksum);
320 PXO_GET_UINT(fs2->missions_flown);
321 PXO_GET_UINT(fs2->flight_time);
322 PXO_GET_UINT(fs2->last_flown);
324 #if !defined(MAKE_FS1) && !defined(FS2_DEMO)
325 PXO_GET_USHORT(fs2->num_medals);
326 PXO_GET_USHORT(fs2->num_ship_types);
328 for (i = 0; i < MAX_FS2_MEDALS; i++) {
329 PXO_GET_INT(fs2->medals[i]);
332 for (i =0; i < MAX_FS2_SHIP_TYPES; i++) {
333 PXO_GET_USHORT(fs2->kills[i]);
340 case UNT_SW_RESULT_RESPONSE: {
341 squad_war_response *sw_resp = (squad_war_response *)&uph->data;
343 PXO_GET_DATA(sw_resp->reason);
344 PXO_GET_DATA(sw_resp->accepted);
353 //SDL_assert(offset == data_size);
357 int InitPilotTrackerClient()
359 struct sockaddr_in sockaddr;
362 FSWriteState = STATE_IDLE;
363 FSReadState = STATE_IDLE;
364 SWWriteState = STATE_IDLE;
368 fs_pr = (pilot_request *)&fs_pilot_req.data;
371 pilotsock = socket(AF_INET,SOCK_DGRAM,0);
373 if ( pilotsock == (SOCKET)INVALID_SOCKET )
375 mprintf(("Unable to open a socket.\n"));
380 memset( &sockaddr, 0, sizeof(struct sockaddr_in) );
381 sockaddr.sin_family = AF_INET;
382 sockaddr.sin_addr.s_addr = INADDR_ANY;
383 sockaddr.sin_port = 0;//htons(REGPORT);
386 if (SOCKET_ERROR==bind(pilotsock, (struct sockaddr*)&sockaddr, sizeof (sockaddr)))
388 mprintf(("Unable to bind a socket.\n"));
389 mprintf(("WSAGetLastError() returned %d.\n",WSAGetLastError()));
394 // iaddr = inet_addr ( Multi_user_tracker_ip_address );
396 // first try and resolve by name
397 iaddr = inet_addr( Multi_options_g.user_tracker_ip );
398 if ( iaddr == INADDR_NONE ) {
400 he = gethostbyname( Multi_options_g.user_tracker_ip );
405 // try and resolve by address
406 unsigned int n_order = inet_addr(Multi_user_tracker_ip_address);
407 he = gethostbyaddr((char*)&n_order,4,PF_INET);
414 iaddr = ((in_addr *)(he->h_addr))->s_addr;
417 ptrackaddr.sin_addr.s_addr = iaddr;
418 ptrackaddr.sin_family = AF_INET;
419 ptrackaddr.sin_port = htons(REGPORT);
425 // -3 Error -- Called with NULL, but no request is waiting
426 // -2 Error -- Already sending data (hasn't timed out yet)
427 // -1 Timeout trying to send pilot data
429 // 1 Data succesfully sent
430 // 2 Send Cancelled (data may still have been written already, we just haven't been ACK'd yet)
431 // 3 Pilot not written (for some reason)
433 // Call with NULL to poll
434 // Call with -1 to cancel send
435 // Call with valid pointer to a vmt_descent3_struct to initiate send
436 int SendFSPilotData(vmt_stats_struct *fs_pilot)
438 //First check the network
443 if(FSWriteState == STATE_IDLE)
447 if(FSWriteState == STATE_SENDING_PILOT)
451 if(FSWriteState == STATE_WROTE_PILOT)
453 //We wrote this pilot, and now we are about to inform the app, so back to idle
454 FSWriteState = STATE_IDLE;
457 if(FSWriteState == STATE_TIMED_OUT)
459 //We gave up on sending this pilot, and now we are about to inform the app, so back to idle
460 FSWriteState = STATE_IDLE;
464 if(FSWriteState == STATE_WRITE_PILOT_FAILED)
466 //The tracker said this dude couldn't be written
467 FSWriteState = STATE_IDLE;
473 else if(fs_pilot == (vmt_stats_struct*)0xffffffff)
475 if(FSWriteState == STATE_IDLE)
482 FSWriteState = STATE_IDLE;
488 else if(FSWriteState == STATE_IDLE)
490 //New request, send out the req, and go for it.
492 FSWriteState = STATE_SENDING_PILOT;
495 FSFirstSentWrite = timer_get_milliseconds();
497 fs_pilot_write.type = UNT_PILOT_DATA_WRITE_NEW;
499 fs_pilot_write.code = CMD_GAME_FREESPACE;
501 fs_pilot_write.code = CMD_GAME_FREESPACE2;
503 fs_pilot_write.len = PACKED_HEADER_ONLY_SIZE+sizeof(vmt_stats_struct);
504 memcpy(&fs_pilot_write.data,fs_pilot,sizeof(vmt_stats_struct));
512 // -3 Error -- Called with NULL, but no request is waiting
513 // -2 Error -- Already sending data (hasn't timed out yet)
514 // -1 Timeout trying to send pilot data
516 // 1 Data succesfully sent
517 // 2 Send Cancelled (data may still have been written already, we just haven't been ACK'd yet)
518 // 3 Pilot not written (for some reason)
520 // Call with NULL to poll
521 // Call with -1 to cancel send
522 // Call with valid pointer to a vmt_descent3_struct to initiate send
523 int SendSWData(squad_war_result *sw_res, squad_war_response *sw_resp)
525 //First check the network
529 if(SWWriteState == STATE_IDLE){
532 if(SWWriteState == STATE_SENDING_PILOT){
536 // fill in the response
537 if(SWWriteState == STATE_WROTE_PILOT){
538 // We wrote this pilot, and now we are about to inform the app, so back to idle
539 SWWriteState = STATE_IDLE;
542 memcpy(sw_resp, &SquadWarWriteResponse, sizeof(squad_war_response));
546 // fill in the response
547 if(SWWriteState == STATE_WRITE_PILOT_FAILED){
548 // The tracker said this dude couldn't be written
549 SWWriteState = STATE_IDLE;
552 memcpy(sw_resp, &SquadWarWriteResponse, sizeof(squad_war_response));
557 if(SWWriteState == STATE_TIMED_OUT){
558 // We gave up on sending this pilot, and now we are about to inform the app, so back to idle
559 SWWriteState = STATE_IDLE;
563 } else if(sw_res == (squad_war_result*)0xffffffff){
564 if(SWWriteState == STATE_IDLE){
568 SWWriteState = STATE_IDLE;
572 } else if(SWWriteState == STATE_IDLE) {
573 //New request, send out the req, and go for it.
575 SWWriteState = STATE_SENDING_PILOT;
578 SWFirstSentWrite = timer_get_milliseconds();
580 sw_res_write.len = PACKED_HEADER_ONLY_SIZE+sizeof(squad_war_result);
581 sw_res_write.type = UNT_SW_RESULT_WRITE;
583 sw_res_write.code = CMD_GAME_FREESPACE;
585 sw_res_write.code = CMD_GAME_FREESPACE2;
587 memcpy(&sw_res_write.data, sw_res, sizeof(squad_war_result));
596 // -3 Error -- Called with NULL, but no request is waiting
597 // -2 Error -- Already waiting on data (hasn't timed out yet)
598 // -1 Timeout waiting for pilot data
599 // 0 Waiting for data
604 // Call with NULL to poll
605 // Call with -1 to cancel wait
606 // Call with valid pointer to a vmt_descent3_struct to get a response
607 int GetFSPilotData(vmt_stats_struct *fs_pilot, const char *pilot_name, const char *tracker_id, int get_security)
609 //First check the network
614 if(FSReadState == STATE_IDLE)
618 if(FSReadState == STATE_READING_PILOT)
622 if(FSReadState == STATE_RECEIVED_PILOT)
624 // We got this pilot, and now we are about to inform the app, so back to idle
625 FSReadState = STATE_IDLE;
629 if(FSReadState == STATE_TIMED_OUT)
631 // We gave up on this pilot, and now we are about to inform the app, so back to idle
632 FSReadState = STATE_IDLE;
636 if(FSReadState == STATE_PILOT_NOT_FOUND)
638 //The tracker said this dude is not found.
639 FSReadState = STATE_IDLE;
645 else if(fs_pilot == (vmt_stats_struct*)0xffffffff)
647 if(FSReadState == STATE_IDLE)
654 FSReadState = STATE_IDLE;
660 else if(FSReadState == STATE_IDLE)
662 //New request, send out the req, and go for it.
664 FSReadState = STATE_READING_PILOT;
665 ReadFSPilot = fs_pilot;
667 FSFirstSent = timer_get_milliseconds();
669 fs_pilot_req.len = PACKED_HEADER_ONLY_SIZE+sizeof(pilot_request);
672 fs_pilot_req.type = UNT_PILOT_DATA_READ_NEW;
674 fs_pilot_req.type = UNT_PILOT_DATA_READ;
678 fs_pilot_req.code = CMD_GAME_FREESPACE;
680 fs_pilot_req.code = CMD_GAME_FREESPACE2;
682 SDL_strlcpy(fs_pr->pilot_name, pilot_name, SDL_arraysize(fs_pr->pilot_name));
683 SDL_strlcpy(fs_pr->tracker_id, tracker_id, SDL_arraysize(fs_pr->tracker_id));
691 // Send an ACK to the server
692 void AckServer(unsigned int sig)
694 udp_packet_header ack_pack;
695 ubyte packet_data[sizeof(udp_packet_header)];
696 int packet_length = 0;
698 ack_pack.type = UNT_CONTROL;
700 ack_pack.code = CMD_CLIENT_RECEIVED;
701 ack_pack.len = PACKED_HEADER_ONLY_SIZE;
703 packet_length = SerializePilotPacket(&ack_pack, packet_data);
704 SDL_assert(packet_length == PACKED_HEADER_ONLY_SIZE);
705 PXO_SENDTO(PILOTSOCK, (char *)&packet_data, packet_length, 0, (struct sockaddr *)&ptrackaddr, sizeof(struct sockaddr_in), PSNET_TYPE_USER_TRACKER);
710 ubyte packet_data[sizeof(udp_packet_header)];
711 int packet_length = 0;
714 PSNET_TOP_LAYER_PROCESS();
717 // reading pilot data
718 if(FSReadState == STATE_READING_PILOT){
719 if((timer_get_milliseconds()-FSFirstSent)>=PILOT_REQ_TIMEOUT){
720 FSReadState = STATE_TIMED_OUT;
721 } else if((timer_get_milliseconds()-FSLastSent)>=PILOT_REQ_RESEND_TIME){
723 packet_length = SerializePilotPacket(&fs_pilot_req, packet_data);
724 PXO_SENDTO(PILOTSOCK, (char *)&packet_data, packet_length, 0, (struct sockaddr *)&ptrackaddr, sizeof(struct sockaddr_in), PSNET_TYPE_USER_TRACKER);
725 FSLastSent = timer_get_milliseconds();
729 // writing pilot data
730 if(FSWriteState == STATE_SENDING_PILOT){
731 if((timer_get_milliseconds()-FSFirstSentWrite)>=PILOT_REQ_TIMEOUT){
732 FSWriteState = STATE_TIMED_OUT;
734 } else if((timer_get_milliseconds()-FSLastSentWrite)>=PILOT_REQ_RESEND_TIME){
736 packet_length = SerializePilotPacket(&fs_pilot_write, packet_data);
737 PXO_SENDTO(PILOTSOCK, (char *)&packet_data, packet_length, 0, (struct sockaddr *)&ptrackaddr, sizeof(struct sockaddr_in), PSNET_TYPE_USER_TRACKER);
738 FSLastSentWrite = timer_get_milliseconds();
742 // writing squad war results
743 if(SWWriteState == STATE_SENDING_PILOT){
744 if((timer_get_milliseconds()-SWFirstSentWrite) >= PILOT_REQ_TIMEOUT){
745 SWWriteState = STATE_TIMED_OUT;
746 } else if((timer_get_milliseconds()-SWLastSentWrite) >= PILOT_REQ_RESEND_TIME){
748 packet_length = SerializePilotPacket(&sw_res_write, packet_data);
749 PXO_SENDTO(PILOTSOCK, (char *)&packet_data, packet_length, 0, (struct sockaddr *)&ptrackaddr, sizeof(struct sockaddr_in), PSNET_TYPE_USER_TRACKER);
750 SWLastSentWrite = timer_get_milliseconds();
758 struct timeval timeout;
759 ubyte packet_data[sizeof(udp_packet_header)];
767 FD_SET(PILOTSOCK, &read_fds);
769 if(PXO_SELECT(PILOTSOCK+1, &read_fds,NULL,NULL,&timeout, PSNET_TYPE_USER_TRACKER)){
772 struct sockaddr_in fromaddr;
774 udp_packet_header inpacket;
777 addrsize = sizeof(struct sockaddr_in);
779 bytesin = PXO_RECVFROM(PILOTSOCK, (char *)&packet_data, sizeof(udp_packet_header), 0, (struct sockaddr *)&fromaddr, &addrsize, PSNET_TYPE_USER_TRACKER);
782 DeserializePilotPacket(packet_data, bytesin, &inpacket);
785 // decrease packet size by 1
790 int wserr=WSAGetLastError();
791 mprintf(("recvfrom() failure. WSAGetLastError() returned %d\n",wserr));
795 //Check to make sure the packets ok
796 if ( (bytesin > 0) && (bytesin == inpacket.len) ) {
797 switch(inpacket.type){
798 case UNT_PILOT_DATA_RESPONSE:
799 if(inpacket.code == CMD_GAME_FREESPACE2){
803 if(FSReadState == STATE_READING_PILOT){
804 vmt_freespace2_struct *stats;
806 // 9/17/98 MWA. Compare the tracker id of this packet with the tracker id of
807 // what we are expecting. Only set our state to something different when
808 // the tracker id's match. This fixes possible multiple packets for a single pilto
809 // accidentally getting set for the wrong pilot
811 stats = (vmt_freespace2_struct *)(&inpacket.data);
812 if ( !SDL_strncasecmp(stats->tracker_id, fs_pr->tracker_id,TRACKER_ID_LEN) ) {
814 memcpy(ReadFSPilot,&inpacket.data,sizeof(vmt_freespace2_struct));
816 FSReadState = STATE_RECEIVED_PILOT;
820 } else if(inpacket.code == CMD_GAME_FREESPACE){
824 if(FSReadState == STATE_READING_PILOT){
825 vmt_freespace_struct *stats;
827 // 9/17/98 MWA. Compare the tracker id of this packet with the tracker id of
828 // what we are expecting. Only set our state to something different when
829 // the tracker id's match. This fixes possible multiple packets for a single pilto
830 // accidentally getting set for the wrong pilot
832 stats = (vmt_freespace_struct *)(&inpacket.data);
833 if ( !SDL_strncasecmp(stats->tracker_id, fs_pr->tracker_id,TRACKER_ID_LEN) ) {
835 memcpy(ReadFSPilot,&inpacket.data,sizeof(vmt_freespace_struct));
837 FSReadState = STATE_RECEIVED_PILOT;
846 case UNT_PILOT_READ_FAILED:
847 if(inpacket.code == CMD_GAME_FREESPACE2){
851 if(FSReadState == STATE_READING_PILOT){
852 FSReadState = STATE_PILOT_NOT_FOUND;
855 } else if(inpacket.code == CMD_GAME_FREESPACE){
859 if(FSReadState == STATE_READING_PILOT){
860 FSReadState = STATE_PILOT_NOT_FOUND;
868 case UNT_PILOT_WRITE_SUCCESS:
869 if(inpacket.code == CMD_GAME_FREESPACE2){
873 if(FSWriteState == STATE_SENDING_PILOT){
874 FSWriteState = STATE_WROTE_PILOT;
877 } else if(inpacket.code == CMD_GAME_FREESPACE){
881 if(FSWriteState == STATE_SENDING_PILOT){
882 FSWriteState = STATE_WROTE_PILOT;
890 case UNT_PILOT_WRITE_FAILED:
891 if(inpacket.code == CMD_GAME_FREESPACE2){
895 if(FSWriteState == STATE_SENDING_PILOT){
896 FSWriteState = STATE_WRITE_PILOT_FAILED;
899 } else if(inpacket.code == CMD_GAME_FREESPACE){
903 if(FSWriteState == STATE_SENDING_PILOT){
904 FSWriteState = STATE_WRITE_PILOT_FAILED;
912 case UNT_SW_RESULT_RESPONSE:
913 if(SWWriteState == STATE_SENDING_PILOT){
915 SDL_assert((bytesin - PACKED_HEADER_ONLY_SIZE) == sizeof(squad_war_response));
916 if((bytesin - PACKED_HEADER_ONLY_SIZE) == sizeof(squad_war_response)){
917 memset(&SquadWarWriteResponse, 0, sizeof(squad_war_response));
918 memcpy(&SquadWarWriteResponse, inpacket.data, sizeof(squad_war_response));
920 // now check to see if we're good
921 if(SquadWarWriteResponse.accepted){
922 SWWriteState = STATE_WROTE_PILOT;
924 SWWriteState = STATE_WRITE_PILOT_FAILED;
927 SWWriteState = STATE_WRITE_PILOT_FAILED;
936 case UNT_CONTROL_VALIDATION:
943 AckServer(inpacket.sig);