tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

Error: division by zero #657

Closed EvoLandEco closed 1 year ago

EvoLandEco commented 1 year ago

In file color.cpp, lines 58-65

color get_random_respawn_color(std::mt19937& ran_num_gen) noexcept
{
    int r = 1 + ran_num_gen()/((ran_num_gen.max() + 1u)/255);
    int g = 1 + ran_num_gen()/((ran_num_gen.max() + 1u)/255);
    int b = 1 + ran_num_gen()/((ran_num_gen.max() + 1u)/255);

    return color(r, g, b);
}

Build gave this error:

C:\Source\game\src\color.cpp:62: error: division by zero [-Werror=div-by-zero]
..\game\src\color.cpp:62:30: error: division by zero [-Werror=div-by-zero]
     int b = 1 + ran_num_gen()/((ran_num_gen.max() + 1u)/255);
                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Introduced by merging develop into my own branch

richelbilderbeek commented 1 year ago

I saw @TheoPannetier working on this last time. He worked on develop (which is OK: it affects everybody). I'll assign him for now, he can unassign if he thinks I was wrong to do so :-)