summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/externs.h30
-rw-r--r--crawl-ref/source/initfile.cc98
-rw-r--r--crawl-ref/source/view.cc126
-rw-r--r--crawl-ref/source/view.h2
4 files changed, 134 insertions, 122 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 055dfa26ee..a1cb6da756 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -701,6 +701,23 @@ struct colour_mapping
int colour;
};
+struct feature_def
+{
+ unsigned short symbol; // symbol used for seen terrain
+ unsigned short magic_symbol; // symbol used for magic-mapped terrain
+ unsigned short colour; // normal in LoS colour
+ unsigned short map_colour; // colour when out of LoS on display
+ unsigned short seen_colour; // map_colour when is_terrain_seen()
+ bool notable; // gets noted when seen
+ bool seen_effect; // requires special handling when seen
+};
+
+struct feature_override
+{
+ dungeon_feature_type feat;
+ feature_def override;
+};
+
class InitLineInput;
struct game_options
{
@@ -713,6 +730,10 @@ public:
void read_options(InitLineInput &, bool runscripts);
public:
+ // View options
+ std::vector<feature_override> feature_overrides;
+ unsigned cset_override[NUM_CSET][NUM_DCHAR_TYPES];
+
std::string save_dir; // Directory where saves and bones go.
std::string player_name;
@@ -758,7 +779,7 @@ public:
bool delay_message_clear; // avoid clearing messages each turn
unsigned friend_brand; // Attribute for branding friendly monsters
bool no_dark_brand; // Attribute for branding friendly monsters
- bool macro_meta_entry; // Allow user to use \{foo} sequences when
+ bool macro_meta_entry; // Allow user to use numeric sequences when
// creating macros
int fire_items_start; // index of first item for fire command
@@ -906,6 +927,13 @@ public:
int o_colour(const char *name, int def = LIGHTGREY) const;
private:
+ void clear_feature_overrides();
+ void clear_cset_overrides();
+ void add_cset_override(char_set_type set, const std::string &overrides);
+ void add_cset_override(char_set_type set, dungeon_char_type dc,
+ unsigned char symbol);
+ void add_feature_override(const std::string &);
+
void set_default_activity_interrupts();
void clear_activity_interrupts(FixedVector<bool, NUM_AINTERRUPTS> &eints);
void set_activity_interrupt(
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 406efe44bc..7abb47dab3 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -24,6 +24,7 @@
#include "clua.h"
#include "delay.h"
+#include "direct.h"
#include "Kills.h"
#include "files.h"
#include "defines.h"
@@ -698,6 +699,103 @@ void game_options::reset_options()
initialise_travel();
}
+void game_options::clear_cset_overrides()
+{
+ memset(cset_override, 0, sizeof cset_override);
+}
+
+void game_options::clear_feature_overrides()
+{
+ feature_overrides.clear();
+}
+
+static unsigned short read_symbol(std::string s)
+{
+ if (s.empty())
+ return (0);
+ if (s.length() == 1)
+ return s[0];
+
+ if (s[0] == '\\')
+ s = s.substr(1);
+
+ int feat = atoi(s.c_str());
+ if (feat < 0)
+ feat = 0;
+ return static_cast<unsigned short>(feat);
+}
+
+void game_options::add_feature_override(const std::string &text)
+{
+ std::string::size_type epos = text.rfind("}");
+ if (epos == std::string::npos)
+ return;
+
+ std::string::size_type spos = text.rfind("{", epos);
+ if (spos == std::string::npos)
+ return;
+
+ std::string fname = text.substr(0, spos);
+ std::string props = text.substr(spos + 1, epos - spos - 1);
+ std::vector<std::string> iprops = split_string(",", props, true, true);
+
+ if (iprops.size() < 1 || iprops.size() > 5)
+ return;
+
+ if (iprops.size() < 5)
+ iprops.resize(5);
+
+ trim_string(fname);
+ std::vector<dungeon_feature_type> feats = features_by_desc(fname);
+ if (feats.empty())
+ return;
+
+ for (int i = 0, size = feats.size(); i < size; ++i)
+ {
+ feature_override fov;
+ fov.feat = feats[i];
+
+ fov.override.symbol = read_symbol(iprops[0]);
+ fov.override.magic_symbol = read_symbol(iprops[1]);
+ fov.override.colour = str_to_colour(iprops[2], BLACK);
+ fov.override.map_colour = str_to_colour(iprops[3], BLACK);
+ fov.override.seen_colour = str_to_colour(iprops[4], BLACK);
+
+ feature_overrides.push_back(fov);
+ }
+}
+
+void game_options::add_cset_override(
+ char_set_type set, const std::string &overrides)
+{
+ std::vector<std::string> overs = split_string(",", overrides);
+ for (int i = 0, size = overs.size(); i < size; ++i)
+ {
+ std::vector<std::string> mapping = split_string(":", overs[i]);
+ if (mapping.size() != 2)
+ continue;
+
+ dungeon_char_type dc = dchar_by_name(mapping[0]);
+ if (dc == NUM_DCHAR_TYPES)
+ continue;
+
+ unsigned char symbol =
+ static_cast<unsigned char>(read_symbol(mapping[1]));
+
+ if (set == NUM_CSET)
+ for (int c = 0; c < NUM_CSET; ++c)
+ add_cset_override(char_set_type(c), dc, symbol);
+ else
+ add_cset_override(set, dc, symbol);
+ }
+}
+
+void game_options::add_cset_override(char_set_type set, dungeon_char_type dc,
+ unsigned char symbol)
+{
+ cset_override[set][dc] = symbol;
+}
+
// returns where the init file was read from
std::string read_init_file(bool runscript)
{
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index a10240decb..9d989da86a 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -68,25 +68,7 @@
#define MC_ITEM 0x01
#define MC_MONS 0x02
-struct feature_def
-{
- unsigned short symbol; // symbol used for seen terrain
- unsigned short magic_symbol; // symbol used for magic-mapped terrain
- unsigned short colour; // normal in LoS colour
- unsigned short map_colour; // colour when out of LoS on display
- unsigned short seen_colour; // map_colour when is_terrain_seen()
- bool notable; // gets noted when seen
- bool seen_effect; // requires special handling when seen
-};
-
-struct feature_override
-{
- dungeon_feature_type feat;
- feature_def override;
-};
-
-static FixedVector< struct feature_def, NUM_FEATURES > Feature;
-static std::vector<feature_override> Feature_Overrides;
+static FixedVector<feature_def, NUM_FEATURES> Feature;
#if defined(DOS_TERM)
// DOS functions like gettext() and puttext() can only
@@ -2601,8 +2583,6 @@ static const unsigned char table[ NUM_CSET ][ NUM_DCHAR_TYPES ] =
},
};
-static unsigned char cset_override[NUM_CSET][NUM_DCHAR_TYPES];
-
dungeon_char_type dchar_by_name(const std::string &name)
{
const char *dchar_names[] =
@@ -2623,118 +2603,22 @@ dungeon_char_type dchar_by_name(const std::string &name)
return (NUM_DCHAR_TYPES);
}
-void clear_cset_overrides()
-{
- memset(cset_override, 0, sizeof cset_override);
-}
-
-static unsigned short read_symbol(std::string s)
-{
- if (s.empty())
- return (0);
- if (s.length() == 1)
- return s[0];
-
- if (s[0] == '\\')
- s = s.substr(1);
-
- int feat = atoi(s.c_str());
- if (feat < 0)
- feat = 0;
- return static_cast<unsigned short>(feat);
-}
-
-void add_cset_override(char_set_type set, dungeon_char_type dc,
- unsigned char symbol)
-{
- cset_override[set][dc] = symbol;
-}
-
-void add_cset_override(char_set_type set, const std::string &overrides)
-{
- std::vector<std::string> overs = split_string(",", overrides);
- for (int i = 0, size = overs.size(); i < size; ++i)
- {
- std::vector<std::string> mapping = split_string(":", overs[i]);
- if (mapping.size() != 2)
- continue;
-
- dungeon_char_type dc = dchar_by_name(mapping[0]);
- if (dc == NUM_DCHAR_TYPES)
- continue;
-
- unsigned char symbol =
- static_cast<unsigned char>(read_symbol(mapping[1]));
-
- if (set == NUM_CSET)
- for (int c = 0; c < NUM_CSET; ++c)
- add_cset_override(char_set_type(c), dc, symbol);
- else
- add_cset_override(set, dc, symbol);
- }
-}
-
void init_char_table( char_set_type set )
{
for (int i = 0; i < NUM_DCHAR_TYPES; i++)
{
- if (cset_override[set][i])
- Options.char_table[i] = cset_override[set][i];
+ if (Options.cset_override[set][i])
+ Options.char_table[i] = Options.cset_override[set][i];
else
Options.char_table[i] = table[set][i];
}
}
-void clear_feature_overrides()
-{
- Feature_Overrides.clear();
-}
-
-void add_feature_override(const std::string &text)
-{
- std::string::size_type epos = text.rfind("}");
- if (epos == std::string::npos)
- return;
-
- std::string::size_type spos = text.rfind("{", epos);
- if (spos == std::string::npos)
- return;
-
- std::string fname = text.substr(0, spos);
- std::string props = text.substr(spos + 1, epos - spos - 1);
- std::vector<std::string> iprops = split_string(",", props, true, true);
-
- if (iprops.size() < 1 || iprops.size() > 5)
- return;
-
- if (iprops.size() < 5)
- iprops.resize(5);
-
- trim_string(fname);
- std::vector<dungeon_feature_type> feats = features_by_desc(fname);
- if (feats.empty())
- return;
-
- for (int i = 0, size = feats.size(); i < size; ++i)
- {
- feature_override fov;
- fov.feat = feats[i];
-
- fov.override.symbol = read_symbol(iprops[0]);
- fov.override.magic_symbol = read_symbol(iprops[1]);
- fov.override.colour = str_to_colour(iprops[2], BLACK);
- fov.override.map_colour = str_to_colour(iprops[3], BLACK);
- fov.override.seen_colour = str_to_colour(iprops[4], BLACK);
-
- Feature_Overrides.push_back(fov);
- }
-}
-
void apply_feature_overrides()
{
- for (int i = 0, size = Feature_Overrides.size(); i < size; ++i)
+ for (int i = 0, size = Options.feature_overrides.size(); i < size; ++i)
{
- const feature_override &fov = Feature_Overrides[i];
+ const feature_override &fov = Options.feature_overrides[i];
const feature_def &ofeat = fov.override;
feature_def &feat = Feature[fov.feat];
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index 75f385e1b0..bbf07baf9a 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -143,6 +143,8 @@ void viewwindow(bool draw_it, bool do_updates);
bool find_ray( int sourcex, int sourcey, int targetx, int targety,
bool allow_fallback, ray_def& ray );
+dungeon_char_type dchar_by_name(const std::string &name);
+
#if defined(WIN32CONSOLE) || defined(DOS)
unsigned short dos_brand( unsigned short colour,
unsigned brand = CHATTR_REVERSE);