Skip to content

New feature: poll external file for console commands #1541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kmeaw
Copy link

@kmeaw kmeaw commented Feb 2, 2022

The commit adds "-refreshfile" and "-refreshinterval" command-line
arguments. Every refreshinterval tics (or once a second if not
specified) a refreshfile is read and is evaluated if exists and not
empty. Then it is truncated.

This feature provides a facility for an external program to control
the game.

Copy link
Member

@coelckers coelckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't decided yet whether this will be added - but if it will the handling of the file name needs to be changed to be Unicode compatible on all platforms. fopen does not support Unicode on Windows.

@kmeaw
Copy link
Author

kmeaw commented Feb 5, 2022

I have changed the code to use FileReader/FileWriter classes, which use _wfopen if WIN32 is #defined.

@kmeaw kmeaw requested a review from coelckers February 5, 2022 11:16
Copy link
Contributor

@MajorCooke MajorCooke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some problems when attempting to include this in GZDoom. Was this fully compiled on your end?

if (i > 0 && i < (int)Args->NumArgs() - 1)
{
RefreshFile = Args->GetArgList(i + 1);
RefreshInterval = TICRATE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When trying to merge this into QZDoom, I get the error that TICRATE isn't found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, when doing this just on GZDoom, TICRATE isn't found. Please fix this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which toolchain are you using? It builds fine on my machine with GCC 11.2.0.
I have just added an #include "doomdef.h" statement in c_console.cpp, it should fix the problem, TICRATE is defined as enum in this file. Please try to reproduce the issue by building 315e58f.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using Visual Studio 2017. I'll try it again in a bit. If it works, then I'll put it in QZDoom.

MajorCooke added a commit to ZDoom/qzdoom that referenced this pull request May 21, 2022
The commit adds "-refreshfile" and "-refreshinterval" command-line
arguments. Every refreshinterval tics (or once a second if not
specified) a refreshfile is read and is evaluated if exists and not
empty. Then it is truncated.

This feature provides a facility for an external program to control
the game.
@madame-rachelle
Copy link
Collaborator

I'm marking this one as "on hold" - I am not going to merge this one until I know for sure that it's okay to do so.

@madame-rachelle
Copy link
Collaborator

This one needs an "ok" from Graf. Functionally it seems this was tested and I was going to go ahead and merge it, but considering the nature of this feature it will need that extra layer of approval.

@CandiceJoy
Copy link
Member

This one needs an "ok" from Graf. Functionally it seems this was tested and I was going to go ahead and merge it, but considering the nature of this feature it will need that extra layer of approval.

Yep, I agree. For what it's worth, I tested it more thoroughly than the others, and it performed flawlessly in all cases; I was actually rather impressed, as I even tried it with a few hundred lines, various refresh intervals, etc.

That being said, I don't know this is the way to go about bringing in commands from outside; that is entirely up to Graf :)

@TancredTerror
Copy link

Hello everybody
The mod TwitchyDoom (https://github.com/CutmanMike/twitchy-doom/blob/main/README.md) can't work anymore since GZDoom didn't manage .txt files as beginning.
Is it possible to fix it please ?

@gamevoin
Copy link

Hello everybody The mod TwitchyDoom (https://github.com/CutmanMike/twitchy-doom/blob/main/README.md) can't work anymore since GZDoom didn't manage .txt files as beginning. Is it possible to fix it please ?

I'd like to see this resolved as well, the mod's been borked past GZDoom 4.10 as it lost the feature to read a constantly updating .txt file.

@ToxicFrog
Copy link

ToxicFrog commented Mar 10, 2025

I would also love to see this, the lack of an official IPC mechanism in GZDoom engenders some pretty gross workarounds.

I was myself thinking along the lines of a socket-based protocol to send and receive netevents and netcommands without needing the whole netplay protocol, but the ability to send it console commands via file is not something I'd considered and would be a huge boon.

This one needs an "ok" from Graf. Functionally it seems this was tested and I was going to go ahead and merge it, but considering the nature of this feature it will need that extra layer of approval.

Is there something specific you're concerned about? The feature isn't active unless the user specifies it on the command line, AIUI, so it's not like it opens a running gzdoom to external nonsense by default.

@RicardoLuis0
Copy link
Collaborator

think @madame-rachelle talked about adding ipc to zscript before too? named pipes or smth, don't remember much off the top of my head

@kyler-smiler
Copy link

I also would be very happy to see this feature return in future releases.
Like others have mentioned, I've been stuck on 4.10 when using my favorite mod, TwitchyDoom.

@RicardoLuis0
Copy link
Collaborator

yeah this PR is waiting on graf still for years so idk when it would be merged

@kmeaw
Copy link
Author

kmeaw commented May 21, 2025

@kyler-smiler, @RicardoLuis0, If you really need to integrate Twitch and ZDoom right now and can't want for this patch to merge, you can try zdrct from my github. UI is really bad but and unintuitive, but the whole thing works fine on Windows and Linux.
Or you can just drop the UI part (build c/inject.c and take the dll) and implement your own control plane.

@kyler-smiler
Copy link

@kyler-smiler, @RicardoLuis0, If you really need to integrate Twitch and ZDoom right now and can't want for this patch to merge, you can try zdrct from my github. UI is really bad but and unintuitive, but the whole thing works fine on Windows and Linux. Or you can just drop the UI part (build c/inject.c and take the dll) and implement your own control plane.

Right on, I will give this a shot. I really appreciate you sharing this.

@ToxicFrog
Copy link

There's also this although it doesn't look like the source has been published yet -- IPC to gzdoom using bidirectional OSC. Based on the description this probably hijacks stdout/stdin, so I think I'd rather have the repeatedly-read-external-file mechanism described here, or some sort of socket protocol, but I am honestly not picky as long as we get something.

@Macil
Copy link
Contributor

Macil commented Jun 24, 2025

There's also this

Oh hey that's me. The current code is at https://github.com/Macil/gzdoom/tree/macil/ec#readme. It supports two-way communication into and out of gzdoom. The implementation is actually pretty principled (not based on stdin/out; "piping" was used informally there) and demo-compatible (I think multiplayer-compatible too), but there's still some rough bits to it I'm working on improving before considering submitting it as a PR here. I think I could have a polished PR ready within a few weeks.

(I need to give it its own zscript interface instead of piggybacking directly on network command events, and I want to replace its use of the connectionless OSC protocol with something connection-oriented that properly supports multiple clients, and have it listen on a unix domain socket or named pipe so that it could be safely enabled by default and not be abusable by other unprivileged users on the same host.)

@ToxicFrog
Copy link

The implementation is actually pretty principled (not based on stdin/out; "piping" was used informally there) and demo-compatible (I think multiplayer-compatible too), but there's still some rough bits to it I'm working on improving before considering submitting it as a PR here. I think I could have a polished PR ready within a few weeks.

Oh, that is super cool! And yeah, based on the bsky description I thought you meant OSC as in the TTY escape sequence category, I'd never heard of Open Sound Control. That makes a lot more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.