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