Attached Files |
0001-Changes-for-Mantis-4339.patch [^] (2,289 bytes) 2011-08-04 01:38 [Show Content] [Hide Content]From 86bd182df069ecf722679ce65952cdf6005f3fd8 Mon Sep 17 00:00:00 2001
From: blueDave <dshackspam@comcast.net>
Date: Wed, 3 Aug 2011 16:18:01 -0700
Subject: [PATCH] Changes for Mantis 4339
---
crawl-ref/source/colour.h | 1 +
crawl-ref/source/l_colour.cc | 5 +++++
crawl-ref/source/main.cc | 11 +++++++++++
3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/crawl-ref/source/colour.h b/crawl-ref/source/colour.h
index 034c4aa..d5db0d1 100644
--- a/crawl-ref/source/colour.h
+++ b/crawl-ref/source/colour.h
@@ -86,6 +86,7 @@ unsigned int str_to_tile_colour(std::string colour);
void init_element_colours();
void add_element_colour(element_colour_calc *colour);
void clear_colours_on_exit();
+void reset_next_colour();
uint8_t random_colour();
uint8_t random_uncommon_colour();
bool is_low_colour(uint8_t colour);
diff --git a/crawl-ref/source/l_colour.cc b/crawl-ref/source/l_colour.cc
index 78955bf..f22780a 100644
--- a/crawl-ref/source/l_colour.cc
+++ b/crawl-ref/source/l_colour.cc
@@ -43,6 +43,11 @@ int lua_element_colour_calc::get(const coord_def& loc, bool non_random)
static int next_colour = ETC_FIRST_LUA;
+void reset_next_colour()
+{
+ next_colour = ETC_FIRST_LUA;
+}
+
static int _lua_element_colour(int rand, const coord_def& loc,
lua_datum function)
{
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index ee54671..9b7768d 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -181,6 +181,7 @@ const struct coord_def Compass[8] =
};
// Functions in main module
+static void _reinit_static_variables(); /* mantis 4339 */
static void _launch_game_loop();
static void _launch_game();
@@ -292,6 +293,15 @@ int main(int argc, char *argv[])
return 0;
}
+
+static void _reinit_static_variables()
+{
+ // when starting a new game after death or exit, reinit some statics
+ // which cause crashes if allowed to grow indefinitely mantis 4339
+
+ reset_next_colour();
+}
+
static void _reset_game()
{
clrscr();
@@ -314,6 +324,7 @@ static void _reset_game()
crawl_state.title_screen = false;
tiles.clear_text_tags(TAG_NAMED_MONSTER);
#endif
+ _reinit_static_variables();
}
static void _launch_game_loop()
--
1.7.5.GIT
|