Skip to content

Commit

Permalink
Fix bug where intake would sometimes skip handling input text. (#497)
Browse files Browse the repository at this point in the history
Commit 25d638b repurposed the original `cur_char`, which originally
held the input internal keycode. It was changed to instead do nothing
in 0d72581 when SDL_TEXTINPUT handling was implemented, however, the
original exit check prior to text input wasn't removed. Repurposing
this variable reactivated that check and caused some text input fields
to stop accepting input altogether (dependent on data stored in old
board names, or particularly in the SFX editor, uninitialized memory).

Since the check has been dead for a while with fundamentally no
problems, it has been removed entirely. The variable has been renamed
to avoid being shadowed by the new handler, which also uses `cur_char`.
Finally, the SFX string buffers in the SFX editor are cleared now.
  • Loading branch information
AliceLR authored Oct 27, 2024
1 parent b1fed77 commit 72ef2ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ USERS
+ Fixed the board editor show thing hotkeys (broken by 2.93b).
+ Fixed a crash that would occur in builds using extra memory
hacks (DOS) when copying blocks between boards in the editor.
+ Fixed text input bugs caused by a 2.93b change accidentally
reenabling old deadcode for exiting intake().

DEVELOPERS

Expand Down
2 changes: 1 addition & 1 deletion src/editor/sfx_edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ void sfx_edit(struct world *mzx_world)
num_elements = counts[page];
num_sfx = num_elements;

memset(buffers, 0, sizeof(buffers));
for(i = 0, pos = offsets[page]; i < num_sfx; i++, pos++)
{
const struct custom_sfx *sfx = sfx_get(custom_sfx, pos);
buffers[i][0] = '\0';

update_label(sfx, pos, i);
if(sfx)
Expand Down
13 changes: 3 additions & 10 deletions src/intake.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int intake(struct world *mzx_world, char *string, int max_len, int display_len,
int currx, curr_len;
int scrolledx, tmpx;
int done = 0, place = 0;
char cur_char = 0;
char tmp_char;
boolean select_char = false;
int mouse_press;
int action;
Expand Down Expand Up @@ -122,10 +122,10 @@ int intake(struct world *mzx_world, char *string, int max_len, int display_len,
tmpx = display_len;
}

cur_char = string[tmpx];
tmp_char = string[tmpx];
string[tmpx] = '\0';
write_string_ext(string + scrolledx, x, y, color, flags, 0, c_offset);
string[tmpx] = cur_char;
string[tmpx] = tmp_char;

if(curr_len < display_len)
{
Expand Down Expand Up @@ -488,13 +488,6 @@ int intake(struct world *mzx_world, char *string, int max_len, int display_len,
{
int num_placed = 0;

if((cur_char != 0) && (cur_char < 32) && (exit_type == INTK_EXIT_ANY))
{
done = 1;
key = cur_char;
}
else

while((curr_len < max_len) && (!done) && num_placed < KEY_UNICODE_MAX)
{
uint32_t cur_char = get_key(keycode_text_ascii);
Expand Down

0 comments on commit 72ef2ab

Please sign in to comment.