Beispiel #1
0
void destroy_objects_host()
{
	unsigned int i;
	for (i = 0; i < num_objects.hosts; i++) {
		host *this_host = host_ary[i];
		destroy_host(this_host);
	}
	host_list = NULL;
	if (host_hash_table)
		g_hash_table_destroy(host_hash_table);

	host_hash_table = NULL;
	nm_free(host_ary);
	num_objects.hosts = 0;
}
Beispiel #2
0
bool connection_join(const char *hostname, uint16_t port) {
    destroy_host();

    ENetAddress address;
    enet_address_set_host(&address, hostname);
    address.port = port;

    host = enet_host_create(NULL, 1, CHANNEL_COUNT, 0, 0);
    server = enet_host_connect(host, &address, CHANNEL_COUNT, 0);

    ENetEvent event;
    if (enet_host_service(host, &event, 1000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) {
        entity_reset_all();
    }

    return host != NULL;
}
Beispiel #3
0
bool connection_host(uint16_t port, size_t max_players) {
    destroy_host();

    ENetAddress address;
    address.host = ENET_HOST_ANY;
    address.port = port;

    host = enet_host_create(&address, max_players, CHANNEL_COUNT, 0, 0);

    if (host) {
        entity_reset_all();

        ALLEGRO_EVENT event;
        event.type = CONNECTION_JOIN_EVENT_ID;
        al_emit_user_event(&event_source, &event, NULL);
    }

    return host != NULL;
}