Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Server Help

Author
Message
FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 3rd Dec 2011 05:29
I'm trying to write my server code using Multisync. For it to be flexible and easy to just pass around data, I've been trying to base it off of Valve's Source SDK networking article.
I read in a tickrate value from my config file and use that to control how the server runs. In the article, it says that whatever is defined as the tickrate, that number of "loops" run each second. And each iteration the server reads incoming messages and updates the world for the most part. I'm having trouble just working out the logic and flow of how this should go.

In my main GDK loop I have this:



Then the serverCore object has the runServer member function as such:



Now, I know that seems like a bunch of nonsense that makes sense. But what I want it to come down to is that the 1 second controls the other functions. I believe it may come to some multithreading, which is fine and I can just use the windows.h threading functions if need be. I just kind of need some help figuring out the best way to go about doing this. Thanks

Dev team portal Email me to join the dev team!

FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 4th Dec 2011 04:24
I have the Boost libraries installed. I still am having trouble figuring this out. Maybe it's because I am terrible at multithreading or just how this should work with a sync rate. Or maybe both.

What I feel like I need to do is create a thread for every tick. Well essentially 4 threads for each tick. 1 for checking for players, 1 for getting incoming messages to the server, 1 for updating the world, and 1 for sending snapshots to the clients. Now, these threads need to be created, run, then terminated/interrupted each tick. Since the default tickrate is 66, that's essentially 15 ms.

I just can't for the sake of everything that is good in this world, figure out how to create, run, and then interrupt even just 1 thread every 15ms. The important thing, is that I need to recreate this thread again after that time is up, so it does the specified function again. If anyone has any knowledge with threading or just a better way to do this, any input is appreciated.

Dev team portal Email me to join the dev team!

FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 6th Dec 2011 03:46
If anyone has any ideas, I'm still stuck on this.

Dev team portal Email me to join the dev team!

FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 8th Dec 2011 01:36
Anyone? I know this is probably confusing, so if it is, just say so xD I'm just not sure how to really go about tackling this.

Dev team portal Email me to join the dev team!

FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 16th Dec 2011 21:56
Soooo, I know no one has answered this, but I could still use some help. Here is my ServerCore.cpp file



And my main:



It's mainly in the runServer member function that I need some help. The tickRate variable is the one read from the config file, and right now it is 66. The problem is that the curTickCount is never reaching 66 in a second. I know this by using an if statement to sleep the program at 1 second, and see what the tick count is. It has never fully read 66 before.

Dev team portal Email me to join the dev team!

Login to post a reply

Server time is: 2024-04-19 18:10:24
Your offset time is: 2024-04-19 18:10:24