Skip to content

Commit

Permalink
bug: fix hang on choosing player name
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jun 16, 2023
1 parent 6be9ff9 commit 40bb18f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 55 deletions.
3 changes: 3 additions & 0 deletions build/windows/windows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
<distributionFile>
<origin>C:/msys64/home/neila/zorbash/build/windows/zorbash.ico</origin>
</distributionFile>
<distributionFile>
<origin>C:/msys64/ucrt64/bin/libunwind.dll</origin>
</distributionFile>
<distributionFile>
<origin>C:/msys64/ucrt64/bin/libmpg123-0.dll</origin>
</distributionFile>
Expand Down
25 changes: 0 additions & 25 deletions src/gauss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,3 @@ double gaussrand(double mean, double stddev)

return val;
}

double gauss(const double m, const double s)
{
static int use_last = 0;
static double y2;
double x1, x2, w, y1;

if (use_last) {
y1 = y2;
} else {
do { // ming don't have random
x1 = 2.0 * ((double) non_pcg_rand() / (double) (((uint32_t) -1))) - 1.0;
x2 = 2.0 * ((double) non_pcg_rand() / (double) (((uint32_t) -1))) - 1.0;
w = x1 * x1 + x2 * x2;
} while (w >= 1.0);

w = sqrt((-2.0 * log(w)) / w);
y1 = x1 * w;
y2 = x2 * w;
}

use_last = ! use_last;

return (m + y1 * s);
}
1 change: 0 additions & 1 deletion src/my_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#ifndef _MY_MATH_UTIL_HPP_
#define _MY_MATH_UTIL_HPP_

double gauss(const double m, const double s);
double gaussrand(double mean, double stddev);

#ifdef __APPLE__
Expand Down
4 changes: 3 additions & 1 deletion src/wid_choose_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ static Widp wid_keyboard_wid_choose_player_name;

static void selected(Widp w, const std::wstring &text)
{
std::string s = wstring_to_string(text);
CON("INF: choose name [%s]", s.c_str());
wid_destroy(&wid_keyboard_wid_choose_player_name);
g_opt_player_name = wstring_to_string(text);
g_opt_player_name = s;
game->save_config();
game->wid_main_menu_select();
}
Expand Down
28 changes: 0 additions & 28 deletions src/wid_keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,33 +721,6 @@ static void wid_keyboard_tick(Widp w)
}
}

static void wid_keyboard_destroy_begin(Widp w)
{
TRACE_AND_INDENT();
wid_keyboard_ctx *ctx = (wid_keyboard_ctx *) wid_get_void_context(w);
verify(MTYPE_MISC, ctx);

/*
* Zoom buttons in
*/
int x, y;

for (x = 0; x < WID_KEYBOARD_ACROSS; x++) {
for (y = 0; y < WID_KEYBOARD_DOWN; y++) {

Widp b = ctx->buttons[ y ][ x ];

float x = gauss(0.0, 2.0);
float y = gauss(0.0, 2.0);

x *= TERM_WIDTH;
y *= TERM_HEIGHT;

wid_move_to_pct_centered_in(b, x, y, 500);
}
}
}

static void wid_keyboard_bg_tick(Widp w)
{
TRACE_AND_INDENT();
Expand Down Expand Up @@ -802,7 +775,6 @@ Widp wid_keyboard(const std::wstring &text, const std::wstring &title, wid_keybo

wid_set_pos(window, tl, br);
wid_set_style(window, UI_WID_STYLE_NORMAL);
wid_set_on_destroy_begin(window, wid_keyboard_destroy_begin);
wid_set_on_key_down(window, wid_keyboard_parent_key_down);
wid_set_on_joy_button(window, wid_keyboard_parent_joy_button);
wid_set_on_destroy(window, wid_keyboard_destroy);
Expand Down

0 comments on commit 40bb18f

Please sign in to comment.