7 |
|
#include "Flatline.h" |
8 |
|
#include "Flatline_Server.h" |
9 |
|
#include "Mariusnet_Public.h" |
10 |
+ |
#include "Flatline_Client.h" |
11 |
|
bool server_started = 0; |
12 |
|
bool client_connected = 0; |
13 |
|
int sock = 0; |
77 |
|
uint16_t ONICALL connect_to_server(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
78 |
|
{ |
79 |
|
//TODO: Move this into the client initialization. Doing it like this is silly. |
80 |
< |
if( NetPlatform_Initalize()) { |
80 |
< |
static flatline_packet packet; |
81 |
< |
memset(&client_address, 0, sizeof(sockaddr_in)); |
82 |
< |
sock = NetUDPSocket_Create(27777, &client_address); |
83 |
< |
address.sin_family = AF_INET; address.sin_port = htons(27777); address.sin_addr.S_un.S_addr = inet_addr(args[0].value_str32 ); |
84 |
< |
//address.sin_family = AF_INET; address.sin_port = htons(27777); address.sin_addr.S_un.S_addr = inet_addr("192.168.0.1"); |
85 |
< |
|
86 |
< |
packet.id = CONNECT_SEND; |
87 |
< |
memcpy(((connect_send*)(packet.data))->country , player_country, 2); |
88 |
< |
memcpy(((connect_send*)(packet.data))->name, player_name, 256); |
89 |
< |
DDrConsole_PrintF("%s", ((connect_send*)(packet.data))->name); |
90 |
< |
CreateThread(NULL, 0, StartClient, &packet, 0, 0); |
91 |
< |
|
92 |
< |
} |
93 |
< |
|
80 |
> |
FLcConnect(inet_addr(args[0].value_str32), htons(27777)); |
81 |
|
return 0; |
82 |
|
} |
83 |
|
uint16_t ONICALL status(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
223 |
|
return 0; |
224 |
|
} |
225 |
|
|
226 |
+ |
extern uint16_t ONICALL mnet_joingame(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret); |
227 |
+ |
|
228 |
|
void SLrFlatline_Initialize() |
229 |
|
{ |
230 |
|
|
237 |
|
SLrScript_Command_Register_Void("msg","Sends a message", "", send_message); |
238 |
|
SLrScript_Command_Register_ReturnType("name","changes your name", "name:string", sl_void, change_name); |
239 |
|
SLrScript_Command_Register_Void("status","shows the connection status", "", status); |
240 |
< |
SLrGlobalVariable_Register_String("country", "Your Multiplayer country", player_name); |
240 |
> |
//SLrGlobalVariable_Register_String("country", "Your Multiplayer country", player_name); |
241 |
|
SLrScript_Command_Register_ReturnType("addbot","adds a fake client", "", sl_void, addfake); |
242 |
|
SLrScript_Command_Register_Void("kick", "Kicks a client from the server", "clientnum:int", kick); |
243 |
|
SLrScript_Command_Register_Void("con", "Activates a console", "con:int", con); |
244 |
|
SLrScript_Command_Register_Void("ping", "pong!", "", ping); |
245 |
|
|
246 |
|
SLrScript_Command_Register_Void("login", "logs into mariusnet", "username:string password:string", mnet_login); |
247 |
+ |
SLrScript_Command_Register_Void("join", "joins a mariusnet game", "index:int", mnet_joingame); |
248 |
|
} |