Examining key_dest
Moderator: InsideQC Admins
14 posts
• Page 1 of 1
Examining key_dest
Not the most interesting topic, but shows what I consider an annoying behavior.
key_dest has 4 values
- 0: key_game
- 1: key_console
- 2: key_message
- 3: key_menu
Now add the pseudo state of con_forcedup, which is whenever cl_worldmodel is NULL.
If you type disconnect in the console, you'll have a state of key_console.
Now press ESC and you'll have a state of key_menu.
Now press ESC again you'll have a state of key_game even though you aren't in the game. Now the console will still get the input because con_forcedup is true.
This kind of makes key_dest rather unreliable by itself.
You wouldn't want to alter the behavior because the console could be forced up in between the starting demos or technically during map load. Or ... since I enabled multimap demo playback the console may be forced up ever so briefly during the actual play of a demo.
Just one of the inner mysteries of Quake.
I've had to delve into this because I want the mousewheel to scroll the console even when disconnected.
This also explains why someone said (Sajt?) DarkPlaces briefly pops up the console in between maps?
key_dest has 4 values
- 0: key_game
- 1: key_console
- 2: key_message
- 3: key_menu
Now add the pseudo state of con_forcedup, which is whenever cl_worldmodel is NULL.
If you type disconnect in the console, you'll have a state of key_console.
Now press ESC and you'll have a state of key_menu.
Now press ESC again you'll have a state of key_game even though you aren't in the game. Now the console will still get the input because con_forcedup is true.
This kind of makes key_dest rather unreliable by itself.
You wouldn't want to alter the behavior because the console could be forced up in between the starting demos or technically during map load. Or ... since I enabled multimap demo playback the console may be forced up ever so briefly during the actual play of a demo.
Just one of the inner mysteries of Quake.
I've had to delve into this because I want the mousewheel to scroll the console even when disconnected.
This also explains why someone said (Sajt?) DarkPlaces briefly pops up the console in between maps?
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Ah yes, the wonderful mysteries of Quake having 47 different ways of doing everything, none of which work cleanly with each other, and none of which can be removed without causing major upset elsewhere.
Just for kicks DirectQ has a fifth (key_automap!)
Just for kicks DirectQ has a fifth (key_automap!)
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Add: What sucks is you never know quite why the console is forced up when key_dest isn't key_console. Possible reasons:
0. Maybe upon Quake start up before anything is initialized; rather sure this one situation.
1. Disconnected and someone went to the menu and back.
2. Someone pressed tilde when the console is forced up, which I think changes it back to key_game. Or for sure changes it to key_console when it was key_game.
3. In between startdemos demo queue.
4. In between maps in multimap demo playback.
5. In between maps in game play.
6. Maybe possibly a host_error ... although I'm thinking no because that triggers a CL_Disconnect ();
0. Maybe upon Quake start up before anything is initialized; rather sure this one situation.
1. Disconnected and someone went to the menu and back.
2. Someone pressed tilde when the console is forced up, which I think changes it back to key_game. Or for sure changes it to key_console when it was key_game.
3. In between startdemos demo queue.
4. In between maps in multimap demo playback.
5. In between maps in game play.
6. Maybe possibly a host_error ... although I'm thinking no because that triggers a CL_Disconnect ();
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Quake definitely starts up with key_dest == key_game - that one had me beating my head for a while some time back. There's a lesson there about never relying on the implicit initialization of globals to 0 (another bad coding practice that the engine is littered with).
Regarding con_forcedup, it is valid from one perspective as it's used to track if the console is fullscreen. But that doesn't mean I'm saying it's anything other than ugly; the whole thing would have been better collected into a single state enum, preferable as a static local in a function so that the only way it can be changed is through that function. At least that way you could set a single breakpoint on the function and track what's happening, add validation for other states that might affect it, and so on.
Regarding con_forcedup, it is valid from one perspective as it's used to track if the console is fullscreen. But that doesn't mean I'm saying it's anything other than ugly; the whole thing would have been better collected into a single state enum, preferable as a static local in a function so that the only way it can be changed is through that function. At least that way you could set a single breakpoint on the function and track what's happening, add validation for other states that might affect it, and so on.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Well ... if you also use con_initialized and scr_disabled_for_loading (or whatever it is called) ... I guess you can use the whole "sea" of cvars combined to figure out what is going on.
Maybe add cls.demonum to the mix and cls.demoplayback to the mix.
And make one big phat #define WHAT_IS_REALLY_THE_KEY_STATE ...
Haha!
Maybe add cls.demonum to the mix and cls.demoplayback to the mix.
And make one big phat #define WHAT_IS_REALLY_THE_KEY_STATE ...
Haha!
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Don't forget block_drawing!
And scr_initialized!
And vid_initialized!
I predict that you're going to have enormous fun when you come to untangle the mess that is window_center_x, window_center_y, window_x, window_y, window_width, window_height, window_rect, WindowRect, DIBWidth, DIBHeight, glx, gly, glwidth, glheight, vid.width, vid.height, vid.conwidth, vid.conheight, and all their friends. I'll have the comfy seat and the popcorn ready and waiting for your rant!
And scr_initialized!
And vid_initialized!
I predict that you're going to have enormous fun when you come to untangle the mess that is window_center_x, window_center_y, window_x, window_y, window_width, window_height, window_rect, WindowRect, DIBWidth, DIBHeight, glx, gly, glwidth, glheight, vid.width, vid.height, vid.conwidth, vid.conheight, and all their friends. I'll have the comfy seat and the popcorn ready and waiting for your rant!
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
I wish we just clean up the source code for vanilla quake
so you guys could adjust your engines to a clean codebase.
And any active mods could clean up their evil hax as well, leaving only single player mods and mods that aren't played much anymore (or closed source mods with asbent authors) left to be played on classic engines.
It'd be nice to tame the beast.
so you guys could adjust your engines to a clean codebase.
And any active mods could clean up their evil hax as well, leaving only single player mods and mods that aren't played much anymore (or closed source mods with asbent authors) left to be played on classic engines.
It'd be nice to tame the beast.
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
mh wrote:Don't forget block_drawing!
And scr_initialized!![]()
And vid_initialized!![]()
I predict that you're going to have enormous fun when you come to untangle the mess that is window_center_x, window_center_y, window_x, window_y, window_width, window_height, window_rect, WindowRect, DIBWidth, DIBHeight, glx, gly, glwidth, glheight, vid.width, vid.height, vid.conwidth, vid.conheight, and all their friends. I'll have the comfy seat and the popcorn ready and waiting for your rant!
I love it how I can move a GLQuake engine in windowed mode and drag it over to my second monitor.
But if I do that with WinQuake it pops back on monitor #1 when I release the mouse.
Oh well ... it is open source and that's the only thing that matters.
Open source means it may not longer be maintained, but it never has to be out of development
gnounc wrote:I wish we just clean up the source code for vanilla quake.
I wish someone would make the ultimate progs.dat 2.0
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Me, I wish we could get everyone onto D3D9/OpenGL 2 class hardware so that we can all start writing sensible rendering code. 
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Baker wrote:I love it how I can move a GLQuake engine in windowed mode and drag it over to my second monitor.
But if I do that with WinQuake it pops back on monitor #1 when I release the mouse.![]()
I've been having this problem, but I noticed it vanishes if you switch to vid_mode 2. So you can do this, move the window and then switch back to vid_mode 1.
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
mh wrote:Quake definitely starts up with key_dest == key_game - that one had me beating my head for a while some time back. There's a lesson there about never relying on the implicit initialization of globals to 0 (another bad coding practice that the engine is littered with).
Regarding con_forcedup, it is valid from one perspective as it's used to track if the console is fullscreen. But that doesn't mean I'm saying it's anything other than ugly; the whole thing would have been better collected into a single state enum, preferable as a static local in a function so that the only way it can be changed is through that function. At least that way you could set a single breakpoint on the function and track what's happening, add validation for other states that might affect it, and so on.
Can be useful to draw a state diagram to help refactor the code, then. And the getter/setter idea is good, too.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
frag.machine wrote:mh wrote:Quake definitely starts up with key_dest == key_game - that one had me beating my head for a while some time back. There's a lesson there about never relying on the implicit initialization of globals to 0 (another bad coding practice that the engine is littered with).
Regarding con_forcedup, it is valid from one perspective as it's used to track if the console is fullscreen. But that doesn't mean I'm saying it's anything other than ugly; the whole thing would have been better collected into a single state enum, preferable as a static local in a function so that the only way it can be changed is through that function. At least that way you could set a single breakpoint on the function and track what's happening, add validation for other states that might affect it, and so on.
Can be useful to draw a state diagram to help refactor the code, then. And the getter/setter idea is good, too.
Good point, it would definitely need a getter as well so the single function with a static local wouldn't work without some massaging.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
mh
Me, I wish we could get everyone onto D3D9/OpenGL 2 class hardware so that we can all start writing sensible rendering code. Crying or Very sad
Well you know what hardware I'm using by now lol, but if you were to write you're engine to specs my machine cant handle for sake of clean code, I'd hold no grudges.
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
Re: mh
gnounc wrote:Me, I wish we could get everyone onto D3D9/OpenGL 2 class hardware so that we can all start writing sensible rendering code. Crying or Very sad
Well you know what hardware I'm using by now lol, but if you were to write you're engine to specs my machine cant handle for sake of clean code, I'd hold no grudges.
Yeah, but that actually is a D3D9 class part. It's not too bad a part either, quite capable, just that so many renderers out there can't really take advantage of those capabilities properly.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
14 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest