summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-23 17:29:20 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-23 17:29:20 +0000
commit055b9f2b1ee8e5aa131d3febdf82c789e023fefe (patch)
treeac6648429455e82d8d625d5c2bd2cda57ec76319
parent324764aa0c424121d6493f7c8056f6ff4f3fb08e (diff)
downloadcrawl-ref-055b9f2b1ee8e5aa131d3febdf82c789e023fefe.tar.gz
crawl-ref-055b9f2b1ee8e5aa131d3febdf82c789e023fefe.zip
Bumped version, removed unused files.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2902 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/dat/clua/lm_flags.lua347
-rw-r--r--crawl-ref/source/dat/clua/lm_fog.lua184
-rw-r--r--crawl-ref/source/dat/glass.des153
-rw-r--r--crawl-ref/source/state.cc367
-rw-r--r--crawl-ref/source/store.cc1624
-rw-r--r--crawl-ref/source/store.h402
-rw-r--r--crawl-ref/source/version.h2
-rw-r--r--crawl-ref/source/xom.h43
8 files changed, 1 insertions, 3121 deletions
diff --git a/crawl-ref/source/dat/clua/lm_flags.lua b/crawl-ref/source/dat/clua/lm_flags.lua
deleted file mode 100644
index 770c80110e..0000000000
--- a/crawl-ref/source/dat/clua/lm_flags.lua
+++ /dev/null
@@ -1,347 +0,0 @@
----------------------------------------------------------------------------
--- lm_flags.lua
--- Changing level flags and branch flags
---------------------------------------------------------------------------
-
---------------------------------------------------------------------------
--- There are three different types of pre-packaged "change level and
--- branch flags" marker types. All three share the following parameters:
---
--- * level_flags: A space separated list of level flag names to set or unset.
--- To unset a flag, prefix the name with "!".
---
--- * branch_flags: Like level_flags, but for branch flags to set or unset.
---
--- * group: Different flag change markers on the same level can be put
--- into the same group by giving them the same group name.
--- Of all of the markers in the same group, only the last one
--- to have its conditions met will cause the flags to change.
--- This is useful if, for example, there are two magical fountains,
--- and you only want the flags to change when both dry up.
---
--- * msg: A message to give the user when the flags are changed; suppress
--- any messages Crawl would normally give for the changes effected.
--- The message is not given if nothing is changed (i.e., if all
--- the flags to be set were already set and all the flags to be
--- unset were already unset).
---
--- The three different marker types can be created with the following
--- functions:
---
--- * mons_dies_change_flags(): Creates a marker which changes the flags
--- when a named monster dies. Accepts the parameter "mon_name"
--- as the name of the monster to watch. The marker can be
--- placed anywhere on the level, and doesn't have to be near the
--- monster when it dies.
---
--- * feat_change_change_flags(): Creates a marker which acts when the
--- feature of its grid changes. Accepts the optional string
--- parameter "final_feat", which will cause the change to only
--- take place when the changed feature contains final_feat as
--- a substring. For example, a sparkling fountain can dry up
--- either by turning directly into a dry_fountain_ii feature,
--- or by first turning into a blue_fountain feature, and then
--- into a dry_fountain_i feature. Without final_feat, the
--- flags will change if the sparkling fountain changes into
--- a blue fountain. However, if "final_feat" is set to
--- "dry_fountain", the marker will ignore the feature turning
--- into blue_fountain, and will only act when it changes into
--- dry_fountain_i or dry_fountain_ii
---
--- * item_pickup_change_flags(): Creates a marker which acts when
--- an item on its grid gets picked up. Accepts the parameter
--- "item", which is the plain name of the item its watching
--- (i.e., "Orb of Zot" and "golden rune" rather than "the Orb of Zot"
--- or "a golden rune").
---------------------------------------------------------------------------
-
-ChangeFlags = { }
-ChangeFlags.__index = ChangeFlags
-
-function ChangeFlags:_new()
- local cf = { }
- setmetatable(cf, self)
- self.__index = self
-
- return cf
-end
-
-function ChangeFlags:new(pars)
- pars = pars or { }
-
- pars.level_flags = pars.level_flags or ""
- pars.branch_flags = pars.branch_flags or ""
- pars.msg = pars.msg or ""
-
- if not (pars.level_flags ~= "" or pars.branch_flags ~= "") then
- error("Must provide at least one of level_flags or branch_flags.")
- end
-
- local cf = self:_new()
- cf.level_flags = pars.level_flags
- cf.branch_flags = pars.branch_flags
- cf.msg = pars.msg
- cf.props = { flag_group = pars.group }
-
- return cf
-end
-
-function ChangeFlags:do_change(marker)
- local did_change1 = false
- local did_change2 = false
- local silent = self.msg and self.msg ~= ""
-
- if self.props.flag_group and self.props.flag_group ~= "" then
- local num_markers = dgn.num_matching_markers("flag_group",
- self.props.group)
-
- if num_markers > 1 then
- return false, false
- end
- end
-
- if self.level_flags and self.level_flags ~= "" then
- did_change1 = dgn.change_level_flags(self.level_flags, silent)
- end
-
- if self.branch_flags and self.branch_flags ~= "" then
- did_change2 = dgn.change_branch_flags(self.branch_flags, silent)
- end
-
- if did_change1 or did_change2 then
- if self.msg and self.msg ~= "" then
- crawl.mpr(self.smg)
- end
-
- return true, true
- end
-
- return true, false
-end
-
-function ChangeFlags:property(marker, pname)
- return self.props[pname] or ''
-end
-
-function ChangeFlags:write(marker, th)
- file.marshall(th, self.level_flags)
- file.marshall(th, self.branch_flags)
- file.marshall(th, self.msg)
- lmark.marshall_table(th, self.props)
-end
-
-function ChangeFlags:read(marker, th)
- self.level_flags = file.unmarshall_string(th)
- self.branch_flags = file.unmarshall_string(th)
- self.msg = file.unmarshall_string(th)
- self.props = lmark.unmarshall_table(th)
- setmetatable(self, ChangeFlags)
-
- return self
-end
-
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-
-MonDiesChangeFlags = ChangeFlags:_new()
-MonDiesChangeFlags.__index = MonDiesChangeFlags
-
-function MonDiesChangeFlags:_new(pars)
- local mdcf
-
- if pars then
- mdcf = ChangeFlags:new(pars)
- else
- mdcf = ChangeFlags:_new()
- end
-
- setmetatable(mdcf, self)
- self.__index = self
-
- return mdcf
-end
-
-function MonDiesChangeFlags:new(pars)
- pars = pars or { }
-
- if not pars.mon_name then
- error("No monster name provided.")
- end
-
- local mdcf = self:_new(pars)
- mdcf.mon_name = pars.mon_name
-
- return mdcf
-end
-
-function MonDiesChangeFlags:activate(marker)
- dgn.register_listener(dgn.dgn_event_type('monster_dies'), marker)
-end
-
-function MonDiesChangeFlags:event(marker, ev)
- local midx = ev:arg1()
- local mons = dgn.mons_from_index(midx)
-
- if not mons then
- error("MonDiesChangeFlags:event() didn't get a valid monster index")
- end
-
- if mons.name == self.mon_name then
- ChangeFlags.do_change(self, marker)
- dgn.remove_listener(marker)
- dgn.remove_marker(marker)
- end
-end
-
-function MonDiesChangeFlags:write(marker, th)
- ChangeFlags.write(self, marker, th)
- file.marshall(th, self.mon_name)
-end
-
-function MonDiesChangeFlags:read(marker, th)
- ChangeFlags.read(self, marker, th)
- self.mon_name = file.unmarshall_string(th)
- setmetatable(self, MonDiesChangeFlags)
-
- return self
-end
-
-function mons_dies_change_flags(pars)
- return MonDiesChangeFlags:new(pars)
-end
-
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-FeatChangeChangeFlags = ChangeFlags:_new()
-FeatChangeChangeFlags.__index = FeatChangeChangeFlags
-
-function FeatChangeChangeFlags:_new(pars)
- local fccf
-
- if pars then
- fccf = ChangeFlags:new(pars)
- else
- fccf = ChangeFlags:_new()
- end
-
- setmetatable(fccf, self)
- self.__index = self
-
- return fccf
-end
-
-function FeatChangeChangeFlags:new(pars)
- pars = pars or { }
-
- local fccf = self:_new(pars)
-
- fccf.final_feat = pars.final_feat
-
- return fccf
-end
-
-function FeatChangeChangeFlags:activate(marker)
- dgn.register_listener(dgn.dgn_event_type('feat_change'), marker,
- marker:pos())
-end
-
-function FeatChangeChangeFlags:event(marker, ev)
- if self.final_feat and self.final_feat ~= "" then
- local feat = dgn.feature_name(dgn.grid(ev:pos()))
- if not string.find(feat, self.final_feat) then
- return
- end
- end
-
- ChangeFlags.do_change(self, marker)
- dgn.remove_listener(marker, marker:pos())
- dgn.remove_marker(marker)
-end
-
-function FeatChangeChangeFlags:write(marker, th)
- ChangeFlags.write(self, marker, th)
- file.marshall(th, self.final_feat)
-end
-
-function FeatChangeChangeFlags:read(marker, th)
- ChangeFlags.read(self, marker, th)
- self.final_feat = file.unmarshall_string(th)
- setmetatable(self, FeatChangeChangeFlags)
-
- return self
-end
-
-function feat_change_change_flags(pars)
- return FeatChangeChangeFlags:new(pars)
-end
-
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-
-ItemPickupChangeFlags = ChangeFlags:_new()
-ItemPickupChangeFlags.__index = ItemPickupChangeFlags
-
-function ItemPickupChangeFlags:_new(pars)
- local ipcf
-
- if pars then
- ipcf = ChangeFlags:new(pars)
- else
- ipcf = ChangeFlags:_new()
- end
-
- setmetatable(ipcf, self)
- self.__index = self
-
- return ipcf
-end
-
-function ItemPickupChangeFlags:new(pars)
- pars = pars or { }
-
- if not pars.item then
- error("No item name provided.")
- end
-
- local ipcf = self:_new(pars)
- ipcf.item = pars.item
-
- return ipcf
-end
-
-function ItemPickupChangeFlags:activate(marker)
- dgn.register_listener(dgn.dgn_event_type('item_pickup'), marker,
- marker:pos())
-end
-
-function ItemPickupChangeFlags:event(marker, ev)
- local obj_idx = ev:arg1()
- local it = dgn.item_from_index(obj_idx)
-
- if not it then
- error("ItemPickupChangeFlags:event() didn't get a valid item index")
- end
-
- if item.name(it) == self.item then
- ChangeFlags.do_change(self, marker)
- dgn.remove_listener(marker, marker:pos())
- dgn.remove_marker(marker)
- end
-end
-
-function ItemPickupChangeFlags:write(marker, th)
- ChangeFlags.write(self, marker, th)
- file.marshall(th, self.item)
-end
-
-function ItemPickupChangeFlags:read(marker, th)
- ChangeFlags.read(self, marker, th)
- self.item = file.unmarshall_string(th)
- setmetatable(self, ItemPickupChangeFlags)
-
- return self
-end
-
-function item_pickup_change_flags(pars)
- return ItemPickupChangeFlags:new(pars)
-end
diff --git a/crawl-ref/source/dat/clua/lm_fog.lua b/crawl-ref/source/dat/clua/lm_fog.lua
deleted file mode 100644
index d1106101fa..0000000000
--- a/crawl-ref/source/dat/clua/lm_fog.lua
+++ /dev/null
@@ -1,184 +0,0 @@
-------------------------------------------------------------------------------
--- lm_tmsg.lua:
--- Fog machines.
---
--- There are three different "pure" ways to use a fog machine marker:
---
--- 1) Repeatedly lay down medium to large clouds on top of the marker
--- and let them pile up on one another. (One of the cloud grids in
--- the gfirst laid cloud has to decay away before this is this really
--- starts working.
---
--- 2) Perform random walks from the marker and place a single-grid cloud
--- at the destination of each walk.
---
--- 3) Place a single-grid cloud on the marker and let it spread out.
---
--- Comibining these different methods, along with varying the differrent
--- parameters, can be used to achieve different effects.
---
--- Marker parameters:
---
--- cloud_type: The name of the cloud type to use. Defaults to "thin mist".
--- walk_dist: The distance to move over the course of one random walk.
--- defaults to 0.
--- pow_min: The minimum "power" (lifetime) of each cloud; defaults to 1.
--- pow_max: The maximum power of each cloud; must be provided.
--- pow_rolls: The number of rolls of [pow_min, pow_max], with the average
--- value uses; increasing the values makes the average value more likely
--- and exterme values less likely. Defaults to 1.
--- delay, delay_min and delay_max: The delay between laying down one cloud
--- and the next. 10 is equal to normal-speed player turn. Either
--- delay or delay_max and delay_min must be provided. Providing just
--- "delay" is equivalent to delay_min and delay_max being equal.
--- size, size_min and size_max: The number of grids each cloud will cover.
--- Either size or size_max and size_min must be provided. Providing
--- just "size" is equivalent to size_min and size_max being equal.
--- spread_rate: The rate at which a cloud spreads. Must either be
--- -1 (default spread rate that varies by cloud type) or between
--- 0 and 100 inclusive.
--- start_clouds: The number of clouds to lay when the level containing
--- the cloud machine is entered. This is necessary since clouds
--- are cleared when the player leaves a level.
-------------------------------------------------------------------------------
-
-FogMachine = { }
-FogMachine.__index = FogMachine
-
-function FogMachine:_new()
- local m = { }
- setmetatable(m, self)
- self.__index = self
- return m
-end
-
-function FogMachine:new(pars)
- if not pars then
- error("No parameters provided")
- end
-
- if not pars.pow_max then
- error("No pow_max provided.")
- end
-
- if not (pars.delay or (pars.delay_min and pars.delay_max)) then
- error("Delay parameters not provided.")
- end
-
- if not (pars.size or (pars.size_min and pars.size_max)) then
- error("Size parameters not provided.")
- end
-
- local m = FogMachine:_new()
- m.cloud_type = pars.cloud_type or "thin mist"
- m.walk_dist = pars.walk_dist or 0
- m.pow_min = pars.pow_min or 1
- m.pow_max = pars.pow_max
- m.pow_rolls = pars.pow_rolls or 3
- m.delay_min = pars.delay_min or pars.delay or 1
- m.delay_max = pars.delay_max or pars.delay
- m.kill_cat = pars.kill_cat or "other"
- m.size_min = pars.size_min or pars.size or 1
- m.size_max = pars.size_max or pars.size
- m.spread_rate = pars.spread_rate or -1
- m.start_clouds = pars.start_clouds or 1
- m.countdown = 0
-
- return m
-end
-
-function FogMachine:do_fog(marker)
- local x, y = marker:pos()
- if self.walk_dist > 0 then
- x, y = dgn.random_walk(x, y, self.walk_dist)
- end
-
- dgn.apply_area_cloud(x, y, self.pow_min, self.pow_max, self.pow_rolls,
- crawl.random_range(self.size_min, self.size_max, 1),
- self.cloud_type, self.kill_cat, self.spread_rate)
-end
-
-function FogMachine:activate(marker, verbose)
- local _x, _y = marker:pos()
- dgn.register_listener(dgn.dgn_event_type('turn'), marker)
- dgn.register_listener(dgn.dgn_event_type('entered_level'), marker)
-end
-
-function FogMachine:event(marker, ev)
- local _x, _y = marker:pos()
- if ev:type() == dgn.dgn_event_type('turn') then
- self.countdown = self.countdown - ev:ticks()
-
- while self.countdown <= 0 do
- self:do_fog(marker)
- self.countdown = self.countdown +
- crawl.random_range(self.delay_min, self.delay_max, 1)
- end
- elseif ev:type() == dgn.dgn_event_type('entered_level') then
- for i = 1, self.start_clouds do
- self:do_fog(marker)
- self.countdown = crawl.random_range(self.delay_min, self.delay_max, 1)
- end
- end
-end
-
-function FogMachine:write(marker, th)
- file.marshall(th, self.cloud_type)
- file.marshall(th, self.walk_dist)
- file.marshall(th, self.pow_min)
- file.marshall(th, self.pow_max)
- file.marshall(th, self.pow_rolls)
- file.marshall(th, self.delay_min)
- file.marshall(th, self.delay_max)
- file.marshall(th, self.kill_cat)
- file.marshall(th, self.size_min)
- file.marshall(th, self.size_max)
- file.marshall(th, self.spread_rate)
- file.marshall(th, self.start_clouds)
- file.marshall(th, self.countdown)
-end
-
-function FogMachine:read(marker, th)
- self.cloud_type = file.unmarshall_string(th)
- self.walk_dist = file.unmarshall_number(th)
- self.pow_min = file.unmarshall_number(th)
- self.pow_max = file.unmarshall_number(th)
- self.pow_rolls = file.unmarshall_number(th)
- self.delay_min = file.unmarshall_number(th)
- self.delay_max = file.unmarshall_number(th)
- self.kill_cat = file.unmarshall_string(th)
- self.size_min = file.unmarshall_number(th)
- self.size_max = file.unmarshall_number(th)
- self.spread_rate = file.unmarshall_number(th)
- self.start_clouds = file.unmarshall_number(th)
- self.countdown = file.unmarshall_number(th)
-
- setmetatable(self, FogMachine)
-
- return self
-end
-
-function fog_machine(pars)
- return FogMachine:new(pars)
-end
-
-function fog_machine_geyser(cloud_type, size, power)
- return FogMachine:new {
- cloud_type = cloud_type, pow_max = power, size = size,
- delay_min = power , delay_max = power * 2
- }
-end
-
-function fog_machine_spread(cloud_type, size, power)
- return FogMachine:new {
- cloud_type = cloud_type, pow_max = power, spread_rate = size,
- size = 1, delay_min = 5, delay_max = 15
- }
-end
-
-function fog_machine_brownian(cloud_type, size, power)
- return FogMachine:new {
- cloud_type = cloud_type, size = 1, pow_max = power,
- walk_dist = size, delay_min = 1, delay_max = power / size
- }
-end
diff --git a/crawl-ref/source/dat/glass.des b/crawl-ref/source/dat/glass.des
deleted file mode 100644
index 7d7bd28039..0000000000
--- a/crawl-ref/source/dat/glass.des
+++ /dev/null
@@ -1,153 +0,0 @@
-###########################################################################
-# Small areas with translucent rock (glass) columns which you can duck
-# behind, but still see the monster you're ducking from (and they can
-# still see you
-NAME: glass_columns_a
-DEPTH:
-MAP
-.....
-.m.m.
-.....
-.m.m.
-.....
-ENDMAP
-
-NAME: glass_columns_b
-DEPTH:
-MAP
-.......
-.m.m.m.
-.......
-.m.m.m.
-.......
-.m.m.m.
-.......
-ENDMAP
-
-NAME: glass_columns_c
-DEPTH:
-MAP
-.........
-.m.m.m.m.
-.........
-.m.m.m.m.
-.........
-.m.m.m.m.
-.........
-.m.m.m.m.
-.........
-ENDMAP
-
-##########################################################
-# A feature encased in glass, for flavour.
-NAME: feat_on_display
-DEPTH:
-SUBST: ? = TUl
-TAGS: no_monster_gen no_item_gen
-MAP
-.....
-.mmm.
-.m?m.
-.mmm.
-.....
-ENDMAP
-
-#######################################################################
-# An item encased in glass. If the player wants it, it can be dug out.
-NAME: item_on_display_a
-DEPTH:
-TAGS: no_monster_gen no_item_gen
-MAP
-.....
-.mmm.
-.m%m.
-.mmm.
-.....
-ENDMAP
-
-#####################################################################
-# A good item encased in *permanent* glass. If the player wants it,
-# teleport control will be needed.
-NAME: item_on_display_b
-DEPTH:
-TAGS: no_monster_gen no_item_gen
-MAP
-.....
-.ooo.
-.o*o.
-.ooo.
-.....
-ENDMAP
-
-#####################################################################
-# An average monster in a cage of glass; can get out if it has the
-# ability to dig or blink like a blink-frog. Also, the player can
-# dig it out.
-NAME: caged_monster_a
-DEPTH: D, Elf, Snake, Vault
-MAP
-.....
-.mmm.
-.m0m.
-.mmm.
-.....
-ENDMAP
-
-############################################################################
-# Entry vaults using translucent (glass) walls
-
-# A spiral made entirely of glass
-
-NAME: glass_entry_001
-TAGS: entry
-ORIENT: float
-SHUFFLE: {[(<
-SUBST: < = .
-MAP
-mmmmmmmmmmmmmmmmmm
-m................m
-m.mmmmmmmmmmmmmm.m
-m.m............m.m
-m.m.mmmmmmmmmm.m.m
-m.m.m........m.m.m
-m.m.m.mmmmmm.m.m.m
-m.m.m.m....m.m.m.m
-m.m.m.m.mm.m.m.m.m
-m.m.m.m{[m.m.m.m.m
-m.m.m.m(<m.m.m.m.m
-m.m.m.mmmm.m.m.m.m
-m.m.m......m.m.m.m
-m.m.mmmmmmmm.m.m.m
-m.m..........m.m.m
-m.mmmmmmmmmmmm.m.m
-m..............m.m
-mmmmmmmmmmmmmmmm@m
-ENDMAP
-
-# A spiral made of rock, with lots of "windows".
-
-NAME: glass_entry_002
-TAGS: entry
-ORIENT: float
-SHUFFLE: {[(<
-SUBST: < = .
-MAP
-mxmxmxmxmxmxxmxxmx
-x................m
-m.xmxmxmxmxmxmxm.x
-x.m............x.m
-m.x.mxmxmxmxmx.m.x
-x.m.x........m.x.m
-m.x.m.xmxmxx.x.m.x
-x.m.x.m....x.m.x.m
-m.x.m.x.mx.m.x.m.x
-x.m.x.m{[m.x.m.x.m
-m.x.m.x(<x.m.x.m.x
-x.m.x.xmxx.x.m.x.m
-m.x.m......m.x.m.x
-x.m.xxmxmxmx.m.x.m
-m.x..........x.m.x
-x.xmxmxmxmxmxm.x.m
-m..............m.x
-xxmxmxmxmxmxmxmx@m
-ENDMAP
diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc
deleted file mode 100644
index 1d86dc1862..0000000000
--- a/crawl-ref/source/state.cc
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * File: state.cc
- * Summary: Game state functions.
- * Written by: Matthew Cline
- *
- * Modified for Crawl Reference by $Author$ on $Date$
- *
- * Change History (most recent first):
- *
- * <1> 09/18/07 MPC Created
- */
-
-#include "AppHdr.h"
-#include "externs.h"
-
-#include "delay.h"
-#include "direct.h"
-#include "macro.h"
-#include "menu.h" // For print_formatted_paragraph()
-#include "message.h"
-#include "mon-util.h"
-#include "player.h"
-#include "state.h"
-#include "tutorial.h"
-#include "view.h"
-
-game_state::game_state()
- : mouse_enabled(false), waiting_for_command(false),
- terminal_resized(false), io_inited(false), need_save(false),
- saving_game(false), updating_scores(false), seen_hups(0),
- map_stat_gen(false), unicode_ok(false), glyph2strfn(NULL),
- multibyte_strlen(NULL), terminal_resize_handler(NULL),
- terminal_resize_check(NULL), doing_prev_cmd_again(false),
- prev_cmd(CMD_NO_CMD), repeat_cmd(CMD_NO_CMD), cmd_repeat_count(0),
- cmd_repeat_goal(0), prev_repetition_turn(0),
- cmd_repeat_started_unsafe(false), input_line_curr(0),
- level_annotation_shown(false)
-{
- reset_cmd_repeat();
- reset_cmd_again();
-}
-
-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();
-}
-
-///////////////////////////////////////////////////////////////////////////
-// Repeating commands and doing the previous command over again.
-
-bool game_state::is_replaying_keys() const
-{
- return (crawl_state.doing_prev_cmd_again
- || (crawl_state.is_repeating_cmd()
- && !crawl_state.cmd_repeat_start));
-}
-
-bool game_state::is_repeating_cmd() const
-{
- ASSERT((cmd_repeat_goal == 0 && cmd_repeat_count == 0
- && repeat_cmd == CMD_NO_CMD && !cmd_repeat_start)
- || (cmd_repeat_goal > 0 && cmd_repeat_count <= cmd_repeat_goal
- && repeat_cmd != CMD_NO_CMD));
-
- return (repeat_cmd != CMD_NO_CMD);
-}
-
-void game_state::cancel_cmd_repeat(std::string reason)
-{
- if (!is_repeating_cmd())
- return;
-
- if (is_replaying_keys() || cmd_repeat_start)
- flush_input_buffer(FLUSH_KEY_REPLAY_CANCEL);
-
- if (is_processing_macro())
- flush_input_buffer(FLUSH_ABORT_MACRO);
-
- reset_cmd_repeat();
-
- if (reason != "")
- mpr(reason.c_str());
-}
-
-void game_state::cancel_cmd_again(std::string reason)
-{
- if (!doing_prev_cmd_again)
- return;
-
- flush_input_buffer(FLUSH_KEY_REPLAY_CANCEL);
-
- if (is_processing_macro())
- flush_input_buffer(FLUSH_ABORT_MACRO);
-
- reset_cmd_again();
-
- if (reason != "")
- mpr(reason.c_str());
-}
-
-void game_state::cant_cmd_repeat(std::string reason)
-{
- if (reason == "")
- reason = "Can't repeat that command.";
-
- cancel_cmd_repeat(reason);
-}
-
-void game_state::cant_cmd_again(std::string reason)
-{
- if (reason == "")
- reason = "Can't redo that command.";
-
- cancel_cmd_again(reason);
-}
-
-// The method is called to prevent the "no repeating zero turns
-// commands" message that input() generates (in the absence of
-// cancelling the repeition) for a repeated command that took no
-// turns. A wrapper around cancel_cmd_repeat(), its only purpose it
-// to make it clear why cancel_cmd_repeat() is being called.
-void game_state::zero_turns_taken()
-{
- ASSERT(!you.turn_is_over);
- cancel_cmd_repeat();
-}
-
-bool interrupt_cmd_repeat( activity_interrupt_type ai,
- const activity_interrupt_data &at )
-{
- if (crawl_state.cmd_repeat_start)
- return false;
-
- if (crawl_state.repeat_cmd == CMD_WIZARD)
- return false;
-
- switch (ai)
- {
- case AI_STATUE:
- case AI_HUNGRY:
- case AI_TELEPORT:
- case AI_FORCE_INTERRUPT:
- case AI_HP_LOSS:
- case AI_MONSTER_ATTACKS:
- crawl_state.cancel_cmd_repeat("Command repetition interrupted.");
- return true;
-
- default:
- break;
- }
-
- if (ai == AI_SEE_MONSTER)
- {
- const monsters* mon = static_cast<const monsters*>(at.data);
- if (!mon->visible())
- return false;
-
- if (crawl_state.cmd_repeat_started_unsafe
- && at.context != "newly seen")
- {
- return false;
- }
-
- crawl_state.cancel_cmd_repeat();
-
-#ifndef DEBUG_DIAGNOSTICS
- if (at.context == "newly seen")
- {
- std::string text = get_monster_desc(mon, false);
- text += " comes into view.";
- print_formatted_paragraph(text, get_number_of_cols(), MSGCH_WARN);
- }
-
- if (Options.tutorial_left)
- {
- // enforce that this message comes first
- tutorial_first_monster(*mon);
- if (get_mons_colour(mon) != mon->colour)
- learned_something_new(TUT_MONSTER_BRAND);
- }
-#else
- formatted_string fs( channel_to_colour(MSGCH_WARN) );
- fs.cprintf("%s (", mon->name(DESC_PLAIN, true).c_str());
- fs.add_glyph( mon );
- fs.cprintf(") in view: (%d,%d), see_grid: %s",
- mon->x, mon->y,
- see_grid(mon->x, mon->y)? "yes" : "no");
- formatted_mpr(fs, MSGCH_WARN);
-#endif
-
- return true;
- }
-
- // If command repitition is being used to immitate the rest command,
- // then everything interrupts it.
- if (crawl_state.repeat_cmd == CMD_MOVE_NOWHERE
- || crawl_state.repeat_cmd == CMD_SEARCH)
- {
- if (ai == AI_FULL_MP)
- crawl_state.cancel_cmd_repeat("Magic restored.");
- else if (ai == AI_FULL_HP)
- crawl_state.cancel_cmd_repeat("HP restored.");
- else
- crawl_state.cancel_cmd_repeat("Command repetition interrupted.");
- return true;
- }
-
- if (crawl_state.cmd_repeat_started_unsafe)
- return false;
-
- if (ai == AI_HIT_MONSTER)
- {
- // This check is for when command repetition is used to
- // whack away at a 0xp monster, since the player feels safe
- // when the only monsters around are 0xp.
- const monsters* mon = static_cast<const monsters*>(at.data);
-
- if (mons_class_flag(mon->type, M_NO_EXP_GAIN)
- && player_monster_visible(mon))
- {
- return false;
- }
-
- crawl_state.cancel_cmd_repeat("Command repetition interrupted.");
- return true;
- }
-
- return false;
-}
-
-void game_state::reset_cmd_repeat()
-{
- repeat_cmd = CMD_NO_CMD;
- cmd_repeat_count = 0;
- cmd_repeat_goal = 0;
- cmd_repeat_start = false;
- prev_repetition_turn = 0;
-
- repeat_cmd_keys.clear();
-}
-
-void game_state::reset_cmd_again()
-{
- doing_prev_cmd_again = false;
- prev_cmd = CMD_NO_CMD;
-
- prev_cmd_keys.clear();
-}
-
-///////////////////////////////////////////////////////////
-// Keeping track of which god is currently doing something
-///////////////////////////////////////////////////////////
-
-god_act_state::god_act_state()
-{
- reset();
-}
-
-void god_act_state::reset()
-{
- which_god = GOD_NO_GOD;
- retribution = false;
- depth = 0;
-}
-
-bool game_state::is_god_acting() const
-{
- ASSERT(god_act.depth >= 0);
- ASSERT(!(god_act.depth > 0 && god_act.which_god == GOD_NO_GOD));
- ASSERT(!(god_act.depth == 0 && god_act.which_god != GOD_NO_GOD));
- ASSERT(!(god_act.depth == 0 && god_act_stack.size() > 0));
-
- return (god_act.depth > 0);
-}
-
-bool game_state::is_god_retribution() const
-{
- ASSERT(is_god_acting());
-
- return (god_act.retribution);
-}
-
-god_type game_state::which_god_acting() const
-{
- return god_act.which_god;
-}
-
-void game_state::inc_god_acting(bool is_retribution)
-{
- inc_god_acting(you.religion, is_retribution);
-}
-
-void game_state::inc_god_acting(god_type which_god, bool is_retribution)
-{
- ASSERT(which_god != GOD_NO_GOD);
-
- if (god_act.which_god != GOD_NO_GOD &&
- god_act.which_god != which_god)
- {
- ASSERT(god_act.depth >= 1);
-
- god_act_stack.push_back(god_act);
- god_act.reset();
- }
-
- god_act.which_god = which_god;
- god_act.retribution = is_retribution || god_act.retribution;
- god_act.depth++;
-}
-
-void game_state::dec_god_acting()
-{
- dec_god_acting(you.religion);
-}
-
-void game_state::dec_god_acting(god_type which_god)
-{
- ASSERT(which_god != GOD_NO_GOD);
- ASSERT(god_act.depth > 0);
- ASSERT(god_act.which_god == which_god);
-
- god_act.depth--;
-
- if (god_act.depth == 0)
- {
- god_act.reset();
- if (god_act_stack.size() > 0)
- {
- god_act = god_act_stack[god_act_stack.size() - 1];
- god_act_stack.pop_back();
- ASSERT(god_act.depth >= 1);
- ASSERT(god_act.which_god != GOD_NO_GOD);
- ASSERT(god_act.which_god != which_god);
- }
- }
-}
-
-void game_state::clear_god_acting()
-{
- ASSERT(!is_god_acting());
- ASSERT(god_act_stack.size() == 0);
-
- god_act.reset();
-}
-
-std::vector<god_act_state> game_state::other_gods_acting() const
-{
- ASSERT(is_god_acting());
- return god_act_stack;
-}
diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc
deleted file mode 100644
index 0ffa96e194..0000000000
--- a/crawl-ref/source/store.cc
+++ /dev/null
@@ -1,1624 +0,0 @@
-/*
- * File: store.cc
- * Summary: Saveable hash-table and vector capable of storing
- * multiple types of data.
- * Written by: Matthew Cline
- *
- * Modified for Crawl Reference by $Author$ on $Date$
- *
- * Change History (most recent first):
-
- * <1> 10/5/07 MPC Created
- */
-
-#include "AppHdr.h"
-#include "store.h"
-
-#include "externs.h"
-#include "tags.h"
-
-CrawlStoreValue::CrawlStoreValue()
- : type(SV_NONE), flags(SFLAG_UNSET)
-{
- val.ptr = NULL;
-}
-
-CrawlStoreValue::CrawlStoreValue(const CrawlStoreValue &other)
-{
- ASSERT(other.type >= SV_NONE && other.type < NUM_STORE_VAL_TYPES);
-
- type = other.type;
- flags = other.flags;
-
- if (flags & SFLAG_UNSET)
- {
- val = other.val;
- return;
- }
-
- switch (type)
- {
- case SV_NONE:
- case SV_BOOL:
- case SV_BYTE:
- case SV_SHORT:
- case SV_LONG:
- case SV_FLOAT:
- val = other.val;
- break;
-
- case SV_STR:
- {
- std::string* str;
- str = new std::string(*static_cast<std::string*>(other.val.ptr));
- val.ptr = static_cast<void*>(str);
- break;
- }
-
- case SV_COORD:
- {
- coord_def* coord;
- coord = new coord_def(*static_cast<coord_def*>(other.val.ptr));
- val.ptr = static_cast<void*>(coord);
- break;
- }
-
- case SV_ITEM:
- {
- item_def* item;
- item = new item_def(*static_cast<item_def*>(other.val.ptr));
- val.ptr = static_cast<void*>(item);
- break;
- }
-
- case SV_HASH:
- {
- CrawlHashTable* hash;
- CrawlHashTable* tmp = static_cast<CrawlHashTable*>(other.val.ptr);
- hash = new CrawlHashTable(*tmp);
- val.ptr = static_cast<void*>(hash);
- break;
- }
-
- case SV_VEC:
- {
- CrawlVector* vec;
- CrawlVector* tmp = static_cast<CrawlVector*>(other.val.ptr);
- vec = new CrawlVector(*tmp);
- val.ptr = static_cast<void*>(vec);
- break;
- }
-
- case NUM_STORE_VAL_TYPES:
- ASSERT(false);
- }
-}
-
-CrawlStoreValue::CrawlStoreValue(const store_flags _flags,
- const store_val_type _type)
- : type(_type), flags(_flags)
-{
- ASSERT(type >= SV_NONE && type < NUM_STORE_VAL_TYPES);
- ASSERT(!(flags & SFLAG_UNSET));
-
- flags |= SFLAG_UNSET;
- val.ptr = NULL;
-}
-
-// Conversion constructors
-CrawlStoreValue::CrawlStoreValue(const bool _val)
- : type(SV_BOOL), flags(0)
-{
- get_bool() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const char &_val)
- : type(SV_BYTE), flags(0)
-{
- get_byte() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const short &_val)
- : type(SV_SHORT), flags(0)
-{
- get_short() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const long &_val)
- : type(SV_LONG), flags(0)
-{
- get_long() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const float &_val)
- : type(SV_FLOAT), flags(0)
-{
- get_float() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const std::string &_val)
- : type(SV_STR), flags(0)
-{
- get_string() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const char* _val)
- : type(SV_STR), flags(0)
-{
- get_string() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const coord_def &_val)
- : type(SV_COORD), flags(0)
-{
- get_coord() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const item_def &_val)
- : type(SV_ITEM), flags(0)
-{
- get_item() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const CrawlHashTable &_val)
- : type(SV_HASH), flags(0)
-{
- get_table() = _val;
-}
-
-CrawlStoreValue::CrawlStoreValue(const CrawlVector &_val)
- : type(SV_VEC), flags(0)
-{
- get_vector() = _val;
-}
-
-CrawlStoreValue::~CrawlStoreValue()
-{
- unset(true);
-}
-
-void CrawlStoreValue::unset(bool force)
-{
- if (flags & SFLAG_UNSET)
- return;
-
- if (force)
- flags &= ~SFLAG_NO_ERASE;
-
- ASSERT(!(flags & SFLAG_NO_ERASE));
-
- switch (type)
- {
- case SV_BOOL:
- val.boolean = false;
- break;
-
- case SV_BYTE:
- val.byte = 0;
- break;
-
- case SV_SHORT:
- val._short = 0;
- break;
-
- case SV_LONG:
- val._long = 0;
- break;
-
- case SV_FLOAT:
- val._float = 0.0;
- break;
-
- case SV_STR:
- {
- std::string* str = static_cast<std::string*>(val.ptr);
- delete str;
- val.ptr = NULL;
- break;
- }
-
- case SV_COORD:
- {
- coord_def* coord = static_cast<coord_def*>(val.ptr);
- delete coord;
- val.ptr = NULL;
- break;
- }
-
- case SV_ITEM:
- {
- item_def* item = static_cast<item_def*>(val.ptr);
- delete item;
- val.ptr = NULL;
- break;
- }
-
- case SV_HASH:
- {
- CrawlHashTable* hash = static_cast<CrawlHashTable*>(val.ptr);
- delete hash;
- val.ptr = NULL;
- break;
- }
-
- case SV_VEC:
- {
- CrawlVector* vec = static_cast<CrawlVector*>(val.ptr);
- delete vec;
- val.ptr = NULL;
- break;
- }
-
- case SV_NONE:
- ASSERT(false);
-
- case NUM_STORE_VAL_TYPES:
- ASSERT(false);
- }
-
- flags |= SFLAG_UNSET;
-}
-
-// Only needed to do some assertion checking.
-CrawlStoreValue &CrawlStoreValue::operator = (const CrawlStoreValue &other)
-{
- ASSERT(other.type >= SV_NONE && other.type < NUM_STORE_VAL_TYPES);
- ASSERT(other.type != SV_NONE || type == SV_NONE);
-
- // NOTE: We don't bother checking SFLAG_CONST_VAL, since the
- // asignment operator is used when swapping two elements.
-
- if (!(flags & SFLAG_UNSET))
- {
- if (flags & SFLAG_CONST_TYPE)
- ASSERT(type == SV_NONE || type == other.type);
- }
-
- type = other.type;
- flags = other.flags;
- val = other.val;
-
- return (*this);
-}
-
-///////////////////////////////////
-// Meta-data accessors and changers
-store_flags CrawlStoreValue::get_flags() const
-{
- return flags;
-}
-
-store_flags CrawlStoreValue::set_flags(store_flags _flags)
-{
- flags |= _flags;
- return flags;
-}
-
-store_flags CrawlStoreValue::unset_flags(store_flags _flags)
-{
- flags &= ~_flags;
- return flags;
-}
-
-store_val_type CrawlStoreValue::get_type() const
-{
- return type;
-}
-
-//////////////////////////////
-// Read/write from/to savefile
-void CrawlStoreValue::write(tagHeader &th) const
-{
- ASSERT(!(flags & SFLAG_UNSET));
-
- marshallByte(th, (char) type);
- marshallByte(th, (char) flags);
-
- switch (type)
- {
- case SV_BOOL:
- marshallBoolean(th, val.boolean);
- break;
-
- case SV_BYTE:
- marshallByte(th, val.byte);
- break;
-
- case SV_SHORT:
- marshallShort(th, val._short);
- break;
-
- case SV_LONG:
- marshallLong(th, val._long);
- break;
-
- case SV_FLOAT:
- marshallFloat(th, val._float);
- break;
-
- case SV_STR:
- {
- std::string* str = static_cast<std::string*>(val.ptr);
- marshallString(th, *str);
- break;
- }
-
- case SV_COORD:
- {
- coord_def* coord = static_cast<coord_def*>(val.ptr);
- marshallCoord(th, *coord);
- break;
- }
-
- case SV_ITEM:
- {
- item_def* item = static_cast<item_def*>(val.ptr);
- marshallItem(th, *item);
- break;
- }
-
- case SV_HASH:
- {
- CrawlHashTable* hash = static_cast<CrawlHashTable*>(val.ptr);
- hash->write(th);
- break;
- }
-
- case SV_VEC:
- {
- CrawlVector* vec = static_cast<CrawlVector*>(val.ptr);
- vec->write(th);
- break;
- }
-
- case SV_NONE:
- ASSERT(false);
-
- case NUM_STORE_VAL_TYPES:
- ASSERT(false);
- }
-}
-
-void CrawlStoreValue::read(tagHeader &th)
-{
- type = static_cast<store_val_type>(unmarshallByte(th));
- flags = (store_flags) unmarshallByte(th);
-
- ASSERT(!(flags & SFLAG_UNSET));
-
- switch (type)
- {
- case SV_BOOL:
- val.boolean = unmarshallBoolean(th);
- break;
-
- case SV_BYTE:
- val.byte = unmarshallByte(th);
- break;
-
- case SV_SHORT:
- val._short = unmarshallShort(th);
- break;
-
- case SV_LONG:
- val._long = unmarshallLong(th);
- break;
-
- case SV_FLOAT:
- val._float = unmarshallFloat(th);
- break;
-
- case SV_STR:
- {
- std::string str = unmarshallString(th);
- val.ptr = (void*) new std::string(str);
- break;
- }
-
- case SV_COORD:
- {
- coord_def coord;
- unmarshallCoord(th, coord);
- val.ptr = (void*) new coord_def(coord);
-
- break;
- }
-
- case SV_ITEM:
- {
- item_def item;
- unmarshallItem(th, item);
- val.ptr = (void*) new item_def(item);
-
- break;
- }
-
- case SV_HASH:
- {
- CrawlHashTable* hash = new CrawlHashTable();
- hash->read(th);
- val.ptr = (void*) hash;
-
- break;
- }
-
- case SV_VEC:
- {
- CrawlVector* vec = new CrawlVector();
- vec->read(th);
- val.ptr = (void*) vec;
-
- break;
- }
-
- case SV_NONE:
- ASSERT(false);
-
- case NUM_STORE_VAL_TYPES:
- ASSERT(false);
- }
-}
-
-////////////////////////////////////////////////////////////////
-// Setup a new table with the given flags and/or type; assert if
-// a table already exists.
-CrawlHashTable &CrawlStoreValue::new_table(store_flags _flags)
-{
- return new_table(SV_NONE, flags);
-}
-
-CrawlHashTable &CrawlStoreValue::new_table(store_val_type _type,
- store_flags _flags)
-{
-#if DEBUG
- CrawlHashTable* old_table = static_cast<CrawlHashTable*>(val.ptr);
-
- ASSERT(flags & SFLAG_UNSET);
- ASSERT(type == SV_NONE
- || (type == SV_HASH
- && old_table->size() == 0
- && old_table->get_type() == SV_NONE
- && old_table->get_default_flags() == 0));
-#endif
-
- CrawlHashTable &table = get_table();
-
- table.default_flags = _flags;
- table.type = _type;
-
- type = SV_HASH;
- flags &= ~SFLAG_UNSET;
-
- return table;
-}
-
-////////////////////////////////////////////////////////////////
-// Setup a new vector with the given flags and/or type; assert if
-// a vector already exists.
-CrawlVector &CrawlStoreValue::new_vector(store_flags _flags,
- vec_size max_size)
-{
- return new_vector(SV_NONE, flags, max_size);
-}
-
-CrawlVector &CrawlStoreValue::new_vector(store_val_type _type,
- store_flags _flags,
- vec_size _max_size)
-{
-#if DEBUG
- CrawlVector* old_vector = static_cast<CrawlVector*>(val.ptr);
-
- ASSERT(flags & SFLAG_UNSET);
- ASSERT(type == SV_NONE
- || (type == SV_VEC
- && old_vector->size() == 0
- && old_vector->get_type() == SV_NONE
- && old_vector->get_default_flags() == 0
- && old_vector->get_max_size() == VEC_MAX_SIZE));
-#endif
-
- CrawlVector &vector = get_vector();
-
- vector.default_flags = _flags;
- vector.type = _type;
-
- type = SV_VEC;
- flags &= ~SFLAG_UNSET;
-
- return vector;
-}
-
-///////////////////////////////////////////
-// Dynamic type-checking accessor functions
-#define GET_VAL(x, _type, field, value) \
- ASSERT((flags & SFLAG_UNSET) || !(flags & SFLAG_CONST_VAL)); \
- if (type != (x)) \
- { \
- if (type == SV_NONE) \
- { \
- type = (x); \
- field = (value); \
- } \
- else \
- { \
- ASSERT(!(flags & SFLAG_CONST_TYPE)); \
- switch(type) \
- { \
- case SV_BOOL: \
- field = (_type) val.boolean; \
- break; \
- case SV_BYTE: \
- field = (_type) val.byte; \
- break; \
- case SV_SHORT: \
- field = (_type) val._short; \
- break; \
- case SV_LONG: \
- field = (_type) val._long; \
- break; \
- case SV_FLOAT: \
- field = (_type) val._float; \
- break; \
- default: \
- ASSERT(false); \
- } \
- type = (x); \
- } \
- } \
- flags &= ~SFLAG_UNSET; \
- return field;
-
-#define GET_VAL_PTR(x, _type, value) \
- ASSERT((flags & SFLAG_UNSET) || !(flags & SFLAG_CONST_VAL)); \
- if (type != (x)) \
- { \
- if (type == SV_NONE) \
- { \
- type = (x); \
- val.ptr = (value); \
- } \
- else \
- { \
- unset(); \
- val.ptr = (value); \
- type = (x); \
- } \
- } \
- flags &= ~SFLAG_UNSET; \
- return *((_type) val.ptr);
-
-bool &CrawlStoreValue::get_bool()
-{
- GET_VAL(SV_BOOL, bool, val.boolean, false);
-}
-
-char &CrawlStoreValue::get_byte()
-{
- GET_VAL(SV_BYTE, char, val.byte, 0);
-}
-
-short &CrawlStoreValue::get_short()
-{
- GET_VAL(SV_SHORT, short, val._short, 0);
-}
-
-long &CrawlStoreValue::get_long()
-{
- GET_VAL(SV_LONG, long, val._long, 0);
-}
-
-float &CrawlStoreValue::get_float()
-{
- GET_VAL(SV_FLOAT, float, val._float, 0.0);
-}
-
-std::string &CrawlStoreValue::get_string()
-{
- GET_VAL_PTR(SV_STR, std::string*, new std::string(""));
-}
-
-coord_def &CrawlStoreValue::get_coord()
-{
- GET_VAL_PTR(SV_COORD, coord_def*, new coord_def());
-}
-
-item_def &CrawlStoreValue::get_item()
-{
- GET_VAL_PTR(SV_ITEM, item_def*, new item_def());
-}
-
-CrawlHashTable &CrawlStoreValue::get_table()
-{
- GET_VAL_PTR(SV_HASH, CrawlHashTable*, new CrawlHashTable());
-}
-
-CrawlVector &CrawlStoreValue::get_vector()
-{
- GET_VAL_PTR(SV_VEC, CrawlVector*, new CrawlVector());
-}
-
-CrawlStoreValue &CrawlStoreValue::operator [] (const std::string &key)
-{
- return get_table()[key];
-}
-
-CrawlStoreValue &CrawlStoreValue::operator [] (const vec_size &index)
-{
- return get_vector()[index];
-}
-
-///////////////////////////
-// Const accessor functions
-#define GET_CONST_SETUP(x) \
- ASSERT(!(flags & SFLAG_UNSET)); \
- ASSERT(type == (x));
-
-bool CrawlStoreValue::get_bool() const
-{
- GET_CONST_SETUP(SV_BOOL);
- return val.boolean;
-}
-
-char CrawlStoreValue::get_byte() const
-{
- GET_CONST_SETUP(SV_BYTE);
- return val.byte;
-}
-
-short CrawlStoreValue::get_short() const
-{
- GET_CONST_SETUP(SV_SHORT);
- return val._short;
-}
-
-long CrawlStoreValue::get_long() const
-{
- GET_CONST_SETUP(SV_LONG);
- return val._long;
-}
-
-float CrawlStoreValue::get_float() const
-{
- GET_CONST_SETUP(SV_FLOAT);
- return val._float;
-}
-
-std::string CrawlStoreValue::get_string() const
-{
- GET_CONST_SETUP(SV_STR);
- return *((std::string*)val.ptr);
-}
-
-coord_def CrawlStoreValue::get_coord() const
-{
- GET_CONST_SETUP(SV_COORD);
- return *((coord_def*)val.ptr);
-}
-
-const item_def& CrawlStoreValue::get_item() const
-{
- GET_CONST_SETUP(SV_ITEM);
- return *((item_def*)val.ptr);
-}
-
-const CrawlHashTable& CrawlStoreValue::get_table() const
-{
- GET_CONST_SETUP(SV_HASH);
- return *((CrawlHashTable*)val.ptr);
-}
-
-const CrawlVector& CrawlStoreValue::get_vector() const
-{
- GET_CONST_SETUP(SV_VEC);
- return *((CrawlVector*)val.ptr);
-}
-
-const CrawlStoreValue &CrawlStoreValue::operator
- [] (const std::string &key) const
-{
- return get_table()[key];
-}
-
-const CrawlStoreValue &CrawlStoreValue::operator
- [](const vec_size &index) const
-{
- return get_vector()[index];
-}
-
-/////////////////////
-// Typecast operators
-&CrawlStoreValue::operator bool()
-{
- return get_bool();
-}
-
-&CrawlStoreValue::operator char()
-{
- return get_byte();
-}
-
-&CrawlStoreValue::operator short()
-{
- return get_short();
-}
-
-&CrawlStoreValue::operator float()
-{
- return get_float();
-}
-
-&CrawlStoreValue::operator long()
-{
- return get_long();
-}
-
-&CrawlStoreValue::operator std::string()
-{
- return get_string();
-}
-
-&CrawlStoreValue::operator coord_def()
-{
- return get_coord();
-}
-
-&CrawlStoreValue::operator CrawlHashTable()
-{
- return get_table();
-}
-
-&CrawlStoreValue::operator CrawlVector()
-{
- return get_vector();
-}
-
-&CrawlStoreValue::operator item_def()
-{
- return get_item();
-}
-
-///////////////////////////
-// Const typecast operators
-CrawlStoreValue::operator bool() const
-{
- return get_bool();
-}
-
-#define CONST_INT_CAST() \
- switch(type) \
- { \
- case SV_BYTE: \
- return get_byte(); \
- case SV_SHORT: \
- return get_short(); \
- case SV_LONG: \
- return get_long(); \
- default: \
- ASSERT(false); \
- return 0; \
- }
-
-CrawlStoreValue::operator char() const
-{
- CONST_INT_CAST();
-}
-
-CrawlStoreValue::operator short() const
-{
- CONST_INT_CAST();
-}
-
-CrawlStoreValue::operator long() const
-{
- CONST_INT_CAST();
-}
-
-CrawlStoreValue::operator float() const
-{
- return get_float();
-}
-
-CrawlStoreValue::operator std::string() const
-{
- return get_string();
-}
-
-CrawlStoreValue::operator coord_def() const
-{
- return get_coord();
-}
-
-///////////////////////
-// Assignment operators
-CrawlStoreValue &CrawlStoreValue::operator = (const bool &_val)
-{
- get_bool() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const char &_val)
-{
- get_byte() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const short &_val)
-{
- get_short() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const long &_val)
-{
- get_long() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const float &_val)
-{
- get_float() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const std::string &_val)
-{
- get_string() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const char* _val)
-{
- get_string() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const coord_def &_val)
-{
- get_coord() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const CrawlHashTable &_val)
-{
- get_table() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const CrawlVector &_val)
-{
- get_vector() = _val;
- return (*this);
-}
-
-CrawlStoreValue &CrawlStoreValue::operator = (const item_def &_val)
-{
- get_item() = _val;
- return (*this);
-}
-
-///////////////////////////////////////////////////
-// Non-assignment operators which affect the lvalue
-#define INT_OPERATOR_UNARY(op) \
- switch(type) \
- { \
- case SV_BYTE: \
- { \
- char &temp = get_byte(); \
- temp op; \
- return temp; \
- } \
- \
- case SV_SHORT: \
- { \
- short &temp = get_short(); \
- temp op; \
- return temp; \
- } \
- case SV_LONG: \
- { \
- long &temp = get_long(); \
- temp op; \
- return temp; \
- } \
- \
- default: \
- ASSERT(false); \
- return 0; \
- }
-
-// Prefix
-long CrawlStoreValue::operator ++ ()
-{
- INT_OPERATOR_UNARY(++);
-}
-
-long CrawlStoreValue::operator -- ()
-{
- INT_OPERATOR_UNARY(--);
-}
-
-// Postfix
-long CrawlStoreValue::operator ++ (int)
-{
- INT_OPERATOR_UNARY(++);
-}
-
-long CrawlStoreValue::operator -- (int)
-{
- INT_OPERATOR_UNARY(--);
-}
-
-std::string &CrawlStoreValue::operator += (const std::string &_val)
-{
- return (get_string() += _val);
-}
-
-////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////
-
-CrawlHashTable::CrawlHashTable()
- : type(SV_NONE), default_flags(0)
-{
-}
-
-CrawlHashTable::CrawlHashTable(store_flags flags)
- : type(SV_NONE), default_flags(flags)
-{
- ASSERT(!(default_flags & SFLAG_UNSET));
-}
-
-CrawlHashTable::CrawlHashTable(store_val_type _type, store_flags flags)
- : type(_type), default_flags(flags)
-{
- ASSERT(type >= SV_NONE && type < NUM_STORE_VAL_TYPES);
- ASSERT(!(default_flags & SFLAG_UNSET));
-}
-
-CrawlHashTable::~CrawlHashTable()
-{
- assert_validity();
-}
-
-//////////////////////////////
-// Read/write from/to savefile
-void CrawlHashTable::write(tagHeader &th) const
-{
- assert_validity();
- if (empty())
- {
- marshallByte(th, 0);
- return;
- }
-
- marshallByte(th, size());
- marshallByte(th, static_cast<char>(type));
- marshallByte(th, (char) default_flags);
-
- CrawlHashTable::hash_map_type::const_iterator i = hash_map.begin();
-
- for (; i != hash_map.end(); i++)
- {
- marshallString(th, i->first);
- i->second.write(th);
- }
-
- assert_validity();
-}
-
-void CrawlHashTable::read(tagHeader &th)
-{
- assert_validity();
-
- ASSERT(empty());
- ASSERT(type == SV_NONE);
- ASSERT(default_flags == 0);
-
- hash_size _size = (hash_size) unmarshallByte(th);
-
- if (_size == 0)
- return;
-
- type = static_cast<store_val_type>(unmarshallByte(th));
- default_flags = (store_flags) unmarshallByte(th);
-
- for (hash_size i = 0; i < _size; i++)
- {
- std::string key = unmarshallString(th);
- CrawlStoreValue &val = (*this)[key];
-
- val.read(th);
- }
-
- assert_validity();
-}
-
-
-//////////////////
-// Misc functions
-
-store_flags CrawlHashTable::get_default_flags() const
-{
- assert_validity();
- return default_flags;
-}
-
-store_flags CrawlHashTable::set_default_flags(store_flags flags)
-{
- assert_validity();
- ASSERT(!(flags & SFLAG_UNSET));
- default_flags |= flags;
-
- return default_flags;
-}
-
-store_flags CrawlHashTable::unset_default_flags(store_flags flags)
-{
- assert_validity();
- ASSERT(!(flags & SFLAG_UNSET));
- default_flags &= ~flags;
-
- return default_flags;
-}
-
-store_val_type CrawlHashTable::get_type() const
-{
- assert_validity();
- return type;
-}
-
-bool CrawlHashTable::exists(const std::string key) const
-{
- assert_validity();
- hash_map_type::const_iterator i = hash_map.find(key);
-
- return (i != hash_map.end());
-}
-
-void CrawlHashTable::assert_validity() const
-{
-#if DEBUG
- ASSERT(!(default_flags & SFLAG_UNSET));
-
- hash_map_type::const_iterator i = hash_map.begin();
-
- unsigned long actual_size = 0;
-
- for (; i != hash_map.end(); i++)
- {
- actual_size++;
-
- const std::string &key = i->first;
- const CrawlStoreValue &val = i->second;
-
- ASSERT(key != "");
- std::string trimmed = trimmed_string(key);
- ASSERT(key == trimmed);
-
- ASSERT(val.type != SV_NONE);
- ASSERT(!(val.flags & SFLAG_UNSET));
-
- switch(val.type)
- {
- case SV_STR:
- case SV_COORD:
- case SV_ITEM:
- ASSERT(val.val.ptr != NULL);
- break;
-
- case SV_HASH:
- {
- ASSERT(val.val.ptr != NULL);
-
- CrawlHashTable* nested;
- nested = static_cast<CrawlHashTable*>(val.val.ptr);
-
- nested->assert_validity();
- break;
- }
-
- default:
- break;
- }
- }
-
- ASSERT(size() == actual_size);
-#endif
-}
-
-////////////////////////////////
-// Accessors to contained values
-
-CrawlStoreValue& CrawlHashTable::get_value(const std::string &key)
-{
- assert_validity();
- iterator i = hash_map.find(key);
-
- if (i == hash_map.end())
- {
- hash_map[key] = CrawlStoreValue(default_flags);
- CrawlStoreValue &val = hash_map[key];
-
- if (type != SV_NONE)
- {
- val.type = type;
- val.flags |= SFLAG_CONST_TYPE;
- }
-
- return (val);
- }
-
- return (i->second);
-}
-
-const CrawlStoreValue& CrawlHashTable::get_value(const std::string &key) const
-{
- assert_validity();
- hash_map_type::const_iterator i = hash_map.find(key);
-
- ASSERT(i != hash_map.end());
- ASSERT(i->second.type != SV_NONE);
- ASSERT(!(i->second.flags & SFLAG_UNSET));
-
- return (i->second);
-}
-
-CrawlStoreValue& CrawlHashTable::operator[] (const std::string &key)
-{
- return get_value(key);
-}
-
-const CrawlStoreValue& CrawlHashTable::operator[] (const std::string &key)
- const
-{
- return get_value(key);
-}
-
-///////////////////////////
-// std::map style interface
-hash_size CrawlHashTable::size() const
-{
- return hash_map.size();
-}
-
-bool CrawlHashTable::empty() const
-{
- return hash_map.empty();
-}
-
-void CrawlHashTable::erase(const std::string key)
-{
- assert_validity();
- iterator i = hash_map.find(key);
-
- if (i != hash_map.end())
- {
-#if DEBUG
- CrawlStoreValue &val = i->second;
- ASSERT(!(val.flags & SFLAG_NO_ERASE));
-#endif
-
- hash_map.erase(i);
- }
-}
-
-void CrawlHashTable::clear()
-{
- assert_validity();
- ASSERT(!(default_flags & SFLAG_NO_ERASE));
-
- iterator i = hash_map.begin();
- for (; i != hash_map.end(); i++)
- ASSERT(!(i->second.flags & SFLAG_NO_ERASE));
-
- hash_map.clear();
- default_flags = 0;
- type = SV_NONE;
-}
-
-CrawlHashTable::iterator CrawlHashTable::begin()
-{
- assert_validity();
- return hash_map.begin();
-}
-
-CrawlHashTable::iterator CrawlHashTable::end()
-{
- assert_validity();
- return hash_map.end();
-}
-
-CrawlHashTable::const_iterator CrawlHashTable::begin() const
-{
- assert_validity();
- return hash_map.begin();
-}
-
-CrawlHashTable::const_iterator CrawlHashTable::end() const
-{
- assert_validity();
- return hash_map.end();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CrawlVector::CrawlVector()
- : type(SV_NONE), default_flags(0), max_size(VEC_MAX_SIZE)
-{
-}
-
-CrawlVector::CrawlVector(store_flags flags, vec_size _max_size)
- : type(SV_NONE), default_flags(flags), max_size(_max_size)
-{
- ASSERT(!(default_flags & SFLAG_UNSET));
- ASSERT(max_size > 0);
-}
-
-CrawlVector::CrawlVector(store_val_type _type, store_flags flags,
- vec_size _max_size)
- : type(_type), default_flags(flags), max_size(_max_size)
-{
- ASSERT(type >= SV_NONE && type < NUM_STORE_VAL_TYPES);
- ASSERT(!(default_flags & SFLAG_UNSET));
- ASSERT(max_size > 0);
-}
-
-CrawlVector::~CrawlVector()
-{
- assert_validity();
-}
-
-//////////////////////////////
-// Read/write from/to savefile
-void CrawlVector::write(tagHeader &th) const
-{
- assert_validity();
- if (empty())
- {
- marshallByte(th, 0);
- return;
- }
-
- marshallByte(th, (char) size());
- marshallByte(th, (char) max_size);
- marshallByte(th, static_cast<char>(type));
- marshallByte(th, (char) default_flags);
-
- for (vec_size i = 0; i < size(); i++)
- {
- CrawlStoreValue val = vector[i];
- ASSERT(val.type != SV_NONE);
- ASSERT(!(val.flags & SFLAG_UNSET));
- val.write(th);
- }
-
- assert_validity();
-}
-
-void CrawlVector::read(tagHeader &th)
-{
- assert_validity();
-
- ASSERT(empty());
- ASSERT(type == SV_NONE);
- ASSERT(default_flags == 0);
- ASSERT(max_size == VEC_MAX_SIZE);
-
- vec_size _size = (vec_size) unmarshallByte(th);
-
- if (_size == 0)
- return;
-
- max_size = static_cast<vec_size>(unmarshallByte(th));
- type = static_cast<store_val_type>(unmarshallByte(th));
- default_flags = static_cast<store_flags>(unmarshallByte(th));
-
- ASSERT(_size <= max_size);
-
- vector.resize(_size);
-
- for (vec_size i = 0; i < _size; i++)
- vector[i].read(th);
-
- assert_validity();
-}
-
-
-//////////////////
-// Misc functions
-
-store_flags CrawlVector::get_default_flags() const
-{
- assert_validity();
- return default_flags;
-}
-
-store_flags CrawlVector::set_default_flags(store_flags flags)
-{
- assert_validity();
- ASSERT(!(flags & SFLAG_UNSET));
- default_flags |= flags;
-
- return default_flags;
-}
-
-store_flags CrawlVector::unset_default_flags(store_flags flags)
-{
- assert_validity();
- ASSERT(!(flags & SFLAG_UNSET));
- default_flags &= ~flags;
-
- return default_flags;
-}
-
-store_val_type CrawlVector::get_type() const
-{
- assert_validity();
- return type;
-}
-
-void CrawlVector::assert_validity() const
-{
-#if DEBUG
- ASSERT(!(default_flags & SFLAG_UNSET));
- ASSERT(max_size > 0);
- ASSERT(max_size >= size());
-
- for (vec_size i = 0, _size = size(); i < _size; i++)
- {
- const CrawlStoreValue &val = vector[i];
-
- // A vector might be resize()'d and filled up with unset
- // values, which are then set one by one, so we can't
- // assert over that here.
- if (val.type == SV_NONE || (val.flags & SFLAG_UNSET))
- continue;
-
- switch(val.type)
- {
- case SV_STR:
- case SV_COORD:
- case SV_ITEM:
- ASSERT(val.val.ptr != NULL);
- break;
-
- case SV_HASH:
- {
- ASSERT(val.val.ptr != NULL);
-
- CrawlVector* nested;
- nested = static_cast<CrawlVector*>(val.val.ptr);
-
- nested->assert_validity();
- break;
- }
-
- case SV_VEC:
- {
- ASSERT(val.val.ptr != NULL);
-
- CrawlVector* nested;
- nested = static_cast<CrawlVector*>(val.val.ptr);
-
- nested->assert_validity();
- break;
- }
-
- default:
- break;
- }
- }
-#endif
-}
-
-void CrawlVector::set_max_size(vec_size _size)
-{
- ASSERT(_size > 0);
- ASSERT(max_size == VEC_MAX_SIZE);
- max_size = _size;
-
- vector.reserve(max_size);
-}
-
-vec_size CrawlVector::get_max_size() const
-{
- return max_size;
-}
-
-
-////////////////////////////////
-// Accessors to contained values
-
-CrawlStoreValue& CrawlVector::get_value(const vec_size &index)
-{
- assert_validity();
-
- ASSERT(index <= max_size);
- ASSERT(index <= vector.size());
-
- return vector[index];
-}
-
-const CrawlStoreValue& CrawlVector::get_value(const vec_size &index) const
-{
- assert_validity();
-
- ASSERT(index <= max_size);
- ASSERT(index <= vector.size());
-
- return vector[index];
-}
-
-CrawlStoreValue& CrawlVector::operator[] (const vec_size &index)
-{
- return get_value(index);
-}
-
-const CrawlStoreValue& CrawlVector::operator[] (const vec_size &index) const
-{
- return get_value(index);
-}
-
-///////////////////////////
-// std::vector style interface
-vec_size CrawlVector::size() const
-{
- return vector.size();
-}
-
-bool CrawlVector::empty() const
-{
- return vector.empty();
-}
-
-CrawlStoreValue& CrawlVector::pop_back()
-{
- assert_validity();
- ASSERT(vector.size() > 0);
-
- CrawlStoreValue& val = vector[vector.size() - 1];
- vector.pop_back();
- return val;
-}
-
-void CrawlVector::push_back(CrawlStoreValue val)
-{
- assert_validity();
- ASSERT(vector.size() < max_size);
- ASSERT(type == SV_NONE
- || (val.type == SV_NONE && (val.flags & SFLAG_UNSET))
- || (val.type == type));
- val.flags |= default_flags;
- if (type != SV_NONE)
- {
- val.type = type;
- val.flags |= SFLAG_CONST_TYPE;
- }
- vector.push_back(val);
-}
-
-void CrawlVector::insert(const vec_size index, CrawlStoreValue val)
-{
- assert_validity();
- ASSERT(vector.size() < max_size);
- ASSERT(type == SV_NONE
- || (val.type == SV_NONE && (val.flags & SFLAG_UNSET))
- || (val.type == type));
- val.flags |= default_flags;
- if (type != SV_NONE)
- {
- val.type = type;
- val.flags |= SFLAG_CONST_TYPE;
- }
- vector.insert(vector.begin() + index, val);
-}
-
-void CrawlVector::resize(const vec_size _size)
-{
- assert_validity();
- ASSERT(max_size == VEC_MAX_SIZE);
- ASSERT(_size < max_size);
-
- vec_size old_size = size();
- vector.resize(_size);
-
- for (vec_size i = old_size; i < _size; i++)
- {
- vector[i].flags = SFLAG_UNSET | default_flags;
- vector[i].type = SV_NONE;
- }
-}
-
-void CrawlVector::erase(const vec_size index)
-{
- assert_validity();
- ASSERT(index <= max_size);
- ASSERT(index <= vector.size());
-
- vector.erase(vector.begin() + index);
-}
-
-void CrawlVector::clear()
-{
- assert_validity();
- ASSERT(!(default_flags & SFLAG_NO_ERASE));
-
- for (vec_size i = 0, _size = size(); i < _size; i++)
- ASSERT(!(vector[i].flags & SFLAG_NO_ERASE));
-
- vector.clear();
- default_flags = 0;
- type = SV_NONE;
-}
-
-CrawlVector::iterator CrawlVector::begin()
-{
- assert_validity();
- return vector.begin();
-}
-
-CrawlVector::iterator CrawlVector::end()
-{
- assert_validity();
- return vector.end();
-}
-
-CrawlVector::const_iterator CrawlVector::begin() const
-{
- assert_validity();
- return vector.begin();
-}
-
-CrawlVector::const_iterator CrawlVector::end() const
-{
- assert_validity();
- return vector.end();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-template <typename T, store_val_type TYPE>
-CrawlTableWrapper<T, TYPE>::CrawlTableWrapper()
-{
- table = NULL;
-}
-
-template <typename T, store_val_type TYPE>
-CrawlTableWrapper<T, TYPE>::CrawlTableWrapper(CrawlHashTable& _table)
-{
- wrap(_table);
-}
-
-template <typename T, store_val_type TYPE>
-CrawlTableWrapper<T, TYPE>::CrawlTableWrapper(CrawlHashTable* _table)
-{
- wrap(_table);
-}
-
-template <typename T, store_val_type TYPE>
-void CrawlTableWrapper<T, TYPE>::wrap(CrawlHashTable& _table)
-{
- wrap(&_table);
-}
-
-template <typename T, store_val_type TYPE>
-void CrawlTableWrapper<T, TYPE>::wrap(CrawlHashTable* _table)
-{
- ASSERT(_table != NULL);
- ASSERT(_table->get_type() == TYPE);
-
- table = _table;
-}
-
-template <typename T, store_val_type TYPE>
-T& CrawlTableWrapper<T, TYPE>::operator[] (const std::string &key)
-{
- return (T&) (*table)[key];
-}
-
-template <typename T, store_val_type TYPE>
-const T CrawlTableWrapper<T, TYPE>::operator[] (const std::string &key) const
-{
- return (T) (*table)[key];
-}
diff --git a/crawl-ref/source/store.h b/crawl-ref/source/store.h
deleted file mode 100644
index 434c0cd74d..0000000000
--- a/crawl-ref/source/store.h
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * File: store.cc
- * Summary: Saveable hash-table and vector capable of storing
- * multiple types of data.
- * Written by: Matthew Cline
- *
- * Modified for Crawl Reference by $Author$ on $Date$
- *
- * Change History (most recent first):
-
- * <1> 10/5/07 MPC Created
- */
-
-#ifndef STORE_H
-#define STORE_H
-
-#include <limits.h>
-#include <map>
-#include <string>
-#include <vector>
-
-struct tagHeader;
-class CrawlHashTable;
-class CrawlVector;
-class item_def;
-class coord_def;
-
-typedef unsigned char hash_size;
-typedef unsigned char vec_size;
-typedef unsigned char store_flags;
-
-#define VEC_MAX_SIZE 255
-#define HASH_MAX_SIZE 255
-
-// NOTE: Changing the ordering of these enums will break savefile
-// compatibility.
-enum store_val_type
-{
- SV_NONE = 0,
- SV_BOOL,
- SV_BYTE,
- SV_SHORT,
- SV_LONG,
- SV_FLOAT,
- SV_STR,
- SV_COORD,
- SV_ITEM,
- SV_HASH,
- SV_VEC,
- NUM_STORE_VAL_TYPES
-};
-
-enum store_flag_type
-{
- SFLAG_UNSET = (1 << 0),
- SFLAG_CONST_VAL = (1 << 1),
- SFLAG_CONST_TYPE = (1 << 2),
- SFLAG_NO_ERASE = (1 << 3)
-};
-
-
-// Can't just cast everything into a void pointer, since a float might
-// not fit into a pointer on all systems.
-typedef union StoreUnion StoreUnion;
-union StoreUnion
-{
- bool boolean;
- char byte;
- short _short;
- long _long;
- float _float;
- void* ptr;
-};
-
-
-class CrawlStoreValue
-{
-public:
- CrawlStoreValue();
- CrawlStoreValue(const CrawlStoreValue &other);
-
- ~CrawlStoreValue();
-
- // Conversion constructors
- CrawlStoreValue(const bool val);
- CrawlStoreValue(const char &val);
- CrawlStoreValue(const short &val);
- CrawlStoreValue(const long &val);
- CrawlStoreValue(const float &val);
- CrawlStoreValue(const std::string &val);
- CrawlStoreValue(const char* val);
- CrawlStoreValue(const coord_def &val);
- CrawlStoreValue(const item_def &val);
- CrawlStoreValue(const CrawlHashTable &val);
- CrawlStoreValue(const CrawlVector &val);
-
- // Only needed for doing some assertion checking.
- CrawlStoreValue &operator = (const CrawlStoreValue &other);
-
-protected:
- store_val_type type;
- store_flags flags;
- StoreUnion val;
-
-public:
- store_flags get_flags() const;
- store_flags set_flags(store_flags flags);
- store_flags unset_flags(store_flags flags);
- store_val_type get_type() const;
-
- CrawlHashTable &new_table(store_flags flags);
- CrawlHashTable &new_table(store_val_type type, store_flags flags = 0);
-
- CrawlVector &new_vector(store_flags flags,
- vec_size max_size = VEC_MAX_SIZE);
- CrawlVector &new_vector(store_val_type type, store_flags flags = 0,
- vec_size max_size = VEC_MAX_SIZE);
-
- bool &get_bool();
- char &get_byte();
- short &get_short();
- long &get_long();
- float &get_float();
- std::string &get_string();
- coord_def &get_coord();
- CrawlHashTable &get_table();
- CrawlVector &get_vector();
- item_def &get_item();
-
- bool get_bool() const;
- char get_byte() const;
- short get_short() const;
- long get_long() const;
- float get_float() const;
- std::string get_string() const;
- coord_def get_coord() const;
-
- const CrawlHashTable& get_table() const;
- const CrawlVector& get_vector() const;
- const item_def& get_item() const;
-
- void set_bool(const bool val);
- void set_byte(const char val);
- void set_short(const short val);
- void set_long(const long val);
- void set_float(const float val);
- void set_string(const std::string &val);
- void set_coord(const coord_def &val);
- void set_table(const CrawlHashTable &val);
- void set_vector(const CrawlVector &val);
- void set_item(const item_def &val);
-
-public:
- // NOTE: All operators will assert if the value is of the wrong
- // type for the operation. If the value has no type yet, the
- // operation will set it to the appropriate type. If the value
- // has no type yet and the operation modifies the existing value
- // rather than replacing it (e.g., ++) the value will be set to a
- // default before the operation is done.
-
- // If the value is a hash table or vector, the container's values
- // can be accessed with the [] operator with the approriate key
- // type (strings for hashes, longs for vectors).
- CrawlStoreValue &operator [] (const std::string &key);
- CrawlStoreValue &operator [] (const vec_size &index);
-
- const CrawlStoreValue &operator [] (const std::string &key) const;
- const CrawlStoreValue &operator [] (const vec_size &index) const;
-
- // Typecast operators
- &operator bool();
- &operator char();
- &operator short();
- &operator long();
- &operator float();
- &operator std::string();
- &operator coord_def();
- &operator CrawlHashTable();
- &operator CrawlVector();
- &operator item_def();
-
- operator bool() const;
- operator char() const;
- operator short() const;
- operator long() const;
- operator float() const;
- operator std::string() const;
- operator coord_def() const;
-
- // Assignment operators
- CrawlStoreValue &operator = (const bool &val);
- CrawlStoreValue &operator = (const char &val);
- CrawlStoreValue &operator = (const short &val);
- CrawlStoreValue &operator = (const long &val);
- CrawlStoreValue &operator = (const float &val);
- CrawlStoreValue &operator = (const std::string &val);
- CrawlStoreValue &operator = (const char* val);
- CrawlStoreValue &operator = (const coord_def &val);
- CrawlStoreValue &operator = (const CrawlHashTable &val);
- CrawlStoreValue &operator = (const CrawlVector &val);
- CrawlStoreValue &operator = (const item_def &val);
-
- // Misc operators
- std::string &operator += (const std::string &val);
-
- // Prefix
- long operator ++ ();
- long operator -- ();
-
- // Postfix
- long operator ++ (int);
- long operator -- (int);
-
-protected:
- CrawlStoreValue(const store_flags flags,
- const store_val_type type = SV_NONE);
-
- void write(tagHeader &th) const;
- void read(tagHeader &th);
-
- void unset(bool force = false);
-
- friend class CrawlHashTable;
- friend class CrawlVector;
-};
-
-
-// A hash table can have a maximum of 255 key/value pairs. If you
-// want more than that you can use nested hash tables.
-//
-// By default a hash table's value data types are heterogeneous. To
-// make it homogeneous (which causes dynamic type checking) you have
-// to give a type to the hash table constructor; once it's been
-// created its type (or lack of type) is immutable.
-//
-// An empty hash table will take up only 1 byte in the savefile. A
-// non-empty hash table will have an overhead of 3 bytes for the hash
-// table overall and 2 bytes per key/value pair, over and above the
-// number of bytes needed to store the keys and values themselves.
-class CrawlHashTable
-{
-public:
- CrawlHashTable();
- CrawlHashTable(store_flags flags);
- CrawlHashTable(store_val_type type, store_flags flags = 0);
-
- ~CrawlHashTable();
-
- typedef std::map<std::string, CrawlStoreValue> hash_map_type;
- typedef hash_map_type::iterator iterator;
- typedef hash_map_type::const_iterator const_iterator;
-
-protected:
- store_val_type type;
- store_flags default_flags;
- hash_map_type hash_map;
-
- friend class CrawlStoreValue;
-
-public:
- void write(tagHeader &th) const;
- void read(tagHeader &th);
-
- store_flags get_default_flags() const;
- store_flags set_default_flags(store_flags flags);
- store_flags unset_default_flags(store_flags flags);
- store_val_type get_type() const;
- bool exists(const std::string key) const;
- void assert_validity() const;
-
- // NOTE: If the const versions of get_value() or [] are given a
- // key which doesn't exist, they will assert.
- const CrawlStoreValue& get_value(const std::string &key) const;
- const CrawlStoreValue& operator[] (const std::string &key) const;
-
- // NOTE: If get_value() or [] is given a key which doesn't exist
- // in the table, an unset/empty CrawlStoreValue will be created
- // with that key and returned. If it is not then given a value
- // then the next call to assert_validity() will fail. If the
- // hash table has a type (rather than being heterogeneous)
- // then trying to assign a different type to the CrawlStoreValue
- // will assert.
- CrawlStoreValue& get_value(const std::string &key);
- CrawlStoreValue& operator[] (const std::string &key);
-
- // std::map style interface
- hash_size size() const;
- bool empty() const;
-
- void erase(const std::string key);
- void clear();
-
- const_iterator begin() const;
- const_iterator end() const;
-
- iterator begin();
- iterator end();
-};
-
-// A CrawlVector is the vector version of CrawlHashTable, except that
-// a non-empty CrawlVector has one more byte of savefile overhead that
-// a hash table, and that can specify a maximum size to make it act
-// similarly to a FixedVec.
-class CrawlVector
-{
-public:
- CrawlVector();
- CrawlVector(store_flags flags, vec_size max_size = VEC_MAX_SIZE);
- CrawlVector(store_val_type type, store_flags flags = 0,
- vec_size max_size = VEC_MAX_SIZE);
-
- ~CrawlVector();
-
- typedef std::vector<CrawlStoreValue> vector_type;
- typedef vector_type::iterator iterator;
- typedef vector_type::const_iterator const_iterator;
-
-protected:
- store_val_type type;
- store_flags default_flags;
- vec_size max_size;
- vector_type vector;
-
- friend class CrawlStoreValue;
-
-public:
- void write(tagHeader &th) const;
- void read(tagHeader &th);
-
- store_flags get_default_flags() const;
- store_flags set_default_flags(store_flags flags);
- store_flags unset_default_flags(store_flags flags);
- store_val_type get_type() const;
- void assert_validity() const;
- void set_max_size(vec_size size);
- vec_size get_max_size() const;
-
- // NOTE: If the const versions of get_value() or [] are given a
- // index which doesn't exist, they will assert.
- const CrawlStoreValue& get_value(const vec_size &index) const;
- const CrawlStoreValue& operator[] (const vec_size &index) const;
-
- CrawlStoreValue& get_value(const vec_size &index);
- CrawlStoreValue& operator[] (const vec_size &index);
-
- // std::vector style interface
- vec_size size() const;
- bool empty() const;
-
- // NOTE: push_back() and insert() have val passed by value rather
- // than by reference so that conversion constructors will work.
- CrawlStoreValue& pop_back();
- void push_back(CrawlStoreValue val);
- void insert(const vec_size index, CrawlStoreValue val);
-
- // resize() will assert if the maximum size has been set.
- void resize(const vec_size size);
- void erase(const vec_size index);
- void clear();
-
- const_iterator begin() const;
- const_iterator end() const;
-
- iterator begin();
- iterator end();
-};
-
-// A wrapper for non-heterogeneous hash tables, so that the values can
-// be accessed without using get_foo(). T needs to have both normal
-// and const type-cast operators defined by CrawlStoreValue for this
-// template to work.
-template <typename T, store_val_type TYPE>
-class CrawlTableWrapper
-{
-public:
- CrawlTableWrapper();
- CrawlTableWrapper(CrawlHashTable& table);
- CrawlTableWrapper(CrawlHashTable* table);
-
-protected:
- CrawlHashTable* table;
-
-public:
- void wrap(CrawlHashTable& table);
- void wrap(CrawlHashTable* table);
-
- const CrawlHashTable* get_table() const;
- const T operator[] (const std::string &key) const;
-
- CrawlHashTable* get_table();
- T& operator[] (const std::string &key);
-};
-
-typedef CrawlTableWrapper<bool, SV_BOOL> CrawlBoolTable;
-typedef CrawlTableWrapper<char, SV_BYTE> CrawlByteTable;
-typedef CrawlTableWrapper<short, SV_SHORT> CrawlShortTable;
-typedef CrawlTableWrapper<long, SV_LONG> CrawlLongTable;
-typedef CrawlTableWrapper<float, SV_FLOAT> CrawlFloatTable;
-typedef CrawlTableWrapper<std::string, SV_STR> CrawlStringTable;
-typedef CrawlTableWrapper<coord_def, SV_COORD> CrawlCoordTable;
-
-#endif
diff --git a/crawl-ref/source/version.h b/crawl-ref/source/version.h
index c99e6ac1b0..5311630fb5 100644
--- a/crawl-ref/source/version.h
+++ b/crawl-ref/source/version.h
@@ -37,7 +37,7 @@
#define CRAWL "Dungeon Crawl Stone Soup"
-#define VER_NUM "0.3.2"
+#define VER_NUM "0.3.3"
#define VER_QUAL ""
// last updated 07august2001 {mv}
diff --git a/crawl-ref/source/xom.h b/crawl-ref/source/xom.h
deleted file mode 100644
index ec8878c9b1..0000000000
--- a/crawl-ref/source/xom.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * File: xom.h
- * Summary: Misc Xom related functions.
- * Written by: Linley Henzell
- *
- * Modified for Crawl Reference by $Author$ on $Date$
- *
- * Change History (most recent first):
- *
- * <1> 09/28/07 MPC Split from religion.h
- */
-
-#ifndef XOM_H
-#define XOM_H
-
-class item_def;
-
-enum xom_message_type
-{
- XM_NORMAL,
- XM_INTRIGUED,
- NUM_XOM_MESSAGE_TYPES
-};
-
-void xom_is_stimulated(int maxinterestingness,
- xom_message_type message_type = XM_NORMAL,
- bool force_message = false);
-void xom_is_stimulated(int maxinterestingness, const std::string& message,
- bool force_message = false);
-bool xom_is_nice();
-void xom_acts(bool niceness, int sever);
-const char *describe_xom_favour();
-
-inline void xom_acts(int sever)
-{
- xom_acts(xom_is_nice(), sever);
-}
-
-void xom_check_lost_item(const item_def& item);
-void xom_check_destroyed_item(const item_def& item, int cause = -1);
-bool there_are_monsters_nearby();
-
-#endif