lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
620 stars 65 forks source link

`ClientId` in `renetcode` through new package `renet_core` #129

Closed ActuallyHappening closed 7 months ago

ActuallyHappening commented 7 months ago

Thanks so much for this awesome ecosystem of crates!

This PR extends #103 by introducing the ClientId type into renetcode. #108 for why a new package was needed, there would be a cyclic dependency if renetcode depended on a type from renet since renet depends on renetcode.

This PR also bumps all the package versions, so this would be a major release which is SemVer correct since all the examples would have to be updated. Note: renet_core::ClientId is publicly exported from both renet and renetcode.

Also, to satisfy clippy warnings about 'this loop never actually loops' were fixed in the relevant examples.

lucaspoffo commented 7 months ago

Renetcode is a standalone crate, and shouldn't share any code with renet. Is there a reason why you want to make this change?

ActuallyHappening commented 7 months ago

This change ensures that properly typed arguments are used to be more explicit in intent, to ensure better type safety. It is also more consistent, as ClientId and ClientID were used in renet and renetcode respectively but were distinct types, which was confusing and could be improved to use a shared type.

If you try to define the ClientId in renet, it cannot be used in renetcode (cyclic deps). If you try to define ClientId in renetcode, renet must unconditionally depend on it as part of renet's public API uses ClientId, but its actual transport layer is optional. Thus, a new dependency must be added if both renet and renetcode are to use the same type.

lucaspoffo commented 7 months ago

Hey,

This seems a bit overkill for what essentially is a u64. And renetcode is a standalone crate, don't want to renet/renetcode to share a crate just for the ClientId type.

I decided to remove the alias in renetcode and just use an u64 (e9566792b9ed110b6d2551a2971ed48c3e14bb9f), it didn't add very much. Was not public and not even used in all places.

ActuallyHappening commented 7 months ago

OK all good