naev 0.11.5
lua_enet.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
33#include <stdlib.h>
34#include <string.h>
35
36// For lua5.2 support, instead we could replace all the luaL_register's with whatever
37// lua5.2's equivalent function is, but this is easier so whatever.
38#define LUA_COMPAT_MODULE
39#include "lua.h"
40#include "lualib.h"
41#include "lauxlib.h"
42#include <enet/enet.h>
43
44#define check_host(l, idx)\
45 *(ENetHost**)luaL_checkudata(l, idx, "enet_host")
46
47#define check_peer(l, idx)\
48 *(ENetPeer**)luaL_checkudata(l, idx, "enet_peer")
49
56static void parse_address(lua_State *l, const char *addr_str, ENetAddress *address) {
57 int host_i = 0, port_i = 0;
58 char host_str[128] = {0};
59 char port_str[32] = {0};
60 int scanning_port = 0;
61
62 char *c = (char *)addr_str;
63
64 while (*c != 0) {
65 if (host_i >= 128 || port_i >= 32 ) luaL_error(l, "Hostname too long");
66 if (scanning_port) {
67 port_str[port_i++] = *c;
68 } else {
69 if (*c == ':') {
70 scanning_port = 1;
71 } else {
72 host_str[host_i++] = *c;
73 }
74 }
75 c++;
76 }
77 host_str[host_i] = '\0';
78 port_str[port_i] = '\0';
79
80 if (host_i == 0) luaL_error(l, "Failed to parse address");
81 if (port_i == 0) luaL_error(l, "Missing port in address");
82
83 if (strcmp("*", host_str) == 0) {
84 address->host = ENET_HOST_ANY;
85 } else {
86 if (enet_address_set_host(address, host_str) != 0) {
87 luaL_error(l, "Failed to resolve host name");
88 }
89 }
90
91 if (strcmp("*", port_str) == 0) {
92 address->port = ENET_PORT_ANY;
93 } else {
94 address->port = atoi(port_str);
95 }
96}
97
101size_t find_peer_index (lua_State *l, ENetHost *enet_host, ENetPeer *peer) {
102 size_t peer_index;
103 for (peer_index = 0; peer_index < enet_host->peerCount; peer_index++) {
104 if (peer == &(enet_host->peers[peer_index]))
105 return peer_index;
106 }
107
108 luaL_error (l, "enet: could not find peer id!");
109
110 return peer_index;
111}
112
113static void push_peer(lua_State *l, ENetPeer *peer) {
114 // try to find in peer table
115 lua_getfield(l, LUA_REGISTRYINDEX, "enet_peers");
116 lua_pushlightuserdata(l, peer);
117 lua_gettable(l, -2);
118
119 if (lua_isnil(l, -1)) {
120 // printf("creating new peer\n");
121 lua_pop(l, 1);
122
123 *(ENetPeer**)lua_newuserdata(l, sizeof(void*)) = peer;
124 luaL_getmetatable(l, "enet_peer");
125 lua_setmetatable(l, -2);
126
127 lua_pushlightuserdata(l, peer);
128 lua_pushvalue(l, -2);
129
130 lua_settable(l, -4);
131 }
132 lua_remove(l, -2); // remove enet_peers
133}
134
135static void push_event(lua_State *l, ENetEvent *event) {
136 lua_newtable(l); // event table
137
138 if (event->peer) {
139 push_peer(l, event->peer);
140 lua_setfield(l, -2, "peer");
141 }
142
143 switch (event->type) {
144 case ENET_EVENT_TYPE_CONNECT:
145 lua_pushinteger(l, event->data);
146 lua_setfield(l, -2, "data");
147
148 lua_pushstring(l, "connect");
149 break;
150 case ENET_EVENT_TYPE_DISCONNECT:
151 lua_pushinteger(l, event->data);
152 lua_setfield(l, -2, "data");
153
154 lua_pushstring(l, "disconnect");
155 break;
156 case ENET_EVENT_TYPE_RECEIVE:
157 lua_pushlstring(l, (const char *)event->packet->data, event->packet->dataLength);
158 lua_setfield(l, -2, "data");
159
160 lua_pushinteger(l, event->channelID);
161 lua_setfield(l, -2, "channel");
162
163 lua_pushstring(l, "receive");
164
165 enet_packet_destroy(event->packet);
166 break;
167 case ENET_EVENT_TYPE_NONE:
168 lua_pushstring(l, "none");
169 break;
170 }
171
172 lua_setfield(l, -2, "type");
173}
174
179static ENetPacket *read_packet(lua_State *l, int idx, enet_uint8 *channel_id) {
180 size_t size;
181 int argc = lua_gettop(l);
182 const void *data = luaL_checklstring(l, idx, &size);
183 ENetPacket *packet;
184
185 enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE;
186 *channel_id = 0;
187
188 if (argc >= idx+2 && !lua_isnil(l, idx+2)) {
189 const char *flag_str = luaL_checkstring(l, idx+2);
190 if (strcmp("unsequenced", flag_str) == 0) {
191 flags = ENET_PACKET_FLAG_UNSEQUENCED;
192 } else if (strcmp("reliable", flag_str) == 0) {
193 flags = ENET_PACKET_FLAG_RELIABLE;
194 } else if (strcmp("unreliable", flag_str) == 0) {
195 flags = 0;
196 } else {
197 luaL_error(l, "Unknown packet flag: %s", flag_str);
198 }
199 }
200
201 if (argc >= idx+1 && !lua_isnil(l, idx+1)) {
202 *channel_id = luaL_checkint(l, idx+1);
203 }
204
205 packet = enet_packet_create(data, size, flags);
206 if (packet == NULL) {
207 luaL_error(l, "Failed to create packet");
208 }
209
210 return packet;
211}
212
222static int host_create(lua_State *l) {
223 ENetHost *host;
224 size_t peer_count = 64, channel_count = 1;
225 enet_uint32 in_bandwidth = 0, out_bandwidth = 0;
226
227 int have_address = 1;
228 ENetAddress address;
229
230 if (lua_gettop(l) == 0 || lua_isnil(l, 1)) {
231 have_address = 0;
232 } else {
233 parse_address(l, luaL_checkstring(l, 1), &address);
234 }
235
236 switch (lua_gettop(l)) {
237 case 5:
238 if (!lua_isnil(l, 5)) out_bandwidth = luaL_checkint(l, 5);
239 /* fallthrough */
240 case 4:
241 if (!lua_isnil(l, 4)) in_bandwidth = luaL_checkint(l, 4);
242 /* fallthrough */
243 case 3:
244 if (!lua_isnil(l, 3)) channel_count = luaL_checkint(l, 3);
245 /* fallthrough */
246 case 2:
247 if (!lua_isnil(l, 2)) peer_count = luaL_checkint(l, 2);
248 }
249
250 // printf("host create, peers=%d, channels=%d, in=%d, out=%d\n",
251 // peer_count, channel_count, in_bandwidth, out_bandwidth);
252 host = enet_host_create(have_address ? &address : NULL, peer_count,
253 channel_count, in_bandwidth, out_bandwidth);
254
255 if (host == NULL) {
256 lua_pushnil (l);
257 lua_pushstring(l, "enet: failed to create host (already listening?)");
258 return 2;
259 }
260
261 *(ENetHost**)lua_newuserdata(l, sizeof(void*)) = host;
262 luaL_getmetatable(l, "enet_host");
263 lua_setmetatable(l, -2);
264
265 return 1;
266}
267
268static int linked_version(lua_State *l) {
269 lua_pushfstring(l, "%d.%d.%d",
270 ENET_VERSION_GET_MAJOR(enet_linked_version()),
271 ENET_VERSION_GET_MINOR(enet_linked_version()),
272 ENET_VERSION_GET_PATCH(enet_linked_version()));
273 return 1;
274}
275
285static int host_service(lua_State *l) {
286 ENetHost *host = check_host(l, 1);
287 if (!host) {
288 return luaL_error(l, "Tried to index a nil host!");
289 }
290 ENetEvent event;
291 int timeout = 0, out;
292
293 if (lua_gettop(l) > 1)
294 timeout = luaL_checkint(l, 2);
295
296 out = enet_host_service(host, &event, timeout);
297 if (out == 0) return 0;
298 if (out < 0) return luaL_error(l, "Error during service");
299
300 push_event(l, &event);
301 return 1;
302}
303
307static int host_check_events(lua_State *l) {
308 ENetHost *host = check_host(l, 1);
309 if (!host) {
310 return luaL_error(l, "Tried to index a nil host!");
311 }
312 ENetEvent event;
313 int out = enet_host_check_events(host, &event);
314 if (out == 0) return 0;
315 if (out < 0) return luaL_error(l, "Error checking event");
316
317 push_event(l, &event);
318 return 1;
319}
320
325static int host_compress_with_range_coder(lua_State *l) {
326 ENetHost *host = check_host(l, 1);
327 if (!host) {
328 return luaL_error(l, "Tried to index a nil host!");
329 }
330
331 int result = enet_host_compress_with_range_coder (host);
332 if (result == 0) {
333 lua_pushboolean (l, 1);
334 } else {
335 lua_pushboolean (l, 0);
336 }
337
338 return 1;
339}
340
348static int host_connect(lua_State *l) {
349 ENetHost *host = check_host(l, 1);
350 if (!host) {
351 return luaL_error(l, "Tried to index a nil host!");
352 }
353 ENetAddress address;
354 ENetPeer *peer;
355
356 enet_uint32 data = 0;
357 size_t channel_count = 1;
358
359 parse_address(l, luaL_checkstring(l, 2), &address);
360
361 switch (lua_gettop(l)) {
362 case 4:
363 if (!lua_isnil(l, 4)) data = luaL_checkint(l, 4);
364 /* fallthrough */
365 case 3:
366 /* fallthrough */
367 if (!lua_isnil(l, 3)) channel_count = luaL_checkint(l, 3);
368 }
369
370 // printf("host connect, channels=%d, data=%d\n", channel_count, data);
371 peer = enet_host_connect(host, &address, channel_count, data);
372
373 if (peer == NULL) {
374 return luaL_error(l, "Failed to create peer");
375 }
376
377 push_peer(l, peer);
378
379 return 1;
380}
381
382static int host_flush(lua_State *l) {
383 ENetHost *host = check_host(l, 1);
384 if (!host) {
385 return luaL_error(l, "Tried to index a nil host!");
386 }
387 enet_host_flush(host);
388 return 0;
389}
390
391static int host_broadcast(lua_State *l) {
392 ENetHost *host = check_host(l, 1);
393 if (!host) {
394 return luaL_error(l, "Tried to index a nil host!");
395 }
396
397 enet_uint8 channel_id;
398 ENetPacket *packet = read_packet(l, 2, &channel_id);
399 enet_host_broadcast(host, channel_id, packet);
400 return 0;
401}
402
403// Args: limit:number
404static int host_channel_limit(lua_State *l) {
405 ENetHost *host = check_host(l, 1);
406 if (!host) {
407 return luaL_error(l, "Tried to index a nil host!");
408 }
409 int limit = luaL_checkint(l, 2);
410 enet_host_channel_limit(host, limit);
411 return 0;
412}
413
414static int host_bandwidth_limit(lua_State *l) {
415 ENetHost *host = check_host(l, 1);
416 if (!host) {
417 return luaL_error(l, "Tried to index a nil host!");
418 }
419 enet_uint32 in_bandwidth = luaL_checkint(l, 2);
420 enet_uint32 out_bandwidth = luaL_checkint(l, 2);
421 enet_host_bandwidth_limit(host, in_bandwidth, out_bandwidth);
422 return 0;
423}
424
425static int host_get_socket_address(lua_State *l) {
426 ENetHost *host = check_host(l, 1);
427 if (!host) {
428 return luaL_error(l, "Tried to index a nil host!");
429 }
430 ENetAddress address;
431 enet_socket_get_address (host->socket, &address);
432
433 lua_pushfstring(l, "%d.%d.%d.%d:%d",
434 ((address.host) & 0xFF),
435 ((address.host >> 8) & 0xFF),
436 ((address.host >> 16) & 0xFF),
437 (address.host >> 24& 0xFF),
438 address.port);
439
440 return 1;
441}
442static int host_total_sent_data(lua_State *l) {
443 ENetHost *host = check_host(l, 1);
444 if (!host) {
445 return luaL_error(l, "Tried to index a nil host!");
446 }
447
448 lua_pushinteger (l, host->totalSentData);
449
450 return 1;
451}
452
453static int host_total_received_data(lua_State *l) {
454 ENetHost *host = check_host(l, 1);
455 if (!host) {
456 return luaL_error(l, "Tried to index a nil host!");
457 }
458
459 lua_pushinteger (l, host->totalReceivedData);
460
461 return 1;
462}
463static int host_service_time(lua_State *l) {
464 ENetHost *host = check_host(l, 1);
465 if (!host) {
466 return luaL_error(l, "Tried to index a nil host!");
467 }
468
469 lua_pushinteger (l, host->serviceTime);
470
471 return 1;
472}
473
474static int host_peer_count(lua_State *l) {
475 ENetHost *host = check_host(l, 1);
476 if (!host) {
477 return luaL_error(l, "Tried to index a nil host!");
478 }
479
480 lua_pushinteger (l, host->peerCount);
481
482 return 1;
483}
484
485static int host_get_peer(lua_State *l) {
486 ENetHost *host = check_host(l, 1);
487 if (!host) {
488 return luaL_error(l, "Tried to index a nil host!");
489 }
490
491 size_t peer_index = (size_t) luaL_checkint(l, 2) - 1;
492
493 if (peer_index >= host->peerCount) {
494 luaL_argerror (l, 2, "Invalid peer index");
495 }
496
497 ENetPeer *peer = &(host->peers[peer_index]);
498
499 push_peer (l, peer);
500 return 1;
501}
502
503static int host_gc(lua_State *l) {
504 // We have to manually grab the userdata so that we can set it to NULL.
505 ENetHost** host = luaL_checkudata(l, 1, "enet_host");
506 // We don't want to crash by destroying a non-existant host.
507 if (*host) {
508 enet_host_destroy(*host);
509 }
510 *host = NULL;
511 return 0;
512}
513
514static int peer_tostring(lua_State *l) {
515 ENetPeer *peer = check_peer(l, 1);
516 char host_str[128];
517 enet_address_get_host_ip(&peer->address, host_str, 128);
518
519 lua_pushstring(l, host_str);
520 lua_pushstring(l, ":");
521 lua_pushinteger(l, peer->address.port);
522 lua_concat(l, 3);
523 return 1;
524}
525
526static int peer_ping(lua_State *l) {
527 ENetPeer *peer = check_peer(l, 1);
528 enet_peer_ping(peer);
529 return 0;
530}
531
532static int peer_throttle_configure(lua_State *l) {
533 ENetPeer *peer = check_peer(l, 1);
534
535 enet_uint32 interval = luaL_checkint(l, 2);
536 enet_uint32 acceleration = luaL_checkint(l, 3);
537 enet_uint32 deceleration = luaL_checkint(l, 4);
538
539 enet_peer_throttle_configure(peer, interval, acceleration, deceleration);
540 return 0;
541}
542
543static int peer_round_trip_time(lua_State *l) {
544 ENetPeer *peer = check_peer(l, 1);
545
546 if (lua_gettop(l) > 1) {
547 enet_uint32 round_trip_time = luaL_checkint(l, 2);
548 peer->roundTripTime = round_trip_time;
549 }
550
551 lua_pushinteger (l, peer->roundTripTime);
552
553 return 1;
554}
555
556static int peer_last_round_trip_time(lua_State *l) {
557 ENetPeer *peer = check_peer(l, 1);
558
559 if (lua_gettop(l) > 1) {
560 enet_uint32 round_trip_time = luaL_checkint(l, 2);
561 peer->lastRoundTripTime = round_trip_time;
562 }
563 lua_pushinteger (l, peer->lastRoundTripTime);
564
565 return 1;
566}
567
568static int peer_ping_interval(lua_State *l) {
569 ENetPeer *peer = check_peer(l, 1);
570
571 if (lua_gettop(l) > 1) {
572 enet_uint32 interval = luaL_checkint(l, 2);
573 enet_peer_ping_interval (peer, interval);
574 }
575
576 lua_pushinteger (l, peer->pingInterval);
577
578 return 1;
579}
580
581static int peer_timeout(lua_State *l) {
582 ENetPeer *peer = check_peer(l, 1);
583
584 enet_uint32 timeout_limit = 0;
585 enet_uint32 timeout_minimum = 0;
586 enet_uint32 timeout_maximum = 0;
587
588 switch (lua_gettop(l)) {
589 case 4:
590 if (!lua_isnil(l, 4)) timeout_maximum = luaL_checkint(l, 4);
591 /* fallthrough */
592 case 3:
593 if (!lua_isnil(l, 3)) timeout_minimum = luaL_checkint(l, 3);
594 /* fallthrough */
595 case 2:
596 if (!lua_isnil(l, 2)) timeout_limit = luaL_checkint(l, 2);
597 }
598
599 enet_peer_timeout (peer, timeout_limit, timeout_minimum, timeout_maximum);
600
601 lua_pushinteger (l, peer->timeoutLimit);
602 lua_pushinteger (l, peer->timeoutMinimum);
603 lua_pushinteger (l, peer->timeoutMaximum);
604
605 return 3;
606}
607
608static int peer_disconnect(lua_State *l) {
609 ENetPeer *peer = check_peer(l, 1);
610
611 enet_uint32 data = lua_gettop(l) > 1 ? luaL_checkint(l, 2) : 0;
612 enet_peer_disconnect(peer, data);
613 return 0;
614}
615
616static int peer_disconnect_now(lua_State *l) {
617 ENetPeer *peer = check_peer(l, 1);
618
619 enet_uint32 data = lua_gettop(l) > 1 ? luaL_checkint(l, 2) : 0;
620 enet_peer_disconnect_now(peer, data);
621 return 0;
622}
623
624static int peer_disconnect_later(lua_State *l) {
625 ENetPeer *peer = check_peer(l, 1);
626
627 enet_uint32 data = lua_gettop(l) > 1 ? luaL_checkint(l, 2) : 0;
628 enet_peer_disconnect_later(peer, data);
629 return 0;
630}
631
632static int peer_index(lua_State *l) {
633 ENetPeer *peer = check_peer(l, 1);
634
635 size_t peer_index = find_peer_index (l, peer->host, peer);
636 lua_pushinteger (l, peer_index + 1);
637
638 return 1;
639}
640
641static int peer_state(lua_State *l) {
642 ENetPeer *peer = check_peer(l, 1);
643
644 switch (peer->state) {
645 case (ENET_PEER_STATE_DISCONNECTED):
646 lua_pushstring (l, "disconnected");
647 break;
648 case (ENET_PEER_STATE_CONNECTING):
649 lua_pushstring (l, "connecting");
650 break;
651 case (ENET_PEER_STATE_ACKNOWLEDGING_CONNECT):
652 lua_pushstring (l, "acknowledging_connect");
653 break;
654 case (ENET_PEER_STATE_CONNECTION_PENDING):
655 lua_pushstring (l, "connection_pending");
656 break;
657 case (ENET_PEER_STATE_CONNECTION_SUCCEEDED):
658 lua_pushstring (l, "connection_succeeded");
659 break;
660 case (ENET_PEER_STATE_CONNECTED):
661 lua_pushstring (l, "connected");
662 break;
663 case (ENET_PEER_STATE_DISCONNECT_LATER):
664 lua_pushstring (l, "disconnect_later");
665 break;
666 case (ENET_PEER_STATE_DISCONNECTING):
667 lua_pushstring (l, "disconnecting");
668 break;
669 case (ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT):
670 lua_pushstring (l, "acknowledging_disconnect");
671 break;
672 case (ENET_PEER_STATE_ZOMBIE):
673 lua_pushstring (l, "zombie");
674 break;
675 default:
676 lua_pushstring (l, "unknown");
677 }
678
679 return 1;
680}
681
682static int peer_connect_id(lua_State *l) {
683 ENetPeer *peer = check_peer(l, 1);
684
685 lua_pushinteger (l, peer->connectID);
686
687 return 1;
688}
689
690
691static int peer_reset(lua_State *l) {
692 ENetPeer *peer = check_peer(l, 1);
693 enet_peer_reset(peer);
694 return 0;
695}
696
697static int peer_receive(lua_State *l) {
698 ENetPeer *peer = check_peer(l, 1);
699 ENetPacket *packet;
700 enet_uint8 channel_id = 0;
701
702 if (lua_gettop(l) > 1) {
703 channel_id = luaL_checkint(l, 2);
704 }
705
706 packet = enet_peer_receive(peer, &channel_id);
707 if (packet == NULL) return 0;
708
709 lua_pushlstring(l, (const char *)packet->data, packet->dataLength);
710 lua_pushinteger(l, channel_id);
711
712 enet_packet_destroy(packet);
713 return 2;
714}
715
716
725static int peer_send(lua_State *l) {
726 ENetPeer *peer = check_peer(l, 1);
727
728 enet_uint8 channel_id;
729 ENetPacket *packet = read_packet(l, 2, &channel_id);
730
731 // printf("sending, channel_id=%d\n", channel_id);
732 int ret = enet_peer_send(peer, channel_id, packet);
733 if (ret < 0) {
734 enet_packet_destroy(packet);
735 }
736
737 lua_pushinteger(l, ret);
738
739 return 1;
740}
741
742static const struct luaL_Reg enet_funcs [] = {
743 {"host_create", host_create},
744 {"linked_version", linked_version},
745 {NULL, NULL}
746};
747
748static const struct luaL_Reg enet_host_funcs [] = {
749 {"service", host_service},
750 {"check_events", host_check_events},
751 {"compress_with_range_coder", host_compress_with_range_coder},
752 {"connect", host_connect},
753 {"flush", host_flush},
754 {"broadcast", host_broadcast},
755 {"channel_limit", host_channel_limit},
756 {"bandwidth_limit", host_bandwidth_limit},
757 // Since ENetSocket isn't part of enet-lua, we should try to keep
758 // naming conventions the same as the rest of the lib.
759 {"get_socket_address", host_get_socket_address},
760 // We need this function to free up our ports when needed!
761 {"destroy", host_gc},
762
763 // additional convenience functions (mostly accessors)
764 {"total_sent_data", host_total_sent_data},
765 {"total_received_data", host_total_received_data},
766 {"service_time", host_service_time},
767 {"peer_count", host_peer_count},
768 {"get_peer", host_get_peer},
769 {NULL, NULL}
770};
771
772static const struct luaL_Reg enet_peer_funcs [] = {
773 {"disconnect", peer_disconnect},
774 {"disconnect_now", peer_disconnect_now},
775 {"disconnect_later", peer_disconnect_later},
776 {"reset", peer_reset},
777 {"ping", peer_ping},
778 {"receive", peer_receive},
779 {"send", peer_send},
780 {"throttle_configure", peer_throttle_configure},
781 {"ping_interval", peer_ping_interval},
782 {"timeout", peer_timeout},
783
784 // additional convenience functions to member variables
785 {"index", peer_index},
786 {"state", peer_state},
787 {"connect_id", peer_connect_id},
788 {"round_trip_time", peer_round_trip_time},
789 {"last_round_trip_time", peer_last_round_trip_time},
790 {NULL, NULL}
791};
792
793int luaopen_enet(lua_State *l) {
794 enet_initialize();
795 atexit(enet_deinitialize);
796
797 // create metatables
798 luaL_newmetatable(l, "enet_host");
799 lua_newtable(l); // index
800 luaL_register(l, NULL, enet_host_funcs);
801 lua_setfield(l, -2, "__index");
802 lua_pushcfunction(l, host_gc);
803 lua_setfield(l, -2, "__gc");
804
805 luaL_newmetatable(l, "enet_peer");
806 lua_newtable(l);
807 luaL_register(l, NULL, enet_peer_funcs);
808 lua_setfield(l, -2, "__index");
809 lua_pushcfunction(l, peer_tostring);
810 lua_setfield(l, -2, "__tostring");
811
812 // set up peer table
813 lua_newtable(l);
814
815 lua_newtable(l); // metatable
816 lua_pushstring(l, "v");
817 lua_setfield(l, -2, "__mode");
818 lua_setmetatable(l, -2);
819
820 lua_setfield(l, LUA_REGISTRYINDEX, "enet_peers");
821
822 luaL_register(l, "enet", enet_funcs);
823 return 1;
824}
static int host_service(lua_State *l)
Definition lua_enet.c:285
static int host_create(lua_State *l)
Definition lua_enet.c:222
static int host_compress_with_range_coder(lua_State *l)
Definition lua_enet.c:325
size_t find_peer_index(lua_State *l, ENetHost *enet_host, ENetPeer *peer)
Definition lua_enet.c:101
static int host_connect(lua_State *l)
Definition lua_enet.c:348
static void parse_address(lua_State *l, const char *addr_str, ENetAddress *address)
Definition lua_enet.c:56
static ENetPacket * read_packet(lua_State *l, int idx, enet_uint8 *channel_id)
Definition lua_enet.c:179
static int peer_send(lua_State *l)
Definition lua_enet.c:725
static int host_check_events(lua_State *l)
Definition lua_enet.c:307
static const double c[]
Definition rng.c:264