|
From: <l-...@us...> - 2008-01-13 19:39:08
|
Revision: 817
http://xqf.svn.sourceforge.net/xqf/?rev=817&view=rev
Author: l-n
Date: 2008-01-13 11:39:13 -0800 (Sun, 13 Jan 2008)
Log Message:
-----------
ottd support
Modified Paths:
--------------
trunk/xqf/src/game.c
trunk/xqf/src/games.c
trunk/xqf/src/games.xml
trunk/xqf/src/pixmaps.c
trunk/xqf/src/source.c
trunk/xqf/src/xqf.h
Added Paths:
-----------
trunk/xqf/src/xpm/openttd.xpm
Modified: trunk/xqf/src/game.c
===================================================================
--- trunk/xqf/src/game.c 2008-01-13 19:19:57 UTC (rev 816)
+++ trunk/xqf/src/game.c 2008-01-13 19:39:13 UTC (rev 817)
@@ -67,6 +67,7 @@
static struct player *un_parse_player(char *tokens[], int num, struct server *s);
static struct player *descent3_parse_player(char *tokens[], int num, struct server *s);
static struct player *savage_parse_player (char *token[], int n, struct server *s);
+static struct player *ottd_parse_player(char *tokens[], int num, struct server *s);
static void quake_parse_server (char *tokens[], int num, struct server *s);
@@ -80,6 +81,7 @@
static void bf1942_analyze_serverinfo (struct server *s);
static void descent3_analyze_serverinfo (struct server *s);
static void savage_analyze_serverinfo (struct server *s);
+static void ottd_analyze_serverinfo (struct server *s);
static int quake_config_is_valid (struct server *s);
static int config_is_valid_generic (struct server *s);
@@ -103,6 +105,7 @@
static int savage_exec (const struct condef *con, int forkit);
static int netpanzer_exec (const struct condef *con, int forkit);
static int descent3_exec (const struct condef *con, int forkit);
+static int ottd_exec (const struct condef *con, int forkit);
/*
static GList *q1_custom_cfgs (struct game* this, char *dir, char *game);
@@ -587,6 +590,11 @@
return q2_parse_player(token, n, s);
}
+static struct player *ottd_parse_player (char *token[], int n, struct server *s)
+{
+ return q2_parse_player(token, n, s);
+}
+
static void quake_parse_server (char *token[], int n, struct server *server) {
/*
This does both Quake (?) and Unreal servers
@@ -1685,6 +1693,25 @@
}
}
+static void ottd_analyze_serverinfo (struct server *s) {
+ char **info_ptr;
+
+ /* Clear out the flags */
+ s->flags = 0;
+
+ if ((games[s->type].flags & GAME_SPECTATE) != 0)
+ s->flags |= SERVER_SPECTATE;
+
+ for (info_ptr = s->info; info_ptr && *info_ptr; info_ptr += 2) {
+ if (!strcmp(*info_ptr, "password") && strcmp(info_ptr[1],"0") )
+ {
+ s->flags |= SERVER_PASSWORD;
+ if (games[s->type].flags & GAME_SPECTATE)
+ s->flags |= SERVER_SP_PASSWORD;
+ }
+ }
+}
+
static int quake_config_is_valid (struct server *s) {
struct stat stat_buf;
char *cfgdir;
@@ -2975,6 +3002,33 @@
}
+// OTTD: only supports -n
+static int ottd_exec(const struct condef *con, int forkit) {
+ char *argv[32];
+ int argi = 0;
+ char *cmd;
+ struct game *g = &games[con->s->type];
+ int retval;
+
+ cmd = strdup_strip (g->cmd);
+
+ argv[argi++] = strtok (cmd, delim);
+ while ((argv[argi] = strtok (NULL, delim)) != NULL)
+ argi++;
+
+ if (con->server) {
+ argv[argi++] = "-n";
+ argv[argi++] = con->server;
+ }
+
+ argv[argi] = NULL;
+
+ retval = client_launch_exec (forkit, g->real_dir, argv, con->s);
+
+ g_free (cmd);
+ return retval;
+}
+
static char *dir_custom_cfg_filter (const char *dir, const char *str) {
static const char *cfgext[] = { ".cfg", ".scr", ".rc", NULL };
const char **ext;
Modified: trunk/xqf/src/games.c
===================================================================
--- trunk/xqf/src/games.c 2008-01-13 19:19:57 UTC (rev 816)
+++ trunk/xqf/src/games.c 2008-01-13 19:39:13 UTC (rev 817)
@@ -47,6 +47,7 @@
static char* stringlist045[] = { "warsow", NULL };
static char* stringlist046[] = { "base", NULL };
static char* stringlist047[] = { "tremulous", NULL };
+static char* stringlist048[] = { "openttd", NULL };
struct game games[] = {
{
type : Q1_SERVER,
@@ -972,6 +973,27 @@
command : stringlist047,
},
{
+ type : OTTD_SERVER,
+ flags : GAME_CONNECT,
+ name : "OpenTTD",
+ default_port : 3979,
+ default_master_port : 3978,
+ id : "OTTDS",
+ qstat_str : "OTTDS",
+ qstat_option : "-ottds",
+ qstat_master_option : "-ottdm",
+ icon : "openttd.xpm",
+ parse_player : ottd_parse_player,
+ parse_server : quake_parse_server,
+ analyze_serverinfo : ottd_analyze_serverinfo,
+ config_is_valid : config_is_valid_generic,
+ exec_client : ottd_exec,
+ custom_cfgs : quake_custom_cfgs,
+ save_info : quake_save_info,
+ default_home : "~/.openttd",
+ command : stringlist048,
+ },
+ {
type : GPS_SERVER,
flags : GAME_CONNECT,
name : "Generic Gamespy",
Modified: trunk/xqf/src/games.xml
===================================================================
--- trunk/xqf/src/games.xml 2008-01-13 19:19:57 UTC (rev 816)
+++ trunk/xqf/src/games.xml 2008-01-13 19:39:13 UTC (rev 817)
@@ -744,6 +744,25 @@
<pd>tremulous_private</pd>
</game>
<game>
+ <type>OTTD_SERVER</type>
+ <flags>GAME_CONNECT</flags>
+ <name>OpenTTD</name>
+ <default_port>3979</default_port>
+ <default_master_port>3978</default_master_port>
+ <id>OTTDS</id>
+ <qstat_str>OTTDS</qstat_str>
+ <qstat_option>-ottds</qstat_option>
+ <qstat_master_option>-ottdm</qstat_master_option>
+ <icon>openttd.xpm</icon>
+ <parse_player>ottd_parse_player</parse_player>
+ <analyze_serverinfo>ottd_analyze_serverinfo</analyze_serverinfo>
+ <config_is_valid>config_is_valid_generic</config_is_valid>
+ <exec_client>ottd_exec</exec_client>
+ <custom_cfgs>quake_custom_cfgs</custom_cfgs>
+ <command>openttd</command>
+ <default_home>~/.openttd</default_home>
+ </game>
+ <game>
<type>GPS_SERVER</type>
<name>Generic Gamespy</name>
<flags>GAME_CONNECT</flags>
Modified: trunk/xqf/src/pixmaps.c
===================================================================
--- trunk/xqf/src/pixmaps.c 2008-01-13 19:19:57 UTC (rev 816)
+++ trunk/xqf/src/pixmaps.c 2008-01-13 19:39:13 UTC (rev 817)
@@ -81,6 +81,7 @@
#include "xpm/jk3.xpm"
#include "xpm/doom3.xpm"
#include "xpm/etqw.xpm"
+#include "xpm/openttd.xpm"
#include "xpm/green-plus.xpm"
#include "xpm/red-minus.xpm"
Modified: trunk/xqf/src/source.c
===================================================================
--- trunk/xqf/src/source.c 2008-01-13 19:19:57 UTC (rev 816)
+++ trunk/xqf/src/source.c 2008-01-13 19:39:13 UTC (rev 817)
@@ -1162,6 +1162,8 @@
"ADD TREMULOUS master://master.tremulous.net:30710 tremulous.net",
+ "ADD OTTDS master://master.openttd.org OpenTTD",
+
"ADD QS lan://255.255.255.255 LAN",
"ADD QWS lan://255.255.255.255 LAN",
"ADD Q2S lan://255.255.255.255 LAN",
Added: trunk/xqf/src/xpm/openttd.xpm
===================================================================
--- trunk/xqf/src/xpm/openttd.xpm (rev 0)
+++ trunk/xqf/src/xpm/openttd.xpm 2008-01-13 19:39:13 UTC (rev 817)
@@ -0,0 +1,36 @@
+/* XPM */
+static char * openttd_xpm[] = {
+"16 16 17 1",
+" c None",
+". c #4D3835",
+"+ c #6E5029",
+"@ c #52602A",
+"# c #866747",
+"$ c #539B34",
+"% c #A1805B",
+"& c #F47006",
+"* c #DB873F",
+"= c #5DD036",
+"- c #F79236",
+"; c #CBA47F",
+"> c #F4A757",
+", c #C1B3A4",
+"' c #DECDB9",
+") c #E2E5E3",
+"! c #F2FFFF",
+" . ",
+" %# ",
+" %>># ",
+" %>%;># ",
+" %>%)'%># ",
+" #>,)')!>>+ ",
+" #>>,),;,;--+ ",
+" #>>-*)!)%-&-&+ ",
+" +---%*;)!;&&&. ",
+" $@&&,'%;''&&@$ ",
+" $=@&;))))-&@=$ ",
+" $=+&&;'&&@=$ ",
+" ==+&**&@=$ ",
+" ==+&&+=$ ",
+" $ ++ $ ",
+" "};
Modified: trunk/xqf/src/xqf.h
===================================================================
--- trunk/xqf/src/xqf.h 2008-01-13 19:19:57 UTC (rev 816)
+++ trunk/xqf/src/xqf.h 2008-01-13 19:39:13 UTC (rev 817)
@@ -136,6 +136,7 @@
NEXUIZ_SERVER,
WARSOW_SERVER,
TREMULOUS_SERVER,
+ OTTD_SERVER,
GPS_SERVER,
UNKNOWN_SERVER
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|