MMO : How to keep/handle the info about players connected?

Array? List? Something I don't know of yet?

Page 1 of 1

7 Replies - 1519 Views - Last Post: 25 September 2009 - 11:05 AM Rate Topic: -----

#1 StooZorNess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 17-April 09

MMO : How to keep/handle the info about players connected?

Posted 03 May 2009 - 01:38 AM

Hey, another question! xD

I have just read this thread : http://www.dreaminco...wtopic94539.htm and a question came to my mind.

How are the information about the players connected stored in memory? Things like people's coordinates, stats, items held, etc.

Is it an array of structs, a list, or a queue, or anything else that I don't know of?



Also, can anyone direct me toward something that explains how connections are usually managed in MMO games?



Thank you very much, again! Great community :3

This post has been edited by StooZorNess: 03 May 2009 - 02:21 PM


Is This A Good Question/Topic? 0
  • +

Replies To: MMO : How to keep/handle the info about players connected?

#2 WolfCoder   User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 828
  • View blog
  • Posts: 7,696
  • Joined: 05-May 05

Re: MMO : How to keep/handle the info about players connected?

Posted 03 May 2009 - 03:59 PM

I've been writing mine in JAVA, and I use an ArrayList of players. Each one starts a new thread that handles each individual gaming experience. Code located in objects allows for one user to interact with others. However, this will get complicated. You should design what you need yourself and draw it up, it's going to look different for every game.
Was This Post Helpful? 1
  • +
  • -

#3 StooZorNess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 17-April 09

Re: MMO : How to keep/handle the info about players connected?

Posted 03 May 2009 - 06:50 PM

lol it's exactly what I was going to do with pokemon fights. Each pokemon object would interact with other pokemon objects to deal damage to each other, etc.

I'm going to do the same thing for the players too.

I think that your idea of each player having their own thread is good.. I'm going to try to do the same thing.


Really what I needed was to know whether I should use an array, a list, or anything else.


Thanks :3
Was This Post Helpful? 0
  • +
  • -

#4 UG Cyber   User is offline

  • D.I.C Addict

Reputation: 36
  • View blog
  • Posts: 611
  • Joined: 24-July 08

Re: MMO : How to keep/handle the info about players connected?

Posted 04 May 2009 - 06:08 PM

