summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-24 17:24:21 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-24 17:24:21 +0000
commitcb28e0f9ad004dc4c09664d09cad4e1c24cacee8 (patch)
tree2c8508318d76ff6ea4f7f9c9c639250767c1e28d
parent055b9f2b1ee8e5aa131d3febdf82c789e023fefe (diff)
downloadcrawl-ref-cb28e0f9ad004dc4c09664d09cad4e1c24cacee8.tar.gz
crawl-ref-cb28e0f9ad004dc4c09664d09cad4e1c24cacee8.zip
Trunk->0.3 merge (2882-2883, 2885, 2908): Fixes for Unicode handling, error reporting for .crawlrc errors, turn count tracking.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2909 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/INSTALL13
-rw-r--r--crawl-ref/source/acr.cc2
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/initfile.cc47
-rw-r--r--crawl-ref/source/libunix.cc7
-rw-r--r--crawl-ref/source/makefile.obj1
-rw-r--r--crawl-ref/source/makefile.unix35
-rw-r--r--crawl-ref/source/newgame.cc8
-rw-r--r--crawl-ref/source/state.cc39
-rw-r--r--crawl-ref/source/state.h5
-rw-r--r--crawl-ref/source/stuff.cc8
11 files changed, 133 insertions, 34 deletions
diff --git a/crawl-ref/INSTALL b/crawl-ref/INSTALL
index 871eadf95d..32a4304674 100644
--- a/crawl-ref/INSTALL
+++ b/crawl-ref/INSTALL
@@ -368,7 +368,18 @@ not UTF-8, you can force it to UTF-8 on most systems by doing "export
LC_ALL=en_US.UTF-8" or the equivalent, depending on your language
locale and what shell you're using.
+Crawl tries to use en_US.UTF-8 as its default Unicode locale. If you
+do not have this locale installed, but do have some other UTF-8 locale,
+you can tell Crawl to use your preferred UTF-8 locale by setting
+UNICODE_LOCALE = ${foo}.UTF-8 in makefile.unix, where ${foo} is your
+locale name.
+
+You may not want to embed the locale in Crawl itself, but have Crawl
+use the locale as set in the environment LC_* variables. In such
+cases, you can use UNICODE_LOCALE = . in makefile.unix. Crawl will
+then use the locale as set in your environment.
+
If you're playing Crawl on a remote machine, the remote Crawl should be
built with Unicode support, it needs to have a UTF-8 locale installed,
*and* your local terminal (where you're running telnet/ssh) needs to be
-able to decode UTF-8.
+able to decode UTF-8. \ No newline at end of file
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index a32a1f67e4..9eddc78791 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -2330,7 +2330,7 @@ static void world_reacts()
if (you.num_turns != -1)
{
you.num_turns++;
- if (env.turns_on_level + 1 > env.turns_on_level)
+ if (env.turns_on_level < INT_MAX)
env.turns_on_level++;
update_turn_count();
}
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index f937f71c5f..72db529680 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1401,6 +1401,8 @@ public:
bool messaging; // Check for messages.
#endif
+ bool suppress_startup_errors;
+
bool mouse_input;
int view_max_width;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index e6bc768a53..c53ee1e455 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -371,12 +371,14 @@ static unsigned curses_attribute(const std::string &field)
int col = field.find(":");
int colour = str_to_colour(field.substr(col + 1));
if (colour == -1)
- fprintf(stderr, "Bad highlight string -- %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad highlight string -- %s\n", field.c_str()));
else
return CHATTR_HILITE | (colour << 8);
}
else if (field != "none")
- fprintf( stderr, "Bad colour -- %s\n", field.c_str() );
+ crawl_state.add_startup_error(
+ make_stringf( "Bad colour -- %s\n", field.c_str() ) );
return CHATTR_NORMAL;
}
@@ -466,7 +468,8 @@ void game_options::set_activity_interrupt(
delay_type delay = get_delay(delay_name);
if (delay == NUM_DELAYS)
{
- fprintf(stderr, "Unknown delay: %s\n", delay_name.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Unknown delay: %s\n", delay_name.c_str()));
return;
}
@@ -483,8 +486,9 @@ void game_options::set_activity_interrupt(
activity_interrupt_type ai = get_activity_interrupt(interrupt);
if (ai == NUM_AINTERRUPTS)
{
- fprintf(stderr, "Delay interrupt name \"%s\" not recognised.\n",
- interrupt.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Delay interrupt name \"%s\" not recognised.\n",
+ interrupt.c_str()));
return;
}
@@ -499,7 +503,8 @@ void game_options::set_activity_interrupt(const std::string &activity_name,
const delay_type delay = get_delay(activity_name);
if (delay == NUM_DELAYS)
{
- fprintf(stderr, "Unknown delay: %s\n", activity_name.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Unknown delay: %s\n", activity_name.c_str()));
return;
}
@@ -597,6 +602,9 @@ void game_options::reset_options()
(1L << 7) | // jewellery
(1L << 3) | // wands
(1L << 4)); // food
+
+ suppress_startup_errors = false;
+
show_inventory_weights = false;
colour_map = true;
clean_map = false;
@@ -866,7 +874,8 @@ void game_options::add_mon_glyph_overrides(const std::string &mons,
int letter = -1;
if (mons.length() == 1)
letter = mons[0] == '_' ? ' ' : mons[0];
-
+
+ bool found = false;
for (int i = 0; i < NUM_MONSTERS; ++i)
{
const monsterentry *me = get_monster_data(i);
@@ -874,8 +883,14 @@ void game_options::add_mon_glyph_overrides(const std::string &mons,
continue;
if (me->showchar == letter || me->name == mons)
+ {
+ found = true;
add_mon_glyph_override(static_cast<monster_type>(i), mdisp);
+ }
}
+ if (!found)
+ crawl_state.add_startup_error(
+ make_stringf("Unknown monster: \"%s\"", mons.c_str()));
}
mon_display game_options::parse_mon_glyph(const std::string &s) const
@@ -1643,6 +1658,10 @@ void game_options::read_option_line(const std::string &str, bool runscript)
// should weights be shown on inventory items?
show_inventory_weights = read_bool( field, show_inventory_weights );
}
+ else if (key == "suppress_startup_errors")
+ {
+ suppress_startup_errors = read_bool( field, suppress_startup_errors );
+ }
else if (key == "clean_map")
{
// removes monsters/clouds from map
@@ -2133,7 +2152,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
else if (field == "yes")
wiz_mode = WIZ_YES;
else
- fprintf(stderr, "Unknown wiz_mode option: %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Unknown wiz_mode option: %s\n", field.c_str()));
#endif
}
else if (key == "ban_pickup")
@@ -2184,7 +2204,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
if ( insplit.size() == 0 || insplit.size() > 2 ||
(insplit.size() == 1 && i != 0) )
{
- fprintf(stderr, "Bad hp_colour string: %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad hp_colour string: %s\n", field.c_str()));
break;
}
@@ -2207,7 +2228,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
if ( insplit.size() == 0 || insplit.size() > 2 ||
(insplit.size() == 1 && i != 0) )
{
- fprintf(stderr, "Bad mp_colour string: %s\n", field.c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad mp_colour string: %s\n", field.c_str()));
break;
}
@@ -2228,8 +2250,9 @@ void game_options::read_option_line(const std::string &str, bool runscript)
note_skill_levels.push_back(num);
else
{
- fprintf(stderr, "Bad skill level to note -- %s\n",
- thesplit[i].c_str());
+ crawl_state.add_startup_error(
+ make_stringf("Bad skill level to note -- %s\n",
+ thesplit[i].c_str()));
continue;
}
}
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index c4a64a779e..8667c24e29 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -216,10 +216,13 @@ static void termio_init()
tcsetattr(0, TCSAFLUSH, &game_term);
+ crawl_state.unicode_ok = false;
#ifdef UNICODE_GLYPHS
- if ((crawl_state.unicode_ok = !!setlocale(LC_ALL, UNICODE_LOCALE)))
+ if (setlocale(LC_ALL, UNICODE_LOCALE)
+ && !strcmp(nl_langinfo(CODESET), "UTF-8"))
{
- crawl_state.glyph2strfn = unix_glyph2string;
+ crawl_state.unicode_ok = true;
+ crawl_state.glyph2strfn = unix_glyph2string;
crawl_state.multibyte_strlen = unix_multibyte_strlen;
}
#endif
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index 4bbf544129..460cffcf21 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -75,6 +75,7 @@ spl-cast.o \
spl-util.o \
sqldbm.o \
stash.o \
+state.o \
stuff.o \
tags.o \
terrain.o \
diff --git a/crawl-ref/source/makefile.unix b/crawl-ref/source/makefile.unix
index 36ee1ef1f8..547344631e 100644
--- a/crawl-ref/source/makefile.unix
+++ b/crawl-ref/source/makefile.unix
@@ -17,13 +17,14 @@ DELETE = rm -f
COPY = cp
OS_TYPE = UNIX
-# Change this to y if you want to use Unicode glyphs in the map, and you have
-# libncursesw available.
+# Change this to y (case-sensitive!) if you want to use Unicode glyphs
+# in the map, and you have libncursesw available.
UNICODE_GLYPHS = n
# If you're using UNICODE_GLYPHS=y, and have a preferred Unicode
# (UTF-8) locale you want Crawl to use, you can set it here. The
-# default is en_US.UTF-8.
+# default is en_US.UTF-8. If you'd prefer that Crawl use the locale
+# as set in your environment LC_* variables, use UNICODE_LOCALE = .
UNICODE_LOCALE =
# If you have lex and yacc, set DOYACC to y (lowercase y).
@@ -60,14 +61,14 @@ NDBM_FILE := /usr/include/ndbm.h
HAVE_DBH := $(shell [ -f $(DBH_FILE) ] && echo y)
HAVE_NDBM := $(shell [ -f $(NDBM_FILE) ] && echo y)
-ifeq ($(HAVE_DBH),y)
+ifeq ($(strip $(HAVE_DBH)),y)
ifneq ($(shell grep dbm_open $(DBH_FILE)),)
SELDBM := -DDB_DBH
LIBDBM := -ldb
endif
endif
-ifeq ($(HAVE_NDBM),y)
+ifeq ($(strip $(HAVE_NDBM)),y)
SELDBM ?= -DDB_NDBM
ifeq ($(SELDBM),-DDB_NDBM)
LIBDBM := -ldbm
@@ -79,7 +80,7 @@ SQLLIB := sqlite3
SQLLIBA := lib$(SQLLIB).a
FSQLLIBA := $(SQLSRC)/$(SQLLIBA)
-ifeq ($(LIBDBM),)
+ifeq ($(strip $(LIBDBM)),)
LIBDBM := -L$(SQLSRC) -lsqlite3
EXTRA_INCLUDES += -I$(SQLSRC)
EXTRA_DEPENDS += $(FSQLLIBA)
@@ -93,15 +94,15 @@ CFWARN := -Wall -Wwrite-strings -Wshadow -Wuninitialized -pedantic
CFOTHERS := -O2 -fsigned-char -D$(OS_TYPE) $(EXTRA_FLAGS) -DCLUA_BINDINGS
-ifneq ($(SAVEDIR),)
-CFOTHERS += '-DSAVE_DIR_PATH="$(SAVEDIR)"'
+ifneq ($(strip $(SAVEDIR)),)
+CFOTHERS += '-DSAVE_DIR_PATH="$(strip $(SAVEDIR))"'
endif
-ifneq ($(DATADIR),)
-CFOTHERS += '-DDATA_DIR_PATH="$(DATADIR)"'
+ifneq ($(strip $(DATADIR)),)
+CFOTHERS += '-DDATA_DIR_PATH="$(strip $(DATADIR))"'
endif
-ifeq ($(UNICODE_GLYPHS),y)
+ifeq ($(strip $(UNICODE_GLYPHS)),y)
# Include path for (n)curses with Unicode support.
INCLUDES += -I/usr/include/ncursesw
@@ -110,8 +111,12 @@ INCLUDES += -I/usr/include/ncursesw
LIBCURS = ncursesw
CFOTHERS += -DUNICODE_GLYPHS
-ifneq ($(UNICODE_LOCALE),)
-CFOTHERS += -DUNICODE_LOCALE=\"$(UNICODE_LOCALE)\"
+ifneq ($(strip $(UNICODE_LOCALE)),)
+ifneq ($(strip $(UNICODE_LOCALE)),.)
+CFOTHERS += -DUNICODE_LOCALE=\"$(strip $(UNICODE_LOCALE))\"
+else
+CFOTHERS += -DUNICODE_LOCALE=\"\"
+endif
endif
# The standard ncurses library also supports Unicode on Mac OS/Darwin.
@@ -137,11 +142,11 @@ YTABH := levcomp.tab.h
OBJECTS := $(UTIL)levcomp.tab.o $(UTIL)levcomp.lex.o $(OBJECTS)
-ifeq ($(LEX),)
+ifeq ($(strip $(LEX)),)
DOYACC :=
endif
-ifeq ($(YACC),)
+ifeq ($(strip $(YACC)),)
DOYACC :=
endif
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 3131868cf1..5c2f464321 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -93,6 +93,7 @@
#include "skills2.h"
#include "spl-book.h"
#include "spl-util.h"
+#include "state.h"
#include "stuff.h"
#include "tutorial.h"
#include "version.h"
@@ -715,6 +716,13 @@ bool new_game(void)
init_player();
+ if (!crawl_state.startup_errors.empty()
+ && !Options.suppress_startup_errors)
+ {
+ crawl_state.show_startup_errors();
+ clrscr();
+ }
+
if (!Options.player_name.empty())
{
strncpy(you.your_name, Options.player_name.c_str(), kNameLen);
diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc
new file mode 100644
index 0000000000..98d45bcf32
--- /dev/null
+++ b/crawl-ref/source/state.cc
@@ -0,0 +1,39 @@
+/*
+ * File: state.cc
+ * Summary: Game state functions.
+ * Written by: Matthew Cline
+ *
+ * Modified for Crawl Reference by $Author: dshaligram $ on $Date: 2007-11-20T12:19:31.082781Z $
+ *
+ * Change History (most recent first):
+ *
+ * <1> 09/18/07 MPC Created
+ */
+
+#include "AppHdr.h"
+#include "externs.h"
+
+#include "state.h"
+#include "menu.h" // For print_formatted_paragraph()
+
+void game_state::add_startup_error(const std::string &err)
+{
+ startup_errors.push_back(err);
+}
+
+void game_state::show_startup_errors()
+{
+ formatted_scroller error_menu;
+ error_menu.set_flags(MF_NOSELECT | MF_ALWAYS_SHOW_MORE | MF_NOWRAP
+ | MF_EASY_EXIT);
+ error_menu.set_more(
+ formatted_string::parse_string(
+ "<cyan>[ + : Page down. - : Page up."
+ " Esc or Enter to continue.]"));
+ error_menu.set_title(
+ new MenuEntry("Warning: Crawl encountered errors during startup:",
+ MEL_TITLE));
+ for (int i = 0, size = startup_errors.size(); i < size; ++i)
+ error_menu.add_entry(new MenuEntry(startup_errors[i]));
+ error_menu.show();
+}
diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h
index 2be86b8a76..98053cb909 100644
--- a/crawl-ref/source/state.h
+++ b/crawl-ref/source/state.h
@@ -33,11 +33,14 @@ struct game_state
bool unicode_ok; // Is unicode support available?
+ std::vector<std::string> startup_errors;
+
std::string (*glyph2strfn)(unsigned glyph);
int (*multibyte_strlen)(const std::string &s);
void (*terminal_resize_handler)();
void (*terminal_resize_check)();
+public:
game_state() : mouse_enabled(false), waiting_for_command(false),
terminal_resized(false), io_inited(false), need_save(false),
saving_game(false), updating_scores(false),
@@ -47,6 +50,8 @@ struct game_state
{
}
+ void add_startup_error(const std::string &error);
+ void show_startup_errors();
void check_term_size() const
{
if (terminal_resize_check)
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 0a67d233f2..52148a4b7c 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -443,9 +443,11 @@ void cio_init()
crawl_view.init_geometry();
if (Options.char_set == CSET_UNICODE && !crawl_state.unicode_ok)
- end(1, false,
- "Unicode glyphs are not available, please change your "
- "char_set option");
+ {
+ crawl_state.add_startup_error(
+ "Unicode glyphs are not available, falling back to ASCII.");
+ Options.char_set = CSET_ASCII;
+ }
}
void cio_cleanup()