summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-15 20:09:19 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-15 20:09:19 +0000
commit141a6b8304cb7a55cad08cd1de379e43ca83b38b (patch)
tree56a1e039e771a49242d2c3ae3a3c4e3ceecb598f /crawl-ref/source
parentceb4c8964c99e64f6adebad119e1bbbafafedd62 (diff)
downloadcrawl-ref-141a6b8304cb7a55cad08cd1de379e43ca83b38b.tar.gz
crawl-ref-141a6b8304cb7a55cad08cd1de379e43ca83b38b.zip
Apply my recent commits to trunk.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9984 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/acr.cc20
-rw-r--r--crawl-ref/source/beam.cc11
-rw-r--r--crawl-ref/source/beam.h1
-rw-r--r--crawl-ref/source/directn.cc1
-rw-r--r--crawl-ref/source/libdos.cc1
-rw-r--r--crawl-ref/source/libgui.cc5
-rw-r--r--crawl-ref/source/libunix.cc1
-rw-r--r--crawl-ref/source/libw32c.cc3
-rw-r--r--crawl-ref/source/menu.cc2
-rw-r--r--crawl-ref/source/message.cc10
-rw-r--r--crawl-ref/source/message.h1
-rw-r--r--crawl-ref/source/newgame.cc10
-rw-r--r--crawl-ref/source/stuff.cc10
-rw-r--r--crawl-ref/source/stuff.h1
-rw-r--r--crawl-ref/source/tilefont.cc41
-rw-r--r--crawl-ref/source/tilereg.cc26
-rw-r--r--crawl-ref/source/tilesdl.cc8
-rw-r--r--crawl-ref/source/tiletex.cc6
-rw-r--r--crawl-ref/source/view.cc44
-rw-r--r--crawl-ref/source/view.h1
20 files changed, 131 insertions, 72 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index b0e05d51fd..f7364fa457 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -286,6 +286,8 @@ int main( int argc, char *argv[] )
while (true)
_input();
+ clear_globals_on_exit();
+
return 0;
}
@@ -1005,12 +1007,13 @@ static void _input()
c_input_reset(true);
_center_cursor();
- // Enable the cursor to read input. The cursor stays on while
- // the command is being processed, so subsidiary prompts
- // shouldn't need to turn it on explicitly.
+
#ifdef USE_TILE
cursor_control con(false);
#else
+ // Enable the cursor to read input. The cursor stays on while
+ // the command is being processed, so subsidiary prompts
+ // shouldn't need to turn it on explicitly.
cursor_control con(true);
#endif
const command_type cmd = _get_next_cmd();
@@ -2535,8 +2538,11 @@ void world_reacts()
}
#ifdef USE_TILE
- tiles.clear_text_tags(TAG_TUTORIAL);
- tiles.place_cursor(CURSOR_TUTORIAL, Region::NO_CURSOR);
+ if (Options.tutorial_left)
+ {
+ tiles.clear_text_tags(TAG_TUTORIAL);
+ tiles.place_cursor(CURSOR_TUTORIAL, Region::NO_CURSOR);
+ }
#endif
if (you.num_turns != -1)
@@ -3425,6 +3431,10 @@ static bool _initialise(void)
#endif
#ifdef USE_TILE
+ // Override inventory weights options for tiled menus.
+ if (Options.tile_menu_icons && Options.show_inventory_weights)
+ Options.show_inventory_weights = false;
+
tiles.resize();
#endif
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 31511af214..c05e1bf18f 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -5522,7 +5522,7 @@ bolt::bolt() : range(-2), type('*'),
smart_monster(false), can_see_invis(false),
attitude(ATT_HOSTILE), foe_ratio(0), chose_ray(false),
beam_cancelled(false), dont_stop_player(false), bounces(false),
- bounce_pos(), reflections(0), reflector(-1)
+ bounce_pos(), reflections(0), reflector(-1), auto_hit(false)
{
}
@@ -5718,3 +5718,12 @@ std::string beam_type_name(beam_type type)
DEBUGSTR("unknown beam type");
return("UNKNOWN");
}
+
+void clear_zap_info_on_exit()
+{
+ for (unsigned int i = 0; i < NUM_BEAMS; ++i)
+ {
+ delete zap_data[i].damage;
+ delete zap_data[i].tohit;
+ }
+}
diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h
index 88ff7c4b47..a87283766b 100644
--- a/crawl-ref/source/beam.h
+++ b/crawl-ref/source/beam.h
@@ -295,5 +295,6 @@ bool zapping(zap_type ztype, int power, bolt &pbolt,
bool player_tracer(zap_type ztype, int power, bolt &pbolt, int range = 0);
std::string beam_type_name(beam_type type);
+void clear_zap_info_on_exit();
#endif
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 073565e368..eaeb19075f 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -788,6 +788,7 @@ void full_describe_view()
// Unset show_glyph for other menus.
InvEntry *me = new InvEntry(list_items[0]);
me->set_show_glyph(false);
+ delete me;
}
#else
// Clear cursor placement.
diff --git a/crawl-ref/source/libdos.cc b/crawl-ref/source/libdos.cc
index 8442bf9e06..c141a0f950 100644
--- a/crawl-ref/source/libdos.cc
+++ b/crawl-ref/source/libdos.cc
@@ -1,6 +1,7 @@
/*
* File: libdos.cc
* Summary: Functions for DOS support.
+ * Needed by makefile.dos.
* Written by: Darshan Shaligram
*
* Added for Crawl Reference by dshaligram on Wed Nov 22 08:41:20 2006 UTC
diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc
index 751392004e..0bb75f5b96 100644
--- a/crawl-ref/source/libgui.cc
+++ b/crawl-ref/source/libgui.cc
@@ -1,6 +1,7 @@
/*
* File: libgui.cc
* Summary: Functions that any display port needs to implement.
+ * Needed by makefile_tiles.mgw and makefile_tiles.unix.
* Written by: M.Itakura
*
* Modified for Crawl Reference by $Author$ on $Date$
@@ -92,8 +93,8 @@ void gui_init_view_params(crawl_view_geometry &geom)
geom.msgp.x = 1;
geom.msgp.y = 1;
- geom.mlistp.x = 1;
- geom.mlistp.y = 1;
+ geom.mlistp.x = 1;
+ geom.mlistp.y = 1;
geom.mlistsz.x = 0;
geom.mlistsz.y = 0;
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index f140f28061..830f03edcb 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -1,6 +1,7 @@
/*
* File: libunix.cc
* Summary: Functions for unix and curses support
+ * Needed by makefile.unix.
* Written by: ?
*
* Modified for Crawl Reference by $Author$ on $Date$
diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc
index 40d94ea467..ef456090a4 100644
--- a/crawl-ref/source/libw32c.cc
+++ b/crawl-ref/source/libw32c.cc
@@ -5,7 +5,8 @@ REVISION("$Rev$");
/*
* File: libw32c.cc
- * Summary: Functions for windows32 console mode support
+ * Summary: Functions for windows32 console mode support.
+ * Needed by makefile.mgw.
* Written by: Gordon Lipford
*
* Modified for Crawl Reference by $Author$ on $Date$
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index e2a907f5f0..cfc4ab768b 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -212,6 +212,8 @@ Menu::~Menu()
for (int i = 0, count = items.size(); i < count; ++i)
delete items[i];
delete title;
+ if (title2)
+ delete title2;
delete highlighter;
delete mdisplay;
}
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index b64acfb9dd..e5606cd39c 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -52,6 +52,10 @@ public:
text(""), repeats(0)
{
}
+
+ ~message_item()
+ {
+ }
};
// Circular buffer for keeping past messages.
@@ -76,7 +80,8 @@ static unsigned char prepare_message(const std::string& imsg,
namespace msg
{
- std::ostream stream(new mpr_stream_buf(MSGCH_PLAIN));
+ mpr_stream_buf* msbuf = new mpr_stream_buf(MSGCH_PLAIN);
+ std::ostream stream(msbuf);
std::vector<std::ostream*> stream_ptrs;
std::vector<mpr_stream_buf*> stream_buffers;
@@ -103,6 +108,7 @@ namespace msg
void deinitialise_mpr_streams()
{
+ delete msbuf;
for (unsigned int i = 0; i < stream_ptrs.size(); ++i)
delete stream_ptrs[i];
stream_ptrs.clear();
@@ -1371,8 +1377,6 @@ void replay_messages(void)
}
}
}
-
- return;
} // end replay_messages()
void set_msg_dump_file(FILE* file)
diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h
index 86474a585e..f82741b0b9 100644
--- a/crawl-ref/source/message.h
+++ b/crawl-ref/source/message.h
@@ -109,6 +109,7 @@ namespace msg
{
public:
mpr_stream_buf(msg_channel_type chan);
+ virtual ~mpr_stream_buf() {};
void set_param(int p);
void set_muted(bool m);
protected:
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index e168fcd94c..2b147050d4 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -3219,6 +3219,7 @@ static bool _read_player_name( char *name, int len,
return (true);
}
}
+
// Go back and prompt the user.
}
}
@@ -3275,12 +3276,13 @@ static void _enter_player_name(bool blankOK)
// If the player wants out, we bail out.
if (!_read_player_name(name, kNameLen, existing_chars, char_menu))
end(0);
-
+#if 0
#ifdef USE_TILE
+ // What's this supposed to achieve? (jpeg)
clrscr();
cgotoxy(1, 1);
#endif
-
+#endif
// Laboriously trim the damn thing.
std::string read_name = name;
trim_string(read_name);
@@ -3289,7 +3291,7 @@ static void _enter_player_name(bool blankOK)
}
}
while (ask_name = !_is_good_name(you.your_name, blankOK, true));
-} // end enter_player_name()
+}
static bool _validate_player_name(bool verbose)
{
@@ -3316,7 +3318,7 @@ bool validate_player_name(const char* name, bool verbose)
char c = *pn;
// Note that this includes systems which may be using the
// packaging system. The packaging system is very simple
- // and doesn't take the time to escape every characters that
+ // and doesn't take the time to escape every character that
// might be a problem for some random shell or OS... so we
// play it very conservative here. -- bwr
if (!isalnum(c) && c != '-' && c != '.' && c != '_' && c != ' ')
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 6359f10f42..4fb4d9234f 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -9,6 +9,7 @@
#include "AppHdr.h"
REVISION("$Rev$");
+#include "beam.h"
#include "cio.h"
#include "database.h"
#include "directn.h"
@@ -734,10 +735,17 @@ void cio_cleanup()
#endif
msg::deinitialise_mpr_streams();
-
+ clear_globals_on_exit();
crawl_state.io_inited = false;
}
+// Clear some globally defined variables.
+void clear_globals_on_exit()
+{
+ clear_rays_on_exit();
+ clear_zap_info_on_exit();
+}
+
void end(int exit_code, bool print_error, const char *format, ...)
{
std::string error = print_error? strerror(errno) : "";
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index 4104825dbe..96d54af6e6 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -134,6 +134,7 @@ int fuzz_value(int val, int lowfuzz, int highfuzz, int naverage = 2);
void cio_init();
void cio_cleanup();
+void clear_globals_on_exit();
void end(int exit_code, bool print_err = false,
const char *message = NULL, ...);
diff --git a/crawl-ref/source/tilefont.cc b/crawl-ref/source/tilefont.cc
index 63583a82eb..be531595ee 100644
--- a/crawl-ref/source/tilefont.cc
+++ b/crawl-ref/source/tilefont.cc
@@ -89,23 +89,21 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
// Get maximum advance
m_max_advance = coord_def(0,0);
- int ascender = face->ascender >> 6;
- int min_y = 100000;
- int max_y = 0;
+ int ascender = face->ascender >> 6;
+ int min_y = 100000;
+ int max_y = 0;
int max_width = 0;
- m_min_offset = 0;
- m_glyphs = new GlyphInfo[256];
+ m_min_offset = 0;
+ m_glyphs = new GlyphInfo[256];
for (unsigned int c = 0; c < 256; c++)
{
- m_glyphs[c].offset = 0;
+ m_glyphs[c].offset = 0;
m_glyphs[c].advance = 0;
m_glyphs[c].renderable = false;
FT_Int glyph_index = FT_Get_Char_Index(face, c);
if (!glyph_index)
- {
continue;
- }
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER);
ASSERT(!error);
@@ -116,13 +114,13 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
m_max_advance.x = std::max(m_max_advance.x, advance);
- int bmp_width = bmp->width;
- int bmp_top = ascender - face->glyph->bitmap_top;
+ int bmp_width = bmp->width;
+ int bmp_top = ascender - face->glyph->bitmap_top;
int bmp_bottom = ascender + bmp->rows - face->glyph->bitmap_top;
if (outl)
{
- bmp_width += 2;
- bmp_top -= 1;
+ bmp_width += 2;
+ bmp_top -= 1;
bmp_bottom += 1;
}
@@ -130,9 +128,9 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
min_y = std::min(min_y, bmp_top);
max_y = std::max(max_y, bmp_bottom);
- m_glyphs[c].offset = face->glyph->bitmap_left;
+ m_glyphs[c].offset = face->glyph->bitmap_left;
m_glyphs[c].advance = advance;
- m_glyphs[c].width = bmp_width;
+ m_glyphs[c].width = bmp_width;
m_min_offset = std::min((char)m_min_offset, m_glyphs[c].offset);
}
@@ -142,9 +140,9 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
// heights on the characters we care about to get better values for the
// text height and the ascender.
m_max_advance.y = max_y - min_y;
- ascender -= min_y;
+ ascender -= min_y;
- int max_height = m_max_advance.y;
+ int max_height = m_max_advance.y;
// Grow character size to power of 2
coord_def charsz(1,1);
@@ -157,8 +155,8 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
// Having to blow out 8-bit alpha values into full 32-bit textures is
// kind of frustrating, but not all OpenGL implementations support the
// "esoteric" ALPHA8 format and it's not like this texture is very large.
- unsigned int width = 16 * charsz.x;
- unsigned int height = 16 * charsz.y;
+ unsigned int width = 16 * charsz.x;
+ unsigned int height = 16 * charsz.y;
unsigned char *pixels = new unsigned char[4 * width * height];
memset(pixels, 0, sizeof(unsigned char) * 4 * width * height);
@@ -214,7 +212,7 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
{
bool x_valid = x >= 0 && x < bmp->width;
bool y_valid = y >= 0 && y < bmp->rows;
- bool valid = x_valid && y_valid;
+ bool valid = x_valid && y_valid;
unsigned char orig = valid ? bmp->buffer[x + charw * y] : 0;
unsigned char edge = 0;
@@ -224,7 +222,7 @@ bool FTFont::load_font(const char *font_name, unsigned int font_size, bool outl)
edge = std::max(bmp->buffer[x + charw * (y-1)], edge);
if (y_valid && x < bmp->width - 1)
edge = std::max(bmp->buffer[(x+1) + charw * y], edge);
- if (x_valid && y < bmp->width - 1)
+ if (x_valid && y < bmp->rows - 1)
edge = std::max(bmp->buffer[x + charw * (y+1)], edge);
unsigned int idx = offset_x+x+1 + (offset_y+y+1) * width;
@@ -462,10 +460,9 @@ unsigned int FTFont::string_height(const char *text)
{
int height = 1;
for (const char *itr = text; (*itr); itr++)
- {
if (*itr == '\n')
height++;
- }
+
return char_height() * height;
}
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index a3879ab2a1..b7ee5377c7 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -10,6 +10,7 @@
#include "AppHdr.h"
REVISION("$Rev$");
+#include <cmath>
#include "cio.h"
#include "debug.h"
#include "describe.h"
@@ -428,7 +429,7 @@ void DungeonRegion::pack_doll(const dolls_data &doll, int x, int y)
TILEP_PART_HAIR,
TILEP_PART_BEARD,
TILEP_PART_HELM,
- TILEP_PART_DRCHEAD // 15
+ TILEP_PART_DRCHEAD // 15
};
int flags[TILEP_PART_MAX];
@@ -1194,7 +1195,7 @@ void DungeonRegion::add_text_tag(text_tag_type type, const std::string &tag,
{
TextTag t;
t.tag = tag;
- t.gc = gc;
+ t.gc = gc;
m_tags[type].push_back(t);
}
@@ -1243,6 +1244,7 @@ InventoryRegion::InventoryRegion(ImageManager* im, FTFont *tag_font,
InventoryRegion::~InventoryRegion()
{
delete[] m_flavour;
+ m_flavour = NULL;
}
void InventoryRegion::clear()
@@ -1364,9 +1366,12 @@ void InventoryRegion::pack_buffers()
if (item.flag & TILEI_FLAG_FLOOR)
{
+ if (i >= (unsigned int) mx * my)
+ break;
+
int num_floor = tile_dngn_count(env.tile_default.floor);
m_buf_dngn.add(env.tile_default.floor
- + m_flavour[i] % num_floor, x, y);
+ + m_flavour[i] % num_floor, x, y);
}
else
m_buf_dngn.add(TILE_ITEM_SLOT, x, y);
@@ -2166,8 +2171,8 @@ TextRegion::TextRegion(FTFont *font) :
void TextRegion::on_resize()
{
- delete cbuf;
- delete abuf;
+ delete[] cbuf;
+ delete[] abuf;
int size = mx * my;
cbuf = new unsigned char[size];
@@ -2295,13 +2300,14 @@ void TextRegion::cgotoxy(int x, int y)
print_x = x-1;
print_y = y-1;
+#if 0
if (cursor_region != NULL && cursor_flag)
{
cursor_x = -1;
cursor_y = -1;
cursor_region = NULL;
}
-
+#endif
if (cursor_flag)
{
cursor_x = print_x;
@@ -2461,7 +2467,7 @@ void MessageRegion::render()
{
idx = cursor_x + mx * cursor_y;
char_back = cbuf[idx];
- col_back = abuf[idx];
+ col_back = abuf[idx];
cbuf[idx] = '_';
abuf[idx] = WHITE;
@@ -2663,7 +2669,7 @@ void MenuRegion::place_entries()
continue;
}
- if (height + max_entry_height > end_height)
+ if (height + max_entry_height > end_height && column <= max_columns)
{
height = 0;
column++;
@@ -2715,6 +2721,8 @@ void MenuRegion::place_entries()
int text_sy = m_entries[i].sy;
text_sy += (entry_height - m_font_entry->char_height()) / 2;
+ // Split menu entries that don't fit into a single lines into two
+ // lines.
if (Options.tile_menu_icons
&& text_sx + text_width > entry_start + column_width)
{
@@ -2848,7 +2856,7 @@ int MenuRegion::maxpagesize() const
// Similar to the definition of max_entry_height in place_entries().
const int div = (Options.tile_menu_icons ? 32
- : m_font_entry->char_height());
+ : m_font_entry->char_height() + 1);
const int pagesize = ((my - more_height) / div) * m_max_columns;
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index e112c7cc34..9ba2f854df 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -351,8 +351,6 @@ bool TilesFramework::initialise()
int TilesFramework::load_font(const char *font_file, int font_size,
bool default_on_fail, bool outline)
{
- FTFont *font = new FTFont();
-
for (unsigned int i = 0; i < m_fonts.size(); i++)
{
font_info &finfo = m_fonts[i];
@@ -363,6 +361,8 @@ int TilesFramework::load_font(const char *font_file, int font_size,
}
}
+ FTFont *font = new FTFont();
+
if (!font->load_font(font_file, font_size, outline))
{
delete font;
@@ -373,9 +373,9 @@ int TilesFramework::load_font(const char *font_file, int font_size,
}
font_info finfo;
+ finfo.font = font;
finfo.name = font_file;
finfo.size = font_size;
- finfo.font = font;
finfo.outline = outline;
m_fonts.push_back(finfo);
@@ -744,7 +744,7 @@ int TilesFramework::getch_ck()
int key = 0;
- const unsigned int ticks_per_redraw = 50;
+ const unsigned int ticks_per_redraw = 80;
unsigned int last_redraw_tick = 0;
unsigned int res = Options.tile_tooltip_ms;
diff --git a/crawl-ref/source/tiletex.cc b/crawl-ref/source/tiletex.cc
index 9f01a25456..faaf20f5b0 100644
--- a/crawl-ref/source/tiletex.cc
+++ b/crawl-ref/source/tiletex.cc
@@ -198,15 +198,13 @@ bool GenericTexture::load_texture(const char *filename,
bool success = false;
if (!proc || proc(pixels, new_width, new_height))
- {
success |= load_texture(pixels, new_width, new_height, mip_opt);
- }
// If conversion has occurred, delete converted data.
if (pixels != img->pixels)
- delete pixels;
+ delete[] pixels;
- m_orig_width = img->w;
+ m_orig_width = img->w;
m_orig_height = img->h;
SDL_FreeSurface(img);
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 7384954294..ec151ae053 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -1838,8 +1838,8 @@ const int sh_yo = 9;
int los_radius_squared = 8*8 + 1;
unsigned long* los_blockrays = NULL;
-unsigned long* dead_rays = NULL;
-unsigned long* smoke_rays = NULL;
+unsigned long* dead_rays = NULL;
+unsigned long* smoke_rays = NULL;
std::vector<short> ray_coord_x;
std::vector<short> ray_coord_y;
std::vector<short> compressed_ray_x;
@@ -1847,6 +1847,13 @@ std::vector<short> compressed_ray_y;
std::vector<int> raylengths;
std::vector<ray_def> fullrays;
+void clear_rays_on_exit()
+{
+ delete[] dead_rays;
+ delete[] smoke_rays;
+ delete[] los_blockrays;
+}
+
void setLOSRadius(int newLR)
{
los_radius_squared = newLR * newLR + 1*1;
@@ -2355,9 +2362,9 @@ static void _create_blockrays()
int cur_offset = 0;
- for ( unsigned int ray = 0; ray < raylengths.size(); ++ray )
+ for (unsigned int ray = 0; ray < raylengths.size(); ++ray)
{
- for ( int i = 0; i < raylengths[ray]; ++i )
+ for (int i = 0; i < raylengths[ray]; ++i)
{
// every cell blocks...
unsigned long* const inptr = full_los_blockrays +
@@ -2365,7 +2372,7 @@ static void _create_blockrays()
ray_coord_y[i + cur_offset]) * num_words;
// ...all following cellrays
- for ( int j = i+1; j < raylengths[ray]; ++j )
+ for (int j = i+1; j < raylengths[ray]; ++j)
_set_bit_in_long_array( inptr, j + cur_offset );
}
@@ -2383,18 +2390,18 @@ static void _create_blockrays()
// we want to only keep the cellrays from nondupe_cellrays.
compressed_ray_x.resize(num_nondupe_rays);
compressed_ray_y.resize(num_nondupe_rays);
- for ( unsigned int i = 0; i < num_nondupe_rays; ++i )
+ for (unsigned int i = 0; i < num_nondupe_rays; ++i)
{
compressed_ray_x[i] = ray_coord_x[nondupe_cellrays[i]];
compressed_ray_y[i] = ray_coord_y[nondupe_cellrays[i]];
}
unsigned long* oldptr = full_los_blockrays;
unsigned long* newptr = los_blockrays;
- for ( int x = 0; x <= LOS_MAX_RANGE_X; ++x )
- for ( int y = 0; y <= LOS_MAX_RANGE_Y; ++y )
+ for (int x = 0; x <= LOS_MAX_RANGE_X; ++x)
+ for (int y = 0; y <= LOS_MAX_RANGE_Y; ++y)
{
- for ( unsigned int i = 0; i < num_nondupe_rays; ++i )
- if ( get_bit_in_long_array(oldptr, nondupe_cellrays[i]) )
+ for (unsigned int i = 0; i < num_nondupe_rays; ++i)
+ if (get_bit_in_long_array(oldptr, nondupe_cellrays[i]))
_set_bit_in_long_array(newptr, i);
oldptr += num_words;
@@ -2402,9 +2409,9 @@ static void _create_blockrays()
}
// we can throw away full_los_blockrays now
- delete [] full_los_blockrays;
+ delete[] full_los_blockrays;
- dead_rays = new unsigned long[num_nondupe_words];
+ dead_rays = new unsigned long[num_nondupe_words];
smoke_rays = new unsigned long[num_nondupe_words];
#ifdef DEBUG_DIAGNOSTICS
@@ -2416,7 +2423,7 @@ static void _create_blockrays()
static int _gcd( int x, int y )
{
int tmp;
- while ( y != 0 )
+ while (y != 0)
{
x %= y;
tmp = x;
@@ -2436,7 +2443,7 @@ bool complexity_lt( const std::pair<int,int>& lhs,
void raycast()
{
static bool done_raycast = false;
- if ( done_raycast )
+ if (done_raycast)
return;
// Creating all rays for first quadrant
@@ -2896,7 +2903,7 @@ void losight(env_show_grid &sh,
// block rays which have already seen a cloud
for (unsigned int i = 0; i < num_words; ++i)
{
- dead_rays[i] |= (smoke_rays[i] & inptr[i]);
+ dead_rays[i] |= (smoke_rays[i] & inptr[i]);
smoke_rays[i] |= inptr[i];
}
}
@@ -2934,6 +2941,10 @@ void losight(env_show_grid &sh,
// [dshaligram] The player's current position is always visible.
sh[sh_xo][sh_yo] = gr[x_p][y_p];
+
+ *dead_rays = NULL;
+ *smoke_rays = NULL;
+ *los_blockrays = NULL;
}
@@ -5743,7 +5754,8 @@ void crawl_view_geometry::set_player_at(const coord_def &c, bool centre)
void crawl_view_geometry::init_geometry()
{
termsz = coord_def( get_number_of_cols(), get_number_of_lines() );
- hudsz = coord_def(HUD_WIDTH, HUD_HEIGHT + (Options.show_gold_turns ? 1 : 0));
+ hudsz = coord_def(HUD_WIDTH,
+ HUD_HEIGHT + (Options.show_gold_turns ? 1 : 0));
const _inline_layout lay_inline(termsz, hudsz);
const _mlist_col_layout lay_mlist(termsz, hudsz);
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index 3210182862..2d7b495696 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -70,6 +70,7 @@ bool mon_enemies_around(const monsters *monster);
void find_features(const std::vector<coord_def>& features,
unsigned char feature, std::vector<coord_def> *found);
+void clear_rays_on_exit();
void losight(env_show_grid &sh, feature_grid &gr,
const coord_def& center, bool clear_walls_block = false,
bool ignore_clouds = false);