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

Explicitly assign packet IDs (not implicitly from ordering in source code) #19

Merged
merged 6 commits into from
Dec 1, 2018

Conversation

iceiix
Copy link
Owner

@iceiix iceiix commented Nov 5, 2018

@iceiix
Copy link
Owner Author

iceiix commented Nov 6, 2018

Up to 26d8268 is only a refactoring, still on 1.11; e844166 starts to add the 1.10.2 packet definitions, along the lines of what I was thinking. The packets across both versions are listed in packets.rs, so because of the macro expansion the unused packet variants have to be included but with an unused packet ID (used -1). Not the most elegant yet, may have to think about this further, and see if can come up with a cleaner solution.

Another problem: switching to the different protocols at runtime. src/server/mod.rs connect() sends protocol::SUPPORTED_PROTOCOL, the hardcoded fixed value. But src/screen/server_list.rs tick() receives the server protocol version in the ping. Could save the res.protocol_version value, for each server, then send along this value in the packet sent in the connect() method (iff it is within the supported protocols)

https://github.com/iceiix/steven/issues/18#issuecomment-435730991
Expanded the macro using trace_macros!() and some scripts:

https://gist.github.com/iceiix/fc3941d7bc0c639f7eae9d90eacc1212
pbpaste|grep pub\ const|perl -pe's/.*] //g'>/tmp/e
i=0
for line in file("/tmp/e").readlines():
    line = line.strip()
    if "=" in line:
        var, value = line.split("=")
    else:
        var = line
        value=""
    if "0" in value:
        i = 0
    else:
        i += 1
    var = var.strip().split(":")[0].strip()
    print "%s: i32 = 0x%.2x;" % (var, i)
@iceiix iceiix changed the title Flexible packet IDs Explicitly assign packet IDs instead of implicitly from ordering in source Dec 1, 2018
@iceiix iceiix changed the title Explicitly assign packet IDs instead of implicitly from ordering in source Explicitly assign packet IDs (not implicitly from ordering in source code) Dec 1, 2018
@iceiix iceiix merged commit 6189d56 into updates Dec 1, 2018
@iceiix iceiix deleted the packet_ids branch December 1, 2018 01:02
@iceiix
Copy link
Owner Author

iceiix commented Dec 1, 2018

Downscoped this to only change the packet IDs, not moving the definitions or adding new protocol support (although can still connect to both 1.11 and 1.10.2 despite the minor incompatibility)

iceiix added a commit that referenced this pull request Dec 1, 2018
iceiix added a commit that referenced this pull request Dec 1, 2018
iceiix added a commit that referenced this pull request Dec 1, 2018
iceiix added a commit that referenced this pull request Dec 1, 2018
#19

warning: unreachable pattern
   --> src/protocol/mod.rs:238:41
    |
238 |                                           self::$state::$dir::internal_ids::$name => {
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
   ::: src/protocol/packet.rs:19:1
    |
19  | / state_packets!(
20  | |     handshake Handshaking {
21  | |          serverbound Serverbound {
22  | |             /// Handshake is the first packet sent in the protocol.
...   |
912 | |     }
913 | | );
    | |__- in this macro invocation
    |
    = note: #[warn(unreachable_patterns)] on by default
iceiix added a commit that referenced this pull request Dec 1, 2018
iceiix added a commit that referenced this pull request Dec 1, 2018
iceiix added a commit that referenced this pull request Dec 1, 2018
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

Successfully merging this pull request may close these issues.

None yet

1 participant