Seeding from the 1.2 tree.
This commit is contained in:
174
dll/qbx/Makefile.in
Normal file
174
dll/qbx/Makefile.in
Normal file
@@ -0,0 +1,174 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = qbx
|
||||
|
||||
all: Makefile qbx$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
qbx.o: $(srcdir)/qbx.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/qbx.c
|
||||
|
||||
qbx$(SHLIB_SUFFIX): qbx.o ../dllinit.o
|
||||
$(SHLIB_LD) qbx.o ../dllinit.o $(SHLIB_CFLAGS) -o qbx$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o qbx$(SHLIB_SUFFIX) *.a *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
9
dll/qbx/README
Normal file
9
dll/qbx/README
Normal file
@@ -0,0 +1,9 @@
|
||||
irc commands:
|
||||
!q2 <server>[:port] - queries a quake2 server
|
||||
!qw <server>[:port] - queries a quakeworld server
|
||||
!q3a <server>[:port] - queries a quake3 server
|
||||
|
||||
normal commands:
|
||||
/QBX <on|off> - enables or disables qbx
|
||||
|
||||
any suggestions or questions email pod@caro.net
|
||||
300
dll/qbx/qbx.c
Normal file
300
dll/qbx/qbx.c
Normal file
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Qbx by pod (pod@caro.net)
|
||||
* Some of this code is from Qir by Ben Turner (seti@detroit.org)
|
||||
*/
|
||||
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "hook.h"
|
||||
#include "module.h"
|
||||
#define INIT_MODULE
|
||||
#include "modval.h"
|
||||
|
||||
#include "qbx.h"
|
||||
|
||||
#define cparse convert_output_format
|
||||
|
||||
int qfd, querying = 0, qbx_on = 1, q_type = 0;
|
||||
char q_server[256], q_chan[256];
|
||||
struct timeval q_tv;
|
||||
|
||||
void privmsg(char *to, const char *format, ...) {
|
||||
va_list ap;
|
||||
char buffer[1024];
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
va_end(ap);
|
||||
queue_send_to_server(from_server, "PRIVMSG %s :%s", to, buffer);
|
||||
}
|
||||
|
||||
int time_delta(struct timeval *later, struct timeval *past) {
|
||||
if(later->tv_usec < past->tv_usec) {
|
||||
later->tv_sec--;
|
||||
later->tv_usec+= 1000000;
|
||||
}
|
||||
return (later->tv_sec - past->tv_sec) * 1000 +
|
||||
(later->tv_usec - past->tv_usec) / 1000;
|
||||
}
|
||||
|
||||
|
||||
void q_timeout(int fd) {
|
||||
put_it("No response from %s", q_server);
|
||||
privmsg(q_chan, "No response from %s", q_server);
|
||||
close_socketread(qfd);
|
||||
querying = 0;
|
||||
}
|
||||
|
||||
void q_timer(int fd) {
|
||||
int i = 0, j = 0, k = 0, type = q_type;
|
||||
int nextpart = 0, num_players = 0, cheats = 0;
|
||||
struct quake_variable variable[50];
|
||||
struct timeval tv;
|
||||
char status[65507], temp[1024];
|
||||
char server_hostname[1024], server_maxclients[1024], server_mapname[1024];
|
||||
char server_fraglimit[1024], server_timelimit[1024], server_game[1024];
|
||||
|
||||
/* ick. */
|
||||
memset(&temp, 0, sizeof(temp));
|
||||
memset(&server_hostname, 0, sizeof(server_hostname));
|
||||
memset(&server_maxclients, 0, sizeof(server_maxclients));
|
||||
memset(&server_mapname, 0, sizeof(server_mapname));
|
||||
memset(&server_fraglimit, 0, sizeof(server_fraglimit));
|
||||
memset(&server_timelimit, 0, sizeof(server_timelimit));
|
||||
memset(&server_game, 0, sizeof(server_game));
|
||||
|
||||
/* now we should be expecting something back */
|
||||
memset(&status, 0, sizeof(status));
|
||||
if(recv(fd, status, 65507, 0) < 0) {
|
||||
put_it("Error receiving from %s: %s", q_server, strerror(errno));
|
||||
privmsg(q_chan, "Error receiving from %s: %s", q_server, strerror(errno));
|
||||
close_socketread(fd);
|
||||
querying = 0;
|
||||
return;
|
||||
}
|
||||
gettimeofday(&tv, NULL);
|
||||
close_socketread(fd);
|
||||
|
||||
memset(&variable, 0, sizeof(variable));
|
||||
|
||||
/* now we have our info, but we still need to decode it! */
|
||||
if(type == 1)
|
||||
i = 7;
|
||||
else if(type == 2)
|
||||
i = 11;
|
||||
else if(type == 3)
|
||||
i = 20;
|
||||
|
||||
/* the following while loop copies all the variables from the status message
|
||||
into an array together with their value */
|
||||
while (status[i] != '\n') {
|
||||
/* check whether it's time for a new variable */
|
||||
if (status[i] == '\\') {
|
||||
if (nextpart) {
|
||||
nextpart = 0;
|
||||
variable[j].value[k] = '\0';
|
||||
j++;
|
||||
} else {
|
||||
nextpart = 1;
|
||||
variable[j].name[k] = '\0';
|
||||
}
|
||||
k = 0;
|
||||
} else {
|
||||
/* put our character in the correct position */
|
||||
if (nextpart)
|
||||
variable[j].value[k] = status[i];
|
||||
else
|
||||
variable[j].name[k] = status[i];
|
||||
k++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
variable[j].value[k] = '\0';
|
||||
|
||||
/* now we can count how many players there are on the server */
|
||||
i++;
|
||||
put_it(&status[i]);
|
||||
while (i < strlen(status)) {
|
||||
if (status[i] == '\n') {
|
||||
num_players++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
for (i = 0; i < 50; i++) {
|
||||
if(type != 3) {
|
||||
if(!strcmp("hostname", variable[i].name))
|
||||
strcpy(server_hostname, variable[i].value);
|
||||
if(!strcmp("maxclients", variable[i].name))
|
||||
strcpy(server_maxclients, variable[i].value);
|
||||
} else {
|
||||
if(!strcmp("sv_hostname", variable[i].name))
|
||||
strcpy(server_hostname, variable[i].value);
|
||||
if(!strcmp("sv_maxclients", variable[i].name))
|
||||
strcpy(server_maxclients, variable[i].value);
|
||||
if(!strcmp("g_gametype", variable[i].name)) {
|
||||
switch(atoi(variable[i].name)) {
|
||||
case 0: strcpy(server_game, "FFA"); break;
|
||||
case 1: strcpy(server_game, "DUEL"); break;
|
||||
case 3: strcpy(server_game, "TEAM DM"); break;
|
||||
case 4: strcpy(server_game, "CTF"); break;
|
||||
default: strcpy(server_game, "UNKNOWN"); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type == 1) {
|
||||
if(!strcmp("map", variable[i].name))
|
||||
strcpy(server_mapname, variable[i].value);
|
||||
if(!strcmp("*gamedir", variable[i].name))
|
||||
strcpy(server_game, variable[i].value);
|
||||
if(!strcmp("cheats", variable[i].name))
|
||||
cheats = 1;
|
||||
}
|
||||
else {
|
||||
if(!strcmp("mapname", variable[i].name))
|
||||
strcpy(server_mapname, variable[i].value);
|
||||
}
|
||||
if(type == 2) {
|
||||
if(!strcmp("gamename", variable[i].name))
|
||||
strcpy(server_game, variable[i].value);
|
||||
}
|
||||
if(!strcmp("timelimit", variable[i].name))
|
||||
strcpy(server_timelimit, variable[i].value);
|
||||
if(!strcmp("fraglimit", variable[i].name))
|
||||
strcpy(server_fraglimit, variable[i].value);
|
||||
}
|
||||
if(type == 1) {
|
||||
snprintf(temp, 1024, "%s : players: %d/%s, ping: %d, map: %s, timelimit: %s, fraglimit: %s", server_hostname, num_players, server_maxclients, time_delta(&tv, &q_tv), server_mapname, server_timelimit, server_fraglimit);
|
||||
if(server_game[0] != '\0') {
|
||||
char temp2[1024];
|
||||
snprintf(temp2, 1024, ", game: %s", server_game);
|
||||
strcat(temp, temp2);
|
||||
}
|
||||
if(cheats)
|
||||
strcat(temp, ", cheats enabled");
|
||||
}
|
||||
if(type == 2)
|
||||
snprintf(temp, 1024, "%s : players: %d/%s, ping: %d, map: %s, timelimit: %s, fraglimit: %s, game: %s", server_hostname, num_players, server_maxclients, time_delta(&tv, &q_tv), server_mapname, server_timelimit, server_fraglimit, server_game);
|
||||
if(type == 3)
|
||||
snprintf(temp, 1024, "%s : players: %d/%s, ping: %d, map: %s, gametype: %s, timelimit: %s, fraglimit: %s", server_hostname, num_players, server_maxclients, time_delta(&tv, &q_tv), server_mapname, server_game, server_timelimit, server_fraglimit);
|
||||
put_it(temp);
|
||||
privmsg(q_chan, temp);
|
||||
querying = 0;
|
||||
}
|
||||
|
||||
void query_q_server(char *server, int port, int game) {
|
||||
char buffer[16];
|
||||
|
||||
struct sockaddr_in qsock;
|
||||
struct hostent *he;
|
||||
|
||||
querying = 1;
|
||||
|
||||
/* look up our quakeserver address */
|
||||
if ((he = gethostbyname(server)) == NULL) {
|
||||
put_it("unknown host: %s", server);
|
||||
close(qfd);
|
||||
querying = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
qfd = connect_by_number(server, &port, SERVICE_CLIENT, PROTOCOL_UDP, 1);
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(&qsock, 0, sizeof(struct sockaddr_in));
|
||||
if(game == 3)
|
||||
strcpy(buffer, "\xFF\xFF\xFF\xFFgetstatus");
|
||||
else
|
||||
strcpy(buffer, "\xFF\xFF\xFF\xFFstatus");
|
||||
|
||||
qsock.sin_family = AF_INET;
|
||||
qsock.sin_port = htons(port);
|
||||
qsock.sin_addr = *((struct in_addr *)he->h_addr);
|
||||
|
||||
put_it("Sending status request to %d.%d.%d.%d...",
|
||||
(unsigned char) he->h_addr_list[0][0],
|
||||
(unsigned char) he->h_addr_list[0][1],
|
||||
(unsigned char) he->h_addr_list[0][2],
|
||||
(unsigned char) he->h_addr_list[0][3]);
|
||||
|
||||
/* send our information to the quake server */
|
||||
sendto(qfd, buffer, strlen(buffer), 0, (struct sockaddr *)&qsock, sizeof(struct sockaddr));
|
||||
gettimeofday(&q_tv, NULL);
|
||||
|
||||
strncpy(q_server, server, 256);
|
||||
q_type = game;
|
||||
add_socketread(qfd, port, 0, server, q_timer, NULL);
|
||||
add_sockettimeout(qfd, 5, q_timeout);
|
||||
}
|
||||
|
||||
int pub_proc(char *which, char *str, char **unused) {
|
||||
char *loc, *nick, *chan, *cmd, *serv;
|
||||
int port = 0;
|
||||
|
||||
if(qbx_on == 0) return 1;
|
||||
loc = LOCAL_COPY(str);
|
||||
nick = next_arg(loc, &loc);
|
||||
chan = next_arg(loc, &loc);
|
||||
cmd = next_arg(loc, &loc);
|
||||
if(cmd && *cmd != '!') return 1;
|
||||
if(my_stricmp(cmd, Q3A_COMMAND) && my_stricmp(cmd, Q2_COMMAND) && my_stricmp(cmd, QW_COMMAND))
|
||||
return 1;
|
||||
serv = next_arg(loc, &loc);
|
||||
if(serv == NULL) {
|
||||
privmsg(chan, "%s: Give me a server to query", nick);
|
||||
return 1;
|
||||
}
|
||||
if(querying == 1) {
|
||||
privmsg(chan, "%s: A query is already in progress", nick);
|
||||
return 1;
|
||||
}
|
||||
if(strchr(serv, ':')) {
|
||||
serv = strtok(serv, ":");
|
||||
port = atoi(strtok(NULL, ""));
|
||||
}
|
||||
else
|
||||
port = 0;
|
||||
strncpy(q_chan, chan, 256);
|
||||
if(!my_stricmp(cmd, Q3A_COMMAND)) { /* quake3 server (my fav =) */
|
||||
if(port == 0) port = Q3A_GAME_PORT;
|
||||
query_q_server(serv, port, 3);
|
||||
return 1;
|
||||
}
|
||||
else if(!my_stricmp(cmd, Q2_COMMAND)) { /* quake2 server */
|
||||
if(port == 0) port = Q2_GAME_PORT;
|
||||
query_q_server(serv, port, 2);
|
||||
return 1;
|
||||
}
|
||||
else if(!my_stricmp(cmd, QW_COMMAND)) { /* quakeworld server */
|
||||
if(port == 0) port = QW_GAME_PORT;
|
||||
query_q_server(serv, port, 1);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(qbx_cmd)
|
||||
{
|
||||
if(!my_stricmp(args, "on")) {
|
||||
qbx_on = 1;
|
||||
put_it("Qbx turned on");
|
||||
return;
|
||||
}
|
||||
if(!my_stricmp(args, "off")) {
|
||||
qbx_on = 0;
|
||||
put_it("Qbx turned off");
|
||||
return;
|
||||
}
|
||||
userage("QBX", helparg);
|
||||
}
|
||||
|
||||
int Qbx_Init(IrcCommandDll **intp, Function_ptr *global_table) {
|
||||
initialize_module("qbx");
|
||||
add_module_proc(HOOK_PROC, "qbx", NULL, "* % !q*", PUBLIC_LIST, 1, NULL, pub_proc);
|
||||
add_module_proc(HOOK_PROC, "qbx", NULL, "* % !q*", PUBLIC_OTHER_LIST, 1, NULL, pub_proc);
|
||||
add_module_proc(COMMAND_PROC, "qbx", "qbx", NULL, 0, 0, qbx_cmd, "<on|off>\n- Turns Qbx on or off");
|
||||
put_it("Qbx %s loaded", QBX_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *Qbx_Version(IrcCommandDll **intp) {
|
||||
return QBX_VERSION;
|
||||
}
|
||||
16
dll/qbx/qbx.h
Normal file
16
dll/qbx/qbx.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#define QBX_VERSION "0.5"
|
||||
|
||||
struct quake_variable {
|
||||
char name[256];
|
||||
char value[256];
|
||||
};
|
||||
|
||||
#define Q3A_COMMAND "!q3a"
|
||||
#define QW_COMMAND "!qw"
|
||||
#define Q2_COMMAND "!q2"
|
||||
#define HL_COMMAND "!hl"
|
||||
|
||||
#define Q3A_GAME_PORT 27960
|
||||
#define QW_GAME_PORT 27500
|
||||
#define Q2_GAME_PORT 27910
|
||||
#define HL_GAME_PORT 27015
|
||||
Reference in New Issue
Block a user