ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/MSVC/Flatline_Client.c
(Generate patch)

Comparing Daodan/MSVC/Flatline_Client.c (file contents):
Revision 586 by gumby, Wed Feb 2 08:17:19 2011 UTC vs.
Revision 589 by gumby, Sat Aug 20 09:47:49 2011 UTC

# Line 1 | Line 1
1   #include "Flatline.h"
2   #include "Flatline_Client.h"
3 + #include "Mariusnet_Public.h"
4 + #include "PortForwardWrapper.h"
5  
6   int client_slot = 0;
7   RGBA green = {0, 0xFF, 0, 0};
# Line 31 | Line 33 | int FLcEventHandler( int eventIndex, int
33          return 0;
34   }
35  
36 + void FLcConnect( int ip, short port )
37 + {
38 +        if(     NetPlatform_Initalize()) {
39 +                static flatline_packet packet;
40 +                memset(&client_address, 0, sizeof(sockaddr_in));
41 +                sock = NetUDPSocket_Create(ntohs(port), &client_address);
42 +                address.sin_family = AF_INET; address.sin_port = port; address.sin_addr.S_un.S_addr = ip;
43 +                //address.sin_family = AF_INET; address.sin_port = htons(27777); address.sin_addr.S_un.S_addr = inet_addr("192.168.0.1");      
44 +
45 +                packet.id = CONNECT_SEND;
46 +                memcpy(((connect_send*)(packet.data))->country ,  "XD", 2);
47 +                memcpy(((connect_send*)(packet.data))->name, player_name, 256);
48 +                DDrConsole_PrintF("%s", ((connect_send*)(packet.data))->name);
49 +                CreateThread(NULL, 0, StartClient, &packet, 0, 0);
50 +
51 +        }
52 + }
53  
54   bool FLrClient_Run(flatline_packet* packet)
55   {
# Line 39 | Line 58 | bool FLrClient_Run(flatline_packet* pack
58          uint16_t len;
59          int j;
60          int sent_bytes;
42        client_connected = 0;
61  
62 +        PortMappingContainer_C PMC =
63 +        {
64 +                "",
65 +                "27777",
66 +                "27777",
67 +                "UDP",
68 +                "",
69 +                "",
70 +                "Flatline!"
71 +        };
72 +
73 +        uPnP_Remove( &PMC );
74 +        client_connected = 0;
75  
76 +        
77          //starts the connection
78          DDrConsole_PrintF("Connecting to server %s on socket %i",  inet_ntoa(address.sin_addr), client_sock);
79          sent_bytes = NetUDPSocket_Send(client_sock, (sockaddr*)&address, (char*)packet, FLATLINE_HEADER + sizeof(connect_send) );
# Line 81 | Line 113 | bool FLrClient_Run(flatline_packet* pack
113                                          //DDrPatch_NOOP(0x43B23,0x10);
114                                          //DDrPatch_NOOP(0x4EC248,(0x5A-0x48));
115                                          //DDrPatch_NOOP(0x4EC861, 6);
116 +
117 +                                        //Close Mariusnet collection because it hurts latency
118 +                                        MSNet_RoomExit();
119                                          break;
120                                  }
121                                  else {

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)