diff --git a/xqf/ChangeLog b/xqf/ChangeLog index 5afd2f3..a09dbd2 100644 --- a/xqf/ChangeLog +++ b/xqf/ChangeLog @@ -1,3 +1,6 @@ +Aug 13, 2004: Ludwig Nussel +- Doom 3 rcon support + Aug 12, 2004: Ludwig Nussel - properly detect installed Doom 3 maps. No preview though since gdk-pixbuf doesn't support the TGA format used by id :-( diff --git a/xqf/src/games.c b/xqf/src/games.c index b6b845b..4f2e829 100644 --- a/xqf/src/games.c +++ b/xqf/src/games.c @@ -199,7 +199,7 @@ struct game games[] = { }, { type : DOOM3_SERVER, - flags : GAME_CONNECT | GAME_PASSWORD | GAME_QUAKE3_MASTERPROTOCOL, + flags : GAME_CONNECT | GAME_PASSWORD | GAME_RCON | GAME_QUAKE3_MASTERPROTOCOL, name : "Doom 3", default_port : 27666, default_master_port : 27650, diff --git a/xqf/src/games.xml b/xqf/src/games.xml index 5dd69f4..8772aee 100644 --- a/xqf/src/games.xml +++ b/xqf/src/games.xml @@ -171,7 +171,7 @@ Q3_SERVER DOOM3_SERVER - GAME_CONNECT | GAME_PASSWORD | GAME_QUAKE3_MASTERPROTOCOL + GAME_CONNECT | GAME_PASSWORD | GAME_RCON | GAME_QUAKE3_MASTERPROTOCOL Doom 3 27666 27650 diff --git a/xqf/src/rcon.c b/xqf/src/rcon.c index f20f964..f4b2a11 100644 --- a/xqf/src/rcon.c +++ b/xqf/src/rcon.c @@ -27,6 +27,7 @@ #include /* close */ #include /* memset, strcmp */ #include /* errno */ +#include /* isprint */ #include // select @@ -143,7 +144,9 @@ static int open_connection (struct in_addr *ip, unsigned short port) { static int rcon_send(const char* cmd) { - char* buf; + char* buf = NULL; + size_t bufsize = 0; + int ret = -1; if(rcon_servertype == HL_SERVER && rcon_challenge == NULL) { @@ -153,7 +156,8 @@ static int rcon_send(const char* cmd) char* mustresponse = "\377\377\377\377challenge rcon "; int size; buf = "\377\377\377\377challenge rcon"; - send (rcon_fd, buf, strlen(buf)+1, 0); + bufsize = strlen(buf)+1; + send (rcon_fd, buf, bufsize, 0); { fd_set rfds; @@ -203,13 +207,28 @@ static int rcon_send(const char* cmd) } buf = g_strdup_printf("\377\377\377\377rcon %s %s %s",rcon_challenge, rcon_password, cmd); + bufsize = strlen(buf)+1; + } + else if (rcon_servertype == DOOM3_SERVER) + { + const char prefix[] = "\377\377rcon"; + bufsize = sizeof(prefix) +strlen(rcon_password) +1 +strlen(cmd) +1; + buf = g_new0(char, bufsize); + strcpy(buf, prefix); + strcpy(buf+sizeof(prefix), rcon_password); + strcpy(buf+sizeof(prefix)+strlen(rcon_password)+1, cmd); } else + { buf = g_strdup_printf("\377\377\377\377rcon %s %s",rcon_password, cmd); + bufsize = strlen(buf)+1; + } rcon_print ("RCON> %s\n", cmd); - return send (rcon_fd, buf, strlen(buf)+1, 0); + ret = send (rcon_fd, buf, bufsize, 0); + g_free(buf); + return ret; } #ifndef RCON_STANDALONE @@ -316,6 +335,24 @@ static char* rcon_receive() size = size - 4 - 1; break; + case DOOM3_SERVER: + // "\377\377print\0????\0" + if(size > 2+6+4+1) + { + char* ptr = msg = packet+2+6+4; + while(ptr && ptr < packet + size - 1) + { + if(*ptr == '\n' || isprint(*ptr)) + ++ptr; + else + { + *ptr = '.'; + ++ptr; + } + } + } + break; + /* Q2, Q3 */ default: @@ -578,8 +615,7 @@ void rcon_dialog (const struct server *s, const char *passwd) { packet = NULL; } - if(rcon_challenge) - g_free(rcon_challenge); + g_free(rcon_challenge); rcon_challenge = NULL; unregister_window (window); @@ -642,6 +678,11 @@ int main(int argc, char* argv[]) rcon_servertype = HW_SERVER; argpos++; } + else if(!strcmp(argv[argpos],"--dm3s")) + { + rcon_servertype = DOOM3_SERVER; + argpos++; + } } if( argc-argpos<2 || !strcmp(argv[argpos],"--help")) @@ -707,7 +748,9 @@ int main(int argc, char* argv[]) } else { - printf("%s",rcon_receive()); + char* msg = rcon_receive(); + printf("%s", msg); + g_free(msg); } } } diff --git a/xqf/src/source.c b/xqf/src/source.c index da7c69e..99faadf 100644 --- a/xqf/src/source.c +++ b/xqf/src/source.c @@ -941,6 +941,7 @@ static char *builtin_masters_update_info[] = { "ADD T2S lan://255.255.255.255 LAN", "ADD POSTAL2 lan://255.255.255.255 LAN", "ADD SFS lan://255.255.255.255 LAN", + "ADD DM3S lan://255.255.255.255 LAN", NULL };