wheybags / freeablo

[ARCHIVED] Modern reimplementation of the Diablo 1 game engine
GNU General Public License v3.0
2.16k stars 193 forks source link

Server::mHost is null on Windows 10 without calling enet_address_set_host() #401

Closed balintkissdev closed 5 years ago

balintkissdev commented 5 years ago

In Engine::Server, enet_host_service() was crashing because mHost was null on my Windows 10 machine after call to enet_host_create().

 void Server::update()
{
    ENetEvent event;

    while (enet_host_service(mHost, &event, 0))  // Crash here
    {
        ...
    }
}
Server::Server(FAWorld::World& world, LocalInputHandler& localInputHandler) : mWorld(world), mLocalInputHandler(localInputHandler)
{
    mAddress.port = 6666;
    mAddress.host = ENET_HOST_ANY;
    mHost = enet_host_create(&mAddress, 32, 2, 0, 0);  // mHost will be null
}

Setting the address to the localhost ("127.0.0.1") with enet_address_set_host() solved the issue for me. Not sure if it was removed previously for some reason.