- Doom 3 rcon support
git-svn-id: http://svn.code.sf.net/p/xqf/code/trunk@637 d2ac09be-c843-0410-8b1f-f8a84130e0ec
This commit is contained in:
parent
73bb5595e4
commit
8aedf3306b
@ -1,3 +1,6 @@
|
||||
Aug 13, 2004: Ludwig Nussel <l-n@users.sourceforge.net>
|
||||
- Doom 3 rcon support
|
||||
|
||||
Aug 12, 2004: Ludwig Nussel <l-n@users.sourceforge.net>
|
||||
- properly detect installed Doom 3 maps. No preview though since gdk-pixbuf
|
||||
doesn't support the TGA format used by id :-(
|
||||
|
@ -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,
|
||||
|
@ -171,7 +171,7 @@
|
||||
<game>
|
||||
<base>Q3_SERVER</base>
|
||||
<type>DOOM3_SERVER</type>
|
||||
<flags>GAME_CONNECT | GAME_PASSWORD | GAME_QUAKE3_MASTERPROTOCOL</flags>
|
||||
<flags>GAME_CONNECT | GAME_PASSWORD | GAME_RCON | GAME_QUAKE3_MASTERPROTOCOL</flags>
|
||||
<name>Doom 3</name>
|
||||
<default_port>27666</default_port>
|
||||
<default_master_port>27650</default_master_port>
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <unistd.h> /* close */
|
||||
#include <string.h> /* memset, strcmp */
|
||||
#include <errno.h> /* errno */
|
||||
#include <ctype.h> /* isprint */
|
||||
|
||||
#include <sys/time.h> // 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user