Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to setup a game server in the best way?  (Read 5301 times)

0 Members and 1 Guest are viewing this topic.

Argha

  • Newbie
  • *
  • Posts: 11
    • View Profile
How to setup a game server in the best way?
« on: August 11, 2015, 07:13:57 pm »
See Subject.
Do you run a vserver where udp packages are send to and unlocked equipment is saved into a database which will be loaded in the appropriate moment?

Server with NodeJS or also a version with SFML handling the udp packages?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: How to setup a game server in the best way?
« Reply #1 on: August 11, 2015, 08:07:58 pm »
You are asking a very general question that has thousands of potential answers.
If you want sensible replies you'll need to be much more specific about what you want to achieve and why.

I can recommend reading this: http://www.catb.org/esr/faqs/smart-questions.html
« Last Edit: August 11, 2015, 08:17:28 pm by Jesper Juhl »

Argha

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: How to setup a game server in the best way?
« Reply #2 on: August 11, 2015, 09:20:46 pm »
I would appreciate if someone has books, documentations or something with a solid approche/idea.

I just can't see so far how I shall be able to have the position of every object (e.g. player) saved in a world.

Say player A logs of at X: 07 Y: 132. Time goes, he logs in again and has to be spawned at said coordinates. Meaning it has to be saved somewhere. A database? Wouldn't that take ages for every object?


Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: How to setup a game server in the best way?
« Reply #3 on: August 11, 2015, 11:07:48 pm »
I'm assuming you are imaging a server for a mmorpg type game. In that case, yes, a database would be an option for storing player locations.

Quote
Wouldn't that take ages for every object?
What type of objects are you imagining? If both your game client and server know about the game world then static objects that don't move, such as walls, tables, rocks, etc., can always be known by the clients. The server doesn't need to tell the client where those objects are because they don't ever move. The server only needs to synchronize the clients for objects that do move. For example, if a user presses the up button in order to move the player, then the client can tell the server that it just moved up, and then the server can broadcast to all of the other clients that you just pressed up.

Anyway, as Jesper Juhl mentioned, this is a very large topic that is kind of out of the scope of these forums. These forums are for SFML related questions, not just game development in general. You might not get many good responses on this topic here.
« Last Edit: August 11, 2015, 11:09:31 pm by Arcade »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: How to setup a game server in the best way?
« Reply #4 on: August 11, 2015, 11:34:23 pm »
Seriously. If you are just starting out then DON'T try to build a MMOOOOOOooooo however many Moooos. You'll Fail. They take teams of 10-50+ programmers and graphics artists multiple years to build. Don't go there, you'll just be disappointed.

If you are just trying to create a simple game server for a 2-3 person game; then go to gamedev.net - they have lots of resources on how to do that sort of thing.

How to store stuff in a database (or not) or use UDP vs TCP or how to enable multiple players or whatnot - really is not any of SFML's concern. That's something you should learn elsewhere.

And seriously; from reading your posts so far - I think you should start by doing a tetris, pacman, pong or space invaders game and learn the trade that way rather than going straight for MMORPG (or whatever). Do some simple games first. Build some experience. Then maybe in 10 years or so build that MMO you want.
« Last Edit: August 11, 2015, 11:39:35 pm by Jesper Juhl »

Argha

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: How to setup a game server in the best way?
« Reply #5 on: August 11, 2015, 11:58:38 pm »
Trust me, I don't even want an MMO :D
My pong game works just fine with UDP between to clients, but I try to get my mind on a server<->clients system. The pong game syncs positions as long as both are connected, but does not save the position where they left in any kind of persisten way. That's what I wanted to know how to do. I always think of databases being slow.

Of course you can write it when they click leave, but they could also disconnect etc


Do you have any resources for that? Like having 3 people connected to a server which saves where they logged of, how much points they had etc?

