View previous topic :: View next topic |
Author |
Message |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jul 13, 2010 9:32 pm Post subject: 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? _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Tue Jul 13, 2010 9:36 pm Post subject: |
|
|
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!) _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jul 13, 2010 9:36 pm Post subject: |
|
|
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 (); _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Tue Jul 13, 2010 9:57 pm Post subject: |
|
|
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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jul 13, 2010 10:01 pm Post subject: |
|
|
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! _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Tue Jul 13, 2010 10:21 pm Post subject: |
|
|
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!  _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
gnounc

Joined: 06 Apr 2009 Posts: 120
|
Posted: Tue Jul 13, 2010 11:12 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Wed Jul 14, 2010 12:11 am Post subject: |
|
|
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  _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
|
Back to top |
|
 |
mk

Joined: 04 Jul 2008 Posts: 94
|
Posted: Wed Jul 14, 2010 4:28 am Post subject: |
|
|
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. _________________ Makaqu engine blog / website.
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Wed Jul 14, 2010 12:43 pm Post subject: |
|
|
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. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Wed Jul 14, 2010 12:52 pm Post subject: |
|
|
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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
gnounc

Joined: 06 Apr 2009 Posts: 120
|
Posted: Thu Jul 15, 2010 3:56 am Post subject: mh |
|
|
Quote: | 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. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Thu Jul 15, 2010 8:59 am Post subject: Re: mh |
|
|
gnounc wrote: | Quote: | 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.  _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
|