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

Author Topic: The Beginning of an MMO  (Read 4298 times)

0 Members and 1 Guest are viewing this topic.

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
The Beginning of an MMO
« on: January 17, 2015, 08:08:21 am »
I have heard many questions in the past about this. I have been looking into this for over a year now and have a game i am trying to adapt to an mmo. I rebuilt the foundation of it and mannaged to get the server to add the cilents ip to a list as well as its username and player info refering to a number given to it. I now have a prosgram that has it connected and listed on both ends. Now I have the server sending map data to the scilent in between upperleftx and upperlefty to lowerright x and y . It is based off of view width and viewheight . How should I aproach sending data between upperleftx and y and lowerightx and y in a square. How would the server receive properly. Thank you. Edit:: even a link to a tutorial might help.
« Last Edit: January 17, 2015, 08:16:22 am by lordseanington »

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
Re: The Beginning of an MMO
« Reply #1 on: January 17, 2015, 08:27:17 am »
A tutorial would also be verry helpfull but not neccassary.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: The Beginning of an MMO
« Reply #2 on: January 17, 2015, 11:10:06 am »
The standard packet tutorial should be more than enough: http://www.sfml-dev.org/tutorials/2.2/network-packet.php

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10394
    • View Profile
    • development blog
    • Email
Re: The Beginning of an MMO
« Reply #3 on: January 17, 2015, 04:32:03 pm »
Even if you have researched your things, I still want to place this "So You Want To: Write A Minor MMO" link here.
Also if you can't figure out the most basic networking/serialization part, you're in for a very rough journey. ;)

Besides the question not being related to SFML and you probably getting more/better help at dedicated gamedev communities, I'll still add some basic layout that you probably want to follow for a multiplayer game:

To prevent client side manipulation/hacking, all the physics and action should happen on the server side. All the client essentially sends to the server is the user input. Then the server validates these inputs and simulates the new position/action/etc. and sends that information back to the client. In the meantime the client simulates the physics as well and for example moves your character forward, but if the position from the server doesn't match the position of the client, the client will reset to the information of the server. That way you can't just move your character to position X and the server will accept it as a valid movement/position.

This is the simple client/server setup. From there you'll have to expand to multiple clients, meaning that all the position and effects of the players, NPCs, etc. need to be send to every client and every client's input has to be taken into account in the physics simulation.

That's the basic layout of a "modern" MMO and thus I really suggest to you, to start with some basic single player games first, then maybe move to a multiplayer and only after a lot of experience pick something like minor MMO. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
Re: The Beginning of an MMO
« Reply #4 on: January 17, 2015, 08:12:35 pm »
Thank You All,
I have created many singleplayer games, I have been obsessing over getting better. I truthfully believe im ready. I am ready for making an MMO. About posting on the sfml forums, I am sorry, I thought someone might post SFML based code.

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
Re: The Beginning of an MMO
« Reply #5 on: January 18, 2015, 02:00:49 am »
I previously understood that. It working properly currently. The main problem I am having is having the server sending map information to the client. I have a problem. I dont know how I should package the data and howw it should be received on the cilent side. The size of the map varies from server to server. The size of screen the player can be seen is dependent on VIEW_WIDTH and VIEW_HEIGHT. It is equal on both server and cilent. How should I proceed. Should I package it all in a single packet. If so, how would I package it.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: The Beginning of an MMO
« Reply #6 on: January 18, 2015, 02:33:19 am »
The general problem you're referring to is called "serialization".  It's not specific to SFML, and in most cases there's no right or wrong answer and you can simply do whatever you want provided you understand what types of data can and cannot be serialized directly.  I would simply google that term for a while and read what comes up until you're comfortable with the idea.

sf::Packet doesn't impose any particular restrictions, however it doesn't directly support any containers or variable-sized types, so if you have any of those you'll have to choose a serialization format for them.  For example, you can insert the size of the container and then the elements.

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
Re: The Beginning of an MMO
« Reply #7 on: January 18, 2015, 05:37:01 am »
I have fixed some of the problem. I have managed to come up with a version that does work in that respect. There are a few more problems i have. The main one. The server receives connection data from the client and the server adds it to a list. It sends a confirmation to the cilent. It then waits for a request. Now, the problem I'm having,. When the client sends a request for map data, thesserver never receives it. Why would this not work, or should I just have the server send data automatically to the client without it requesting map data?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: The Beginning of an MMO
« Reply #8 on: January 18, 2015, 11:26:32 am »
That's the sort of problem where we'll have to see a complete and minimal code example in order to figure out what's wrong.

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
Re: The Beginning of an MMO
« Reply #9 on: January 19, 2015, 03:32:59 am »
I have a main question. Should the server send information to the client without a request from the cilent. By the way, here is my code in the attachements. Sorry, at the moment they are fairly small and this is the barebones basics. Please help. Also, please report any other problems. Using sfml 2.1. This is truthfully what i think should be included.

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: The Beginning of an MMO
« Reply #10 on: January 19, 2015, 07:36:04 am »
It depends what the data is. For player's leaving and joining, that data should be sent to all players regardless of their positions in the map and so on (If you have messages being send on those events). Data about a player should only be sent to players who can see that player (You will need some sort of PVS for this).

lordseanington

  • Jr. Member
  • **
  • Posts: 86
  • Coffee is the blood of a coder.
    • View Profile
Re: The Beginning of an MMO
« Reply #11 on: January 19, 2015, 08:34:53 am »
What i am mainly asking is when sending map data to a player should the client make a request to the server and the server sends the map data or the server sends it without request. Also, please someone look over the code, i can pinpoint the problem.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10394
    • View Profile
    • development blog
    • Email
Re: The Beginning of an MMO
« Reply #12 on: January 19, 2015, 09:26:11 am »
This is still unrelated to SFML, you'd really be better off with a dedicated gamedev community...

If you go back to my previous post, you'll already see how I'd set things up. That way you'd first make sure both ends know of each other and then you simply start to send data (usually via UDP) between server and client. The client just sends its actions and positions to the server, while the server does all the simulation and sends back all the relevant information. You don't request any information explicitly, because the client essentially doesn't know what there is to request, like it wouldn't know if there are now 5 people next to you, only the server knows that.

Anyways, I seriously suggest you get some good material from somewhere on networking and multiplayer games writing. It's not a trivial task and will take forever to get something useful with trial-and-error, if you at all get something...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://dev.my-gate.net/

Pablo

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: The Beginning of an MMO
« Reply #13 on: January 28, 2015, 01:02:15 am »
Valve wrote some very good documents explaining how they handle networking in their engine. Have a look at them. They're quite interesting:

https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization


Gan

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: The Beginning of an MMO
« Reply #14 on: January 28, 2015, 08:12:35 am »
You can have a Client-Ready response that the server will reply with map data to. When I made an online platformer game, I wrote out all my server and client packets in a text file to keep the organized and outlined the relationship between packets.

Client sending Login Data packet, server replies with Login State packet, if logged in the server send a Character Data packet, then server proceeds to send all the necessary info for the client to display the game. Map data and such. All players in the vicinity.

Online game networking is a lot of fun. I'm actually making an online space game in SFML.

 

anything