```
-
```
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
nostdout = Cvar_Get("nostdout", "0", 0);
if (!nostdout->value) {
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
}
```
I'm thinking about this piece of code present in Quake 2 but not in Quake III too much.
What did they wanted to say... -
```
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
nostdout = Cvar_Get("nostdout", "0", 0);
if (!nostdout->value) {
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
}
```
I'm thinking about this piece of code present in Quake 2 but not in Quake III too much.
What did they wanted to say...@a1ba most interesting! And I assume there is no good version of this in quake 1 either? But it can be found in common code?
-
@a1ba most interesting! And I assume there is no good version of this in quake 1 either? But it can be found in common code?
@a1ba so someone goofed of course, but maybe the original version was meant to either close stdout (redirect to /dev/null), or put stdin into non blocking to essentially make a console out of your terminal.
-
@a1ba so someone goofed of course, but maybe the original version was meant to either close stdout (redirect to /dev/null), or put stdin into non blocking to essentially make a console out of your terminal.
@a1ba the quake 3 code had a lot of goofy stuff and sharp edges, when id passed it over to me I spent the first few months cleaning up compiler warnings.
It was a good way to familiarize with it, but I don't remember running into this.
-
@a1ba so someone goofed of course, but maybe the original version was meant to either close stdout (redirect to /dev/null), or put stdin into non blocking to essentially make a console out of your terminal.
@TTimo @a1ba
https://github.com/TTimo/doom3.gpl/blob/master/neo/sys/posix/posix_main.cpp#L582-L587
looks kinda similar, except it correctly uses O_NONBLOCK (and STDIN_FILENO instead of 0, but STDIN_FILENO *is* 0)However, at least on Linux, FNDELAY is defined as O_NDELAY, which is defined as.. O_NONBLOCK
so in the end that code does the same(except for the redundancy of calling that and then calling it again if the nostdout is set to 0)
-
@a1ba the quake 3 code had a lot of goofy stuff and sharp edges, when id passed it over to me I spent the first few months cleaning up compiler warnings.
It was a good way to familiarize with it, but I don't remember running into this.
-
@TTimo @a1ba
https://github.com/TTimo/doom3.gpl/blob/master/neo/sys/posix/posix_main.cpp#L582-L587
looks kinda similar, except it correctly uses O_NONBLOCK (and STDIN_FILENO instead of 0, but STDIN_FILENO *is* 0)However, at least on Linux, FNDELAY is defined as O_NDELAY, which is defined as.. O_NONBLOCK
so in the end that code does the same(except for the redundancy of calling that and then calling it again if the nostdout is set to 0)
@Doomed_Daniel @a1ba that part looks more like code I may have written, the quake 1 / 2 era stuff is an older C dialect, typically how JDC would write it.
But yeah that all matches with the idea that it was for tty mode.
-
@Doomed_Daniel @a1ba that part looks more like code I may have written, the quake 1 / 2 era stuff is an older C dialect, typically how JDC would write it.
But yeah that all matches with the idea that it was for tty mode.
@Doomed_Daniel @a1ba when we worked on Doom3 I was the one to refactor the low level code into Sys_ Win_ Posix_ etc. functions.
It turned out way better than a mess of ifdefs inside one 'portable' function declaration imo.
-
A a1ba@suya.place shared this topic
-
@Doomed_Daniel @a1ba when we worked on Doom3 I was the one to refactor the low level code into Sys_ Win_ Posix_ etc. functions.
It turned out way better than a mess of ifdefs inside one 'portable' function declaration imo.
@TTimo @Doomed_Daniel speaking of doom3, it's interesting how some tiny part of it ended up in RTCW (there is idLib folder at least) but RTCW itself also has bits that were removed in Q3 by the time it hit public release.