summaryrefslogtreecommitdiff
path: root/genworld_gui.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-01 22:46:10 +0000
committerrubidium <rubidium@openttd.org>2007-01-01 22:46:10 +0000
commite6c7d9f9e8cac64581df66b6091f013772acf93d (patch)
tree66bec0dc6f6af9c99c8bae478beef45d1e81f515 /genworld_gui.c
parent68fcccb6343994f196c68ec2979b0a403c82d40d (diff)
downloadopenttd-e6c7d9f9e8cac64581df66b6091f013772acf93d.tar.xz
(svn r7733) -Fix (r5946): do not use WP(w, querystr_d) and WP(w, def_d) for the same window.
Diffstat (limited to 'genworld_gui.c')
-rw-r--r--genworld_gui.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/genworld_gui.c b/genworld_gui.c
index 2519a67fd..bbd0cb31b 100644
--- a/genworld_gui.c
+++ b/genworld_gui.c
@@ -43,7 +43,6 @@ typedef enum glwp_modes {
GLWP_END
} glwp_modes;
-static char _edit_str_buf[LEN_RND_SEED];
static uint _heightmap_x = 0;
static uint _heightmap_y = 0;
static StringID _heightmap_str = STR_NULL;
@@ -193,11 +192,22 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
static const StringID num_towns[] = {STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
static const StringID num_inds[] = {STR_26816_NONE, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
+ /* Data used for the generate seed edit box */
+ static querystr_d _genseed_query;
+ static char _genseed_buffer[LEN_RND_SEED];
+
uint mode = w->window_number;
uint y;
switch (e->event) {
- case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + 3); break;
+ case WE_CREATE:
+ LowerWindowWidget(w, _opt_newgame.landscape + 3);
+
+ snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
+ InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120);
+ _genseed_query.caption = STR_NULL;
+ _genseed_query.afilter = CS_NUMERAL;
+ break;
case WE_PAINT:
/* You can't select smoothness if not terragenesis */
@@ -244,7 +254,7 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
}
DrawString( 12, 153 + y, STR_RANDOM_SEED, 0);
- DrawEditBox(w, &WP(w, querystr_d), SEED_EDIT);
+ DrawEditBox(w, &_genseed_query, SEED_EDIT);
DrawString(182, 113 + y, STR_DATE, 0);
SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
@@ -315,8 +325,8 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
break;
case 16: // Random seed
_patches_newgame.generation_seed = InteractiveRandom();
- snprintf(_edit_str_buf, lengthof(_edit_str_buf), "%u", _patches_newgame.generation_seed);
- UpdateTextBufferSize(&WP(w, querystr_d).text);
+ snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
+ UpdateTextBufferSize(&_genseed_query.text);
SetWindowDirty(w);
break;
case 17: // Generate
@@ -385,17 +395,17 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
break;
case WE_MOUSELOOP:
- HandleEditBox(w, &WP(w, querystr_d), SEED_EDIT);
+ HandleEditBox(w, &_genseed_query, SEED_EDIT);
break;
case WE_KEYPRESS:
- HandleEditBoxKey(w, &WP(w, querystr_d), SEED_EDIT, e);
+ HandleEditBoxKey(w, &_genseed_query, SEED_EDIT, e);
/* the seed is unsigned, therefore atoi cannot be used.
* As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
* (use random seed) it should not be possible to be
* entered into the input field; the generate seed
* button can be used instead. */
- _patches_newgame.generation_seed = minu(strtoul(_edit_str_buf, NULL, 10), MAX_UVALUE(uint32) - 1);
+ _patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1);
break;
case WE_DROPDOWN_SELECT:
@@ -503,13 +513,6 @@ static void _ShowGenerateLandscape(glwp_modes mode)
w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
if (w != NULL) {
- querystr_d *querystr = &WP(w, querystr_d);
-
- snprintf(_edit_str_buf, lengthof(_edit_str_buf), "%u", _patches_newgame.generation_seed);
-
- InitializeTextBuffer(&querystr->text, _edit_str_buf, lengthof(_edit_str_buf), 120);
- querystr->caption = STR_NULL;
- querystr->afilter = CS_NUMERAL;
InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
}