1. Thanks for visiting! These forums are for the original Risk of Rain, if you're interested in discussing the newly released Risk of Rain 2 head over to that game's steam discussion forum
    Dismiss Notice

Risk of Rain protocol

Discussion in 'General Discussion' started by alyphen, Nov 5, 2014.

  1. alyphen

    alyphen Master Chief

    Introduction

    I recently started playing RoR, and I felt that there was a lot of untapped potential in the multiplayer. The game is a lot of fun, but multiplayer seems a little unstable and not quite as customisable as it could be. I was curious, and decided I wanted to write a custom server, and in order to do that, I needed to work out the protocol.

    From a few weeks' work, I now have most of the protocol - though there are still some unknown fields in packets that will require some more experimentation & research.

    Protocol

    The client initialises the connection. The server then responds with GM:Studio-Connect.
    See https://docs.google.com/spreadsheets/d/1XChii2gp_JLRgoa97r03n1PYbaWTjcRrbXEbC_nP9Bk/edit?usp=sharing for individual packet information - some packets may not make sense in the clientbound or serverbound context, I have yet to identify which are used where completely.
    GM:Studio prefixes a header to each packet. This header is currently the following:
    -34, -64, -83, -34, 12, 0, 0, 0, [length], 0, 0, 0
    where [length] is the length of the data after the header.
    Next is the packet ID, followed by the data. See the spreadsheet for how each packet uses this.

    I'll try and update this thread with any of my findings, and when I manage to write my custom server, I'll release it on my GitHub so that we can create a decent, stable, server-side modding platform for this game, and anyone who wishes to learn from it can.

    Any information anyone already has on this is greatly appreciated - if we can improve the experience of the RoR community in any way, shape or form, that's awesome.
     
      Last edited: Nov 26, 2014
    • warxy

      warxy Phantasmal Quasar

      Interesting work. I will definitely keep an eye on this.
      Will have a crack at the bytes if I find some time, though I'm not familiar with packet analysis.

      Might port your work to a C++ version eventually if this goes anywhere.
       
      • alyphen

        alyphen Master Chief

        Awesome, I'm always on the IRC (#RiskOfRain on FreeNode), so if you want me to go over how I'm doing this currently, give me a shout and I'll run over it. I'll usually be idling until the evening (GMT), so if I don't respond immediately, just hang around for a few hours and I'll probably respond.

        I've tidied up the post a little, and added a little information on what I think is a Client > Server Ping/KeepAlive packet?

        I'll replicate the ping behaviour either tomorrow or over the weekend, and see where that gets me, and also try clicking on a few things and see what happens.
         
        • warxy

          warxy Phantasmal Quasar

          I will see how much time I have after my exams.

          It would help if you have the bytes in binary or hex form.

          Update:
          I've gone through the packet values you've posted so far.
          I'm finding contradicting information (see: http://gmc.yoyogames.com/index.php?showtopic=636216&p=4645166).
          Basically, there's a 12 octet(byte) header like you've described, and it goes in the sequent of 4,1,4,3.
          • no idea what the 1st 4 bytes are.
          • always 12(0x0c) it would appears.
          • 4 bytes: length of non-header portion in bytes.
          • three 1 byte zeros (0x00).
          I've created a spreadsheet with some colour code: https://docs.google.com/spreadsheets/d/1mOQVUuIA7gmw0TqplXtHXkfR9XSG0PbVJgIWytD7vIk/edit?usp=sharing
           
            Last edited: Nov 7, 2014
          • SkyHunter

            SkyHunter Void-Bound Voyager

            I've written my own Lobby Server, which can handle all of the lobby actions at the moment. (Chatting, Starting, Character selection, etc.)
            Looking into the ingame stuff next, I hope that I can find a way to pass the host stuff or something to another client.
             
            • warxy

              warxy Phantasmal Quasar

              Do you plan to open source your code (if you haven't already done so) or release the information you have on the protocol?
               
              • alyphen

                alyphen Master Chief

                SkyHunter & I have been talking about a lot of the details on Skype. I've updated the post with my findings (moved most things to the spreadsheet) - SkyHunter made the breakthrough that client and server packets use the same IDs, the server just adds the player information onto the beginning of the packet.
                I need to talk with him over a few things, but other than that, I think I've got most of it nailed now. I just need to write the implementation.
                 
                  warxy likes this.
                • warxy

                  warxy Phantasmal Quasar

                  Cool! I just finished my exams so I have a bit more time now. Will join the conversation shortly. SkyHunter has passed me his contacts (Skype & Steam). Thanks for sharing the spreadsheet.
                   
                  • alyphen

                    alyphen Master Chief

                    Updated the spreadsheet with some corrections to serverbound packets
                     
                    • ExtravagantPin

                      ExtravagantPin Void-Bound Voyager

                      I have a small error, I think the datatypes for UPDATE_PLAYER are incorrect, since when I use this:
                      Code:
                        [Packet("UpdatePlayer", 5)]
                              public static void UpdatePlayer(Packet packet)
                              {
                                  int playerClass = packet.Reader.ReadInt32();
                                  Console.WriteLine(playerClass);
                      
                                  double x = packet.Reader.ReadDouble();
                                  Console.WriteLine(x);
                      
                                  double y = packet.Reader.ReadDouble();
                                  Console.WriteLine(y);
                      
                                  string name = packet.Reader.ReadString();
                                  Console.WriteLine("{0} {1} {2} {3}", playerClass, x, y, name);
                      
                                  packet.Sender.CharacterInformation.Update(name, playerClass, x, y);
                              }
                      It throws an exception at .ReadString() as there are not enough bytes left to read. (Ignore the messy code, I'll probably re-do it some later time). It could always just be me reading the wrong data types though! :S ahaha
                      Edit:
                      From what I can tell, the UPDATE_PLAYER packet doesn't contain any info concerning username+login, it looks to be just integers.

                      Also:: I would be interested in also exchanging skype details etc, as I'm planning to ALSO make an emulator, for exactly the same reasons. I bought this game the other day and hated the fact people kept complaining about crashes etc, so I set out to create my own emulator.
                       
                        Last edited: Nov 30, 2014
                      • alyphen

                        alyphen Master Chief

                        The update player packet definitely included the player name - this was included as a null-terminated, UTF-8 encoded string.
                        SkyHunter & I have started developing at https://github.com/stormcloud-dev/stormcloud now, so there's some stuff going on there. Message me your Skype details and I'll be more than happy to add you to the conversation.
                         
                        • ExtravagantPin

                          ExtravagantPin Void-Bound Voyager

                          Yup, just my small error ahahahaha. Haven't had much time to catch up with what's been going on, too much school works. :'\
                           
                          • ShadowlessWanderer

                            ShadowlessWanderer Pangalactic Porcupine

                            Pardon the intrusion but as someone who has absolutely no idea what you people are talking about: What are you guys trying to do? Create an external server program for RoR (like how terraria has)?
                             
                            • ExtravagantPin

                              ExtravagantPin Void-Bound Voyager

                              Exactly :)!
                               
                              • ShadowlessWanderer

                                ShadowlessWanderer Pangalactic Porcupine

                                Well then thats great news. Good luck to all you fine gentlemen and best of luck!
                                 
                                  ExtravagantPin likes this.
                                • legoblob

                                  legoblob Void-Bound Voyager

                                  (Thank you for asking, Ive been watching this thread because it seemed interesting and I didnt want to interrupt their work. Now I know what they are doing xP)
                                   
                                  • Rayfen Windspear

                                    Rayfen Windspear Intergalactic Tourist

                                    Not really sure why everyone seems to use java for these sorts of projects, but if you guys get everything all fleshed out, I would be happy to port it to Go so people can use a low memory footprint version. Something like this probably wouldn't even get anywhere near 50mb of ram usage if it didn't have to lug around a JVM. I won't apologize for being anti-java, I use it every day at work and it drives me nuts.
                                     
                                    • Omen267901

                                      Omen267901 Subatomic Cosmonaut

                                      Same here. For stuff like this Go or LUA or something works much better in my opinion. I personally hate java as a game engine, (It's great otherwise) but there are reasons for using it.
                                       
                                      • warxy

                                        warxy Phantasmal Quasar

                                        Personally I dislilke Java very much, but your arguments seem rather, 'childish'.
                                        Java being a higher level language (compared to the likes of C/C++) is very well known and relatively easy to pick up. OP's project being open source, I think they've made a good decision (whether it is the right one appears to be irrelevantly debatable).

                                        It is true that Java applications and the JVM itself take up quite a bit of memory during runtime, but unless a person's aiming to run this project on anything other than a desktop or similar hardware 50mb is of no concern. Where did this 50mb come from anyway.
                                        You said "probably", which suggests that you either don't know or are uncertain whether your potential version of the project written in Go would have a better memory footage. Don't forget Go is also garbage collected which could well lead to unpredictable memory footage and runtime performance just like any garbage collected language.
                                        And why wait for things to get fleshed out and not start now? @alyphen and @SkyHunter have done an amazing job so far of setting up the ground work with the packet analysis. Between Java and Go, there is no direct mapping anyway.

                                        I'm all for doing this in whatever the heck language everyone prefer, the more people throwing their hands at this the merrier. Personally I will write one in C++. So instead of being ultra defensive and attack the project, why don't you just say "Java sucks big time, I will write one in Go". Let's all be nice to each other :)

                                        Java is not a game engine. I don't think I will ask why LUA would work better...
                                         
                                        • tracc

                                          tracc Void-Bound Voyager

                                          I just want to say thank you for this work you are doing (even if I don't fully understand it)!
                                          and keep us updated on the progress.
                                          one question: Will your server thing be implemented into the game (like a steam Update, after which Hosting and playing will work), or how does a noob like me use whatever you are creating :)?
                                           

                                          Share This Page