I have read all of the answers here about tracking player locations, but still have some questions. I don't seem to understand how to do this efficiently, and feel that the internet could greatly benefit from an effective solution that is easy to find.
Anyway, I am making a 2d mmo (the first multiplayer game I have made that will handle this many people) and can't seem to come up with a good way to manage the location of players, and alert other players when they are near them. My map is tile-based, and I want the clients connected to know when a player of another client is withen 200 blocks from the other client.
My map uses x and y coordinates, and each block is a value. I read something I was linked to by a similar question here, that explained that a good way of managing this sort of thing is to create a box around each player, and to alert both player's when their boxes overlap (assuming I understood it correctly).
But how should I create these boxes without wasting tons of computing power and resources? I thought of storing it in SQL database, but that would be too slow. I then realized that player locations would have to be stored in the RAM. So what are some previously used strategies to track player movement in the RAM? Should I store a variable for each player containing the coordinates withen 200 blocks from them, and constantly have the server checking to see if two players overlap? This doesn't seem very efficient, and I believe that I am going about this the wrong way.
Any help is greatly valued.