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

Protobuf definition out of date? #7

Closed
NikEyX opened this issue Jun 2, 2018 · 7 comments
Closed

Protobuf definition out of date? #7

NikEyX opened this issue Jun 2, 2018 · 7 comments

Comments

@NikEyX
Copy link

NikEyX commented Jun 2, 2018

Hi,

Could it be that you're using an outdated version of the sc2 client protobuf code?
For example, this is in the current s2clientprotobuf/sc2api.proto:

message Action {
optional ActionRaw action_raw = 1; // Populated if Raw interface is enabled.
optional ActionSpatial action_feature_layer = 2; // Populated if Feature Layer interface is enabled.
optional ActionSpatial action_render = 3; // Not implemented. Populated if Render interface is enabled.
optional ActionUI action_ui = 4; // Populated if Feature Layer or Render interface is enabled.
optional ActionChat action_chat = 6; // Chat messages as a player typing into the chat channel.
}

Whereas you seem to have generated the C# code based on this (as per your current github commit):

message Action {
ActionRaw action_raw = 1; // Populated if Raw interface is enabled.
ActionSpatial action_feature_layer = 2; // Populated if Feature Layer interface is enabled.
ActionSpatial action_render = 3; // Not implemented. Populated if Render interface is enabled.
ActionUI action_ui = 4; // Populated if Feature Layer or Render interface is enabled.
repeated ActionChat chat = 5; // Chat messages as a player typing into the chat channel.
}

This leads to chat not working at all. There might be more things broken though.

@matthid
Copy link
Owner

matthid commented Jun 2, 2018

Note that this repository uses protobuf version 3 which (is / can be made) binary compatible to protobuf 2.

In v3 everything is optional by default, see https://stackoverflow.com/a/42634681/1269722

See also Blizzard/s2client-proto#44 where I send the updates back but blizzard is stuck on v2 internally. We are stuck on v3 because it is easier to get it running on netstandard.

@NikEyX
Copy link
Author

NikEyX commented Jun 2, 2018

Hi Matthias,

Sorry if that was misunderstood - I wasn't referring to the fact that you use a different proto version, but rather the fact that your self-maintained proto files differ functionally from the official implementation at this point. For example look at the chat message field pasted above. The actual variable name changed. The field ID also changed. This leads to incompatibility.

So if you want to keep it updated and also use proto3, then it might make sense to pull the current s2clientprotocol from Blizzard and doing a full upgrade to proto3 again. Also on a side note: C# generation of protobuf code is actually posssible with proto 2. When google released their initial v3 releases, they were able to handle both proto2 and proto3 c# generation. This works up to protoc-3.0.0-alpha-3. I've done that already and the files are here:
SC2Protocol.zip

However, this comes with other challenges, since everything is set to read-only by default, so I guess a small script could fix this. Alternatively I saw in your referenced thread that there is a python script to update the proto2 blizzard files to proto3 automatically. Maybe you could use that?

Kind regards

@matthid
Copy link
Owner

matthid commented Jun 2, 2018

Hi @NikEyX
Ah sorry it didn't occur to me that they would do breaking changes to the protocol, but apparently they do.
This is a bit of an unfortunate situation to be in ;)

So yes than they might be out of date. Yes it should not be too hard to update everything. Feel free to update and send a pull request. I can release it for you then

@NikEyX
Copy link
Author

NikEyX commented Jun 2, 2018

I'm actually not using your lib directly, but a fork of it, so I don't know exactly what do change on your end (hence I'll defer the PR to someone more acquainted with that). However, I generated both the proto3 files as well as the C-#Sharpe files. They work on the fork. Find them attached below. I imagine they're just plug&play:

s2clientprotocol PROTO3.zip
UPDATED CS files.zip

Die firma dankt!
Cheers

@travis-leith
Copy link

travis-leith commented Jun 25, 2018

I can get NikEyX's demo to work, but it is all C#, and I really would prefer to code in F#, so would be incredibly grateful if someone can get this one to work. Unfortunately, I lack the expertise to do it myself.

I realize I can use the demo and still code in F# but I think that a library designed for F# is likely to lead to more idiomatic F# code.

When I try to run the demo F# code, I get the following screen

image

and the output window in VS says "The program '[19108] sc2test.exe' has exited with code -1073741510 (0xc000013a)."

@travis-leith
Copy link

Never mind, it turns out you cannot run anything if you have stableid.json open in a text editor. Closed that and then the F# code ran fine. So whats all this about the protobuf definition being out of date? If it doesn't prevent me from running code, what are the implications?

@matthid
Copy link
Owner

matthid commented Jul 7, 2018

@ChechyLevas The implications are that the game sends more information than you actually receive in your types you program with. So the only question is if you need that information for your logic. If not everything is good.

I just updated the proto-files with the zipfile provided by @NikEyX (thanks a lot!) and released a new version. So I guess we can close this.

@matthid matthid closed this as completed Jul 7, 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

No branches or pull requests

3 participants