Jump to content

  • Log In with Google      Sign In   
  • Create Account

Hypothetical Problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 SineNomine   Members   -  Reputation: 104

Like
0Likes
Like

Posted 22 February 2013 - 11:58 AM

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, 22 February 2013 - 01:02 PM.


Sponsor:

#2 frob   Moderators   -  Reputation: 21479

Like
2Likes
Like

Posted 22 February 2013 - 12:20 PM

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, 22 February 2013 - 12:24 PM.

Check out my personal indie blog at bryanwagstaff.com.

#3 SineNomine   Members   -  Reputation: 104

Like
0Likes
Like

Posted 22 February 2013 - 12:36 PM

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, 22 February 2013 - 12:36 PM.


#4 swiftcoder   Senior Moderators   -  Reputation: 10080

Like
0Likes
Like

Posted 22 February 2013 - 01:47 PM

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 - Software Engineer @Amazon - [swiftcoding]


#5 King Mir   Members   -  Reputation: 2002

Like
1Likes
Like

Posted 22 February 2013 - 01:58 PM

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

#6 SineNomine   Members   -  Reputation: 104

Like
0Likes
Like

Posted 22 February 2013 - 02:42 PM

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?



#7 slicer4ever   Crossbones+   -  Reputation: 3906

Like
0Likes
Like

Posted 22 February 2013 - 03:44 PM

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.

#8 ApochPiQ   Moderators   -  Reputation: 15832

Like
1Likes
Like

Posted 22 February 2013 - 03:50 PM

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?

#9 SineNomine   Members   -  Reputation: 104

Like
0Likes
Like

Posted 22 February 2013 - 04:35 PM

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.



#10 ApochPiQ   Moderators   -  Reputation: 15832

Like
2Likes
Like

Posted 22 February 2013 - 05:22 PM

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.

#11 SineNomine   Members   -  Reputation: 104

Like
0Likes
Like

Posted 22 February 2013 - 05:35 PM

Oh I know, I also know no matter how bad I can anticipate it will be, it will still be worse. sad.png

Some parts have been built with eventual multi-player in mind, basically strong boundaries between user interaction and the actual responses.  But still, i know nightmare ensues.
If it helps, assume we have an abundance of time.

What I am looking to do is reduce the nightmare as much I can. 



#12 swiftcoder   Senior Moderators   -  Reputation: 10080

Like
0Likes
Like

Posted 22 February 2013 - 08:15 PM

What I am looking to do is reduce the nightmare as much I can.

In that case, my $0.2 is that implementing servers in C++ is a bigger nightmare than you imagine ;)

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#13 King Mir   Members   -  Reputation: 2002

Like
0Likes
Like

Posted 22 February 2013 - 08:31 PM

Oh I know, I also know no matter how bad I can anticipate it will be, it will still be worse. sad.png

Some parts have been built with eventual multi-player in mind, basically strong boundaries between user interaction and the actual responses.  But still, i know nightmare ensues.
If it helps, assume we have an abundance of time.

What I am looking to do is reduce the nightmare as much I can.

Actually, this does point to a particular problem with switching languages for the back end: if you're going to be moving old code to server, then if would help if you don't have to translate it to a different language.

#14 abeylin   Members   -  Reputation: 237

Like
1Likes
Like

Posted 27 February 2013 - 07:40 AM

C# makes a lot of things simple.

I doubt you'd have a significant portion of code that is going to be shared if you do client and server in C++, so I would say rewriting few classes in order to use C# will overall speed up development time.

 

I'd vote against C# on basis of how you cannot control when GC happens, and how it ties your server to windows, but that's not the question you're asking.


http://www.mildspring.com - developing android games





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS