Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

RakNet Native Compile Info

Discussion in 'Multiplayer' started by zumwalt, Jul 29, 2009.

  1. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    First go to:
    http://www.jenkinssoftware.com/
    Download the latest version of RakNet
    Unzip it

    Start XCode
    Create a new project
    Choose Application of type Carbon C++ Standard Application
    Give it a name
    Add to your list of source files existing files and get all of the files in the source folder under your rakknet folder.

    // BEGIN
    // This is obsolete if you are using the latest version of RakNet
    Find the files with #include <malloc.h> in it, just replace it with the following 3 lines.
    #ifndef __APPLE__
    #include <malloc.h>
    #endif
    // END

    Now click build (if you forget to do the malloc.h fix, then it will let you know there was only 1 error and that is it, just fix and save)

    // Resolved in latest version, only happens in original 3.0
    You will only have 2 warnings after that, and they will be for 2 unused variables, just remark them out, one is in NetworkIDObject.cpp for a variable of count=65535 and the other is in RakPeer.spp for the variable i=0, one you remark those out and compile you should see successful build.

    There you go, built on XCode.
    This also works for Carbon Bundles.
    For fun, I own Intel C++ Pro compiler for the Mac.
    Under the Targets, for the rules on the type, I changed the C rule to use Intel C++ 10, this however was a flop, so don't try it. I don't know why it wouldn't work but for some reason Intel C++ compiler doesn't understand the code. Stick with C++ 4.0 or higher.

    Additional information, if you get ahold of the original 3.0 version of RakNet, you can use the client.connect to your server by using the internal version of RakNet that Unity is using, however, it sends responses back as UNID 83, which of course, we have no control over the ENUMS's or how to hand them, there is no pass through built in, they only handle their own personal ENUMS, so you will still have to make your own client. See attached image for an example, the image is using a carbon bundle that I build for the server and client, running purely on the Mac for this explanation.

    Once I get help with the SWIG issue and Unity engine not playing nice with .Net 2.0 assemblies, I'll post that library and example server / client code on how to set that thing up. With your own build of the client, you need an EGO (or other static game object that will not be destroyed between level loading) and have the client info attached to that EGO. The server can be ran on Linux, Windows or Mac, frankly it doesn't matter as long as the server RakNet build is the same level as the Client interface.

    I can see about putting together a package to post that includes the latest code from Jenkins with both a client and a server with the Carbon bundle, but only as soon as they get around to fixing my inability to post anything larger than 128k to the forums, if they don't get a chance to fix that, I can post instructions but thats about all I can do.

    The facilitator is really just another server running strictly the facilitator methods and doing broadcasts and listening, the master server is the build that would simply allow client connects and broadcast its information as if it was a client to the facilitator, the client is obvious.

    Your client accepts no connections, but connects to the master server, the master server allows any client connections but in turn does a ->connect to the facilitator, the facilitator allows only server connections (or rather should be designed that way). I am very busy this week but I will try also to put together a short 5 minute or less video that shows all of these in action and how to do it on your own, however, you have to have Pro to use the Plugin feature to accommodate for this, you also have to have several versions of the build for each client type (Mac, PC, etc) that you want to support. (instructions for how to do that is in the Unity docs)
     

    Attached Files:

  2. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    If you attempt to use the latest version of Unity 2.5.1 and use the internal network as a client to your own version of RakNet (any flavor it seems) you will get the following errors:
    (so you have to build your own client / server)
     

    Attached Files: