Discussion:
quake2 improvements and problem
Anders Storsveen
2005-03-26 05:06:30 UTC
Permalink
here are some other ideas:

http://cure.gamepoint.net/q2_enhanced_engine_wishlist.html

also I have a problem with getting battleground to work, I get this error:

NET_Socket: socket: Address family not supported by protocol
NET_Socket: socket: Address family not supported by protocol
------- Loading gamei386.so -------

==== InitGame ====
------- Server Initialization -------
Quake2 Battleground v1.38
Map: q2dm1 Mode: Match
Reading banned IPs...
Reading MOTD...
droptofloor: item_health startsolid at (1192 -24 912)
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

and Received signal 11, exiting... in glx.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Thomas J Fogal
2005-03-26 20:20:12 UTC
Permalink
Post by Anders Storsveen
http://cure.gamepoint.net/q2_enhanced_engine_wishlist.html
Got bored today. Implemented one of his suggested fixes because it
sounded easy.

The following patch:
makes HOME clear the current line, going to the 1st char
makes CTRL-HOME and CTRL-END goto the start and end of the current
scrollback buffer.
additionally makes CTRL-U clear the line, a la the shell
has framework for END to goto EOL
fixes minor code formatting things i noticed (but not all of them)

In the current setup, HOME and END cannot be made to goto the beginning
of a line. This is because of how the scrollback buffer is
stored/accessed; being at a certain position within a line means
anything after that position is 'invalid'.
Someone can, of course, modify how the data is stored/accessed, but I
wasn't that ambitious for this patch. If they do, to make it work with
end they should see the code around the line with the comment:

/* how can I get end of line? */

-tom

####
the patch:
####
--- /home/tom/src/quake2/src/client/keys.c 2002-04-02 20:08:23.000000000 -0500
+++ keys.c 2005-03-26 15:09:00.000000000 -0500
@@ -19,12 +19,7 @@
*/
#include "client.h"

-/*
-
-key up events are sent even if in console mode
-
-*/
-
+/* key up events are sent even if in console mode */

#define MAXCMDLINE 256
char key_lines[32][MAXCMDLINE];
@@ -43,10 +38,9 @@
int key_repeats[K_LAST]; // if > 1, it is autorepeating
qboolean keydown[K_LAST];

-typedef struct
-{
- char *name;
- int keynum;
+typedef struct {
+ char *name;
+ int keynum;
} keyname_t;

keyname_t keynames[] =
@@ -158,9 +152,7 @@

/*
==============================================================================
-
LINE TYPING INTO THE CONSOLE
-
==============================================================================
*/

@@ -196,7 +188,6 @@
*/
void Key_Console (int key)
{
-
switch ( key )
{
case K_KP_SLASH:
@@ -272,13 +263,9 @@
return;
}

- if ( key == 'l' )
- {
- if ( keydown[K_CTRL] )
- {
- Cbuf_AddText ("clear\n");
- return;
- }
+ if(key == 'l' && keydown[K_CTRL]) {
+ Cbuf_AddText ("clear\n");
+ return;
}

if ( key == K_ENTER || key == K_KP_ENTER )
@@ -351,8 +338,7 @@
return;
}

- if (key == K_PGUP || key == K_KP_PGUP )
- {
+ if(key == K_PGUP || key == K_KP_PGUP) {
con.display -= 2;
return;
}
@@ -365,28 +351,42 @@
return;
}

- if (key == K_HOME || key == K_KP_HOME )
- {
- con.display = con.current - con.totallines + 10;
+ /* HOME goes to beginning of the line or top of scroll buffer with CTRL */
+ if(key == K_HOME || key == K_KP_HOME) {
+ if(keydown[K_CTRL]) {
+ con.display = con.current - con.totallines + 10;
+ } else {
+ con.x = key_linepos = 1;
+ }
return;
}

- if (key == K_END || key == K_KP_END )
- {
- con.display = con.current;
+ /* similarly, CTRL-U clears the current line */
+ if(key == 'u' && keydown[K_CTRL]) {
+ con.x = key_linepos = 1;
+ return;
+ }
+
+ /* END goes to end of line or bottom of scrollbuffer w/ CTRL */
+ if(key == K_END || key == K_KP_END) {
+ if(keydown[K_CTRL]) {
+ con.current = con.display = con.totallines;
+ } else {
+ /* how can I get end of line? */
+ con.x = con.linewidth;
+ key_linepos = con.linewidth;
+ }
return;
}

if (key < 32 || key > 127)
return; // non printable

- if (key_linepos < MAXCMDLINE-1)
- {
+ if (key_linepos < MAXCMDLINE-1) {
key_lines[edit_line][key_linepos] = key;
key_linepos++;
key_lines[edit_line][key_linepos] = 0;
}
-
}

//============================================================================
Sigurdur Hannesson
2005-03-27 11:51:58 UTC
Permalink
/* how can I get end of line? */

Not sure if it'll do, but hey! Try this:

key_linepos = strlen (key_lines[edit_line];


On Sat, 26 Mar 2005 15:20:12 -0500, Thomas J Fogal
Post by Thomas J Fogal
Post by Anders Storsveen
http://cure.gamepoint.net/q2_enhanced_engine_wishlist.html
Got bored today. Implemented one of his suggested fixes because it
sounded easy.
makes HOME clear the current line, going to the 1st char
makes CTRL-HOME and CTRL-END goto the start and end of the current
scrollback buffer.
additionally makes CTRL-U clear the line, a la the shell
has framework for END to goto EOL
fixes minor code formatting things i noticed (but not all of them)
In the current setup, HOME and END cannot be made to goto the beginning
of a line. This is because of how the scrollback buffer is
stored/accessed; being at a certain position within a line means
anything after that position is 'invalid'.
Someone can, of course, modify how the data is stored/accessed, but I
wasn't that ambitious for this patch. If they do, to make it work with
/* how can I get end of line? */
-tom
####
####
--- /home/tom/src/quake2/src/client/keys.c 2002-04-02 20:08:23.000000000 -0500
+++ keys.c 2005-03-26 15:09:00.000000000 -0500
@@ -19,12 +19,7 @@
*/
#include "client.h"
-/*
-
-key up events are sent even if in console mode
-
-*/
-
+/* key up events are sent even if in console mode */
#define MAXCMDLINE 256
char key_lines[32][MAXCMDLINE];
@@ -43,10 +38,9 @@
int key_repeats[K_LAST]; // if > 1, it is autorepeating
qboolean keydown[K_LAST];
-typedef struct
-{
- char *name;
- int keynum;
+typedef struct {
+ char *name;
+ int keynum;
} keyname_t;
keyname_t keynames[] =
@@ -158,9 +152,7 @@
/*
==============================================================================
-
LINE TYPING INTO THE CONSOLE
-
==============================================================================
*/
@@ -196,7 +188,6 @@
*/
void Key_Console (int key)
{
-
switch ( key )
{
@@ -272,13 +263,9 @@
return;
}
- if ( key == 'l' )
- {
- if ( keydown[K_CTRL] )
- {
- Cbuf_AddText ("clear\n");
- return;
- }
+ if(key == 'l' && keydown[K_CTRL]) {
+ Cbuf_AddText ("clear\n");
+ return;
}
if ( key == K_ENTER || key == K_KP_ENTER )
@@ -351,8 +338,7 @@
return;
}
- if (key == K_PGUP || key == K_KP_PGUP )
- {
+ if(key == K_PGUP || key == K_KP_PGUP) {
con.display -= 2;
return;
}
@@ -365,28 +351,42 @@
return;
}
- if (key == K_HOME || key == K_KP_HOME )
- {
- con.display = con.current - con.totallines + 10;
+ /* HOME goes to beginning of the line or top of scroll buffer with CTRL */
+ if(key == K_HOME || key == K_KP_HOME) {
+ if(keydown[K_CTRL]) {
+ con.display = con.current - con.totallines + 10;
+ } else {
+ con.x = key_linepos = 1;
+ }
return;
}
- if (key == K_END || key == K_KP_END )
- {
- con.display = con.current;
+ /* similarly, CTRL-U clears the current line */
+ if(key == 'u' && keydown[K_CTRL]) {
+ con.x = key_linepos = 1;
+ return;
+ }
+
+ /* END goes to end of line or bottom of scrollbuffer w/ CTRL */
+ if(key == K_END || key == K_KP_END) {
+ if(keydown[K_CTRL]) {
+ con.current = con.display = con.totallines;
+ } else {
+ /* how can I get end of line? */
+ con.x = con.linewidth;
+ key_linepos = con.linewidth;
+ }
return;
}
if (key < 32 || key > 127)
return; // non printable
- if (key_linepos < MAXCMDLINE-1)
- {
+ if (key_linepos < MAXCMDLINE-1) {
key_lines[edit_line][key_linepos] = key;
key_linepos++;
key_lines[edit_line][key_linepos] = 0;
}
-
}
//============================================================================
--
Regards,
Sigurdur Axel
Alexey Dokuchaev
2005-03-27 17:27:15 UTC
Permalink
Post by Thomas J Fogal
fixes minor code formatting things i noticed (but not all of them)
Actually, you "code formatting things" are quite contrary to nowadays'
Post by Thomas J Fogal
-/*
-
-key up events are sent even if in console mode
-
-*/
-
+/* key up events are sent even if in console mode */
Full sentence comments should be coded this way:

/*
* This is some what long comment.
*/
Post by Thomas J Fogal
/*
==============================================================================
-
LINE TYPING INTO THE CONSOLE
-
==============================================================================
*/
This is part of original id's comment, and should probably be left
intact.
Post by Thomas J Fogal
+ if(key == 'l' && keydown[K_CTRL]) {
It is actually far more readable to retain space after statement (if,
while, for, switch, return, etc).
Post by Thomas J Fogal
+ Cbuf_AddText ("clear\n");
On the contrary, there are no space after function calls.
Post by Thomas J Fogal
- if (key == K_PGUP || key == K_KP_PGUP )
- {
+ if(key == K_PGUP || key == K_KP_PGUP) {
Same thing here.

To summarise, when you change things/implement new ones, try to separate
functional changes from style/markup ones (in your diffs, at least).

Thanks!

./danfe
Thomas J Fogal
2005-03-27 16:32:26 UTC
Permalink
Post by Thomas J Fogal
/* how can I get end of line? */
key_linepos = strlen (key_lines[edit_line];
unfortunately, no. the way text is currently done, going to the
beginning of the line clears the whole line. Therefore the above might
go to the end of the current line, but really the cursor can never
leave that position anyway. Basically, moving backwards deletes text
AND moves the cursor =(

I would imagine once someone seperates the idea of moving the cursor
and adding/deleting text, the above will work to grab the end of line.

-tom
Thomas J Fogal
2005-03-27 22:48:22 UTC
Permalink
Post by Alexey Dokuchaev
Post by Thomas J Fogal
fixes minor code formatting things i noticed (but not all of them)
Actually, you "code formatting things" are quite contrary to nowadays'
<snip>

These are purely opinion based, and I would disagree with most. But
lets not start a holy war on syntax.

I'm actually in favor of /** doxygen comments */ for small one line
comments. Though I didn't bother for this.
Post by Alexey Dokuchaev
To summarise, when you change things/implement new ones, try to separate
functional changes from style/markup ones (in your diffs, at least).
good call. will do.

-tom
Brendan Burns
2005-03-27 23:59:02 UTC
Permalink
I firmly second the let's not start a syntax holy war. I myself am
pretty lax about style as a maintainer.

It's not like the original q2 source is a paragon of brilliant style ;-P

I figure as long as someone is contributing code and its understandable
to me, I'm cool with including it...

--brendan
Post by Thomas J Fogal
Post by Alexey Dokuchaev
Post by Thomas J Fogal
fixes minor code formatting things i noticed (but not all of them)
Actually, you "code formatting things" are quite contrary to nowadays'
<snip>
These are purely opinion based, and I would disagree with most. But
lets not start a holy war on syntax.
I'm actually in favor of /** doxygen comments */ for small one line
comments. Though I didn't bother for this.
Post by Alexey Dokuchaev
To summarise, when you change things/implement new ones, try to separate
functional changes from style/markup ones (in your diffs, at least).
good call. will do.
-tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2377 bytes
Desc: not available
URL: <http://icculus.org/pipermail/quake2/attachments/20050327/5572de43/attachment.bin>
Loading...