SRCDS output redirection on windows
Redirecting the server output to a file or other monitoring program wasn't easily possible, because the SRCDS allocated a new console on windows and didn't use the stdout/stdin.
Over at Facepunch, Megalan posted
something about "-HFILE -HPARENT -HCHILD" command line options for srcds.exe to redirect the output. After some searching, I've only found references to a long-dead server management tool for Quake 1 called "QHost
", for which those parameters were initially added. Luckily they persisted in the engine code until now.
Sadly those parameters aren't exactly for redirecting output
, but rather give the possibility to request the last X lines of output and enter some commands from a different program. I wasn't able to really produce a tool that outputs new lines as they appear in the server commandline reliably.
The attached program does output it correctly, but might get confused when the process window gets resized. QHost apparently expected the server console window to always be of 80 width in size and didn't provide an API call to get the current actual size of the window. You might be able to get the size from the process window itself, but my windows-fu isn't strong enough for that (+ lack of interest).
To use this tool, place the SrcdsConRedirect.exe next to the srcds.exe and just call it in place of that - but redirect the output somewhere if you want ;)
C:\path\to\srcdsserver\SrcdsConRedirect.exe -game cstrike -port 27015 -console +map de_dust2 > console.output
Might be of some use for administration tools like seDirector, so you could send console commands directly to the server without any hacks, just by using the SRCDSControl class in the source package.
The provided methods in the dedicated conproc API are wrapped like
bool SetScreenBufferSize(int iLines);
bool WriteText(string input);
string ReadText(int iBeginLine, int iEndLine);