fix crash in labyrint when flute is used

This commit is contained in:
Ondrej Novak 2025-02-16 21:13:36 +01:00
parent a8c9fced4c
commit 232dae6708
3 changed files with 8 additions and 2 deletions

View file

@ -415,7 +415,7 @@ static char sing_song_clk(int id,int xa,int ya,int xr,int yr)
playing=0;
if (standardflute)
{
if (fletna_get_buffer_pos())
if (fletna_can_add_timer())
{
THE_TIMER *t;
if (standardflute)

View file

@ -1691,6 +1691,7 @@ void animate_checkbox(int first_id,int last_id,int step);
void fletna_pridej_notu(char note);
void check_fletna(THE_TIMER *t);
char fletna_get_buffer_pos(void);
char fletna_can_add_timer();
void check_global_fletna(THE_TIMER *t);
void fletna_glob_add_note(uint8_t note);

View file

@ -1178,6 +1178,7 @@ void skeldal_soupak(OBJREC *o)
static char fletna_str[13];
static uint8_t pos=0;
static uint8_t minnotes=6;
// C C# D D# E F F# G G# A A# B C
// A B C D E F G H I J K L M
@ -1193,7 +1194,7 @@ void fletna_pridej_notu(char note)
{
note+=65;
fletna_str[pos]=note;
if (pos==countof(fletna_str)) memmove(fletna_str,fletna_str+1,pos-1);
if (pos==countof(fletna_str)-1) memmove(fletna_str,fletna_str+1,pos-1);
else pos++;
}
@ -1263,6 +1264,10 @@ void check_fletna(THE_TIMER *t)
pos=0;
}
char fletna_can_add_timer() {
return pos >=minnotes;
}
char fletna_get_buffer_pos()
{
return pos;