| 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}; |
| 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 |
|
{ |
| 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) ); |
| 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 { |