Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  What is the best for a MMORPG?  (Read 3124 times)
0 Members and 1 Guest are viewing this topic.
Offline antoinelechacal

Junior Member





« Posted 2006-03-16 21:42:13 »

Do you think synchonous or asynchonous network is the best for a MMORPG?

Can you develop your opinion, give the pros and cons of both methods...

My name is nobody
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2006-03-16 23:11:17 »

Generally you don't want blocking when having many connections. That would mean a lot of threads, which in this case is a waste of performance.







P.S. what is a MMORG anyway?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2006-03-16 23:37:58 »

Client can afford to block.

Server cannot.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline antoinelechacal

Junior Member





« Reply #3 - Posted 2006-03-17 07:25:58 »

So you guys think it's better using asynchonous network?

Quote
P.S. what is a MMORG anyway?
MMORPG stands for Massive Multiplayer Online Role Playing Game.
This means many clients, many messages etc.

Let's say I have a game loop (60fps) on every client, how can I keep all the clients synchonized (so that all the clients see the same thing), avoiding lags?

Thanks.
See ya

My name is nobody
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2006-03-17 08:14:52 »

Quote
P.S. what is a MMORG anyway?
MMORPG stands for...

MMORG = massive multiplayer online role game ?

You misspelled it in your title, i was just giving a subtle hint Wink

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline antoinelechacal

Junior Member





« Reply #5 - Posted 2006-03-17 11:15:54 »

Sorry, I took me 2 posts to realize... lol

No idea of how to handle clients synchronizing?

My name is nobody
Offline Kova

Senior Member





« Reply #6 - Posted 2006-03-17 12:19:53 »

I'm far away from network programmer, but my first thought is client sending their data to server who sends everyone's data to clients, who then process it Smiley Of course there would be a small lag from time spent to send the data. Idea couldn't be more simple, but it's up to ppl how to implement it.
Offline antoinelechacal

Junior Member





« Reply #7 - Posted 2006-03-17 15:28:12 »

Yeah basicaly this is what I have to do, but what I don't know is how to synchonize two clients.

Indeed, both clients won't run at the same speed, do I have to make all the clients run at the same speed as the slowest client?
Or do I have to let each client run at its own speed and from to time teleport people?

My name is nobody
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2006-03-17 15:35:47 »

Every client should have a predictable ticker, independant of the framerate (say: 50Hz) in which the game-logic takes place.

Then all clients run at exactly the same speed.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline antoinelechacal

Junior Member





« Reply #9 - Posted 2006-03-17 15:48:13 »

What do you call a ticker?

Thanks?

My name is nobody
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2006-03-17 18:32:39 »

A thread that sleeps precisely enough milliseconds to wake up at a fixed interval.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
long nextTick = ...;
long tickInterval = 20; // 20ms = 50Hz

while(true)
{
    long now = ...;
    long timeToNextTick = nextTick - now;
   
    if(timeToNextTick > 0)
          sleep(timeToNextTick);

    nextTick += tickInterval;

    runLogic();
}

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline antoinelechacal

Junior Member





« Reply #11 - Posted 2006-03-17 18:42:47 »

New stupid question, what do you call "the game-logic"?

My name is nobody
Offline Kova

Senior Member





« Reply #12 - Posted 2006-03-17 23:05:13 »

it's how game works, in this case from programmer's point of view, like:
first I draw something
then I update something
then I wait for user to click with mouse
then I sleep...
and so on... of course in precise form, this is extreamly simplified
Offline DzzD
« Reply #13 - Posted 2006-03-18 00:26:34 »

you may use a common timer to synchronize client and server:

- first found offset time between client and server : do many ping requesting server time and keep difference between client time and server time + average ping time * 0.5 (periodically update this offset)

- use your local client timer and add offset you found by ping to know server time, this way all client will use the same time (the server one)

- use interpolator for shared values  (as player pos) to  know aproximatively value at time t or to predict values, this is necessary because value keys can be late or too much spaced in time for low bandwith.

- use previous time based values (interpolated/extrapolated): for player pos and collision detection

- alternatively correct values when new keys arrive (and perform a server validation for movement and other to avoid cheating)

- this way each client is able to use a different framerate and bandwith.


ex prog:
 //Compute server offset time
 //need to be perform multiple time and averaged, also need to be updated periodically
 localTime=System.currentTimeMillis();
 serverTime=networkServerTimeRequest();
 pingTime=localTime-System.currentTimeMillis();
 serverOffsetTime=serverTime-localTime-pingTime*0.5;


 //Read all shared values key from server, ex all player pos
 while(serverPacketPlayer())
 {
  player=getServerPacketPos()
  addTimeBasedPlayerPosKey(player.name,player.time,player.pos);
 }


 //Rendering a frame

//For each player do
 playerPos=getTimeBasedPlayerPosAt(localTime+serverOffsetTime)
 drawPlayerAtLocation(playerPos)


 //Computing colision, logic

//For each player do
 moveWithCollison(lastRealPlayerPos,playerPos) //lastRealPlayerPos mean last received server keys before current time


 
 



Offline CommanderKeith
« Reply #14 - Posted 2006-03-18 02:49:33 »

Hi,
Unless you've got a turn based game i think that its best to run the clients asynchronously or the graphics will be choppy.  Using a time-based approach has worked best for me.  The gameWorld on the client has a time stamp of when it was last updated, and the gameWorld sent from the server does too.  Use System.nanoTime() instead of System.currentTImeMillis() since the the latter is very imprecise on windows and makes the game look choppy.

This is how my client's game loop works:

int newGameWorldRelativeNanos = 0;
long nanoTimeLastUpdated = System.nanoTime();

while(shouldRun){
   long currentTime = System.nanoTime();
   long timeSinceLastUpdate = (currentTime - nanoTimeLastUpdated);
   cumulativeNanosBetweenUpdates += timeSinceLastUpdate;

   long timeElapsedNanos = timeSinceLastUpdate - newGameWorldRelativeNanos;
   // store the Player's events
   if (!(timeElapsedNanos < 0)){
      gameWorld.update(timeElapsedNanos);
   }
   else{
      //  don't update the gameworld using a negative time, just replace it.
      java.awt.Toolkit.getDefaultToolkit().beep();
   }

   newGameWorldRelativeNanos = 0;
   nanoTimeLastUpdated = currentTime;
   view.reDisplay();
   doMinSleep();

   // update to the ServingController's new GameWorld if has been sent exists.
   networkPlayer.doClientAgentRecieve();   // this method calls setGameWorld(...) below if a new gameWorld was sent.
}

public void setGameWorld(GameWorld gameWorld, long oldGameWorldTotalNanosElapsed){
   newGameWorldRelativeNanos = (long)(gameWorld.getTotalNanosElapsed() - oldGameWorldTotalNanosElapsed);
   this.gameWorld = gameWorld;
}

Keith

Offline CommanderKeith
« Reply #15 - Posted 2006-03-18 02:51:55 »

Using this way you don't have to worry about pings and the only thing that can screw you up are the garbage collector pauses.

Offline antoinelechacal

Junior Member





« Reply #16 - Posted 2006-03-18 11:19:13 »

Thank you guys, I will consider your solutions, thanks for being that helpful!


My name is nobody
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (27 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!