Hypothetical Problem

Started by
12 comments, last by abeylin 11 years, 1 month ago
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.
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#.

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.

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).

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

How objects are viewed when talking between the client and server depends on your serialization tools, not on the programming language.

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?

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)).

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
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?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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.

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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement