Jump to content
  • Advertisement
Sign in to follow this  
SineNomine

Hypothetical Problem

This topic is 1972 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so I have this purely hypothetical problem and I would like some professional opinions on it.

Basically I, oh - of course I mean a friend of mine. Is part of group of independent developers who are working on a new game, it has been recently released and now they are wanting to make it multiplayer. This involves a great many changes, as majority of the program was not built with multiplayer in mind. The current medium is C++, with much in script files.

The current plan is to start the server section in C# on reasoning of "It's really simple actually, rapid development while not sacrificing any speed/power".

Now my friend thinks this is a terrible idea, simply because a lot of the code the server and client uses will be the same, or similar variations. Which means we will have some mixture of cross language interfaces, code rewriting and code duplication all of which should be avoided where not necessary.

I have no issue C# as a language, if we were starting again its perfectly valid choice, but the fact is we have a lot already done, a majority of which only needs adapting not completely rewritten.

So I come to gamedev to hopefully get some professional objective opinions.

Thanks,

P.s. I put this in "General programming", as it although pertains to a game, the problem is not specific to games. Feel free to move it.


Edit: I must make clear that I know it could work, i don't dispute its perfectly possible, - its more why do that why?
I think there is obvious hindrance and no actual benefit. Edited by SineNomine

Share this post


Link to post
Share on other sites
Advertisement

Not sure what you are asking about for "the server section".

 

If you are talking about a client/server architecture and the other executable being in a different language....

 

The client and the server are generally completely different code bases.  They may share some enumeration values and other constants, but the logic behind them is usually very different.

 

All that really matters is that the network protocol between the two is the same.  

 

A properly developed networked game will have a very clearly defined communications protocol.  If you are following best practices it should not be an issue.

 

 

 

 

If you are talking about each individual game being able to host a game, and that in-game code being written in a different language...

 

Mixing languages inside code is not a difficult thing.  Most major games incorporate compiled code from multiple languages.

 

It is very straightforward to mix C++ and C#, especially on the PC.  It is a little harder on consoles, but I've known many shipped titles that use Mono to ship with compiled C#.

Edited by frob

Share this post


Link to post
Share on other sites

I was more referring to how all the various different types of objects in the game are stored and connected to each other.  It is true that server, client and standalone will have different views of these objects, but they'll have great similarities.  For which i think using same code would be best.
Maybe I am exaggerating the complexity of mixing C++, C# but you surely can't say that it would be simpler without such?

- Most importantly, thank you for response.

Edited by SineNomine

Share this post


Link to post
Share on other sites

It is true that server, client and standalone will have different views of these objects, but they'll have great similarities.  For which i think using same code would be best

Whether or not you use the same language for each, you still have to convert every object to a language-agnostic format to actually send over the network (and if you use something like protocol buffers, you won't even have to write different serialisation code for each language).

 

Once you've digested that concept, the client and server should really never be performing the same operations on their data. I think you'll quickly find that the similarities are only surface deep - even if you build it all in one language, the server-side will need completely different classes to the client (even to represent the same objects).

Share this post


Link to post
Share on other sites
How objects are viewed when talking between the client and server depends on your serialization tools, not on the programming language.

Share this post


Link to post
Share on other sites

I hear and understand what you guys are saying, I know server and client have different views of an object.  But there will be similarities, if I was using the same language for both then the common variables and functions would be in a class that the specializations derive from.

 

I may  be over apprehensive over having little bits of code here and there written in different languages.  But it does seem very messy to me, especially if it can be easily avoided?

Share this post


Link to post
Share on other sites

I have found that if a game is not written to be a multiplayer game from the very beginning, it is an incredible pain in the ass to adapt it to be.

 

yes, your server/clients well share alot of code base, generally what i do is write a base game as a library, which has very defined methods of outside interactions(generally by feeding it an "Event"(rather that be a network object update event, or simply an user input event, it's easier to control how the engine behave's if you have a single point of entry to modifying your world from outside interactions(i.e input/network code)."

 

so basically, when i write the server code, i simply listen to incoming events from clients, verify the event as a legal event, mark the engine tick it was received, and distribute the event to the other clients.  note that this does not involve modifying how the world behaves, it's just another method of interface.

 

this system has worked very nicely when working with different pieces of the same game(such as building a level editor, server, or client(rather that be singleplayer or multiplayer)).

Share this post


Link to post
Share on other sites
You haven't answered the most important question.

What is your model? Is the "server" just a host who is also playing the game, or a standalone entity?

Share this post


Link to post
Share on other sites

Both - standalone server but client that can host, however I think the current plan is too have client simply start up a local standalone server and interface with that even in single player.  Which also strikes me as bad idea, we already have performance problems.

Share this post


Link to post
Share on other sites
That's a very ambitious undertaking, no matter how you slice it.

Retrofitting an existing SP game with this functionality will be an unmitigated nightmare.


How badly do you want to do this? Because you're going to have to pay for it dearly, in terms of time and implementation effort.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!