Increase precision of mode_countdown_ handling (#52)

* fix harmless warnings and properly try/catch allocations via new

otherwise the error handling will never be triggered

* increase precision of mode_countdown_ handling

potentially there could be modes running a bit too long, depending on passed in ms (which were implicitly truncated before when passing in)

also fix some harmless warnings

* document warnings that i cannot handle on my own

* revert changes to have a new cleaner PR after review/cherry picks

* increase precision of mode_countdown_ handling

potentially there could be modes running a bit too long, depending on passed in ms (which were implicitly truncated before when passing in)

also fix some harmless warnings and add comments where original code is 'correct' but weird
This commit is contained in:
toxie authored and GitHub committed 2021-10-23 07:33:04 +03:00
1 parent 8e07b7fc3f
commit 57af3af800
14 files changed
+27 -28

No files matched your search

+4 -4
View File
@@ -180,7 +180,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
if (!gfr_display)
{
auto plt = static_cast<ColorRgba*>(malloc(1024u));
auto pltPtr = &plt[10];
auto pltPtr = &plt[10]; // first 10 entries are system colors hardcoded in display_palette()
for (int i1 = 0, i2 = 0; i1 < 256 - 10; ++i1, i2 += 8)
{
unsigned char blue = i2, redGreen = i2;
@@ -215,8 +215,8 @@ int winmain::WinMain(LPCSTR lpCmdLine)
int x, y, w, h;
SDL_GetMouseState(&x, &y);
SDL_GetWindowSize(window, &w, &h);
float dx = (last_mouse_x - x) / static_cast<float>(w);
float dy = (y - last_mouse_y) / static_cast<float>(h);
float dx = static_cast<float>(last_mouse_x - x) / static_cast<float>(w);
float dy = static_cast<float>(y - last_mouse_y) / static_cast<float>(h);
pb::ballset(dx, dy);
SDL_WarpMouseInWindow(window, last_mouse_x, last_mouse_y);
@@ -655,7 +655,7 @@ int winmain::event_handler(const SDL_Event* event)
pb::frame(10);
break;
case SDLK_F10:
single_step = single_step == 0;
single_step = (single_step == 0) ? 1 : 0;
if (single_step == 0)
no_time_loss = 1;
break;