Forum

Examining key_dest

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Examining key_dest

Postby Baker » Tue Jul 13, 2010 9:32 pm

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?
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Tue Jul 13, 2010 9:36 pm

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. :evil: :evil: :evil: :evil: :evil:

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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Baker » Tue Jul 13, 2010 9:36 pm

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 ();
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Tue Jul 13, 2010 9:57 pm

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.
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Baker » Tue Jul 13, 2010 10:01 pm

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!
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Tue Jul 13, 2010 10:21 pm

Don't forget block_drawing! :lol:
And scr_initialized! :lol:
And vid_initialized! :lol:

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! :D
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby gnounc » Tue Jul 13, 2010 11:12 pm

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.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby Baker » Wed Jul 14, 2010 12:11 am

mh wrote:Don't forget block_drawing! :lol:
And scr_initialized! :lol:
And vid_initialized! :lol:

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! :D


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. :D

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 :D
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Wed Jul 14, 2010 12:29 am

Me, I wish we could get everyone onto D3D9/OpenGL 2 class hardware so that we can all start writing sensible rendering code. :cry:
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby mankrip » Wed Jul 14, 2010 4:28 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. :D

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.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby frag.machine » Wed Jul 14, 2010 12:43 pm

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby mh » Wed Jul 14, 2010 12:52 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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

mh

Postby gnounc » Thu Jul 15, 2010 3:56 am

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.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Re: mh

Postby mh » Thu Jul 15, 2010 8:59 am

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. :D
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest