Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to enet 1.3.17 #6

Open
SimonN opened this issue Feb 24, 2022 · 1 comment
Open

Update to enet 1.3.17 #6

SimonN opened this issue Feb 24, 2022 · 1 comment

Comments

@SimonN
Copy link

SimonN commented Feb 24, 2022

derelict-enet is for enet 1.3.15. Stable upstream release is enet 1.3.17. Please update. :-)

Struct ENetPeer has a different length in 1.3.17 than the 1.3.15 D bindings (or 1.3.15 C headers) suggest. This risks array misindexing into the array of peers for every connected peer except peer 0.

Workaround

For usercode to run against enet 1.3.17 DLLs with the 1.3.15 bindings, usercode must guess the struct length of ENetPeer at runtime. When usercode receives a packet from a peer (who is not peer 0, who sits at the start of the array), look at the peer.incomingPeerID. If the bindings are correct, this works as an index into _host.peers. But even on mismatching bindings (wrong struct length), you can compute the DLL's struct length from that index with:

(cast(void*)peer - cast(void*) host.peers) / peer.incomingPeerID

This workaround may be useful even with the most up-to-date bindings. When people build the usercode from source, they must install enet DLLs separately, and the usercode can only force a version of the bindings, not a version of the DLL. It can decide to abort on mismatching DLLs, or try this workaround.

@mdparker
Copy link
Member

We're not maintaining Derelict anymore. It's been superseded by BindBC. I've not had a reason to port this one over yet, but I can make time for it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants