🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Dedicated Server Apps

Started by
2 comments, last by Galileo430 23 years, 5 months ago
This is probally a dumb question but here goes.. Games like Quake, Half-life and a few others come with Dedicated server applications that use a console window. 2 Questions actually, One, How do they let you input data while the program proccesses? cin stops the programs execution. Two, How do they proccess incomming messages? Some kind of callback function? Thanks for any help, Steven
------------------------------------------------------------I wrote the best video game ever, then I woke up...
Advertisement
1) Threads and event driven IO
2) Threads and event driven IO (related to callbacks, not exactly the same)

-or-
They poll the living **** out of everything in one thread. If it''s a dedicated machine this an option.

You wouldn''t use cin, you would get the state of the keyboard each loop and see if a key was hit (that was different than last time)

GetAsyncKeyState in Win32
I forget how to do it with 16b x86. There might be a function call and/or a memory mapped IO point to check.

Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
The console merely redirects where input goes. I assume as much having played Alice. While the console is up the game still goes. Cept the keys type characters rather than control Alice.

DirectInput is how I do it. I call the keyboard control routine during game play and when text needs to be entered I switch to the keyboard entry routine. Nothing else changes so the game keeps going. There''s just a case statement with a variable that tells which one is needed.

Both routines are called every frame to check for key presses. For keyboard entry you have to write you''re own "word processor" of sorts. Converting DirectInput codes to ascii codes and programming in keys like shift and del.

Ben

To process input from several sources do a select() (or a WaitForMultipleObjects())-loop. These functions suspend a thread until one of the named objects shows some activity (usually input).

The multi-threading idea isn''t that good b/c there more threads the more OS resources are used up, and context switches take time and can lead to cache flushes and stuff like that (though it''s usually not an issue with threads that share memory). Apart from that, multi-threaded programs are harder to write, because of the dangers of multiple writes to the same memory area and dead-locks.

cu,
Prefect
Widelands - laid back, free software strategy

This topic is closed to new replies.

Advertisement