I mean even if you save the color of the pong player, that would be need to be loaded from the DB, written there anytime he changes it, broadcast to any player when he changes it, ...
« Last Edit: August 12, 2015, 12:01:13 am by Argha »

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: How to setup a game server in the best way?
« Reply #6 on: August 12, 2015, 12:41:28 am »
The pong game syncs positions as long as both are connected, but does not save the position where they left in any kind of persisten way. That's what I wanted to know how to do. I always think of databases being slow.

Of course you can write it when they click leave, but they could also disconnect etc
Have you ever been in an online game, get disconnected, reconnect, and your player is back where they were some time ago, and not when you disconnected? Most servers only sync with clients every so often, not constantly, partly for the reasons you mentioned.

Argha

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: How to setup a game server in the best way?
« Reply #7 on: August 12, 2015, 12:45:18 am »
Makes sense, but just in general: Do they save the position into a database or is there something else they use?

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: How to setup a game server in the best way?
« Reply #8 on: August 12, 2015, 12:51:47 am »
Again, it is hard to say exactly what you would do without all of the requirements of the game. Each game will likely have different requirements for its server. Some may require a database, some may not. As Jesper Juhl pointed out, gamedev.net is a good place to start getting ideas.

Maybe this will satisfy your curiosity a bit, though. When you are talking about a server/client architecture, all of the changing data will be going through the server so that it can send it to the other clients. When a client sends the data to the server, the server can easily hold on to it. The server will be an application you write, so you can do anything you want in it. One idea would be to save the information in some sort of struct...

struct remotePlayer
{
   Vector2f playerPosition
   Color playerColor
   int playerPoints
   ...
};
 
and then to hold the data for all players, you could have a vector of such structs
std::vector<remotePlayer> myClients;
 
When a player needs to change in some way, such as move, it would also send the position info to the server and the server would update the corresponding location in the vector. If a player disconnects, there is nothing that would cause the server to spontaneously lose information from its vector right? There is no need for a database or anything like that in this simple example. When a player reconnects, the server can somehow re-associate that player with a location in the vector and send the client all of its information.

This is of course a contrived example just meant to show how a server could work for your example of having 3 people connected and being able to save positions.

Argha

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: How to setup a game server in the best way?
« Reply #9 on: August 12, 2015, 01:39:47 pm »
Alright, I will still save it in a DB here and there in case the application crashes or something. I will make more researches and also keep your example in mind, thanks for that :)

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: How to setup a game server in the best way?
« Reply #10 on: August 15, 2015, 09:01:15 pm »
Seriously. If you are just starting out then DON'T try to build a MMOOOOOOooooo however many Moooos. You'll Fail. They take teams of 10-50+ programmers and graphics artists multiple years to build. Don't go there, you'll just be disappointed.
Well you're talking about building World of Warcraft, but an MMO wouldn't have to be that advanced.

Imagine a game with simple mechanics: you can fight other players, basic item crafting system, top-down 2d graphics, 2-3 different playable classes, and so on. It's totally plausible that, with a clear vision, one expert programmer and a pixel artist could create such a game in one year and have a very playable beta done.

Yes it's not feasible for a newbie to go into MMO right away, but saying that it takes 50 programmers to create an "MMO" period is just not true.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: How to setup a game server in the best way?
« Reply #11 on: August 15, 2015, 10:05:12 pm »
Yes it's not feasible for a newbie to go into MMO right away, but saying that it takes 50 programmers to create an "MMO" period is just not true.
Then you don't disagree and your post wasn't necessary, because Jesper Juhl said "If you are just starting out...".
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: How to setup a game server in the best way?
« Reply #12 on: August 16, 2015, 12:10:29 am »
Then you don't disagree and your post wasn't necessary, because Jesper Juhl said "If you are just starting out...".
False. He said "They take teams of 10-50+ programmers and graphics artists multiple years to build." Which has nothing to do with "just starting out". I disagreed with the 10-50 programmers and multiple years bit, not the just starting out bit.

 

anything