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.
derelict-enet is for enet 1.3.15. Stable upstream release is enet 1.3.17. Please update. :-)
Struct
ENetPeerhas 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
ENetPeerat runtime. When usercode receives a packet from apeer(who is not peer 0, who sits at the start of the array), look at thepeer.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: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.