- Joined
- May 30, 2009
- Messages
- 190
- Reaction score
- 61
Dataserver would be a server to manage all operations related to database and communicate directly with gameserver.
Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!
Join Today!Makes sense to me. Well, I'll wait for someone to try this too. I'm too rusty for this. But its a nice codebase.
If the community worked together we might pull something off. But you know how it works, right? Whoever fix anything is not likely going to share. Which I hardly do NOT encourage.
Many pristons tick rates are not the same, so it is not possible to rely on sleep. Also, the sleep method is not accurate enough to provide that kind of mechanism as it does give its time slice (Threading).That srAutoPlayCount is really confusing. If it only executes each 63 additions to that variable, meaning each addition is 100ms, why didn't they just use sleep method or something?
Many pristons tick rates are not the same, so it is not possible to rely on sleep. Also, the sleep method is not accurate enough to provide that kind of mechanism as it does give its time slice (Threading).
Loop inside that array is only executed when srAutoPlayCount & 0x3F == 0 for example. Wtf is going on here, I don't know xD Math is not my strong subject. I know each call should be at 100ms since the SetTimer function, so I assume every +1 in srAutoPlayCount means 100ms. 0x3F = 63d. So, does it mean that this bitwise if is just a sleep for 63 * 100ms -> 6,3 seconds? Does not make any sense because packet 0x48470014 is sent something like each second, and it does have a similar logic to control the timing.
I see, makes sense. Never thought of it as "ticks". =D It's amazing to see how much you improved in coding over these years. Congratulations man!!
Awesome explanation, this is what was causing my mind to go nuts when I was trying to convert server to C# just for fun.
-- Edit
@Cainan @bocadecao
Why can I only use power of two numbers - 1 to make this delay?
If I try with 63 I get rouglhy one second. 63 / 70 = Almost one, all right.
140 / 70 = 2. I want a two second delay. If I try 140 it seems like it executes every tick and then sleeps for 2 seconds lol, opposite behaviour. However, with 511 is good, executes about 7.3 seconds.
I didn't understand why it has to be -1. If I put 64 for example it goes crazy.
Bitwise And operator works like that. I would say that it is not supposed to be used as a tick rate management, instead use the module operator % for other cases. Bitwise And operator is just faster, does not use any division nor multiply.
So with this current implementation of tick rate, we are bound to use only power of two numbers to create delay? In other words, I can't choose any delay I want, it must be one of those that power of two numbers - 1 gives. Is that correct?
The remainder operator (%) returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend.
@bocadecao @Cainan
I think I understand.
0x3F -> It will only succeed when anded with 0x3F.
0011 1111 (Mask -> This will determine the "frequency")
0100 0000 (64 - Value checked against)
------
0000 0000 (And Result)
So, the next number from "0100 0000" to return 0 from anding with 0x3F:
0011 1111 (Mask -> This will determine the "frequency")
1000 0000 (Next possible value to expected and result 0) -> 128
-----
0000 0000 (And Result)
It can only go in batches of 64 numbers. Not really power of two after all, was totally wrong about that.
What I still find hard to understand is when Cainan said Fps = 70. That variable along with that
if (cnt > 70 * 2 ) and FrameSkipTimer stuff... Maybe if I understand what that is for I could come up with my own mask to do any delay I wanted. Like, batches of 35, batches of whatever, and get the timing correct.
Btw, I've found this heartbeat class from an mmorpg emulator in github.
You must be registered to see links
Do you think server needs to match exactly how long this tick rate is originally implemented in C++? Or lets assume, as long as I sent more or less each second the 0x48470014 packet game will be fine?
Okay, the maths behind the operations you really don't need to understand. Just put in your mind, And (&) works with (power of two) tick rates, just test it with -1 and it is done, but the module operator (%) works with anything you want, the difference is just performance.
The if(cnt > 70 * 2) and FrameSkipTimer is not a big deal, it will only run if for some reason, the server cannot process stuff fast enough so that when it hits the function (srplaymain) again, it will just ignore the lagged time. In another words, it wont make the client go "Fast Forward Mode" when the server is too busy processing other things.
About the packet 0x48470014, you define the interval, there is no condition that needs to be meet, just be aware that the longer you wait, the bigger it gets (Packet Size), and, it can make you a little laggier (Delay).
Well, its not really power of two numbers,
You must be registered to see links
In this case, it goes in batches of 64 numbers, because of flag chosen to and: 0x3F . After 128, we should get 192 as the next tick, and not 256 that is the next in the power of two. I think maybe it really mean batches. There is another loop for instance which uses 0x3FF. So each 0x3FF adition, it will return 0 when anding.
What I would like to understand better is how/why, technically, they made this algorithm. The 100ms timer, the fact you said something about limiting 70 ticks per second. This 64 must have been thought on purpose, they can't simply try ranndom masks until they say: "Hey this seems like it takes as long as I want"
I found this article too, if anyone likes this stuff:You must be registered to see links
I will try to read your posts again to see if it clarifies anything. But if you'd like to get more technical xD I know it may sound a stupid subject about priston tale but I find it interesting to me. Its the server core, basically.
I wouldn't want to use C++ server so I'm trying to convert it to C# for fun and knoledge its been a while now but I stopped because this tick stuff was boring the hell out of me. lol