Page 1 of 2 12 LastLast
Results 1 to 20 of 34

Thread: RakNet Support (WIP)

  1. #1

    Default RakNet Support (WIP)

    I am currently working on a 2D MMORPG in DarkGDK but me and my team have decided to switch over to NovaShell because of the very flexible license terms and it uses Box2D (which is what we were using anyway so no difference in the switch).

    So I am kinda hoping Seth or a long time source user to give me some feedback on integrating RakNet in the source code (no LUA scripting support yet).

    I already coded a basic server with user commands and etc, but do you think it is possible to convert NovaShell into a stand alone ORPG?

    P.S. I will release a guide on implementing RakNet in the source once im successful.

  2. #2

    Default raknet support...

    sweet sushi,

    you will earn the respect and admiration of many here if you can move us closer to network support for novashell.

    especially people like me who apparently are not sharp enough to figure it out.

    thanks,

  3. #3
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    Well, if I was doing a networked game here are some basic ideas...

    Modify the Entity class so they can be tagged "net objects", remote net objects do not use the Box2d physics, the client will just received updates of position, rotation, map changes.

    They could use prediction based on the displacements of the last two positions. Games like racing games work best for this, because you can't do a 180 degree instant turn.

    A game server figures out what maps need to be sent updates on based on the player position, when things are out of range, they are automatically killed. (This server part heavily depends on the game type... the server could be a version of novashell that just doesn't draw what its doing to improve speed)

    Some games, like Ultima Online use clicks and send desired tile to move to instead of sending rough movements, and verify the new position while displaying the walk animation so you don't notice the 200 MS delay while the server is actually checking each step you make. Otherwise, gameplay would be a drag.

    A game like Quake/Torque engine doesn't verify movement the same way, it lets you move wherever you want and just tells the server where you are so it can distribute the data to the other players. So UDP packets are ok, and only some packets are "guaranteed", like shooting and such.

    Where it gets tricky is you probably don't want Box2D doing much with netobjects.. so you want your server figuring out collision and game logic (best for security) using some other method like simple circle-circle checks.
    Seth A. Robinson
    Robinson Technologies

  4. #4

    Default

    I am going to create it for a 2D MMORPG, keyboard controlled, and UDP. Although as you may know, RakNet can order and guarantee UDP packets so I will use a health mixture of both methods for streaming and messaging.

    We only plan to use Box2D for movement and collision. No added physics like boxes and etc.

    I am looking forward to more input like where to add the initial connection etc etc. Do you think any existing libraries will throw conflicts with RakNet? I haven't been able to test integration yet, I am modifying/learning the pre-exsistant source code.

    Once I get the basic integration done I will release the source code so there will be a net enabled version. I am debating on wrapping the functions in LUA.

    Thanks,
    Dylan

  5. #5

    Default raknet support...

    hey seth & sushi,

    just a question, not a request. would the general workings of 2d type games like board games, cards, puzzles and stuff like that be easier to implement with networking or just as hard?

    i know people here will chomp at the bit for orpg, but i'm sure some have other game types that they might want to try and implement online too.

    i've been considering doing a bidwhist game or dominoes with an ethnic flavor to it. but i would not want it to be simply single player against ai. seth's engine is perfect for designing 2d casual games and such because the visual elements are almost like photoshop for games. so networking at some level of workable simplicity would be a pants soiling event for novashell.

    also, as if i have not already asked too much, what are some good references or tutorial sites for getting my head around this 'networking' crap. i love it, and every game engine site i visit clamors for it. but like web design, only a few people actually do it, while the rest of ramble on 'wishing' we could do it too.

  6. #6

    Default

    Should be the same basic concept. The only thing, it is literally impossibly to integrate networking and keep this engine as flexible as it is. The user would HAVE to know a bit of C++, or else the scripting would be ridiculous to use or implement.

    I plan to release COMPLETELY change the current engine to my needs, but I will post a guide on implementing a RakNet base into Novashell once im successful.

    Go check out RakNet and mess around with it, if you watch all the incredibly long videos they have to offer, I guarantee you will learn a lot. You do not need to thread or worry about sockets cause RakNet already does this underneath. They take the working out of networking.

    I'll keep you all updated, id also like to know if Seth would be too terribly upset if I released my modded version of the engine way down the road once my MMO is released.

    You guys can visit my site here: www.SylereanOnline.com

  7. #7

    Default

    Update: I got the RakNet library implemented and some client sided code in there compiling with no errors. Problem is, i'm looking for a good insertion point to call the function.

    I also added two new commands in the source:

    LogNetwork - Saves a message to the log prepended with "Network: "

    Usage: LogNetwork(const char *lpFormat, ...)

    LogNetworkError - Saves a message to the log prepended with "Network Error: "

    Usage: LogNetworkError(const char *lpFormat, ...)

    I need to look more into how to create commands for LUA. I'm not sure how all the binding works yet.

    Once again, ill keep all of you updated.

  8. #8

    Default

    Update: Clients can now successfully connect to the server! The server also has four user commands built in.

    /help - displays a list of usable commands
    /stat - displays in depth statistics on server communications
    /ban - bans an IP for the session only (no database required)
    /shutdown - shuts down the server and safely logs off clients

    May not seem to incredibly in depth, but at least I got Novashell enabled with basic networking capabilities!!! Once I learn how to bind commands to LUA, I will create some basic commands such as setting the server IP and enabling networking.

    Seth, mind enlightening me?

  9. #9

    Default raknet support...

    sweet sushi,

    i don't know what all of that means, but i know it sounds like steady progress towards basic networking in novashell...kudos.

    i'm looking at the raknet site...it's painful. learning, or in my case, trying to learn, can be a violent, invasive ordeal at times.

    wish i could contribute something as significant as what you are doing to the shellerz.

    keep at it, i'm sure seth appreciates the help...

  10. #10

    Default

    Thanks harrio, right now I'm implementing MySQL into the server for some database support. Should be able to do some simple things such as logging in and etc. I just really need Seth to get on here and tutor me on the LUA bindings.

    You can add me on MSN if you have, same with Seth.: Crank@Gomoku-MS.com

  11. #11
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    Luabind isn't hard to use, but it's a nightmare to debug when something goes wrong... it's an insanely complicated template system to very quickly allow script to access classes.

    Luabind docs is the best place to learn about it

    So, let's say you have a NetworkManager.cpp global, and it has like 10 functions you want to give scripters access to.

    Use the TextManager global (g_textManager) as an example.

    First, you register it:
    Code:
    void luabindMisc(lua_State *pState)
    {
    	module(pState)
    		[
    ,class_<TextManager>("TextManager")
    		.def("__tostring", &TextManagerToString)
    		.def("Add", &TextManager::Add)
    		.def("AddCustom", &TextManager::AddCustom)
    		.def("AddCustomScreen", &TextManager::AddCustomScreen)
    	];
    }

    Then you give the scripting system a way to access the global (if needed):

    Luabind will automatically look at each of these functions and figure its parameters.

    The "__tostring" is a special function that just tells the scripting system what to print if someone says LogMsg(GetTextManager); it isn't required.

    Code:
    luabind::globals(pLuaState)["GetTextManager"] = &g_textManager;
    You can search to see where I do it in the source, but keep in mind, you probably want to put most of your stuff in separate files and just add 'hooks', so it's easier for you to add bugfixes ect that come from me.

    Good luck!

    I'll keep you all updated, id also like to know if Seth would be too terribly upset if I released my modded version of the engine way down the road once my MMO is released.
    Certainly fine with me! Assuming you get that far...
    Seth A. Robinson
    Robinson Technologies

  12. #12

    Thumbs up raknet support...

    great to see you and seth working together on this. of course it hurt my head just to read the 'advice' seth gave you.

    now i'll finally be able to make that 'caveman checkers' online game i've always wanted to.

    just joking...although
    harriozspot... it ain't much, but it's mine.

  13. #13

    Default

    Since Novashell is based on Clanlib wouldn't it make sense to try to use it's networking code?

  14. #14

    Default

    RakNet is an AMAZING UDP networking library, its commercially backed and very easy to use. I wouldn't ever want to use anything else.

    I'm going to read Seth's response now, was way too tired last night haha.

  15. #15

    Default

    One of the problems with using RakNet as NovaShell's networking lib of choice is that it has a closed-source license. If you wanted to sell your network-enabled NovaShell game, you'd have to buy a proper license from RakNet. If you wanted to sell your non-network-enabled game and not want to pay for a RakNet license, there would have to be some way of not including RakNet in your product.

    Thankfully, it is licensed as CC non-commercial, so for non-commercial products you could use it however you wanted. Having it as a third-party plugin of some sort would be nice.

  16. #16

    Default

    The commercial license for RakNet is only $99, which isn't bad, but they allow for bargaining or a pay as you go plan.

    But performance wise, RakNet is amazing.

  17. #17

    Default

    Ok, I finally ran into some trouble

    I tried adding in the bind for the NetworkManager. Here are the files I created and filled up as you showed.

    NetworkManager.h
    NetworkManger.cpp
    NetworkManagerBindings.h
    NetworkManagerBindings.cpp

    I tried adding OpenNetwork( PORT, IP ) and CloseNetwork(). It compiled fine with no errors, but when I went to go run the application, I got an assertion error. After finding where, this is what it said in the source:

    Code:
    // if you get caught in this assert you are
    // trying to use an unregistered type
    assert(crep && "you are trying to use an unregistered type");
    If you need to see any source I have written so far, let me know which file cause there is a lot.

    For those who are wondering about the two commands I have added, OpenNetwork will allow your game to connect to the server on the selected IP and PORT. Would be useful to call on startup. CloseNetwork will send a disconnect to the server to let it know we are logging off, would be useful to call after the database update on exit.

    I know its not much, but its slow and stead Client/Server communications using LUA scripting for NovaShell.

  18. #18
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    I tried adding OpenNetwork( PORT, IP ) and CloseNetwork(). It compiled fine with no errors, but when I went to go run the application, I got an assertion error.
    Are PORT or IP custom structures/classes? If so, you would have to also define those in luabind before you can use them.
    Seth A. Robinson
    Robinson Technologies

  19. #19

    Default

    Well here is the function for the connect (some of it)

    NetworkManager.cpp
    Code:
    void NetworkManager::OpenNetwork ( int PORT, const char *IPADDRESS )
    {
    	LogMsg( "Initializing Server Connection..." );
    
    	unsigned char GetPacketIdentifier(Packet *packet);
    	unsigned char packetIdentifier;
    
    	SocketDescriptor s2 ( CLIENTPORT, 0 );
    
    	rakPeer2->Startup ( 500, 0, &s2, 1 );
    	rakPeer2->Connect ( IPADDRESS, PORT, 0, 0, 0 );
    	rakPeer2->SetOccasionalPing(true);
    
    	Packet* packet = rakPeer2->Receive();
    
    	packetIdentifier = GetPacketIdentifier( packet );
    
    	switch ( packetIdentifier )
    	{
    		case ID_CONNECTION_ATTEMPT_FAILED:
    			LogError( "Connection Attempt Failed!" );
    			exit ( 1 );
    		break;
    
    		case ID_CONNECTION_REQUEST_ACCEPTED:
    			LogMsg( "Connection Request Accepted! " );
    		break;
    	}
    
    	rakPeer2->DeallocatePacket(packet);
    }

    and...

    NetworkManagerBindings.cpp
    Code:
    #include "AppPrecomp.h"
    #include "NetworkManagerBindings.h"
    #include "NetworkManager.h"
    
    #ifndef WIN32
    //windows already has this in the precompiled header for speed, I couldn't get that to work on mac..
    #include <luabind/luabind.hpp>
    #include <luabind/operator.hpp>
    #endif
    
    using namespace luabind;
    
    void luabindNetwork(lua_State *pState)
    {
    	module(pState)
    	[
    		class_<NetworkManager>("NetworkManager")
    
    		.def("OpenNetwork", &NetworkManager::OpenNetwork)
    		.def("CloseNetwork", &NetworkManager::CloseNetwork)
    	];
    }
    As you can see, Port and IP are just variables used in there.

  20. #20

    Default

    Ok nevermind, I got it fixed and the command works like a charm in LUA!!!

    The problem was, I didn't call
    Code:
    luabindNetwork(pLuaState);
    Looks like im well on my way!

Similar Threads

  1. Gmail support?
    By redink1 in forum Other RTsoft Games
    Replies: 5
    Last Post: 06-16-2012, 08:00 PM
  2. Raknet for Multiplayer
    By Amando in forum Novashell Game Creation System
    Replies: 2
    Last Post: 08-12-2008, 06:32 AM
  3. unicode support!
    By liver2006 in forum Novashell Game Creation System
    Replies: 3
    Last Post: 02-25-2007, 09:59 AM
  4. Support
    By in forum Dink Smallwood HD
    Replies: 0
    Last Post: 07-08-2004, 05:37 AM
  5. Variable support
    By in forum Other RTsoft Games
    Replies: 2
    Last Post: 10-19-2002, 11:50 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •