diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-11-16 21:05:33 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-11-16 21:25:19 +0100 |
| commit | 5810edaf84707563b452bd0e4b6120909b8ef3ea (patch) | |
| tree | 588d26ae856230d31277bd5c55094167f1f615b8 | |
| parent | f0ff8a508390b0cc809c56297d66dd7a60fd0132 (diff) | |
Fix remaining VS compiler warnings in test programs
| -rw-r--r-- | test/blocks.cxx | 20 | ||||
| -rw-r--r-- | test/editor.cxx | 14 | ||||
| -rw-r--r-- | test/fractals.cxx | 6 |
3 files changed, 20 insertions, 20 deletions
diff --git a/test/blocks.cxx b/test/blocks.cxx index 7faa4c903..75a2a1a09 100644 --- a/test/blocks.cxx +++ b/test/blocks.cxx @@ -60,9 +60,9 @@ // (b) click on a "normal block", destroy this one and adjacent blocks // (c) click on a "bomb", destroy all blocks of the same color -#define LEVEL_FACTOR 0.90 // was: 0.95 -#define NORMAL_FACTOR 0.999 -#define BOMB_FACTOR 0.995 +#define LEVEL_FACTOR 0.900f // was: 0.95 +#define NORMAL_FACTOR 0.999f +#define BOMB_FACTOR 0.995f // Set this to 1 to debug the timer callback (should be 0) #define DEBUG_TIMER 0 @@ -309,8 +309,8 @@ BlockSound::BlockSound() { for (int j = max_sample; j > 0; j --, sample_ptr ++) { float freq = (float)j / (float)max_sample; - float volume = 32767.0 * (0.5 * sqrt(freq) + 0.5); - float sample = 0.0001 * ((rand() % 20001) - 10000); + float volume = float(32767.0 * (0.5 * sqrt(freq) + 0.5)); + float sample = float(0.0001 * ((rand() % 20001) - 10000)); *sample_ptr = (int)(volume * freq * sample + (1.0 - freq) * sample_ptr[-2]); @@ -785,12 +785,12 @@ int BlockWindow::handle(int event) { count --; if (b->bomb) { - sound_->play_explosion(0.19 + 0.005 * count); + sound_->play_explosion(float(0.19 + 0.005 * count)); interval_ *= BOMB_FACTOR; score_ += count; } else { - sound_->play_explosion(0.09 + 0.005 * count); + sound_->play_explosion(float(0.09 + 0.005 * count)); interval_ *= NORMAL_FACTOR; score_ += count * count; @@ -841,11 +841,11 @@ void BlockWindow::init() { // Start a new game... void BlockWindow::new_game() { // Seed the random number generator... - srand(time(NULL)); + srand((unsigned int)time(NULL)); init(); - interval_ = 0.1; + interval_ = 0.1f; opened_columns_ = 0; strcpy(title_, "Level: 1"); @@ -1006,7 +1006,7 @@ void BlockWindow::timeout_cb(BlockWindow *bw) { if (bw->num_columns_ == BLOCK_COLS) { bw->interval_ = -1.0; - bw->sound_->play_explosion(0.8); + bw->sound_->play_explosion(0.8f); bw->play_button_->label("@>"); } else { bw->opened_columns_ ++; diff --git a/test/editor.cxx b/test/editor.cxx index 3170362b3..eb45de7aa 100644 --- a/test/editor.cxx +++ b/test/editor.cxx @@ -658,8 +658,8 @@ void find2_cb(Fl_Widget* w, void* v) { int found = textbuf->search_forward(pos, e->search, &pos); if (found) { // Found a match; select and update the position... - textbuf->select(pos, pos+strlen(e->search)); - e->editor->insert_position(pos+strlen(e->search)); + textbuf->select(pos, pos + (int)strlen(e->search)); + e->editor->insert_position(pos + (int)strlen(e->search)); e->editor->show_insert_position(); } else fl_alert("No occurrences of \'%s\' found!", e->search); @@ -773,11 +773,11 @@ void replace2_cb(Fl_Widget*, void* v) { if (found) { // Found a match; update the position and replace text... - textbuf->select(pos, pos+strlen(find)); + textbuf->select(pos, pos + (int)strlen(find)); textbuf->remove_selection(); textbuf->insert(pos, replace); - textbuf->select(pos, pos+strlen(replace)); - e->editor->insert_position(pos+strlen(replace)); + textbuf->select(pos, pos + (int)strlen(replace)); + e->editor->insert_position(pos + (int)strlen(replace)); e->editor->show_insert_position(); } else fl_alert("No occurrences of \'%s\' found!", find); @@ -807,10 +807,10 @@ void replall_cb(Fl_Widget*, void* v) { if (found) { // Found a match; update the position and replace text... - textbuf->select(pos, pos+strlen(find)); + textbuf->select(pos, pos + (int)strlen(find)); textbuf->remove_selection(); textbuf->insert(pos, replace); - e->editor->insert_position(pos+strlen(replace)); + e->editor->insert_position(pos + (int)strlen(replace)); e->editor->show_insert_position(); times++; } diff --git a/test/fractals.cxx b/test/fractals.cxx index 38ac384d2..bea5bf3d5 100644 --- a/test/fractals.cxx +++ b/test/fractals.cxx @@ -754,11 +754,11 @@ void MenuInit(void) /***************************************************************/ // FLTK-style callbacks to Glut menu callback translators: -void setlevel(Fl_Widget*, void *value) {setlevel(fl_intptr_t(value));} +void setlevel(Fl_Widget*, void *value) {setlevel(fl_int(value));} -void choosefract(Fl_Widget*, void *value) {choosefract(fl_intptr_t(value));} +void choosefract(Fl_Widget*, void *value) {choosefract(fl_int(value));} -void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_intptr_t(value));} +void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_int(value));} #include <FL/Fl_Button.H> #include <FL/Fl_Group.H> |