What i would do (in C++, sorry if it doesn't make since with your language) is get the number of players, then declare an array of classes to hold the information. Kind of like this

class SomeClass
{
             //What ever code you want
};

int main(int argc, char * argv[])
{
          int NumberOfPlayers = GetPlayerCount();
          SomeClass PlayerInfo[NumberOfPlayers];
          //Other code
         return 0;
}



I did something like that to load textures in OpenGL
Hope this helps at all
Was This Post Helpful? 0
  • +
  • -

#5 StooZorNess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 17-April 09

Re: MMO : How to keep/handle the info about players connected?

Posted 24 September 2009 - 10:26 AM

Hm.. I don't know of other compilers but Visual Studio won't allow declaring an array with a variable and I know that doing so is illegal according to C++ standards.
Months after I thought of the problem again. I decided to use a circular list with a kind of "read all, send to all" technique where the map object would send all the data about the others player to each player one by one.

I hesitated between that and making the player objects "poll" every other player objects in the list using their own thread, but with the latency usually not being below 70-80, I think that it's useless to use more processor time since it won't be faster in the end anyway.

This post has been edited by StooZorNess: 24 September 2009 - 10:28 AM

Was This Post Helpful? 0
  • +
  • -

#6 Aeternalis   User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 291
  • Joined: 13-July 09

Re: MMO : How to keep/handle the info about players connected?

Posted 24 September 2009 - 12:21 PM

View PostStooZorNess, on 24 Sep, 2009 - 09:26 AM, said:

Hm.. I don't know of other compilers but Visual Studio won't allow declaring an array with a variable and I know that doing so is illegal according to C++ standards.
Months after I thought of the problem again. I decided to use a circular list with a kind of "read all, send to all" technique where the map object would send all the data about the others player to each player one by one.

I hesitated between that and making the player objects "poll" every other player objects in the list using their own thread, but with the latency usually not being below 70-80, I think that it's useless to use more processor time since it won't be faster in the end anyway.



A couple of questions I wanted to ask about what you said here. What information do you expect to be sending to the client about other clients? I mean.. there really isn't that much data that should be relayed to the client about other clients.

Are we talking about a 2D game? a 3D game? what you send will differ between the two. A 3d game will usually use a scenegraph to keep the worldstate, sending updates to the scenegraph periodically. This info is usually bitpacked to keep the data size small and can contain position, health, any heavily updateable values basically.

a 2d game can be simplified down to a very small data update packet. With special messages used to handle less often occurences.

You can also use Hash Tables to store the connection information. There is an example of this in the C# tutorial on the chat server, by Psychcoder. This is supposed to be a chat server, but can be modified to do just about anything for multiplayer games.

I use it to (among other things) allow players to see the available opponents on my server, select them from the list of players and challenge them, as part of the Game Lobby part of the game.


I hope I didnt ramble too much.
Looking forward to your replies,
Aet
Was This Post Helpful? 0
  • +
  • -

#7 StooZorNess   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 17-April 09

Re: MMO : How to keep/handle the info about players connected?

Posted 24 September 2009 - 01:48 PM

View PostAeternalis, on 24 Sep, 2009 - 11:21 AM, said:

A couple of questions I wanted to ask about what you said here. What information do you expect to be sending to the client about other clients? I mean.. there really isn't that much data that should be relayed to the client about other clients.

Are we talking about a 2D game? a 3D game? what you send will differ between the two. A 3d game will usually use a scenegraph to keep the worldstate, sending updates to the scenegraph periodically. This info is usually bitpacked to keep the data size small and can contain position, health, any heavily updateable values basically.

a 2d game can be simplified down to a very small data update packet. With special messages used to handle less often occurences.

You can also use Hash Tables to store the connection information. There is an example of this in the C# tutorial on the chat server, by Psychcoder. This is supposed to be a chat server, but can be modified to do just about anything for multiplayer games.

I use it to (among other things) allow players to see the available opponents on my server, select them from the list of players and challenge them, as part of the Game Lobby part of the game.


I hope I didnt ramble too much.
Looking forward to your replies,
Aet

We are talking about a 2D game. Aside from their coordinates, I will have to send info about their sprite.

As for the hash tables, I used google since I had never heard of that data structure before and unfortunately, it seems that C++ doesn't have anything like hash tables. The closest thing to it is called maps and it's not supported by C++ standards. Also, it seems that one must really know what they're doing with hash tables (especially when choosing a hash function) or else, performances could easily become worst than simply using a tree or another simpler data structure. Since I know nothing of hash tables, I think it would be safe not to take that risk for now, until I learn more on more complex data structures.

*Edit*
By the way I'm looking for a good book on data structures and algorithms, if you have anything to suggest. :3

This post has been edited by StooZorNess: 24 September 2009 - 02:24 PM

Was This Post Helpful? 0
  • +
  • -

#8 Aeternalis   User is offline

  • D.I.C Regular

Reputation: 28
  • View blog
  • Posts: 291
  • Joined: 13-July 09

Re: MMO : How to keep/handle the info about players connected?

Posted 25 September 2009 - 11:05 AM

how often do you expect the sprite information to change? If it is just so the client knows what to draw, this data can be sent once and then only position data needs to be updated. You would need to send the data of the sprite only when you first add the new sprite to the clients display, or when you first load the scene to the client. then it's just updating position.

adding and removing sprites can be done with messages that specifically handle that event.. and a recurring update packet would handle updating the position of the sprites in the sprite list.

C++ ...I would probably store objects in a vector, one player object class instance per connection.

I have 2 or 3 books on algorithms and data structures from my undergraduate work.. nothing I would recommend. Specific questions I can answer though...
Aet

This post has been edited by Aeternalis: 25 September 2009 - 11:09 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1