diff --git a/Makefile b/Makefile index ffdec28..251ab96 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,6 @@ install: all cp -r tileset $(DESTDIR) mkdir -p $(MANDIR) cp doc/iiag.6 $(MANDIR) - gzip $(MANDIR)/iiag.6 + gzip -f $(MANDIR)/iiag.6 -include $(CLIENT_DEPS) $(SERVER_DEPS) diff --git a/doc/config.md b/doc/config.md index 15fd661..97ff579 100644 --- a/doc/config.md +++ b/doc/config.md @@ -33,7 +33,7 @@ Field Types String | A string value that is terminated with an Space. Note an equal sign also terminates the string. Escape characters (the backslash `\`) can be used to allow a space or equal sign to exist in the string. Boolean | Either `true` or `false`. If neither, it defaults to `false` and logs an error. Integer | A decimal numerical value that represents an integer. - Control | A value representing a key to press on the keyboard in order to utilize a control in game. The format is usually `a` for the A-key, `A` for shift+A-key, and so on. Digits are used for literial keycode values. The special values `%left%`, `%right%`, `%up%`, and `%down%` can be used to represent the arrow-keys. + Control | A value representing a key to press on the keyboard in order to utilize a control in game. The format is dependent on the tileset type, which influences the input backend. For ncurses backends, the literal key name is used when possible (e.g. 'a' for the a-key, 'A' for shift-a), and name strings like 'left' for the left arrow key. Fields ------ @@ -41,22 +41,44 @@ Fields Field Name | Type | Description ------------------|---------|------------- lua-init | string | Specifies the initial lua file to run, like `-i`. + server-ip | string | The IP address of the server to connect to. Unlike `-n`, does nothing unless multiplayer is set. + log-file | string | Specifies the path to the file to log to, like `-l`. + tileset-file | string | The path to the file containing the tileset, like `-t`. show-all | boolean | Specifies whether everything is shown to the player or not, like `-s`. forget-walls | boolean | Specifies whether wall-forgetting is enabled or not, like `-f`. - all-alone | boolean | Specifies whether all-alone mode is enabled, like `-l`. + all-alone | boolean | Specifies whether all-alone mode is enabled, like `-a`. god-mode | boolean | Specifies whether the player may avoid damage during the game, like `-g`. + real-time | boolean | Specifies whether the game should be run in real-time mode, like `-r`. + multiplayer | boolean | Specifies whether the game should try to connect to a remote server, a side effect of `-n` normally. + log-stderr | boolean | Specifies whether logging should be done additionally to stderr or not, like `-e`. + port | integer | The port to connect to on the multiplayer server. log-level | integer | Specifies the verbosity of the log. Valid values are: 0=ALL (no filtering), 1=DEBUG, 2=INFO, 3=NOTICE, 4=WARNING, 5=ERROR. The setting is inclusive. throw-anim-delay | integer | The delay between 'frames' of the throwing animation. 0 indicates the lack of animation - ctrl-up | control | How the player moves up. - ctrl-down | control | How the player moves down. - ctrl-left | control | How the player moves left. - ctrl-right | control | How the player moves right. - ctrl-uleft | control | How the player moves up-left. - ctrl-uright | control | How the player moves up-right. - ctrl-dleft | control | How the player moves down-left. - ctrl-dright | control | How the player moves down-right. - ctrl-scrl-center | control | What key centers the player's scrolling on the player. - ctrl-scrl-up | control | How the player scrolls up. - ctrl-scrl-down | control | How the player scrolls down. - ctrl-scrl-left | control | How the player scrolls left. - ctrl-scrl-right | control | How the player scrolls right. + move-up | control | How the player moves up. + move-down | control | How the player moves down. + move-left | control | How the player moves left. + move-right | control | How the player moves right. + move-uleft | control | How the player moves up-left. + move-uright | control | How the player moves up-right. + move-dleft | control | How the player moves down-left. + move-dright | control | How the player moves down-right. + scroll-center | control | What key centers the player's scrolling on the player. + scroll-up | control | How the player scrolls up. + scroll-down | control | How the player scrolls down. + scroll-left | control | How the player scrolls left. + scroll-right | control | How the player scrolls right. + inventory | control | How the player looks at their inventory. + equipment | control | How the player looks at their equipped items. + pickup | control | How the player picks up an item. + drop | control | How the player drops an item. + consume | control | How the player consumes (eats or quaffs) an item. + equip | control | How the player equips (wears or weilds) an item. + throw | control | How the player throws an item. + stance-neutral | control | How the player switchs their stance to neutral. + stance-defend | control | How the player switchs their stance to defensive. + stance-attack | control | How the player switchs their stance to attacking. + idle | control | How to ignore a turn. + disp-ctrl | control | How to display the control configuration menu. + command | control | How to display the command prompt interface. + + diff --git a/doc/iiag.6 b/doc/iiag.6 index 2af03cd..a2a8013 100644 --- a/doc/iiag.6 +++ b/doc/iiag.6 @@ -28,11 +28,20 @@ the mighty land fiish. Or something like that. Like other terminal games, creatures and other objects are represented as symbols when played in the terminal, and will eventually support other graphical environments as well. + +.PP +It is not currently possible to win the game. .SH OPTIONS .TP +\fB\-a\fR +turn on lonely mode, where there are no monsters. (debugging) +.TP \fB\-c\fR FILE play the game using the specified configuration file .TP +\fB\-e\fR +log errors to stderr as well as the log file +.TP \fB\-f\fR turn on wall forgetting .TP @@ -45,8 +54,11 @@ display the useful help text \fB\-i\fR FILE run with a specific lua init file .TP -\fB\-l\fR -turn on lonely mode, where there are no monsters. (debugging) +\fB\-l\fR FILE +specifies the file to log to +.TP +\fB\-L\fR LOG-LEVEL +specifies the log level to use .TP \fB\-n\fR ADDRESS connect to server for multiplayer @@ -59,9 +71,6 @@ show everything .TP \fB\-t\fR FILE specify the tileset to use - -.PP -It is not currently possible to win the game. .SH AUTHORS Chris Harding, Austin Lund, Eric Richter, Alex Macri, Adam "Baha" Kimball, et. al. .SH SEE ALSO diff --git a/src/config.c b/src/config.c index 285bd71..7f3cdd3 100644 --- a/src/config.c +++ b/src/config.c @@ -18,6 +18,14 @@ config_t config = { NULL, // cfg_file "script/init.lua", // lua_init + // log_file +#ifdef SERVER + "server.log", +#else + "iiag.log", +#endif + + // tileset_file // The default tileset changes based on what is supported // TODO unicode support should probably be detected at runtime #ifdef WITH_NCURSES @@ -34,6 +42,15 @@ config_t config = { 0, // real_time 0, // multiplayer LOG_INFO, // log_level + + // log_stderr + // The server by default also logs to stderr, otherwise not +#ifdef SERVER + 1, +#else + 0, +#endif + 20, // throw_anim_delay }; @@ -52,12 +69,15 @@ struct field { static const struct field cfg_fields[] = { { STRING, "lua-init", &config.lua_init }, { STRING, "server-ip", &config.ip }, + { STRING, "log-file", &config.log_file }, { STRING, "tileset-file", &config.tileset_file }, { BOOLEAN, "show-all", &config.show_all }, { BOOLEAN, "forget-walls", &config.forget_walls }, { BOOLEAN, "all-alone", &config.all_alone }, { BOOLEAN, "god-mode", &config.god_mode }, { BOOLEAN, "real-time", &config.real_time }, + { BOOLEAN, "multiplayer", &config.multiplayer }, + { BOOLEAN, "log-stderr", &config.log_stderr }, { INTEGER, "log-level", &config.log_level }, { INTEGER, "throw-anim-delay", &config.throw_anim_delay }, { INTEGER, "port", &config.port }, @@ -255,8 +275,12 @@ static void print_help() { fprintf(stderr, "\noptions:\n" + " -a\n" + " Turn on all alone mode, for debugging purposes.\n" " -c [config file]\n" " Specify the configuration file to use (- for stdin).\n" + " -e\n" + " Log errors to stderr as well as the log file.\n" " -f\n" " Turn on wall forgetting.\n" " -g\n" @@ -265,8 +289,8 @@ static void print_help() " Display this useful information.\n" " -i [lua init file]\n" " The initial lua script to run.\n" - " -l\n" - " Turn on all alone mode, for debugging purposes.\n" + " -l [log file]\n" + " Set the log file to use.\n" " -L [log level]\n" " Set the logging level.\n" " Supported log levels:\n" @@ -312,7 +336,7 @@ void init_config(int argc, char ** argv) case 'f': config.forget_walls = 1; break; - case 'l': + case 'a': config.all_alone = 1; break; case 'g': @@ -321,6 +345,9 @@ void init_config(int argc, char ** argv) case 'r': config.real_time = 1; break; + case 'e': + config.log_stderr = 1; + break; #ifndef SERVER case 'n': config.multiplayer = 1; @@ -330,6 +357,9 @@ void init_config(int argc, char ** argv) break; #endif + case 'l': + config.log_file = argv[++i]; + break; case 'L': config.log_level = (log_level_t) atoi(argv[++i]); break; diff --git a/src/config.h b/src/config.h index cc81186..7d52247 100644 --- a/src/config.h +++ b/src/config.h @@ -11,6 +11,7 @@ typedef struct config { const char * cfg_file; const char * lua_init; + const char * log_file; const char * tileset_file; const char * ip; int port; @@ -21,6 +22,7 @@ typedef struct config { int real_time; int multiplayer; log_level_t log_level; + int log_stderr; int throw_anim_delay; } config_t; diff --git a/src/log.c b/src/log.c index b77247c..4798161 100644 --- a/src/log.c +++ b/src/log.c @@ -10,12 +10,6 @@ #include "introspection.h" #include "config.h" -#ifdef SERVER -const char * log_file = "server.log"; -#else -const char * log_file = "iiag.log"; -#endif - static clock_t sclock; static char * level_names[] = { @@ -27,7 +21,6 @@ static char * level_names[] = { "ERROR" }; - void wrlog(log_level_t loglevel, const char * fmt, ...) { #ifdef WITH_INTROSPECTION @@ -45,7 +38,7 @@ void wrlog(log_level_t loglevel, const char * fmt, ...) if(loglevel < config.log_level) return; if (logf == NULL) { - logf = fopen(log_file, "a"); + logf = fopen(config.log_file, "a"); if (logf == NULL) return; // TODO do something more useful here? fprintf(logf, "===============================================================================\n"); @@ -72,16 +65,16 @@ void wrlog(log_level_t loglevel, const char * fmt, ...) fflush(logf); va_end(vl); - // Also write to stdout on servers -#ifdef SERVER - va_start(vl, fmt); + // possibly also write to stderr + if (config.log_stderr) { + va_start(vl, fmt); - HEADER(stderr); - vfprintf(stderr, fmt, vl); - fputc('\n', stderr); + HEADER(stderr); + vfprintf(stderr, fmt, vl); + fputc('\n', stderr); - va_end(vl); -#endif + va_end(vl); + } } void start_timer(void)