• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Implementation of persistent world

Initiate Mage
Joined
Feb 3, 2011
Messages
4
Reaction score
0
I know one can probably write a book on this topic, but how it usually implemented in server emulators? For example, player movement, how to make it synchronous? What happen when player (X) clicks somewhere on another side of the map, game just sends destination coordinates, so while game walks to destination how does server informs players in appropriate range that X is moving from A to B? I know if it's straight line, its easy to find position of a player given we know the speed. But usually there are rocks/rivers and other objects that can not be walked on so game will move player around them. How this problem is usually solved?

PS: Is there any good articles by developers or books on persistent worlds in general?
 
Initiate Mage
Joined
Feb 3, 2011
Messages
4
Reaction score
0
You giving me end result. But before update packet can be sent, how do we know where player is?
Send movement packets to whole region from the start? I mean it's a given if range is small, then any action player takes will be reported to those near him. But what if player started moving when he/she was out of range and on a complex terrain?
 
Joined
Mar 11, 2007
Messages
904
Reaction score
1,254
You giving me end result. But before update packet can be sent, how do we know where player is?
Send movement packets to whole region from the start? I mean it's a given if range is small, then any action player takes will be reported to those near him. But what if player started moving when he/she was out of range and on a complex terrain?

then we don't tell the clients that are far away from them about us, we only "update" those in our close proximity. And about knowing where we are, the server saves that, if we know where we are on creation, we can follow throughout the entities life.
 
Goodbye
Loyal Member
Joined
Oct 6, 2009
Messages
965
Reaction score
134
Concerning rocks & rivers you can find tutorials online about "Pathfinding algorithms"
 
Master Summoner
Joined
Jan 11, 2009
Messages
505
Reaction score
8
set initiative variables; max players, ip, port, etc.
open ports
listen to ports
accept connections
accommodate clients
store variables
maintain loop of updates including coordinates
accommodate events such as players quitting, this would be included to the maintained loop too.

while the maintained loop continues to cycle, the protocol has to accept incoming connections too. so, that should look like this:

while(1)
{
acceptCon()
playerID = checkSlotClearAndAssignID();
while(1)
{
msgNetwork = receiveCommand()

switch(msgNetwork)
{
case 1: updateCoor();
case 2: playerExit();
}

//priorities commands to server side variables such as monster coordinates
to compensate universally rather than vice versa
serverUpdate(sendPackets);
}
}

---------- Post added at 04:47 AM ---------- Previous post was at 04:35 AM ----------

i found a flaw

the msgNetwork should be executed before while

so, instead:


playerID = checkSlotClearAndAssignID();

msgNetwork = receiveCommand()

//no packets recieve, not to execute the loop

if(msgNetwork > 0)
{

while(1)
{

switch(msgNetwork)

...

}
 
(oO (||||) (||||) Oo)
Loyal Member
Joined
Aug 6, 2009
Messages
2,132
Reaction score
429
I am not a pro in this (yet :p) but I can think of creating a list of players, list of npc, list of maps. Then when server receives data from client/player you can check if the received move location is more than allowed from current position. If it's all good, you just send a data back to client and all clients that are near player or on same map using for loop for players list.

Hope it makes sense. But I don't think it's very stable/reliable
 
Newbie Spellweaver
Joined
Jul 3, 2009
Messages
46
Reaction score
39
I know one can probably write a book on this topic, but how it usually implemented in server emulators? For example, player movement, how to make it synchronous? What happen when player (X) clicks somewhere on another side of the map, game just sends destination coordinates, so while game walks to destination how does server informs players in appropriate range that X is moving from A to B? I know if it's straight line, its easy to find position of a player given we know the speed. But usually there are rocks/rivers and other objects that can not be walked on so game will move player around them. How this problem is usually solved?

PS: Is there any good articles by developers or books on persistent worlds in general?

The client sends packet with the cord X/Y of the position the player is going to move. The cord X/Y position is taken from a path file that already have all the possible X/Y values including other info of the map (Width, Height). If you click on certain area of the map, the coordinates are taken from the path file (that was already mapped).

So this is a fast approach to take. Path files are small and not hard to make, you just need a tool for that read your map models and ignore certain areas like rocks/rivers/etc (non wakeable objects, wich are usually marked with RED color).

You can make it faster by avoiding opening the path files, and just add in your initialized data section the path info of all maps (via pre compile, that way you avoid using CreateFile/ReadFile).

Take Care.
 
Last edited:
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
I would think, if you click a point on the map, before your player starts walkin there, the server can map out the path, send it back to the client and let the player move. At the same time, if a monster/ butterfly or something is moving on the map, the server already knows where your character is going to walk, and where the monster/butterfly is going to walk. If you come in contact with them, the server can draw a little animation of you swatting the butterfly, or send the monster on an attack. If you interrupt that walk-path by clicking on the monster to attack, the server exits the current path and leaves you where you are, (using where you left off in the middle of the path as the new "A" point) and starts over.

You need to constantly sync.

I don't make MMO's or anything, but I assume it's something like that.. correct me if I'm wrong
 
Last edited:
Back
Top