tAddition of -P, --player command line option to allow setting of the default p… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit c95176f1eaf949e99e940ba6253b826bb046a28c | |
parent 7c658ae1d40867827eb7b8e828bef15b1f251c48 | |
Author: Ben Webb <[email protected]> | |
Date: Mon, 2 Jun 2003 18:40:16 +0000 | |
Addition of -P, --player command line option to allow setting of the default | |
player name. | |
Diffstat: | |
M ChangeLog | 2 ++ | |
M doc/commandline.html | 5 ++++- | |
M doc/dopewars.6.in | 3 +++ | |
M src/curses_client/curses_client.c | 14 +++++++++----- | |
M src/dopewars.c | 17 ++++++++++++++--- | |
M src/dopewars.h | 3 ++- | |
M src/gui_client/gtk_client.c | 3 +++ | |
7 files changed, 37 insertions(+), 10 deletions(-) | |
--- | |
diff --git a/ChangeLog b/ChangeLog | |
t@@ -5,6 +5,8 @@ cvs | |
larger than 80x24 | |
- Fix for a crash encountered if you drop drugs and then encounter | |
the cops | |
+ - Addition of -P, --player command line option to set the player name | |
+ to use (thanks to Michael Mitton) | |
1.5.8 21-10-2002 | |
- Options dialog now allows sounds for all supported game events to be set | |
diff --git a/doc/commandline.html b/doc/commandline.html | |
t@@ -139,6 +139,9 @@ used where available, falling back to a text-mode client i… | |
<dd>When running a dopewars client, forces the use of a text-mode (curses | |
or console mode) interface, even if graphics are available.</dd> | |
+<dt><b>-P <i>name</i></b>, <b>--player=<i>name</i></b></dt> | |
+<dd>Sets the default player name.</dd> | |
+ | |
<dt><b>-C <i>file</i></b>, <b>--convert=<i>file</i></b></dt> | |
<dd>Converts a high score file from an older version of dopewars to the format | |
used by the current version. The old high score file is replaced with a new | |
t@@ -169,7 +172,7 @@ contact details.</dd> | |
<li><a href="index.html">Main index</a></li> | |
</ul> | |
<p> | |
- Last update: <b>15-07-2002</b><br /> | |
+ Last update: <b>02-06-2003</b><br /> | |
Valid <a href="http://validator.w3.org/check/referer">XHTML 1.1</a> | |
</p> | |
</body> | |
diff --git a/doc/dopewars.6.in b/doc/dopewars.6.in | |
t@@ -60,6 +60,9 @@ Force the use of a graphical client (GTK+ or Win32) | |
Force the use of a text-mode (curses) client (by default, a windowed client | |
is used when possible) | |
.TP | |
+\fB\-P\fR, \fB\-\-player\fR=\fINAME\fR | |
+Sets the default player name | |
+.TP | |
\fB\-C\fR, \fB\-\-convert\fR=\fIFILE\fR | |
Convert a high score file used by dopewars-1.5.1 or earlier to the format | |
used by more recent versions | |
diff --git a/src/curses_client/curses_client.c b/src/curses_client/curses_clien… | |
t@@ -2336,11 +2336,15 @@ static void Curses_DoGame(Player *Play) | |
attrset(TextAttr); | |
clear_bottom(); | |
buf = NULL; | |
- do { | |
- g_free(buf); | |
- buf = nice_input(_("Hey dude, what's your name? "), get_ui_area_top() + 1, | |
- 1, FALSE, OldName, '\0'); | |
- } while (buf[0] == 0); | |
+ if (PlayerName && PlayerName[0]) { | |
+ buf = g_strdup(PlayerName); | |
+ } else { | |
+ do { | |
+ g_free(buf); | |
+ buf = nice_input(_("Hey dude, what's your name? "), | |
+ get_ui_area_top() + 1, 1, FALSE, OldName, '\0'); | |
+ } while (buf[0] == 0); | |
+ } | |
#if NETWORKING | |
if (WantNetwork) { | |
if (!ConnectToServer(Play)) { | |
diff --git a/src/dopewars.c b/src/dopewars.c | |
t@@ -81,7 +81,7 @@ gboolean Network, Client, Server, WantAntique = FALSE, UseSo… | |
unsigned Port = 7902; | |
gboolean Sanitized, ConfigVerbose, DrugValue, Antique = FALSE; | |
gchar *HiScoreFile = NULL, *ServerName = NULL; | |
-gchar *ServerMOTD = NULL, *BindAddress = NULL; | |
+gchar *ServerMOTD = NULL, *BindAddress = NULL, *PlayerName = NULL; | |
struct DATE StartDate = { | |
1, 12, 1984 | |
t@@ -2602,6 +2602,7 @@ Drug dealing game based on \"Drug Wars\" by John E. Dell… | |
client (GTK+ or Win32)\n\ | |
-t, --text-client force the use of a text-mode client (curses) (by\n\ | |
default, a windowed client is used when possible)\… | |
+ -P, --player=NAME set player name to \"NAME\"\n\ | |
-C, --convert=FILE convert an \"old format\" score file to the new form… | |
PluginHelp(); | |
g_print(_(" -h, --help display this help information\n\ | |
t@@ -2635,6 +2636,7 @@ Drug dealing game based on \"Drug Wars\" by John E. Dell… | |
-w force the use of a graphical (windowed) client (GTK+ or Win32)\n\ | |
-t force the use of a text-mode client (curses)\n\ | |
(by default, a windowed client is used when possible)\n\ | |
+ -P name set player name to \"name\"\n\ | |
-C file convert an \"old format\" score file to the new format\n\ | |
-A connect to a locally-running server for administration\n"), | |
DPDATADIR); | |
t@@ -2650,7 +2652,7 @@ struct CMDLINE *ParseCmdLine(int argc, char *argv[]) | |
{ | |
int c; | |
struct CMDLINE *cmdline = g_new0(struct CMDLINE, 1); | |
- static const gchar *options = "anbchvf:o:sSp:g:r:wtC:l:NAu:"; | |
+ static const gchar *options = "anbchvf:o:sSp:g:r:wtC:l:NAu:P:"; | |
#ifdef HAVE_GETOPT_LONG | |
static const struct option long_options[] = { | |
t@@ -2668,6 +2670,7 @@ struct CMDLINE *ParseCmdLine(int argc, char *argv[]) | |
{"ai-player", no_argument, NULL, 'c'}, | |
{"windowed-client", no_argument, NULL, 'w'}, | |
{"text-client", no_argument, NULL, 't'}, | |
+ {"player", required_argument, NULL, 'P'}, | |
{"convert", required_argument, NULL, 'C'}, | |
{"logfile", required_argument, NULL, 'l'}, | |
{"admin", no_argument, NULL, 'A'}, | |
t@@ -2679,7 +2682,8 @@ struct CMDLINE *ParseCmdLine(int argc, char *argv[]) | |
#endif | |
cmdline->scorefile = cmdline->servername = cmdline->pidfile | |
- = cmdline->logfile = cmdline->plugin = cmdline->convertfile = NULL; | |
+ = cmdline->logfile = cmdline->plugin = cmdline->convertfile | |
+ = cmdline->playername = NULL; | |
cmdline->configs = NULL; | |
cmdline->colour = cmdline->network = TRUE; | |
cmdline->client = CLIENT_AUTO; | |
t@@ -2748,6 +2752,9 @@ struct CMDLINE *ParseCmdLine(int argc, char *argv[]) | |
case 't': | |
cmdline->client = CLIENT_CURSES; | |
break; | |
+ case 'P': | |
+ AssignName(&cmdline->playername, optarg); | |
+ break; | |
case 'C': | |
AssignName(&cmdline->convertfile, optarg); | |
cmdline->convert = TRUE; | |
t@@ -2771,6 +2778,7 @@ void FreeCmdLine(struct CMDLINE *cmdline) | |
g_free(cmdline->logfile); | |
g_free(cmdline->plugin); | |
g_free(cmdline->convertfile); | |
+ g_free(cmdline->playername); | |
for (list = cmdline->configs; list; list = g_slist_next(list)) { | |
g_free(list->data); | |
t@@ -2816,6 +2824,9 @@ void InitConfiguration(struct CMDLINE *cmdline) | |
if (cmdline->servername) { | |
AssignName(&ServerName, cmdline->servername); | |
} | |
+ if (cmdline->playername) { | |
+ AssignName(&PlayerName, cmdline->playername); | |
+ } | |
if (cmdline->pidfile) { | |
AssignName(&PidFile, cmdline->pidfile); | |
} | |
diff --git a/src/dopewars.h b/src/dopewars.h | |
t@@ -182,7 +182,7 @@ extern int NumLocation, NumGun, NumCop, NumDrug, NumSubway… | |
NumStoppedTo; | |
extern int DebtInterest, BankInterest; | |
extern gchar *HiScoreFile, *ServerName, *ConvertFile, *ServerMOTD, | |
- *BindAddress; | |
+ *BindAddress, *PlayerName; | |
#ifdef CYGWIN | |
extern gboolean MinToSysTray; | |
#else | |
t@@ -359,6 +359,7 @@ struct CMDLINE { | |
gboolean convert, admin, ai, server, notifymeta; | |
gboolean setport; | |
gchar *scorefile, *servername, *pidfile, *logfile, *plugin, *convertfile; | |
+ gchar *playername; | |
unsigned port; | |
ClientType client; | |
GSList *configs; | |
diff --git a/src/gui_client/gtk_client.c b/src/gui_client/gtk_client.c | |
t@@ -2228,6 +2228,9 @@ gboolean GtkLoop(int *argc, char **argv[], | |
/* Create the main player */ | |
ClientData.Play = g_new(Player, 1); | |
FirstClient = AddPlayer(0, ClientData.Play, FirstClient); | |
+ if (PlayerName && PlayerName[0]) { | |
+ SetPlayerName(ClientData.Play, PlayerName); | |
+ } | |
gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_END); | |
gtk_vbutton_box_set_layout_default(GTK_BUTTONBOX_SPREAD); |